Core: Change BitField int to unsigned

pull/1517/head
Thaddeus Crews 2024-07-12 10:11:09 -05:00
parent 53b546e1df
commit 071aec5f20
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
2 changed files with 7 additions and 7 deletions

View File

@ -68,17 +68,17 @@ namespace godot {
template <> \ template <> \
struct VariantCaster<BitField<m_enum>> { \ struct VariantCaster<BitField<m_enum>> { \
static _FORCE_INLINE_ BitField<m_enum> cast(const Variant &p_variant) { \ static _FORCE_INLINE_ BitField<m_enum> cast(const Variant &p_variant) { \
return BitField<m_enum>(p_variant.operator int64_t()); \ return BitField<m_enum>(p_variant.operator uint64_t()); \
} \ } \
}; \ }; \
template <> \ template <> \
struct PtrToArg<BitField<m_enum>> { \ struct PtrToArg<BitField<m_enum>> { \
_FORCE_INLINE_ static BitField<m_enum> convert(const void *p_ptr) { \ _FORCE_INLINE_ static BitField<m_enum> convert(const void *p_ptr) { \
return BitField<m_enum>(*reinterpret_cast<const int64_t *>(p_ptr)); \ return BitField<m_enum>(*reinterpret_cast<const uint64_t *>(p_ptr)); \
} \ } \
typedef int64_t EncodeT; \ typedef uint64_t EncodeT; \
_FORCE_INLINE_ static void encode(BitField<m_enum> p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(BitField<m_enum> p_val, void *p_ptr) { \
*reinterpret_cast<int64_t *>(p_ptr) = p_val; \ *reinterpret_cast<uint64_t *>(p_ptr) = p_val; \
} \ } \
}; \ }; \
} }

View File

@ -260,14 +260,14 @@ inline StringName _gde_constant_get_enum_name(T param, StringName p_constant) {
template <typename T> template <typename T>
class BitField { class BitField {
int64_t value = 0; uint64_t value = 0;
public: public:
_FORCE_INLINE_ void set_flag(T p_flag) { value |= p_flag; } _FORCE_INLINE_ void set_flag(T p_flag) { value |= p_flag; }
_FORCE_INLINE_ bool has_flag(T p_flag) const { return value & p_flag; } _FORCE_INLINE_ bool has_flag(T p_flag) const { return value & p_flag; }
_FORCE_INLINE_ void clear_flag(T p_flag) { value &= ~p_flag; } _FORCE_INLINE_ void clear_flag(T p_flag) { value &= ~p_flag; }
_FORCE_INLINE_ BitField(int64_t p_value) { value = p_value; } _FORCE_INLINE_ BitField(uint64_t p_value) { value = p_value; }
_FORCE_INLINE_ operator int64_t() const { return value; } _FORCE_INLINE_ operator uint64_t() const { return value; }
_FORCE_INLINE_ operator Variant() const { return value; } _FORCE_INLINE_ operator Variant() const { return value; }
}; };