mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +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
|
@ -31,10 +31,10 @@ void $262Object::initialize(Realm& realm)
|
|||
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function("clearKeptObjects", clear_kept_objects, 0, attr);
|
||||
define_native_function("createRealm", create_realm, 0, attr);
|
||||
define_native_function("detachArrayBuffer", detach_array_buffer, 1, attr);
|
||||
define_native_function("evalScript", eval_script, 1, attr);
|
||||
define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr);
|
||||
define_native_function(realm, "createRealm", create_realm, 0, attr);
|
||||
define_native_function(realm, "detachArrayBuffer", detach_array_buffer, 1, attr);
|
||||
define_native_function(realm, "evalScript", eval_script, 1, attr);
|
||||
|
||||
define_direct_property("agent", m_agent, attr);
|
||||
define_direct_property("gc", realm.global_object().get_without_side_effects("gc"), attr);
|
||||
|
|
|
@ -22,8 +22,8 @@ void AgentObject::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function("monotonicNow", monotonic_now, 0, attr);
|
||||
define_native_function("sleep", sleep, 1, attr);
|
||||
define_native_function(realm, "monotonicNow", monotonic_now, 0, attr);
|
||||
define_native_function(realm, "sleep", sleep, 1, attr);
|
||||
// TODO: broadcast
|
||||
// TODO: getReport
|
||||
// TODO: start
|
||||
|
|
|
@ -22,7 +22,7 @@ void GlobalObject::initialize_global_object(Realm& realm)
|
|||
|
||||
// https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function("print", print, 1, attr);
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
define_direct_property("$262", m_$262, attr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue