From d6225b1e0004c57cc50452ddb5d512fd6556a523 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 22 Jun 2016 23:12:20 -0300 Subject: Improved binding system (ObjectTypeDB::bind_method) to be friendlier to statically typed languages, should help in the Mono integration. Disabled by default. --- core/reference.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'core/reference.h') diff --git a/core/reference.h b/core/reference.h index 8bfbf19ab..60a256dc9 100644 --- a/core/reference.h +++ b/core/reference.h @@ -329,6 +329,62 @@ public: WeakRef(); }; +#ifdef PTRCALL_ENABLED + +template +struct PtrToArg< Ref > { + + _FORCE_INLINE_ static Ref convert(const void* p_ptr) { + + return Ref(reinterpret_cast(p_ptr)); + } + + _FORCE_INLINE_ static void encode(Ref p_val,const void* p_ptr) { + + *((T**)p_ptr)=p_val.ptr(); + } + +}; + + +template +struct PtrToArg< const Ref& > { + + _FORCE_INLINE_ static Ref convert(const void* p_ptr) { + + return Ref(reinterpret_cast(p_ptr)); + } + +}; +//this is for RefPtr + +template<> +struct PtrToArg< RefPtr > { + + _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) { + + return Ref(reinterpret_cast(p_ptr)).get_ref_ptr(); + } + + _FORCE_INLINE_ static void encode(RefPtr p_val,const void* p_ptr) { + + Ref r = p_val; + *((Reference**)p_ptr)=r.ptr(); + } + +}; + +template<> +struct PtrToArg< const RefPtr& > { + + _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) { + + return Ref(reinterpret_cast(p_ptr)).get_ref_ptr(); + } + +}; + +#endif #endif // REFERENCE_H -- cgit v1.2.3-70-g09d2