Enforce template syntax `typename` over `class`
(cherry picked from commit 87f5fb0691
)
pull/1410/head
parent
98ad839827
commit
7473b984cb
|
@ -567,7 +567,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
|
|
||||||
vararg = method["is_vararg"]
|
vararg = method["is_vararg"]
|
||||||
if vararg:
|
if vararg:
|
||||||
result.append("\ttemplate<class... Args>")
|
result.append("\ttemplate<typename... Args>")
|
||||||
|
|
||||||
method_signature = "\t"
|
method_signature = "\t"
|
||||||
if "is_static" in method and method["is_static"]:
|
if "is_static" in method and method["is_static"]:
|
||||||
|
@ -666,7 +666,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
result.append("\tchar32_t *ptrw();")
|
result.append("\tchar32_t *ptrw();")
|
||||||
|
|
||||||
if class_name == "Array":
|
if class_name == "Array":
|
||||||
result.append("\ttemplate <class... Args>")
|
result.append("\ttemplate <typename... Args>")
|
||||||
result.append("\tstatic Array make(Args... args) {")
|
result.append("\tstatic Array make(Args... args) {")
|
||||||
result.append("\t\treturn helpers::append_all(Array(), args...);")
|
result.append("\t\treturn helpers::append_all(Array(), args...);")
|
||||||
result.append("\t}")
|
result.append("\t}")
|
||||||
|
@ -1427,7 +1427,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
result.append("protected:")
|
result.append("protected:")
|
||||||
# T is the custom class we want to register (from which the call initiates, going up the inheritance chain),
|
# 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).
|
# B is its base class (can be a custom class too, that's why we pass it).
|
||||||
result.append("\ttemplate <class T, class B>")
|
result.append("\ttemplate <typename T, typename B>")
|
||||||
result.append("\tstatic void register_virtuals() {")
|
result.append("\tstatic void register_virtuals() {")
|
||||||
if class_name != "Object":
|
if class_name != "Object":
|
||||||
result.append(f"\t\t{inherits}::register_virtuals<T, B>();")
|
result.append(f"\t\t{inherits}::register_virtuals<T, B>();")
|
||||||
|
@ -1473,16 +1473,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
if class_name == "Object":
|
if class_name == "Object":
|
||||||
result.append("")
|
result.append("")
|
||||||
|
|
||||||
result.append("\ttemplate<class T>")
|
result.append("\ttemplate<typename T>")
|
||||||
result.append("\tstatic T *cast_to(Object *p_object);")
|
result.append("\tstatic T *cast_to(Object *p_object);")
|
||||||
|
|
||||||
result.append("\ttemplate<class T>")
|
result.append("\ttemplate<typename T>")
|
||||||
result.append("\tstatic const T *cast_to(const Object *p_object);")
|
result.append("\tstatic const T *cast_to(const Object *p_object);")
|
||||||
|
|
||||||
result.append("\tvirtual ~Object() = default;")
|
result.append("\tvirtual ~Object() = default;")
|
||||||
|
|
||||||
elif use_template_get_node and class_name == "Node":
|
elif use_template_get_node and class_name == "Node":
|
||||||
result.append("\ttemplate<class T>")
|
result.append("\ttemplate<typename T>")
|
||||||
result.append(
|
result.append(
|
||||||
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
|
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
|
||||||
)
|
)
|
||||||
|
@ -2116,7 +2116,7 @@ def make_varargs_template(
|
||||||
if with_public_declare:
|
if with_public_declare:
|
||||||
function_signature = "public: "
|
function_signature = "public: "
|
||||||
|
|
||||||
function_signature += "template<class... Args> "
|
function_signature += "template<typename... Args> "
|
||||||
|
|
||||||
if static:
|
if static:
|
||||||
function_signature += "static "
|
function_signature += "static "
|
||||||
|
|
|
@ -47,11 +47,11 @@ public:
|
||||||
static void remove_plugin_class(const StringName &p_class_name);
|
static void remove_plugin_class(const StringName &p_class_name);
|
||||||
static void deinitialize(GDExtensionInitializationLevel p_level);
|
static void deinitialize(GDExtensionInitializationLevel p_level);
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static void add_by_type() {
|
static void add_by_type() {
|
||||||
add_plugin_class(T::get_class_static());
|
add_plugin_class(T::get_class_static());
|
||||||
}
|
}
|
||||||
template <class T>
|
template <typename T>
|
||||||
static void remove_by_type() {
|
static void remove_by_type() {
|
||||||
remove_plugin_class(T::get_class_static());
|
remove_plugin_class(T::get_class_static());
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace godot {
|
||||||
|
|
||||||
class RefCounted;
|
class RefCounted;
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class Ref {
|
class Ref {
|
||||||
T *reference = nullptr;
|
T *reference = nullptr;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
ref(p_from);
|
ref(p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T_Other>
|
template <typename T_Other>
|
||||||
void operator=(const Ref<T_Other> &p_from) {
|
void operator=(const Ref<T_Other> &p_from) {
|
||||||
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
|
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
|
||||||
if (!refb) {
|
if (!refb) {
|
||||||
|
@ -144,7 +144,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T_Other>
|
template <typename T_Other>
|
||||||
void reference_ptr(T_Other *p_ptr) {
|
void reference_ptr(T_Other *p_ptr) {
|
||||||
if (reference == p_ptr) {
|
if (reference == p_ptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
ref(p_from);
|
ref(p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T_Other>
|
template <typename T_Other>
|
||||||
Ref(const Ref<T_Other> &p_from) {
|
Ref(const Ref<T_Other> &p_from) {
|
||||||
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
|
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
|
||||||
if (!refb) {
|
if (!refb) {
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<Ref<T>> {
|
struct PtrToArg<Ref<T>> {
|
||||||
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
|
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
|
||||||
GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr;
|
GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr;
|
||||||
|
@ -248,7 +248,7 @@ struct PtrToArg<Ref<T>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<const Ref<T> &> {
|
struct PtrToArg<const Ref<T> &> {
|
||||||
typedef Ref<T> EncodeT;
|
typedef Ref<T> EncodeT;
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ struct PtrToArg<const Ref<T> &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
||||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||||
|
@ -269,7 +269,7 @@ struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
||||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||||
|
|
|
@ -117,7 +117,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_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks);
|
||||||
void register_engine_classes();
|
void register_engine_classes();
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct EngineClassRegistration {
|
struct EngineClassRegistration {
|
||||||
EngineClassRegistration() {
|
EngineClassRegistration() {
|
||||||
add_engine_class_registration_callback(&EngineClassRegistration<T>::callback);
|
add_engine_class_registration_callback(&EngineClassRegistration<T>::callback);
|
||||||
|
@ -186,7 +186,7 @@ protected:
|
||||||
return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \
|
return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
template <class T, class B> \
|
template <typename T, typename B> \
|
||||||
static void register_virtuals() { \
|
static void register_virtuals() { \
|
||||||
m_inherits::register_virtuals<T, B>(); \
|
m_inherits::register_virtuals<T, B>(); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace godot {
|
||||||
}; \
|
}; \
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCaster {
|
struct VariantCaster {
|
||||||
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
||||||
using TStripped = std::remove_pointer_t<T>;
|
using TStripped = std::remove_pointer_t<T>;
|
||||||
|
@ -95,7 +95,7 @@ struct VariantCaster {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCaster<T &> {
|
struct VariantCaster<T &> {
|
||||||
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
||||||
using TStripped = std::remove_pointer_t<T>;
|
using TStripped = std::remove_pointer_t<T>;
|
||||||
|
@ -107,7 +107,7 @@ struct VariantCaster<T &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCaster<const T &> {
|
struct VariantCaster<const T &> {
|
||||||
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
|
||||||
using TStripped = std::remove_pointer_t<T>;
|
using TStripped = std::remove_pointer_t<T>;
|
||||||
|
@ -144,7 +144,7 @@ struct VariantObjectClassChecker<const Ref<T> &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCasterAndValidate {
|
struct VariantCasterAndValidate {
|
||||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
||||||
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
||||||
|
@ -159,7 +159,7 @@ struct VariantCasterAndValidate {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCasterAndValidate<T &> {
|
struct VariantCasterAndValidate<T &> {
|
||||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
||||||
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
||||||
|
@ -174,7 +174,7 @@ struct VariantCasterAndValidate<T &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct VariantCasterAndValidate<const T &> {
|
struct VariantCasterAndValidate<const T &> {
|
||||||
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
|
||||||
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
|
||||||
|
@ -189,47 +189,47 @@ struct VariantCasterAndValidate<const T &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class... P, size_t... Is>
|
template <typename T, typename... P, size_t... Is>
|
||||||
void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
||||||
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
|
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P, size_t... Is>
|
template <typename T, typename... P, size_t... Is>
|
||||||
void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
||||||
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
|
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P, size_t... Is>
|
template <typename T, typename R, typename... P, size_t... Is>
|
||||||
void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
||||||
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P, size_t... Is>
|
template <typename T, typename R, typename... P, size_t... Is>
|
||||||
void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
||||||
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void * /*ret*/) {
|
void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void * /*ret*/) {
|
||||||
call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void * /*ret*/) {
|
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<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_argsc_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret) {
|
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<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_args_ret_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, const GDExtensionConstTypePtr *p_args, void *r_ret) {
|
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<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_args_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P, size_t... Is>
|
template <typename T, typename... P, size_t... Is>
|
||||||
void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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.
|
(void)(p_args); // Avoid warning.
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P, size_t... Is>
|
template <typename T, typename... P, size_t... Is>
|
||||||
void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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.
|
(void)(p_args); // Avoid warning.
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P, size_t... Is>
|
template <typename T, typename R, typename... P, size_t... Is>
|
||||||
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<Is...>) {
|
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<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P, size_t... Is>
|
template <typename T, typename R, typename... P, size_t... Is>
|
||||||
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<Is...>) {
|
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<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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;
|
(void)p_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, int p_argcount, GDExtensionCallError &r_error) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<T, P...>(p_instance, p_method, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
|
call_with_variant_args_helper<T, P...>(p_instance, p_method, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
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) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<T, R, P...>(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
call_with_variant_args_ret_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
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) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<T, R, P...>(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
call_with_variant_args_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
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<Variant> &default_values) {
|
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<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<sizeof...(P)>{});
|
call_with_variant_args_helper(p_instance, p_method, argsp.data(), r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
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<Variant> &default_values) {
|
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<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<sizeof...(P)>{});
|
call_with_variant_argsc_helper(p_instance, p_method, argsp.data(), r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
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<Variant> &default_values) {
|
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<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<sizeof...(P)>{});
|
call_with_variant_args_ret_helper(p_instance, p_method, argsp.data(), r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
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<Variant> &default_values) {
|
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<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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"
|
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class Q>
|
template <typename Q>
|
||||||
void call_get_argument_type_helper(int p_arg, int &index, GDExtensionVariantType &type) {
|
void call_get_argument_type_helper(int p_arg, int &index, GDExtensionVariantType &type) {
|
||||||
if (p_arg == index) {
|
if (p_arg == index) {
|
||||||
type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
|
type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
|
||||||
|
@ -485,7 +485,7 @@ void call_get_argument_type_helper(int p_arg, int &index, GDExtensionVariantType
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
GDExtensionVariantType call_get_argument_type(int p_arg) {
|
GDExtensionVariantType call_get_argument_type(int p_arg) {
|
||||||
GDExtensionVariantType type = GDEXTENSION_VARIANT_TYPE_NIL;
|
GDExtensionVariantType type = GDEXTENSION_VARIANT_TYPE_NIL;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -497,7 +497,7 @@ GDExtensionVariantType call_get_argument_type(int p_arg) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Q>
|
template <typename Q>
|
||||||
void call_get_argument_type_info_helper(int p_arg, int &index, PropertyInfo &info) {
|
void call_get_argument_type_info_helper(int p_arg, int &index, PropertyInfo &info) {
|
||||||
if (p_arg == index) {
|
if (p_arg == index) {
|
||||||
info = GetTypeInfo<Q>::get_class_info();
|
info = GetTypeInfo<Q>::get_class_info();
|
||||||
|
@ -505,7 +505,7 @@ void call_get_argument_type_info_helper(int p_arg, int &index, PropertyInfo &inf
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
void call_get_argument_type_info(int p_arg, PropertyInfo &info) {
|
void call_get_argument_type_info(int p_arg, PropertyInfo &info) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
// I think rocket science is simpler than modern C++.
|
// 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.
|
(void)index; // Suppress GCC warning.
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Q>
|
template <typename Q>
|
||||||
void call_get_argument_metadata_helper(int p_arg, int &index, GDExtensionClassMethodArgumentMetadata &md) {
|
void call_get_argument_metadata_helper(int p_arg, int &index, GDExtensionClassMethodArgumentMetadata &md) {
|
||||||
if (p_arg == index) {
|
if (p_arg == index) {
|
||||||
md = GetTypeInfo<Q>::METADATA;
|
md = GetTypeInfo<Q>::METADATA;
|
||||||
|
@ -523,7 +523,7 @@ void call_get_argument_metadata_helper(int p_arg, int &index, GDExtensionClassMe
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
GDExtensionClassMethodArgumentMetadata call_get_argument_metadata(int p_arg) {
|
GDExtensionClassMethodArgumentMetadata call_get_argument_metadata(int p_arg) {
|
||||||
GDExtensionClassMethodArgumentMetadata md = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
GDExtensionClassMethodArgumentMetadata md = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ GDExtensionClassMethodArgumentMetadata call_get_argument_metadata(int p_arg) {
|
||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P, size_t... Is>
|
template <typename... P, size_t... Is>
|
||||||
void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_args, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, GDExtensionCallError &r_error, const std::vector<Variant> &default_values) {
|
void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionConstVariantPtr *p_args, int p_argcount, GDExtensionCallError &r_error, const std::vector<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<sizeof...(P)>{});
|
call_with_variant_args_static(p_method, argsp.data(), r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P, size_t... Is>
|
template <typename... P, size_t... Is>
|
||||||
void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args, IndexSequence<Is...>) {
|
||||||
p_method(PtrToArg<P>::convert(p_args[Is])...);
|
p_method(PtrToArg<P>::convert(p_args[Is])...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
void call_with_ptr_args_static_method(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args) {
|
void call_with_ptr_args_static_method(void (*p_method)(P...), const GDExtensionConstTypePtr *p_args) {
|
||||||
call_with_ptr_args_static_method_helper<P...>(p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_args_static_method_helper<P...>(p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<R, P...>(p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
call_with_variant_args_static_ret<R, P...>(p_method, p_args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, GDExtensionCallError &r_error) {
|
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
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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...>(p_method, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
|
call_with_variant_args_static<P...>(p_method, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... P, size_t... Is>
|
template <typename R, typename... P, size_t... Is>
|
||||||
void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, Variant &r_ret, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, Variant &r_ret, GDExtensionCallError &r_error, IndexSequence<Is...>) {
|
||||||
r_error.error = GDEXTENSION_CALL_OK;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
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<Variant> &default_values) {
|
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<Variant> &default_values) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ((size_t)p_argcount > sizeof...(P)) {
|
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<sizeof...(P)>{});
|
call_with_variant_args_static_ret(p_method, argsp.data(), r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... P, size_t... Is>
|
template <typename R, typename... P, size_t... Is>
|
||||||
void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
|
||||||
PtrToArg<R>::encode(p_method(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
PtrToArg<R>::encode(p_method(PtrToArg<P>::convert(p_args[Is])...), r_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDExtensionConstTypePtr *p_args, void *r_ret) {
|
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<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
call_with_ptr_args_static_method_ret_helper<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace godot {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <class O, class... Args>
|
template <typename O, typename... Args>
|
||||||
O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, const Args &...args) {
|
O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, const Args &...args) {
|
||||||
GodotObject *ret = nullptr;
|
GodotObject *ret = nullptr;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
|
@ -51,13 +51,13 @@ O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GD
|
||||||
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret));
|
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
void _call_builtin_constructor(const GDExtensionPtrConstructor constructor, GDExtensionTypePtr base, Args... args) {
|
void _call_builtin_constructor(const GDExtensionPtrConstructor constructor, GDExtensionTypePtr base, Args... args) {
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
constructor(base, call_args.data());
|
constructor(base, call_args.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class... Args>
|
template <typename T, typename... Args>
|
||||||
T _call_builtin_method_ptr_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) {
|
T _call_builtin_method_ptr_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) {
|
||||||
T ret;
|
T ret;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
|
@ -65,20 +65,20 @@ T _call_builtin_method_ptr_ret(const GDExtensionPtrBuiltInMethod method, GDExten
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
void _call_builtin_method_ptr_no_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) {
|
void _call_builtin_method_ptr_no_ret(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, Args... args) {
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
method(base, call_args.data(), nullptr, sizeof...(Args));
|
method(base, call_args.data(), nullptr, sizeof...(Args));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
T _call_builtin_operator_ptr(const GDExtensionPtrOperatorEvaluator op, GDExtensionConstTypePtr left, GDExtensionConstTypePtr right) {
|
T _call_builtin_operator_ptr(const GDExtensionPtrOperatorEvaluator op, GDExtensionConstTypePtr left, GDExtensionConstTypePtr right) {
|
||||||
T ret;
|
T ret;
|
||||||
op(left, right, &ret);
|
op(left, right, &ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
T _call_builtin_ptr_getter(const GDExtensionPtrGetter getter, GDExtensionConstTypePtr base) {
|
T _call_builtin_ptr_getter(const GDExtensionPtrGetter getter, GDExtensionConstTypePtr base) {
|
||||||
T ret;
|
T ret;
|
||||||
getter(base, &ret);
|
getter(base, &ret);
|
||||||
|
|
|
@ -109,10 +109,10 @@ private:
|
||||||
static void initialize_class(const ClassInfo &cl);
|
static void initialize_class(const ClassInfo &cl);
|
||||||
static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method);
|
static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method);
|
||||||
|
|
||||||
template <class T, bool is_abstract>
|
template <typename T, bool is_abstract>
|
||||||
static void _register_class(bool p_virtual = false, bool p_exposed = true);
|
static void _register_class(bool p_virtual = false, bool p_exposed = true);
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static GDExtensionObjectPtr _create_instance_func(void *data) {
|
static GDExtensionObjectPtr _create_instance_func(void *data) {
|
||||||
if constexpr (!std::is_abstract_v<T>) {
|
if constexpr (!std::is_abstract_v<T>) {
|
||||||
T *new_object = memnew(T);
|
T *new_object = memnew(T);
|
||||||
|
@ -122,7 +122,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static GDExtensionClassInstancePtr _recreate_instance_func(void *data, GDExtensionObjectPtr obj) {
|
static GDExtensionClassInstancePtr _recreate_instance_func(void *data, GDExtensionObjectPtr obj) {
|
||||||
if constexpr (!std::is_abstract_v<T>) {
|
if constexpr (!std::is_abstract_v<T>) {
|
||||||
#ifdef HOT_RELOAD_ENABLED
|
#ifdef HOT_RELOAD_ENABLED
|
||||||
|
@ -140,24 +140,24 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <typename T>
|
||||||
static void register_class(bool p_virtual = false);
|
static void register_class(bool p_virtual = false);
|
||||||
template <class T>
|
template <typename T>
|
||||||
static void register_abstract_class();
|
static void register_abstract_class();
|
||||||
template <class T>
|
template <typename T>
|
||||||
static void register_internal_class();
|
static void register_internal_class();
|
||||||
|
|
||||||
_FORCE_INLINE_ static void _register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
|
_FORCE_INLINE_ static void _register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
|
||||||
instance_binding_callbacks[p_name] = p_callbacks;
|
instance_binding_callbacks[p_name] = p_callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class N, class M, typename... VarArgs>
|
template <typename N, typename M, typename... VarArgs>
|
||||||
static MethodBind *bind_method(N p_method_name, M p_method, VarArgs... p_args);
|
static MethodBind *bind_method(N p_method_name, M p_method, VarArgs... p_args);
|
||||||
|
|
||||||
template <class N, class M, typename... VarArgs>
|
template <typename N, typename M, typename... VarArgs>
|
||||||
static MethodBind *bind_static_method(StringName p_class, N p_method_name, M p_method, VarArgs... p_args);
|
static MethodBind *bind_static_method(StringName p_class, N p_method_name, M p_method, VarArgs... p_args);
|
||||||
|
|
||||||
template <class M>
|
template <typename M>
|
||||||
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const std::vector<Variant> &p_default_args = std::vector<Variant>{}, bool p_return_nil_is_variant = true);
|
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const std::vector<Variant> &p_default_args = std::vector<Variant>{}, bool p_return_nil_is_variant = true);
|
||||||
|
|
||||||
static void add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix);
|
static void add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix);
|
||||||
|
@ -195,7 +195,7 @@ public:
|
||||||
::godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, _call##m_method); \
|
::godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, _call##m_method); \
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, bool is_abstract>
|
template <typename T, bool is_abstract>
|
||||||
void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
||||||
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
||||||
instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks;
|
instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks;
|
||||||
|
@ -248,22 +248,22 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
||||||
initialize_class(classes[cl.name]);
|
initialize_class(classes[cl.name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void ClassDB::register_class(bool p_virtual) {
|
void ClassDB::register_class(bool p_virtual) {
|
||||||
ClassDB::_register_class<T, false>(p_virtual);
|
ClassDB::_register_class<T, false>(p_virtual);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void ClassDB::register_abstract_class() {
|
void ClassDB::register_abstract_class() {
|
||||||
ClassDB::_register_class<T, true>();
|
ClassDB::_register_class<T, true>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void ClassDB::register_internal_class() {
|
void ClassDB::register_internal_class() {
|
||||||
ClassDB::_register_class<T, false>(false, false);
|
ClassDB::_register_class<T, false>(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class N, class M, typename... VarArgs>
|
template <typename N, typename M, typename... VarArgs>
|
||||||
MethodBind *ClassDB::bind_method(N p_method_name, M p_method, VarArgs... p_args) {
|
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.
|
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];
|
const Variant *argptrs[sizeof...(p_args) + 1];
|
||||||
|
@ -274,7 +274,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));
|
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const void **)argptrs, sizeof...(p_args));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class N, class M, typename... VarArgs>
|
template <typename N, typename M, typename... VarArgs>
|
||||||
MethodBind *ClassDB::bind_static_method(StringName p_class, N p_method_name, M p_method, VarArgs... p_args) {
|
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.
|
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];
|
const Variant *argptrs[sizeof...(p_args) + 1];
|
||||||
|
@ -286,7 +286,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));
|
return bind_methodfi(0, bind, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const void **)argptrs, sizeof...(p_args));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class M>
|
template <typename M>
|
||||||
MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info, const std::vector<Variant> &p_default_args, bool p_return_nil_is_variant) {
|
MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info, const std::vector<Variant> &p_default_args, bool p_return_nil_is_variant) {
|
||||||
MethodBind *bind = create_vararg_method_bind(p_method, p_info, 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);
|
ERR_FAIL_NULL_V(bind, nullptr);
|
||||||
|
|
|
@ -108,7 +108,7 @@ typedef float real_t;
|
||||||
// Generic swap template.
|
// Generic swap template.
|
||||||
#ifndef SWAP
|
#ifndef SWAP
|
||||||
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
|
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
|
||||||
template <class T>
|
template <typename T>
|
||||||
inline void __swap_tmpl(T &x, T &y) {
|
inline void __swap_tmpl(T &x, T &y) {
|
||||||
T aux = x;
|
T aux = x;
|
||||||
x = y;
|
x = y;
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace godot {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <class O, class... Args>
|
template <typename O, typename... Args>
|
||||||
O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
||||||
GodotObject *ret = nullptr;
|
GodotObject *ret = nullptr;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
|
@ -54,7 +54,7 @@ O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, co
|
||||||
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret));
|
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... Args>
|
template <typename R, typename... Args>
|
||||||
R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
||||||
R ret;
|
R ret;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
|
@ -62,13 +62,13 @@ R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const A
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
|
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class R, class... Args>
|
template <typename R, typename... Args>
|
||||||
R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) {
|
R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) {
|
||||||
R ret;
|
R ret;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
|
@ -76,7 +76,7 @@ R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, void *instance, const Args &...args) {
|
Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, void *instance, const Args &...args) {
|
||||||
GodotObject *ret = nullptr;
|
GodotObject *ret = nullptr;
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> 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);
|
return (Object *)internal::get_object_instance_binding(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
void _call_utility_no_ret(const GDExtensionPtrUtilityFunction func, const Args &...args) {
|
void _call_utility_no_ret(const GDExtensionPtrUtilityFunction func, const Args &...args) {
|
||||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||||
func(nullptr, mb_args.data(), mb_args.size());
|
func(nullptr, mb_args.data(), mb_args.size());
|
||||||
|
|
|
@ -84,7 +84,7 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) {
|
||||||
// Generic swap template.
|
// Generic swap template.
|
||||||
#ifndef SWAP
|
#ifndef SWAP
|
||||||
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
|
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
|
||||||
template <class T>
|
template <typename T>
|
||||||
inline void __swap_tmpl(T &x, T &y) {
|
inline void __swap_tmpl(T &x, T &y) {
|
||||||
T aux = x;
|
T aux = x;
|
||||||
x = y;
|
x = y;
|
||||||
|
@ -138,7 +138,7 @@ static inline int get_shift_from_power_of_2(unsigned int p_bits) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) {
|
static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) {
|
||||||
--x;
|
--x;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
_ALWAYS_INLINE_ void postinitialize_handler(void *) {}
|
_ALWAYS_INLINE_ void postinitialize_handler(void *) {}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
_ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
|
_ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
|
||||||
postinitialize_handler(p_obj);
|
postinitialize_handler(p_obj);
|
||||||
return 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)
|
#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.
|
// Generic comparator used in Map, List, etc.
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct Comparator {
|
struct Comparator {
|
||||||
_ALWAYS_INLINE_ bool operator()(const T &p_a, const T &p_b) const { return (p_a < p_b); }
|
_ALWAYS_INLINE_ bool operator()(const T &p_a, const T &p_b) const { return (p_a < p_b); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wrapped, T>>::type * = nullptr) {
|
void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wrapped, T>>::type * = nullptr) {
|
||||||
if constexpr (!std::is_trivially_destructible_v<T>) {
|
if constexpr (!std::is_trivially_destructible_v<T>) {
|
||||||
p_class->~T();
|
p_class->~T();
|
||||||
|
@ -114,12 +114,12 @@ void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wra
|
||||||
Memory::free_static(p_class);
|
Memory::free_static(p_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, std::enable_if_t<std::is_base_of_v<godot::Wrapped, T>, bool> = true>
|
template <typename T, std::enable_if_t<std::is_base_of_v<godot::Wrapped, T>, bool> = true>
|
||||||
void memdelete(T *p_class) {
|
void memdelete(T *p_class) {
|
||||||
godot::internal::gdextension_interface_object_destroy(p_class->_owner);
|
godot::internal::gdextension_interface_object_destroy(p_class->_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class A>
|
template <typename T, typename A>
|
||||||
void memdelete_allocator(T *p_class) {
|
void memdelete_allocator(T *p_class) {
|
||||||
if constexpr (!std::is_trivially_destructible_v<T>) {
|
if constexpr (!std::is_trivially_destructible_v<T>) {
|
||||||
p_class->~T();
|
p_class->~T();
|
||||||
|
@ -134,10 +134,10 @@ public:
|
||||||
_ALWAYS_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr); }
|
_ALWAYS_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class DefaultTypedAllocator {
|
class DefaultTypedAllocator {
|
||||||
public:
|
public:
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
_ALWAYS_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); }
|
_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); }
|
_ALWAYS_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,7 +147,7 @@ public:
|
||||||
virtual ~MethodBind();
|
virtual ~MethodBind();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Derived, class T, class R, bool should_returns>
|
template <typename Derived, typename T, typename R, bool should_returns>
|
||||||
class MethodBindVarArgBase : public MethodBind {
|
class MethodBindVarArgBase : public MethodBind {
|
||||||
protected:
|
protected:
|
||||||
R(T::*method)
|
R(T::*method)
|
||||||
|
@ -208,7 +208,7 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false> {
|
class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false> {
|
||||||
friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>;
|
friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>;
|
||||||
|
|
||||||
|
@ -231,14 +231,14 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
|
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<T>)(p_method, p_info, p_return_nil_is_variant));
|
MethodBind *a = memnew((MethodBindVarArgT<T>)(p_method, p_info, p_return_nil_is_variant));
|
||||||
a->set_instance_class(T::get_class_static());
|
a->set_instance_class(T::get_class_static());
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class R>
|
template <typename T, typename R>
|
||||||
class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true> {
|
class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true> {
|
||||||
friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>;
|
friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class R>
|
template <typename T, typename R>
|
||||||
MethodBind *create_vararg_method_bind(R (T::*p_method)(const Variant **, GDExtensionInt, GDExtensionCallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
|
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<T, R>)(p_method, p_info, p_return_nil_is_variant));
|
MethodBind *a = memnew((MethodBindVarArgTR<T, R>)(p_method, p_info, p_return_nil_is_variant));
|
||||||
a->set_instance_class(T::get_class_static());
|
a->set_instance_class(T::get_class_static());
|
||||||
|
@ -277,9 +277,9 @@ class _gde_UnexistingClass;
|
||||||
// No return, not const.
|
// No return, not const.
|
||||||
|
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
#else
|
#else
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
#endif // TYPED_METHOD_BIND
|
#endif // TYPED_METHOD_BIND
|
||||||
class MethodBindT : public MethodBind {
|
class MethodBindT : public MethodBind {
|
||||||
void (MB_T::*method)(P...);
|
void (MB_T::*method)(P...);
|
||||||
|
@ -339,7 +339,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
MethodBind *create_method_bind(void (T::*p_method)(P...)) {
|
MethodBind *create_method_bind(void (T::*p_method)(P...)) {
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
MethodBind *a = memnew((MethodBindT<T, P...>)(p_method));
|
MethodBind *a = memnew((MethodBindT<T, P...>)(p_method));
|
||||||
|
@ -353,9 +353,9 @@ MethodBind *create_method_bind(void (T::*p_method)(P...)) {
|
||||||
// No return, const.
|
// No return, const.
|
||||||
|
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
#else
|
#else
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
#endif // TYPED_METHOD_BIND
|
#endif // TYPED_METHOD_BIND
|
||||||
class MethodBindTC : public MethodBind {
|
class MethodBindTC : public MethodBind {
|
||||||
void (MB_T::*method)(P...) const;
|
void (MB_T::*method)(P...) const;
|
||||||
|
@ -415,7 +415,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
MethodBind *create_method_bind(void (T::*p_method)(P...) const) {
|
MethodBind *create_method_bind(void (T::*p_method)(P...) const) {
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
MethodBind *a = memnew((MethodBindTC<T, P...>)(p_method));
|
MethodBind *a = memnew((MethodBindTC<T, P...>)(p_method));
|
||||||
|
@ -429,9 +429,9 @@ MethodBind *create_method_bind(void (T::*p_method)(P...) const) {
|
||||||
// Return, not const.
|
// Return, not const.
|
||||||
|
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
#else
|
#else
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
#endif // TYPED_METHOD_BIND
|
#endif // TYPED_METHOD_BIND
|
||||||
class MethodBindTR : public MethodBind {
|
class MethodBindTR : public MethodBind {
|
||||||
R(MB_T::*method)
|
R(MB_T::*method)
|
||||||
|
@ -498,7 +498,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
MethodBind *create_method_bind(R (T::*p_method)(P...)) {
|
MethodBind *create_method_bind(R (T::*p_method)(P...)) {
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
MethodBind *a = memnew((MethodBindTR<T, R, P...>)(p_method));
|
MethodBind *a = memnew((MethodBindTR<T, R, P...>)(p_method));
|
||||||
|
@ -512,9 +512,9 @@ MethodBind *create_method_bind(R (T::*p_method)(P...)) {
|
||||||
// Return, const.
|
// Return, const.
|
||||||
|
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
#else
|
#else
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
#endif // TYPED_METHOD_BIND
|
#endif // TYPED_METHOD_BIND
|
||||||
class MethodBindTRC : public MethodBind {
|
class MethodBindTRC : public MethodBind {
|
||||||
R(MB_T::*method)
|
R(MB_T::*method)
|
||||||
|
@ -581,7 +581,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
MethodBind *create_method_bind(R (T::*p_method)(P...) const) {
|
MethodBind *create_method_bind(R (T::*p_method)(P...) const) {
|
||||||
#ifdef TYPED_METHOD_BIND
|
#ifdef TYPED_METHOD_BIND
|
||||||
MethodBind *a = memnew((MethodBindTRC<T, R, P...>)(p_method));
|
MethodBind *a = memnew((MethodBindTRC<T, R, P...>)(p_method));
|
||||||
|
@ -596,7 +596,7 @@ MethodBind *create_method_bind(R (T::*p_method)(P...) const) {
|
||||||
|
|
||||||
// no return
|
// no return
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
class MethodBindTS : public MethodBind {
|
class MethodBindTS : public MethodBind {
|
||||||
void (*function)(P...);
|
void (*function)(P...);
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
MethodBind *create_static_method_bind(void (*p_method)(P...)) {
|
MethodBind *create_static_method_bind(void (*p_method)(P...)) {
|
||||||
MethodBind *a = memnew((MethodBindTS<P...>)(p_method));
|
MethodBind *a = memnew((MethodBindTS<P...>)(p_method));
|
||||||
return a;
|
return a;
|
||||||
|
@ -660,7 +660,7 @@ MethodBind *create_static_method_bind(void (*p_method)(P...)) {
|
||||||
|
|
||||||
// return
|
// return
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
class MethodBindTRS : public MethodBind {
|
class MethodBindTRS : public MethodBind {
|
||||||
R(*function)
|
R(*function)
|
||||||
(P...);
|
(P...);
|
||||||
|
@ -722,7 +722,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
MethodBind *create_static_method_bind(R (*p_method)(P...)) {
|
MethodBind *create_static_method_bind(R (*p_method)(P...)) {
|
||||||
MethodBind *a = memnew((MethodBindTRS<R, P...>)(p_method));
|
MethodBind *a = memnew((MethodBindTRS<R, P...>)(p_method));
|
||||||
return a;
|
return a;
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg {};
|
struct PtrToArg {};
|
||||||
|
|
||||||
#define MAKE_PTRARG(m_type) \
|
#define MAKE_PTRARG(m_type) \
|
||||||
|
@ -166,7 +166,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
|
||||||
|
|
||||||
// This is for Object.
|
// This is for Object.
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<T *> {
|
struct PtrToArg<T *> {
|
||||||
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
||||||
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
||||||
|
@ -178,7 +178,7 @@ struct PtrToArg<T *> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<const T *> {
|
struct PtrToArg<const T *> {
|
||||||
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
||||||
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
||||||
|
|
|
@ -78,31 +78,31 @@ struct MethodInfo {
|
||||||
|
|
||||||
MethodInfo();
|
MethodInfo();
|
||||||
MethodInfo(StringName p_name);
|
MethodInfo(StringName p_name);
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo(StringName p_name, const Args &...args);
|
MethodInfo(StringName p_name, const Args &...args);
|
||||||
MethodInfo(Variant::Type ret);
|
MethodInfo(Variant::Type ret);
|
||||||
MethodInfo(Variant::Type ret, StringName p_name);
|
MethodInfo(Variant::Type ret, StringName p_name);
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo(Variant::Type ret, StringName p_name, const Args &...args);
|
MethodInfo(Variant::Type ret, StringName p_name, const Args &...args);
|
||||||
MethodInfo(const PropertyInfo &p_ret, StringName p_name);
|
MethodInfo(const PropertyInfo &p_ret, StringName p_name);
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...);
|
MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo::MethodInfo(StringName p_name, const Args &...args) :
|
MethodInfo::MethodInfo(StringName p_name, const Args &...args) :
|
||||||
name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
||||||
arguments = { args... };
|
arguments = { args... };
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo::MethodInfo(Variant::Type ret, StringName p_name, const Args &...args) :
|
MethodInfo::MethodInfo(Variant::Type ret, StringName p_name, const Args &...args) :
|
||||||
name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
name(p_name), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
||||||
return_val.type = ret;
|
return_val.type = ret;
|
||||||
arguments = { args... };
|
arguments = { args... };
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
MethodInfo::MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...args) :
|
MethodInfo::MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args &...args) :
|
||||||
name(p_name), return_val(p_ret), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
name(p_name), return_val(p_ret), flags(GDEXTENSION_METHOD_FLAG_NORMAL) {
|
||||||
arguments = { args... };
|
arguments = { args... };
|
||||||
|
@ -119,7 +119,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
T *Object::cast_to(Object *p_object) {
|
T *Object::cast_to(Object *p_object) {
|
||||||
if (p_object == nullptr) {
|
if (p_object == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -132,7 +132,7 @@ T *Object::cast_to(Object *p_object) {
|
||||||
return dynamic_cast<T *>(internal::get_object_instance_binding(casted));
|
return dynamic_cast<T *>(internal::get_object_instance_binding(casted));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
const T *Object::cast_to(const Object *p_object) {
|
const T *Object::cast_to(const Object *p_object) {
|
||||||
if (p_object == nullptr) {
|
if (p_object == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -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
|
// 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<T>' is instantiated.
|
// include the actual declaration of 'T' in the source file where 'GetTypeInfo<T>' is instantiated.
|
||||||
|
|
||||||
template <class T, typename = void>
|
template <typename T, typename = void>
|
||||||
struct GetTypeInfo;
|
struct GetTypeInfo;
|
||||||
|
|
||||||
#define MAKE_TYPE_INFO(m_type, m_var_type) \
|
#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<T>::get_class_info().class_name;
|
return GetTypeInfo<T>::get_class_info().class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class BitField {
|
class BitField {
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ inline StringName _gde_constant_get_bitfield_name(T param, StringName p_constant
|
||||||
return GetTypeInfo<BitField<T>>::get_class_info().class_name;
|
return GetTypeInfo<BitField<T>>::get_class_info().class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<TypedArray<T>> {
|
struct PtrToArg<TypedArray<T>> {
|
||||||
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
|
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
|
||||||
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
|
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
|
||||||
|
@ -306,7 +306,7 @@ struct PtrToArg<TypedArray<T>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct PtrToArg<const TypedArray<T> &> {
|
struct PtrToArg<const TypedArray<T> &> {
|
||||||
typedef Array EncodeT;
|
typedef Array EncodeT;
|
||||||
_FORCE_INLINE_ static TypedArray<T>
|
_FORCE_INLINE_ static TypedArray<T>
|
||||||
|
|
|
@ -43,13 +43,13 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class Vector;
|
class Vector;
|
||||||
|
|
||||||
template <class T, class V>
|
template <typename T, typename V>
|
||||||
class VMap;
|
class VMap;
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class CharStringT;
|
class CharStringT;
|
||||||
|
|
||||||
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
|
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
|
||||||
|
@ -60,15 +60,15 @@ static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
|
||||||
#pragma GCC diagnostic ignored "-Wplacement-new"
|
#pragma GCC diagnostic ignored "-Wplacement-new"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class CowData {
|
class CowData {
|
||||||
template <class TV>
|
template <typename TV>
|
||||||
friend class Vector;
|
friend class Vector;
|
||||||
|
|
||||||
template <class TV, class VV>
|
template <typename TV, typename VV>
|
||||||
friend class VMap;
|
friend class VMap;
|
||||||
|
|
||||||
template <class TS>
|
template <typename TS>
|
||||||
friend class CharStringT;
|
friend class CharStringT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -248,7 +248,7 @@ public:
|
||||||
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
|
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void CowData<T>::_unref(void *p_data) {
|
void CowData<T>::_unref(void *p_data) {
|
||||||
if (!p_data) {
|
if (!p_data) {
|
||||||
return;
|
return;
|
||||||
|
@ -275,7 +275,7 @@ void CowData<T>::_unref(void *p_data) {
|
||||||
Memory::free_static(((uint8_t *)p_data) - DATA_OFFSET, false);
|
Memory::free_static(((uint8_t *)p_data) - DATA_OFFSET, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
typename CowData<T>::USize CowData<T>::_copy_on_write() {
|
typename CowData<T>::USize CowData<T>::_copy_on_write() {
|
||||||
if (!_ptr) {
|
if (!_ptr) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -315,7 +315,7 @@ typename CowData<T>::USize CowData<T>::_copy_on_write() {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
template <bool p_ensure_zero>
|
template <bool p_ensure_zero>
|
||||||
Error CowData<T>::resize(Size p_size) {
|
Error CowData<T>::resize(Size p_size) {
|
||||||
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
|
||||||
|
@ -407,7 +407,7 @@ Error CowData<T>::resize(Size p_size) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
|
typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
|
||||||
Size ret = -1;
|
Size ret = -1;
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
|
typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
|
||||||
const Size s = size();
|
const Size s = size();
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
typename CowData<T>::Size CowData<T>::count(const T &p_val) const {
|
typename CowData<T>::Size CowData<T>::count(const T &p_val) const {
|
||||||
Size amount = 0;
|
Size amount = 0;
|
||||||
for (Size i = 0; i < size(); i++) {
|
for (Size i = 0; i < size(); i++) {
|
||||||
|
@ -455,12 +455,12 @@ typename CowData<T>::Size CowData<T>::count(const T &p_val) const {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void CowData<T>::_ref(const CowData *p_from) {
|
void CowData<T>::_ref(const CowData *p_from) {
|
||||||
_ref(*p_from);
|
_ref(*p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void CowData<T>::_ref(const CowData &p_from) {
|
void CowData<T>::_ref(const CowData &p_from) {
|
||||||
if (_ptr == p_from._ptr) {
|
if (_ptr == p_from._ptr) {
|
||||||
return; // self assign, do nothing.
|
return; // self assign, do nothing.
|
||||||
|
@ -478,7 +478,7 @@ void CowData<T>::_ref(const CowData &p_from) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
CowData<T>::~CowData() {
|
CowData<T>::~CowData() {
|
||||||
_unref(_ptr);
|
_unref(_ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace godot {
|
||||||
* The assignment operator copy the pairs from one map to the other.
|
* The assignment operator copy the pairs from one map to the other.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <typename TKey, typename TValue>
|
||||||
struct HashMapElement {
|
struct HashMapElement {
|
||||||
HashMapElement *next = nullptr;
|
HashMapElement *next = nullptr;
|
||||||
HashMapElement *prev = nullptr;
|
HashMapElement *prev = nullptr;
|
||||||
|
@ -62,10 +62,10 @@ struct HashMapElement {
|
||||||
data(p_key, p_value) {}
|
data(p_key, p_value) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class TKey, class TValue,
|
template <typename TKey, typename TValue,
|
||||||
class Hasher = HashMapHasherDefault,
|
typename Hasher = HashMapHasherDefault,
|
||||||
class Comparator = HashMapComparatorDefault<TKey>,
|
typename Comparator = HashMapComparatorDefault<TKey>,
|
||||||
class Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
|
typename Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
|
||||||
class HashMap {
|
class HashMap {
|
||||||
public:
|
public:
|
||||||
const uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
|
const uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
|
||||||
|
|
|
@ -48,9 +48,9 @@ namespace godot {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class TKey,
|
template <typename TKey,
|
||||||
class Hasher = HashMapHasherDefault,
|
typename Hasher = HashMapHasherDefault,
|
||||||
class Comparator = HashMapComparatorDefault<TKey>>
|
typename Comparator = HashMapComparatorDefault<TKey>>
|
||||||
class HashSet {
|
class HashSet {
|
||||||
public:
|
public:
|
||||||
static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
|
static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
|
||||||
|
|
|
@ -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);
|
return ((p_prev << 5) + p_prev) + hash_one_uint64(u.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static _FORCE_INLINE_ uint32_t hash_make_uint32_t(T p_in) {
|
static _FORCE_INLINE_ uint32_t hash_make_uint32_t(T p_in) {
|
||||||
union {
|
union {
|
||||||
T t;
|
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;
|
return ((p_prev << 5) + p_prev) ^ p_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) {
|
static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) {
|
||||||
union {
|
union {
|
||||||
T t;
|
T t;
|
||||||
|
@ -298,15 +298,15 @@ static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) {
|
||||||
return _u._u64;
|
return _u._u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class Ref;
|
class Ref;
|
||||||
|
|
||||||
struct HashMapHasherDefault {
|
struct HashMapHasherDefault {
|
||||||
// Generic hash function for any type.
|
// Generic hash function for any type.
|
||||||
template <class T>
|
template <typename T>
|
||||||
static _FORCE_INLINE_ uint32_t hash(const T *p_pointer) { return hash_one_uint64((uint64_t)p_pointer); }
|
static _FORCE_INLINE_ uint32_t hash(const T *p_pointer) { return hash_one_uint64((uint64_t)p_pointer); }
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
static _FORCE_INLINE_ uint32_t hash(const Ref<T> &p_ref) { return hash_one_uint64((uint64_t)p_ref.operator->()); }
|
static _FORCE_INLINE_ uint32_t hash(const Ref<T> &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(); }
|
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T, class A = DefaultAllocator>
|
template <typename T, typename A = DefaultAllocator>
|
||||||
class List {
|
class List {
|
||||||
struct _Data;
|
struct _Data;
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* find an element in the list,
|
* find an element in the list,
|
||||||
*/
|
*/
|
||||||
template <class T_v>
|
template <typename T_v>
|
||||||
Element *find(const T_v &p_val) {
|
Element *find(const T_v &p_val) {
|
||||||
Element *it = front();
|
Element *it = front();
|
||||||
while (it) {
|
while (it) {
|
||||||
|
@ -646,7 +646,7 @@ public:
|
||||||
sort_custom<Comparator<T>>();
|
sort_custom<Comparator<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C>
|
template <typename C>
|
||||||
void sort_custom_inplace() {
|
void sort_custom_inplace() {
|
||||||
if (size() < 2) {
|
if (size() < 2) {
|
||||||
return;
|
return;
|
||||||
|
@ -693,7 +693,7 @@ public:
|
||||||
_data->last = to;
|
_data->last = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C>
|
template <typename C>
|
||||||
struct AuxiliaryComparator {
|
struct AuxiliaryComparator {
|
||||||
C compare;
|
C compare;
|
||||||
_FORCE_INLINE_ bool operator()(const Element *a, const Element *b) const {
|
_FORCE_INLINE_ bool operator()(const Element *a, const Element *b) const {
|
||||||
|
@ -701,7 +701,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class C>
|
template <typename C>
|
||||||
void sort_custom() {
|
void sort_custom() {
|
||||||
// this version uses auxiliary memory for speed.
|
// this version uses auxiliary memory for speed.
|
||||||
// if you don't want to use auxiliary memory, use the in_place version
|
// if you don't want to use auxiliary memory, use the in_place version
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace godot {
|
||||||
|
|
||||||
// If tight, it grows strictly as much as needed.
|
// If tight, it grows strictly as much as needed.
|
||||||
// Otherwise, it grows exponentially (the default and what you want in most cases).
|
// Otherwise, it grows exponentially (the default and what you want in most cases).
|
||||||
template <class T, class U = uint32_t, bool force_trivial = false, bool tight = false>
|
template <typename T, typename U = uint32_t, bool force_trivial = false, bool tight = false>
|
||||||
class LocalVector {
|
class LocalVector {
|
||||||
private:
|
private:
|
||||||
U count = 0;
|
U count = 0;
|
||||||
|
@ -257,7 +257,7 @@ public:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C>
|
template <typename C>
|
||||||
void sort_custom() {
|
void sort_custom() {
|
||||||
U len = count;
|
U len = count;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -331,7 +331,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class U = uint32_t, bool force_trivial = false>
|
template <typename T, typename U = uint32_t, bool force_trivial = false>
|
||||||
using TightLocalVector = LocalVector<T, U, force_trivial, true>;
|
using TightLocalVector = LocalVector<T, U, force_trivial, true>;
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class F, class S>
|
template <typename F, typename S>
|
||||||
struct Pair {
|
struct Pair {
|
||||||
F first;
|
F first;
|
||||||
S second;
|
S second;
|
||||||
|
@ -49,17 +49,17 @@ struct Pair {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class F, class S>
|
template <typename F, typename S>
|
||||||
bool operator==(const Pair<F, S> &pair, const Pair<F, S> &other) {
|
bool operator==(const Pair<F, S> &pair, const Pair<F, S> &other) {
|
||||||
return (pair.first == other.first) && (pair.second == other.second);
|
return (pair.first == other.first) && (pair.second == other.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class F, class S>
|
template <typename F, typename S>
|
||||||
bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) {
|
bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) {
|
||||||
return (pair.first != other.first) || (pair.second != other.second);
|
return (pair.first != other.first) || (pair.second != other.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class F, class S>
|
template <typename F, typename S>
|
||||||
struct PairSort {
|
struct PairSort {
|
||||||
bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const {
|
bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const {
|
||||||
if (A.first != B.first) {
|
if (A.first != B.first) {
|
||||||
|
@ -69,7 +69,7 @@ struct PairSort {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class V>
|
template <typename K, typename V>
|
||||||
struct KeyValue {
|
struct KeyValue {
|
||||||
const K key;
|
const K key;
|
||||||
V value;
|
V value;
|
||||||
|
@ -85,17 +85,17 @@ struct KeyValue {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class V>
|
template <typename K, typename V>
|
||||||
bool operator==(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
|
bool operator==(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
|
||||||
return (pair.key == other.key) && (pair.value == other.value);
|
return (pair.key == other.key) && (pair.value == other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class V>
|
template <typename K, typename V>
|
||||||
bool operator!=(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
|
bool operator!=(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
|
||||||
return (pair.key != other.key) || (pair.value != other.value);
|
return (pair.key != other.key) || (pair.value != other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class V>
|
template <typename K, typename V>
|
||||||
struct KeyValueSort {
|
struct KeyValueSort {
|
||||||
bool operator()(const KeyValue<K, V> &A, const KeyValue<K, V> &B) const {
|
bool operator()(const KeyValue<K, V> &A, const KeyValue<K, V> &B) const {
|
||||||
return A.key < B.key;
|
return A.key < B.key;
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace godot {
|
||||||
// based on the very nice implementation of rb-trees by:
|
// 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
|
// https://web.archive.org/web/20120507164830/https://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
|
||||||
|
|
||||||
template <class K, class V, class C = Comparator<K>, class A = DefaultAllocator>
|
template <typename K, typename V, typename C = Comparator<K>, typename A = DefaultAllocator>
|
||||||
class RBMap {
|
class RBMap {
|
||||||
enum Color {
|
enum Color {
|
||||||
RED,
|
RED,
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T, class C = Comparator<T>, class A = DefaultAllocator>
|
template <typename T, typename C = Comparator<T>, typename A = DefaultAllocator>
|
||||||
class RBSet {
|
class RBSet {
|
||||||
enum Color {
|
enum Color {
|
||||||
RED,
|
RED,
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T, bool THREAD_SAFE = false>
|
template <typename T, bool THREAD_SAFE = false>
|
||||||
class RID_Alloc {
|
class RID_Alloc {
|
||||||
T **chunks = nullptr;
|
T **chunks = nullptr;
|
||||||
uint32_t **free_list_chunks = nullptr;
|
uint32_t **free_list_chunks = nullptr;
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, bool THREAD_SAFE = false>
|
template <typename T, bool THREAD_SAFE = false>
|
||||||
class RID_PtrOwner {
|
class RID_PtrOwner {
|
||||||
RID_Alloc<T *, THREAD_SAFE> alloc;
|
RID_Alloc<T *, THREAD_SAFE> alloc;
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ public:
|
||||||
alloc(p_target_chunk_byte_size) {}
|
alloc(p_target_chunk_byte_size) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, bool THREAD_SAFE = false>
|
template <typename T, bool THREAD_SAFE = false>
|
||||||
class RID_Owner {
|
class RID_Owner {
|
||||||
RID_Alloc<T, THREAD_SAFE> alloc;
|
RID_Alloc<T, THREAD_SAFE> alloc;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace godot {
|
||||||
static_assert(sizeof(SafeFlag) == sizeof(bool)); \
|
static_assert(sizeof(SafeFlag) == sizeof(bool)); \
|
||||||
static_assert(alignof(SafeFlag) == alignof(bool));
|
static_assert(alignof(SafeFlag) == alignof(bool));
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class SafeNumeric {
|
class SafeNumeric {
|
||||||
std::atomic<T> value;
|
std::atomic<T> value;
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public:
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class SafeNumeric {
|
class SafeNumeric {
|
||||||
protected:
|
protected:
|
||||||
T value;
|
T value;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T, class Comparator = _DefaultComparator<T>>
|
template <typename T, typename Comparator = _DefaultComparator<T>>
|
||||||
class SearchArray {
|
class SearchArray {
|
||||||
public:
|
public:
|
||||||
Comparator compare;
|
Comparator compare;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class SelfList {
|
class SelfList {
|
||||||
public:
|
public:
|
||||||
class List {
|
class List {
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace godot {
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
struct _DefaultComparator {
|
struct _DefaultComparator {
|
||||||
_FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); }
|
_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
|
#define SORT_ARRAY_VALIDATE_ENABLED false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class T, class Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
|
template <typename T, typename Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
|
||||||
class SortArray {
|
class SortArray {
|
||||||
enum {
|
enum {
|
||||||
INTROSORT_THRESHOLD = 16
|
INTROSORT_THRESHOLD = 16
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ThreadWorkPool {
|
||||||
virtual ~BaseWork() = default;
|
virtual ~BaseWork() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class C, class M, class U>
|
template <typename C, typename M, typename U>
|
||||||
struct Work : public BaseWork {
|
struct Work : public BaseWork {
|
||||||
C *instance;
|
C *instance;
|
||||||
M method;
|
M method;
|
||||||
|
@ -94,7 +94,7 @@ class ThreadWorkPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class C, class M, class U>
|
template <typename C, typename M, typename U>
|
||||||
void begin_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
|
void begin_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
|
||||||
ERR_FAIL_NULL(threads); // Never initialized.
|
ERR_FAIL_NULL(threads); // Never initialized.
|
||||||
ERR_FAIL_COND(current_work != nullptr);
|
ERR_FAIL_COND(current_work != nullptr);
|
||||||
|
@ -145,7 +145,7 @@ public:
|
||||||
current_work = nullptr;
|
current_work = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C, class M, class U>
|
template <typename C, typename M, typename U>
|
||||||
void do_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
|
void do_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
|
||||||
switch (p_elements) {
|
switch (p_elements) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class VectorWriteProxy {
|
class VectorWriteProxy {
|
||||||
public:
|
public:
|
||||||
_FORCE_INLINE_ T &operator[](typename CowData<T>::Size p_index) {
|
_FORCE_INLINE_ T &operator[](typename CowData<T>::Size p_index) {
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class Vector {
|
class Vector {
|
||||||
friend class VectorWriteProxy<T>;
|
friend class VectorWriteProxy<T>;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public:
|
||||||
sort_custom<_DefaultComparator<T>>();
|
sort_custom<_DefaultComparator<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, class... Args>
|
template <typename Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, typename... Args>
|
||||||
void sort_custom(Args &&...args) {
|
void sort_custom(Args &&...args) {
|
||||||
Size len = _cowdata.size();
|
Size len = _cowdata.size();
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
return bsearch_custom<_DefaultComparator<T>>(p_value, p_before);
|
return bsearch_custom<_DefaultComparator<T>>(p_value, p_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Comparator, class Value, class... Args>
|
template <typename Comparator, typename Value, typename... Args>
|
||||||
Size bsearch_custom(const Value &p_value, bool p_before, Args &&...args) {
|
Size bsearch_custom(const Value &p_value, bool p_before, Args &&...args) {
|
||||||
SearchArray<T, Comparator> search{ args... };
|
SearchArray<T, Comparator> search{ args... };
|
||||||
return search.bisect(ptrw(), size(), p_value, p_before);
|
return search.bisect(ptrw(), size(), p_value, p_before);
|
||||||
|
@ -293,7 +293,7 @@ public:
|
||||||
_FORCE_INLINE_ ~Vector() {}
|
_FORCE_INLINE_ ~Vector() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void Vector<T>::reverse() {
|
void Vector<T>::reverse() {
|
||||||
for (Size i = 0; i < size() / 2; i++) {
|
for (Size i = 0; i < size() / 2; i++) {
|
||||||
T *p = ptrw();
|
T *p = ptrw();
|
||||||
|
@ -301,7 +301,7 @@ void Vector<T>::reverse() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void Vector<T>::append_array(Vector<T> p_other) {
|
void Vector<T>::append_array(Vector<T> p_other) {
|
||||||
const Size ds = p_other.size();
|
const Size ds = p_other.size();
|
||||||
if (ds == 0) {
|
if (ds == 0) {
|
||||||
|
@ -314,7 +314,7 @@ void Vector<T>::append_array(Vector<T> p_other) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
bool Vector<T>::push_back(T p_elem) {
|
bool Vector<T>::push_back(T p_elem) {
|
||||||
Error err = resize(size() + 1);
|
Error err = resize(size() + 1);
|
||||||
ERR_FAIL_COND_V(err, true);
|
ERR_FAIL_COND_V(err, true);
|
||||||
|
@ -323,7 +323,7 @@ bool Vector<T>::push_back(T p_elem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void Vector<T>::fill(T p_elem) {
|
void Vector<T>::fill(T p_elem) {
|
||||||
T *p = ptrw();
|
T *p = ptrw();
|
||||||
for (Size i = 0; i < size(); i++) {
|
for (Size i = 0; i < size(); i++) {
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T, class V>
|
template <typename T, typename V>
|
||||||
class VMap {
|
class VMap {
|
||||||
public:
|
public:
|
||||||
struct Pair {
|
struct Pair {
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class VSet {
|
class VSet {
|
||||||
Vector<T> _data;
|
Vector<T> _data;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_m
|
||||||
// No return value.
|
// No return value.
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
class CallableCustomMethodPointer : public CallableCustomMethodPointerBase {
|
class CallableCustomMethodPointer : public CallableCustomMethodPointerBase {
|
||||||
struct Data {
|
struct Data {
|
||||||
T *instance;
|
T *instance;
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class... P>
|
template <typename T, typename... P>
|
||||||
Callable create_custom_callable_function_pointer(T *p_instance, void (T::*p_method)(P...)) {
|
Callable create_custom_callable_function_pointer(T *p_instance, void (T::*p_method)(P...)) {
|
||||||
typedef CallableCustomMethodPointer<T, P...> CCMP;
|
typedef CallableCustomMethodPointer<T, P...> CCMP;
|
||||||
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
|
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.
|
// With return value.
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
class CallableCustomMethodPointerRet : public CallableCustomMethodPointerBase {
|
class CallableCustomMethodPointerRet : public CallableCustomMethodPointerBase {
|
||||||
struct Data {
|
struct Data {
|
||||||
T *instance;
|
T *instance;
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
Callable create_custom_callable_function_pointer(T *p_instance, R (T::*p_method)(P...)) {
|
Callable create_custom_callable_function_pointer(T *p_instance, R (T::*p_method)(P...)) {
|
||||||
typedef CallableCustomMethodPointerRet<T, R, P...> CCMP; // Messes with memnew otherwise.
|
typedef CallableCustomMethodPointerRet<T, R, P...> CCMP; // Messes with memnew otherwise.
|
||||||
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
|
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.
|
// Const with return value.
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
class CallableCustomMethodPointerRetC : public CallableCustomMethodPointerBase {
|
class CallableCustomMethodPointerRetC : public CallableCustomMethodPointerBase {
|
||||||
struct Data {
|
struct Data {
|
||||||
T *instance;
|
T *instance;
|
||||||
|
@ -159,7 +159,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class R, class... P>
|
template <typename T, typename R, typename... P>
|
||||||
Callable create_custom_callable_function_pointer(const T *p_instance, R (T::*p_method)(P...) const) {
|
Callable create_custom_callable_function_pointer(const T *p_instance, R (T::*p_method)(P...) const) {
|
||||||
typedef CallableCustomMethodPointerRetC<T, R, P...> CCMP; // Messes with memnew otherwise.
|
typedef CallableCustomMethodPointerRetC<T, R, P...> CCMP; // Messes with memnew otherwise.
|
||||||
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
|
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.
|
// Static method with no return value.
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
class CallableCustomStaticMethodPointer : public CallableCustomMethodPointerBase {
|
class CallableCustomStaticMethodPointer : public CallableCustomMethodPointerBase {
|
||||||
struct Data {
|
struct Data {
|
||||||
void (*method)(P...);
|
void (*method)(P...);
|
||||||
|
@ -194,7 +194,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class... P>
|
template <typename... P>
|
||||||
Callable create_custom_callable_static_function_pointer(void (*p_method)(P...)) {
|
Callable create_custom_callable_static_function_pointer(void (*p_method)(P...)) {
|
||||||
typedef CallableCustomStaticMethodPointer<P...> CCMP;
|
typedef CallableCustomStaticMethodPointer<P...> CCMP;
|
||||||
CCMP *ccmp = memnew(CCMP(p_method));
|
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.
|
// Static method with return value.
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
class CallableCustomStaticMethodPointerRet : public CallableCustomMethodPointerBase {
|
class CallableCustomStaticMethodPointerRet : public CallableCustomMethodPointerBase {
|
||||||
struct Data {
|
struct Data {
|
||||||
R(*method)
|
R(*method)
|
||||||
|
@ -229,7 +229,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R, class... P>
|
template <typename R, typename... P>
|
||||||
Callable create_custom_callable_static_function_pointer(R (*p_method)(P...)) {
|
Callable create_custom_callable_static_function_pointer(R (*p_method)(P...)) {
|
||||||
typedef CallableCustomStaticMethodPointerRet<R, P...> CCMP;
|
typedef CallableCustomStaticMethodPointerRet<R, P...> CCMP;
|
||||||
CCMP *ccmp = memnew(CCMP(p_method));
|
CCMP *ccmp = memnew(CCMP(p_method));
|
||||||
|
|
|
@ -38,12 +38,12 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class CharStringT;
|
class CharStringT;
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class CharProxy {
|
class CharProxy {
|
||||||
template <class TS>
|
template <typename TS>
|
||||||
friend class CharStringT;
|
friend class CharStringT;
|
||||||
|
|
||||||
const int64_t _index;
|
const int64_t _index;
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class CharStringT {
|
class CharStringT {
|
||||||
friend class String;
|
friend class String;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
class TypedArray : public Array {
|
class TypedArray : public Array {
|
||||||
public:
|
public:
|
||||||
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
||||||
|
|
|
@ -269,7 +269,7 @@ public:
|
||||||
|
|
||||||
void callp(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error);
|
void callp(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error);
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
Variant call(const StringName &method, Args... args) {
|
Variant call(const StringName &method, Args... args) {
|
||||||
std::array<Variant, sizeof...(args)> vargs = { args... };
|
std::array<Variant, sizeof...(args)> vargs = { args... };
|
||||||
std::array<const Variant *, sizeof...(args)> argptrs;
|
std::array<const Variant *, sizeof...(args)> argptrs;
|
||||||
|
@ -284,7 +284,7 @@ public:
|
||||||
|
|
||||||
static void callp_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error);
|
static void callp_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error);
|
||||||
|
|
||||||
template <class... Args>
|
template <typename... Args>
|
||||||
static Variant call_static(Variant::Type type, const StringName &method, Args... args) {
|
static Variant call_static(Variant::Type type, const StringName &method, Args... args) {
|
||||||
std::array<Variant, sizeof...(args)> vargs = { args... };
|
std::array<Variant, sizeof...(args)> vargs = { args... };
|
||||||
std::array<const Variant *, sizeof...(args)> argptrs;
|
std::array<const Variant *, sizeof...(args)> argptrs;
|
||||||
|
|
|
@ -65,7 +65,7 @@ _FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
bool CharStringT<T>::operator<(const CharStringT<T> &p_right) const {
|
bool CharStringT<T>::operator<(const CharStringT<T> &p_right) const {
|
||||||
if (length() == 0) {
|
if (length() == 0) {
|
||||||
return p_right.length() != 0;
|
return p_right.length() != 0;
|
||||||
|
@ -74,7 +74,7 @@ bool CharStringT<T>::operator<(const CharStringT<T> &p_right) const {
|
||||||
return is_str_less(get_data(), p_right.get_data());
|
return is_str_less(get_data(), p_right.get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
CharStringT<T> &CharStringT<T>::operator+=(T p_char) {
|
CharStringT<T> &CharStringT<T>::operator+=(T p_char) {
|
||||||
const int64_t lhs_len = length();
|
const int64_t lhs_len = length();
|
||||||
resize(lhs_len + 2);
|
resize(lhs_len + 2);
|
||||||
|
@ -86,7 +86,7 @@ CharStringT<T> &CharStringT<T>::operator+=(T p_char) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void CharStringT<T>::operator=(const T *p_cstr) {
|
void CharStringT<T>::operator=(const T *p_cstr) {
|
||||||
copy_from(p_cstr);
|
copy_from(p_cstr);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ const wchar_t *CharStringT<wchar_t>::get_data() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void CharStringT<T>::copy_from(const T *p_cstr) {
|
void CharStringT<T>::copy_from(const T *p_cstr) {
|
||||||
if (!p_cstr) {
|
if (!p_cstr) {
|
||||||
resize(0);
|
resize(0);
|
||||||
|
|
Loading…
Reference in New Issue