5#ifndef MOLYBDEN_JS_VALUE_DETAIL_HPP
6#define MOLYBDEN_JS_VALUE_DETAIL_HPP
8#include "molybden/js/internal/js_proxy_function_object.hpp"
15 static constexpr bool value =
false;
19struct IsCharArray<char[N]> {
20 static constexpr bool value =
true;
24struct IsCharArray<const char[N]> {
25 static constexpr bool value =
true;
28template <
class R,
class... T>
29std::shared_ptr<JsProxyObject> getFunctionProxy(R (*function)(T...)) {
30 return std::make_shared<internal::JsProxyFunctionObject<R, T...>>(
31 std::function<R(T...)>(function));
34template <
class F,
class R,
class... T>
35std::shared_ptr<JsProxyObject> getFunctionProxy(F&& function,
36 R (F::*)(T...) const) {
37 return std::make_shared<internal::JsProxyFunctionObject<R, T...>>(
38 std::function<R(T...)>(function));
41template <
class F,
class R,
class... T>
42std::shared_ptr<JsProxyObject> getFunctionProxy(F& function,
43 R (F::*)(T...) const) {
44 return std::make_shared<internal::JsProxyFunctionObject<R, T...>>(
45 std::function<R(T...)>(function));
52 using TNoRef =
typename std::remove_reference<T>::type;
55 internal::IsConvertibleFromJsDirectly<TNoRef>::value() ||
56 internal::IsCharArray<TNoRef>::value ||
57 std::is_same<TNoRef, char*>::value ||
58 std::is_same<TNoRef, const char*>::value ||
59 IsFunctor<TNoRef>::value ||
60 std::is_function<typename std::remove_pointer<TNoRef>::type>::value,
61 "Unable to construct JsValue from the given type.");
62 return JsValue(std::forward<T>(value));
67 :
JsValue(static_cast<double>(value)) {}
71 : JsValue(internal::getFunctionProxy(value)) {}
76 internal::getFunctionProxy(std::forward<T>(value), &T::operator())) {}
81 internal::getFunctionProxy(std::forward<T>(value), &T::operator())) {}
A JavaScript value.
Definition js_value.hpp:44
static JsValue from(T &&value)
Constructs a JavaScript value from the convertible C++ one.
Definition js_value_detail.hpp:51
JsValue()
Constructs an empty JsValue.