Update typed array API to match "GDScript: Fix typed arrays".
This commit is contained in:
@@ -39,14 +39,9 @@ namespace godot {
|
||||
template <class T>
|
||||
class TypedArray : public Array {
|
||||
public:
|
||||
template <class U>
|
||||
_FORCE_INLINE_ void operator=(const TypedArray<U> &p_array) {
|
||||
static_assert(__is_base_of(T, U));
|
||||
typed_assign(p_array);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
||||
typed_assign(p_array);
|
||||
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type.");
|
||||
_ref(p_array);
|
||||
}
|
||||
_FORCE_INLINE_ TypedArray(const Variant &p_variant) :
|
||||
Array(p_variant.operator Array(), Variant::OBJECT, T::get_class_static(), Variant()) {
|
||||
@@ -61,22 +56,23 @@ public:
|
||||
|
||||
// specialization for the rest of variant types
|
||||
|
||||
#define MAKE_TYPED_ARRAY(m_type, m_variant_type) \
|
||||
template <> \
|
||||
class TypedArray<m_type> : public Array { \
|
||||
public: \
|
||||
_FORCE_INLINE_ void operator=(const Array &p_array) { \
|
||||
typed_assign(p_array); \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray(const Variant &p_variant) : \
|
||||
Array(p_variant.operator Array(), m_variant_type, StringName(), Variant()) { \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray(const Array &p_array) : \
|
||||
Array(p_array, m_variant_type, StringName(), Variant()) { \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray() { \
|
||||
set_typed(m_variant_type, StringName(), Variant()); \
|
||||
} \
|
||||
#define MAKE_TYPED_ARRAY(m_type, m_variant_type) \
|
||||
template <> \
|
||||
class TypedArray<m_type> : public Array { \
|
||||
public: \
|
||||
_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."); \
|
||||
_ref(p_array); \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray(const Variant &p_variant) : \
|
||||
Array(p_variant.operator Array(), m_variant_type, StringName(), Variant()) { \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray(const Array &p_array) : \
|
||||
Array(p_array, m_variant_type, StringName(), Variant()) { \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray() { \
|
||||
set_typed(m_variant_type, StringName(), Variant()); \
|
||||
} \
|
||||
};
|
||||
|
||||
MAKE_TYPED_ARRAY(bool, Variant::BOOL)
|
||||
|
||||
Reference in New Issue
Block a user