Enforce template syntax typename over class

This commit is contained in:
Thaddeus Crews 2024-03-07 20:29:49 -06:00
parent aef11a1427
commit 9903e6779b
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
101 changed files with 538 additions and 538 deletions

View File

@ -70,7 +70,7 @@ protected:
AccessType get_access_type() const; AccessType get_access_type() const;
virtual String fix_path(const String &p_path) const; virtual String fix_path(const String &p_path) const;
template <class T> template <typename T>
static Ref<DirAccess> _create_builtin() { static Ref<DirAccess> _create_builtin() {
return memnew(T); return memnew(T);
} }
@ -130,7 +130,7 @@ public:
static Ref<DirAccess> create(AccessType p_access); static Ref<DirAccess> create(AccessType p_access);
static Error get_open_error(); static Error get_open_error();
template <class T> template <typename T>
static void make_default(AccessType p_access) { static void make_default(AccessType p_access) {
create_func[p_access] = _create_builtin<T>; create_func[p_access] = _create_builtin<T>;
} }

View File

@ -114,7 +114,7 @@ private:
AccessType _access_type = ACCESS_FILESYSTEM; AccessType _access_type = ACCESS_FILESYSTEM;
static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */
template <class T> template <typename T>
static Ref<FileAccess> _create_builtin() { static Ref<FileAccess> _create_builtin() {
return memnew(T); return memnew(T);
} }
@ -226,7 +226,7 @@ public:
static PackedByteArray _get_file_as_bytes(const String &p_path) { return get_file_as_bytes(p_path, &last_file_open_error); } static PackedByteArray _get_file_as_bytes(const String &p_path) { return get_file_as_bytes(p_path, &last_file_open_error); }
static String _get_file_as_string(const String &p_path) { return get_file_as_string(p_path, &last_file_open_error); } static String _get_file_as_string(const String &p_path) { return get_file_as_string(p_path, &last_file_open_error); }
template <class T> template <typename T>
static void make_default(AccessType p_access) { static void make_default(AccessType p_access) {
create_func[p_access] = _create_builtin<T>; create_func[p_access] = _create_builtin<T>;
} }

View File

@ -679,7 +679,7 @@ static double _bicubic_interp_kernel(double x) {
return bc; return bc;
} }
template <int CC, class T> template <int CC, typename T>
static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) { static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
// get source image size // get source image size
int width = p_src_width; int width = p_src_width;
@ -766,7 +766,7 @@ static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_
} }
} }
template <int CC, class T> template <int CC, typename T>
static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) { static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
enum { enum {
FRAC_BITS = 8, FRAC_BITS = 8,
@ -856,7 +856,7 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
} }
} }
template <int CC, class T> template <int CC, typename T>
static void _scale_nearest(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) { static void _scale_nearest(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
for (uint32_t i = 0; i < p_dst_height; i++) { for (uint32_t i = 0; i < p_dst_height; i++) {
uint32_t src_yofs = i * p_src_height / p_dst_height; uint32_t src_yofs = i * p_src_height / p_dst_height;
@ -883,7 +883,7 @@ static float _lanczos(float p_x) {
return Math::abs(p_x) >= LANCZOS_TYPE ? 0 : Math::sincn(p_x) * Math::sincn(p_x / LANCZOS_TYPE); return Math::abs(p_x) >= LANCZOS_TYPE ? 0 : Math::sincn(p_x) * Math::sincn(p_x / LANCZOS_TYPE);
} }
template <int CC, class T> template <int CC, typename T>
static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) { static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
int32_t src_width = p_src_width; int32_t src_width = p_src_width;
int32_t src_height = p_src_height; int32_t src_height = p_src_height;
@ -1665,7 +1665,7 @@ bool Image::_can_modify(Format p_format) const {
return p_format <= FORMAT_RGBE9995; return p_format <= FORMAT_RGBE9995;
} }
template <class Component, int CC, bool renormalize, template <typename Component, int CC, bool renormalize,
void (*average_func)(Component &, const Component &, const Component &, const Component &, const Component &), void (*average_func)(Component &, const Component &, const Component &, const Component &, const Component &),
void (*renormalize_func)(Component *)> void (*renormalize_func)(Component *)>
static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint32_t p_width, uint32_t p_height) { static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint32_t p_width, uint32_t p_height) {

View File

@ -57,7 +57,7 @@
#define BVHTREE_CLASS BVH_Tree<T, NUM_TREES, 2, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT> #define BVHTREE_CLASS BVH_Tree<T, NUM_TREES, 2, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>
#define BVH_LOCKED_FUNCTION BVHLockedFunction _lock_guard(&_mutex, BVH_THREAD_SAFE &&_thread_safe); #define BVH_LOCKED_FUNCTION BVHLockedFunction _lock_guard(&_mutex, BVH_THREAD_SAFE &&_thread_safe);
template <class T, int NUM_TREES = 1, bool USE_PAIRS = false, int MAX_ITEMS = 32, class USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, class USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, class BOUNDS = AABB, class POINT = Vector3, bool BVH_THREAD_SAFE = true> template <typename T, int NUM_TREES = 1, bool USE_PAIRS = false, int MAX_ITEMS = 32, typename USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, typename USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, typename BOUNDS = AABB, typename POINT = Vector3, bool BVH_THREAD_SAFE = true>
class BVH_Manager { class BVH_Manager {
public: public:
// note we are using uint32_t instead of BVHHandle, losing type safety, but this // note we are using uint32_t instead of BVHHandle, losing type safety, but this

View File

@ -32,7 +32,7 @@
#define BVH_ABB_H #define BVH_ABB_H
// special optimized version of axis aligned bounding box // special optimized version of axis aligned bounding box
template <class BOUNDS = AABB, class POINT = Vector3> template <typename BOUNDS = AABB, typename POINT = Vector3>
struct BVH_ABB { struct BVH_ABB {
struct ConvexHull { struct ConvexHull {
// convex hulls (optional) // convex hulls (optional)

View File

@ -106,7 +106,7 @@ struct BVHHandle {
}; };
// helper class to make iterative versions of recursive functions // helper class to make iterative versions of recursive functions
template <class T> template <typename T>
class BVH_IterativeInfo { class BVH_IterativeInfo {
public: public:
enum { enum {
@ -152,7 +152,7 @@ public:
} }
}; };
template <class T> template <typename T>
class BVH_DummyPairTestFunction { class BVH_DummyPairTestFunction {
public: public:
static bool user_collision_check(T *p_a, T *p_b) { static bool user_collision_check(T *p_a, T *p_b) {
@ -161,7 +161,7 @@ public:
} }
}; };
template <class T> template <typename T>
class BVH_DummyCullTestFunction { class BVH_DummyCullTestFunction {
public: public:
static bool user_cull_check(T *p_a, T *p_b) { static bool user_cull_check(T *p_a, T *p_b) {
@ -170,7 +170,7 @@ public:
} }
}; };
template <class T, int NUM_TREES, int MAX_CHILDREN, int MAX_ITEMS, class USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, class USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, bool USE_PAIRS = false, class BOUNDS = AABB, class POINT = Vector3> template <typename T, int NUM_TREES, int MAX_CHILDREN, int MAX_ITEMS, typename USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, typename USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, bool USE_PAIRS = false, typename BOUNDS = AABB, typename POINT = Vector3>
class BVH_Tree { class BVH_Tree {
friend class BVH; friend class BVH;

View File

@ -35,7 +35,7 @@
#include "core/templates/vector.h" #include "core/templates/vector.h"
/* This DisjointSet class uses Find with path compression and Union by rank */ /* This DisjointSet class uses Find with path compression and Union by rank */
template <typename T, class H = HashMapHasherDefault, class C = HashMapComparatorDefault<T>, class AL = DefaultAllocator> template <typename T, typename H = HashMapHasherDefault, typename C = HashMapComparatorDefault<T>, typename AL = DefaultAllocator>
class DisjointSet { class DisjointSet {
struct Element { struct Element {
T object; T object;
@ -65,14 +65,14 @@ public:
/* FUNCTIONS */ /* FUNCTIONS */
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
DisjointSet<T, H, C, AL>::~DisjointSet() { DisjointSet<T, H, C, AL>::~DisjointSet() {
for (KeyValue<T, Element *> &E : elements) { for (KeyValue<T, Element *> &E : elements) {
memdelete_allocator<Element, AL>(E.value); memdelete_allocator<Element, AL>(E.value);
} }
} }
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::get_parent(Element *element) { typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::get_parent(Element *element) {
if (element->parent != element) { if (element->parent != element) {
element->parent = get_parent(element->parent); element->parent = get_parent(element->parent);
@ -81,7 +81,7 @@ typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::get_parent
return element->parent; return element->parent;
} }
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::insert_or_get(T object) { typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::insert_or_get(T object) {
typename MapT::Iterator itr = elements.find(object); typename MapT::Iterator itr = elements.find(object);
if (itr != nullptr) { if (itr != nullptr) {
@ -96,7 +96,7 @@ typename DisjointSet<T, H, C, AL>::Element *DisjointSet<T, H, C, AL>::insert_or_
return new_element; return new_element;
} }
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
void DisjointSet<T, H, C, AL>::create_union(T a, T b) { void DisjointSet<T, H, C, AL>::create_union(T a, T b) {
Element *x = insert_or_get(a); Element *x = insert_or_get(a);
Element *y = insert_or_get(b); Element *y = insert_or_get(b);
@ -121,7 +121,7 @@ void DisjointSet<T, H, C, AL>::create_union(T a, T b) {
} }
} }
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
void DisjointSet<T, H, C, AL>::get_representatives(Vector<T> &out_representatives) { void DisjointSet<T, H, C, AL>::get_representatives(Vector<T> &out_representatives) {
for (KeyValue<T, Element *> &E : elements) { for (KeyValue<T, Element *> &E : elements) {
Element *element = E.value; Element *element = E.value;
@ -131,7 +131,7 @@ void DisjointSet<T, H, C, AL>::get_representatives(Vector<T> &out_representative
} }
} }
template <typename T, class H, class C, class AL> template <typename T, typename H, typename C, typename AL>
void DisjointSet<T, H, C, AL>::get_members(Vector<T> &out_members, T representative) { void DisjointSet<T, H, C, AL>::get_members(Vector<T> &out_members, T representative) {
typename MapT::Iterator rep_itr = elements.find(representative); typename MapT::Iterator rep_itr = elements.find(representative);
ERR_FAIL_NULL(rep_itr); ERR_FAIL_NULL(rep_itr);

View File

@ -305,11 +305,11 @@ public:
virtual ~DefaultQueryResult() {} virtual ~DefaultQueryResult() {}
}; };
template <class QueryResult> template <typename QueryResult>
_FORCE_INLINE_ void aabb_query(const AABB &p_aabb, QueryResult &r_result); _FORCE_INLINE_ void aabb_query(const AABB &p_aabb, QueryResult &r_result);
template <class QueryResult> template <typename QueryResult>
_FORCE_INLINE_ void convex_query(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count, QueryResult &r_result); _FORCE_INLINE_ void convex_query(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count, QueryResult &r_result);
template <class QueryResult> template <typename QueryResult>
_FORCE_INLINE_ void ray_query(const Vector3 &p_from, const Vector3 &p_to, QueryResult &r_result); _FORCE_INLINE_ void ray_query(const Vector3 &p_from, const Vector3 &p_to, QueryResult &r_result);
void set_index(uint32_t p_index); void set_index(uint32_t p_index);
@ -318,7 +318,7 @@ public:
~DynamicBVH(); ~DynamicBVH();
}; };
template <class QueryResult> template <typename QueryResult>
void DynamicBVH::aabb_query(const AABB &p_box, QueryResult &r_result) { void DynamicBVH::aabb_query(const AABB &p_box, QueryResult &r_result) {
if (!bvh_root) { if (!bvh_root) {
return; return;
@ -363,7 +363,7 @@ void DynamicBVH::aabb_query(const AABB &p_box, QueryResult &r_result) {
} while (depth > 0); } while (depth > 0);
} }
template <class QueryResult> template <typename QueryResult>
void DynamicBVH::convex_query(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count, QueryResult &r_result) { void DynamicBVH::convex_query(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count, QueryResult &r_result) {
if (!bvh_root) { if (!bvh_root) {
return; return;
@ -420,7 +420,7 @@ void DynamicBVH::convex_query(const Plane *p_planes, int p_plane_count, const Ve
} }
} while (depth > 0); } while (depth > 0);
} }
template <class QueryResult> template <typename QueryResult>
void DynamicBVH::ray_query(const Vector3 &p_from, const Vector3 &p_to, QueryResult &r_result) { void DynamicBVH::ray_query(const Vector3 &p_from, const Vector3 &p_to, QueryResult &r_result) {
if (!bvh_root) { if (!bvh_root) {
return; return;

View File

@ -243,7 +243,7 @@ private:
} }
}; };
template <class T> template <typename T>
T *alloc_node() { T *alloc_node() {
T *node = memnew(T); T *node = memnew(T);
node->next = nodes; node->next = nodes;

View File

@ -34,7 +34,7 @@
#include "core/math/vector3.h" #include "core/math/vector3.h"
#include "core/math/vector4.h" #include "core/math/vector4.h"
template <class T> template <typename T>
class Vector; class Vector;
struct AABB; struct AABB;

View File

@ -59,7 +59,7 @@ static int __bsr_clz32(uint32_t x) {
#define LDEXPF(s, e) ldexp(s, e) #define LDEXPF(s, e) ldexp(s, e)
#endif #endif
template <class T> template <typename T>
class Vector; class Vector;
class RandomPCG { class RandomPCG {

View File

@ -77,7 +77,7 @@ public:
virtual uint32_t hash() const; virtual uint32_t hash() const;
}; };
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;
@ -107,7 +107,7 @@ public:
} }
}; };
template <class T, class... P> template <typename T, typename... P>
Callable create_custom_callable_function_pointer(T *p_instance, Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
const char *p_func_text, const char *p_func_text,
@ -123,7 +123,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
// VERSION WITH RETURN // VERSION WITH RETURN
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;
@ -154,7 +154,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, Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
const char *p_func_text, const char *p_func_text,
@ -170,7 +170,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
// CONST VERSION WITH RETURN // CONST VERSION WITH RETURN
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;
@ -201,7 +201,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, Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
const char *p_func_text, const char *p_func_text,
@ -223,7 +223,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
// STATIC VERSIONS // STATIC VERSIONS
template <class... P> template <typename... P>
class CallableCustomStaticMethodPointer : public CallableCustomMethodPointerBase { class CallableCustomStaticMethodPointer : public CallableCustomMethodPointerBase {
struct Data { struct Data {
void (*method)(P...); void (*method)(P...);
@ -250,7 +250,7 @@ public:
} }
}; };
template <class T, class... P> template <typename T, typename... P>
Callable create_custom_callable_static_function_pointer( Callable create_custom_callable_static_function_pointer(
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
const char *p_func_text, const char *p_func_text,
@ -264,7 +264,7 @@ Callable create_custom_callable_static_function_pointer(
return Callable(ccmp); return Callable(ccmp);
} }
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)
@ -291,7 +291,7 @@ public:
} }
}; };
template <class R, class... P> template <typename R, typename... P>
Callable create_custom_callable_static_function_pointer( Callable create_custom_callable_static_function_pointer(
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
const char *p_func_text, const char *p_func_text,

View File

@ -140,7 +140,7 @@ public:
~ClassInfo() {} ~ClassInfo() {}
}; };
template <class T> template <typename T>
static Object *creator() { static Object *creator() {
return memnew(T); return memnew(T);
} }
@ -187,12 +187,12 @@ private:
public: public:
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!! // DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
template <class T> template <typename T>
static void _add_class() { static void _add_class() {
_add_class2(T::get_class_static(), T::get_parent_class_static()); _add_class2(T::get_class_static(), T::get_parent_class_static());
} }
template <class T> template <typename T>
static void register_class(bool p_virtual = false) { static void register_class(bool p_virtual = false) {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS."); static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS.");
@ -207,7 +207,7 @@ public:
T::register_custom_data_to_otdb(); T::register_custom_data_to_otdb();
} }
template <class T> template <typename T>
static void register_abstract_class() { static void register_abstract_class() {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS."); static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS.");
@ -220,7 +220,7 @@ public:
//nothing //nothing
} }
template <class T> template <typename T>
static void register_internal_class() { static void register_internal_class() {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS."); static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS.");
@ -235,7 +235,7 @@ public:
T::register_custom_data_to_otdb(); T::register_custom_data_to_otdb();
} }
template <class T> template <typename T>
static void register_runtime_class() { static void register_runtime_class() {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS."); static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS.");
@ -255,12 +255,12 @@ public:
static void register_extension_class(ObjectGDExtension *p_extension); static void register_extension_class(ObjectGDExtension *p_extension);
static void unregister_extension_class(const StringName &p_class, bool p_free_method_binds = true); static void unregister_extension_class(const StringName &p_class, bool p_free_method_binds = true);
template <class T> template <typename T>
static Object *_create_ptr_func() { static Object *_create_ptr_func() {
return T::create(); return T::create();
} }
template <class T> template <typename T>
static void register_custom_instance_class() { static void register_custom_instance_class() {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS."); static_assert(types_are_same_v<typename T::self_type, T>, "Class not declared properly, please use GDCLASS.");
@ -314,7 +314,7 @@ public:
using return_type = R; using return_type = R;
}; };
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) {
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];
@ -328,7 +328,7 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, false, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args)); return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, false, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
} }
template <class N, class M, typename... VarArgs> template <typename N, typename M, typename... VarArgs>
static MethodBind *bind_static_method(const StringName &p_class, N p_method_name, M p_method, VarArgs... p_args) { static MethodBind *bind_static_method(const 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];
@ -343,7 +343,7 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, false, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args)); return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, false, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
} }
template <class N, class M, typename... VarArgs> template <typename N, typename M, typename... VarArgs>
static MethodBind *bind_compatibility_method(N p_method_name, M p_method, VarArgs... p_args) { static MethodBind *bind_compatibility_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];
@ -357,7 +357,7 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, true, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args)); return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, true, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
} }
template <class N, class M, typename... VarArgs> template <typename N, typename M, typename... VarArgs>
static MethodBind *bind_compatibility_static_method(const StringName &p_class, N p_method_name, M p_method, VarArgs... p_args) { static MethodBind *bind_compatibility_static_method(const 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];
@ -372,7 +372,7 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, true, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args)); return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, true, p_method_name, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
} }
template <class M> template <typename M>
static MethodBind *bind_vararg_method(uint32_t p_flags, const StringName &p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) { static MethodBind *bind_vararg_method(uint32_t p_flags, const StringName &p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
@ -385,7 +385,7 @@ public:
return _bind_vararg_method(bind, p_name, p_default_args, false); return _bind_vararg_method(bind, p_name, p_default_args, false);
} }
template <class M> template <typename M>
static MethodBind *bind_compatibility_vararg_method(uint32_t p_flags, const StringName &p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) { static MethodBind *bind_compatibility_vararg_method(uint32_t p_flags, const StringName &p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
GLOBAL_LOCK_FUNCTION; GLOBAL_LOCK_FUNCTION;
@ -497,13 +497,13 @@ _FORCE_INLINE_ void errarray_add_str(Vector<Error> &arr, const Error &p_err) {
arr.push_back(p_err); arr.push_back(p_err);
} }
template <class... P> template <typename... P>
_FORCE_INLINE_ void errarray_add_str(Vector<Error> &arr, const Error &p_err, P... p_args) { _FORCE_INLINE_ void errarray_add_str(Vector<Error> &arr, const Error &p_err, P... p_args) {
arr.push_back(p_err); arr.push_back(p_err);
errarray_add_str(arr, p_args...); errarray_add_str(arr, p_args...);
} }
template <class... P> template <typename... P>
_FORCE_INLINE_ Vector<Error> errarray(P... p_args) { _FORCE_INLINE_ Vector<Error> errarray(P... p_args) {
Vector<Error> arr; Vector<Error> arr;
errarray_add_str(arr, p_args...); errarray_add_str(arr, p_args...);

View File

@ -140,7 +140,7 @@ public:
}; };
// MethodBindVarArg base CRTP // MethodBindVarArg base CRTP
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)
@ -219,7 +219,7 @@ private:
}; };
// variadic, no return // variadic, no return
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>;
@ -245,7 +245,7 @@ private:
} }
}; };
template <class T> template <typename T>
MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, int, Callable::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) { MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, int, Callable::CallError &), 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());
@ -253,7 +253,7 @@ MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, int,
} }
// variadic, return // variadic, return
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>;
@ -287,7 +287,7 @@ private:
} }
}; };
template <class T, class R> template <typename T, typename R>
MethodBind *create_vararg_method_bind(R (T::*p_method)(const Variant **, int, Callable::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) { MethodBind *create_vararg_method_bind(R (T::*p_method)(const Variant **, int, Callable::CallError &), 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());
@ -305,9 +305,9 @@ class __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 #endif
class MethodBindT : public MethodBind { class MethodBindT : public MethodBind {
void (MB_T::*method)(P...); void (MB_T::*method)(P...);
@ -375,7 +375,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));
@ -389,9 +389,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 #endif
class MethodBindTC : public MethodBind { class MethodBindTC : public MethodBind {
void (MB_T::*method)(P...) const; void (MB_T::*method)(P...) const;
@ -460,7 +460,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));
@ -474,9 +474,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 #endif
class MethodBindTR : public MethodBind { class MethodBindTR : public MethodBind {
R(MB_T::*method) R(MB_T::*method)
@ -555,7 +555,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));
@ -570,9 +570,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 #endif
class MethodBindTRC : public MethodBind { class MethodBindTRC : public MethodBind {
R(MB_T::*method) R(MB_T::*method)
@ -652,7 +652,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));
@ -667,7 +667,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...);
@ -717,7 +717,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;
@ -725,7 +725,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...);
@ -784,7 +784,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;

View File

@ -796,12 +796,12 @@ public:
void detach_from_objectdb(); void detach_from_objectdb();
_FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_id; } _FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_id; }
template <class T> template <typename T>
static T *cast_to(Object *p_object) { static T *cast_to(Object *p_object) {
return p_object ? dynamic_cast<T *>(p_object) : nullptr; return p_object ? dynamic_cast<T *>(p_object) : nullptr;
} }
template <class T> template <typename T>
static const T *cast_to(const Object *p_object) { static const T *cast_to(const Object *p_object) {
return p_object ? dynamic_cast<const T *>(p_object) : nullptr; return p_object ? dynamic_cast<const T *>(p_object) : nullptr;
} }

View File

@ -53,7 +53,7 @@ public:
~RefCounted() {} ~RefCounted() {}
}; };
template <class T> template <typename T>
class Ref { class Ref {
T *reference = nullptr; T *reference = nullptr;
@ -117,7 +117,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) {
@ -149,7 +149,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;
@ -166,7 +166,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) {
@ -240,7 +240,7 @@ public:
WeakRef() {} WeakRef() {}
}; };
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) {
if (p_ptr == nullptr) { if (p_ptr == nullptr) {
@ -258,7 +258,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;
@ -271,7 +271,7 @@ struct PtrToArg<const Ref<T> &> {
} }
}; };
template <class T> template <typename T>
struct GetTypeInfo<Ref<T>> { struct GetTypeInfo<Ref<T>> {
static const Variant::Type VARIANT_TYPE = Variant::OBJECT; static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
@ -281,7 +281,7 @@ struct GetTypeInfo<Ref<T>> {
} }
}; };
template <class T> template <typename T>
struct GetTypeInfo<const Ref<T> &> { struct GetTypeInfo<const Ref<T> &> {
static const Variant::Type VARIANT_TYPE = Variant::OBJECT; static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
@ -291,13 +291,13 @@ struct GetTypeInfo<const Ref<T> &> {
} }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<Ref<T>> { struct VariantInternalAccessor<Ref<T>> {
static _FORCE_INLINE_ Ref<T> get(const Variant *v) { return Ref<T>(*VariantInternal::get_object(v)); } static _FORCE_INLINE_ Ref<T> get(const Variant *v) { return Ref<T>(*VariantInternal::get_object(v)); }
static _FORCE_INLINE_ void set(Variant *v, const Ref<T> &p_ref) { VariantInternal::refcounted_object_assign(v, p_ref.ptr()); } static _FORCE_INLINE_ void set(Variant *v, const Ref<T> &p_ref) { VariantInternal::refcounted_object_assign(v, p_ref.ptr()); }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<const Ref<T> &> { struct VariantInternalAccessor<const Ref<T> &> {
static _FORCE_INLINE_ Ref<T> get(const Variant *v) { return Ref<T>(*VariantInternal::get_object(v)); } static _FORCE_INLINE_ Ref<T> get(const Variant *v) { return Ref<T>(*VariantInternal::get_object(v)); }
static _FORCE_INLINE_ void set(Variant *v, const Ref<T> &p_ref) { VariantInternal::refcounted_object_assign(v, p_ref.ptr()); } static _FORCE_INLINE_ void set(Variant *v, const Ref<T> &p_ref) { VariantInternal::refcounted_object_assign(v, p_ref.ptr()); }

View File

@ -157,7 +157,7 @@ private:
TaskID _add_task(const Callable &p_callable, void (*p_func)(void *), void *p_userdata, BaseTemplateUserdata *p_template_userdata, bool p_high_priority, const String &p_description); TaskID _add_task(const Callable &p_callable, void (*p_func)(void *), void *p_userdata, BaseTemplateUserdata *p_template_userdata, bool p_high_priority, const String &p_description);
GroupID _add_group_task(const Callable &p_callable, void (*p_func)(void *, uint32_t), void *p_userdata, BaseTemplateUserdata *p_template_userdata, int p_elements, int p_tasks, bool p_high_priority, const String &p_description); GroupID _add_group_task(const Callable &p_callable, void (*p_func)(void *, uint32_t), void *p_userdata, BaseTemplateUserdata *p_template_userdata, int p_elements, int p_tasks, bool p_high_priority, const String &p_description);
template <class C, class M, class U> template <typename C, typename M, typename U>
struct TaskUserData : public BaseTemplateUserdata { struct TaskUserData : public BaseTemplateUserdata {
C *instance; C *instance;
M method; M method;
@ -167,7 +167,7 @@ private:
} }
}; };
template <class C, class M, class U> template <typename C, typename M, typename U>
struct GroupUserData : public BaseTemplateUserdata { struct GroupUserData : public BaseTemplateUserdata {
C *instance; C *instance;
M method; M method;
@ -181,7 +181,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
template <class C, class M, class U> template <typename C, typename M, typename U>
TaskID add_template_task(C *p_instance, M p_method, U p_userdata, bool p_high_priority = false, const String &p_description = String()) { TaskID add_template_task(C *p_instance, M p_method, U p_userdata, bool p_high_priority = false, const String &p_description = String()) {
typedef TaskUserData<C, M, U> TUD; typedef TaskUserData<C, M, U> TUD;
TUD *ud = memnew(TUD); TUD *ud = memnew(TUD);
@ -196,7 +196,7 @@ public:
bool is_task_completed(TaskID p_task_id) const; bool is_task_completed(TaskID p_task_id) const;
Error wait_for_task_completion(TaskID p_task_id); Error wait_for_task_completion(TaskID p_task_id);
template <class C, class M, class U> template <typename C, typename M, typename U>
GroupID add_template_group_task(C *p_instance, M p_method, U p_userdata, int p_elements, int p_tasks = -1, bool p_high_priority = false, const String &p_description = String()) { GroupID add_template_group_task(C *p_instance, M p_method, U p_userdata, int p_elements, int p_tasks = -1, bool p_high_priority = false, const String &p_description = String()) {
typedef GroupUserData<C, M, U> GroupUD; typedef GroupUserData<C, M, U> GroupUD;
GroupUD *ud = memnew(GroupUD); GroupUD *ud = memnew(GroupUD);

View File

@ -54,7 +54,7 @@ class ConditionVariable {
mutable THREADING_NAMESPACE::condition_variable condition; mutable THREADING_NAMESPACE::condition_variable condition;
public: public:
template <class BinaryMutexT> template <typename BinaryMutexT>
_ALWAYS_INLINE_ void wait(const MutexLock<BinaryMutexT> &p_lock) const { _ALWAYS_INLINE_ void wait(const MutexLock<BinaryMutexT> &p_lock) const {
condition.wait(const_cast<THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &>(p_lock.lock)); condition.wait(const_cast<THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &>(p_lock.lock));
} }
@ -72,7 +72,7 @@ public:
class ConditionVariable { class ConditionVariable {
public: public:
template <class BinaryMutexT> template <typename BinaryMutexT>
void wait(const MutexLock<BinaryMutexT> &p_lock) const {} void wait(const MutexLock<BinaryMutexT> &p_lock) const {}
void notify_one() const {} void notify_one() const {}
void notify_all() const {} void notify_all() const {}

View File

@ -92,7 +92,7 @@ void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_d
_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;
@ -107,7 +107,7 @@ _ALWAYS_INLINE_ bool predelete_handler(void *) {
return true; return true;
} }
template <class T> template <typename T>
void memdelete(T *p_class) { void memdelete(T *p_class) {
if (!predelete_handler(p_class)) { if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted return; // doesn't want to be deleted
@ -119,7 +119,7 @@ void memdelete(T *p_class) {
Memory::free_static(p_class, false); Memory::free_static(p_class, false);
} }
template <class T, class A> template <typename T, typename A>
void memdelete_allocator(T *p_class) { void memdelete_allocator(T *p_class) {
if (!predelete_handler(p_class)) { if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted return; // doesn't want to be deleted
@ -213,10 +213,10 @@ struct _GlobalNilClass {
static _GlobalNil _nil; static _GlobalNil _nil;
}; };
template <class T> template <typename T>
class DefaultTypedAllocator { class DefaultTypedAllocator {
public: public:
template <class... Args> template <typename... Args>
_FORCE_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); } _FORCE_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); }
_FORCE_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); } _FORCE_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); }
}; };

View File

@ -45,10 +45,10 @@
#ifdef THREADS_ENABLED #ifdef THREADS_ENABLED
template <class MutexT> template <typename MutexT>
class MutexLock; class MutexLock;
template <class StdMutexT> template <typename StdMutexT>
class MutexImpl { class MutexImpl {
friend class MutexLock<MutexImpl<StdMutexT>>; friend class MutexLock<MutexImpl<StdMutexT>>;
@ -70,7 +70,7 @@ public:
} }
}; };
template <class MutexT> template <typename MutexT>
class MutexLock { class MutexLock {
friend class ConditionVariable; friend class ConditionVariable;
@ -100,7 +100,7 @@ public:
bool try_lock() const { return true; } bool try_lock() const { return true; }
}; };
template <class MutexT> template <typename MutexT>
class MutexLock { class MutexLock {
public: public:
MutexLock(const MutexT &p_mutex) {} MutexLock(const MutexT &p_mutex) {}

View File

@ -2459,7 +2459,7 @@ bool String::is_numeric() const {
return true; // TODO: Use the parser below for this instead return true; // TODO: Use the parser below for this instead
} }
template <class C> template <typename C>
static double built_in_strtod( static double built_in_strtod(
/* A decimal ASCII floating-point number, /* A decimal ASCII floating-point number,
* optionally preceded by white space. Must * optionally preceded by white space. Must

View File

@ -43,7 +43,7 @@
/* CharProxy */ /* CharProxy */
/*************************************************************************/ /*************************************************************************/
template <class T> template <typename T>
class CharProxy { class CharProxy {
friend class Char16String; friend class Char16String;
friend class CharString; friend class CharString;
@ -602,13 +602,13 @@ _FORCE_INLINE_ void sarray_add_str(Vector<String> &arr, const String &p_str) {
arr.push_back(p_str); arr.push_back(p_str);
} }
template <class... P> template <typename... P>
_FORCE_INLINE_ void sarray_add_str(Vector<String> &arr, const String &p_str, P... p_args) { _FORCE_INLINE_ void sarray_add_str(Vector<String> &arr, const String &p_str, P... p_args) {
arr.push_back(p_str); arr.push_back(p_str);
sarray_add_str(arr, p_args...); sarray_add_str(arr, p_args...);
} }
template <class... P> template <typename... P>
_FORCE_INLINE_ Vector<String> sarray(P... p_args) { _FORCE_INLINE_ Vector<String> sarray(P... p_args) {
Vector<String> arr; Vector<String> arr;
sarray_add_str(arr, p_args...); sarray_add_str(arr, p_args...);

View File

@ -34,7 +34,7 @@
#include "core/templates/local_vector.h" #include "core/templates/local_vector.h"
#include "core/templates/paged_array.h" #include "core/templates/paged_array.h"
template <class T> template <typename T>
class BinSortedArray { class BinSortedArray {
PagedArray<T> array; PagedArray<T> array;
LocalVector<uint64_t> bin_limits; LocalVector<uint64_t> bin_limits;

View File

@ -207,41 +207,41 @@
#define ARG(N) p##N #define ARG(N) p##N
#define PARAM(N) P##N p##N #define PARAM(N) P##N p##N
#define TYPE_PARAM(N) class P##N #define TYPE_PARAM(N) typename P##N
#define PARAM_DECL(N) typename GetSimpleTypeT<P##N>::type_t p##N #define PARAM_DECL(N) typename GetSimpleTypeT<P##N>::type_t p##N
#define DECL_CMD(N) \ #define DECL_CMD(N) \
template <class T, class M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \ template <typename T, typename M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \
struct Command##N : public CommandBase { \ struct Command##N : public CommandBase { \
T *instance; \ T *instance; \
M method; \ M method; \
SEMIC_SEP_LIST(PARAM_DECL, N); \ SEMIC_SEP_LIST(PARAM_DECL, N); \
virtual void call() override { \ virtual void call() override { \
(instance->*method)(COMMA_SEP_LIST(ARG, N)); \ (instance->*method)(COMMA_SEP_LIST(ARG, N)); \
} \ } \
}; };
#define DECL_CMD_RET(N) \ #define DECL_CMD_RET(N) \
template <class T, class M, COMMA_SEP_LIST(TYPE_PARAM, N) COMMA(N) class R> \ template <typename T, typename M, COMMA_SEP_LIST(TYPE_PARAM, N) COMMA(N) typename R> \
struct CommandRet##N : public SyncCommand { \ struct CommandRet##N : public SyncCommand { \
R *ret; \ R *ret; \
T *instance; \ T *instance; \
M method; \ M method; \
SEMIC_SEP_LIST(PARAM_DECL, N); \ SEMIC_SEP_LIST(PARAM_DECL, N); \
virtual void call() override { \ virtual void call() override { \
*ret = (instance->*method)(COMMA_SEP_LIST(ARG, N)); \ *ret = (instance->*method)(COMMA_SEP_LIST(ARG, N)); \
} \ } \
}; };
#define DECL_CMD_SYNC(N) \ #define DECL_CMD_SYNC(N) \
template <class T, class M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \ template <typename T, typename M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \
struct CommandSync##N : public SyncCommand { \ struct CommandSync##N : public SyncCommand { \
T *instance; \ T *instance; \
M method; \ M method; \
SEMIC_SEP_LIST(PARAM_DECL, N); \ SEMIC_SEP_LIST(PARAM_DECL, N); \
virtual void call() override { \ virtual void call() override { \
(instance->*method)(COMMA_SEP_LIST(ARG, N)); \ (instance->*method)(COMMA_SEP_LIST(ARG, N)); \
} \ } \
}; };
#define TYPE_ARG(N) P##N #define TYPE_ARG(N) P##N
@ -249,7 +249,7 @@
#define CMD_ASSIGN_PARAM(N) cmd->p##N = p##N #define CMD_ASSIGN_PARAM(N) cmd->p##N = p##N
#define DECL_PUSH(N) \ #define DECL_PUSH(N) \
template <class T, class M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \ template <typename T, typename M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \
void push(T *p_instance, M p_method COMMA(N) COMMA_SEP_LIST(PARAM, N)) { \ void push(T *p_instance, M p_method COMMA(N) COMMA_SEP_LIST(PARAM, N)) { \
CMD_TYPE(N) *cmd = allocate_and_lock<CMD_TYPE(N)>(); \ CMD_TYPE(N) *cmd = allocate_and_lock<CMD_TYPE(N)>(); \
cmd->instance = p_instance; \ cmd->instance = p_instance; \
@ -263,7 +263,7 @@
#define CMD_RET_TYPE(N) CommandRet##N<T, M, COMMA_SEP_LIST(TYPE_ARG, N) COMMA(N) R> #define CMD_RET_TYPE(N) CommandRet##N<T, M, COMMA_SEP_LIST(TYPE_ARG, N) COMMA(N) R>
#define DECL_PUSH_AND_RET(N) \ #define DECL_PUSH_AND_RET(N) \
template <class T, class M, COMMA_SEP_LIST(TYPE_PARAM, N) COMMA(N) class R> \ template <typename T, typename M, COMMA_SEP_LIST(TYPE_PARAM, N) COMMA(N) typename R> \
void push_and_ret(T *p_instance, M p_method, COMMA_SEP_LIST(PARAM, N) COMMA(N) R *r_ret) { \ void push_and_ret(T *p_instance, M p_method, COMMA_SEP_LIST(PARAM, N) COMMA(N) R *r_ret) { \
SyncSemaphore *ss = _alloc_sync_sem(); \ SyncSemaphore *ss = _alloc_sync_sem(); \
CMD_RET_TYPE(N) *cmd = allocate_and_lock<CMD_RET_TYPE(N)>(); \ CMD_RET_TYPE(N) *cmd = allocate_and_lock<CMD_RET_TYPE(N)>(); \
@ -282,7 +282,7 @@
#define CMD_SYNC_TYPE(N) CommandSync##N<T, M COMMA(N) COMMA_SEP_LIST(TYPE_ARG, N)> #define CMD_SYNC_TYPE(N) CommandSync##N<T, M COMMA(N) COMMA_SEP_LIST(TYPE_ARG, N)>
#define DECL_PUSH_AND_SYNC(N) \ #define DECL_PUSH_AND_SYNC(N) \
template <class T, class M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \ template <typename T, typename M COMMA(N) COMMA_SEP_LIST(TYPE_PARAM, N)> \
void push_and_sync(T *p_instance, M p_method COMMA(N) COMMA_SEP_LIST(PARAM, N)) { \ void push_and_sync(T *p_instance, M p_method COMMA(N) COMMA_SEP_LIST(PARAM, N)) { \
SyncSemaphore *ss = _alloc_sync_sem(); \ SyncSemaphore *ss = _alloc_sync_sem(); \
CMD_SYNC_TYPE(N) *cmd = allocate_and_lock<CMD_SYNC_TYPE(N)>(); \ CMD_SYNC_TYPE(N) *cmd = allocate_and_lock<CMD_SYNC_TYPE(N)>(); \
@ -343,7 +343,7 @@ class CommandQueueMT {
Semaphore *sync = nullptr; Semaphore *sync = nullptr;
uint64_t flush_read_ptr = 0; uint64_t flush_read_ptr = 0;
template <class T> template <typename T>
T *allocate() { T *allocate() {
// alloc size is size+T+safeguard // alloc size is size+T+safeguard
uint32_t alloc_size = ((sizeof(T) + 8 - 1) & ~(8 - 1)); uint32_t alloc_size = ((sizeof(T) + 8 - 1) & ~(8 - 1));
@ -354,7 +354,7 @@ class CommandQueueMT {
return cmd; return cmd;
} }
template <class T> template <typename T>
T *allocate_and_lock() { T *allocate_and_lock() {
lock(); lock();
T *ret = allocate<T>(); T *ret = allocate<T>();

View File

@ -38,12 +38,12 @@
#include <string.h> #include <string.h>
#include <type_traits> #include <type_traits>
template <class T> template <typename T>
class Vector; class Vector;
class String; class String;
class Char16String; class Char16String;
class CharString; class CharString;
template <class T, class V> template <typename T, typename V>
class VMap; class VMap;
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>); static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
@ -54,14 +54,14 @@ 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;
friend class String; friend class String;
friend class Char16String; friend class Char16String;
friend class CharString; friend class CharString;
template <class TV, class VV> template <typename TV, typename VV>
friend class VMap; friend class VMap;
public: public:
@ -241,7 +241,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;
@ -268,7 +268,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;
@ -308,7 +308,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);
@ -401,7 +401,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;
@ -419,7 +419,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();
@ -438,7 +438,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++) {
@ -449,12 +449,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.
@ -472,7 +472,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);
} }

View File

@ -51,7 +51,7 @@
* 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;
@ -61,10 +61,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:
static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime. static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.

View File

@ -46,9 +46,9 @@
* *
*/ */
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.

View File

@ -248,7 +248,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;
@ -281,7 +281,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;
@ -293,15 +293,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(); }
@ -387,7 +387,7 @@ struct HashMapHasherDefault {
}; };
// TODO: Fold this into HashMapHasherDefault once C++20 concepts are allowed // TODO: Fold this into HashMapHasherDefault once C++20 concepts are allowed
template <class T> template <typename T>
struct HashableHasher { struct HashableHasher {
static _FORCE_INLINE_ uint32_t hash(const T &hashable) { return hashable.hash(); } static _FORCE_INLINE_ uint32_t hash(const T &hashable) { return hashable.hash(); }
}; };

View File

@ -43,7 +43,7 @@
* from the iterator. * from the iterator.
*/ */
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
@ -764,7 +764,7 @@ public:
} }
}; };
template <class T, class A> template <typename T, typename A>
void List<T, A>::Element::transfer_to_back(List<T, A> *p_dst_list) { void List<T, A>::Element::transfer_to_back(List<T, A> *p_dst_list) {
// Detach from current. // Detach from current.

View File

@ -41,7 +41,7 @@
// 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;
@ -248,7 +248,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) {
@ -322,7 +322,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>;
#endif // LOCAL_VECTOR_H #endif // LOCAL_VECTOR_H

View File

@ -35,7 +35,7 @@
#include "hash_map.h" #include "hash_map.h"
#include "list.h" #include "list.h"
template <class TKey, class TData, class Hasher = HashMapHasherDefault, class Comparator = HashMapComparatorDefault<TKey>> template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>>
class LRUCache { class LRUCache {
private: private:
struct Pair { struct Pair {

View File

@ -50,9 +50,9 @@
* *
* 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,
class Hasher = HashMapHasherDefault, typename Hasher = HashMapHasherDefault,
class Comparator = HashMapComparatorDefault<TKey>> typename Comparator = HashMapComparatorDefault<TKey>>
class OAHashMap { class OAHashMap {
private: private:
TValue *values = nullptr; TValue *values = nullptr;

View File

@ -40,7 +40,7 @@
#include <type_traits> #include <type_traits>
#include <typeinfo> #include <typeinfo>
template <class T, bool thread_safe = false, uint32_t DEFAULT_PAGE_SIZE = 4096> template <typename T, bool thread_safe = false, uint32_t DEFAULT_PAGE_SIZE = 4096>
class PagedAllocator { class PagedAllocator {
T **page_pool = nullptr; T **page_pool = nullptr;
T ***available_pool = nullptr; T ***available_pool = nullptr;
@ -53,7 +53,7 @@ class PagedAllocator {
SpinLock spin_lock; SpinLock spin_lock;
public: public:
template <class... Args> template <typename... Args>
T *alloc(Args &&...p_args) { T *alloc(Args &&...p_args) {
if (thread_safe) { if (thread_safe) {
spin_lock.lock(); spin_lock.lock();
@ -95,7 +95,7 @@ public:
} }
} }
template <class... Args> template <typename... Args>
T *new_allocation(Args &&...p_args) { return alloc(p_args...); } T *new_allocation(Args &&...p_args) { return alloc(p_args...); }
void delete_allocation(T *p_mem) { free(p_mem); } void delete_allocation(T *p_mem) { free(p_mem); }

View File

@ -41,7 +41,7 @@
// PageArrayPool manages central page allocation in a thread safe matter // PageArrayPool manages central page allocation in a thread safe matter
template <class T> template <typename T>
class PagedArrayPool { class PagedArrayPool {
T **page_pool = nullptr; T **page_pool = nullptr;
uint32_t pages_allocated = 0; uint32_t pages_allocated = 0;
@ -134,7 +134,7 @@ public:
// It does so by allocating pages from a PagedArrayPool. // It does so by allocating pages from a PagedArrayPool.
// It is safe to use multiple PagedArrays from different threads, sharing a single PagedArrayPool // It is safe to use multiple PagedArrays from different threads, sharing a single PagedArrayPool
template <class T> template <typename T>
class PagedArray { class PagedArray {
PagedArrayPool<T> *page_pool = nullptr; PagedArrayPool<T> *page_pool = nullptr;

View File

@ -33,7 +33,7 @@
#include "core/templates/hashfuncs.h" #include "core/templates/hashfuncs.h"
#include "core/typedefs.h" #include "core/typedefs.h"
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 F, class S> template <typename F, typename S>
struct PairHash { struct PairHash {
static uint32_t hash(const Pair<F, S> &P) { static uint32_t hash(const Pair<F, S> &P) {
uint64_t h1 = HashMapHasherDefault::hash(P.first); uint64_t h1 = HashMapHasherDefault::hash(P.first);
@ -78,7 +78,7 @@ struct PairHash {
} }
}; };
template <class K, class V> template <typename K, typename V>
struct KeyValue { struct KeyValue {
const K key; const K key;
V value; V value;
@ -94,17 +94,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;

View File

@ -55,7 +55,7 @@
#include "core/templates/local_vector.h" #include "core/templates/local_vector.h"
template <class T, class U = uint32_t, bool force_trivial = false, bool zero_on_first_request = false> template <typename T, typename U = uint32_t, bool force_trivial = false, bool zero_on_first_request = false>
class PooledList { class PooledList {
LocalVector<T, U, force_trivial> list; LocalVector<T, U, force_trivial> list;
LocalVector<U, U, true> freelist; LocalVector<U, U, true> freelist;
@ -128,7 +128,7 @@ public:
}; };
// a pooled list which automatically keeps a list of the active members // a pooled list which automatically keeps a list of the active members
template <class T, class U = uint32_t, bool force_trivial = false, bool zero_on_first_request = false> template <typename T, typename U = uint32_t, bool force_trivial = false, bool zero_on_first_request = false>
class TrackedPooledList { class TrackedPooledList {
public: public:
U pool_used_size() const { return _pool.used_size(); } U pool_used_size() const { return _pool.used_size(); }

View File

@ -38,7 +38,7 @@
// 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,

View File

@ -37,7 +37,7 @@
// 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 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,

View File

@ -67,7 +67,7 @@ public:
virtual ~RID_AllocBase() {} virtual ~RID_AllocBase() {}
}; };
template <class T, bool THREAD_SAFE = false> template <typename T, bool THREAD_SAFE = false>
class RID_Alloc : public RID_AllocBase { class RID_Alloc : public RID_AllocBase {
T **chunks = nullptr; T **chunks = nullptr;
uint32_t **free_list_chunks = nullptr; uint32_t **free_list_chunks = nullptr;
@ -364,7 +364,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;
@ -423,7 +423,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;

View File

@ -48,7 +48,7 @@
// This is used in very specific areas of the engine where it's critical that these guarantees are held. // This is used in very specific areas of the engine where it's critical that these guarantees are held.
template <class T, class A = DefaultAllocator> template <typename T, typename A = DefaultAllocator>
class SafeList { class SafeList {
struct SafeListNode { struct SafeListNode {
std::atomic<SafeListNode *> next = nullptr; std::atomic<SafeListNode *> next = nullptr;

View File

@ -59,7 +59,7 @@
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;

View File

@ -33,7 +33,7 @@
#include <core/templates/sort_array.h> #include <core/templates/sort_array.h>
template <class T, class Comparator = _DefaultComparator<T>> template <typename T, typename Comparator = _DefaultComparator<T>>
class SearchArray { class SearchArray {
public: public:
Comparator compare; Comparator compare;

View File

@ -34,7 +34,7 @@
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/typedefs.h" #include "core/typedefs.h"
template <class T> template <typename T>
class SelfList { class SelfList {
public: public:
class List { class List {
@ -109,7 +109,7 @@ public:
sort_custom<Comparator<T>>(); sort_custom<Comparator<T>>();
} }
template <class C> template <typename C>
void sort_custom() { void sort_custom() {
if (_first == _last) { if (_first == _last) {
return; return;

View File

@ -33,22 +33,22 @@
/* Batch of specializations to obtain the actual simple type */ /* Batch of specializations to obtain the actual simple type */
template <class T> template <typename T>
struct GetSimpleTypeT { struct GetSimpleTypeT {
typedef T type_t; typedef T type_t;
}; };
template <class T> template <typename T>
struct GetSimpleTypeT<T &> { struct GetSimpleTypeT<T &> {
typedef T type_t; typedef T type_t;
}; };
template <class T> template <typename T>
struct GetSimpleTypeT<T const> { struct GetSimpleTypeT<T const> {
typedef T type_t; typedef T type_t;
}; };
template <class T> template <typename T>
struct GetSimpleTypeT<T const &> { struct GetSimpleTypeT<T const &> {
typedef T type_t; typedef T type_t;
}; };

View File

@ -40,7 +40,7 @@
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); }
}; };
@ -51,7 +51,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

View File

@ -45,7 +45,7 @@
#include <climits> #include <climits>
#include <initializer_list> #include <initializer_list>
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) {
@ -55,7 +55,7 @@ public:
} }
}; };
template <class T> template <typename T>
class Vector { class Vector {
friend class VectorWriteProxy<T>; friend class VectorWriteProxy<T>;
@ -108,7 +108,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) {
@ -124,7 +124,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);
@ -291,7 +291,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();
@ -299,7 +299,7 @@ void Vector<T>::reverse() {
} }
} }
template <class T> template <typename T>
void Vector<T>::append_array(const Vector<T> &p_other) { void Vector<T>::append_array(const Vector<T> &p_other) {
const Size ds = p_other.size(); const Size ds = p_other.size();
if (ds == 0) { if (ds == 0) {
@ -312,7 +312,7 @@ void Vector<T>::append_array(const 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);
@ -321,7 +321,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++) {

View File

@ -34,7 +34,7 @@
#include "core/templates/cowdata.h" #include "core/templates/cowdata.h"
#include "core/typedefs.h" #include "core/typedefs.h"
template <class T, class V> template <typename T, typename V>
class VMap { class VMap {
public: public:
struct Pair { struct Pair {

View File

@ -34,7 +34,7 @@
#include "core/templates/vector.h" #include "core/templates/vector.h"
#include "core/typedefs.h" #include "core/typedefs.h"
template <class T> template <typename T>
class VSet { class VSet {
Vector<T> _data; Vector<T> _data;

View File

@ -132,7 +132,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;
@ -186,7 +186,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;
@ -256,7 +256,7 @@ static inline uint64_t BSWAP64(uint64_t x) {
#endif #endif
// 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); }
}; };

View File

@ -47,7 +47,7 @@
// Variant cannot define an implicit cast operator for every Object subclass, so the // Variant cannot define an implicit cast operator for every Object subclass, so the
// casting is done here, to allow binding methods with parameters more specific than Object * // casting is done here, to allow binding methods with parameters more specific than Object *
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>;
@ -59,7 +59,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>;
@ -71,7 +71,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>;
@ -249,7 +249,7 @@ struct VariantObjectClassChecker<const Ref<T> &> {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
template <class T> template <typename T>
struct VariantCasterAndValidate { struct VariantCasterAndValidate {
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE; Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
@ -264,7 +264,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, Callable::CallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE; Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
@ -279,7 +279,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, Callable::CallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE; Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
@ -296,7 +296,7 @@ struct VariantCasterAndValidate<const T &> {
#endif // DEBUG_METHODS_ENABLED #endif // DEBUG_METHODS_ENABLED
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, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -308,7 +308,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, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -320,87 +320,87 @@ 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... 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 void **p_args, IndexSequence<Is...>) { void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const void **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 void **p_args, IndexSequence<Is...>) { void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const void **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 void **p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const void **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 void **p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const void **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, size_t... Is> template <typename T, typename... P, size_t... Is>
void call_with_ptr_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const void **p_args, IndexSequence<Is...>) { void call_with_ptr_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const void **p_args, IndexSequence<Is...>) {
p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...); p_method(p_instance, 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_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret, IndexSequence<Is...>) {
PtrToArg<R>::encode(p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...), r_ret); PtrToArg<R>::encode(p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...), r_ret);
} }
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 void **p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const void **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... P, size_t... Is> template <typename... P, size_t... Is>
void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const void **p_args, IndexSequence<Is...>) { void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const void **p_args, IndexSequence<Is...>) {
p_method(PtrToArg<P>::convert(p_args[Is])...); 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_validated_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) { void call_with_validated_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
(p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...); (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...);
} }
template <class T, class... P, size_t... Is> template <typename T, typename... P, size_t... Is>
void call_with_validated_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, IndexSequence<Is...>) { void call_with_validated_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, IndexSequence<Is...>) {
(p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...); (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(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_validated_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) { void call_with_validated_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(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_validated_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) { void call_with_validated_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(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_validated_variant_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) { void call_with_validated_variant_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...));
} }
template <class T, class... P, size_t... Is> template <typename T, typename... P, size_t... Is>
void call_with_validated_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, IndexSequence<Is...>) { void call_with_validated_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, IndexSequence<Is...>) {
p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...); p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...);
} }
template <class R, class... P, size_t... Is> template <typename R, typename... P, size_t... Is>
void call_with_validated_variant_args_static_method_ret_helper(R (*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) { void call_with_validated_variant_args_static_method_ret_helper(R (*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...));
} }
template <class... P, size_t... Is> template <typename... P, size_t... Is>
void call_with_validated_variant_args_static_method_helper(void (*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) { void call_with_validated_variant_args_static_method_helper(void (*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
p_method((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...); p_method((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...);
} }
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, Callable::CallError &r_error) { void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -418,7 +418,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... P> template <typename T, typename... P>
void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -451,7 +451,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const V
call_with_variant_args_helper(p_instance, p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_helper(p_instance, p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P> template <typename T, typename... P>
void call_with_variant_argsc(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { void call_with_variant_argsc(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -469,7 +469,7 @@ void call_with_variant_argsc(T *p_instance, void (T::*p_method)(P...) const, con
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... P> template <typename T, typename... P>
void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -502,7 +502,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, args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_argsc_helper(p_instance, p_method, 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_dv(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -535,7 +535,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, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_ret_helper(p_instance, p_method, 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_dv(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -568,111 +568,111 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
call_with_variant_args_retc_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_retc_helper(p_instance, p_method, args, r_ret, r_error, 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 void **p_args) { void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const void **p_args) {
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_argsc(T *p_instance, void (T::*p_method)(P...) const, const void **p_args) { void call_with_ptr_argsc(T *p_instance, void (T::*p_method)(P...) const, const void **p_args) {
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_ret(T *p_instance, R (T::*p_method)(P...), const void **p_args, void *r_ret) { void call_with_ptr_args_ret(T *p_instance, R (T::*p_method)(P...), const void **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_retc(T *p_instance, R (T::*p_method)(P...) const, const void **p_args, void *r_ret) { void call_with_ptr_args_retc(T *p_instance, R (T::*p_method)(P...) const, const void **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> template <typename T, typename... P>
void call_with_ptr_args_static(T *p_instance, void (*p_method)(T *, P...), const void **p_args) { void call_with_ptr_args_static(T *p_instance, void (*p_method)(T *, P...), const void **p_args) {
call_with_ptr_args_static_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_static_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_static_retc(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret) { void call_with_ptr_args_static_retc(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret) {
call_with_ptr_args_static_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_static_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class... P> template <typename R, typename... P>
void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const void **p_args, void *r_ret) { void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const void **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)>{});
} }
template <class... P> template <typename... P>
void call_with_ptr_args_static_method(void (*p_method)(P...), const void **p_args) { void call_with_ptr_args_static_method(void (*p_method)(P...), const void **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)>{});
} }
// Validated // Validated
template <class T, class... P> template <typename T, typename... P>
void call_with_validated_variant_args(Variant *base, void (T::*p_method)(P...), const Variant **p_args) { void call_with_validated_variant_args(Variant *base, void (T::*p_method)(P...), const Variant **p_args) {
call_with_validated_variant_args_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <typename T, typename R, typename... P>
void call_with_validated_variant_args_ret(Variant *base, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret) { void call_with_validated_variant_args_ret(Variant *base, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_ret_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_ret_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), 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_validated_variant_args_retc(Variant *base, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret) { void call_with_validated_variant_args_retc(Variant *base, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P> template <typename T, typename... P>
void call_with_validated_variant_args_static(Variant *base, void (*p_method)(T *, P...), const Variant **p_args) { void call_with_validated_variant_args_static(Variant *base, void (*p_method)(T *, P...), const Variant **p_args) {
call_with_validated_variant_args_static_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_static_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <typename T, typename R, typename... P>
void call_with_validated_variant_args_static_retc(Variant *base, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret) { void call_with_validated_variant_args_static_retc(Variant *base, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_static_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class... P> template <typename... P>
void call_with_validated_variant_args_static_method(void (*p_method)(P...), const Variant **p_args) { void call_with_validated_variant_args_static_method(void (*p_method)(P...), const Variant **p_args) {
call_with_validated_variant_args_static_method_helper<P...>(p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_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_validated_variant_args_static_method_ret(R (*p_method)(P...), const Variant **p_args, Variant *r_ret) { void call_with_validated_variant_args_static_method_ret(R (*p_method)(P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_method_ret_helper<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_static_method_ret_helper<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
// Validated Object // Validated Object
template <class T, class... P> template <typename T, typename... P>
void call_with_validated_object_instance_args(T *base, void (T::*p_method)(P...), const Variant **p_args) { void call_with_validated_object_instance_args(T *base, void (T::*p_method)(P...), const Variant **p_args) {
call_with_validated_variant_args_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P> template <typename T, typename... P>
void call_with_validated_object_instance_argsc(T *base, void (T::*p_method)(P...) const, const Variant **p_args) { void call_with_validated_object_instance_argsc(T *base, void (T::*p_method)(P...) const, const Variant **p_args) {
call_with_validated_variant_argsc_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_argsc_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <typename T, typename R, typename... P>
void call_with_validated_object_instance_args_ret(T *base, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret) { void call_with_validated_object_instance_args_ret(T *base, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_ret_helper<T, R, P...>(base, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_ret_helper<T, R, P...>(base, 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_validated_object_instance_args_retc(T *base, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret) { void call_with_validated_object_instance_args_retc(T *base, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_retc_helper<T, R, P...>(base, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_retc_helper<T, R, P...>(base, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P> template <typename T, typename... P>
void call_with_validated_object_instance_args_static(T *base, void (*p_method)(T *, P...), const Variant **p_args) { void call_with_validated_object_instance_args_static(T *base, void (*p_method)(T *, P...), const Variant **p_args) {
call_with_validated_variant_args_static_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_static_helper<T, P...>(base, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <typename T, typename R, typename... P>
void call_with_validated_object_instance_args_static_retc(T *base, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret) { void call_with_validated_object_instance_args_static_retc(T *base, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_retc_helper<T, R, P...>(base, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_static_retc_helper<T, R, P...>(base, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
@ -684,7 +684,7 @@ void call_with_validated_object_instance_args_static_retc(T *base, R (*p_method)
#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, Variant::Type &type) { void call_get_argument_type_helper(int p_arg, int &index, Variant::Type &type) {
if (p_arg == index) { if (p_arg == index) {
type = GetTypeInfo<Q>::VARIANT_TYPE; type = GetTypeInfo<Q>::VARIANT_TYPE;
@ -692,7 +692,7 @@ void call_get_argument_type_helper(int p_arg, int &index, Variant::Type &type) {
index++; index++;
} }
template <class... P> template <typename... P>
Variant::Type call_get_argument_type(int p_arg) { Variant::Type call_get_argument_type(int p_arg) {
Variant::Type type = Variant::NIL; Variant::Type type = Variant::NIL;
int index = 0; int index = 0;
@ -704,7 +704,7 @@ Variant::Type 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();
@ -712,7 +712,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++.
@ -723,7 +723,7 @@ void call_get_argument_type_info(int p_arg, PropertyInfo &info) {
} }
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
template <class Q> template <typename Q>
void call_get_argument_metadata_helper(int p_arg, int &index, GodotTypeInfo::Metadata &md) { void call_get_argument_metadata_helper(int p_arg, int &index, GodotTypeInfo::Metadata &md) {
if (p_arg == index) { if (p_arg == index) {
md = GetTypeInfo<Q>::METADATA; md = GetTypeInfo<Q>::METADATA;
@ -731,7 +731,7 @@ void call_get_argument_metadata_helper(int p_arg, int &index, GodotTypeInfo::Met
index++; index++;
} }
template <class... P> template <typename... P>
GodotTypeInfo::Metadata call_get_argument_metadata(int p_arg) { GodotTypeInfo::Metadata call_get_argument_metadata(int p_arg) {
GodotTypeInfo::Metadata md = GodotTypeInfo::METADATA_NONE; GodotTypeInfo::Metadata md = GodotTypeInfo::METADATA_NONE;
@ -748,7 +748,7 @@ GodotTypeInfo::Metadata call_get_argument_metadata(int p_arg) {
////////////////////// //////////////////////
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, Callable::CallError &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, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -759,7 +759,7 @@ void call_with_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), co
#endif #endif
} }
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, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, Variant &r_ret, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -770,7 +770,7 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar
#endif #endif
} }
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, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -781,7 +781,7 @@ void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_arg
#endif #endif
} }
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, Callable::CallError &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, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -799,7 +799,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, 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, Callable::CallError &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, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -811,7 +811,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 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, Callable::CallError &r_error) { void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -829,7 +829,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, Callable::CallError &r_error) { void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -847,7 +847,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 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, Callable::CallError &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, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -865,7 +865,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 R, class... P, size_t... Is> template <typename T, typename R, typename... P, size_t... Is>
void call_with_variant_args_retc_static_helper(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, Variant &r_ret, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_args_retc_static_helper(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, Variant &r_ret, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -878,7 +878,7 @@ void call_with_variant_args_retc_static_helper(T *p_instance, R (*p_method)(T *,
(void)p_args; (void)p_args;
} }
template <class T, class R, class... P> template <typename T, typename R, typename... P>
void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &default_values, Callable::CallError &r_error) { void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &default_values, Callable::CallError &r_error) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -911,7 +911,7 @@ void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T
call_with_variant_args_retc_static_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_retc_static_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P, size_t... Is> template <typename T, typename... P, size_t... Is>
void call_with_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { void call_with_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
@ -924,7 +924,7 @@ void call_with_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P
(void)p_args; (void)p_args;
} }
template <class T, class... P> template <typename T, typename... P>
void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, int p_argcount, const Vector<Variant> &default_values, Callable::CallError &r_error) { void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, int p_argcount, const Vector<Variant> &default_values, Callable::CallError &r_error) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -957,7 +957,7 @@ void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *
call_with_variant_args_static_helper(p_instance, p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_static_helper(p_instance, p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class... P> template <typename R, typename... P>
void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
@ -990,7 +990,7 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p
call_with_variant_args_static_ret(p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_static_ret(p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class... P> template <typename... P>
void call_with_variant_args_static_dv(void (*p_method)(P...), const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) { void call_with_variant_args_static_dv(void (*p_method)(P...), const Variant **p_args, int p_argcount, Callable::CallError &r_error, const Vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {

View File

@ -35,7 +35,7 @@
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
template <class T> template <typename T>
struct PtrToArg {}; struct PtrToArg {};
#define MAKE_PTRARG(m_type) \ #define MAKE_PTRARG(m_type) \
@ -156,7 +156,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 *> {
_FORCE_INLINE_ static T *convert(const void *p_ptr) { _FORCE_INLINE_ static T *convert(const void *p_ptr) {
if (p_ptr == nullptr) { if (p_ptr == nullptr) {
@ -170,7 +170,7 @@ struct PtrToArg<T *> {
} }
}; };
template <class T> template <typename T>
struct PtrToArg<const T *> { struct PtrToArg<const T *> {
_FORCE_INLINE_ static const T *convert(const void *p_ptr) { _FORCE_INLINE_ static const T *convert(const void *p_ptr) {
if (p_ptr == nullptr) { if (p_ptr == nullptr) {

View File

@ -35,7 +35,7 @@
#include "core/variant/method_ptrcall.h" #include "core/variant/method_ptrcall.h"
#include "core/variant/type_info.h" #include "core/variant/type_info.h"
template <class T> template <typename T>
struct GDExtensionConstPtr { struct GDExtensionConstPtr {
const T *data = nullptr; const T *data = nullptr;
GDExtensionConstPtr(const T *p_assign) { data = p_assign; } GDExtensionConstPtr(const T *p_assign) { data = p_assign; }
@ -44,7 +44,7 @@ struct GDExtensionConstPtr {
operator Variant() const { return uint64_t(data); } operator Variant() const { return uint64_t(data); }
}; };
template <class T> template <typename T>
struct GDExtensionPtr { struct GDExtensionPtr {
T *data = nullptr; T *data = nullptr;
GDExtensionPtr(T *p_assign) { data = p_assign; } GDExtensionPtr(T *p_assign) { data = p_assign; }
@ -95,7 +95,7 @@ struct GDExtensionPtr {
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr<m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \ static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr<m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \
}; };
template <class T> template <typename T>
struct GetTypeInfo<GDExtensionConstPtr<T>> { struct GetTypeInfo<GDExtensionConstPtr<T>> {
static const Variant::Type VARIANT_TYPE = Variant::NIL; static const Variant::Type VARIANT_TYPE = Variant::NIL;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
@ -104,7 +104,7 @@ struct GetTypeInfo<GDExtensionConstPtr<T>> {
} }
}; };
template <class T> template <typename T>
struct GetTypeInfo<GDExtensionPtr<T>> { struct GetTypeInfo<GDExtensionPtr<T>> {
static const Variant::Type VARIANT_TYPE = Variant::NIL; static const Variant::Type VARIANT_TYPE = Variant::NIL;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
@ -113,7 +113,7 @@ struct GetTypeInfo<GDExtensionPtr<T>> {
} }
}; };
template <class T> template <typename T>
struct PtrToArg<GDExtensionConstPtr<T>> { struct PtrToArg<GDExtensionConstPtr<T>> {
_FORCE_INLINE_ static GDExtensionConstPtr<T> convert(const void *p_ptr) { _FORCE_INLINE_ static GDExtensionConstPtr<T> convert(const void *p_ptr) {
return GDExtensionConstPtr<T>(reinterpret_cast<const T *>(p_ptr)); return GDExtensionConstPtr<T>(reinterpret_cast<const T *>(p_ptr));
@ -123,7 +123,7 @@ struct PtrToArg<GDExtensionConstPtr<T>> {
*((const T **)p_ptr) = p_val.data; *((const T **)p_ptr) = p_val.data;
} }
}; };
template <class T> template <typename T>
struct PtrToArg<GDExtensionPtr<T>> { struct PtrToArg<GDExtensionPtr<T>> {
_FORCE_INLINE_ static GDExtensionPtr<T> convert(const void *p_ptr) { _FORCE_INLINE_ static GDExtensionPtr<T> convert(const void *p_ptr) {
return GDExtensionPtr<T>(reinterpret_cast<const T *>(p_ptr)); return GDExtensionPtr<T>(reinterpret_cast<const T *>(p_ptr));

View File

@ -80,7 +80,7 @@ enum Metadata {
// If 'T' is a class that inherits 'Object', make sure it can see the actual class declaration // If 'T' is a class that inherits 'Object', make sure it can see the actual class declaration
// 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) \
@ -278,7 +278,7 @@ inline StringName __constant_get_enum_name(T param, const String &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;

View File

@ -38,7 +38,7 @@
#include "core/variant/type_info.h" #include "core/variant/type_info.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
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) {
@ -56,12 +56,12 @@ public:
} }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<TypedArray<T>> { struct VariantInternalAccessor<TypedArray<T>> {
static _FORCE_INLINE_ TypedArray<T> get(const Variant *v) { return *VariantInternal::get_array(v); } static _FORCE_INLINE_ TypedArray<T> get(const Variant *v) { return *VariantInternal::get_array(v); }
static _FORCE_INLINE_ void set(Variant *v, const TypedArray<T> &p_array) { *VariantInternal::get_array(v) = p_array; } static _FORCE_INLINE_ void set(Variant *v, const TypedArray<T> &p_array) { *VariantInternal::get_array(v) = p_array; }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<const TypedArray<T> &> { struct VariantInternalAccessor<const TypedArray<T> &> {
static _FORCE_INLINE_ TypedArray<T> get(const Variant *v) { return *VariantInternal::get_array(v); } static _FORCE_INLINE_ TypedArray<T> get(const Variant *v) { return *VariantInternal::get_array(v); }
static _FORCE_INLINE_ void set(Variant *v, const TypedArray<T> &p_array) { *VariantInternal::get_array(v) = p_array; } static _FORCE_INLINE_ void set(Variant *v, const TypedArray<T> &p_array) { *VariantInternal::get_array(v) = p_array; }
@ -136,7 +136,7 @@ MAKE_TYPED_ARRAY(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY) MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
MAKE_TYPED_ARRAY(IPAddress, Variant::STRING) MAKE_TYPED_ARRAY(IPAddress, Variant::STRING)
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));
@ -147,7 +147,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> convert(const void *p_ptr) { _FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
@ -155,7 +155,7 @@ struct PtrToArg<const TypedArray<T> &> {
} }
}; };
template <class T> template <typename T>
struct GetTypeInfo<TypedArray<T>> { struct GetTypeInfo<TypedArray<T>> {
static const Variant::Type VARIANT_TYPE = Variant::ARRAY; static const Variant::Type VARIANT_TYPE = Variant::ARRAY;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
@ -164,7 +164,7 @@ struct GetTypeInfo<TypedArray<T>> {
} }
}; };
template <class T> template <typename T>
struct GetTypeInfo<const TypedArray<T> &> { struct GetTypeInfo<const TypedArray<T> &> {
static const Variant::Type VARIANT_TYPE = Variant::ARRAY; static const Variant::Type VARIANT_TYPE = Variant::ARRAY;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;

View File

@ -1697,7 +1697,7 @@ String stringify_variant_clean(const Variant &p_variant, int recursion_count) {
return s; return s;
} }
template <class T> template <typename T>
String stringify_vector(const T &vec, int recursion_count) { String stringify_vector(const T &vec, int recursion_count) {
String str("["); String str("[");
for (int i = 0; i < vec.size(); i++) { for (int i = 0; i < vec.size(); i++) {
@ -2188,7 +2188,7 @@ Variant::operator Signal() const {
} }
} }
template <class DA, class SA> template <typename DA, typename SA>
inline DA _convert_array(const SA &p_array) { inline DA _convert_array(const SA &p_array) {
DA da; DA da;
da.resize(p_array.size()); da.resize(p_array.size());
@ -2200,7 +2200,7 @@ inline DA _convert_array(const SA &p_array) {
return da; return da;
} }
template <class DA> template <typename DA>
inline DA _convert_array_from_variant(const Variant &p_variant) { inline DA _convert_array_from_variant(const Variant &p_variant) {
switch (p_variant.get_type()) { switch (p_variant.get_type()) {
case Variant::ARRAY: { case Variant::ARRAY: {

View File

@ -204,7 +204,7 @@ private:
_FORCE_INLINE_ virtual ~PackedArrayRefBase() {} //needs virtual destructor, but make inline _FORCE_INLINE_ virtual ~PackedArrayRefBase() {} //needs virtual destructor, but make inline
}; };
template <class T> template <typename T>
struct PackedArrayRef : public PackedArrayRefBase { struct PackedArrayRef : public PackedArrayRefBase {
Vector<T> array; Vector<T> array;
static _FORCE_INLINE_ PackedArrayRef<T> *create() { static _FORCE_INLINE_ PackedArrayRef<T> *create() {

View File

@ -43,329 +43,329 @@
typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args); typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args);
typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args); typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args);
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void vc_static_method_call(R (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_static_method_call(R (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_static_ret_dv(method, p_args, p_argcount, r_ret, r_error, p_defvals); call_with_variant_args_static_ret_dv(method, p_args, p_argcount, r_ret, r_error, p_defvals);
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void vc_static_method_call(void (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_static_method_call(void (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_static_dv(method, p_args, p_argcount, r_error, p_defvals); call_with_variant_args_static_dv(method, p_args, p_argcount, r_error, p_defvals);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_ret_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals); call_with_variant_args_ret_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_retc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals); call_with_variant_args_retc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
VariantInternal::clear(&r_ret); VariantInternal::clear(&r_ret);
call_with_variant_args_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals); call_with_variant_args_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
VariantInternal::clear(&r_ret); VariantInternal::clear(&r_ret);
call_with_variant_argsc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals); call_with_variant_argsc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_variant_args_ret_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals); call_with_variant_args_ret_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals);
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_variant_args_retc_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals); call_with_variant_args_retc_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals);
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_variant_args_dv(&converted, method, p_args, p_argcount, r_error, p_defvals); call_with_variant_args_dv(&converted, method, p_args, p_argcount, r_error, p_defvals);
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_variant_argsc_dv(&converted, method, p_args, p_argcount, r_error, p_defvals); call_with_variant_argsc_dv(&converted, method, p_args, p_argcount, r_error, p_defvals);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, p_defvals, r_error); call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, p_defvals, r_error);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_method_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { static _FORCE_INLINE_ void vc_method_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
call_with_variant_args_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, p_defvals, r_error); call_with_variant_args_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, p_defvals, r_error);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_ret(base, method, p_args, r_ret); call_with_validated_variant_args_ret(base, method, p_args, r_ret);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_retc(base, method, p_args, r_ret); call_with_validated_variant_args_retc(base, method, p_args, r_ret);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args(base, method, p_args); call_with_validated_variant_args(base, method, p_args);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_argsc(base, method, p_args); call_with_validated_variant_argsc(base, method, p_args);
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_validated_variant_args_ret_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_ret_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_validated_variant_args_retc_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_retc_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_validated_variant_args_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_args_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base))); T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
call_with_validated_variant_argsc_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_validated_variant_argsc_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_retc(base, method, p_args, r_ret); call_with_validated_variant_args_static_retc(base, method, p_args, r_ret);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_validated_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static(base, method, p_args); call_with_validated_variant_args_static(base, method, p_args);
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void vc_validated_static_call(R (*method)(P...), const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_static_call(R (*method)(P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_method_ret(method, p_args, r_ret); call_with_validated_variant_args_static_method_ret(method, p_args, r_ret);
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void vc_validated_static_call(void (*method)(P...), const Variant **p_args, Variant *r_ret) { static _FORCE_INLINE_ void vc_validated_static_call(void (*method)(P...), const Variant **p_args, Variant *r_ret) {
call_with_validated_variant_args_static_method(method, p_args); call_with_validated_variant_args_static_method(method, p_args);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_args_ret(reinterpret_cast<T *>(p_base), method, p_args, r_ret); call_with_ptr_args_ret(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_args_retc(reinterpret_cast<T *>(p_base), method, p_args, r_ret); call_with_ptr_args_retc(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_args(reinterpret_cast<T *>(p_base), method, p_args); call_with_ptr_args(reinterpret_cast<T *>(p_base), method, p_args);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_argsc(reinterpret_cast<T *>(p_base), method, p_args); call_with_ptr_argsc(reinterpret_cast<T *>(p_base), method, p_args);
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
T converted(*reinterpret_cast<From *>(p_base)); T converted(*reinterpret_cast<From *>(p_base));
call_with_ptr_args_ret(&converted, method, p_args, r_ret); call_with_ptr_args_ret(&converted, method, p_args, r_ret);
} }
template <class From, class R, class T, class... P> template <typename From, typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
T converted(*reinterpret_cast<From *>(p_base)); T converted(*reinterpret_cast<From *>(p_base));
call_with_ptr_args_retc(&converted, method, p_args, r_ret); call_with_ptr_args_retc(&converted, method, p_args, r_ret);
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
T converted(*reinterpret_cast<From *>(p_base)); T converted(*reinterpret_cast<From *>(p_base));
call_with_ptr_args(&converted, method, p_args); call_with_ptr_args(&converted, method, p_args);
} }
template <class From, class T, class... P> template <typename From, typename T, typename... P>
static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
T converted(*reinterpret_cast<From *>(p_base)); T converted(*reinterpret_cast<From *>(p_base));
call_with_ptr_argsc(&converted, method, p_args); call_with_ptr_argsc(&converted, method, p_args);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) { static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...) const) { static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...) const) {
return sizeof...(P); return sizeof...(P);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...)) { static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...) const) { static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...) const) {
return sizeof...(P); return sizeof...(P);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count(R (*method)(T *, P...)) { static _FORCE_INLINE_ int vc_get_argument_count(R (*method)(T *, P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ int vc_get_argument_count_static(R (*method)(P...)) { static _FORCE_INLINE_ int vc_get_argument_count_static(R (*method)(P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...), int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...) const, int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...) const, int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...), int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...) const, int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...) const, int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (*method)(T *, P...), int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (*method)(T *, P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_argument_type_static(R (*method)(P...), int p_arg) { static _FORCE_INLINE_ Variant::Type vc_get_argument_type_static(R (*method)(P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...)) {
return GetTypeInfo<R>::VARIANT_TYPE; return GetTypeInfo<R>::VARIANT_TYPE;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...) const) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...) const) {
return GetTypeInfo<R>::VARIANT_TYPE; return GetTypeInfo<R>::VARIANT_TYPE;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...)) {
return Variant::NIL; return Variant::NIL;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...) const) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...) const) {
return Variant::NIL; return Variant::NIL;
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (*method)(P...)) {
return GetTypeInfo<R>::VARIANT_TYPE; return GetTypeInfo<R>::VARIANT_TYPE;
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (*method)(P...)) {
return Variant::NIL; return Variant::NIL;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...)) { static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...)) {
return true; return true;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...) const) { static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...) const) {
return true; return true;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...)) { static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...)) {
return false; return false;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...) const) { static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...) const) {
return false; return false;
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ bool vc_has_return_type_static(void (*method)(P...)) { static _FORCE_INLINE_ bool vc_has_return_type_static(void (*method)(P...)) {
return false; return false;
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ bool vc_has_return_type_static(R (*method)(P...)) { static _FORCE_INLINE_ bool vc_has_return_type_static(R (*method)(P...)) {
return true; return true;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...)) { static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...)) {
return false; return false;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...) const) { static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...) const) {
return true; return true;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...)) { static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...)) {
return false; return false;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...) const) { static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...) const) {
return true; return true;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...)) {
return GetTypeInfo<T>::VARIANT_TYPE; return GetTypeInfo<T>::VARIANT_TYPE;
} }
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...) const) { static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...) const) {
return GetTypeInfo<T>::VARIANT_TYPE; return GetTypeInfo<T>::VARIANT_TYPE;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...)) { static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...)) {
return GetTypeInfo<T>::VARIANT_TYPE; return GetTypeInfo<T>::VARIANT_TYPE;
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) const) { static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) const) {
return GetTypeInfo<T>::VARIANT_TYPE; return GetTypeInfo<T>::VARIANT_TYPE;
} }
@ -450,12 +450,12 @@ static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) con
} \ } \
}; };
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void vc_static_ptrcall(R (*method)(P...), const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_static_ptrcall(R (*method)(P...), const void **p_args, void *r_ret) {
call_with_ptr_args_static_method_ret<R, P...>(method, p_args, r_ret); call_with_ptr_args_static_method_ret<R, P...>(method, p_args, r_ret);
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void **p_args, void *r_ret) {
call_with_ptr_args_static_method<P...>(method, p_args); call_with_ptr_args_static_method<P...>(method, p_args);
} }
@ -500,12 +500,12 @@ static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void **
} \ } \
}; };
template <class R, class T, class... P> template <typename R, typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_args_static_retc<T, R, P...>(reinterpret_cast<T *>(p_base), method, p_args, r_ret); call_with_ptr_args_static_retc<T, R, P...>(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
} }
template <class T, class... P> template <typename T, typename... P>
static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) { static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) {
call_with_ptr_args_static<T, P...>(reinterpret_cast<T *>(p_base), method, p_args); call_with_ptr_args_static<T, P...>(reinterpret_cast<T *>(p_base), method, p_args);
} }
@ -1160,7 +1160,7 @@ typedef OAHashMap<StringName, VariantBuiltInMethodInfo> BuiltinMethodMap;
static BuiltinMethodMap *builtin_method_info; static BuiltinMethodMap *builtin_method_info;
static List<StringName> *builtin_method_names; static List<StringName> *builtin_method_names;
template <class T> template <typename T>
static void register_builtin_method(const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) { static void register_builtin_method(const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) {
StringName name = T::get_name(); StringName name = T::get_name();

View File

@ -41,7 +41,7 @@ struct VariantConstructData {
static LocalVector<VariantConstructData> construct_data[Variant::VARIANT_MAX]; static LocalVector<VariantConstructData> construct_data[Variant::VARIANT_MAX];
template <class T> template <typename T>
static void add_constructor(const Vector<String> &arg_names) { static void add_constructor(const Vector<String> &arg_names) {
ERR_FAIL_COND_MSG(arg_names.size() != T::get_argument_count(), "Argument names size mismatch for " + Variant::get_type_name(T::get_base_type()) + "."); ERR_FAIL_COND_MSG(arg_names.size() != T::get_argument_count(), "Argument names size mismatch for " + Variant::get_type_name(T::get_base_type()) + ".");

View File

@ -42,7 +42,7 @@
#include "core/templates/local_vector.h" #include "core/templates/local_vector.h"
#include "core/templates/oa_hash_map.h" #include "core/templates/oa_hash_map.h"
template <class T> template <typename T>
struct PtrConstruct {}; struct PtrConstruct {};
#define MAKE_PTRCONSTRUCT(m_type) \ #define MAKE_PTRCONSTRUCT(m_type) \
@ -99,7 +99,7 @@ MAKE_PTRCONSTRUCT(PackedVector3Array);
MAKE_PTRCONSTRUCT(PackedColorArray); MAKE_PTRCONSTRUCT(PackedColorArray);
MAKE_PTRCONSTRUCT(Variant); MAKE_PTRCONSTRUCT(Variant);
template <class T, class... P> template <typename T, typename... P>
class VariantConstructor { class VariantConstructor {
template <size_t... Is> template <size_t... Is>
static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
@ -222,7 +222,7 @@ public:
} }
}; };
template <class T> template <typename T>
class VariantConstructorFromString { class VariantConstructorFromString {
public: public:
static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
@ -470,7 +470,7 @@ public:
} }
}; };
template <class T> template <typename T>
class VariantConstructorToArray { class VariantConstructorToArray {
public: public:
static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
@ -529,7 +529,7 @@ public:
} }
}; };
template <class T> template <typename T>
class VariantConstructorFromArray { class VariantConstructorFromArray {
public: public:
static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
@ -622,7 +622,7 @@ public:
} }
}; };
template <class T> template <typename T>
class VariantConstructNoArgs { class VariantConstructNoArgs {
public: public:
static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {

View File

@ -34,7 +34,7 @@
static Variant::PTRDestructor destruct_pointers[Variant::VARIANT_MAX] = { nullptr }; static Variant::PTRDestructor destruct_pointers[Variant::VARIANT_MAX] = { nullptr };
template <class T> template <typename T>
static void add_destructor() { static void add_destructor() {
destruct_pointers[T::get_base_type()] = T::ptr_destruct; destruct_pointers[T::get_base_type()] = T::ptr_destruct;
} }

View File

@ -35,7 +35,7 @@
#include "core/object/class_db.h" #include "core/object/class_db.h"
template <class T> template <typename T>
struct VariantDestruct {}; struct VariantDestruct {};
#define MAKE_PTRDESTRUCT(m_type) \ #define MAKE_PTRDESTRUCT(m_type) \

View File

@ -211,7 +211,7 @@ public:
_FORCE_INLINE_ static const ObjectID get_object_id(const Variant *v) { return v->_get_obj().id; } _FORCE_INLINE_ static const ObjectID get_object_id(const Variant *v) { return v->_get_obj().id; }
template <class T> template <typename T>
_FORCE_INLINE_ static void init_generic(Variant *v) { _FORCE_INLINE_ static void init_generic(Variant *v) {
v->type = GetTypeInfo<T>::VARIANT_TYPE; v->type = GetTypeInfo<T>::VARIANT_TYPE;
} }
@ -510,7 +510,7 @@ public:
} }
}; };
template <class T> template <typename T>
struct VariantGetInternalPtr { struct VariantGetInternalPtr {
}; };
@ -797,7 +797,7 @@ struct VariantGetInternalPtr<PackedColorArray> {
static const PackedColorArray *get_ptr(const Variant *v) { return VariantInternal::get_color_array(v); } static const PackedColorArray *get_ptr(const Variant *v) { return VariantInternal::get_color_array(v); }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor { struct VariantInternalAccessor {
}; };
@ -830,13 +830,13 @@ struct VariantInternalAccessor<ObjectID> {
static _FORCE_INLINE_ void set(Variant *v, ObjectID p_value) { *VariantInternal::get_int(v) = p_value; } static _FORCE_INLINE_ void set(Variant *v, ObjectID p_value) { *VariantInternal::get_int(v) = p_value; }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<T *> { struct VariantInternalAccessor<T *> {
static _FORCE_INLINE_ T *get(const Variant *v) { return const_cast<T *>(static_cast<const T *>(*VariantInternal::get_object(v))); } static _FORCE_INLINE_ T *get(const Variant *v) { return const_cast<T *>(static_cast<const T *>(*VariantInternal::get_object(v))); }
static _FORCE_INLINE_ void set(Variant *v, const T *p_value) { VariantInternal::object_assign(v, p_value); } static _FORCE_INLINE_ void set(Variant *v, const T *p_value) { VariantInternal::object_assign(v, p_value); }
}; };
template <class T> template <typename T>
struct VariantInternalAccessor<const T *> { struct VariantInternalAccessor<const T *> {
static _FORCE_INLINE_ const T *get(const Variant *v) { return static_cast<const T *>(*VariantInternal::get_object(v)); } static _FORCE_INLINE_ const T *get(const Variant *v) { return static_cast<const T *>(*VariantInternal::get_object(v)); }
static _FORCE_INLINE_ void set(Variant *v, const T *p_value) { VariantInternal::object_assign(v, p_value); } static _FORCE_INLINE_ void set(Variant *v, const T *p_value) { VariantInternal::object_assign(v, p_value); }
@ -1091,7 +1091,7 @@ struct VariantInternalAccessor<Vector<Variant>> {
} }
}; };
template <class T> template <typename T>
struct VariantInitializer { struct VariantInitializer {
}; };
@ -1301,7 +1301,7 @@ struct VariantInitializer<Object *> {
static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_object(v); } static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_object(v); }
}; };
template <class T> template <typename T>
struct VariantDefaultInitializer { struct VariantDefaultInitializer {
}; };
@ -1490,7 +1490,7 @@ struct VariantDefaultInitializer<PackedColorArray> {
static _FORCE_INLINE_ void init(Variant *v) { *VariantInternal::get_color_array(v) = PackedColorArray(); } static _FORCE_INLINE_ void init(Variant *v) { *VariantInternal::get_color_array(v) = PackedColorArray(); }
}; };
template <class T> template <typename T>
struct VariantTypeChanger { struct VariantTypeChanger {
static _FORCE_INLINE_ void change(Variant *v) { static _FORCE_INLINE_ void change(Variant *v) {
if (v->get_type() != GetTypeInfo<T>::VARIANT_TYPE || GetTypeInfo<T>::VARIANT_TYPE >= Variant::PACKED_BYTE_ARRAY) { //second condition removed by optimizer if (v->get_type() != GetTypeInfo<T>::VARIANT_TYPE || GetTypeInfo<T>::VARIANT_TYPE >= Variant::PACKED_BYTE_ARRAY) { //second condition removed by optimizer
@ -1508,7 +1508,7 @@ struct VariantTypeChanger {
} }
}; };
template <class T> template <typename T>
struct VariantTypeAdjust { struct VariantTypeAdjust {
_FORCE_INLINE_ static void adjust(Variant *r_ret) { _FORCE_INLINE_ static void adjust(Variant *r_ret) {
VariantTypeChanger<typename GetSimpleTypeT<T>::type_t>::change(r_ret); VariantTypeChanger<typename GetSimpleTypeT<T>::type_t>::change(r_ret);
@ -1532,7 +1532,7 @@ struct VariantTypeAdjust<Object *> {
// GDExtension helpers. // GDExtension helpers.
template <class T> template <typename T>
struct VariantTypeConstructor { struct VariantTypeConstructor {
_FORCE_INLINE_ static void variant_from_type(void *r_variant, void *p_value) { _FORCE_INLINE_ static void variant_from_type(void *r_variant, void *p_value) {
// r_variant is provided by caller as uninitialized memory // r_variant is provided by caller as uninitialized memory

View File

@ -37,7 +37,7 @@ static VariantEvaluatorFunction operator_evaluator_table[Variant::OP_MAX][Varian
static Variant::ValidatedOperatorEvaluator validated_operator_evaluator_table[Variant::OP_MAX][Variant::VARIANT_MAX][Variant::VARIANT_MAX]; static Variant::ValidatedOperatorEvaluator validated_operator_evaluator_table[Variant::OP_MAX][Variant::VARIANT_MAX][Variant::VARIANT_MAX];
static Variant::PTROperatorEvaluator ptr_operator_evaluator_table[Variant::OP_MAX][Variant::VARIANT_MAX][Variant::VARIANT_MAX]; static Variant::PTROperatorEvaluator ptr_operator_evaluator_table[Variant::OP_MAX][Variant::VARIANT_MAX][Variant::VARIANT_MAX];
template <class T> template <typename T>
void register_op(Variant::Operator p_op, Variant::Type p_type_a, Variant::Type p_type_b) { void register_op(Variant::Operator p_op, Variant::Type p_type_a, Variant::Type p_type_b) {
operator_return_type_table[p_op][p_type_a][p_type_b] = T::get_return_type(); operator_return_type_table[p_op][p_type_a][p_type_b] = T::get_return_type();
operator_evaluator_table[p_op][p_type_a][p_type_b] = T::evaluate; operator_evaluator_table[p_op][p_type_a][p_type_b] = T::evaluate;

View File

@ -37,7 +37,7 @@
#include "core/debugger/engine_debugger.h" #include "core/debugger/engine_debugger.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorAdd { class OperatorEvaluatorAdd {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -55,7 +55,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorSub { class OperatorEvaluatorSub {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -73,7 +73,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorMul { class OperatorEvaluatorMul {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -91,7 +91,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorPow { class OperatorEvaluatorPow {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -109,7 +109,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorXForm { class OperatorEvaluatorXForm {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -127,7 +127,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorXFormInv { class OperatorEvaluatorXFormInv {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -145,7 +145,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorDiv { class OperatorEvaluatorDiv {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -163,7 +163,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorDivNZ { class OperatorEvaluatorDivNZ {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -258,7 +258,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<Vector4i>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<Vector4i>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorMod { class OperatorEvaluatorMod {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -276,7 +276,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorModNZ { class OperatorEvaluatorModNZ {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -371,7 +371,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<Vector4i>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<Vector4i>::VARIANT_TYPE; }
}; };
template <class R, class A> template <typename R, typename A>
class OperatorEvaluatorNeg { class OperatorEvaluatorNeg {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -388,7 +388,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A> template <typename R, typename A>
class OperatorEvaluatorPos { class OperatorEvaluatorPos {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -405,7 +405,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorShiftLeft { class OperatorEvaluatorShiftLeft {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -431,7 +431,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorShiftRight { class OperatorEvaluatorShiftRight {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -457,7 +457,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorBitOr { class OperatorEvaluatorBitOr {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -475,7 +475,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorBitAnd { class OperatorEvaluatorBitAnd {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -493,7 +493,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A, class B> template <typename R, typename A, typename B>
class OperatorEvaluatorBitXor { class OperatorEvaluatorBitXor {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -511,7 +511,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class R, class A> template <typename R, typename A>
class OperatorEvaluatorBitNeg { class OperatorEvaluatorBitNeg {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -528,7 +528,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorEqual { class OperatorEvaluatorEqual {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -599,7 +599,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorNotEqual { class OperatorEvaluatorNotEqual {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -670,7 +670,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorLess { class OperatorEvaluatorLess {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -688,7 +688,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorLessEqual { class OperatorEvaluatorLessEqual {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -706,7 +706,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorGreater { class OperatorEvaluatorGreater {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -724,7 +724,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorGreaterEqual { class OperatorEvaluatorGreaterEqual {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -742,7 +742,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorAnd { class OperatorEvaluatorAnd {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -760,7 +760,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorOr { class OperatorEvaluatorOr {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -779,7 +779,7 @@ public:
}; };
#define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b))) #define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b)))
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorXor { class OperatorEvaluatorXor {
public: public:
_FORCE_INLINE_ static bool xor_op(const A &a, const B &b) { _FORCE_INLINE_ static bool xor_op(const A &a, const B &b) {
@ -800,7 +800,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A> template <typename A>
class OperatorEvaluatorNot { class OperatorEvaluatorNot {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -857,7 +857,7 @@ public:
static Variant::Type get_return_type() { return Variant::ARRAY; } static Variant::Type get_return_type() { return Variant::ARRAY; }
}; };
template <class T> template <typename T>
class OperatorEvaluatorAppendArray { class OperatorEvaluatorAppendArray {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -880,7 +880,7 @@ public:
static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; } static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; }
}; };
template <class Left, class Right> template <typename Left, typename Right>
class OperatorEvaluatorStringConcat { class OperatorEvaluatorStringConcat {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -902,10 +902,10 @@ public:
static Variant::Type get_return_type() { return Variant::STRING; } static Variant::Type get_return_type() { return Variant::STRING; }
}; };
template <class S, class T> template <typename S, typename T>
class OperatorEvaluatorStringFormat; class OperatorEvaluatorStringFormat;
template <class S> template <typename S>
class OperatorEvaluatorStringFormat<S, void> { class OperatorEvaluatorStringFormat<S, void> {
public: public:
_FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) { _FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) {
@ -933,7 +933,7 @@ public:
static Variant::Type get_return_type() { return Variant::STRING; } static Variant::Type get_return_type() { return Variant::STRING; }
}; };
template <class S> template <typename S>
class OperatorEvaluatorStringFormat<S, Array> { class OperatorEvaluatorStringFormat<S, Array> {
public: public:
_FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) { _FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) {
@ -958,7 +958,7 @@ public:
static Variant::Type get_return_type() { return Variant::STRING; } static Variant::Type get_return_type() { return Variant::STRING; }
}; };
template <class S> template <typename S>
class OperatorEvaluatorStringFormat<S, Object> { class OperatorEvaluatorStringFormat<S, Object> {
public: public:
_FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) { _FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) {
@ -986,7 +986,7 @@ public:
static Variant::Type get_return_type() { return Variant::STRING; } static Variant::Type get_return_type() { return Variant::STRING; }
}; };
template <class S, class T> template <typename S, typename T>
class OperatorEvaluatorStringFormat { class OperatorEvaluatorStringFormat {
public: public:
_FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) { _FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) {
@ -1317,10 +1317,10 @@ public:
//// ////
template <class Left, class Right> template <typename Left, typename Right>
class OperatorEvaluatorInStringFind; class OperatorEvaluatorInStringFind;
template <class Left> template <typename Left>
class OperatorEvaluatorInStringFind<Left, String> { class OperatorEvaluatorInStringFind<Left, String> {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -1341,7 +1341,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class Left> template <typename Left>
class OperatorEvaluatorInStringFind<Left, StringName> { class OperatorEvaluatorInStringFind<Left, StringName> {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -1362,7 +1362,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A, class B> template <typename A, typename B>
class OperatorEvaluatorInArrayFind { class OperatorEvaluatorInArrayFind {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
@ -1417,7 +1417,7 @@ public:
static Variant::Type get_return_type() { return Variant::BOOL; } static Variant::Type get_return_type() { return Variant::BOOL; }
}; };
template <class A> template <typename A>
class OperatorEvaluatorInDictionaryHas { class OperatorEvaluatorInDictionaryHas {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {

View File

@ -546,7 +546,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
} }
} }
template <class T> template <typename T>
Error VariantParser::_parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str) { Error VariantParser::_parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str) {
Token token; Token token;
get_token(p_stream, token, line, r_err_str); get_token(p_stream, token, line, r_err_str);

View File

@ -139,7 +139,7 @@ public:
private: private:
static const char *tk_name[TK_MAX]; static const char *tk_name[TK_MAX];
template <class T> template <typename T>
static Error _parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str); static Error _parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str);
static Error _parse_enginecfg(Stream *p_stream, Vector<String> &strings, int &line, String &r_err_str); static Error _parse_enginecfg(Stream *p_stream, Vector<String> &strings, int &line, String &r_err_str);
static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr);

View File

@ -45,7 +45,7 @@ struct VariantSetterGetterInfo {
static LocalVector<VariantSetterGetterInfo> variant_setters_getters[Variant::VARIANT_MAX]; static LocalVector<VariantSetterGetterInfo> variant_setters_getters[Variant::VARIANT_MAX];
static LocalVector<StringName> variant_setters_getters_names[Variant::VARIANT_MAX]; //one next to another to make it cache friendly static LocalVector<StringName> variant_setters_getters_names[Variant::VARIANT_MAX]; //one next to another to make it cache friendly
template <class T> template <typename T>
static void register_member(Variant::Type p_type, const StringName &p_member) { static void register_member(Variant::Type p_type, const StringName &p_member) {
VariantSetterGetterInfo sgi; VariantSetterGetterInfo sgi;
sgi.setter = T::set; sgi.setter = T::set;
@ -873,7 +873,7 @@ struct VariantIndexedSetterGetterInfo {
static VariantIndexedSetterGetterInfo variant_indexed_setters_getters[Variant::VARIANT_MAX]; static VariantIndexedSetterGetterInfo variant_indexed_setters_getters[Variant::VARIANT_MAX];
template <class T> template <typename T>
static void register_indexed_member(Variant::Type p_type) { static void register_indexed_member(Variant::Type p_type) {
VariantIndexedSetterGetterInfo &sgi = variant_indexed_setters_getters[p_type]; VariantIndexedSetterGetterInfo &sgi = variant_indexed_setters_getters[p_type];
@ -1094,7 +1094,7 @@ struct VariantKeyedSetterGetterInfo {
static VariantKeyedSetterGetterInfo variant_keyed_setters_getters[Variant::VARIANT_MAX]; static VariantKeyedSetterGetterInfo variant_keyed_setters_getters[Variant::VARIANT_MAX];
template <class T> template <typename T>
static void register_keyed_member(Variant::Type p_type) { static void register_keyed_member(Variant::Type p_type) {
VariantKeyedSetterGetterInfo &sgi = variant_keyed_setters_getters[p_type]; VariantKeyedSetterGetterInfo &sgi = variant_keyed_setters_getters[p_type];

View File

@ -1235,7 +1235,7 @@ bool VariantUtilityFunctions::is_same(const Variant &p_a, const Variant &p_b) {
#define VCALL p_func(VariantCaster<P>::cast(*p_args[Is])...) #define VCALL p_func(VariantCaster<P>::cast(*p_args[Is])...)
#endif #endif
template <class R, class... P, size_t... Is> template <typename R, typename... P, size_t... Is>
static _FORCE_INLINE_ void call_helperpr(R (*p_func)(P...), Variant *ret, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { static _FORCE_INLINE_ void call_helperpr(R (*p_func)(P...), Variant *ret, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
VCALLR; VCALLR;
@ -1243,51 +1243,51 @@ static _FORCE_INLINE_ void call_helperpr(R (*p_func)(P...), Variant *ret, const
(void)r_error; (void)r_error;
} }
template <class R, class... P, size_t... Is> template <typename R, typename... P, size_t... Is>
static _FORCE_INLINE_ void validated_call_helperpr(R (*p_func)(P...), Variant *ret, const Variant **p_args, IndexSequence<Is...>) { static _FORCE_INLINE_ void validated_call_helperpr(R (*p_func)(P...), Variant *ret, const Variant **p_args, IndexSequence<Is...>) {
*ret = p_func(VariantCaster<P>::cast(*p_args[Is])...); *ret = p_func(VariantCaster<P>::cast(*p_args[Is])...);
(void)p_args; (void)p_args;
} }
template <class R, class... P, size_t... Is> template <typename R, typename... P, size_t... Is>
static _FORCE_INLINE_ void ptr_call_helperpr(R (*p_func)(P...), void *ret, const void **p_args, IndexSequence<Is...>) { static _FORCE_INLINE_ void ptr_call_helperpr(R (*p_func)(P...), void *ret, const void **p_args, IndexSequence<Is...>) {
PtrToArg<R>::encode(p_func(PtrToArg<P>::convert(p_args[Is])...), ret); PtrToArg<R>::encode(p_func(PtrToArg<P>::convert(p_args[Is])...), ret);
(void)p_args; (void)p_args;
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void call_helperr(R (*p_func)(P...), Variant *ret, const Variant **p_args, Callable::CallError &r_error) { static _FORCE_INLINE_ void call_helperr(R (*p_func)(P...), Variant *ret, const Variant **p_args, Callable::CallError &r_error) {
call_helperpr(p_func, ret, p_args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_helperpr(p_func, ret, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void validated_call_helperr(R (*p_func)(P...), Variant *ret, const Variant **p_args) { static _FORCE_INLINE_ void validated_call_helperr(R (*p_func)(P...), Variant *ret, const Variant **p_args) {
validated_call_helperpr(p_func, ret, p_args, BuildIndexSequence<sizeof...(P)>{}); validated_call_helperpr(p_func, ret, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ void ptr_call_helperr(R (*p_func)(P...), void *ret, const void **p_args) { static _FORCE_INLINE_ void ptr_call_helperr(R (*p_func)(P...), void *ret, const void **p_args) {
ptr_call_helperpr(p_func, ret, p_args, BuildIndexSequence<sizeof...(P)>{}); ptr_call_helperpr(p_func, ret, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ int get_arg_count_helperr(R (*p_func)(P...)) { static _FORCE_INLINE_ int get_arg_count_helperr(R (*p_func)(P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ Variant::Type get_arg_type_helperr(R (*p_func)(P...), int p_arg) { static _FORCE_INLINE_ Variant::Type get_arg_type_helperr(R (*p_func)(P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class R, class... P> template <typename R, typename... P>
static _FORCE_INLINE_ Variant::Type get_ret_type_helperr(R (*p_func)(P...)) { static _FORCE_INLINE_ Variant::Type get_ret_type_helperr(R (*p_func)(P...)) {
return GetTypeInfo<R>::VARIANT_TYPE; return GetTypeInfo<R>::VARIANT_TYPE;
} }
// WITHOUT RET // WITHOUT RET
template <class... P, size_t... Is> template <typename... P, size_t... Is>
static _FORCE_INLINE_ void call_helperp(void (*p_func)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { static _FORCE_INLINE_ void call_helperp(void (*p_func)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK; r_error.error = Callable::CallError::CALL_OK;
VCALL; VCALL;
@ -1295,44 +1295,44 @@ static _FORCE_INLINE_ void call_helperp(void (*p_func)(P...), const Variant **p_
(void)r_error; (void)r_error;
} }
template <class... P, size_t... Is> template <typename... P, size_t... Is>
static _FORCE_INLINE_ void validated_call_helperp(void (*p_func)(P...), const Variant **p_args, IndexSequence<Is...>) { static _FORCE_INLINE_ void validated_call_helperp(void (*p_func)(P...), const Variant **p_args, IndexSequence<Is...>) {
p_func(VariantCaster<P>::cast(*p_args[Is])...); p_func(VariantCaster<P>::cast(*p_args[Is])...);
(void)p_args; (void)p_args;
} }
template <class... P, size_t... Is> template <typename... P, size_t... Is>
static _FORCE_INLINE_ void ptr_call_helperp(void (*p_func)(P...), const void **p_args, IndexSequence<Is...>) { static _FORCE_INLINE_ void ptr_call_helperp(void (*p_func)(P...), const void **p_args, IndexSequence<Is...>) {
p_func(PtrToArg<P>::convert(p_args[Is])...); p_func(PtrToArg<P>::convert(p_args[Is])...);
(void)p_args; (void)p_args;
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void call_helper(void (*p_func)(P...), const Variant **p_args, Callable::CallError &r_error) { static _FORCE_INLINE_ void call_helper(void (*p_func)(P...), const Variant **p_args, Callable::CallError &r_error) {
call_helperp(p_func, p_args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_helperp(p_func, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void validated_call_helper(void (*p_func)(P...), const Variant **p_args) { static _FORCE_INLINE_ void validated_call_helper(void (*p_func)(P...), const Variant **p_args) {
validated_call_helperp(p_func, p_args, BuildIndexSequence<sizeof...(P)>{}); validated_call_helperp(p_func, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ void ptr_call_helper(void (*p_func)(P...), const void **p_args) { static _FORCE_INLINE_ void ptr_call_helper(void (*p_func)(P...), const void **p_args) {
ptr_call_helperp(p_func, p_args, BuildIndexSequence<sizeof...(P)>{}); ptr_call_helperp(p_func, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ int get_arg_count_helper(void (*p_func)(P...)) { static _FORCE_INLINE_ int get_arg_count_helper(void (*p_func)(P...)) {
return sizeof...(P); return sizeof...(P);
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ Variant::Type get_arg_type_helper(void (*p_func)(P...), int p_arg) { static _FORCE_INLINE_ Variant::Type get_arg_type_helper(void (*p_func)(P...), int p_arg) {
return call_get_argument_type<P...>(p_arg); return call_get_argument_type<P...>(p_arg);
} }
template <class... P> template <typename... P>
static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) { static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
return Variant::NIL; return Variant::NIL;
} }
@ -1645,7 +1645,7 @@ struct VariantUtilityFunctionInfo {
static OAHashMap<StringName, VariantUtilityFunctionInfo> utility_function_table; static OAHashMap<StringName, VariantUtilityFunctionInfo> utility_function_table;
static List<StringName> utility_function_name_table; static List<StringName> utility_function_name_table;
template <class T> template <typename T>
static void register_utility_function(const String &p_name, const Vector<String> &argnames) { static void register_utility_function(const String &p_name, const Vector<String> &argnames) {
String name = p_name; String name = p_name;
if (name.begins_with("_")) { if (name.begins_with("_")) {

View File

@ -144,7 +144,7 @@ private:
RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED;
uint64_t scene_pass = 0; uint64_t scene_pass = 0;
template <class T> template <typename T>
struct InstanceSort { struct InstanceSort {
float depth; float depth;
T *instance = nullptr; T *instance = nullptr;

View File

@ -300,7 +300,7 @@ public:
void remove_node(Node *p_node); void remove_node(Node *p_node);
bool is_selected(Node *p_node) const; bool is_selected(Node *p_node) const;
template <class T> template <typename T>
T *get_node_editor_data(Node *p_node) { T *get_node_editor_data(Node *p_node) {
if (!selection.has(p_node)) { if (!selection.has(p_node)) {
return nullptr; return nullptr;

View File

@ -117,7 +117,7 @@ class EditorHelpSearch::Runner : public RefCounted {
}; };
int phase = 0; int phase = 0;
template <class T> template <typename T>
struct MemberMatch { struct MemberMatch {
T *doc = nullptr; T *doc = nullptr;
bool name = false; bool name = false;

View File

@ -264,7 +264,7 @@ class EditorPlugins {
static EditorPluginCreateFunc creation_funcs[MAX_CREATE_FUNCS]; static EditorPluginCreateFunc creation_funcs[MAX_CREATE_FUNCS];
static int creation_func_count; static int creation_func_count;
template <class T> template <typename T>
static EditorPlugin *creator() { static EditorPlugin *creator() {
return memnew(T); return memnew(T);
} }
@ -276,7 +276,7 @@ public:
return creation_funcs[p_idx](); return creation_funcs[p_idx]();
} }
template <class T> template <typename T>
static void add_by_type() { static void add_by_type() {
add_create_func(creator<T>); add_create_func(creator<T>);
} }

View File

@ -303,10 +303,10 @@ public:
ResourceImporterScene(bool p_animation_import = false, bool p_singleton = false); ResourceImporterScene(bool p_animation_import = false, bool p_singleton = false);
~ResourceImporterScene(); ~ResourceImporterScene();
template <class M> template <typename M>
static Vector<Ref<Shape3D>> get_collision_shapes(const Ref<ImporterMesh> &p_mesh, const M &p_options, float p_applied_root_scale); static Vector<Ref<Shape3D>> get_collision_shapes(const Ref<ImporterMesh> &p_mesh, const M &p_options, float p_applied_root_scale);
template <class M> template <typename M>
static Transform3D get_collision_shapes_transform(const M &p_options); static Transform3D get_collision_shapes_transform(const M &p_options);
}; };
@ -319,7 +319,7 @@ public:
virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr) override; virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr) override;
}; };
template <class M> template <typename M>
Vector<Ref<Shape3D>> ResourceImporterScene::get_collision_shapes(const Ref<ImporterMesh> &p_mesh, const M &p_options, float p_applied_root_scale) { Vector<Ref<Shape3D>> ResourceImporterScene::get_collision_shapes(const Ref<ImporterMesh> &p_mesh, const M &p_options, float p_applied_root_scale) {
ERR_FAIL_COND_V(p_mesh.is_null(), Vector<Ref<Shape3D>>()); ERR_FAIL_COND_V(p_mesh.is_null(), Vector<Ref<Shape3D>>());
ShapeType generate_shape_type = SHAPE_TYPE_DECOMPOSE_CONVEX; ShapeType generate_shape_type = SHAPE_TYPE_DECOMPOSE_CONVEX;
@ -476,7 +476,7 @@ Vector<Ref<Shape3D>> ResourceImporterScene::get_collision_shapes(const Ref<Impor
return Vector<Ref<Shape3D>>(); return Vector<Ref<Shape3D>>();
} }
template <class M> template <typename M>
Transform3D ResourceImporterScene::get_collision_shapes_transform(const M &p_options) { Transform3D ResourceImporterScene::get_collision_shapes_transform(const M &p_options) {
Transform3D transform; Transform3D transform;

View File

@ -35,7 +35,7 @@
#include "core/os/thread.h" #include "core/os/thread.h"
#include "core/typedefs.h" #include "core/typedefs.h"
template <class T> template <typename T>
class Vector; class Vector;
class Main { class Main {

View File

@ -799,7 +799,7 @@ void GDScriptParser::parse_extends() {
} }
} }
template <class T> template <typename T>
void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static) { void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static) {
advance(); advance();

View File

@ -777,7 +777,7 @@ public:
bool has_function(const StringName &p_name) const { bool has_function(const StringName &p_name) const {
return has_member(p_name) && members[members_indices[p_name]].type == Member::FUNCTION; return has_member(p_name) && members[members_indices[p_name]].type == Member::FUNCTION;
} }
template <class T> template <typename T>
void add_member(T *p_member_node) { void add_member(T *p_member_node) {
members_indices[p_member_node->identifier->name] = members.size(); members_indices[p_member_node->identifier->name] = members.size();
members.push_back(Member(p_member_node)); members.push_back(Member(p_member_node));
@ -1167,7 +1167,7 @@ public:
bool has_local(const StringName &p_name) const; bool has_local(const StringName &p_name) const;
const Local &get_local(const StringName &p_name) const; const Local &get_local(const StringName &p_name) const;
template <class T> template <typename T>
void add_local(T *p_local, FunctionNode *p_source_function) { void add_local(T *p_local, FunctionNode *p_source_function) {
locals_indices[p_local->identifier->name] = locals.size(); locals_indices[p_local->identifier->name] = locals.size();
locals.push_back(Local(p_local, p_source_function)); locals.push_back(Local(p_local, p_source_function));
@ -1418,7 +1418,7 @@ private:
void reset_extents(Node *p_node, GDScriptTokenizer::Token p_token); void reset_extents(Node *p_node, GDScriptTokenizer::Token p_token);
void reset_extents(Node *p_node, Node *p_from); void reset_extents(Node *p_node, Node *p_from);
template <class T> template <typename T>
T *alloc_node() { T *alloc_node() {
T *node = memnew(T); T *node = memnew(T);
@ -1464,7 +1464,7 @@ private:
void parse_class_name(); void parse_class_name();
void parse_extends(); void parse_extends();
void parse_class_body(bool p_is_multiline); void parse_class_body(bool p_is_multiline);
template <class T> template <typename T>
void parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static = false); void parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static = false);
SignalNode *parse_signal(bool p_is_static); SignalNode *parse_signal(bool p_is_static);
EnumNode *parse_enum(bool p_is_static); EnumNode *parse_enum(bool p_is_static);

View File

@ -5483,7 +5483,7 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> p_state, const GL
} }
} }
template <class T> template <typename T>
struct SceneFormatImporterGLTFInterpolate { struct SceneFormatImporterGLTFInterpolate {
T lerp(const T &a, const T &b, float c) const { T lerp(const T &a, const T &b, float c) const {
return a + (b - a) * c; return a + (b - a) * c;
@ -5533,7 +5533,7 @@ struct SceneFormatImporterGLTFInterpolate<Quaternion> {
} }
}; };
template <class T> template <typename T>
T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) {
ERR_FAIL_COND_V(p_values.is_empty(), T()); ERR_FAIL_COND_V(p_values.is_empty(), T());
if (p_times.size() != (p_values.size() / (p_interp == GLTFAnimation::INTERP_CUBIC_SPLINE ? 3 : 1))) { if (p_times.size() != (p_values.size() / (p_interp == GLTFAnimation::INTERP_CUBIC_SPLINE ? 3 : 1))) {

View File

@ -216,7 +216,7 @@ private:
Light3D *_generate_light(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index); Light3D *_generate_light(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
Node3D *_generate_spatial(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index); Node3D *_generate_spatial(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
void _assign_node_names(Ref<GLTFState> p_state); void _assign_node_names(Ref<GLTFState> p_state);
template <class T> template <typename T>
T _interpolate_track(const Vector<real_t> &p_times, const Vector<T> &p_values, T _interpolate_track(const Vector<real_t> &p_times, const Vector<T> &p_values,
const float p_time, const float p_time,
const GLTFAnimation::Interpolation p_interp); const GLTFAnimation::Interpolation p_interp);

View File

@ -37,7 +37,7 @@
#include "core/variant/typed_array.h" #include "core/variant/typed_array.h"
namespace GLTFTemplateConvert { namespace GLTFTemplateConvert {
template <class T> template <typename T>
static Array to_array(const Vector<T> &p_inp) { static Array to_array(const Vector<T> &p_inp) {
Array ret; Array ret;
for (int i = 0; i < p_inp.size(); i++) { for (int i = 0; i < p_inp.size(); i++) {
@ -46,7 +46,7 @@ static Array to_array(const Vector<T> &p_inp) {
return ret; return ret;
} }
template <class T> template <typename T>
static TypedArray<T> to_array(const HashSet<T> &p_inp) { static TypedArray<T> to_array(const HashSet<T> &p_inp) {
TypedArray<T> ret; TypedArray<T> ret;
typename HashSet<T>::Iterator elem = p_inp.begin(); typename HashSet<T>::Iterator elem = p_inp.begin();
@ -57,7 +57,7 @@ static TypedArray<T> to_array(const HashSet<T> &p_inp) {
return ret; return ret;
} }
template <class T> template <typename T>
static void set_from_array(Vector<T> &r_out, const Array &p_inp) { static void set_from_array(Vector<T> &r_out, const Array &p_inp) {
r_out.clear(); r_out.clear();
for (int i = 0; i < p_inp.size(); i++) { for (int i = 0; i < p_inp.size(); i++) {
@ -65,7 +65,7 @@ static void set_from_array(Vector<T> &r_out, const Array &p_inp) {
} }
} }
template <class T> template <typename T>
static void set_from_array(HashSet<T> &r_out, const TypedArray<T> &p_inp) { static void set_from_array(HashSet<T> &r_out, const TypedArray<T> &p_inp) {
r_out.clear(); r_out.clear();
for (int i = 0; i < p_inp.size(); i++) { for (int i = 0; i < p_inp.size(); i++) {
@ -73,7 +73,7 @@ static void set_from_array(HashSet<T> &r_out, const TypedArray<T> &p_inp) {
} }
} }
template <class K, class V> template <typename K, typename V>
static Dictionary to_dictionary(const HashMap<K, V> &p_inp) { static Dictionary to_dictionary(const HashMap<K, V> &p_inp) {
Dictionary ret; Dictionary ret;
for (const KeyValue<K, V> &E : p_inp) { for (const KeyValue<K, V> &E : p_inp) {
@ -82,7 +82,7 @@ static Dictionary to_dictionary(const HashMap<K, V> &p_inp) {
return ret; return ret;
} }
template <class K, class V> template <typename K, typename V>
static void set_from_dictionary(HashMap<K, V> &r_out, const Dictionary &p_inp) { static void set_from_dictionary(HashMap<K, V> &r_out, const Dictionary &p_inp) {
r_out.clear(); r_out.clear();
Array keys = p_inp.keys(); Array keys = p_inp.keys();

View File

@ -47,7 +47,7 @@ public:
INTERP_CUBIC_SPLINE, INTERP_CUBIC_SPLINE,
}; };
template <class T> template <typename T>
struct Channel { struct Channel {
Interpolation interpolation = INTERP_LINEAR; Interpolation interpolation = INTERP_LINEAR;
Vector<real_t> times; Vector<real_t> times;

View File

@ -112,7 +112,7 @@ private:
Error _update_spawn_visibility(int p_peer, const ObjectID &p_oid); Error _update_spawn_visibility(int p_peer, const ObjectID &p_oid);
void _free_remotes(const PeerInfo &p_info); void _free_remotes(const PeerInfo &p_info);
template <class T> template <typename T>
static T *get_id_as(const ObjectID &p_id) { static T *get_id_as(const ObjectID &p_id) {
return p_id.is_valid() ? Object::cast_to<T>(ObjectDB::get_instance(p_id)) : nullptr; return p_id.is_valid() ? Object::cast_to<T>(ObjectDB::get_instance(p_id)) : nullptr;
} }

View File

@ -33,7 +33,7 @@
#include "core/templates/ring_buffer.h" #include "core/templates/ring_buffer.h"
template <class T> template <typename T>
class PacketBuffer { class PacketBuffer {
private: private:
typedef struct { typedef struct {

View File

@ -69,7 +69,7 @@
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4 #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4
#endif #endif
template <class T> template <typename T>
class ComAutoreleaseRef { class ComAutoreleaseRef {
public: public:
T *reference = nullptr; T *reference = nullptr;

View File

@ -57,7 +57,7 @@ protected:
MTFlag() : MTFlag() :
mt{} {} mt{} {}
}; };
template <class T> template <typename T>
union MTNumeric { union MTNumeric {
SafeNumeric<T> mt; SafeNumeric<T> mt;
T st; T st;

View File

@ -1041,7 +1041,7 @@ bool Animation::track_get_interpolation_loop_wrap(int p_track) const {
return tracks[p_track]->loop_wrap; return tracks[p_track]->loop_wrap;
} }
template <class T, class V> template <typename T, typename V>
int Animation::_insert(double p_time, T &p_keys, const V &p_value) { int Animation::_insert(double p_time, T &p_keys, const V &p_value) {
int idx = p_keys.size(); int idx = p_keys.size();
@ -1065,7 +1065,7 @@ int Animation::_insert(double p_time, T &p_keys, const V &p_value) {
return -1; return -1;
} }
template <class T> template <typename T>
void Animation::_clear(T &p_keys) { void Animation::_clear(T &p_keys) {
p_keys.clear(); p_keys.clear();
} }
@ -2331,7 +2331,7 @@ void Animation::track_set_key_transition(int p_track, int p_key_idx, real_t p_tr
emit_changed(); emit_changed();
} }
template <class K> template <typename K>
int Animation::_find(const Vector<K> &p_keys, double p_time, bool p_backward, bool p_limit) const { int Animation::_find(const Vector<K> &p_keys, double p_time, bool p_backward, bool p_limit) const {
int len = p_keys.size(); int len = p_keys.size();
if (len == 0) { if (len == 0) {
@ -2451,7 +2451,7 @@ Variant Animation::_cubic_interpolate_angle_in_time(const Variant &p_pre_a, cons
return _cubic_interpolate_in_time(p_pre_a, p_a, p_b, p_post_b, p_c, p_pre_a_t, p_b_t, p_post_b_t); return _cubic_interpolate_in_time(p_pre_a, p_a, p_b, p_post_b, p_c, p_pre_a_t, p_b_t, p_post_b_t);
} }
template <class T> template <typename T>
T Animation::_interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward) const { T Animation::_interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward) const {
int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end) int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end)
@ -2693,7 +2693,7 @@ Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const
return vt->update_mode; return vt->update_mode;
} }
template <class T> template <typename T>
void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const { void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const {
int len = p_array.size(); int len = p_array.size();
if (len == 0) { if (len == 0) {

View File

@ -120,7 +120,7 @@ private:
}; };
// Transform key holds either Vector3 or Quaternion. // Transform key holds either Vector3 or Quaternion.
template <class T> template <typename T>
struct TKey : public Key { struct TKey : public Key {
T value; T value;
}; };
@ -235,13 +235,13 @@ private:
Vector<Track *> tracks; Vector<Track *> tracks;
template <class T> template <typename T>
void _clear(T &p_keys); void _clear(T &p_keys);
template <class T, class V> template <typename T, typename V>
int _insert(double p_time, T &p_keys, const V &p_value); int _insert(double p_time, T &p_keys, const V &p_value);
template <class K> template <typename K>
inline int _find(const Vector<K> &p_keys, double p_time, bool p_backward = false, bool p_limit = false) const; inline int _find(const Vector<K> &p_keys, double p_time, bool p_backward = false, bool p_limit = false) const;
@ -257,10 +257,10 @@ private:
_FORCE_INLINE_ real_t _cubic_interpolate_in_time(const real_t &p_pre_a, const real_t &p_a, const real_t &p_b, const real_t &p_post_b, real_t p_c, real_t p_pre_a_t, real_t p_b_t, real_t p_post_b_t) const; _FORCE_INLINE_ real_t _cubic_interpolate_in_time(const real_t &p_pre_a, const real_t &p_a, const real_t &p_b, const real_t &p_post_b, real_t p_c, real_t p_pre_a_t, real_t p_b_t, real_t p_post_b_t) const;
_FORCE_INLINE_ Variant _cubic_interpolate_angle_in_time(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, real_t p_c, real_t p_pre_a_t, real_t p_b_t, real_t p_post_b_t) const; _FORCE_INLINE_ Variant _cubic_interpolate_angle_in_time(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, real_t p_c, real_t p_pre_a_t, real_t p_b_t, real_t p_post_b_t) const;
template <class T> template <typename T>
_FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward = false) const; _FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward = false) const;
template <class T> template <typename T>
_FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const; _FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const;
double length = 1.0; double length = 1.0;

View File

@ -86,7 +86,7 @@ void AudioStreamPlaybackWAV::seek(double p_time) {
offset = uint64_t(p_time * base->mix_rate) << MIX_FRAC_BITS; offset = uint64_t(p_time * base->mix_rate) << MIX_FRAC_BITS;
} }
template <class Depth, bool is_stereo, bool is_ima_adpcm> template <typename Depth, bool is_stereo, bool is_ima_adpcm>
void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm) { void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm) {
// this function will be compiled branchless by any decent compiler // this function will be compiled branchless by any decent compiler

View File

@ -60,7 +60,7 @@ class AudioStreamPlaybackWAV : public AudioStreamPlayback {
friend class AudioStreamWAV; friend class AudioStreamWAV;
Ref<AudioStreamWAV> base; Ref<AudioStreamWAV> base;
template <class Depth, bool is_stereo, bool is_ima_adpcm> template <typename Depth, bool is_stereo, bool is_ima_adpcm>
void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm); void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm);
public: public:

View File

@ -71,7 +71,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
template <class T> template <typename T>
static CameraServer *_create_builtin() { static CameraServer *_create_builtin() {
return memnew(T); return memnew(T);
} }
@ -79,7 +79,7 @@ protected:
public: public:
static CameraServer *get_singleton(); static CameraServer *get_singleton();
template <class T> template <typename T>
static void make_default() { static void make_default() {
create_func = _create_builtin<T>; create_func = _create_builtin<T>;
} }

View File

@ -38,7 +38,7 @@
#include "core/math/vector2.h" #include "core/math/vector2.h"
class GodotBroadPhase2DBVH : public GodotBroadPhase2D { class GodotBroadPhase2DBVH : public GodotBroadPhase2D {
template <class T> template <typename T>
class UserPairTestFunction { class UserPairTestFunction {
public: public:
static bool user_pair_check(const T *p_a, const T *p_b) { static bool user_pair_check(const T *p_a, const T *p_b) {
@ -47,7 +47,7 @@ class GodotBroadPhase2DBVH : public GodotBroadPhase2D {
} }
}; };
template <class T> template <typename T>
class UserCullTestFunction { class UserCullTestFunction {
public: public:
static bool user_cull_check(const T *p_a, const T *p_b) { static bool user_cull_check(const T *p_a, const T *p_b) {

View File

@ -171,7 +171,7 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_collector); contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_collector);
} }
template <class ShapeA, class ShapeB, bool castA = false, bool castB = false, bool withMargin = false> template <typename ShapeA, typename ShapeB, bool castA = false, bool castB = false, bool withMargin = false>
class SeparatorAxisTest2D { class SeparatorAxisTest2D {
const ShapeA *shape_A = nullptr; const ShapeA *shape_A = nullptr;
const ShapeB *shape_B = nullptr; const ShapeB *shape_B = nullptr;

View File

@ -36,7 +36,7 @@
#include "core/math/bvh.h" #include "core/math/bvh.h"
class GodotBroadPhase3DBVH : public GodotBroadPhase3D { class GodotBroadPhase3DBVH : public GodotBroadPhase3D {
template <class T> template <typename T>
class UserPairTestFunction { class UserPairTestFunction {
public: public:
static bool user_pair_check(const T *p_a, const T *p_b) { static bool user_pair_check(const T *p_a, const T *p_b) {
@ -45,7 +45,7 @@ class GodotBroadPhase3DBVH : public GodotBroadPhase3D {
} }
}; };
template <class T> template <typename T>
class UserCullTestFunction { class UserCullTestFunction {
public: public:
static bool user_cull_check(const T *p_a, const T *p_b) { static bool user_cull_check(const T *p_a, const T *p_b) {

View File

@ -612,7 +612,7 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_callback); contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_callback);
} }
template <class ShapeA, class ShapeB, bool withMargin = false> template <typename ShapeA, typename ShapeB, bool withMargin = false>
class SeparatorAxisTest { class SeparatorAxisTest {
const ShapeA *shape_A = nullptr; const ShapeA *shape_A = nullptr;
const ShapeB *shape_B = nullptr; const ShapeB *shape_B = nullptr;

View File

@ -2162,7 +2162,7 @@ bool RendererCanvasCull::free(RID p_rid) {
return true; return true;
} }
template <class T> template <typename T>
void RendererCanvasCull::_free_rids(T &p_owner, const char *p_type) { void RendererCanvasCull::_free_rids(T &p_owner, const char *p_type) {
List<RID> owned; List<RID> owned;
p_owner.get_owned_list(&owned); p_owner.get_owned_list(&owned);

View File

@ -170,7 +170,7 @@ public:
RID_Owner<Item, true> canvas_item_owner; RID_Owner<Item, true> canvas_item_owner;
RID_Owner<RendererCanvasRender::Light, true> canvas_light_owner; RID_Owner<RendererCanvasRender::Light, true> canvas_light_owner;
template <class T> template <typename T>
void _free_rids(T &p_owner, const char *p_type); void _free_rids(T &p_owner, const char *p_type);
bool disable_scale; bool disable_scale;

View File

@ -366,7 +366,7 @@ public:
mutable double debug_redraw_time = 0; mutable double debug_redraw_time = 0;
#endif #endif
template <class T> template <typename T>
T *alloc_command() { T *alloc_command() {
T *command = nullptr; T *command = nullptr;
if (commands == nullptr) { if (commands == nullptr) {

View File

@ -5182,7 +5182,7 @@ void RenderingDevice::_save_pipeline_cache(void *p_data) {
} }
} }
template <class T> template <typename T>
void RenderingDevice::_free_rids(T &p_owner, const char *p_type) { void RenderingDevice::_free_rids(T &p_owner, const char *p_type) {
List<RID> owned; List<RID> owned;
p_owner.get_owned_list(&owned); p_owner.get_owned_list(&owned);

View File

@ -1294,7 +1294,7 @@ private:
void _stall_for_previous_frames(); void _stall_for_previous_frames();
void _flush_and_stall_for_all_frames(); void _flush_and_stall_for_all_frames();
template <class T> template <typename T>
void _free_rids(T &p_owner, const char *p_type); void _free_rids(T &p_owner, const char *p_type);
#ifdef DEV_ENABLED #ifdef DEV_ENABLED

View File

@ -56,7 +56,7 @@
// This may one day be used in Godot for interoperability between C arrays, Vector and LocalVector. // This may one day be used in Godot for interoperability between C arrays, Vector and LocalVector.
// (See https://github.com/godotengine/godot-proposals/issues/5144.) // (See https://github.com/godotengine/godot-proposals/issues/5144.)
template <class T> template <typename T>
class VectorView { class VectorView {
const T *_ptr = nullptr; const T *_ptr = nullptr;
const uint32_t _size = 0; const uint32_t _size = 0;
@ -97,20 +97,20 @@ public:
#define ENUM_MEMBERS_EQUAL(m_a, m_b) ((int64_t)m_a == (int64_t)m_b) #define ENUM_MEMBERS_EQUAL(m_a, m_b) ((int64_t)m_a == (int64_t)m_b)
// This helps using a single paged allocator for many resource types. // This helps using a single paged allocator for many resource types.
template <class... RESOURCE_TYPES> template <typename... RESOURCE_TYPES>
struct VersatileResourceTemplate { struct VersatileResourceTemplate {
static constexpr size_t RESOURCE_SIZES[] = { sizeof(RESOURCE_TYPES)... }; static constexpr size_t RESOURCE_SIZES[] = { sizeof(RESOURCE_TYPES)... };
static constexpr size_t MAX_RESOURCE_SIZE = std::max_element(RESOURCE_SIZES, RESOURCE_SIZES + sizeof...(RESOURCE_TYPES))[0]; static constexpr size_t MAX_RESOURCE_SIZE = std::max_element(RESOURCE_SIZES, RESOURCE_SIZES + sizeof...(RESOURCE_TYPES))[0];
uint8_t data[MAX_RESOURCE_SIZE]; uint8_t data[MAX_RESOURCE_SIZE];
template <class T> template <typename T>
static T *allocate(PagedAllocator<VersatileResourceTemplate> &p_allocator) { static T *allocate(PagedAllocator<VersatileResourceTemplate> &p_allocator) {
T *obj = (T *)p_allocator.alloc(); T *obj = (T *)p_allocator.alloc();
memnew_placement(obj, T); memnew_placement(obj, T);
return obj; return obj;
} }
template <class T> template <typename T>
static void free(PagedAllocator<VersatileResourceTemplate> &p_allocator, T *p_object) { static void free(PagedAllocator<VersatileResourceTemplate> &p_allocator, T *p_object) {
p_object->~T(); p_object->~T();
p_allocator.free((VersatileResourceTemplate *)p_object); p_allocator.free((VersatileResourceTemplate *)p_object);

View File

@ -383,7 +383,7 @@ public:
virtual ~Node() {} virtual ~Node() {}
}; };
template <class T> template <typename T>
T *alloc_node() { T *alloc_node() {
T *node = memnew(T); T *node = memnew(T);
node->next = nodes; node->next = nodes;

Some files were not shown because too many files have changed in this diff Show More