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/method_bind.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'core/method_bind.h') diff --git a/core/method_bind.h b/core/method_bind.h index 48848c5848..30a848270d 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -33,6 +33,7 @@ #include "variant.h" #include "object.h" #include +#include "method_ptrcall.h" /** @author Juan Linietsky @@ -85,6 +86,32 @@ struct VariantCaster { (VariantCaster::cast( (m_idx-1)>=p_arg_count?get_default_argument(m_idx-1):*p_args[m_idx-1] )) //SIMPLE_NUMERIC_TYPE is used to avoid a warning on Variant::get_type_for + +#ifdef PTRCALL_ENABLED + + +#define VARIANT_ENUM_CAST( m_enum ) \ +SIMPLE_NUMERIC_TYPE( m_enum );\ +template<> \ +struct VariantCaster {\ +\ + static _FORCE_INLINE_ m_enum cast(const Variant& p_variant) {\ + return (m_enum)p_variant.operator int();\ + }\ +};\ +template<>\ +struct PtrToArg< m_enum > {\ + _FORCE_INLINE_ static m_enum convert(const void* p_ptr) {\ + return m_enum(*reinterpret_cast(p_ptr));\ + }\ + _FORCE_INLINE_ static void encode(m_enum p_val,const void* p_ptr) {\ + *(int*)p_ptr=p_val;\ + }\ +}; + +#else + + #define VARIANT_ENUM_CAST( m_enum ) \ SIMPLE_NUMERIC_TYPE( m_enum );\ template<> \ @@ -96,6 +123,9 @@ struct VariantCaster {\ }; +#endif + + #define CHECK_ARG(m_arg)\ if ((m_arg-1)