NativeProperty.h 710 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Function.h>
  8. #include <LibJS/Runtime/Object.h>
  9. namespace JS {
  10. class NativeProperty final : public Cell {
  11. public:
  12. NativeProperty(AK::Function<Value(VM&, GlobalObject&)> getter, AK::Function<void(VM&, GlobalObject&, Value)> setter);
  13. virtual ~NativeProperty() override;
  14. Value get(VM&, GlobalObject&) const;
  15. void set(VM&, GlobalObject&, Value);
  16. private:
  17. virtual const char* class_name() const override { return "NativeProperty"; }
  18. AK::Function<Value(VM&, GlobalObject&)> m_getter;
  19. AK::Function<void(VM&, GlobalObject&, Value)> m_setter;
  20. };
  21. }