mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user