Typed array equality operator logic updated
• Instead of calling to `_ref`, the same effect is achieved by calling to the base class assignment operator • No longer need to be expose `_ref`; set back to private & remove reference from gdextension_interface
This commit is contained in:
@ -1277,11 +1277,13 @@ static GDExtensionVariantPtr gdextension_array_operator_index_const(GDExtensionC
|
|||||||
return (GDExtensionVariantPtr)&self->operator[](p_index);
|
return (GDExtensionVariantPtr)&self->operator[](p_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
void gdextension_array_ref(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from) {
|
void gdextension_array_ref(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from) {
|
||||||
Array *self = (Array *)p_self;
|
Array *self = (Array *)p_self;
|
||||||
const Array *from = (const Array *)p_from;
|
const Array *from = (const Array *)p_from;
|
||||||
self->_ref(*from);
|
self->Array::operator=(*from);
|
||||||
}
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void gdextension_array_set_typed(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script) {
|
void gdextension_array_set_typed(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script) {
|
||||||
Array *self = reinterpret_cast<Array *>(p_self);
|
Array *self = reinterpret_cast<Array *>(p_self);
|
||||||
@ -1798,7 +1800,9 @@ void gdextension_setup_interface() {
|
|||||||
REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index_const);
|
REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index_const);
|
||||||
REGISTER_INTERFACE_FUNC(array_operator_index);
|
REGISTER_INTERFACE_FUNC(array_operator_index);
|
||||||
REGISTER_INTERFACE_FUNC(array_operator_index_const);
|
REGISTER_INTERFACE_FUNC(array_operator_index_const);
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
REGISTER_INTERFACE_FUNC(array_ref);
|
REGISTER_INTERFACE_FUNC(array_ref);
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
REGISTER_INTERFACE_FUNC(array_set_typed);
|
REGISTER_INTERFACE_FUNC(array_set_typed);
|
||||||
REGISTER_INTERFACE_FUNC(dictionary_operator_index);
|
REGISTER_INTERFACE_FUNC(dictionary_operator_index);
|
||||||
REGISTER_INTERFACE_FUNC(dictionary_operator_index_const);
|
REGISTER_INTERFACE_FUNC(dictionary_operator_index_const);
|
||||||
|
|||||||
@ -2386,6 +2386,7 @@ typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDE
|
|||||||
/**
|
/**
|
||||||
* @name array_ref
|
* @name array_ref
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
|
* @deprecated in Godot 4.5. use `Array::operator=` instead.
|
||||||
*
|
*
|
||||||
* Sets an Array to be a reference to another Array object.
|
* Sets an Array to be a reference to another Array object.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -44,6 +44,7 @@ struct ContainerType;
|
|||||||
|
|
||||||
class Array {
|
class Array {
|
||||||
mutable ArrayPrivate *_p;
|
mutable ArrayPrivate *_p;
|
||||||
|
void _ref(const Array &p_from) const;
|
||||||
void _unref() const;
|
void _unref() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -109,8 +110,6 @@ public:
|
|||||||
ConstIterator begin() const;
|
ConstIterator begin() const;
|
||||||
ConstIterator end() const;
|
ConstIterator end() const;
|
||||||
|
|
||||||
void _ref(const Array &p_from) const;
|
|
||||||
|
|
||||||
Variant &operator[](int p_idx);
|
Variant &operator[](int p_idx);
|
||||||
const Variant &operator[](int p_idx) const;
|
const Variant &operator[](int p_idx) const;
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ class TypedArray : public Array {
|
|||||||
public:
|
public:
|
||||||
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
||||||
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type.");
|
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type.");
|
||||||
_ref(p_array);
|
Array::operator=(p_array);
|
||||||
}
|
}
|
||||||
_FORCE_INLINE_ TypedArray(const Variant &p_variant) :
|
_FORCE_INLINE_ TypedArray(const Variant &p_variant) :
|
||||||
TypedArray(Array(p_variant)) {
|
TypedArray(Array(p_variant)) {
|
||||||
@ -50,7 +50,7 @@ public:
|
|||||||
_FORCE_INLINE_ TypedArray(const Array &p_array) {
|
_FORCE_INLINE_ TypedArray(const Array &p_array) {
|
||||||
set_typed(Variant::OBJECT, T::get_class_static(), Variant());
|
set_typed(Variant::OBJECT, T::get_class_static(), Variant());
|
||||||
if (is_same_typed(p_array)) {
|
if (is_same_typed(p_array)) {
|
||||||
_ref(p_array);
|
Array::operator=(p_array);
|
||||||
} else {
|
} else {
|
||||||
assign(p_array);
|
assign(p_array);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ struct VariantInternalAccessor<const TypedArray<T> &> {
|
|||||||
public: \
|
public: \
|
||||||
_FORCE_INLINE_ void operator=(const Array &p_array) { \
|
_FORCE_INLINE_ void operator=(const Array &p_array) { \
|
||||||
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); \
|
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); \
|
||||||
_ref(p_array); \
|
Array::operator=(p_array); \
|
||||||
} \
|
} \
|
||||||
_FORCE_INLINE_ TypedArray(std::initializer_list<Variant> p_init) : \
|
_FORCE_INLINE_ TypedArray(std::initializer_list<Variant> p_init) : \
|
||||||
Array(Array(p_init), m_variant_type, StringName(), Variant()) { \
|
Array(Array(p_init), m_variant_type, StringName(), Variant()) { \
|
||||||
@ -92,7 +92,7 @@ struct VariantInternalAccessor<const TypedArray<T> &> {
|
|||||||
_FORCE_INLINE_ TypedArray(const Array &p_array) { \
|
_FORCE_INLINE_ TypedArray(const Array &p_array) { \
|
||||||
set_typed(m_variant_type, StringName(), Variant()); \
|
set_typed(m_variant_type, StringName(), Variant()); \
|
||||||
if (is_same_typed(p_array)) { \
|
if (is_same_typed(p_array)) { \
|
||||||
_ref(p_array); \
|
Array::operator=(p_array); \
|
||||||
} else { \
|
} else { \
|
||||||
assign(p_array); \
|
assign(p_array); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
Reference in New Issue
Block a user