summaryrefslogtreecommitdiffstats
path: root/core/reference.h
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-22 23:12:20 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-22 23:13:41 -0300
commitd6225b1e0004c57cc50452ddb5d512fd6556a523 (patch)
treeeeb6169dcc735c6b66052581b81bb5a71b466509 /core/reference.h
parent842e7bfc2f81cda73fd9f16a1ade323a1a5d0292 (diff)
downloadredot-engine-d6225b1e0004c57cc50452ddb5d512fd6556a523.tar.gz
Improved binding system (ObjectTypeDB::bind_method) to be friendlier to statically typed languages, should help in the Mono integration.
Disabled by default.
Diffstat (limited to 'core/reference.h')
-rw-r--r--core/reference.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/reference.h b/core/reference.h
index 8bfbf19ab6..60a256dc99 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -329,6 +329,62 @@ public:
WeakRef();
};
+#ifdef PTRCALL_ENABLED
+
+template<class T>
+struct PtrToArg< Ref<T> > {
+
+ _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) {
+
+ return Ref<T>(reinterpret_cast<const T*>(p_ptr));
+ }
+
+ _FORCE_INLINE_ static void encode(Ref<T> p_val,const void* p_ptr) {
+
+ *((T**)p_ptr)=p_val.ptr();
+ }
+
+};
+
+
+template<class T>
+struct PtrToArg< const Ref<T>& > {
+
+ _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) {
+
+ return Ref<T>(reinterpret_cast<const T*>(p_ptr));
+ }
+
+};
+//this is for RefPtr
+
+template<>
+struct PtrToArg< RefPtr > {
+
+ _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) {
+
+ return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr();
+ }
+
+ _FORCE_INLINE_ static void encode(RefPtr p_val,const void* p_ptr) {
+
+ Ref<Reference> r = p_val;
+ *((Reference**)p_ptr)=r.ptr();
+ }
+
+};
+
+template<>
+struct PtrToArg< const RefPtr& > {
+
+ _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) {
+
+ return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr();
+ }
+
+};
+
+#endif
#endif // REFERENCE_H