mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 12:15:07 +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
9 changed files with 28 additions and 26 deletions
|
@ -37,13 +37,11 @@ ObjectPrototype::ObjectPrototype()
|
|||
{
|
||||
set_prototype(nullptr);
|
||||
|
||||
put_native_function("hasOwnProperty", [](Interpreter& interpreter, Vector<Value> arguments) -> Value {
|
||||
dbg() << "hasOwnProperty";
|
||||
put_native_function("hasOwnProperty", [](Object* this_object, Vector<Value> arguments) -> Value {
|
||||
ASSERT(this_object);
|
||||
if (arguments.is_empty())
|
||||
return js_undefined();
|
||||
Value this_value = interpreter.this_value();
|
||||
ASSERT(this_value.is_object());
|
||||
return Value(this_value.as_object()->has_own_property(arguments[0].to_string()));
|
||||
return Value(this_object->has_own_property(arguments[0].to_string()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue