blob: 475f808c46c37240768c7f88a16c1a085aecb223 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/NativeProperty.h>
#include <LibJS/Runtime/Value.h>
namespace JS {
NativeProperty::NativeProperty(AK::Function<Value(VM&, GlobalObject&)> getter, AK::Function<void(VM&, GlobalObject&, Value)> setter)
: m_getter(move(getter))
, m_setter(move(setter))
{
}
NativeProperty::~NativeProperty()
{
}
Value NativeProperty::get(VM& vm, GlobalObject& global_object) const
{
if (!m_getter)
return js_undefined();
return m_getter(vm, global_object);
}
void NativeProperty::set(VM& vm, GlobalObject& global_object, Value value)
{
if (!m_setter)
return;
m_setter(vm, global_object, move(value));
}
}
|