diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-20 13:55:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-20 15:45:07 +0200 |
commit | e4add199153bd32a7a4ccbe32751c799aaacaea9 (patch) | |
tree | 5d326c1635f94eadf6d53861be17186a21865085 /Libraries/LibJS/Runtime/NativeProperty.cpp | |
parent | 4aa98052caa728da0de4c3960d312d8cf92f1be7 (diff) | |
download | serenity-e4add199153bd32a7a4ccbe32751c799aaacaea9.zip |
LibJS: Pass GlobalObject& to native functions and property accessors
More work towards supporting multiple global objects. Native C++ code
now get a GlobalObject& and don't have to ask the Interpreter for it.
I've added macros for declaring and defining native callbacks since
this was pretty tedious and this makes it easier next time we want to
change any of these signatures.
Diffstat (limited to 'Libraries/LibJS/Runtime/NativeProperty.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/NativeProperty.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibJS/Runtime/NativeProperty.cpp b/Libraries/LibJS/Runtime/NativeProperty.cpp index 9f9fd7b236..50487fde7a 100644 --- a/Libraries/LibJS/Runtime/NativeProperty.cpp +++ b/Libraries/LibJS/Runtime/NativeProperty.cpp @@ -29,7 +29,7 @@ namespace JS { -NativeProperty::NativeProperty(AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter) +NativeProperty::NativeProperty(AK::Function<Value(Interpreter&, GlobalObject&)> getter, AK::Function<void(Interpreter&, GlobalObject&, Value)> setter) : Object(nullptr) , m_getter(move(getter)) , m_setter(move(setter)) @@ -44,14 +44,14 @@ Value NativeProperty::get(Interpreter& interpreter) const { if (!m_getter) return js_undefined(); - return m_getter(interpreter); + return m_getter(interpreter, global_object()); } void NativeProperty::set(Interpreter& interpreter, Value value) { if (!m_setter) return; - m_setter(interpreter, move(value)); + m_setter(interpreter, global_object(), move(value)); } } |