diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-28 22:48:35 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-28 22:51:09 +0100 |
commit | 7c4e53f31e23223e67bcb04156ed8b12b515b1b5 (patch) | |
tree | a11de166c7587e4488c46f8f64680cd04fb8720d /Libraries/LibJS/Runtime/NativeFunction.h | |
parent | c209ea1985087ac135cbbd40635de13d5cf701c6 (diff) | |
download | serenity-7c4e53f31e23223e67bcb04156ed8b12b515b1b5.zip |
LibJS: Rework how native functions are called to improve |this| value
Native functions now only get the Interpreter& as an argument. They can
then extract |this| along with any indexed arguments it wants from it.
This forces functions that want |this| to actually deal with calling
interpreter.this_value().to_object(), and dealing with the possibility
of a non-object |this|.
This is still not great but let's keep massaging it forward.
Diffstat (limited to 'Libraries/LibJS/Runtime/NativeFunction.h')
-rw-r--r-- | Libraries/LibJS/Runtime/NativeFunction.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibJS/Runtime/NativeFunction.h b/Libraries/LibJS/Runtime/NativeFunction.h index 739a9eac12..85ecd63294 100644 --- a/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Libraries/LibJS/Runtime/NativeFunction.h @@ -33,10 +33,10 @@ namespace JS { class NativeFunction : public Function { public: - explicit NativeFunction(AK::Function<Value(Object*, const Vector<Value>&)>); + explicit NativeFunction(AK::Function<Value(Interpreter&)>); virtual ~NativeFunction() override; - virtual Value call(Interpreter&, const Vector<Value>&) override; + virtual Value call(Interpreter&) override; protected: NativeFunction() {} @@ -45,7 +45,7 @@ private: virtual bool is_native_function() const override { return true; } virtual const char* class_name() const override { return "NativeFunction"; } - AK::Function<Value(Object*, const Vector<Value>&)> m_native_function; + AK::Function<Value(Interpreter&)> m_native_function; }; } |