22 std::reference_wrapper<T> referenceToWrapper(T &v)
28 std::reference_wrapper<T> pointerToWrapper(T *v)
34 std::reference_wrapper<T> sharedToWrapper(std::shared_ptr<T> &v)
39 template <
typename T,
typename Base>
40 std::reference_wrapper<Base> convertToBase(T &v)
42 return std::ref<Base>(v);
46 void deleteValue(T &v)
51 template <
typename ClassType,
typename ValueType>
52 static const ValueType &getField(ClassType &i,
const std::function<ValueType &(ClassType *)> &getRef)
57 template <
typename ClassType,
typename ValueType>
58 static void setField(ClassType &i,
const std::function<ValueType &(ClassType *)> &getRef,
const ValueType &v)
65 template <
typename ClassType>
68 if (not getReferenceToWrapper() or not getPointerToWrapper() or not getSharedToWrapper())
70 registerReferenceToWrapper(
Callable(&Detail::referenceToWrapper<ClassType>));
71 registerPointerToWrapper(
Callable(&Detail::pointerToWrapper<ClassType>));
72 registerSharedToWrapper(
Callable(&Detail::sharedToWrapper<ClassType>));
73 registerMethod(
"delete",
Callable(&Detail::deleteValue<ClassType>));
78 template <
typename ClassType,
typename BaseClassType>
81 return this->registerToBaseClass(
Callable(&Detail::convertToBase<ClassType, BaseClassType>));
84 template <
typename ClassType,
typename ValueType>
87 std::function<ValueType &(ClassType *)> getRef = std::mem_fn(member);
88 this->registerMethod(
"get:"+name,
Callable(&Detail::getField<ClassType, ValueType>).bind(getRef, 1));
89 this->registerMethod(
"set:"+name,
Callable(&Detail::setField<ClassType, ValueType>).bind(getRef, 1));
93 template <
typename ClassType,
typename... ArgsType>
96 this->registerClass<ClassType>();
97 this->registerConstructor(Callable::factory<ClassType, ArgsType...>());
98 this->registerStaticMethod(
"new", Callable::factoryNew<ClassType, ArgsType...>());
99 this->registerStaticMethod(
"shared", Callable::factoryShared<ClassType, ArgsType...>());
103 template <
typename ReturnType,
typename... ArgsType>
106 this->registerStaticMethod(name,
Callable(method));
110 template <
typename ReturnType,
typename ClassType,
typename... ArgsType>
113 this->registerClass<ClassType>();
114 this->registerMethod(name,
Callable(method));
118 template <
typename ReturnType,
typename ClassType,
typename... ArgsType>
121 this->registerClass<ClassType>();
122 this->registerMethod(name,
Callable(method));
126 template <
typename ClassType>
129 this->registerClass<ClassType>();
130 this->registerOpaqueConstructor(Callable::factory<ClassType, const Object *, const size_t>());
ManagedClass & registerOpaqueConstructor(void)
Definition: ClassImpl.hpp:127
ManagedClass & registerMethod(const std::string &name, ReturnType(ClassType::*method)(ArgsType...))
Definition: ClassImpl.hpp:111
Definition: Callable.hpp:30
Definition: Testing.hpp:134
ManagedClass & registerConstructor(void)
Definition: ClassImpl.hpp:94
ManagedClass & registerBaseClass(void)
Definition: ClassImpl.hpp:79
ManagedClass & registerClass(void)
Definition: ClassImpl.hpp:66
ManagedClass & registerField(const std::string &name, ValueType ClassType::*member)
Definition: ClassImpl.hpp:85
ManagedClass & registerStaticMethod(const std::string &name, ReturnType(*method)(ArgsType...))
Definition: ClassImpl.hpp:104