1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibJS+LibWeb: Move native properties to separate getters/setters

This was a bit cumbersome now, but it gets us closer to a format suited
for code generation.
This commit is contained in:
Andreas Kling 2020-03-29 00:37:33 +01:00
parent 56936b97d0
commit 30440134cb
19 changed files with 210 additions and 96 deletions

View file

@ -29,7 +29,7 @@
namespace JS {
NativeProperty::NativeProperty(AK::Function<Value(Object*)> getter, AK::Function<void(Object*, Value)> setter)
NativeProperty::NativeProperty(AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter)
: m_getter(move(getter))
, m_setter(move(setter))
{
@ -39,18 +39,18 @@ NativeProperty::~NativeProperty()
{
}
Value NativeProperty::get(Object* object) const
Value NativeProperty::get(Interpreter& interpreter) const
{
if (!m_getter)
return js_undefined();
return m_getter(object);
return m_getter(interpreter);
}
void NativeProperty::set(Object* object, Value value)
void NativeProperty::set(Interpreter& interpreter, Value value)
{
if (!m_setter)
return;
m_setter(object, move(value));
m_setter(interpreter, move(value));
}
}