summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Function.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-21 15:14:02 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-21 15:15:52 +0200
commitaf51dc105a1ab91a01cb8e343980e96167350f5b (patch)
treea1b524d14b566e9cb294be29a08314ccef9c2f51 /Libraries/LibJS/Runtime/Function.h
parent1914f52371bbd846bf3d154493e3fb993a202a6e (diff)
downloadserenity-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/Function.h')
-rw-r--r--Libraries/LibJS/Runtime/Function.h3
1 files changed, 2 insertions, 1 deletions
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; }