mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-15 07:32:52 +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:
parent
3163929990
commit
63b3cfdc73
Notes:
sideshowbarker
2024-07-19 08:17:26 +09:00
Author: https://github.com/awesomekling
Commit: 63b3cfdc73
9 changed files with 28 additions and 26 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue