summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/NativeProperty.h
blob: 1498a3192453484321e32bfe6039eb54aa856668 (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
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Function.h>
#include <LibJS/Runtime/Object.h>

namespace JS {

class NativeProperty final : public Cell {
public:
    NativeProperty(AK::Function<Value(VM&, GlobalObject&)> getter, AK::Function<void(VM&, GlobalObject&, Value)> setter);
    virtual ~NativeProperty() override;

    Value get(VM&, GlobalObject&) const;
    void set(VM&, GlobalObject&, Value);

private:
    virtual const char* class_name() const override { return "NativeProperty"; }

    AK::Function<Value(VM&, GlobalObject&)> m_getter;
    AK::Function<void(VM&, GlobalObject&, Value)> m_setter;
};

}