mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:48:13 +00:00
LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct realm, usually forwarded from the Object's initialize() function, rather than using the current realm.
This commit is contained in:
parent
7c468b5a77
commit
e3895e6c80
116 changed files with 893 additions and 890 deletions
|
@ -1073,9 +1073,8 @@ void Object::set_prototype(Object* new_prototype)
|
|||
m_shape = shape.create_prototype_transition(new_prototype);
|
||||
}
|
||||
|
||||
void Object::define_native_accessor(PropertyKey const& property_key, Function<ThrowCompletionOr<Value>(VM&)> getter, Function<ThrowCompletionOr<Value>(VM&)> setter, PropertyAttributes attribute)
|
||||
void Object::define_native_accessor(Realm& realm, PropertyKey const& property_key, Function<ThrowCompletionOr<Value>(VM&)> getter, Function<ThrowCompletionOr<Value>(VM&)> setter, PropertyAttributes attribute)
|
||||
{
|
||||
auto& realm = *global_object().associated_realm();
|
||||
FunctionObject* getter_function = nullptr;
|
||||
if (getter)
|
||||
getter_function = NativeFunction::create(realm, move(getter), 0, property_key, &realm, {}, "get"sv);
|
||||
|
@ -1123,9 +1122,8 @@ Value Object::get_without_side_effects(PropertyKey const& property_key) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void Object::define_native_function(PropertyKey const& property_key, Function<ThrowCompletionOr<Value>(VM&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
void Object::define_native_function(Realm& realm, PropertyKey const& property_key, Function<ThrowCompletionOr<Value>(VM&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
{
|
||||
auto& realm = *global_object().associated_realm();
|
||||
auto* function = NativeFunction::create(realm, move(native_function), length, property_key, &realm);
|
||||
define_direct_property(property_key, function, attribute);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue