Molybden API
Loading...
Searching...
No Matches
js_accessible.hpp
1// Copyright (c) 2000-2023 TeamDev Ltd. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_JS_ACCESSIBLE_HPP
6#define MOLYBDEN_JS_ACCESSIBLE_HPP
7
8#include <map>
9
10#include "molybden/js/internal/field_container.hpp"
11#include "molybden/js/internal/method_container.hpp"
12#include "molybden/js/js_proxy_object.hpp"
13
14namespace molybden {
15
80template <class C>
82 public internal::MethodContainer,
83 public internal::FieldContainer {
84 public:
85 ~JsAccessible() override = default;
86
87 private:
88 // JsProxyObject
89 bool hasMethod(const std::string& method_name) override;
90 bool hasProperty(const std::string& property_name) override;
91 bool setProperty(const std::string& property_name,
92 const JsValue& value) override;
93 JsValue getProperty(const std::string& property_name) override;
94 std::string getType() override;
95 std::vector<std::string> enumerateMembers() override;
96 JsReturnValue call(const std::string& method_name,
97 const std::vector<JsValue>& args) override;
98};
99
113#define JS_ACCESSIBLE_METHOD(method_name) \
114 int __molybden_##method_name = \
115 molybden::internal::MethodContainer::addMethod( \
116 &std::remove_reference<decltype(*this)>::type::method_name, \
117 #method_name)
118
129#define JS_ACCESSIBLE_FIELD(field_name) \
130 int __molybden_##field_name = molybden::internal::FieldContainer::addField( \
131 &std::remove_reference<decltype(*this)>::type::field_name, \
132 #field_name)
133
134} // namespace molybden
135
136#endif // MOLYBDEN_JS_ACCESSIBLE_HPP
The base class for defining JavaScript accessible object classes that can be automatically converted ...
Definition js_accessible.hpp:83
Derive C from JsProxyObjectImpl<C> via CRTP pattern and implement the interface of JsProxyObject.
Definition js_proxy_object.hpp:171
Represents the JS function return value.
Definition js_return_value.hpp:35
A JavaScript value.
Definition js_value.hpp:44