diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-21 15:14:02 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-21 15:15:52 +0200 |
commit | af51dc105a1ab91a01cb8e343980e96167350f5b (patch) | |
tree | a1b524d14b566e9cb294be29a08314ccef9c2f51 /Libraries/LibJS/Runtime/ConsoleObject.h | |
parent | 1914f52371bbd846bf3d154493e3fb993a202a6e (diff) | |
download | serenity-af51dc105a1ab91a01cb8e343980e96167350f5b.zip |
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. :^)
Diffstat (limited to 'Libraries/LibJS/Runtime/ConsoleObject.h')
-rw-r--r-- | Libraries/LibJS/Runtime/ConsoleObject.h | 4 |
1 files changed, 2 insertions, 2 deletions
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); |