mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
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.
This commit is contained in:
@@ -78,15 +78,15 @@ Value ArrayConstructor::construct(Interpreter& interpreter)
|
||||
return call(interpreter);
|
||||
}
|
||||
|
||||
Value ArrayConstructor::is_array(Interpreter& interpreter)
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::is_array)
|
||||
{
|
||||
auto value = interpreter.argument(0);
|
||||
return Value(value.is_array());
|
||||
}
|
||||
|
||||
Value ArrayConstructor::of(Interpreter& interpreter)
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::of)
|
||||
{
|
||||
auto* array = Array::create(interpreter.global_object());
|
||||
auto* array = Array::create(global_object);
|
||||
for (size_t i = 0; i < interpreter.argument_count(); ++i)
|
||||
array->indexed_properties().append(interpreter.argument(i));
|
||||
return array;
|
||||
|
||||
Reference in New Issue
Block a user