mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
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. :^)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user