mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +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:
@@ -31,7 +31,7 @@
|
||||
|
||||
namespace JS {
|
||||
|
||||
NativeFunction* NativeFunction::create(Interpreter&, GlobalObject& global_object, const FlyString& name, AK::Function<Value(Interpreter&)> function)
|
||||
NativeFunction* NativeFunction::create(Interpreter&, GlobalObject& global_object, const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)> function)
|
||||
{
|
||||
return global_object.heap().allocate<NativeFunction>(name, move(function), *global_object.function_prototype());
|
||||
}
|
||||
@@ -41,7 +41,7 @@ NativeFunction::NativeFunction(Object& prototype)
|
||||
{
|
||||
}
|
||||
|
||||
NativeFunction::NativeFunction(const FlyString& name, AK::Function<Value(Interpreter&)> native_function, Object& prototype)
|
||||
NativeFunction::NativeFunction(const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)> native_function, Object& prototype)
|
||||
: Function(prototype)
|
||||
, m_name(name)
|
||||
, m_native_function(move(native_function))
|
||||
@@ -60,7 +60,7 @@ NativeFunction::~NativeFunction()
|
||||
|
||||
Value NativeFunction::call(Interpreter& interpreter)
|
||||
{
|
||||
return m_native_function(interpreter);
|
||||
return m_native_function(interpreter, global_object());
|
||||
}
|
||||
|
||||
Value NativeFunction::construct(Interpreter&)
|
||||
|
||||
Reference in New Issue
Block a user