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/Object.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/Object.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/Object.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 92efb5ba4a..0f36ed527c 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -680,7 +680,7 @@ bool Object::put(PropertyName property_name, Value value) return put_own_property(*this, property_string, value, default_attributes, PutOwnPropertyMode::Put); } -bool Object::define_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)> native_function, i32 length, PropertyAttributes attribute) +bool Object::define_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute) { auto* function = NativeFunction::create(interpreter(), global_object(), property_name, move(native_function)); function->define_property("length", Value(length), Attribute::Configurable); @@ -692,7 +692,7 @@ bool Object::define_native_function(const FlyString& property_name, AK::Function return define_property(property_name, function, attribute); } -bool Object::define_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter, PropertyAttributes attribute) +bool Object::define_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&, GlobalObject&)> getter, AK::Function<void(Interpreter&, GlobalObject&, Value)> setter, PropertyAttributes attribute) { return define_property(property_name, heap().allocate<NativeProperty>(move(getter), move(setter)), attribute); } |