Style: Enforce AllowShortFunctionsOnASingleLine

This commit is contained in:
Thaddeus Crews 2024-12-30 10:23:23 -06:00
parent 2582793d40
commit e06d83860d
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
15 changed files with 611 additions and 405 deletions

View file

@ -42,8 +42,12 @@ class Node;
#define RES_BASE_EXTENSION(m_ext) \
public: \
static void register_custom_data_to_otdb() { ClassDB::add_resource_base_extension(m_ext, get_class_static()); } \
virtual String get_base_extension() const override { return m_ext; } \
static void register_custom_data_to_otdb() { \
ClassDB::add_resource_base_extension(m_ext, get_class_static()); \
} \
virtual String get_base_extension() const override { \
return m_ext; \
} \
\
private:

View file

@ -430,7 +430,9 @@ public:
} \
return (p_class == (#m_class)) ? true : m_inherits::is_class(p_class); \
} \
virtual bool is_class_ptr(void *p_ptr) const override { return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); } \
virtual bool is_class_ptr(void *p_ptr) const override { \
return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); \
} \
\
static void get_valid_parents_static(List<String> *p_parents) { \
if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) { \
@ -558,7 +560,9 @@ private:
#define OBJ_SAVE_TYPE(m_class) \
public: \
virtual String get_save_class() const override { return #m_class; } \
virtual String get_save_class() const override { \
return #m_class; \
} \
\
private:

View file

@ -64,7 +64,9 @@ SafeNumeric<uint64_t> Memory::max_usage;
SafeNumeric<uint64_t> Memory::alloc_count;
inline bool is_power_of_2(size_t x) { return x && ((x & (x - 1U)) == 0U); }
inline bool is_power_of_2(size_t x) {
return x && ((x & (x - 1U)) == 0U);
}
void *Memory::alloc_aligned_static(size_t p_bytes, size_t p_alignment) {
DEV_ASSERT(is_power_of_2(p_alignment));

View file

@ -32,69 +32,133 @@
#define PASS_FUNC_H
#define PASS0R(m_r, m_name) \
m_r m_name() { return PASSBASE->m_name(); }
m_r m_name() { \
return PASSBASE->m_name(); \
}
#define PASS0RC(m_r, m_name) \
m_r m_name() const { return PASSBASE->m_name(); }
m_r m_name() const { \
return PASSBASE->m_name(); \
}
#define PASS1R(m_r, m_name, m_type1) \
m_r m_name(m_type1 arg1) { return PASSBASE->m_name(arg1); }
m_r m_name(m_type1 arg1) { \
return PASSBASE->m_name(arg1); \
}
#define PASS1RC(m_r, m_name, m_type1) \
m_r m_name(m_type1 arg1) const { return PASSBASE->m_name(arg1); }
m_r m_name(m_type1 arg1) const { \
return PASSBASE->m_name(arg1); \
}
#define PASS2R(m_r, m_name, m_type1, m_type2) \
m_r m_name(m_type1 arg1, m_type2 arg2) { return PASSBASE->m_name(arg1, arg2); }
m_r m_name(m_type1 arg1, m_type2 arg2) { \
return PASSBASE->m_name(arg1, arg2); \
}
#define PASS2RC(m_r, m_name, m_type1, m_type2) \
m_r m_name(m_type1 arg1, m_type2 arg2) const { return PASSBASE->m_name(arg1, arg2); }
m_r m_name(m_type1 arg1, m_type2 arg2) const { \
return PASSBASE->m_name(arg1, arg2); \
}
#define PASS3R(m_r, m_name, m_type1, m_type2, m_type3) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { return PASSBASE->m_name(arg1, arg2, arg3); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { \
return PASSBASE->m_name(arg1, arg2, arg3); \
}
#define PASS3RC(m_r, m_name, m_type1, m_type2, m_type3) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { return PASSBASE->m_name(arg1, arg2, arg3); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { \
return PASSBASE->m_name(arg1, arg2, arg3); \
}
#define PASS4R(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { return PASSBASE->m_name(arg1, arg2, arg3, arg4); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4); \
}
#define PASS4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4); \
}
#define PASS5R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \
}
#define PASS5RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) const { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \
}
#define PASS6R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \
}
#define PASS6RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) const { \
return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \
}
#define PASS0(m_name) \
void m_name() { PASSBASE->m_name(); }
void m_name() { \
PASSBASE->m_name(); \
}
#define PASS1(m_name, m_type1) \
void m_name(m_type1 arg1) { PASSBASE->m_name(arg1); }
void m_name(m_type1 arg1) { \
PASSBASE->m_name(arg1); \
}
#define PASS1C(m_name, m_type1) \
void m_name(m_type1 arg1) const { PASSBASE->m_name(arg1); }
void m_name(m_type1 arg1) const { \
PASSBASE->m_name(arg1); \
}
#define PASS2(m_name, m_type1, m_type2) \
void m_name(m_type1 arg1, m_type2 arg2) { PASSBASE->m_name(arg1, arg2); }
void m_name(m_type1 arg1, m_type2 arg2) { \
PASSBASE->m_name(arg1, arg2); \
}
#define PASS2C(m_name, m_type1, m_type2) \
void m_name(m_type1 arg1, m_type2 arg2) const { PASSBASE->m_name(arg1, arg2); }
void m_name(m_type1 arg1, m_type2 arg2) const { \
PASSBASE->m_name(arg1, arg2); \
}
#define PASS3(m_name, m_type1, m_type2, m_type3) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { PASSBASE->m_name(arg1, arg2, arg3); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { \
PASSBASE->m_name(arg1, arg2, arg3); \
}
#define PASS4(m_name, m_type1, m_type2, m_type3, m_type4) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { PASSBASE->m_name(arg1, arg2, arg3, arg4); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4); \
}
#define PASS5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \
}
#define PASS6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \
}
#define PASS7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
}
#define PASS8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
}
#define PASS9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
}
#define PASS10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \
}
#define PASS11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \
}
#define PASS12(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \
}
#define PASS13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \
}
#define PASS14(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \
}
#define PASS15(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14, m_type15) \
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); }
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \
}
#endif // PASS_FUNC_H

View file

@ -102,12 +102,18 @@ struct VariantCaster<const T &> {
}; \
template <> \
struct ZeroInitializer<m_enum> { \
static void initialize(m_enum &value) { value = (m_enum)0; } \
static void initialize(m_enum &value) { \
value = (m_enum)0; \
} \
}; \
template <> \
struct VariantInternalAccessor<m_enum> { \
static _FORCE_INLINE_ m_enum get(const Variant *v) { return m_enum(*VariantInternal::get_int(v)); } \
static _FORCE_INLINE_ void set(Variant *v, m_enum p_value) { *VariantInternal::get_int(v) = (int64_t)p_value; } \
static _FORCE_INLINE_ m_enum get(const Variant *v) { \
return m_enum(*VariantInternal::get_int(v)); \
} \
static _FORCE_INLINE_ void set(Variant *v, m_enum p_value) { \
*VariantInternal::get_int(v) = (int64_t)p_value; \
} \
};
#define VARIANT_BITFIELD_CAST(m_enum) \
@ -130,12 +136,18 @@ struct VariantCaster<const T &> {
}; \
template <> \
struct ZeroInitializer<BitField<m_enum>> { \
static void initialize(BitField<m_enum> &value) { value = 0; } \
static void initialize(BitField<m_enum> &value) { \
value = 0; \
} \
}; \
template <> \
struct VariantInternalAccessor<BitField<m_enum>> { \
static _FORCE_INLINE_ BitField<m_enum> get(const Variant *v) { return BitField<m_enum>(*VariantInternal::get_int(v)); } \
static _FORCE_INLINE_ void set(Variant *v, BitField<m_enum> p_value) { *VariantInternal::get_int(v) = p_value.operator int64_t(); } \
static _FORCE_INLINE_ BitField<m_enum> get(const Variant *v) { \
return BitField<m_enum>(*VariantInternal::get_int(v)); \
} \
static _FORCE_INLINE_ void set(Variant *v, BitField<m_enum> p_value) { \
*VariantInternal::get_int(v) = p_value.operator int64_t(); \
} \
};
// Object enum casts must go here

View file

@ -58,10 +58,18 @@ struct GDExtensionPtr {
struct GDExtensionConstPtr<const m_type> { \
const m_type *data = nullptr; \
GDExtensionConstPtr() {} \
GDExtensionConstPtr(const m_type *p_assign) { data = p_assign; } \
static const char *get_name() { return "const " #m_type; } \
operator const m_type *() const { return data; } \
operator Variant() const { return uint64_t(data); } \
GDExtensionConstPtr(const m_type *p_assign) { \
data = p_assign; \
} \
static const char *get_name() { \
return "const " #m_type; \
} \
operator const m_type *() const { \
return data; \
} \
operator Variant() const { \
return uint64_t(data); \
} \
}; \
template <> \
struct VariantCaster<GDExtensionConstPtr<const m_type>> { \
@ -71,17 +79,29 @@ struct GDExtensionPtr {
}; \
template <> \
struct VariantInternalAccessor<GDExtensionConstPtr<const m_type>> { \
static _FORCE_INLINE_ const GDExtensionConstPtr<const m_type> &get(const Variant *v) { return *reinterpret_cast<const GDExtensionConstPtr<const m_type> *>(VariantInternal::get_int(v)); } \
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr<const m_type> &p_value) { *VariantInternal::get_int(v) = uint64_t(p_value.data); } \
static _FORCE_INLINE_ const GDExtensionConstPtr<const m_type> &get(const Variant *v) { \
return *reinterpret_cast<const GDExtensionConstPtr<const m_type> *>(VariantInternal::get_int(v)); \
} \
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr<const m_type> &p_value) { \
*VariantInternal::get_int(v) = uint64_t(p_value.data); \
} \
}; \
template <> \
struct GDExtensionPtr<m_type> { \
m_type *data = nullptr; \
GDExtensionPtr() {} \
GDExtensionPtr(m_type *p_assign) { data = p_assign; } \
static const char *get_name() { return #m_type; } \
operator m_type *() const { return data; } \
operator Variant() const { return uint64_t(data); } \
GDExtensionPtr(m_type *p_assign) { \
data = p_assign; \
} \
static const char *get_name() { \
return #m_type; \
} \
operator m_type *() const { \
return data; \
} \
operator Variant() const { \
return uint64_t(data); \
} \
}; \
template <> \
struct VariantCaster<GDExtensionPtr<m_type>> { \
@ -91,8 +111,12 @@ struct GDExtensionPtr {
}; \
template <> \
struct VariantInternalAccessor<GDExtensionPtr<m_type>> { \
static _FORCE_INLINE_ const GDExtensionPtr<m_type> &get(const Variant *v) { return *reinterpret_cast<const GDExtensionPtr<m_type> *>(VariantInternal::get_int(v)); } \
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_ const GDExtensionPtr<m_type> &get(const Variant *v) { \
return *reinterpret_cast<const GDExtensionPtr<m_type> *>(VariantInternal::get_int(v)); \
} \
static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr<m_type> &p_value) { \
*VariantInternal::get_int(v) = uint64_t(p_value.data); \
} \
};
template <typename T>

View file

@ -322,7 +322,9 @@ struct ZeroInitializer<T *> {
#define ZERO_INITIALIZER_NUMBER(m_type) \
template <> \
struct ZeroInitializer<m_type> { \
static void initialize(m_type &value) { value = 0; } \
static void initialize(m_type &value) { \
value = 0; \
} \
};
ZERO_INITIALIZER_NUMBER(uint8_t)

View file

@ -834,8 +834,12 @@ struct VariantInternalAccessor<bool> {
#define VARIANT_ACCESSOR_NUMBER(m_type) \
template <> \
struct VariantInternalAccessor<m_type> { \
static _FORCE_INLINE_ m_type get(const Variant *v) { return (m_type) * VariantInternal::get_int(v); } \
static _FORCE_INLINE_ void set(Variant *v, m_type p_value) { *VariantInternal::get_int(v) = p_value; } \
static _FORCE_INLINE_ m_type get(const Variant *v) { \
return (m_type) * VariantInternal::get_int(v); \
} \
static _FORCE_INLINE_ void set(Variant *v, m_type p_value) { \
*VariantInternal::get_int(v) = p_value; \
} \
};
VARIANT_ACCESSOR_NUMBER(int8_t)
@ -1133,7 +1137,9 @@ struct VariantInitializer<bool> {
#define INITIALIZER_INT(m_type) \
template <> \
struct VariantInitializer<m_type> { \
static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_generic<int64_t>(v); } \
static _FORCE_INLINE_ void init(Variant *v) { \
VariantInternal::init_generic<int64_t>(v); \
} \
};
INITIALIZER_INT(uint8_t)

View file

@ -390,9 +390,15 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, v.size()); \
v.write[index] = PtrToArg<m_elem_type>::convert(member); \
} \
static Variant::Type get_index_type() { return GetTypeInfo<m_elem_type>::VARIANT_TYPE; } \
static uint32_t get_index_usage() { return GetTypeInfo<m_elem_type>::get_class_info().usage; } \
static uint64_t get_indexed_size(const Variant *base) { return VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); } \
static Variant::Type get_index_type() { \
return GetTypeInfo<m_elem_type>::VARIANT_TYPE; \
} \
static uint32_t get_index_usage() { \
return GetTypeInfo<m_elem_type>::get_class_info().usage; \
} \
static uint64_t get_indexed_size(const Variant *base) { \
return VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
} \
};
#define INDEXED_SETGET_STRUCT_TYPED_NUMERIC(m_base_type, m_elem_type, m_assign_type) \
@ -462,9 +468,15 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, v.size()); \
v.write[index] = PtrToArg<m_elem_type>::convert(member); \
} \
static Variant::Type get_index_type() { return GetTypeInfo<m_elem_type>::VARIANT_TYPE; } \
static uint32_t get_index_usage() { return GetTypeInfo<m_elem_type>::get_class_info().usage; } \
static uint64_t get_indexed_size(const Variant *base) { return VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); } \
static Variant::Type get_index_type() { \
return GetTypeInfo<m_elem_type>::VARIANT_TYPE; \
} \
static uint32_t get_index_usage() { \
return GetTypeInfo<m_elem_type>::get_class_info().usage; \
} \
static uint64_t get_indexed_size(const Variant *base) { \
return VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
} \
};
#define INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(m_base_type, m_elem_type, m_assign_type, m_max) \
@ -518,9 +530,15 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
v[index] = PtrToArg<m_elem_type>::convert(member); \
} \
static Variant::Type get_index_type() { return GetTypeInfo<m_elem_type>::VARIANT_TYPE; } \
static uint32_t get_index_usage() { return GetTypeInfo<m_elem_type>::get_class_info().usage; } \
static uint64_t get_indexed_size(const Variant *base) { return m_max; } \
static Variant::Type get_index_type() { \
return GetTypeInfo<m_elem_type>::VARIANT_TYPE; \
} \
static uint32_t get_index_usage() { \
return GetTypeInfo<m_elem_type>::get_class_info().usage; \
} \
static uint64_t get_indexed_size(const Variant *base) { \
return m_max; \
} \
};
#define INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(m_base_type, m_elem_type, m_accessor, m_max) \
@ -568,9 +586,15 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
v m_accessor[index] = PtrToArg<m_elem_type>::convert(member); \
} \
static Variant::Type get_index_type() { return GetTypeInfo<m_elem_type>::VARIANT_TYPE; } \
static uint32_t get_index_usage() { return GetTypeInfo<m_elem_type>::get_class_info().usage; } \
static uint64_t get_indexed_size(const Variant *base) { return m_max; } \
static Variant::Type get_index_type() { \
return GetTypeInfo<m_elem_type>::VARIANT_TYPE; \
} \
static uint32_t get_index_usage() { \
return GetTypeInfo<m_elem_type>::get_class_info().usage; \
} \
static uint64_t get_indexed_size(const Variant *base) { \
return m_max; \
} \
};
#define INDEXED_SETGET_STRUCT_BULTIN_FUNC(m_base_type, m_elem_type, m_set, m_get, m_max) \
@ -618,9 +642,15 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
v.m_set(index, PtrToArg<m_elem_type>::convert(member)); \
} \
static Variant::Type get_index_type() { return GetTypeInfo<m_elem_type>::VARIANT_TYPE; } \
static uint32_t get_index_usage() { return GetTypeInfo<m_elem_type>::get_class_info().usage; } \
static uint64_t get_indexed_size(const Variant *base) { return m_max; } \
static Variant::Type get_index_type() { \
return GetTypeInfo<m_elem_type>::VARIANT_TYPE; \
} \
static uint32_t get_index_usage() { \
return GetTypeInfo<m_elem_type>::get_class_info().usage; \
} \
static uint64_t get_indexed_size(const Variant *base) { \
return m_max; \
} \
};
struct VariantIndexedSetGet_Array {

View file

@ -67,7 +67,9 @@
b.m_member = PtrToArg<m_member_type>::convert(member); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \
@ -101,7 +103,9 @@
b.m_member = PtrToArg<m_member_type>::convert(member); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
@ -132,7 +136,9 @@
b.m_custom = PtrToArg<m_member_type>::convert(member); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
@ -166,7 +172,9 @@
b.m_custom = PtrToArg<m_member_type>::convert(member); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
@ -197,7 +205,9 @@
b.m_setter(PtrToArg<m_member_type>::convert(member)); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
@ -231,7 +241,9 @@
b.m_setter(PtrToArg<m_member_type>::convert(member)); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \
@ -262,7 +274,9 @@
b.m_setter(m_index, PtrToArg<m_member_type>::convert(member)); \
PtrToArg<m_base_type>::encode(b, base); \
} \
static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
static Variant::Type get_type() { \
return GetTypeInfo<m_member_type>::VARIANT_TYPE; \
} \
};
SETGET_NUMBER_STRUCT(Vector2, double, x)

View file

@ -1370,8 +1370,12 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
static bool has_return_type() { \
return true; \
} \
static bool is_vararg() { return false; } \
static Variant::UtilityFunctionType get_type() { return m_category; } \
static bool is_vararg() { \
return false; \
} \
static Variant::UtilityFunctionType get_type() { \
return m_category; \
} \
}; \
register_utility_function<Func_##m_func>(#m_func, m_args)
@ -1402,8 +1406,12 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
static bool has_return_type() { \
return true; \
} \
static bool is_vararg() { return false; } \
static Variant::UtilityFunctionType get_type() { return m_category; } \
static bool is_vararg() { \
return false; \
} \
static Variant::UtilityFunctionType get_type() { \
return m_category; \
} \
}; \
register_utility_function<Func_##m_func>(#m_func, m_args)
@ -1436,8 +1444,12 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
static bool has_return_type() { \
return true; \
} \
static bool is_vararg() { return false; } \
static Variant::UtilityFunctionType get_type() { return m_category; } \
static bool is_vararg() { \
return false; \
} \
static Variant::UtilityFunctionType get_type() { \
return m_category; \
} \
}; \
register_utility_function<Func_##m_func>(#m_func, m_args)
@ -1470,8 +1482,12 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
static bool has_return_type() { \
return true; \
} \
static bool is_vararg() { return false; } \
static Variant::UtilityFunctionType get_type() { return m_category; } \
static bool is_vararg() { \
return false; \
} \
static Variant::UtilityFunctionType get_type() { \
return m_category; \
} \
}; \
register_utility_function<Func_##m_func>(#m_func, m_args)
@ -1633,8 +1649,12 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) {
static bool has_return_type() { \
return false; \
} \
static bool is_vararg() { return false; } \
static Variant::UtilityFunctionType get_type() { return m_category; } \
static bool is_vararg() { \
return false; \
} \
static Variant::UtilityFunctionType get_type() { \
return m_category; \
} \
}; \
register_utility_function<Func_##m_func>(#m_func, m_args)

View file

@ -74,7 +74,9 @@ namespace MTL {
class name { \
public: \
name(id<MTL##name> obj = nil) : m_obj(obj) {} \
operator id<MTL##name>() const { return m_obj; } \
operator id<MTL##name>() const { \
return m_obj; \
} \
id<MTL##name> m_obj; \
};
@ -950,7 +952,9 @@ void *owned(id p_id) {
}
#define MAKE_ID(FROM, TO) \
_FORCE_INLINE_ TO make(FROM p_obj) { return TO(owned(p_obj)); }
_FORCE_INLINE_ TO make(FROM p_obj) { \
return TO(owned(p_obj)); \
}
MAKE_ID(id<MTLTexture>, RDD::TextureID)
MAKE_ID(id<MTLBuffer>, RDD::BufferID)

View file

@ -53,11 +53,15 @@ void clear(Tv &p_value, Tm p_mask) {
/*! Returns whether the specified value has any of the bits specified in mask set to 1. */
template <typename Tv, typename Tm>
static constexpr bool any(Tv p_value, const Tm p_mask) { return ((p_value & p_mask) != 0); }
static constexpr bool any(Tv p_value, const Tm p_mask) {
return ((p_value & p_mask) != 0);
}
/*! Returns whether the specified value has all of the bits specified in mask set to 1. */
template <typename Tv, typename Tm>
static constexpr bool all(Tv p_value, const Tm p_mask) { return ((p_value & p_mask) == p_mask); }
static constexpr bool all(Tv p_value, const Tm p_mask) {
return ((p_value & p_mask) == p_mask);
}
} //namespace flags

View file

@ -34,8 +34,12 @@
#include "servers/rendering/rendering_device.h"
#define RD_SETGET(m_type, m_member) \
void set_##m_member(m_type p_##m_member) { base.m_member = p_##m_member; } \
m_type get_##m_member() const { return base.m_member; }
void set_##m_member(m_type p_##m_member) { \
base.m_member = p_##m_member; \
} \
m_type get_##m_member() const { \
return base.m_member; \
}
#define RD_BIND(m_variant_type, m_class, m_member) \
ClassDB::bind_method(D_METHOD("set_" _MKSTR(m_member), "p_" _MKSTR(member)), &m_class::set_##m_member); \
@ -43,8 +47,12 @@
ADD_PROPERTY(PropertyInfo(m_variant_type, #m_member), "set_" _MKSTR(m_member), "get_" _MKSTR(m_member))
#define RD_SETGET_SUB(m_type, m_sub, m_member) \
void set_##m_sub##_##m_member(m_type p_##m_member) { base.m_sub.m_member = p_##m_member; } \
m_type get_##m_sub##_##m_member() const { return base.m_sub.m_member; }
void set_##m_sub##_##m_member(m_type p_##m_member) { \
base.m_sub.m_member = p_##m_member; \
} \
m_type get_##m_sub##_##m_member() const { \
return base.m_sub.m_member; \
}
#define RD_BIND_SUB(m_variant_type, m_class, m_sub, m_member) \
ClassDB::bind_method(D_METHOD("set_" _MKSTR(m_sub) "_" _MKSTR(m_member), "p_" _MKSTR(member)), &m_class::set_##m_sub##_##m_member); \

View file

@ -127,14 +127,22 @@ public:
#define DEFINE_ID(m_name) \
struct m_name##ID : public ID { \
_ALWAYS_INLINE_ explicit operator bool() const { return id != 0; } \
_ALWAYS_INLINE_ explicit operator bool() const { \
return id != 0; \
} \
_ALWAYS_INLINE_ m_name##ID &operator=(m_name##ID p_other) { \
id = p_other.id; \
return *this; \
} \
_ALWAYS_INLINE_ bool operator<(const m_name##ID &p_other) const { return id < p_other.id; } \
_ALWAYS_INLINE_ bool operator==(const m_name##ID &p_other) const { return id == p_other.id; } \
_ALWAYS_INLINE_ bool operator!=(const m_name##ID &p_other) const { return id != p_other.id; } \
_ALWAYS_INLINE_ bool operator<(const m_name##ID &p_other) const { \
return id < p_other.id; \
} \
_ALWAYS_INLINE_ bool operator==(const m_name##ID &p_other) const { \
return id == p_other.id; \
} \
_ALWAYS_INLINE_ bool operator!=(const m_name##ID &p_other) const { \
return id != p_other.id; \
} \
_ALWAYS_INLINE_ m_name##ID(const m_name##ID &p_other) : ID(p_other.id) {} \
_ALWAYS_INLINE_ explicit m_name##ID(uint64_t p_int) : ID(p_int) {} \
_ALWAYS_INLINE_ explicit m_name##ID(void *p_ptr) : ID((uint64_t)p_ptr) {} \