diff options
57 files changed, 122 insertions, 106 deletions
diff --git a/Libraries/LibJS/Runtime/Array.h b/Libraries/LibJS/Runtime/Array.h index 3abf4262ae..20a9ed30d9 100644 --- a/Libraries/LibJS/Runtime/Array.h +++ b/Libraries/LibJS/Runtime/Array.h @@ -31,6 +31,8 @@ namespace JS { class Array final : public Object { + JS_OBJECT(Array, Object); + public: static Array* create(GlobalObject&); @@ -40,7 +42,6 @@ public: static Array* typed_this(Interpreter&, GlobalObject&); private: - virtual const char* class_name() const override { return "Array"; } virtual bool is_array() const override { return true; } JS_DECLARE_NATIVE_GETTER(length_getter); diff --git a/Libraries/LibJS/Runtime/ArrayConstructor.h b/Libraries/LibJS/Runtime/ArrayConstructor.h index 182b2a3e2a..dd8df2db03 100644 --- a/Libraries/LibJS/Runtime/ArrayConstructor.h +++ b/Libraries/LibJS/Runtime/ArrayConstructor.h @@ -31,6 +31,8 @@ namespace JS { class ArrayConstructor final : public NativeFunction { + JS_OBJECT(ArrayConstructor, NativeFunction); + public: explicit ArrayConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "ArrayConstructor"; } JS_DECLARE_NATIVE_FUNCTION(is_array); JS_DECLARE_NATIVE_FUNCTION(of); diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.h b/Libraries/LibJS/Runtime/ArrayPrototype.h index 2a1969ab08..989603dafa 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.h +++ b/Libraries/LibJS/Runtime/ArrayPrototype.h @@ -32,14 +32,14 @@ namespace JS { class ArrayPrototype final : public Object { + JS_OBJECT(ArrayPrototype, Object); + public: ArrayPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~ArrayPrototype() override; private: - virtual const char* class_name() const override { return "ArrayPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(filter); JS_DECLARE_NATIVE_FUNCTION(for_each); JS_DECLARE_NATIVE_FUNCTION(map); diff --git a/Libraries/LibJS/Runtime/BigIntConstructor.h b/Libraries/LibJS/Runtime/BigIntConstructor.h index 4a9adcf6a1..25a81625e5 100644 --- a/Libraries/LibJS/Runtime/BigIntConstructor.h +++ b/Libraries/LibJS/Runtime/BigIntConstructor.h @@ -31,6 +31,8 @@ namespace JS { class BigIntConstructor final : public NativeFunction { + JS_OBJECT(BigIntConstructor, NativeFunction); + public: explicit BigIntConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "BigIntConstructor"; } JS_DECLARE_NATIVE_FUNCTION(as_int_n); JS_DECLARE_NATIVE_FUNCTION(as_uint_n); diff --git a/Libraries/LibJS/Runtime/BigIntObject.h b/Libraries/LibJS/Runtime/BigIntObject.h index 5c5a273400..05a3e9db6b 100644 --- a/Libraries/LibJS/Runtime/BigIntObject.h +++ b/Libraries/LibJS/Runtime/BigIntObject.h @@ -32,6 +32,8 @@ namespace JS { class BigIntObject final : public Object { + JS_OBJECT(BigIntObject, Object); + public: static BigIntObject* create(GlobalObject&, BigInt&); @@ -46,7 +48,6 @@ public: private: virtual void visit_children(Visitor&) override; - virtual const char* class_name() const override { return "BigIntObject"; } virtual bool is_bigint_object() const override { return true; } BigInt& m_bigint; diff --git a/Libraries/LibJS/Runtime/BigIntPrototype.h b/Libraries/LibJS/Runtime/BigIntPrototype.h index b1aa29c81f..28e838fee3 100644 --- a/Libraries/LibJS/Runtime/BigIntPrototype.h +++ b/Libraries/LibJS/Runtime/BigIntPrototype.h @@ -31,14 +31,14 @@ namespace JS { class BigIntPrototype final : public Object { + JS_OBJECT(BigIntPrototype, Object); + public: explicit BigIntPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~BigIntPrototype() override; private: - virtual const char* class_name() const override { return "BigIntPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(to_locale_string); JS_DECLARE_NATIVE_FUNCTION(value_of); diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.h b/Libraries/LibJS/Runtime/BooleanConstructor.h index 22b559cd2b..1755123157 100644 --- a/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -31,6 +31,8 @@ namespace JS { class BooleanConstructor final : public NativeFunction { + JS_OBJECT(BooleanConstructor, NativeFunction); + public: explicit BooleanConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "BooleanConstructor"; } }; } diff --git a/Libraries/LibJS/Runtime/BooleanObject.h b/Libraries/LibJS/Runtime/BooleanObject.h index 4ecaaec3a5..eade92c275 100644 --- a/Libraries/LibJS/Runtime/BooleanObject.h +++ b/Libraries/LibJS/Runtime/BooleanObject.h @@ -30,6 +30,8 @@ namespace JS { class BooleanObject : public Object { + JS_OBJECT(BooleanObject, Object); + public: static BooleanObject* create(GlobalObject&, bool); @@ -42,7 +44,6 @@ public: } private: - virtual const char* class_name() const override { return "BooleanObject"; } virtual bool is_boolean_object() const override { return true; } bool m_value { false }; }; diff --git a/Libraries/LibJS/Runtime/BooleanPrototype.h b/Libraries/LibJS/Runtime/BooleanPrototype.h index 1995b51129..03367971ed 100644 --- a/Libraries/LibJS/Runtime/BooleanPrototype.h +++ b/Libraries/LibJS/Runtime/BooleanPrototype.h @@ -31,14 +31,14 @@ namespace JS { class BooleanPrototype final : public BooleanObject { + JS_OBJECT(BooleanPrototype, BooleanObject); + public: explicit BooleanPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~BooleanPrototype() override; private: - virtual const char* class_name() const override { return "BooleanPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(value_of); }; diff --git a/Libraries/LibJS/Runtime/BoundFunction.h b/Libraries/LibJS/Runtime/BoundFunction.h index 67252ff360..1ee964e566 100644 --- a/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Libraries/LibJS/Runtime/BoundFunction.h @@ -31,6 +31,8 @@ namespace JS { class BoundFunction final : public Function { + JS_OBJECT(BoundFunction, Function); + public: BoundFunction(GlobalObject&, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -56,7 +58,6 @@ public: private: virtual bool is_bound_function() const override { return true; } - virtual const char* class_name() const override { return "BoundFunction"; } Function* m_target_function = nullptr; Object* m_constructor_prototype = nullptr; diff --git a/Libraries/LibJS/Runtime/ConsoleObject.h b/Libraries/LibJS/Runtime/ConsoleObject.h index 77a764bd6a..83a2b6bcd2 100644 --- a/Libraries/LibJS/Runtime/ConsoleObject.h +++ b/Libraries/LibJS/Runtime/ConsoleObject.h @@ -31,14 +31,14 @@ namespace JS { class ConsoleObject final : public Object { + JS_OBJECT(ConsoleObject, Object); + public: explicit ConsoleObject(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~ConsoleObject() override; private: - virtual const char* class_name() const override { return "ConsoleObject"; } - JS_DECLARE_NATIVE_FUNCTION(log); JS_DECLARE_NATIVE_FUNCTION(debug); JS_DECLARE_NATIVE_FUNCTION(info); diff --git a/Libraries/LibJS/Runtime/Date.h b/Libraries/LibJS/Runtime/Date.h index 7770f438f8..ec816b1a01 100644 --- a/Libraries/LibJS/Runtime/Date.h +++ b/Libraries/LibJS/Runtime/Date.h @@ -32,6 +32,8 @@ namespace JS { class Date final : public Object { + JS_OBJECT(Date, Object); + public: static Date* create(GlobalObject&, Core::DateTime, u16 milliseconds); @@ -57,7 +59,6 @@ public: private: virtual bool is_date() const final { return true; } - virtual const char* class_name() const override { return "Date"; } Core::DateTime m_datetime; u16 m_milliseconds; diff --git a/Libraries/LibJS/Runtime/DateConstructor.h b/Libraries/LibJS/Runtime/DateConstructor.h index 68b8dd6305..fcb2b022df 100644 --- a/Libraries/LibJS/Runtime/DateConstructor.h +++ b/Libraries/LibJS/Runtime/DateConstructor.h @@ -31,6 +31,8 @@ namespace JS { class DateConstructor final : public NativeFunction { + JS_OBJECT(DateConstructor, NativeFunction); + public: explicit DateConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "DateConstructor"; } JS_DECLARE_NATIVE_FUNCTION(now); }; diff --git a/Libraries/LibJS/Runtime/DatePrototype.h b/Libraries/LibJS/Runtime/DatePrototype.h index 2e10ebb00a..40c6667d11 100644 --- a/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Libraries/LibJS/Runtime/DatePrototype.h @@ -31,14 +31,13 @@ namespace JS { class DatePrototype final : public Object { + JS_OBJECT(DatePrototype, Object); public: explicit DatePrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~DatePrototype() override; private: - virtual const char* class_name() const override { return "DatePrototype"; } - JS_DECLARE_NATIVE_FUNCTION(get_date); JS_DECLARE_NATIVE_FUNCTION(get_day); JS_DECLARE_NATIVE_FUNCTION(get_full_year); diff --git a/Libraries/LibJS/Runtime/Error.cpp b/Libraries/LibJS/Runtime/Error.cpp index 3056fee031..df2a79eec6 100644 --- a/Libraries/LibJS/Runtime/Error.cpp +++ b/Libraries/LibJS/Runtime/Error.cpp @@ -57,7 +57,6 @@ Error::~Error() { \ } \ ClassName::~ClassName() { } \ - const char* ClassName::class_name() const { return #ClassName; } JS_ENUMERATE_ERROR_SUBCLASSES #undef __JS_ENUMERATE diff --git a/Libraries/LibJS/Runtime/Error.h b/Libraries/LibJS/Runtime/Error.h index 785541ac0a..7ec5c67ac2 100644 --- a/Libraries/LibJS/Runtime/Error.h +++ b/Libraries/LibJS/Runtime/Error.h @@ -32,6 +32,8 @@ namespace JS { class Error : public Object { + JS_OBJECT(Error, Object); + public: static Error* create(GlobalObject&, const FlyString& name, const String& message); @@ -45,7 +47,6 @@ public: private: virtual bool is_error() const final { return true; } - virtual const char* class_name() const override { return "Error"; } FlyString m_name; String m_message; @@ -53,14 +54,13 @@ private: #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); \ \ ClassName(const String& message, Object& prototype); \ virtual ~ClassName() override; \ - \ - private: \ - virtual const char* class_name() const override; \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.h b/Libraries/LibJS/Runtime/ErrorConstructor.h index fcc610b08d..2208020a61 100644 --- a/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -32,6 +32,8 @@ namespace JS { class ErrorConstructor final : public NativeFunction { + JS_OBJECT(ErrorConstructor, NativeFunction); + public: explicit ErrorConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -42,11 +44,12 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "ErrorConstructor"; } }; #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(Interpreter&, GlobalObject&) override; \ @@ -56,7 +59,6 @@ private: \ private: \ virtual bool has_constructor() const override { return true; } \ - virtual const char* class_name() const override { return #ClassName "Constructor"; } \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ diff --git a/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 64127c9ab8..1c597b8762 100644 --- a/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -126,8 +126,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) : Object(global_object.error_prototype()) \ { \ } \ - PrototypeName::~PrototypeName() { } \ - const char* PrototypeName::class_name() const { return #PrototypeName; } + PrototypeName::~PrototypeName() { } JS_ENUMERATE_ERROR_SUBCLASSES #undef __JS_ENUMERATE diff --git a/Libraries/LibJS/Runtime/ErrorPrototype.h b/Libraries/LibJS/Runtime/ErrorPrototype.h index a70fe4f9df..8dc6b88cdb 100644 --- a/Libraries/LibJS/Runtime/ErrorPrototype.h +++ b/Libraries/LibJS/Runtime/ErrorPrototype.h @@ -31,14 +31,14 @@ namespace JS { class ErrorPrototype final : public Object { + JS_OBJECT(ErrorPrototype, Object); + public: explicit ErrorPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~ErrorPrototype() override; private: - virtual const char* class_name() const override { return "ErrorPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_GETTER(name_getter); @@ -49,13 +49,12 @@ private: #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(Interpreter&, GlobalObject&) override { } \ virtual ~PrototypeName() override; \ - \ - private: \ - virtual const char* class_name() const override; \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ diff --git a/Libraries/LibJS/Runtime/Function.h b/Libraries/LibJS/Runtime/Function.h index 9e254f4bf6..8e19472fcc 100644 --- a/Libraries/LibJS/Runtime/Function.h +++ b/Libraries/LibJS/Runtime/Function.h @@ -32,6 +32,8 @@ namespace JS { class Function : public Object { + JS_OBJECT(Function, Object); + public: virtual ~Function(); virtual void initialize(Interpreter&, GlobalObject&) override { } @@ -60,7 +62,6 @@ public: protected: explicit Function(Object& prototype); Function(Object& prototype, Value bound_this, Vector<Value> bound_arguments); - virtual const char* class_name() const override { return "Function"; } private: virtual bool is_function() const final { return true; } diff --git a/Libraries/LibJS/Runtime/FunctionConstructor.h b/Libraries/LibJS/Runtime/FunctionConstructor.h index e84e7cddba..97b0aa9001 100644 --- a/Libraries/LibJS/Runtime/FunctionConstructor.h +++ b/Libraries/LibJS/Runtime/FunctionConstructor.h @@ -31,6 +31,8 @@ namespace JS { class FunctionConstructor final : public NativeFunction { + JS_OBJECT(FunctionConstructor, NativeFunction); + public: explicit FunctionConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "FunctionConstructor"; } }; } diff --git a/Libraries/LibJS/Runtime/FunctionPrototype.h b/Libraries/LibJS/Runtime/FunctionPrototype.h index bb5c3f6072..5e744004ea 100644 --- a/Libraries/LibJS/Runtime/FunctionPrototype.h +++ b/Libraries/LibJS/Runtime/FunctionPrototype.h @@ -31,14 +31,14 @@ namespace JS { class FunctionPrototype final : public Object { + JS_OBJECT(FunctionPrototype, Object); + public: explicit FunctionPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~FunctionPrototype() override; private: - virtual const char* class_name() const override { return "FunctionPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(apply); JS_DECLARE_NATIVE_FUNCTION(bind); JS_DECLARE_NATIVE_FUNCTION(call); diff --git a/Libraries/LibJS/Runtime/GlobalObject.h b/Libraries/LibJS/Runtime/GlobalObject.h index f4ca8ce59c..0801d712c3 100644 --- a/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Libraries/LibJS/Runtime/GlobalObject.h @@ -32,6 +32,8 @@ namespace JS { class GlobalObject : public Object { + JS_OBJECT(GlobalObject, Object); + public: explicit GlobalObject(); virtual void initialize(); @@ -53,8 +55,6 @@ protected: void add_constructor(const FlyString& property_name, ConstructorType*&, Object& prototype); private: - virtual const char* class_name() const override { return "GlobalObject"; } - JS_DECLARE_NATIVE_FUNCTION(gc); JS_DECLARE_NATIVE_FUNCTION(is_nan); JS_DECLARE_NATIVE_FUNCTION(is_finite); diff --git a/Libraries/LibJS/Runtime/JSONObject.h b/Libraries/LibJS/Runtime/JSONObject.h index 3ce62280a2..eac7aa2e5b 100644 --- a/Libraries/LibJS/Runtime/JSONObject.h +++ b/Libraries/LibJS/Runtime/JSONObject.h @@ -31,6 +31,8 @@ namespace JS { class JSONObject final : public Object { + JS_OBJECT(JSONObject, Object); + public: explicit JSONObject(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -45,8 +47,6 @@ private: Optional<Vector<String>> property_list; }; - virtual const char* class_name() const override { return "JSONObject"; } - // Stringify helpers static String serialize_json_property(Interpreter&, StringifyState&, const PropertyName& key, Object* holder); static String serialize_json_object(Interpreter&, StringifyState&, Object&); diff --git a/Libraries/LibJS/Runtime/MathObject.h b/Libraries/LibJS/Runtime/MathObject.h index c5a5868a0b..2455ead29c 100644 --- a/Libraries/LibJS/Runtime/MathObject.h +++ b/Libraries/LibJS/Runtime/MathObject.h @@ -31,14 +31,14 @@ namespace JS { class MathObject final : public Object { + JS_OBJECT(MathObject, Object); + public: explicit MathObject(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~MathObject() override; private: - virtual const char* class_name() const override { return "MathObject"; } - JS_DECLARE_NATIVE_FUNCTION(abs); JS_DECLARE_NATIVE_FUNCTION(random); JS_DECLARE_NATIVE_FUNCTION(sqrt); diff --git a/Libraries/LibJS/Runtime/NativeFunction.h b/Libraries/LibJS/Runtime/NativeFunction.h index c8478171fc..f569e382ac 100644 --- a/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Libraries/LibJS/Runtime/NativeFunction.h @@ -32,6 +32,8 @@ namespace JS { class NativeFunction : public Function { + JS_OBJECT(NativeFunction, Function); + public: static NativeFunction* create(Interpreter&, GlobalObject&, const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)>); @@ -51,7 +53,6 @@ protected: private: virtual bool is_native_function() const override { return true; } - virtual const char* class_name() const override { return "NativeFunction"; } virtual LexicalEnvironment* create_environment() override final { return nullptr; } FlyString m_name; diff --git a/Libraries/LibJS/Runtime/NativeProperty.h b/Libraries/LibJS/Runtime/NativeProperty.h index 52bd5cc125..05e0102bc7 100644 --- a/Libraries/LibJS/Runtime/NativeProperty.h +++ b/Libraries/LibJS/Runtime/NativeProperty.h @@ -32,6 +32,8 @@ namespace JS { class NativeProperty final : public Object { + JS_OBJECT(NativeProperty, Object); + public: NativeProperty(AK::Function<Value(Interpreter&, GlobalObject&)> getter, AK::Function<void(Interpreter&, GlobalObject&, Value)> setter); virtual ~NativeProperty() override; @@ -41,7 +43,6 @@ public: private: virtual bool is_native_property() const override { return true; } - virtual const char* class_name() const override { return "NativeProperty"; } AK::Function<Value(Interpreter&, GlobalObject&)> m_getter; AK::Function<void(Interpreter&, GlobalObject&, Value)> m_setter; diff --git a/Libraries/LibJS/Runtime/NumberConstructor.h b/Libraries/LibJS/Runtime/NumberConstructor.h index bcaff30162..ebde71db0b 100644 --- a/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Libraries/LibJS/Runtime/NumberConstructor.h @@ -31,6 +31,8 @@ namespace JS { class NumberConstructor final : public NativeFunction { + JS_OBJECT(NumberConstructor, NativeFunction); + public: explicit NumberConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "NumberConstructor"; } JS_DECLARE_NATIVE_FUNCTION(is_finite); JS_DECLARE_NATIVE_FUNCTION(is_integer); diff --git a/Libraries/LibJS/Runtime/NumberObject.h b/Libraries/LibJS/Runtime/NumberObject.h index c316505d66..d5574a4de3 100644 --- a/Libraries/LibJS/Runtime/NumberObject.h +++ b/Libraries/LibJS/Runtime/NumberObject.h @@ -31,6 +31,8 @@ namespace JS { class NumberObject : public Object { + JS_OBJECT(NumberObject, Object); + public: static NumberObject* create(GlobalObject&, double); @@ -41,8 +43,6 @@ public: virtual Value value_of() const override { return Value(m_value); } private: - virtual const char* class_name() const override { return "NumberObject"; } - double m_value { 0 }; }; diff --git a/Libraries/LibJS/Runtime/NumberPrototype.h b/Libraries/LibJS/Runtime/NumberPrototype.h index 3b1e224dac..bf571ba75a 100644 --- a/Libraries/LibJS/Runtime/NumberPrototype.h +++ b/Libraries/LibJS/Runtime/NumberPrototype.h @@ -31,12 +31,11 @@ namespace JS { class NumberPrototype final : public NumberObject { + JS_OBJECT(NumberPrototype, NumberObject); + public: explicit NumberPrototype(GlobalObject&); virtual ~NumberPrototype() override; - -private: - virtual const char* class_name() const override { return "NumberPrototype"; } }; } diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index ebb40cb310..ec434bf05b 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -39,6 +39,12 @@ namespace JS { +#define JS_OBJECT(class_, base_class) \ +public: \ + using Base = base_class; \ + virtual const char* class_name() const override { return #class_; } \ + virtual bool inherits(const StringView& class_name) const override { return class_name == #class_ || Base::inherits(class_name); } + struct PropertyDescriptor { PropertyAttributes attributes; Value value; @@ -60,6 +66,8 @@ public: virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~Object(); + virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); } + enum class GetOwnPropertyMode { Key, Value, @@ -111,8 +119,6 @@ public: virtual bool is_symbol_object() const { return false; } virtual bool is_bigint_object() const { return false; } - virtual bool is_web_wrapper() const { return false; } - virtual const char* class_name() const override { return "Object"; } virtual void visit_children(Cell::Visitor&) override; diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.h b/Libraries/LibJS/Runtime/ObjectConstructor.h index 57eafb5282..782946eb3f 100644 --- a/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -31,6 +31,8 @@ namespace JS { class ObjectConstructor final : public NativeFunction { + JS_OBJECT(ObjectConstructor, NativeFunction); + public: explicit ObjectConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "ObjectConstructor"; } JS_DECLARE_NATIVE_FUNCTION(define_property_); JS_DECLARE_NATIVE_FUNCTION(is); diff --git a/Libraries/LibJS/Runtime/ObjectPrototype.h b/Libraries/LibJS/Runtime/ObjectPrototype.h index 4f0c6ca4bb..2f9775dbcf 100644 --- a/Libraries/LibJS/Runtime/ObjectPrototype.h +++ b/Libraries/LibJS/Runtime/ObjectPrototype.h @@ -31,6 +31,8 @@ namespace JS { class ObjectPrototype final : public Object { + JS_OBJECT(ObjectPrototype, Object); + public: explicit ObjectPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -40,8 +42,6 @@ public: JS_DECLARE_NATIVE_FUNCTION(to_string); private: - virtual const char* class_name() const override { return "ObjectPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(has_own_property); JS_DECLARE_NATIVE_FUNCTION(to_locale_string); JS_DECLARE_NATIVE_FUNCTION(value_of); diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.h b/Libraries/LibJS/Runtime/ProxyConstructor.h index 10d9277280..e914f2e3cc 100644 --- a/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -31,6 +31,8 @@ namespace JS { class ProxyConstructor final : public NativeFunction { + JS_OBJECT(ProxyConstructor, NativeFunction); + public: explicit ProxyConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "ProxyConstructor"; } }; } diff --git a/Libraries/LibJS/Runtime/ProxyObject.h b/Libraries/LibJS/Runtime/ProxyObject.h index 9d57f885d6..ce8c3ef69d 100644 --- a/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Libraries/LibJS/Runtime/ProxyObject.h @@ -31,6 +31,8 @@ namespace JS { class ProxyObject : public Object { + JS_OBJECT(ProxyObject, Object); + public: static ProxyObject* create(GlobalObject&, Object& target, Object& handler); @@ -56,7 +58,6 @@ public: private: virtual void visit_children(Visitor&) override; - virtual const char* class_name() const override { return "ProxyObject"; } virtual bool is_proxy_object() const override { return true; } virtual bool is_array() const override { return m_target.is_array(); }; diff --git a/Libraries/LibJS/Runtime/ProxyPrototype.h b/Libraries/LibJS/Runtime/ProxyPrototype.h index e0ec6f23a1..b680f6dacb 100644 --- a/Libraries/LibJS/Runtime/ProxyPrototype.h +++ b/Libraries/LibJS/Runtime/ProxyPrototype.h @@ -31,12 +31,11 @@ namespace JS { class ProxyPrototype final : public Object { + JS_OBJECT(ProxyPrototype, Object); + public: explicit ProxyPrototype(GlobalObject&); virtual ~ProxyPrototype() override; - -private: - virtual const char* class_name() const override { return "ProxyPrototype"; } }; } diff --git a/Libraries/LibJS/Runtime/ReflectObject.h b/Libraries/LibJS/Runtime/ReflectObject.h index eeae86f308..8cc129fe83 100644 --- a/Libraries/LibJS/Runtime/ReflectObject.h +++ b/Libraries/LibJS/Runtime/ReflectObject.h @@ -31,14 +31,14 @@ namespace JS { class ReflectObject final : public Object { + JS_OBJECT(ReflectObject, Object); + public: explicit ReflectObject(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~ReflectObject() override; private: - virtual const char* class_name() const override { return "ReflectObject"; } - JS_DECLARE_NATIVE_FUNCTION(apply); JS_DECLARE_NATIVE_FUNCTION(construct); JS_DECLARE_NATIVE_FUNCTION(define_property); diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.h b/Libraries/LibJS/Runtime/RegExpConstructor.h index 7da95a71d0..4c09b13b60 100644 --- a/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -31,6 +31,8 @@ namespace JS { class RegExpConstructor final : public NativeFunction { + JS_OBJECT(RegExpConstructor, NativeFunction); + public: explicit RegExpConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "RegExpConstructor"; } }; } diff --git a/Libraries/LibJS/Runtime/RegExpObject.h b/Libraries/LibJS/Runtime/RegExpObject.h index 5acc72b4ce..61d44b2a6f 100644 --- a/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Libraries/LibJS/Runtime/RegExpObject.h @@ -32,6 +32,8 @@ namespace JS { class RegExpObject : public Object { + JS_OBJECT(RegExpObject, Object); + public: static RegExpObject* create(GlobalObject&, String content, String flags); @@ -44,7 +46,6 @@ public: Value to_string() const override; private: - virtual const char* class_name() const override { return "RegExpObject"; } virtual bool is_regexp_object() const override { return true; } String m_content; diff --git a/Libraries/LibJS/Runtime/RegExpPrototype.h b/Libraries/LibJS/Runtime/RegExpPrototype.h index cab917e6e3..bfd42abd16 100644 --- a/Libraries/LibJS/Runtime/RegExpPrototype.h +++ b/Libraries/LibJS/Runtime/RegExpPrototype.h @@ -31,12 +31,11 @@ namespace JS { class RegExpPrototype final : public RegExpObject { + JS_OBJECT(RegExpPrototype, RegExpObject); + public: explicit RegExpPrototype(GlobalObject&); virtual ~RegExpPrototype() override; - -private: - virtual const char* class_name() const override { return "RegExpPrototype"; } }; } diff --git a/Libraries/LibJS/Runtime/ScriptFunction.h b/Libraries/LibJS/Runtime/ScriptFunction.h index 201e5d1af3..304c229b04 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.h +++ b/Libraries/LibJS/Runtime/ScriptFunction.h @@ -32,6 +32,8 @@ namespace JS { class ScriptFunction final : public Function { + JS_OBJECT(ScriptFunction, Function); + public: static ScriptFunction* create(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, bool is_arrow_function = false); @@ -50,7 +52,6 @@ public: private: virtual bool is_script_function() const override { return true; } - virtual const char* class_name() const override { return "ScriptFunction"; } virtual LexicalEnvironment* create_environment() override; virtual void visit_children(Visitor&) override; diff --git a/Libraries/LibJS/Runtime/StringConstructor.h b/Libraries/LibJS/Runtime/StringConstructor.h index b6c651bde5..3e7608920b 100644 --- a/Libraries/LibJS/Runtime/StringConstructor.h +++ b/Libraries/LibJS/Runtime/StringConstructor.h @@ -31,6 +31,8 @@ namespace JS { class StringConstructor final : public NativeFunction { + JS_OBJECT(StringConstructor, NativeFunction); + public: explicit StringConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "StringConstructor"; } JS_DECLARE_NATIVE_FUNCTION(raw); JS_DECLARE_NATIVE_FUNCTION(from_char_code); diff --git a/Libraries/LibJS/Runtime/StringObject.h b/Libraries/LibJS/Runtime/StringObject.h index 23e8f8f1dd..d01de70306 100644 --- a/Libraries/LibJS/Runtime/StringObject.h +++ b/Libraries/LibJS/Runtime/StringObject.h @@ -31,6 +31,8 @@ namespace JS { class StringObject : public Object { + JS_OBJECT(StringObject, Object); + public: static StringObject* create(GlobalObject&, PrimitiveString&); @@ -45,7 +47,6 @@ public: private: virtual void visit_children(Visitor&) override; - virtual const char* class_name() const override { return "StringObject"; } virtual bool is_string_object() const override { return true; } PrimitiveString& m_string; diff --git a/Libraries/LibJS/Runtime/StringPrototype.h b/Libraries/LibJS/Runtime/StringPrototype.h index 6df4c469de..841b41b301 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Libraries/LibJS/Runtime/StringPrototype.h @@ -31,14 +31,14 @@ namespace JS { class StringPrototype final : public StringObject { + JS_OBJECT(StringPrototype, StringObject); + public: explicit StringPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~StringPrototype() override; private: - virtual const char* class_name() const override { return "StringPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(char_at); JS_DECLARE_NATIVE_FUNCTION(repeat); JS_DECLARE_NATIVE_FUNCTION(starts_with); diff --git a/Libraries/LibJS/Runtime/SymbolConstructor.h b/Libraries/LibJS/Runtime/SymbolConstructor.h index c5e39774b6..6e495cae4d 100644 --- a/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -31,6 +31,8 @@ namespace JS { class SymbolConstructor final : public NativeFunction { + JS_OBJECT(SymbolConstructor, NativeFunction); + public: explicit SymbolConstructor(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; @@ -41,7 +43,6 @@ public: private: virtual bool has_constructor() const override { return true; } - virtual const char* class_name() const override { return "SymbolConstructor"; } JS_DECLARE_NATIVE_FUNCTION(for_); JS_DECLARE_NATIVE_FUNCTION(key_for); diff --git a/Libraries/LibJS/Runtime/SymbolObject.h b/Libraries/LibJS/Runtime/SymbolObject.h index 33c726cde0..763354b233 100644 --- a/Libraries/LibJS/Runtime/SymbolObject.h +++ b/Libraries/LibJS/Runtime/SymbolObject.h @@ -32,6 +32,8 @@ namespace JS { class SymbolObject : public Object { + JS_OBJECT(SymbolObject, Object); + public: static SymbolObject* create(GlobalObject&, Symbol&); @@ -70,7 +72,6 @@ public: private: virtual void visit_children(Visitor&) override; - virtual const char* class_name() const override { return "SymbolObject"; } virtual bool is_symbol_object() const override { return true; } Symbol& m_symbol; diff --git a/Libraries/LibJS/Runtime/SymbolPrototype.h b/Libraries/LibJS/Runtime/SymbolPrototype.h index 392c26a914..f8f5730b43 100644 --- a/Libraries/LibJS/Runtime/SymbolPrototype.h +++ b/Libraries/LibJS/Runtime/SymbolPrototype.h @@ -31,14 +31,14 @@ namespace JS { class SymbolPrototype final : public Object { + JS_OBJECT(SymbolPrototype, Object); + public: explicit SymbolPrototype(GlobalObject&); virtual void initialize(Interpreter&, GlobalObject&) override; virtual ~SymbolPrototype() override; private: - virtual const char* class_name() const override { return "SymbolPrototype"; } - JS_DECLARE_NATIVE_GETTER(description_getter); JS_DECLARE_NATIVE_FUNCTION(to_string); diff --git a/Libraries/LibJS/Runtime/Uint8ClampedArray.h b/Libraries/LibJS/Runtime/Uint8ClampedArray.h index bf2351789a..056d490eab 100644 --- a/Libraries/LibJS/Runtime/Uint8ClampedArray.h +++ b/Libraries/LibJS/Runtime/Uint8ClampedArray.h @@ -31,6 +31,8 @@ namespace JS { class Uint8ClampedArray final : public Object { + JS_OBJECT(Uint8ClampedArray, Object); + public: static Uint8ClampedArray* create(GlobalObject&, u32 length); @@ -46,8 +48,6 @@ public: const u8* data() const { return m_data; } private: - virtual const char* class_name() const override { return "Uint8ClampedArray"; } - JS_DECLARE_NATIVE_GETTER(length_getter); u8* m_data { nullptr }; diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h index 7595a63d1c..2fe903858b 100644 --- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h +++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h @@ -32,6 +32,7 @@ namespace Web { namespace Bindings { class CanvasRenderingContext2DWrapper final : public Wrapper { + JS_OBJECT(CanvasRenderingContext2DWrapper, Wrapper); public: CanvasRenderingContext2DWrapper(JS::GlobalObject&, CanvasRenderingContext2D&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; @@ -41,8 +42,6 @@ public: const CanvasRenderingContext2D& impl() const { return m_impl; } private: - virtual const char* class_name() const override { return "CanvasRenderingContext2DWrapper"; } - JS_DECLARE_NATIVE_FUNCTION(fill_rect); JS_DECLARE_NATIVE_FUNCTION(stroke_rect); JS_DECLARE_NATIVE_FUNCTION(draw_image); diff --git a/Libraries/LibWeb/Bindings/EventListenerWrapper.h b/Libraries/LibWeb/Bindings/EventListenerWrapper.h index 4aeb0cfec1..6fad8eaff2 100644 --- a/Libraries/LibWeb/Bindings/EventListenerWrapper.h +++ b/Libraries/LibWeb/Bindings/EventListenerWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class EventListenerWrapper final : public Wrapper { + JS_OBJECT(EventListenerWrapper, Wrapper); + public: EventListenerWrapper(JS::GlobalObject&, EventListener&); virtual ~EventListenerWrapper() override; @@ -40,8 +42,6 @@ public: const EventListener& impl() const { return *m_impl; } private: - virtual const char* class_name() const override { return "EventListenerWrapper"; } - NonnullRefPtr<EventListener> m_impl; }; diff --git a/Libraries/LibWeb/Bindings/EventWrapper.h b/Libraries/LibWeb/Bindings/EventWrapper.h index baf7ef56ad..1e9f4b04b2 100644 --- a/Libraries/LibWeb/Bindings/EventWrapper.h +++ b/Libraries/LibWeb/Bindings/EventWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class EventWrapper : public Wrapper { + JS_OBJECT(EventWrapper, Wrapper); + public: EventWrapper(JS::GlobalObject&, Event&); virtual ~EventWrapper() override; @@ -40,8 +42,6 @@ public: const Event& event() const { return m_event; } private: - virtual const char* class_name() const override { return "EventWrapper"; } - NonnullRefPtr<Event> m_event; }; diff --git a/Libraries/LibWeb/Bindings/ImageDataWrapper.h b/Libraries/LibWeb/Bindings/ImageDataWrapper.h index 97868071ce..059b28d0eb 100644 --- a/Libraries/LibWeb/Bindings/ImageDataWrapper.h +++ b/Libraries/LibWeb/Bindings/ImageDataWrapper.h @@ -32,6 +32,8 @@ namespace Web { namespace Bindings { class ImageDataWrapper : public Wrapper { + JS_OBJECT(ImageDataWrapper, Wrapper); + public: ImageDataWrapper(JS::GlobalObject&, ImageData&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; @@ -41,8 +43,6 @@ public: const ImageData& impl() const { return m_impl; } private: - virtual const char* class_name() const override { return "ImageDataWrapper"; } - JS_DECLARE_NATIVE_GETTER(width_getter); JS_DECLARE_NATIVE_GETTER(height_getter); JS_DECLARE_NATIVE_GETTER(data_getter); diff --git a/Libraries/LibWeb/Bindings/LocationObject.h b/Libraries/LibWeb/Bindings/LocationObject.h index 97133efafc..e0ebb55f32 100644 --- a/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Libraries/LibWeb/Bindings/LocationObject.h @@ -33,14 +33,14 @@ namespace Web { namespace Bindings { class LocationObject final : public JS::Object { + JS_OBJECT(LocationObject, JS::Object); + public: explicit LocationObject(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~LocationObject() override; private: - virtual const char* class_name() const override { return "LocationObject"; } - JS_DECLARE_NATIVE_FUNCTION(reload); JS_DECLARE_NATIVE_GETTER(href_getter); diff --git a/Libraries/LibWeb/Bindings/NavigatorObject.h b/Libraries/LibWeb/Bindings/NavigatorObject.h index ddef82f8f7..b05ecc26cd 100644 --- a/Libraries/LibWeb/Bindings/NavigatorObject.h +++ b/Libraries/LibWeb/Bindings/NavigatorObject.h @@ -33,14 +33,14 @@ namespace Web { namespace Bindings { class NavigatorObject final : public JS::Object { + JS_OBJECT(NavigatorObject, JS::Object); + public: NavigatorObject(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~NavigatorObject() override; private: - virtual const char* class_name() const override { return "NavigatorObject"; } - JS_DECLARE_NATIVE_GETTER(user_agent_getter); }; diff --git a/Libraries/LibWeb/Bindings/Wrapper.h b/Libraries/LibWeb/Bindings/Wrapper.h index bcb72bb440..5fc5abc606 100644 --- a/Libraries/LibWeb/Bindings/Wrapper.h +++ b/Libraries/LibWeb/Bindings/Wrapper.h @@ -37,20 +37,14 @@ namespace Bindings { class Wrapper : public JS::Object , public Weakable<Wrapper> { -public: - virtual bool is_event_target_wrapper() const { return false; } - virtual bool is_node_wrapper() const { return false; } - virtual bool is_document_wrapper() const { return false; } - virtual bool is_element_wrapper() const { return false; } - virtual bool is_htmlelement_wrapper() const { return false; } + JS_OBJECT(Wrapper, JS::Object); +public: protected: explicit Wrapper(Object& prototype) : Object(&prototype) { } - - virtual bool is_web_wrapper() const final { return true; } }; } diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h index dcc2fdfe48..8667825a50 100644 --- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h +++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h @@ -32,14 +32,14 @@ namespace Web { namespace Bindings { class XMLHttpRequestPrototype final : public JS::Object { + JS_OBJECT(XMLHttpRequestPrototype, JS::Object); + public: explicit XMLHttpRequestPrototype(JS::GlobalObject&); virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override; virtual ~XMLHttpRequestPrototype() override; private: - virtual const char* class_name() const override { return "XMLHttpRequestPrototype"; } - JS_DECLARE_NATIVE_FUNCTION(open); JS_DECLARE_NATIVE_FUNCTION(send); diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 324d7c3ab4..0f52953e03 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -315,6 +315,7 @@ static void generate_header(const IDL::Interface& interface) out() << "namespace Bindings {"; out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {"; + out() << " JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");"; out() << "public:"; out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);"; out() << " virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;"; @@ -332,7 +333,6 @@ static void generate_header(const IDL::Interface& interface) out() << " virtual bool " << is_foo_wrapper_name << "() const final { return true; }"; out() << "private:"; - out() << " virtual const char* class_name() const override { return \"" << interface.name << "\"; }"; for (auto& function : interface.functions) { out() << " JS_DECLARE_NATIVE_FUNCTION(" << snake_name(function.name) << ");"; @@ -412,8 +412,7 @@ void generate_implementation(const IDL::Interface& interface) out() << " auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);"; out() << " if (!this_object)"; out() << " return {};"; - auto is_foo_wrapper_name = snake_name(String::format("Is%s", wrapper_class.characters())); - out() << " if (!this_object->is_web_wrapper() || !static_cast<Wrapper*>(this_object)->" << is_foo_wrapper_name << "()) {"; + out() << " if (!this_object->inherits(\"" << wrapper_class << "\")) {"; out() << " interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.name << "\");"; out() << " return nullptr;"; out() << " }"; @@ -441,8 +440,7 @@ void generate_implementation(const IDL::Interface& interface) out() << " auto " << cpp_name << "_object = " << js_name << js_suffix << ".to_object(interpreter, global_object);"; out() << " if (interpreter.exception())"; generate_return(); - auto is_foo_wrapper_name = snake_name(String::format("Is%sWrapper", parameter.type.name.characters())); - out() << " if (!" << cpp_name << "_object->is_web_wrapper() || !static_cast<Wrapper*>(" << cpp_name << "_object)->" << is_foo_wrapper_name << "()) {"; + out() << " if (!" << cpp_name << "_object->inherits(\"" << parameter.type.name << "Wrapper\")) {"; out() << " interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << parameter.type.name << "\");"; generate_return(); out() << " }"; |