From af51dc105a1ab91a01cb8e343980e96167350f5b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 21 Jun 2020 15:14:02 +0200 Subject: LibJS+LibWeb: Add JS::Object::inherits(class_name) To allow implementing the DOM class hierarchy in JS bindings, this patch adds an inherits() function that can be used to ask an Object if it inherits from a specific C++ class (by name). The necessary overrides are baked into each Object subclass by the new JS_OBJECT macro, which works similarly to C_OBJECT in LibCore. Thanks to @Dexesttp for suggesting this approach. :^) --- Libraries/LibJS/Runtime/BigIntObject.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Libraries/LibJS/Runtime/BigIntObject.h') 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; -- cgit v1.2.3