mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 08:06:09 +00:00
LibJS: Pass "this" as an Object* to NativeFunction callbacks
Instead of every NativeFunction callback having to ask the Interpreter for the current "this" value and then converting it to an Object etc, just pass "this" as an Object* directly.
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
namespace JS {
|
||||
|
||||
NativeFunction::NativeFunction(AK::Function<Value(Interpreter&, Vector<Value>)> native_function)
|
||||
NativeFunction::NativeFunction(AK::Function<Value(Object*, Vector<Value>)> native_function)
|
||||
: m_native_function(move(native_function))
|
||||
{
|
||||
}
|
||||
@@ -41,7 +41,9 @@ NativeFunction::~NativeFunction()
|
||||
|
||||
Value NativeFunction::call(Interpreter& interpreter, Vector<Value> arguments)
|
||||
{
|
||||
return m_native_function(interpreter, move(arguments));
|
||||
auto this_value = interpreter.this_value();
|
||||
ASSERT(this_value.is_object());
|
||||
return m_native_function(this_value.as_object(), move(arguments));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user