Skip to content

Commit

Permalink
Merge pull request #100937 from Repiteo/style/clang-format-sync
Browse files Browse the repository at this point in the history
Style: Enforce `AllowShortFunctionsOnASingleLine`
  • Loading branch information
akien-mga committed Jan 2, 2025
2 parents 88babbd + 2c9620f commit 21e6671
Show file tree
Hide file tree
Showing 16 changed files with 614 additions and 405 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ b37fc1014abf7adda70dc30b0822d775b3a4433f

# Style: Apply clang-tidy fixes (superficial)
bb5f390fb9b466be35a5df7651323d7e66afca31

# Style: Enforce `AllowShortFunctionsOnASingleLine`
e06d83860d798b6766b23d6eae48557387a7db85
14 changes: 9 additions & 5 deletions core/io/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@

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; } \
\
#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; \
} \
\
private:

class Resource : public RefCounted {
Expand Down
342 changes: 173 additions & 169 deletions core/object/object.h

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion core/os/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
190 changes: 127 additions & 63 deletions core/templates/pass_func.h

Large diffs are not rendered by default.

116 changes: 64 additions & 52 deletions core/variant/binder_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,60 +82,72 @@ struct VariantCaster<const T &> {
}
};

#define VARIANT_ENUM_CAST(m_enum) \
MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
return (m_enum)p_variant.operator int64_t(); \
} \
}; \
template <> \
struct PtrToArg<m_enum> { \
_FORCE_INLINE_ static m_enum convert(const void *p_ptr) { \
return m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \
typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(m_enum p_val, const void *p_ptr) { \
*(int64_t *)p_ptr = (int64_t)p_val; \
} \
}; \
template <> \
struct ZeroInitializer<m_enum> { \
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; } \
#define VARIANT_ENUM_CAST(m_enum) \
MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
return (m_enum)p_variant.operator int64_t(); \
} \
}; \
template <> \
struct PtrToArg<m_enum> { \
_FORCE_INLINE_ static m_enum convert(const void *p_ptr) { \
return m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \
typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(m_enum p_val, const void *p_ptr) { \
*(int64_t *)p_ptr = (int64_t)p_val; \
} \
}; \
template <> \
struct ZeroInitializer<m_enum> { \
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; \
} \
};

#define VARIANT_BITFIELD_CAST(m_enum) \
MAKE_BITFIELD_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<BitField<m_enum>> { \
static _FORCE_INLINE_ BitField<m_enum> cast(const Variant &p_variant) { \
return BitField<m_enum>(p_variant.operator int64_t()); \
} \
}; \
template <> \
struct PtrToArg<BitField<m_enum>> { \
_FORCE_INLINE_ static BitField<m_enum> convert(const void *p_ptr) { \
return BitField<m_enum>(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \
typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(BitField<m_enum> p_val, const void *p_ptr) { \
*(int64_t *)p_ptr = p_val; \
} \
}; \
template <> \
struct ZeroInitializer<BitField<m_enum>> { \
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(); } \
#define VARIANT_BITFIELD_CAST(m_enum) \
MAKE_BITFIELD_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<BitField<m_enum>> { \
static _FORCE_INLINE_ BitField<m_enum> cast(const Variant &p_variant) { \
return BitField<m_enum>(p_variant.operator int64_t()); \
} \
}; \
template <> \
struct PtrToArg<BitField<m_enum>> { \
_FORCE_INLINE_ static BitField<m_enum> convert(const void *p_ptr) { \
return BitField<m_enum>(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \
typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(BitField<m_enum> p_val, const void *p_ptr) { \
*(int64_t *)p_ptr = p_val; \
} \
}; \
template <> \
struct ZeroInitializer<BitField<m_enum>> { \
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(); \
} \
};

// Object enum casts must go here
Expand Down
Loading

0 comments on commit 21e6671

Please sign in to comment.