From 87f5fb06912d19b3ff3ba80b747fcea3023a1ed5 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Sun, 10 Mar 2024 16:02:43 -0500 Subject: [PATCH] Enforce template syntax `typename` over `class` --- binding_generator.py | 14 ++-- .../classes/editor_plugin_registration.hpp | 4 +- include/godot_cpp/classes/ref.hpp | 16 ++-- include/godot_cpp/classes/wrapped.hpp | 8 +- include/godot_cpp/core/binder_common.hpp | 82 +++++++++---------- include/godot_cpp/core/builtin_ptrcall.hpp | 12 +-- include/godot_cpp/core/class_db.hpp | 36 ++++---- include/godot_cpp/core/defs.hpp | 2 +- include/godot_cpp/core/engine_ptrcall.hpp | 12 +-- include/godot_cpp/core/math.hpp | 4 +- include/godot_cpp/core/memory.hpp | 14 ++-- include/godot_cpp/core/method_bind.hpp | 42 +++++----- include/godot_cpp/core/method_ptrcall.hpp | 6 +- include/godot_cpp/core/object.hpp | 16 ++-- include/godot_cpp/core/type_info.hpp | 8 +- include/godot_cpp/templates/cowdata.hpp | 32 ++++---- include/godot_cpp/templates/hash_map.hpp | 10 +-- include/godot_cpp/templates/hash_set.hpp | 6 +- include/godot_cpp/templates/hashfuncs.hpp | 10 +-- include/godot_cpp/templates/list.hpp | 10 +-- include/godot_cpp/templates/local_vector.hpp | 6 +- include/godot_cpp/templates/pair.hpp | 16 ++-- include/godot_cpp/templates/rb_map.hpp | 2 +- include/godot_cpp/templates/rb_set.hpp | 2 +- include/godot_cpp/templates/rid_owner.hpp | 6 +- include/godot_cpp/templates/safe_refcount.hpp | 4 +- include/godot_cpp/templates/search_array.hpp | 2 +- include/godot_cpp/templates/self_list.hpp | 2 +- include/godot_cpp/templates/sort_array.hpp | 4 +- .../godot_cpp/templates/thread_work_pool.hpp | 6 +- include/godot_cpp/templates/vector.hpp | 16 ++-- include/godot_cpp/templates/vmap.hpp | 2 +- include/godot_cpp/templates/vset.hpp | 2 +- .../variant/callable_method_pointer.hpp | 20 ++--- include/godot_cpp/variant/char_string.hpp | 8 +- include/godot_cpp/variant/typed_array.hpp | 2 +- include/godot_cpp/variant/variant.hpp | 4 +- src/variant/char_string.cpp | 8 +- 38 files changed, 228 insertions(+), 228 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index dbeb809b..d0794bb0 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -687,7 +687,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl vararg = method["is_vararg"] if vararg: - result.append("\ttemplate") + result.append("\ttemplate") method_signature = "\t" if "is_static" in method and method["is_static"]: @@ -786,7 +786,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl result.append("\tchar32_t *ptrw();") if class_name == "Array": - result.append("\ttemplate ") + result.append("\ttemplate ") result.append("\tstatic Array make(Args... args) {") result.append("\t\treturn helpers::append_all(Array(), args...);") result.append("\t}") @@ -1527,7 +1527,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us result.append("protected:") # T is the custom class we want to register (from which the call initiates, going up the inheritance chain), # B is its base class (can be a custom class too, that's why we pass it). - result.append("\ttemplate ") + result.append("\ttemplate ") result.append("\tstatic void register_virtuals() {") if class_name != "Object": result.append(f"\t\t{inherits}::register_virtuals();") @@ -1573,16 +1573,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us if class_name == "Object": result.append("") - result.append("\ttemplate") + result.append("\ttemplate") result.append("\tstatic T *cast_to(Object *p_object);") - result.append("\ttemplate") + result.append("\ttemplate") result.append("\tstatic const T *cast_to(const Object *p_object);") result.append("\tvirtual ~Object() = default;") elif use_template_get_node and class_name == "Node": - result.append("\ttemplate") + result.append("\ttemplate") result.append( "\tT *get_node(const NodePath &p_path) const { return Object::cast_to(get_node_internal(p_path)); }" ) @@ -2216,7 +2216,7 @@ def make_varargs_template( if with_public_declare: function_signature = "public: " - function_signature += "template " + function_signature += "template " if static: function_signature += "static " diff --git a/include/godot_cpp/classes/editor_plugin_registration.hpp b/include/godot_cpp/classes/editor_plugin_registration.hpp index 1ccde314..7870bfc7 100644 --- a/include/godot_cpp/classes/editor_plugin_registration.hpp +++ b/include/godot_cpp/classes/editor_plugin_registration.hpp @@ -47,11 +47,11 @@ public: static void remove_plugin_class(const StringName &p_class_name); static void deinitialize(GDExtensionInitializationLevel p_level); - template + template static void add_by_type() { add_plugin_class(T::get_class_static()); } - template + template static void remove_by_type() { remove_plugin_class(T::get_class_static()); } diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index f3fc3e94..c4682bcf 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -45,7 +45,7 @@ namespace godot { class RefCounted; -template +template class Ref { T *reference = nullptr; @@ -108,7 +108,7 @@ public: ref(p_from); } - template + template void operator=(const Ref &p_from) { RefCounted *refb = const_cast(static_cast(p_from.ptr())); if (!refb) { @@ -144,7 +144,7 @@ public: } } - template + template void reference_ptr(T_Other *p_ptr) { if (reference == p_ptr) { return; @@ -161,7 +161,7 @@ public: ref(p_from); } - template + template Ref(const Ref &p_from) { RefCounted *refb = const_cast(static_cast(p_from.ptr())); if (!refb) { @@ -226,7 +226,7 @@ public: } }; -template +template struct PtrToArg> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr; @@ -248,7 +248,7 @@ struct PtrToArg> { } }; -template +template struct PtrToArg &> { typedef Ref EncodeT; @@ -259,7 +259,7 @@ struct PtrToArg &> { } }; -template +template struct GetTypeInfo, typename EnableIf::value>::type> { static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; @@ -269,7 +269,7 @@ struct GetTypeInfo, typename EnableIf::value> } }; -template +template struct GetTypeInfo &, typename EnableIf::value>::type> { static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index fba855d3..97f9a6ed 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -115,13 +115,13 @@ _FORCE_INLINE_ void snarray_add_str(Vector &arr, const StringName &p arr.push_back(p_str); } -template +template _FORCE_INLINE_ void snarray_add_str(Vector &arr, const StringName &p_str, P... p_args) { arr.push_back(p_str); snarray_add_str(arr, p_args...); } -template +template _FORCE_INLINE_ Vector snarray(P... p_args) { Vector arr; snarray_add_str(arr, p_args...); @@ -138,7 +138,7 @@ void add_engine_class_registration_callback(EngineClassRegistrationCallback p_ca void register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks); void register_engine_classes(); -template +template struct EngineClassRegistration { EngineClassRegistration() { add_engine_class_registration_callback(&EngineClassRegistration::callback); @@ -207,7 +207,7 @@ protected: return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \ } \ \ - template \ + template \ static void register_virtuals() { \ m_inherits::register_virtuals(); \ } \ diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index ce90acda..26ed4ca3 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -83,7 +83,7 @@ namespace godot { }; \ } -template +template struct VariantCaster { static _FORCE_INLINE_ T cast(const Variant &p_variant) { using TStripped = std::remove_pointer_t; @@ -95,7 +95,7 @@ struct VariantCaster { } }; -template +template struct VariantCaster { static _FORCE_INLINE_ T cast(const Variant &p_variant) { using TStripped = std::remove_pointer_t; @@ -107,7 +107,7 @@ struct VariantCaster { } }; -template +template struct VariantCaster { static _FORCE_INLINE_ T cast(const Variant &p_variant) { using TStripped = std::remove_pointer_t; @@ -144,7 +144,7 @@ struct VariantObjectClassChecker &> { } }; -template +template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); @@ -159,7 +159,7 @@ struct VariantCasterAndValidate { } }; -template +template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); @@ -174,7 +174,7 @@ struct VariantCasterAndValidate { } }; -template +template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); @@ -189,47 +189,47 @@ struct VariantCasterAndValidate { } }; -template +template void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence) { (p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...); } -template +template void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, IndexSequence) { (p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...); } -template +template void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode((p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...), r_ret); } -template +template void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode((p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...), r_ret); } -template +template void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void * /*ret*/) { call_with_ptr_args_helper(p_instance, p_method, p_args, BuildIndexSequence{}); } -template +template void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void * /*ret*/) { call_with_ptr_argsc_helper(p_instance, p_method, p_args, BuildIndexSequence{}); } -template +template void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_ret_helper(p_instance, p_method, p_args, r_ret, BuildIndexSequence{}); } -template +template void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_retc_helper(p_instance, p_method, p_args, r_ret, BuildIndexSequence{}); } -template +template void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -241,7 +241,7 @@ void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), con (void)(p_args); // Avoid warning. } -template +template void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -253,7 +253,7 @@ void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) con (void)(p_args); // Avoid warning. } -template +template void call_with_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, Variant &r_ret, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -264,7 +264,7 @@ void call_with_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), co #endif } -template +template void call_with_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, Variant &r_ret, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -276,7 +276,7 @@ void call_with_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) co (void)p_args; } -template +template void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, int p_argcount, GDExtensionCallError &r_error) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -294,7 +294,7 @@ void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Vari call_with_variant_args_helper(p_instance, p_method, p_args, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -312,7 +312,7 @@ void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Var call_with_variant_args_ret_helper(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_retc(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -330,7 +330,7 @@ void call_with_variant_args_retc(T *p_instance, R (T::*p_method)(P...) const, co call_with_variant_args_retc_helper(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -365,7 +365,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G call_with_variant_args_helper(p_instance, p_method, argsp.data(), r_error, BuildIndexSequence{}); } -template +template void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstVariantPtr *p_args, int p_argcount, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -400,7 +400,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, call_with_variant_argsc_helper(p_instance, p_method, argsp.data(), r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -435,7 +435,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const call_with_variant_args_ret_helper(p_instance, p_method, argsp.data(), r_ret, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -477,7 +477,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #endif -template +template void call_get_argument_type_helper(int p_arg, int &index, GDExtensionVariantType &type) { if (p_arg == index) { type = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); @@ -485,7 +485,7 @@ void call_get_argument_type_helper(int p_arg, int &index, GDExtensionVariantType index++; } -template +template GDExtensionVariantType call_get_argument_type(int p_arg) { GDExtensionVariantType type = GDEXTENSION_VARIANT_TYPE_NIL; int index = 0; @@ -497,7 +497,7 @@ GDExtensionVariantType call_get_argument_type(int p_arg) { return type; } -template +template void call_get_argument_type_info_helper(int p_arg, int &index, PropertyInfo &info) { if (p_arg == index) { info = GetTypeInfo::get_class_info(); @@ -505,7 +505,7 @@ void call_get_argument_type_info_helper(int p_arg, int &index, PropertyInfo &inf index++; } -template +template void call_get_argument_type_info(int p_arg, PropertyInfo &info) { int index = 0; // I think rocket science is simpler than modern C++. @@ -515,7 +515,7 @@ void call_get_argument_type_info(int p_arg, PropertyInfo &info) { (void)index; // Suppress GCC warning. } -template +template void call_get_argument_metadata_helper(int p_arg, int &index, GDExtensionClassMethodArgumentMetadata &md) { if (p_arg == index) { md = GetTypeInfo::METADATA; @@ -523,7 +523,7 @@ void call_get_argument_metadata_helper(int p_arg, int &index, GDExtensionClassMe index++; } -template +template GDExtensionClassMethodArgumentMetadata call_get_argument_metadata(int p_arg) { GDExtensionClassMethodArgumentMetadata md = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; @@ -536,7 +536,7 @@ GDExtensionClassMethodArgumentMetadata call_get_argument_metadata(int p_arg) { return md; } -template +template void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -547,7 +547,7 @@ void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_arg #endif } -template +template void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -582,17 +582,17 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionC call_with_variant_args_static(p_method, argsp.data(), r_error, BuildIndexSequence{}); } -template +template void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence) { p_method(PtrToArg

::convert(p_args[Is])...); } -template +template void call_with_ptr_args_static_method(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args) { call_with_ptr_args_static_method_helper(p_method, p_args, BuildIndexSequence{}); } -template +template void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -610,7 +610,7 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar call_with_variant_args_static_ret(p_method, p_args, r_ret, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -628,7 +628,7 @@ void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p call_with_variant_args_static(p_method, p_args, r_error, BuildIndexSequence{}); } -template +template void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, Variant &r_ret, GDExtensionCallError &r_error, IndexSequence) { r_error.error = GDEXTENSION_CALL_OK; @@ -639,7 +639,7 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar #endif } -template +template void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { @@ -674,12 +674,12 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDExtension call_with_variant_args_static_ret(p_method, argsp.data(), r_ret, r_error, BuildIndexSequence{}); } -template +template void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode(p_method(PtrToArg

::convert(p_args[Is])...), r_ret); } -template +template void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_static_method_ret_helper(p_method, p_args, r_ret, BuildIndexSequence{}); } diff --git a/include/godot_cpp/core/builtin_ptrcall.hpp b/include/godot_cpp/core/builtin_ptrcall.hpp index 19250d84..286051fa 100644 --- a/include/godot_cpp/core/builtin_ptrcall.hpp +++ b/include/godot_cpp/core/builtin_ptrcall.hpp @@ -40,7 +40,7 @@ namespace godot { namespace internal { -template +template O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, const Args &...args) { GodotObject *ret = nullptr; std::array call_args = { { (GDExtensionConstTypePtr)args... } }; @@ -51,13 +51,13 @@ O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GD return reinterpret_cast(internal::get_object_instance_binding(ret)); } -template +template void _call_builtin_constructor(const GDExtensionPtrConstructor constructor, GDExtensionTypePtr base, Args... args) { std::array call_args = { { (GDExtensionConstTypePtr)args... } }; constructor(base, call_args.data()); } -template +template T _call_builtin_method_ptr_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) { T ret; std::array call_args = { { (GDExtensionConstTypePtr)args... } }; @@ -65,20 +65,20 @@ T _call_builtin_method_ptr_ret(const GDExtensionPtrBuiltInMethod method, GDExten return ret; } -template +template void _call_builtin_method_ptr_no_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) { std::array call_args = { { (GDExtensionConstTypePtr)args... } }; method(base, call_args.data(), nullptr, sizeof...(Args)); } -template +template T _call_builtin_operator_ptr(const GDExtensionPtrOperatorEvaluator op, GDExtensionConstTypePtr left, GDExtensionConstTypePtr right) { T ret; op(left, right, &ret); return ret; } -template +template T _call_builtin_ptr_getter(const GDExtensionPtrGetter getter, GDExtensionConstTypePtr base) { T ret; getter(base, &ret); diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 91748e65..fdac1e22 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -109,10 +109,10 @@ private: static void initialize_class(const ClassInfo &cl); static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method); - template + template static void _register_class(bool p_virtual = false, bool p_exposed = true, bool p_runtime = false); - template + template static GDExtensionObjectPtr _create_instance_func(void *data) { if constexpr (!std::is_abstract_v) { T *new_object = memnew(T); @@ -122,7 +122,7 @@ private: } } - template + template static GDExtensionClassInstancePtr _recreate_instance_func(void *data, GDExtensionObjectPtr obj) { if constexpr (!std::is_abstract_v) { #ifdef HOT_RELOAD_ENABLED @@ -140,26 +140,26 @@ private: } public: - template + template static void register_class(bool p_virtual = false); - template + template static void register_abstract_class(); - template + template static void register_internal_class(); - template + template static void register_runtime_class(); _FORCE_INLINE_ static void _register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks) { instance_binding_callbacks[p_name] = p_callbacks; } - template + template static MethodBind *bind_method(N p_method_name, M p_method, VarArgs... p_args); - template + template static MethodBind *bind_static_method(StringName p_class, N p_method_name, M p_method, VarArgs... p_args); - template + template static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const std::vector &p_default_args = std::vector{}, bool p_return_nil_is_variant = true); static void add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix); @@ -200,7 +200,7 @@ public: godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, _call##m_method); \ } -template +template void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { static_assert(TypesAreSame::value, "Class not declared properly, please use GDCLASS."); instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks; @@ -254,27 +254,27 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { initialize_class(classes[cl.name]); } -template +template void ClassDB::register_class(bool p_virtual) { ClassDB::_register_class(p_virtual); } -template +template void ClassDB::register_abstract_class() { ClassDB::_register_class(); } -template +template void ClassDB::register_internal_class() { ClassDB::_register_class(false, false); } -template +template void ClassDB::register_runtime_class() { ClassDB::_register_class(false, true, true); } -template +template MethodBind *ClassDB::bind_method(N p_method_name, M p_method, VarArgs... p_args) { Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported. const Variant *argptrs[sizeof...(p_args) + 1]; @@ -285,7 +285,7 @@ MethodBind *ClassDB::bind_method(N p_method_name, M p_method, VarArgs... p_args) return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const void **)argptrs, sizeof...(p_args)); } -template +template MethodBind *ClassDB::bind_static_method(StringName p_class, N p_method_name, M p_method, VarArgs... p_args) { Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported. const Variant *argptrs[sizeof...(p_args) + 1]; @@ -297,7 +297,7 @@ MethodBind *ClassDB::bind_static_method(StringName p_class, N p_method_name, M p return bind_methodfi(0, bind, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const void **)argptrs, sizeof...(p_args)); } -template +template MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info, const std::vector &p_default_args, bool p_return_nil_is_variant) { MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant); ERR_FAIL_NULL_V(bind, nullptr); diff --git a/include/godot_cpp/core/defs.hpp b/include/godot_cpp/core/defs.hpp index c03db503..16812c2b 100644 --- a/include/godot_cpp/core/defs.hpp +++ b/include/godot_cpp/core/defs.hpp @@ -108,7 +108,7 @@ typedef float real_t; // Generic swap template. #ifndef SWAP #define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y)) -template +template inline void __swap_tmpl(T &x, T &y) { T aux = x; x = y; diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index 69ab196b..482dfab7 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -43,7 +43,7 @@ namespace godot { namespace internal { -template +template O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { GodotObject *ret = nullptr; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; @@ -54,7 +54,7 @@ O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, co return reinterpret_cast(internal::get_object_instance_binding(ret)); } -template +template R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { R ret; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; @@ -62,13 +62,13 @@ R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const A return ret; } -template +template void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); } -template +template R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) { R ret; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; @@ -76,7 +76,7 @@ R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) { return ret; } -template +template Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, void *instance, const Args &...args) { GodotObject *ret = nullptr; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; @@ -84,7 +84,7 @@ Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, void *in return (Object *)internal::get_object_instance_binding(ret); } -template +template void _call_utility_no_ret(const GDExtensionPtrUtilityFunction func, const Args &...args) { std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; func(nullptr, mb_args.data(), mb_args.size()); diff --git a/include/godot_cpp/core/math.hpp b/include/godot_cpp/core/math.hpp index db97ba5d..2cbbe272 100644 --- a/include/godot_cpp/core/math.hpp +++ b/include/godot_cpp/core/math.hpp @@ -84,7 +84,7 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) { // Generic swap template. #ifndef SWAP #define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y)) -template +template inline void __swap_tmpl(T &x, T &y) { T aux = x; x = y; @@ -138,7 +138,7 @@ static inline int get_shift_from_power_of_2(unsigned int p_bits) { return -1; } -template +template static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) { --x; diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp index 6775cf76..3c98c194 100644 --- a/include/godot_cpp/core/memory.hpp +++ b/include/godot_cpp/core/memory.hpp @@ -84,7 +84,7 @@ public: _ALWAYS_INLINE_ void postinitialize_handler(void *) {} -template +template _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) { postinitialize_handler(p_obj); return p_obj; @@ -100,12 +100,12 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) { #define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new ("", m_placement, sizeof(m_class), "") m_class) // Generic comparator used in Map, List, etc. -template +template struct Comparator { _ALWAYS_INLINE_ bool operator()(const T &p_a, const T &p_b) const { return (p_a < p_b); } }; -template +template void memdelete(T *p_class, typename std::enable_if>::type * = nullptr) { if constexpr (!std::is_trivially_destructible_v) { p_class->~T(); @@ -114,12 +114,12 @@ void memdelete(T *p_class, typename std::enable_if, bool> = true> +template , bool> = true> void memdelete(T *p_class) { godot::internal::gdextension_interface_object_destroy(p_class->_owner); } -template +template void memdelete_allocator(T *p_class) { if constexpr (!std::is_trivially_destructible_v) { p_class->~T(); @@ -134,10 +134,10 @@ public: _ALWAYS_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr); } }; -template +template class DefaultTypedAllocator { public: - template + template _ALWAYS_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); } _ALWAYS_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); } }; diff --git a/include/godot_cpp/core/method_bind.hpp b/include/godot_cpp/core/method_bind.hpp index 37ae7317..4afd7b8a 100644 --- a/include/godot_cpp/core/method_bind.hpp +++ b/include/godot_cpp/core/method_bind.hpp @@ -147,7 +147,7 @@ public: virtual ~MethodBind(); }; -template +template class MethodBindVarArgBase : public MethodBind { protected: R(T::*method) @@ -208,7 +208,7 @@ private: } }; -template +template class MethodBindVarArgT : public MethodBindVarArgBase, T, void, false> { friend class MethodBindVarArgBase, T, void, false>; @@ -231,14 +231,14 @@ private: } }; -template +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 +template class MethodBindVarArgTR : public MethodBindVarArgBase, T, R, true> { friend class MethodBindVarArgBase, T, R, true>; @@ -260,7 +260,7 @@ private: } }; -template +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()); @@ -277,9 +277,9 @@ class _gde_UnexistingClass; // No return, not const. #ifdef TYPED_METHOD_BIND -template +template #else -template +template #endif // TYPED_METHOD_BIND class MethodBindT : public MethodBind { void (MB_T::*method)(P...); @@ -339,7 +339,7 @@ public: } }; -template +template MethodBind *create_method_bind(void (T::*p_method)(P...)) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindT)(p_method)); @@ -353,9 +353,9 @@ MethodBind *create_method_bind(void (T::*p_method)(P...)) { // No return, const. #ifdef TYPED_METHOD_BIND -template +template #else -template +template #endif // TYPED_METHOD_BIND class MethodBindTC : public MethodBind { void (MB_T::*method)(P...) const; @@ -415,7 +415,7 @@ public: } }; -template +template MethodBind *create_method_bind(void (T::*p_method)(P...) const) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTC)(p_method)); @@ -429,9 +429,9 @@ MethodBind *create_method_bind(void (T::*p_method)(P...) const) { // Return, not const. #ifdef TYPED_METHOD_BIND -template +template #else -template +template #endif // TYPED_METHOD_BIND class MethodBindTR : public MethodBind { R(MB_T::*method) @@ -498,7 +498,7 @@ public: } }; -template +template MethodBind *create_method_bind(R (T::*p_method)(P...)) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTR)(p_method)); @@ -512,9 +512,9 @@ MethodBind *create_method_bind(R (T::*p_method)(P...)) { // Return, const. #ifdef TYPED_METHOD_BIND -template +template #else -template +template #endif // TYPED_METHOD_BIND class MethodBindTRC : public MethodBind { R(MB_T::*method) @@ -581,7 +581,7 @@ public: } }; -template +template MethodBind *create_method_bind(R (T::*p_method)(P...) const) { #ifdef TYPED_METHOD_BIND MethodBind *a = memnew((MethodBindTRC)(p_method)); @@ -596,7 +596,7 @@ MethodBind *create_method_bind(R (T::*p_method)(P...) const) { // no return -template +template class MethodBindTS : public MethodBind { void (*function)(P...); @@ -652,7 +652,7 @@ public: } }; -template +template MethodBind *create_static_method_bind(void (*p_method)(P...)) { MethodBind *a = memnew((MethodBindTS)(p_method)); return a; @@ -660,7 +660,7 @@ MethodBind *create_static_method_bind(void (*p_method)(P...)) { // return -template +template class MethodBindTRS : public MethodBind { R(*function) (P...); @@ -722,7 +722,7 @@ public: } }; -template +template MethodBind *create_static_method_bind(R (*p_method)(P...)) { MethodBind *a = memnew((MethodBindTRS)(p_method)); return a; diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 32f3f459..ca3327ed 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -39,7 +39,7 @@ namespace godot { -template +template struct PtrToArg {}; #define MAKE_PTRARG(m_type) \ @@ -166,7 +166,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant); // This is for Object. -template +template struct PtrToArg { static_assert(std::is_base_of::value, "Cannot encode non-Object value as an Object"); _FORCE_INLINE_ static T *convert(const void *p_ptr) { @@ -178,7 +178,7 @@ struct PtrToArg { } }; -template +template struct PtrToArg { static_assert(std::is_base_of::value, "Cannot encode non-Object value as an Object"); _FORCE_INLINE_ static const T *convert(const void *p_ptr) { diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index c1f10692..0857200f 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -80,31 +80,31 @@ struct MethodInfo { MethodInfo(); MethodInfo(StringName p_name); - template + template MethodInfo(StringName p_name, const Args &...args); MethodInfo(Variant::Type ret); MethodInfo(Variant::Type ret, StringName p_name); - template + template MethodInfo(Variant::Type ret, StringName p_name, const Args &...args); MethodInfo(const PropertyInfo &p_ret, StringName p_name); - template + template MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...); }; -template +template MethodInfo::MethodInfo(StringName p_name, const Args &...args) : name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) { arguments = { args... }; } -template +template MethodInfo::MethodInfo(Variant::Type ret, StringName p_name, const Args &...args) : name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) { return_val.type = ret; arguments = { args... }; } -template +template MethodInfo::MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...args) : name(p_name), return_val(p_ret), flags(GDEXTENSION_METHOD_FLAG_NORMAL) { arguments = { args... }; @@ -121,7 +121,7 @@ public: } }; -template +template T *Object::cast_to(Object *p_object) { if (p_object == nullptr) { return nullptr; @@ -134,7 +134,7 @@ T *Object::cast_to(Object *p_object) { return dynamic_cast(internal::get_object_instance_binding(casted)); } -template +template const T *Object::cast_to(const Object *p_object) { if (p_object == nullptr) { return nullptr; diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index a5cb174f..2bed6be5 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -90,7 +90,7 @@ static PropertyInfo make_property_info(Variant::Type p_type, const StringName &p // instead of a forward declaration. You can always forward declare 'T' in a header file, and then // include the actual declaration of 'T' in the source file where 'GetTypeInfo' is instantiated. -template +template struct GetTypeInfo; #define MAKE_TYPE_INFO(m_type, m_var_type) \ @@ -248,7 +248,7 @@ inline StringName _gde_constant_get_enum_name(T param, StringName p_constant) { return GetTypeInfo::get_class_info().class_name; } -template +template class BitField { int64_t value = 0; @@ -295,7 +295,7 @@ inline StringName _gde_constant_get_bitfield_name(T param, StringName p_constant return GetTypeInfo>::get_class_info().class_name; } -template +template struct PtrToArg> { _FORCE_INLINE_ static TypedArray convert(const void *p_ptr) { return TypedArray(*reinterpret_cast(p_ptr)); @@ -306,7 +306,7 @@ struct PtrToArg> { } }; -template +template struct PtrToArg &> { typedef Array EncodeT; _FORCE_INLINE_ static TypedArray diff --git a/include/godot_cpp/templates/cowdata.hpp b/include/godot_cpp/templates/cowdata.hpp index f2959d19..dcb74ecc 100644 --- a/include/godot_cpp/templates/cowdata.hpp +++ b/include/godot_cpp/templates/cowdata.hpp @@ -43,13 +43,13 @@ namespace godot { -template +template class Vector; -template +template class VMap; -template +template class CharStringT; static_assert(std::is_trivially_destructible_v>); @@ -60,15 +60,15 @@ static_assert(std::is_trivially_destructible_v>); #pragma GCC diagnostic ignored "-Wplacement-new" #endif -template +template class CowData { - template + template friend class Vector; - template + template friend class VMap; - template + template friend class CharStringT; public: @@ -248,7 +248,7 @@ public: _FORCE_INLINE_ CowData(CowData &p_from) { _ref(p_from); }; }; -template +template void CowData::_unref(void *p_data) { if (!p_data) { return; @@ -275,7 +275,7 @@ void CowData::_unref(void *p_data) { Memory::free_static(((uint8_t *)p_data) - DATA_OFFSET, false); } -template +template typename CowData::USize CowData::_copy_on_write() { if (!_ptr) { return 0; @@ -315,7 +315,7 @@ typename CowData::USize CowData::_copy_on_write() { return rc; } -template +template template Error CowData::resize(Size p_size) { ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER); @@ -407,7 +407,7 @@ Error CowData::resize(Size p_size) { return OK; } -template +template typename CowData::Size CowData::find(const T &p_val, Size p_from) const { Size ret = -1; @@ -425,7 +425,7 @@ typename CowData::Size CowData::find(const T &p_val, Size p_from) const { return ret; } -template +template typename CowData::Size CowData::rfind(const T &p_val, Size p_from) const { const Size s = size(); @@ -444,7 +444,7 @@ typename CowData::Size CowData::rfind(const T &p_val, Size p_from) const { return -1; } -template +template typename CowData::Size CowData::count(const T &p_val) const { Size amount = 0; for (Size i = 0; i < size(); i++) { @@ -455,12 +455,12 @@ typename CowData::Size CowData::count(const T &p_val) const { return amount; } -template +template void CowData::_ref(const CowData *p_from) { _ref(*p_from); } -template +template void CowData::_ref(const CowData &p_from) { if (_ptr == p_from._ptr) { return; // self assign, do nothing. @@ -478,7 +478,7 @@ void CowData::_ref(const CowData &p_from) { } } -template +template CowData::~CowData() { _unref(_ptr); } diff --git a/include/godot_cpp/templates/hash_map.hpp b/include/godot_cpp/templates/hash_map.hpp index 77c7b7a9..59cd8e0b 100644 --- a/include/godot_cpp/templates/hash_map.hpp +++ b/include/godot_cpp/templates/hash_map.hpp @@ -52,7 +52,7 @@ namespace godot { * The assignment operator copy the pairs from one map to the other. */ -template +template struct HashMapElement { HashMapElement *next = nullptr; HashMapElement *prev = nullptr; @@ -62,10 +62,10 @@ struct HashMapElement { data(p_key, p_value) {} }; -template , - class Allocator = DefaultTypedAllocator>> +template , + typename Allocator = DefaultTypedAllocator>> class HashMap { public: const uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime. diff --git a/include/godot_cpp/templates/hash_set.hpp b/include/godot_cpp/templates/hash_set.hpp index 884ae4db..1845a1bb 100644 --- a/include/godot_cpp/templates/hash_set.hpp +++ b/include/godot_cpp/templates/hash_set.hpp @@ -48,9 +48,9 @@ namespace godot { * */ -template > +template > class HashSet { public: static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime. diff --git a/include/godot_cpp/templates/hashfuncs.hpp b/include/godot_cpp/templates/hashfuncs.hpp index d6f34002..40b10a9e 100644 --- a/include/godot_cpp/templates/hashfuncs.hpp +++ b/include/godot_cpp/templates/hashfuncs.hpp @@ -253,7 +253,7 @@ static _FORCE_INLINE_ uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev return ((p_prev << 5) + p_prev) + hash_one_uint64(u.i); } -template +template static _FORCE_INLINE_ uint32_t hash_make_uint32_t(T p_in) { union { T t; @@ -286,7 +286,7 @@ static _FORCE_INLINE_ uint64_t hash_djb2_one_64(uint64_t p_in, uint64_t p_prev = return ((p_prev << 5) + p_prev) ^ p_in; } -template +template static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) { union { T t; @@ -298,15 +298,15 @@ static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) { return _u._u64; } -template +template class Ref; struct HashMapHasherDefault { // Generic hash function for any type. - template + template static _FORCE_INLINE_ uint32_t hash(const T *p_pointer) { return hash_one_uint64((uint64_t)p_pointer); } - template + template static _FORCE_INLINE_ uint32_t hash(const Ref &p_ref) { return hash_one_uint64((uint64_t)p_ref.operator->()); } static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); } diff --git a/include/godot_cpp/templates/list.hpp b/include/godot_cpp/templates/list.hpp index 2c8a7c87..376e3ea8 100644 --- a/include/godot_cpp/templates/list.hpp +++ b/include/godot_cpp/templates/list.hpp @@ -45,7 +45,7 @@ namespace godot { -template +template class List { struct _Data; @@ -410,7 +410,7 @@ public: /** * find an element in the list, */ - template + template Element *find(const T_v &p_val) { Element *it = front(); while (it) { @@ -646,7 +646,7 @@ public: sort_custom>(); } - template + template void sort_custom_inplace() { if (size() < 2) { return; @@ -693,7 +693,7 @@ public: _data->last = to; } - template + template struct AuxiliaryComparator { C compare; _FORCE_INLINE_ bool operator()(const Element *a, const Element *b) const { @@ -701,7 +701,7 @@ public: } }; - template + template void sort_custom() { // this version uses auxiliary memory for speed. // if you don't want to use auxiliary memory, use the in_place version diff --git a/include/godot_cpp/templates/local_vector.hpp b/include/godot_cpp/templates/local_vector.hpp index 8ce4e655..5dad32e0 100644 --- a/include/godot_cpp/templates/local_vector.hpp +++ b/include/godot_cpp/templates/local_vector.hpp @@ -43,7 +43,7 @@ namespace godot { // If tight, it grows strictly as much as needed. // Otherwise, it grows exponentially (the default and what you want in most cases). -template +template class LocalVector { private: U count = 0; @@ -257,7 +257,7 @@ public: return -1; } - template + template void sort_custom() { U len = count; if (len == 0) { @@ -331,7 +331,7 @@ public: } }; -template +template using TightLocalVector = LocalVector; } // namespace godot diff --git a/include/godot_cpp/templates/pair.hpp b/include/godot_cpp/templates/pair.hpp index ed35302b..f8754130 100644 --- a/include/godot_cpp/templates/pair.hpp +++ b/include/godot_cpp/templates/pair.hpp @@ -33,7 +33,7 @@ namespace godot { -template +template struct Pair { F first; S second; @@ -49,17 +49,17 @@ struct Pair { } }; -template +template bool operator==(const Pair &pair, const Pair &other) { return (pair.first == other.first) && (pair.second == other.second); } -template +template bool operator!=(const Pair &pair, const Pair &other) { return (pair.first != other.first) || (pair.second != other.second); } -template +template struct PairSort { bool operator()(const Pair &A, const Pair &B) const { if (A.first != B.first) { @@ -69,7 +69,7 @@ struct PairSort { } }; -template +template struct KeyValue { const K key; V value; @@ -85,17 +85,17 @@ struct KeyValue { } }; -template +template bool operator==(const KeyValue &pair, const KeyValue &other) { return (pair.key == other.key) && (pair.value == other.value); } -template +template bool operator!=(const KeyValue &pair, const KeyValue &other) { return (pair.key != other.key) || (pair.value != other.value); } -template +template struct KeyValueSort { bool operator()(const KeyValue &A, const KeyValue &B) const { return A.key < B.key; diff --git a/include/godot_cpp/templates/rb_map.hpp b/include/godot_cpp/templates/rb_map.hpp index cce1e91b..6ab71fd7 100644 --- a/include/godot_cpp/templates/rb_map.hpp +++ b/include/godot_cpp/templates/rb_map.hpp @@ -40,7 +40,7 @@ namespace godot { // based on the very nice implementation of rb-trees by: // https://web.archive.org/web/20120507164830/https://web.mit.edu/~emin/www/source_code/red_black_tree/index.html -template , class A = DefaultAllocator> +template , typename A = DefaultAllocator> class RBMap { enum Color { RED, diff --git a/include/godot_cpp/templates/rb_set.hpp b/include/godot_cpp/templates/rb_set.hpp index c803f818..69aa8d7f 100644 --- a/include/godot_cpp/templates/rb_set.hpp +++ b/include/godot_cpp/templates/rb_set.hpp @@ -38,7 +38,7 @@ namespace godot { -template , class A = DefaultAllocator> +template , typename A = DefaultAllocator> class RBSet { enum Color { RED, diff --git a/include/godot_cpp/templates/rid_owner.hpp b/include/godot_cpp/templates/rid_owner.hpp index 005fc876..1dd4a393 100644 --- a/include/godot_cpp/templates/rid_owner.hpp +++ b/include/godot_cpp/templates/rid_owner.hpp @@ -42,7 +42,7 @@ namespace godot { -template +template class RID_Alloc { T **chunks = nullptr; uint32_t **free_list_chunks = nullptr; @@ -347,7 +347,7 @@ public: } }; -template +template class RID_PtrOwner { RID_Alloc alloc; @@ -406,7 +406,7 @@ public: alloc(p_target_chunk_byte_size) {} }; -template +template class RID_Owner { RID_Alloc alloc; diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp index 519bbf74..12e6840a 100644 --- a/include/godot_cpp/templates/safe_refcount.hpp +++ b/include/godot_cpp/templates/safe_refcount.hpp @@ -57,7 +57,7 @@ namespace godot { static_assert(sizeof(SafeFlag) == sizeof(bool)); \ static_assert(alignof(SafeFlag) == alignof(bool)); -template +template class SafeNumeric { std::atomic value; @@ -195,7 +195,7 @@ public: #else -template +template class SafeNumeric { protected: T value; diff --git a/include/godot_cpp/templates/search_array.hpp b/include/godot_cpp/templates/search_array.hpp index ce2713bd..11a9db52 100644 --- a/include/godot_cpp/templates/search_array.hpp +++ b/include/godot_cpp/templates/search_array.hpp @@ -35,7 +35,7 @@ namespace godot { -template > +template > class SearchArray { public: Comparator compare; diff --git a/include/godot_cpp/templates/self_list.hpp b/include/godot_cpp/templates/self_list.hpp index 3bb13a35..f7a65f68 100644 --- a/include/godot_cpp/templates/self_list.hpp +++ b/include/godot_cpp/templates/self_list.hpp @@ -36,7 +36,7 @@ namespace godot { -template +template class SelfList { public: class List { diff --git a/include/godot_cpp/templates/sort_array.hpp b/include/godot_cpp/templates/sort_array.hpp index 5dda5782..7ce5c784 100644 --- a/include/godot_cpp/templates/sort_array.hpp +++ b/include/godot_cpp/templates/sort_array.hpp @@ -41,7 +41,7 @@ namespace godot { break; \ } -template +template struct _DefaultComparator { _FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); } }; @@ -52,7 +52,7 @@ struct _DefaultComparator { #define SORT_ARRAY_VALIDATE_ENABLED false #endif -template , bool Validate = SORT_ARRAY_VALIDATE_ENABLED> +template , bool Validate = SORT_ARRAY_VALIDATE_ENABLED> class SortArray { enum { INTROSORT_THRESHOLD = 16 diff --git a/include/godot_cpp/templates/thread_work_pool.hpp b/include/godot_cpp/templates/thread_work_pool.hpp index a3efd42e..cb20c6e9 100644 --- a/include/godot_cpp/templates/thread_work_pool.hpp +++ b/include/godot_cpp/templates/thread_work_pool.hpp @@ -52,7 +52,7 @@ class ThreadWorkPool { virtual ~BaseWork() = default; }; - template + template struct Work : public BaseWork { C *instance; M method; @@ -94,7 +94,7 @@ class ThreadWorkPool { } public: - template + template void begin_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) { ERR_FAIL_NULL(threads); // Never initialized. ERR_FAIL_COND(current_work != nullptr); @@ -145,7 +145,7 @@ public: current_work = nullptr; } - template + template void do_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) { switch (p_elements) { case 0: diff --git a/include/godot_cpp/templates/vector.hpp b/include/godot_cpp/templates/vector.hpp index 05b7184c..aaa84f33 100644 --- a/include/godot_cpp/templates/vector.hpp +++ b/include/godot_cpp/templates/vector.hpp @@ -47,7 +47,7 @@ namespace godot { -template +template class VectorWriteProxy { public: _FORCE_INLINE_ T &operator[](typename CowData::Size p_index) { @@ -57,7 +57,7 @@ public: } }; -template +template class Vector { friend class VectorWriteProxy; @@ -110,7 +110,7 @@ public: sort_custom<_DefaultComparator>(); } - template + template void sort_custom(Args &&...args) { Size len = _cowdata.size(); if (len == 0) { @@ -126,7 +126,7 @@ public: return bsearch_custom<_DefaultComparator>(p_value, p_before); } - template + template Size bsearch_custom(const Value &p_value, bool p_before, Args &&...args) { SearchArray search{ args... }; return search.bisect(ptrw(), size(), p_value, p_before); @@ -293,7 +293,7 @@ public: _FORCE_INLINE_ ~Vector() {} }; -template +template void Vector::reverse() { for (Size i = 0; i < size() / 2; i++) { T *p = ptrw(); @@ -301,7 +301,7 @@ void Vector::reverse() { } } -template +template void Vector::append_array(Vector p_other) { const Size ds = p_other.size(); if (ds == 0) { @@ -314,7 +314,7 @@ void Vector::append_array(Vector p_other) { } } -template +template bool Vector::push_back(T p_elem) { Error err = resize(size() + 1); ERR_FAIL_COND_V(err, true); @@ -323,7 +323,7 @@ bool Vector::push_back(T p_elem) { return false; } -template +template void Vector::fill(T p_elem) { T *p = ptrw(); for (Size i = 0; i < size(); i++) { diff --git a/include/godot_cpp/templates/vmap.hpp b/include/godot_cpp/templates/vmap.hpp index 881ac25e..926ccd39 100644 --- a/include/godot_cpp/templates/vmap.hpp +++ b/include/godot_cpp/templates/vmap.hpp @@ -35,7 +35,7 @@ namespace godot { -template +template class VMap { public: struct Pair { diff --git a/include/godot_cpp/templates/vset.hpp b/include/godot_cpp/templates/vset.hpp index 29f0cefe..ce21ba83 100644 --- a/include/godot_cpp/templates/vset.hpp +++ b/include/godot_cpp/templates/vset.hpp @@ -35,7 +35,7 @@ namespace godot { -template +template class VSet { Vector _data; diff --git a/include/godot_cpp/variant/callable_method_pointer.hpp b/include/godot_cpp/variant/callable_method_pointer.hpp index 159f976d..f9e7d737 100644 --- a/include/godot_cpp/variant/callable_method_pointer.hpp +++ b/include/godot_cpp/variant/callable_method_pointer.hpp @@ -60,7 +60,7 @@ Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_m // No return value. // -template +template class CallableCustomMethodPointer : public CallableCustomMethodPointerBase { struct Data { T *instance; @@ -85,7 +85,7 @@ public: } }; -template +template Callable create_custom_callable_function_pointer(T *p_instance, void (T::*p_method)(P...)) { typedef CallableCustomMethodPointer CCMP; CCMP *ccmp = memnew(CCMP(p_instance, p_method)); @@ -96,7 +96,7 @@ Callable create_custom_callable_function_pointer(T *p_instance, void (T::*p_meth // With return value. // -template +template class CallableCustomMethodPointerRet : public CallableCustomMethodPointerBase { struct Data { T *instance; @@ -122,7 +122,7 @@ public: } }; -template +template Callable create_custom_callable_function_pointer(T *p_instance, R (T::*p_method)(P...)) { typedef CallableCustomMethodPointerRet CCMP; // Messes with memnew otherwise. CCMP *ccmp = memnew(CCMP(p_instance, p_method)); @@ -133,7 +133,7 @@ Callable create_custom_callable_function_pointer(T *p_instance, R (T::*p_method) // Const with return value. // -template +template class CallableCustomMethodPointerRetC : public CallableCustomMethodPointerBase { struct Data { T *instance; @@ -159,7 +159,7 @@ public: } }; -template +template Callable create_custom_callable_function_pointer(const T *p_instance, R (T::*p_method)(P...) const) { typedef CallableCustomMethodPointerRetC CCMP; // Messes with memnew otherwise. CCMP *ccmp = memnew(CCMP(p_instance, p_method)); @@ -170,7 +170,7 @@ Callable create_custom_callable_function_pointer(const T *p_instance, R (T::*p_m // Static method with no return value. // -template +template class CallableCustomStaticMethodPointer : public CallableCustomMethodPointerBase { struct Data { void (*method)(P...); @@ -194,7 +194,7 @@ public: } }; -template +template Callable create_custom_callable_static_function_pointer(void (*p_method)(P...)) { typedef CallableCustomStaticMethodPointer CCMP; CCMP *ccmp = memnew(CCMP(p_method)); @@ -205,7 +205,7 @@ Callable create_custom_callable_static_function_pointer(void (*p_method)(P...)) // Static method with return value. // -template +template class CallableCustomStaticMethodPointerRet : public CallableCustomMethodPointerBase { struct Data { R(*method) @@ -229,7 +229,7 @@ public: } }; -template +template Callable create_custom_callable_static_function_pointer(R (*p_method)(P...)) { typedef CallableCustomStaticMethodPointerRet CCMP; CCMP *ccmp = memnew(CCMP(p_method)); diff --git a/include/godot_cpp/variant/char_string.hpp b/include/godot_cpp/variant/char_string.hpp index 993d0467..991c0392 100644 --- a/include/godot_cpp/variant/char_string.hpp +++ b/include/godot_cpp/variant/char_string.hpp @@ -38,12 +38,12 @@ namespace godot { -template +template class CharStringT; -template +template class CharProxy { - template + template friend class CharStringT; const int64_t _index; @@ -80,7 +80,7 @@ public: } }; -template +template class CharStringT { friend class String; diff --git a/include/godot_cpp/variant/typed_array.hpp b/include/godot_cpp/variant/typed_array.hpp index 2261509a..47b74107 100644 --- a/include/godot_cpp/variant/typed_array.hpp +++ b/include/godot_cpp/variant/typed_array.hpp @@ -36,7 +36,7 @@ namespace godot { -template +template class TypedArray : public Array { public: _FORCE_INLINE_ void operator=(const Array &p_array) { diff --git a/include/godot_cpp/variant/variant.hpp b/include/godot_cpp/variant/variant.hpp index 3c64791a..74357389 100644 --- a/include/godot_cpp/variant/variant.hpp +++ b/include/godot_cpp/variant/variant.hpp @@ -270,7 +270,7 @@ public: void callp(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error); - template + template Variant call(const StringName &method, Args... args) { std::array vargs = { args... }; std::array argptrs; @@ -285,7 +285,7 @@ public: static void callp_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error); - template + template static Variant call_static(Variant::Type type, const StringName &method, Args... args) { std::array vargs = { args... }; std::array argptrs; diff --git a/src/variant/char_string.cpp b/src/variant/char_string.cpp index 3c1ac108..cac46cf5 100644 --- a/src/variant/char_string.cpp +++ b/src/variant/char_string.cpp @@ -65,7 +65,7 @@ _FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) { } } -template +template bool CharStringT::operator<(const CharStringT &p_right) const { if (length() == 0) { return p_right.length() != 0; @@ -74,7 +74,7 @@ bool CharStringT::operator<(const CharStringT &p_right) const { return is_str_less(get_data(), p_right.get_data()); } -template +template CharStringT &CharStringT::operator+=(T p_char) { const int64_t lhs_len = length(); resize(lhs_len + 2); @@ -86,7 +86,7 @@ CharStringT &CharStringT::operator+=(T p_char) { return *this; } -template +template void CharStringT::operator=(const T *p_cstr) { copy_from(p_cstr); } @@ -127,7 +127,7 @@ const wchar_t *CharStringT::get_data() const { } } -template +template void CharStringT::copy_from(const T *p_cstr) { if (!p_cstr) { resize(0);