summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Forward.h6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Error.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Error.h25
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.h30
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorPrototype.h20
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp6
8 files changed, 48 insertions, 45 deletions
diff --git a/Userland/Libraries/LibJS/Forward.h b/Userland/Libraries/LibJS/Forward.h
index da0eb5fe27..f2096d0ba6 100644
--- a/Userland/Libraries/LibJS/Forward.h
+++ b/Userland/Libraries/LibJS/Forward.h
@@ -46,7 +46,7 @@
JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES \
__JS_ENUMERATE(TypedArray, typed_array, TypedArrayPrototype, TypedArrayConstructor, void)
-#define JS_ENUMERATE_ERROR_SUBCLASSES \
+#define JS_ENUMERATE_NATIVE_ERRORS \
__JS_ENUMERATE(EvalError, eval_error, EvalErrorPrototype, EvalErrorConstructor, void) \
__JS_ENUMERATE(InternalError, internal_error, InternalErrorPrototype, InternalErrorConstructor, void) \
__JS_ENUMERATE(InvalidCharacterError, invalid_character_error, InvalidCharacterErrorPrototype, InvalidCharacterErrorConstructor, void) \
@@ -75,7 +75,7 @@
#define JS_ENUMERATE_BUILTIN_TYPES \
JS_ENUMERATE_NATIVE_OBJECTS \
- JS_ENUMERATE_ERROR_SUBCLASSES \
+ JS_ENUMERATE_NATIVE_ERRORS \
JS_ENUMERATE_TYPED_ARRAYS
#define JS_ENUMERATE_WELL_KNOWN_SYMBOLS \
@@ -160,7 +160,7 @@ struct ClampedU8;
class ConstructorName; \
class PrototypeName;
JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES
-JS_ENUMERATE_ERROR_SUBCLASSES
+JS_ENUMERATE_NATIVE_ERRORS
JS_ENUMERATE_TYPED_ARRAYS
#undef __JS_ENUMERATE
diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp
index 88cc732e7e..081077463f 100644
--- a/Userland/Libraries/LibJS/Runtime/Error.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Error.cpp
@@ -43,7 +43,7 @@ Error::Error(Object& prototype)
{ \
}
-JS_ENUMERATE_ERROR_SUBCLASSES
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/Error.h b/Userland/Libraries/LibJS/Runtime/Error.h
index 212630fbff..c0fe793035 100644
--- a/Userland/Libraries/LibJS/Runtime/Error.h
+++ b/Userland/Libraries/LibJS/Runtime/Error.h
@@ -22,19 +22,22 @@ public:
virtual ~Error() override = default;
};
-#define DECLARE_ERROR_SUBCLASS(ClassName, snake_name, PrototypeName, ConstructorName) \
- class ClassName final : public Error { \
- JS_OBJECT(ClassName, Error); \
- \
- public: \
- static ClassName* create(GlobalObject&, const String& message = {}); \
- \
- explicit ClassName(Object& prototype); \
- virtual ~ClassName() override = default; \
+// NOTE: Making these inherit from Error is not required by the spec but
+// our way of implementing the [[ErrorData]] internal slot, which is
+// used in Object.prototype.toString().
+#define DECLARE_NATIVE_ERROR(ClassName, snake_name, PrototypeName, ConstructorName) \
+ class ClassName final : public Error { \
+ JS_OBJECT(ClassName, Error); \
+ \
+ public: \
+ static ClassName* create(GlobalObject&, const String& message = {}); \
+ \
+ explicit ClassName(Object& prototype); \
+ virtual ~ClassName() override = default; \
};
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- DECLARE_ERROR_SUBCLASS(ClassName, snake_name, PrototypeName, ConstructorName)
-JS_ENUMERATE_ERROR_SUBCLASSES
+ DECLARE_NATIVE_ERROR(ClassName, snake_name, PrototypeName, ConstructorName)
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index ffd20b75c7..f7eae02791 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -73,7 +73,7 @@ Value ErrorConstructor::construct(Function&)
return ClassName::create(global_object(), message); \
}
-JS_ENUMERATE_ERROR_SUBCLASSES
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
index a3a5c19cb5..71fd400b6f 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
@@ -26,24 +26,24 @@ private:
virtual bool has_constructor() const override { return true; }
};
-#define DECLARE_ERROR_SUBCLASS_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
- class ConstructorName final : public NativeFunction { \
- JS_OBJECT(ConstructorName, NativeFunction); \
- \
- public: \
- explicit ConstructorName(GlobalObject&); \
- virtual void initialize(GlobalObject&) override; \
- virtual ~ConstructorName() override; \
- virtual Value call() override; \
- virtual Value construct(Function& new_target) override; \
- \
- private: \
- virtual bool has_constructor() const override { return true; } \
+#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
+ class ConstructorName final : public NativeFunction { \
+ JS_OBJECT(ConstructorName, NativeFunction); \
+ \
+ public: \
+ explicit ConstructorName(GlobalObject&); \
+ virtual void initialize(GlobalObject&) override; \
+ virtual ~ConstructorName() override; \
+ virtual Value call() override; \
+ virtual Value construct(Function& new_target) override; \
+ \
+ private: \
+ virtual bool has_constructor() const override { return true; } \
};
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- DECLARE_ERROR_SUBCLASS_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName)
-JS_ENUMERATE_ERROR_SUBCLASSES
+ DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName)
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
index a474dd10c4..c12dca2d9d 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
@@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
define_property(vm.names.message, js_string(vm, ""), attr); \
}
-JS_ENUMERATE_ERROR_SUBCLASSES
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h
index 0e938648fa..081a19666c 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h
@@ -22,19 +22,19 @@ private:
JS_DECLARE_NATIVE_FUNCTION(to_string);
};
-#define DECLARE_ERROR_SUBCLASS_PROTOTYPE(ClassName, snake_name, PrototypeName, ConstructorName) \
- class PrototypeName final : public Object { \
- JS_OBJECT(PrototypeName, Object); \
- \
- public: \
- explicit PrototypeName(GlobalObject&); \
- virtual void initialize(GlobalObject&) override; \
- virtual ~PrototypeName() override = default; \
+#define DECLARE_NATIVE_ERROR_PROTOTYPE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ class PrototypeName final : public Object { \
+ JS_OBJECT(PrototypeName, Object); \
+ \
+ public: \
+ explicit PrototypeName(GlobalObject&); \
+ virtual void initialize(GlobalObject&) override; \
+ virtual ~PrototypeName() override = default; \
};
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- DECLARE_ERROR_SUBCLASS_PROTOTYPE(ClassName, snake_name, PrototypeName, ConstructorName)
-JS_ENUMERATE_ERROR_SUBCLASSES
+ DECLARE_NATIVE_ERROR_PROTOTYPE(ClassName, snake_name, PrototypeName, ConstructorName)
+JS_ENUMERATE_NATIVE_ERRORS
#undef __JS_ENUMERATE
}
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index 8d162b2f15..1f6f251aaf 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -151,7 +151,7 @@ void GlobalObject::initialize_global_object()
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
add_constructor(vm.names.ClassName, m_##snake_name##_constructor, m_##snake_name##_prototype);
- JS_ENUMERATE_ERROR_SUBCLASSES
+ JS_ENUMERATE_NATIVE_ERRORS
JS_ENUMERATE_TYPED_ARRAYS
#undef __JS_ENUMERATE
}
@@ -172,7 +172,7 @@ void GlobalObject::visit_edges(Visitor& visitor)
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
visitor.visit(m_##snake_name##_constructor); \
visitor.visit(m_##snake_name##_prototype);
- JS_ENUMERATE_ERROR_SUBCLASSES
+ JS_ENUMERATE_NATIVE_ERRORS
JS_ENUMERATE_BUILTIN_TYPES
#undef __JS_ENUMERATE