diff options
Diffstat (limited to 'core/variant.h')
-rw-r--r-- | core/variant.h | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/core/variant.h b/core/variant.h index 06be914408..51f23b4b49 100644 --- a/core/variant.h +++ b/core/variant.h @@ -44,12 +44,11 @@ #include "core/math/transform_2d.h" #include "core/math/vector3.h" #include "core/node_path.h" -#include "core/pool_vector.h" -#include "core/ref_ptr.h" +#include "core/object_id.h" + #include "core/rid.h" #include "core/ustring.h" -class RefPtr; class Object; class Node; // helper class Control; // helper @@ -57,13 +56,13 @@ class Control; // helper struct PropertyInfo; struct MethodInfo; -typedef PoolVector<uint8_t> PoolByteArray; -typedef PoolVector<int> PoolIntArray; -typedef PoolVector<real_t> PoolRealArray; -typedef PoolVector<String> PoolStringArray; -typedef PoolVector<Vector2> PoolVector2Array; -typedef PoolVector<Vector3> PoolVector3Array; -typedef PoolVector<Color> PoolColorArray; +typedef Vector<uint8_t> PackedByteArray; +typedef Vector<int> PackedIntArray; +typedef Vector<real_t> PackedRealArray; +typedef Vector<String> PackedStringArray; +typedef Vector<Vector2> PackedVector2Array; +typedef Vector<Vector3> PackedVector3Array; +typedef Vector<Color> PackedColorArray; // Temporary workaround until c++11 alignas() #ifdef __GNUC__ @@ -106,13 +105,13 @@ public: ARRAY, // arrays - POOL_BYTE_ARRAY, // 20 - POOL_INT_ARRAY, - POOL_REAL_ARRAY, - POOL_STRING_ARRAY, - POOL_VECTOR2_ARRAY, - POOL_VECTOR3_ARRAY, // 25 - POOL_COLOR_ARRAY, + PACKED_BYTE_ARRAY, // 20 + PACKED_INT_ARRAY, + PACKED_REAL_ARRAY, + PACKED_STRING_ARRAY, + PACKED_VECTOR2_ARRAY, + PACKED_VECTOR3_ARRAY, // 25 + PACKED_COLOR_ARRAY, VARIANT_MAX @@ -127,12 +126,12 @@ private: struct ObjData { + ObjectID id; Object *obj; - RefPtr ref; }; - _FORCE_INLINE_ ObjData &_get_obj(); - _FORCE_INLINE_ const ObjData &_get_obj() const; + _ALWAYS_INLINE_ ObjData &_get_obj(); + _ALWAYS_INLINE_ const ObjData &_get_obj() const; union { bool _bool; @@ -161,6 +160,7 @@ public: bool is_shared() const; bool is_zero() const; bool is_one() const; + bool is_null() const; operator bool() const; operator signed int() const; @@ -177,6 +177,8 @@ public: operator unsigned long() const; #endif + operator ObjectID() const; + operator CharType() const; operator float() const; operator double() const; @@ -194,7 +196,6 @@ public: operator Color() const; operator NodePath() const; - operator RefPtr() const; operator RID() const; operator Object *() const; @@ -204,27 +205,19 @@ public: operator Dictionary() const; operator Array() const; - operator PoolVector<uint8_t>() const; - operator PoolVector<int>() const; - operator PoolVector<real_t>() const; - operator PoolVector<String>() const; - operator PoolVector<Vector3>() const; - operator PoolVector<Color>() const; - operator PoolVector<Plane>() const; - operator PoolVector<Face3>() const; - - operator Vector<Variant>() const; operator Vector<uint8_t>() const; operator Vector<int>() const; operator Vector<real_t>() const; operator Vector<String>() const; - operator Vector<StringName>() const; operator Vector<Vector3>() const; operator Vector<Color>() const; + operator Vector<Plane>() const; + operator Vector<Face3>() const; + + operator Vector<Variant>() const; + operator Vector<StringName>() const; operator Vector<RID>() const; operator Vector<Vector2>() const; - operator PoolVector<Vector2>() const; - operator Vector<Plane>() const; // some core type enums to convert to operator Margin() const; @@ -232,6 +225,9 @@ public: operator IP_Address() const; + Object *get_validated_object() const; + Object *get_validated_object_with_check(bool &r_previously_freed) const; + Variant(bool p_bool); Variant(signed int p_int); // real one Variant(unsigned int p_int); @@ -248,6 +244,7 @@ public: Variant(uint64_t p_int); Variant(float p_float); Variant(double p_double); + Variant(const ObjectID &p_id); Variant(const String &p_string); Variant(const StringName &p_string); Variant(const char *const p_cstring); @@ -263,33 +260,24 @@ public: Variant(const Transform &p_transform); Variant(const Color &p_color); Variant(const NodePath &p_node_path); - Variant(const RefPtr &p_resource); Variant(const RID &p_rid); Variant(const Object *p_object); Variant(const Dictionary &p_dictionary); Variant(const Array &p_array); - Variant(const PoolVector<Plane> &p_array); // helper - Variant(const PoolVector<uint8_t> &p_raw_array); - Variant(const PoolVector<int> &p_int_array); - Variant(const PoolVector<real_t> &p_real_array); - Variant(const PoolVector<String> &p_string_array); - Variant(const PoolVector<Vector3> &p_vector3_array); - Variant(const PoolVector<Color> &p_color_array); - Variant(const PoolVector<Face3> &p_face_array); + Variant(const Vector<Plane> &p_array); // helper + Variant(const Vector<uint8_t> &p_raw_array); + Variant(const Vector<int> &p_int_array); + Variant(const Vector<real_t> &p_real_array); + Variant(const Vector<String> &p_string_array); + Variant(const Vector<Vector3> &p_vector3_array); + Variant(const Vector<Color> &p_color_array); + Variant(const Vector<Face3> &p_face_array); Variant(const Vector<Variant> &p_array); - Variant(const Vector<uint8_t> &p_array); - Variant(const Vector<int> &p_array); - Variant(const Vector<real_t> &p_array); - Variant(const Vector<String> &p_array); Variant(const Vector<StringName> &p_array); - Variant(const Vector<Vector3> &p_array); - Variant(const Vector<Color> &p_array); - Variant(const Vector<Plane> &p_array); // helper Variant(const Vector<RID> &p_array); // helper Variant(const Vector<Vector2> &p_array); // helper - Variant(const PoolVector<Vector2> &p_vector2_array); // helper Variant(const IP_Address &p_address); |