5#ifndef MOLYBDEN_JS_COMPATIBLE_OBJECTS_DETAIL_HPP
6#define MOLYBDEN_JS_COMPATIBLE_OBJECTS_DETAIL_HPP
10#include "molybden/base/internal/is_base_and_derived.hpp"
21 static constexpr bool Value();
25constexpr bool IsJsObject<T>::Value() {
26 return IsBaseAndDerived<JsObject, T>::Value();
30struct IsJsProxyObject {
31 static constexpr bool Value();
35constexpr bool IsJsProxyObject<T>::Value() {
36 return IsBaseAndDerived<JsProxyObject, T>::Value();
39template <
class T,
class V =
void>
40struct IsConvertibleFromJsDirectlyInternal {
41 static constexpr bool value() {
return false; }
45struct IsConvertibleFromJsDirectlyInternal<
47 typename std::enable_if<std::is_integral<T>::value ||
48 std::is_floating_point<T>::value>::type> {
49 static constexpr bool value() {
return true; }
53struct IsConvertibleFromJsDirectlyInternal<std::shared_ptr<T>> {
54 static constexpr bool value() {
55 return IsJsObject<T>::Value() || IsJsProxyObject<T>::Value();
60struct IsConvertibleFromJsDirectlyInternal<std::string> {
61 static constexpr bool value() {
return true; }
65struct IsConvertibleFromJsDirectlyInternal<const char*> {
66 static constexpr bool value() {
return true; }
70struct IsConvertibleFromJsDirectlyInternal<bool> {
71 static constexpr bool value() {
return true; }
75struct IsConvertibleFromJsDirectlyInternal<JsValue> {
76 static constexpr bool value() {
return true; }
80struct IsConvertibleFromJsDirectlyInternal<void> {
81 static constexpr bool value() {
return true; }
85constexpr bool IsConvertibleFromJsDirectly<T>::value() {
86 return IsConvertibleFromJsDirectlyInternal<
87 typename std::remove_const<T>::type>::value();
91struct AreAllConvertibleFromJsDirectly;
93template <
class T0,
class... T>
94void AreAllConvertibleFromJsDirectly<T0, T...>::check() {
96 IsConvertibleFromJsDirectly<T0>::value(),
97 "Invalid type of the JS-accessible field or the method signature. "
102 " 4. std::shared_ptr<SomeJsObject>;"
103 " 5. std::shared_ptr<SomeJsProxyObject>."
104 " Accessible methods also can return void.");
105 AreAllConvertibleFromJsDirectly<T...>::check();