/*************************************************************************/ /* method_bind.hpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #ifndef GODOT_METHOD_BIND_HPP #define GODOT_METHOD_BIND_HPP #include #include #include #include #include #include #include #include namespace godot { class MethodBind { StringName name; StringName instance_class; int argument_count = 0; uint32_t hint_flags = METHOD_FLAGS_DEFAULT; bool _static = false; bool _is_const = false; bool _has_return = false; bool _vararg = false; std::vector argument_names; GDExtensionVariantType *argument_types = nullptr; std::vector default_arguments; protected: virtual GDExtensionVariantType gen_argument_type(int p_arg) const = 0; virtual PropertyInfo gen_argument_type_info(int p_arg) const = 0; void generate_argument_types(int p_count); void set_const(bool p_const); void set_return(bool p_return); void set_static(bool p_static); void set_vararg(bool p_vararg); void set_argument_count(int p_count); public: StringName get_name() const; void set_name(const StringName &p_name); _FORCE_INLINE_ int get_default_argument_count() const { return (int)default_arguments.size(); } _FORCE_INLINE_ const std::vector &get_default_arguments() const { return default_arguments; } _FORCE_INLINE_ Variant has_default_argument(int p_arg) const { int idx = p_arg - (argument_count - (int)default_arguments.size()); if (idx < 0 || idx >= default_arguments.size()) { return false; } else { return true; } } _FORCE_INLINE_ Variant get_default_argument(int p_arg) const { int idx = p_arg - (argument_count - (int)default_arguments.size()); if (idx < 0 || idx >= default_arguments.size()) { return Variant(); } else { return default_arguments[idx]; } } _FORCE_INLINE_ StringName get_instance_class() const { return instance_class; } _FORCE_INLINE_ void set_instance_class(StringName p_class) { instance_class = p_class; } _FORCE_INLINE_ int get_argument_count() const { return argument_count; } _FORCE_INLINE_ bool is_const() const { return _is_const; } _FORCE_INLINE_ bool is_static() const { return _static; } _FORCE_INLINE_ bool is_vararg() const { return _vararg; } _FORCE_INLINE_ bool has_return() const { return _has_return; } _FORCE_INLINE_ uint32_t get_hint_flags() const { return hint_flags | (is_const() ? GDEXTENSION_METHOD_FLAG_CONST : 0) | (is_vararg() ? GDEXTENSION_METHOD_FLAG_VARARG : 0) | (is_static() ? GDEXTENSION_METHOD_FLAG_STATIC : 0); } _FORCE_INLINE_ void set_hint_flags(uint32_t p_hint_flags) { hint_flags = p_hint_flags; } void set_argument_names(const std::vector &p_names); std::vector get_argument_names() const; void set_default_arguments(const std::vector &p_default_arguments) { default_arguments = p_default_arguments; } _FORCE_INLINE_ GDExtensionVariantType get_argument_type(int p_argument) const { ERR_FAIL_COND_V(p_argument < -1 || p_argument > argument_count, GDEXTENSION_VARIANT_TYPE_NIL); return argument_types[p_argument + 1]; } PropertyInfo get_argument_info(int p_argument) const; virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const = 0; std::vector get_arguments_info_list() const { std::vector vec; // First element is return value vec.reserve(argument_count + 1); for (int i = 0; i < argument_count + 1; i++) { vec.push_back(get_argument_info(i - 1)); } return vec; } std::vector get_arguments_metadata_list() const { std::vector vec; // First element is return value vec.reserve(argument_count + 1); for (int i = 0; i < argument_count; i++) { vec.push_back(get_argument_metadata(i - 1)); } return vec; } virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const = 0; virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) const = 0; static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return); virtual ~MethodBind(); }; template class MethodBindVarArgBase : public MethodBind { protected: R(T::*method) (const Variant **, GDExtensionInt, GDExtensionCallError &); std::vector arguments; public: virtual PropertyInfo gen_argument_type_info(int p_arg) const { if (p_arg < 0) { return _gen_return_type_info(); } else if (p_arg < arguments.size()) { return arguments[p_arg]; } else { return make_property_info(Variant::Type::NIL, "vararg", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); } } virtual GDExtensionVariantType gen_argument_type(int p_arg) const { return static_cast(gen_argument_type_info(p_arg).type); } virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int) const { return GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; } virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) const { ERR_FAIL(); // Can't call. } MethodBindVarArgBase( R (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_method_info, bool p_return_nil_is_variant) : method(p_method) { set_vararg(true); set_const(true); set_argument_count(p_method_info.arguments.size()); if (p_method_info.arguments.size()) { arguments = p_method_info.arguments; std::vector names; names.reserve(p_method_info.arguments.size()); for (int i = 0; i < p_method_info.arguments.size(); i++) { names.push_back(p_method_info.arguments[i].name); } set_argument_names(names); } generate_argument_types((int)p_method_info.arguments.size()); set_return(should_returns); } ~MethodBindVarArgBase() {} private: PropertyInfo _gen_return_type_info() const { return reinterpret_cast(this)->_gen_return_type_info_impl(); } }; template class MethodBindVarArgT : public MethodBindVarArgBase, T, void, false> { friend class MethodBindVarArgBase, T, void, false>; public: virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { (static_cast(p_instance)->*MethodBindVarArgBase, T, void, false>::method)((const Variant **)p_args, p_argument_count, r_error); return {}; } MethodBindVarArgT( void (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_method_info, bool p_return_nil_is_variant) : MethodBindVarArgBase, T, void, false>(p_method, p_method_info, p_return_nil_is_variant) { } private: PropertyInfo _gen_return_type_info_impl() const { return {}; } }; template MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) { MethodBind *a = memnew((MethodBindVarArgT)(p_method, p_info, p_return_nil_is_variant)); a->set_instance_class(T::get_class_static()); return a; } template class MethodBindVarArgTR : public MethodBindVarArgBase, T, R, true> { friend class MethodBindVarArgBase, T, R, true>; public: virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { return (static_cast(p_instance)->*MethodBindVarArgBase, T, R, true>::method)((const Variant **)p_args, p_argument_count, r_error); } MethodBindVarArgTR( R (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) : MethodBindVarArgBase, T, R, true>(p_method, p_info, p_return_nil_is_variant) { } private: PropertyInfo _gen_return_type_info_impl() const { return GetTypeInfo::get_class_info(); } }; template MethodBind *create_vararg_method_bind(R (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) { MethodBind *a = memnew((MethodBindVarArgTR)(p_method, p_info, p_return_nil_is_variant)); a->set_instance_class(T::get_class_static()); return a; } #ifndef TYPED_METHOD_BIND class ___UnexistingClass; #define MB_T ___UnexistingClass #else #define MB_T T #endif // No return, not const. #ifdef TYPED_METHOD_BIND template #else template #endif // TYPED_METHOD_BIND class MethodBindT : public MethodBind { void (MB_T::*method)(P...); protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDEXTENSION_VARIANT_TYPE_NIL; } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { PropertyInfo pi; if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { call_get_argument_type_info(p_arg, pi); } else { pi = PropertyInfo(); } return pi; } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const { return call_get_argument_metadata(p_argument); } virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { #ifdef TYPED_METHOD_BIND call_with_variant_args_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); #else call_with_variant_args_dv(reinterpret_cast(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments()); #endif return Variant(); } virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, nullptr); #else call_with_ptr_args(reinterpret_cast(p_instance), method, p_args, nullptr); #endif // TYPED_METHOD_BIND } MethodBindT(void (MB_T::*p_method)(P...)) { method = p_method; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); } }; template MethodBind *create_method_bind(void (T::*p_method)(P...)) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindT)(p_method)); #else MethodBind *a = memnew((MethodBindT)(reinterpret_cast(p_method))); #endif // TYPED_METHOD_BIND a->set_instance_class(T::get_class_static()); return a; } // No return, const. #ifdef TYPED_METHOD_BIND template #else template #endif // TYPED_METHOD_BIND class MethodBindTC : public MethodBind { void (MB_T::*method)(P...) const; protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDEXTENSION_VARIANT_TYPE_NIL; } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { PropertyInfo pi; if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { call_get_argument_type_info(p_arg, pi); } else { pi = PropertyInfo(); } return pi; } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const { return call_get_argument_metadata(p_argument); } virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { #ifdef TYPED_METHOD_BIND call_with_variant_argsc_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); #else call_with_variant_argsc_dv(reinterpret_cast(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments()); #endif return Variant(); } virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, nullptr); #else call_with_ptr_args(reinterpret_cast(p_instance), method, p_args, nullptr); #endif // TYPED_METHOD_BIND } MethodBindTC(void (MB_T::*p_method)(P...) const) { method = p_method; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); } }; template MethodBind *create_method_bind(void (T::*p_method)(P...) const) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTC)(p_method)); #else MethodBind *a = memnew((MethodBindTC)(reinterpret_cast(p_method))); #endif // TYPED_METHOD_BIND a->set_instance_class(T::get_class_static()); return a; } // Return, not const. #ifdef TYPED_METHOD_BIND template #else template #endif // TYPED_METHOD_BIND class MethodBindTR : public MethodBind { R(MB_T::*method) (P...); protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; } else { return GetTypeInfo::get_class_info(); } } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const { if (p_argument >= 0) { return call_get_argument_metadata(p_argument); } else { return GetTypeInfo::METADATA; } } virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_ret_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); #else call_with_variant_args_ret_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments()); #endif return ret; } virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, r_ret); #else call_with_ptr_args(reinterpret_cast(p_instance), method, p_args, r_ret); #endif // TYPED_METHOD_BIND } MethodBindTR(R (MB_T::*p_method)(P...)) { method = p_method; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); set_return(true); } }; template MethodBind *create_method_bind(R (T::*p_method)(P...)) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTR)(p_method)); #else MethodBind *a = memnew((MethodBindTR)(reinterpret_cast(p_method))); #endif // TYPED_METHOD_BIND a->set_instance_class(T::get_class_static()); return a; } // Return, const. #ifdef TYPED_METHOD_BIND template #else template #endif // TYPED_METHOD_BIND class MethodBindTRC : public MethodBind { R(MB_T::*method) (P...) const; protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; } else { return GetTypeInfo::get_class_info(); } } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const { if (p_argument >= 0) { return call_get_argument_metadata(p_argument); } else { return GetTypeInfo::METADATA; } } virtual Variant call(GDExtensionClassInstancePtr p_instance, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_retc_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); #else call_with_variant_args_retc_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments()); #endif return ret; } virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, r_ret); #else call_with_ptr_args(reinterpret_cast(p_instance), method, p_args, r_ret); #endif // TYPED_METHOD_BIND } MethodBindTRC(R (MB_T::*p_method)(P...) const) { method = p_method; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); set_return(true); } }; template MethodBind *create_method_bind(R (T::*p_method)(P...) const) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTRC)(p_method)); #else MethodBind *a = memnew((MethodBindTRC)(reinterpret_cast(p_method))); #endif // TYPED_METHOD_BIND a->set_instance_class(T::get_class_static()); return a; } // STATIC BINDS // no return template class MethodBindTS : public MethodBind { void (*function)(P...); protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDEXTENSION_VARIANT_TYPE_NIL; } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { PropertyInfo pi; if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { call_get_argument_type_info(p_arg, pi); } else { pi = PropertyInfo(); } return pi; } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_arg) const { return call_get_argument_metadata(p_arg); } virtual Variant call(GDExtensionClassInstancePtr p_object, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionCallError &r_error) const { (void)p_object; // unused call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments()); return Variant(); } virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { (void)p_object; (void)r_ret; call_with_ptr_args_static_method(function, p_args); } MethodBindTS(void (*p_function)(P...)) { function = p_function; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); set_static(true); } }; template MethodBind *create_static_method_bind(void (*p_method)(P...)) { MethodBind *a = memnew((MethodBindTS)(p_method)); return a; } // return template class MethodBindTRS : public MethodBind { R(*function) (P...); protected: // GCC raises warnings in the case P = {} as the comparison is always false... #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif virtual GDExtensionVariantType gen_argument_type(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { return GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); } } virtual PropertyInfo gen_argument_type_info(int p_arg) const { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; } else { return GetTypeInfo::get_class_info(); } } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif public: virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_arg) const { if (p_arg >= 0) { return call_get_argument_metadata(p_arg); } else { return GetTypeInfo::METADATA; } } virtual Variant call(GDExtensionClassInstancePtr p_object, GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionCallError &r_error) const { Variant ret; call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments()); return ret; } virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret) const { (void)p_object; call_with_ptr_args_static_method_ret(function, p_args, r_ret); } MethodBindTRS(R (*p_function)(P...)) { function = p_function; generate_argument_types(sizeof...(P)); set_argument_count(sizeof...(P)); set_static(true); set_return(true); } }; template MethodBind *create_static_method_bind(R (*p_method)(P...)) { MethodBind *a = memnew((MethodBindTRS)(p_method)); return a; } } // namespace godot #endif // GODOT_METHOD_BIND_HPP