Molybden API
Loading...
Searching...
No Matches
js_object_detail.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_JS_OBJECT_DETAIL_HPP
6#define MOLYBDEN_JS_OBJECT_DETAIL_HPP
7
8#include <vector>
9
10namespace molybden {
11
12template <class T>
13std::shared_ptr<T> JsObject::as() {
14 static_assert(internal::IsJsObject<T>::Value(),
15 "The object can only be casted to the JsObject subclass.");
16 return nullptr;
17}
18
19template <>
20std::shared_ptr<JsObject> JsObject::as();
21
22template <class... T>
23JsReturnValue JsObject::call(const std::string& method_name, T&&... args) {
24 return call(method_name, {JsValue::from(std::forward<T>(args))...});
25}
26
27template <class T>
28bool JsObject::putProperty(const std::string& name, T&& value) {
29 return putPropertyValue(name, JsValue::from(std::forward<T>(value)));
30}
31
32} // namespace molybden
33
34#endif // MOLYBDEN_JS_OBJECT_DETAIL_HPP
JsReturnValue call(const std::string &method_name, T &&... args)
Executes the method with the given method_name and the args in the JavaScript object.
Definition js_object_detail.hpp:23
std::shared_ptr< T > as()
Returns the shared pointer of type T to this object if it represents one, or nullptr otherwise.
Definition js_object_detail.hpp:13
bool putProperty(const std::string &name, T &&value)
Creates a new property with the given name or updates the existing one in the current JavaScript obje...
Definition js_object_detail.hpp:28
Represents the JS function return value.
Definition js_return_value.hpp:35
static JsValue from(T &&value)
Constructs a JavaScript value from the convertible C++ one.
Definition js_value_detail.hpp:51