mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:08:10 +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
|
@ -1302,14 +1302,15 @@ void ReplObject::initialize_global_object(JS::Realm& realm)
|
|||
Base::initialize_global_object(realm);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function("exit", exit_interpreter, 0, attr);
|
||||
define_native_function("help", repl_help, 0, attr);
|
||||
define_native_function("save", save_to_file, 1, attr);
|
||||
define_native_function("loadINI", load_ini, 1, attr);
|
||||
define_native_function("loadJSON", load_json, 1, attr);
|
||||
define_native_function("print", print, 1, attr);
|
||||
define_native_function(realm, "exit", exit_interpreter, 0, attr);
|
||||
define_native_function(realm, "help", repl_help, 0, attr);
|
||||
define_native_function(realm, "save", save_to_file, 1, attr);
|
||||
define_native_function(realm, "loadINI", load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON", load_json, 1, attr);
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
|
||||
define_native_accessor(
|
||||
realm,
|
||||
"_",
|
||||
[](JS::VM&) {
|
||||
return g_last_value.value();
|
||||
|
@ -1380,9 +1381,9 @@ void ScriptObject::initialize_global_object(JS::Realm& realm)
|
|||
Base::initialize_global_object(realm);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function("loadINI", load_ini, 1, attr);
|
||||
define_native_function("loadJSON", load_json, 1, attr);
|
||||
define_native_function("print", print, 1, attr);
|
||||
define_native_function(realm, "loadINI", load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON", load_json, 1, attr);
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ScriptObject::load_ini)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue