diff options
Diffstat (limited to 'core/variant.cpp')
-rw-r--r-- | core/variant.cpp | 476 |
1 files changed, 0 insertions, 476 deletions
diff --git a/core/variant.cpp b/core/variant.cpp index 162d409026..b2bb7fe309 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -41,172 +41,136 @@ #include "scene/main/node.h" String Variant::get_type_name(Variant::Type p_type) { - switch (p_type) { case NIL: { - return "Nil"; } break; // atomic types case BOOL: { - return "bool"; } break; case INT: { - return "int"; } break; case FLOAT: { - return "float"; } break; case STRING: { - return "String"; } break; // math types case VECTOR2: { - return "Vector2"; } break; case VECTOR2I: { - return "Vector2i"; } break; case RECT2: { - return "Rect2"; } break; case RECT2I: { - return "Rect2i"; } break; case TRANSFORM2D: { - return "Transform2D"; } break; case VECTOR3: { - return "Vector3"; } break; case VECTOR3I: { - return "Vector3i"; } break; case PLANE: { - return "Plane"; } break; case AABB: { - return "AABB"; } break; case QUAT: { - return "Quat"; } break; case BASIS: { - return "Basis"; } break; case TRANSFORM: { - return "Transform"; } break; // misc types case COLOR: { - return "Color"; } break; case _RID: { - return "RID"; } break; case OBJECT: { - return "Object"; } break; case CALLABLE: { - return "Callable"; } break; case SIGNAL: { - return "Signal"; } break; case STRING_NAME: { - return "StringName"; } break; case NODE_PATH: { - return "NodePath"; } break; case DICTIONARY: { - return "Dictionary"; } break; case ARRAY: { - return "Array"; } break; // arrays case PACKED_BYTE_ARRAY: { - return "PackedByteArray"; } break; case PACKED_INT32_ARRAY: { - return "PackedInt32Array"; } break; case PACKED_INT64_ARRAY: { - return "PackedInt64Array"; } break; case PACKED_FLOAT32_ARRAY: { - return "PackedFloat32Array"; } break; case PACKED_FLOAT64_ARRAY: { - return "PackedFloat64Array"; } break; case PACKED_STRING_ARRAY: { - return "PackedStringArray"; } break; case PACKED_VECTOR2_ARRAY: { - return "PackedVector2Array"; } break; case PACKED_VECTOR3_ARRAY: { - return "PackedVector3Array"; } break; case PACKED_COLOR_ARRAY: { - return "PackedColorArray"; } break; @@ -218,7 +182,6 @@ String Variant::get_type_name(Variant::Type p_type) { } bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { - if (p_type_from == p_type_to) return true; if (p_type_to == NIL && p_type_from != NIL) //nil can convert to anything @@ -233,7 +196,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { switch (p_type_to) { case BOOL: { - static const Type valid[] = { INT, FLOAT, @@ -244,7 +206,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case INT: { - static const Type valid[] = { BOOL, FLOAT, @@ -256,7 +217,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case FLOAT: { - static const Type valid[] = { BOOL, INT, @@ -268,7 +228,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case STRING: { - static const Type invalid[] = { OBJECT, NIL @@ -277,7 +236,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { invalid_types = invalid; } break; case VECTOR2: { - static const Type valid[] = { VECTOR2I, NIL, @@ -287,7 +245,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case VECTOR2I: { - static const Type valid[] = { VECTOR2, NIL, @@ -297,7 +254,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case RECT2: { - static const Type valid[] = { RECT2I, NIL, @@ -307,7 +263,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case RECT2I: { - static const Type valid[] = { RECT2, NIL, @@ -317,7 +272,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case TRANSFORM2D: { - static const Type valid[] = { TRANSFORM, NIL @@ -326,7 +280,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case VECTOR3: { - static const Type valid[] = { VECTOR3I, NIL, @@ -336,7 +289,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case VECTOR3I: { - static const Type valid[] = { VECTOR3, NIL, @@ -347,7 +299,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case QUAT: { - static const Type valid[] = { BASIS, NIL @@ -357,7 +308,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case BASIS: { - static const Type valid[] = { QUAT, VECTOR3, @@ -368,7 +318,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case TRANSFORM: { - static const Type valid[] = { TRANSFORM2D, QUAT, @@ -381,7 +330,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case COLOR: { - static const Type valid[] = { STRING, INT, @@ -393,7 +341,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case _RID: { - static const Type valid[] = { OBJECT, NIL @@ -402,7 +349,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case OBJECT: { - static const Type valid[] = { NIL }; @@ -410,7 +356,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case STRING_NAME: { - static const Type valid[] = { STRING, NIL @@ -419,7 +364,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case NODE_PATH: { - static const Type valid[] = { STRING, NIL @@ -428,7 +372,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case ARRAY: { - static const Type valid[] = { PACKED_BYTE_ARRAY, PACKED_INT32_ARRAY, @@ -446,7 +389,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; // arrays case PACKED_BYTE_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -455,7 +397,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_INT32_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -463,7 +404,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_INT64_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -471,7 +411,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_FLOAT32_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -480,7 +419,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_FLOAT64_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -489,7 +427,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_STRING_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -497,7 +434,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; case PACKED_VECTOR2_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -506,7 +442,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case PACKED_VECTOR3_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -515,7 +450,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case PACKED_COLOR_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -529,20 +463,16 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } if (valid_types) { - int i = 0; while (valid_types[i] != NIL) { - if (p_type_from == valid_types[i]) return true; i++; } } else if (invalid_types) { - int i = 0; while (invalid_types[i] != NIL) { - if (p_type_from == invalid_types[i]) return false; i++; @@ -555,7 +485,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type_to) { - if (p_type_from == p_type_to) return true; if (p_type_to == NIL && p_type_from != NIL) //nil can convert to anything @@ -569,7 +498,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type switch (p_type_to) { case BOOL: { - static const Type valid[] = { INT, FLOAT, @@ -580,7 +508,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case INT: { - static const Type valid[] = { BOOL, FLOAT, @@ -592,7 +519,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case FLOAT: { - static const Type valid[] = { BOOL, INT, @@ -604,7 +530,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case STRING: { - static const Type valid[] = { NODE_PATH, STRING_NAME, @@ -614,7 +539,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case VECTOR2: { - static const Type valid[] = { VECTOR2I, NIL, @@ -624,7 +548,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case VECTOR2I: { - static const Type valid[] = { VECTOR2, NIL, @@ -634,7 +557,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case RECT2: { - static const Type valid[] = { RECT2I, NIL, @@ -644,7 +566,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case RECT2I: { - static const Type valid[] = { RECT2, NIL, @@ -654,7 +575,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case TRANSFORM2D: { - static const Type valid[] = { TRANSFORM, NIL @@ -663,7 +583,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case VECTOR3: { - static const Type valid[] = { VECTOR3I, NIL, @@ -673,7 +592,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case VECTOR3I: { - static const Type valid[] = { VECTOR3, NIL, @@ -684,7 +602,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case QUAT: { - static const Type valid[] = { BASIS, NIL @@ -694,7 +611,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case BASIS: { - static const Type valid[] = { QUAT, VECTOR3, @@ -705,7 +621,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case TRANSFORM: { - static const Type valid[] = { TRANSFORM2D, QUAT, @@ -718,7 +633,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case COLOR: { - static const Type valid[] = { STRING, INT, @@ -730,7 +644,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case _RID: { - static const Type valid[] = { OBJECT, NIL @@ -739,7 +652,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case OBJECT: { - static const Type valid[] = { NIL }; @@ -747,7 +659,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case STRING_NAME: { - static const Type valid[] = { STRING, NIL @@ -756,7 +667,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case NODE_PATH: { - static const Type valid[] = { STRING, NIL @@ -765,7 +675,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case ARRAY: { - static const Type valid[] = { PACKED_BYTE_ARRAY, PACKED_INT32_ARRAY, @@ -783,7 +692,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; // arrays case PACKED_BYTE_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -792,7 +700,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_INT32_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -800,7 +707,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_INT64_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -808,7 +714,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_FLOAT32_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -817,7 +722,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_FLOAT64_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -826,7 +730,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_STRING_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -834,7 +737,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; case PACKED_VECTOR2_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -843,7 +745,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case PACKED_VECTOR3_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -852,7 +753,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case PACKED_COLOR_ARRAY: { - static const Type valid[] = { ARRAY, NIL @@ -866,10 +766,8 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } if (valid_types) { - int i = 0; while (valid_types[i] != NIL) { - if (p_type_from == valid_types[i]) return true; i++; @@ -880,7 +778,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } bool Variant::operator==(const Variant &p_variant) const { - if (type != p_variant.type) //evaluation of operator== needs to be more strict return false; bool v; @@ -890,7 +787,6 @@ bool Variant::operator==(const Variant &p_variant) const { } bool Variant::operator!=(const Variant &p_variant) const { - if (type != p_variant.type) //evaluation of operator== needs to be more strict return true; bool v; @@ -909,72 +805,58 @@ bool Variant::operator<(const Variant &p_variant) const { } bool Variant::is_zero() const { - switch (type) { case NIL: { - return true; } break; // atomic types case BOOL: { - return !(_data._bool); } break; case INT: { - return _data._int == 0; } break; case FLOAT: { - return _data._float == 0; } break; case STRING: { - return *reinterpret_cast<const String *>(_data._mem) == String(); } break; // math types case VECTOR2: { - return *reinterpret_cast<const Vector2 *>(_data._mem) == Vector2(); } break; case VECTOR2I: { - return *reinterpret_cast<const Vector2i *>(_data._mem) == Vector2i(); } break; case RECT2: { - return *reinterpret_cast<const Rect2 *>(_data._mem) == Rect2(); } break; case RECT2I: { - return *reinterpret_cast<const Rect2i *>(_data._mem) == Rect2i(); } break; case TRANSFORM2D: { - return *_data._transform2d == Transform2D(); } break; case VECTOR3: { - return *reinterpret_cast<const Vector3 *>(_data._mem) == Vector3(); } break; case VECTOR3I: { - return *reinterpret_cast<const Vector3i *>(_data._mem) == Vector3i(); } break; case PLANE: { - return *reinterpret_cast<const Plane *>(_data._mem) == Plane(); } break; @@ -984,111 +866,89 @@ bool Variant::is_zero() const { } break;*/ case AABB: { - return *_data._aabb == ::AABB(); } break; case QUAT: { - return *reinterpret_cast<const Quat *>(_data._mem) == Quat(); } break; case BASIS: { - return *_data._basis == Basis(); } break; case TRANSFORM: { - return *_data._transform == Transform(); } break; // misc types case COLOR: { - return *reinterpret_cast<const Color *>(_data._mem) == Color(); } break; case _RID: { - return *reinterpret_cast<const RID *>(_data._mem) == RID(); } break; case OBJECT: { - return _get_obj().obj == nullptr; } break; case CALLABLE: { - return reinterpret_cast<const Callable *>(_data._mem)->is_null(); } break; case SIGNAL: { - return reinterpret_cast<const Signal *>(_data._mem)->is_null(); } break; case STRING_NAME: { - return *reinterpret_cast<const StringName *>(_data._mem) != StringName(); } break; case NODE_PATH: { - return reinterpret_cast<const NodePath *>(_data._mem)->is_empty(); } break; case DICTIONARY: { - return reinterpret_cast<const Dictionary *>(_data._mem)->empty(); } break; case ARRAY: { - return reinterpret_cast<const Array *>(_data._mem)->empty(); } break; // arrays case PACKED_BYTE_ARRAY: { - return PackedArrayRef<uint8_t>::get_array(_data.packed_array).size() == 0; } break; case PACKED_INT32_ARRAY: { - return PackedArrayRef<int32_t>::get_array(_data.packed_array).size() == 0; } break; case PACKED_INT64_ARRAY: { - return PackedArrayRef<int64_t>::get_array(_data.packed_array).size() == 0; } break; case PACKED_FLOAT32_ARRAY: { - return PackedArrayRef<float>::get_array(_data.packed_array).size() == 0; } break; case PACKED_FLOAT64_ARRAY: { - return PackedArrayRef<double>::get_array(_data.packed_array).size() == 0; } break; case PACKED_STRING_ARRAY: { - return PackedArrayRef<String>::get_array(_data.packed_array).size() == 0; } break; case PACKED_VECTOR2_ARRAY: { - return PackedArrayRef<Vector2>::get_array(_data.packed_array).size() == 0; } break; case PACKED_VECTOR3_ARRAY: { - return PackedArrayRef<Vector3>::get_array(_data.packed_array).size() == 0; } break; case PACKED_COLOR_ARRAY: { - return PackedArrayRef<Color>::get_array(_data.packed_array).size() == 0; } break; @@ -1100,65 +960,52 @@ bool Variant::is_zero() const { } bool Variant::is_one() const { - switch (type) { case NIL: { - return true; } break; // atomic types case BOOL: { - return _data._bool; } break; case INT: { - return _data._int == 1; } break; case FLOAT: { - return _data._float == 1; } break; case VECTOR2: { - return *reinterpret_cast<const Vector2 *>(_data._mem) == Vector2(1, 1); } break; case VECTOR2I: { - return *reinterpret_cast<const Vector2i *>(_data._mem) == Vector2i(1, 1); } break; case RECT2: { - return *reinterpret_cast<const Rect2 *>(_data._mem) == Rect2(1, 1, 1, 1); } break; case RECT2I: { - return *reinterpret_cast<const Rect2i *>(_data._mem) == Rect2i(1, 1, 1, 1); } break; case VECTOR3: { - return *reinterpret_cast<const Vector3 *>(_data._mem) == Vector3(1, 1, 1); } break; case VECTOR3I: { - return *reinterpret_cast<const Vector3i *>(_data._mem) == Vector3i(1, 1, 1); } break; case PLANE: { - return *reinterpret_cast<const Plane *>(_data._mem) == Plane(1, 1, 1, 1); } break; case COLOR: { - return *reinterpret_cast<const Color *>(_data._mem) == Color(1, 1, 1, 1); } break; @@ -1180,7 +1027,6 @@ bool Variant::is_null() const { } void Variant::reference(const Variant &p_variant) { - switch (type) { case NIL: case BOOL: @@ -1195,93 +1041,73 @@ void Variant::reference(const Variant &p_variant) { switch (p_variant.type) { case NIL: { - // none } break; // atomic types case BOOL: { - _data._bool = p_variant._data._bool; } break; case INT: { - _data._int = p_variant._data._int; } break; case FLOAT: { - _data._float = p_variant._data._float; } break; case STRING: { - memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem))); } break; // math types case VECTOR2: { - memnew_placement(_data._mem, Vector2(*reinterpret_cast<const Vector2 *>(p_variant._data._mem))); } break; case VECTOR2I: { - memnew_placement(_data._mem, Vector2i(*reinterpret_cast<const Vector2i *>(p_variant._data._mem))); } break; case RECT2: { - memnew_placement(_data._mem, Rect2(*reinterpret_cast<const Rect2 *>(p_variant._data._mem))); } break; case RECT2I: { - memnew_placement(_data._mem, Rect2i(*reinterpret_cast<const Rect2i *>(p_variant._data._mem))); } break; case TRANSFORM2D: { - _data._transform2d = memnew(Transform2D(*p_variant._data._transform2d)); } break; case VECTOR3: { - memnew_placement(_data._mem, Vector3(*reinterpret_cast<const Vector3 *>(p_variant._data._mem))); } break; case VECTOR3I: { - memnew_placement(_data._mem, Vector3i(*reinterpret_cast<const Vector3i *>(p_variant._data._mem))); } break; case PLANE: { - memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem))); } break; case AABB: { - _data._aabb = memnew(::AABB(*p_variant._data._aabb)); } break; case QUAT: { - memnew_placement(_data._mem, Quat(*reinterpret_cast<const Quat *>(p_variant._data._mem))); } break; case BASIS: { - _data._basis = memnew(Basis(*p_variant._data._basis)); } break; case TRANSFORM: { - _data._transform = memnew(Transform(*p_variant._data._transform)); } break; // misc types case COLOR: { - memnew_placement(_data._mem, Color(*reinterpret_cast<const Color *>(p_variant._data._mem))); } break; case _RID: { - memnew_placement(_data._mem, RID(*reinterpret_cast<const RID *>(p_variant._data._mem))); } break; case OBJECT: { - memnew_placement(_data._mem, ObjData); if (p_variant._get_obj().obj && p_variant._get_obj().id.is_reference()) { @@ -1298,37 +1124,30 @@ void Variant::reference(const Variant &p_variant) { } break; case CALLABLE: { - memnew_placement(_data._mem, Callable(*reinterpret_cast<const Callable *>(p_variant._data._mem))); } break; case SIGNAL: { - memnew_placement(_data._mem, Signal(*reinterpret_cast<const Signal *>(p_variant._data._mem))); } break; case STRING_NAME: { - memnew_placement(_data._mem, StringName(*reinterpret_cast<const StringName *>(p_variant._data._mem))); } break; case NODE_PATH: { - memnew_placement(_data._mem, NodePath(*reinterpret_cast<const NodePath *>(p_variant._data._mem))); } break; case DICTIONARY: { - memnew_placement(_data._mem, Dictionary(*reinterpret_cast<const Dictionary *>(p_variant._data._mem))); } break; case ARRAY: { - memnew_placement(_data._mem, Array(*reinterpret_cast<const Array *>(p_variant._data._mem))); } break; // arrays case PACKED_BYTE_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<uint8_t> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<uint8_t>::create(); @@ -1336,7 +1155,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_INT32_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<int32_t> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<int32_t>::create(); @@ -1344,7 +1162,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_INT64_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<int64_t> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<int64_t>::create(); @@ -1352,7 +1169,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_FLOAT32_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<float> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<float>::create(); @@ -1360,7 +1176,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_FLOAT64_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<double> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<double>::create(); @@ -1368,7 +1183,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_STRING_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<String> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<String>::create(); @@ -1376,7 +1190,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_VECTOR2_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<Vector2> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<Vector2>::create(); @@ -1384,7 +1197,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_VECTOR3_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<Vector3> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<Vector3>::create(); @@ -1392,7 +1204,6 @@ void Variant::reference(const Variant &p_variant) { } break; case PACKED_COLOR_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<Color> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { _data.packed_array = PackedArrayRef<Color>::create(); @@ -1451,10 +1262,8 @@ void Variant::zero() { } void Variant::clear() { - switch (type) { case STRING: { - reinterpret_cast<String *>(_data._mem)->~String(); } break; /* @@ -1467,33 +1276,26 @@ void Variant::clear() { RECT2 */ case TRANSFORM2D: { - memdelete(_data._transform2d); } break; case AABB: { - memdelete(_data._aabb); } break; case BASIS: { - memdelete(_data._basis); } break; case TRANSFORM: { - memdelete(_data._transform); } break; // misc types case STRING_NAME: { - reinterpret_cast<StringName *>(_data._mem)->~StringName(); } break; case NODE_PATH: { - reinterpret_cast<NodePath *>(_data._mem)->~NodePath(); } break; case OBJECT: { - if (_get_obj().id.is_reference()) { //we are safe that there is a reference here Reference *reference = static_cast<Reference *>(_get_obj().obj); @@ -1509,56 +1311,43 @@ void Variant::clear() { reinterpret_cast<RID *>(_data._mem)->~RID(); } break; case CALLABLE: { - reinterpret_cast<Callable *>(_data._mem)->~Callable(); } break; case SIGNAL: { - reinterpret_cast<Signal *>(_data._mem)->~Signal(); } break; case DICTIONARY: { - reinterpret_cast<Dictionary *>(_data._mem)->~Dictionary(); } break; case ARRAY: { - reinterpret_cast<Array *>(_data._mem)->~Array(); } break; // arrays case PACKED_BYTE_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_INT32_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_INT64_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_FLOAT32_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_FLOAT64_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_STRING_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_VECTOR2_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_VECTOR3_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; case PACKED_COLOR_ARRAY: { - PackedArrayRefBase::destroy(_data.packed_array); } break; default: { @@ -1569,9 +1358,7 @@ void Variant::clear() { } Variant::operator signed int() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1583,15 +1370,12 @@ Variant::operator signed int() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator unsigned int() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1603,16 +1387,13 @@ Variant::operator unsigned int() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator int64_t() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1624,7 +1405,6 @@ Variant::operator int64_t() const { case STRING: return operator String().to_int64(); default: { - return 0; } } @@ -1651,9 +1431,7 @@ Variant::operator long unsigned int() const { */ Variant::operator uint64_t() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1665,7 +1443,6 @@ Variant::operator uint64_t() const { case STRING: return operator String().to_int(); default: { - return 0; } } @@ -1683,9 +1460,7 @@ Variant::operator ObjectID() const { #ifdef NEED_LONG_INT Variant::operator signed long() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1697,7 +1472,6 @@ Variant::operator signed long() const { case STRING: return operator String().to_int(); default: { - return 0; } } @@ -1706,9 +1480,7 @@ Variant::operator signed long() const { }; Variant::operator unsigned long() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1720,7 +1492,6 @@ Variant::operator unsigned long() const { case STRING: return operator String().to_int(); default: { - return 0; } } @@ -1730,9 +1501,7 @@ Variant::operator unsigned long() const { #endif Variant::operator signed short() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1744,15 +1513,12 @@ Variant::operator signed short() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator unsigned short() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1764,15 +1530,12 @@ Variant::operator unsigned short() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator signed char() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1784,15 +1547,12 @@ Variant::operator signed char() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator unsigned char() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1804,21 +1564,17 @@ Variant::operator unsigned char() const { case STRING: return operator String().to_int(); default: { - return 0; } } } Variant::operator CharType() const { - return operator unsigned int(); } Variant::operator float() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1830,15 +1586,12 @@ Variant::operator float() const { case STRING: return operator String().to_double(); default: { - return 0; } } } Variant::operator double() const { - switch (type) { - case NIL: return 0; case BOOL: @@ -1850,14 +1603,12 @@ Variant::operator double() const { case STRING: return operator String().to_double(); default: { - return 0; } } } Variant::operator StringName() const { - if (type == STRING_NAME) { return *reinterpret_cast<const StringName *>(_data._mem); } else if (type == STRING) { @@ -1868,12 +1619,10 @@ Variant::operator StringName() const { } struct _VariantStrPair { - String key; String value; bool operator<(const _VariantStrPair &p) const { - return key < p.key; } }; @@ -1886,7 +1635,6 @@ Variant::operator String() const { String Variant::stringify(List<const void *> &stack) const { switch (type) { - case NIL: return "Null"; case BOOL: @@ -1906,7 +1654,6 @@ String Variant::stringify(List<const void *> &stack) const { case RECT2I: return "(" + operator Rect2i() + ")"; case TRANSFORM2D: { - Transform2D mat32 = operator Transform2D(); return "(" + Variant(mat32.elements[0]).operator String() + ", " + Variant(mat32.elements[1]).operator String() + ", " + Variant(mat32.elements[2]).operator String() + ")"; } break; @@ -1922,19 +1669,16 @@ String Variant::stringify(List<const void *> &stack) const { case QUAT: return "(" + operator Quat() + ")"; case BASIS: { - Basis mat3 = operator Basis(); String mtx("("); for (int i = 0; i < 3; i++) { - if (i != 0) mtx += ", "; mtx += "("; for (int j = 0; j < 3; j++) { - if (j != 0) mtx += ", "; @@ -1955,7 +1699,6 @@ String Variant::stringify(List<const void *> &stack) const { case COLOR: return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a); case DICTIONARY: { - const Dictionary &d = *reinterpret_cast<const Dictionary *>(_data._mem); if (stack.find(d.id())) { return "{...}"; @@ -1971,7 +1714,6 @@ String Variant::stringify(List<const void *> &stack) const { Vector<_VariantStrPair> pairs; for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _VariantStrPair sp; sp.key = E->get().stringify(stack); sp.value = d[E->get()].stringify(stack); @@ -1991,11 +1733,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_VECTOR2_ARRAY: { - Vector<Vector2> vec = operator Vector<Vector2>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + Variant(vec[i]); @@ -2004,11 +1744,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_VECTOR3_ARRAY: { - Vector<Vector3> vec = operator Vector<Vector3>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + Variant(vec[i]); @@ -2017,11 +1755,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_STRING_ARRAY: { - Vector<String> vec = operator Vector<String>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + vec[i]; @@ -2030,11 +1766,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_INT32_ARRAY: { - Vector<int32_t> vec = operator Vector<int32_t>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + itos(vec[i]); @@ -2043,11 +1777,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_INT64_ARRAY: { - Vector<int64_t> vec = operator Vector<int64_t>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + itos(vec[i]); @@ -2056,11 +1788,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_FLOAT32_ARRAY: { - Vector<float> vec = operator Vector<float>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + rtos(vec[i]); @@ -2069,11 +1799,9 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case PACKED_FLOAT64_ARRAY: { - Vector<double> vec = operator Vector<double>(); String str("["); for (int i = 0; i < vec.size(); i++) { - if (i > 0) str += ", "; str = str + rtos(vec[i]); @@ -2082,7 +1810,6 @@ String Variant::stringify(List<const void *> &stack) const { return str; } break; case ARRAY: { - Array arr = operator Array(); if (stack.find(arr.id())) { return "[...]"; @@ -2102,9 +1829,7 @@ String Variant::stringify(List<const void *> &stack) const { } break; case OBJECT: { - if (_get_obj().obj) { - if (!_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { return "[Freed Object]"; }; @@ -2135,7 +1860,6 @@ String Variant::stringify(List<const void *> &stack) const { } Variant::operator Vector2() const { - if (type == VECTOR2) return *reinterpret_cast<const Vector2 *>(_data._mem); else if (type == VECTOR2I) @@ -2149,7 +1873,6 @@ Variant::operator Vector2() const { } Variant::operator Vector2i() const { - if (type == VECTOR2I) return *reinterpret_cast<const Vector2i *>(_data._mem); else if (type == VECTOR2) @@ -2163,7 +1886,6 @@ Variant::operator Vector2i() const { } Variant::operator Rect2() const { - if (type == RECT2) return *reinterpret_cast<const Rect2 *>(_data._mem); else if (type == RECT2I) @@ -2173,7 +1895,6 @@ Variant::operator Rect2() const { } Variant::operator Rect2i() const { - if (type == RECT2I) return *reinterpret_cast<const Rect2i *>(_data._mem); else if (type == RECT2) @@ -2183,7 +1904,6 @@ Variant::operator Rect2i() const { } Variant::operator Vector3() const { - if (type == VECTOR3) return *reinterpret_cast<const Vector3 *>(_data._mem); else if (type == VECTOR3I) @@ -2197,7 +1917,6 @@ Variant::operator Vector3() const { } Variant::operator Vector3i() const { - if (type == VECTOR3I) return *reinterpret_cast<const Vector3i *>(_data._mem); else if (type == VECTOR3) @@ -2211,14 +1930,12 @@ Variant::operator Vector3i() const { } Variant::operator Plane() const { - if (type == PLANE) return *reinterpret_cast<const Plane *>(_data._mem); else return Plane(); } Variant::operator ::AABB() const { - if (type == AABB) return *_data._aabb; else @@ -2226,7 +1943,6 @@ Variant::operator ::AABB() const { } Variant::operator Basis() const { - if (type == BASIS) return *_data._basis; else if (type == QUAT) @@ -2240,7 +1956,6 @@ Variant::operator Basis() const { } Variant::operator Quat() const { - if (type == QUAT) return *reinterpret_cast<const Quat *>(_data._mem); else if (type == BASIS) @@ -2252,7 +1967,6 @@ Variant::operator Quat() const { } Variant::operator Transform() const { - if (type == TRANSFORM) return *_data._transform; else if (type == BASIS) @@ -2274,7 +1988,6 @@ Variant::operator Transform() const { } Variant::operator Transform2D() const { - if (type == TRANSFORM2D) { return *_data._transform2d; } else if (type == TRANSFORM) { @@ -2292,7 +2005,6 @@ Variant::operator Transform2D() const { } Variant::operator Color() const { - if (type == COLOR) return *reinterpret_cast<const Color *>(_data._mem); else if (type == STRING) @@ -2304,7 +2016,6 @@ Variant::operator Color() const { } Variant::operator NodePath() const { - if (type == NODE_PATH) return *reinterpret_cast<const NodePath *>(_data._mem); else if (type == STRING) @@ -2314,7 +2025,6 @@ Variant::operator NodePath() const { } Variant::operator RID() const { - if (type == _RID) return *reinterpret_cast<const RID *>(_data._mem); else if (type == OBJECT && _get_obj().obj == nullptr) { @@ -2337,7 +2047,6 @@ Variant::operator RID() const { } Variant::operator Object *() const { - if (type == OBJECT) return _get_obj().obj; else @@ -2363,14 +2072,12 @@ Object *Variant::get_validated_object() const { } Variant::operator Node *() const { - if (type == OBJECT) return Object::cast_to<Node>(_get_obj().obj); else return nullptr; } Variant::operator Control *() const { - if (type == OBJECT) return Object::cast_to<Control>(_get_obj().obj); else @@ -2378,7 +2085,6 @@ Variant::operator Control *() const { } Variant::operator Dictionary() const { - if (type == DICTIONARY) return *reinterpret_cast<const Dictionary *>(_data._mem); else @@ -2386,7 +2092,6 @@ Variant::operator Dictionary() const { } Variant::operator Callable() const { - if (type == CALLABLE) return *reinterpret_cast<const Callable *>(_data._mem); else @@ -2394,7 +2099,6 @@ Variant::operator Callable() const { } Variant::operator Signal() const { - if (type == SIGNAL) return *reinterpret_cast<const Signal *>(_data._mem); else @@ -2403,12 +2107,10 @@ Variant::operator Signal() const { template <class DA, class SA> inline DA _convert_array(const SA &p_array) { - DA da; da.resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { - da.set(i, Variant(p_array.get(i))); } @@ -2417,9 +2119,7 @@ inline DA _convert_array(const SA &p_array) { template <class DA> inline DA _convert_array_from_variant(const Variant &p_variant) { - switch (p_variant.get_type()) { - case Variant::ARRAY: { return _convert_array<DA, Array>(p_variant.operator Array()); } @@ -2457,7 +2157,6 @@ inline DA _convert_array_from_variant(const Variant &p_variant) { } Variant::operator Array() const { - if (type == ARRAY) return *reinterpret_cast<const Array *>(_data._mem); else @@ -2465,21 +2164,18 @@ Variant::operator Array() const { } Variant::operator Vector<uint8_t>() const { - if (type == PACKED_BYTE_ARRAY) return static_cast<PackedArrayRef<uint8_t> *>(_data.packed_array)->array; else return _convert_array_from_variant<Vector<uint8_t>>(*this); } Variant::operator Vector<int32_t>() const { - if (type == PACKED_INT32_ARRAY) return static_cast<PackedArrayRef<int32_t> *>(_data.packed_array)->array; else return _convert_array_from_variant<Vector<int>>(*this); } Variant::operator Vector<int64_t>() const { - if (type == PACKED_INT64_ARRAY) return static_cast<PackedArrayRef<int64_t> *>(_data.packed_array)->array; else @@ -2487,7 +2183,6 @@ Variant::operator Vector<int64_t>() const { } Variant::operator Vector<float>() const { - if (type == PACKED_FLOAT32_ARRAY) return static_cast<PackedArrayRef<float> *>(_data.packed_array)->array; else @@ -2495,7 +2190,6 @@ Variant::operator Vector<float>() const { } Variant::operator Vector<double>() const { - if (type == PACKED_FLOAT64_ARRAY) return static_cast<PackedArrayRef<double> *>(_data.packed_array)->array; else @@ -2503,21 +2197,18 @@ Variant::operator Vector<double>() const { } Variant::operator Vector<String>() const { - if (type == PACKED_STRING_ARRAY) return static_cast<PackedArrayRef<String> *>(_data.packed_array)->array; else return _convert_array_from_variant<Vector<String>>(*this); } Variant::operator Vector<Vector3>() const { - if (type == PACKED_VECTOR3_ARRAY) return static_cast<PackedArrayRef<Vector3> *>(_data.packed_array)->array; else return _convert_array_from_variant<Vector<Vector3>>(*this); } Variant::operator Vector<Vector2>() const { - if (type == PACKED_VECTOR2_ARRAY) return static_cast<PackedArrayRef<Vector2> *>(_data.packed_array)->array; else @@ -2525,7 +2216,6 @@ Variant::operator Vector<Vector2>() const { } Variant::operator Vector<Color>() const { - if (type == PACKED_COLOR_ARRAY) return static_cast<PackedArrayRef<Color> *>(_data.packed_array)->array; else @@ -2535,7 +2225,6 @@ Variant::operator Vector<Color>() const { /* helpers */ Variant::operator Vector<RID>() const { - Array va = operator Array(); Vector<RID> rids; rids.resize(va.size()); @@ -2545,7 +2234,6 @@ Variant::operator Vector<RID>() const { } Variant::operator Vector<Plane>() const { - Array va = operator Array(); Vector<Plane> planes; int va_size = va.size(); @@ -2562,7 +2250,6 @@ Variant::operator Vector<Plane>() const { } Variant::operator Vector<Face3>() const { - Vector<Vector3> va = operator Vector<Vector3>(); Vector<Face3> faces; int va_size = va.size(); @@ -2580,7 +2267,6 @@ Variant::operator Vector<Face3>() const { } Variant::operator Vector<Variant>() const { - Array va = operator Array(); Vector<Variant> variants; int va_size = va.size(); @@ -2595,31 +2281,25 @@ Variant::operator Vector<Variant>() const { return variants; } Variant::operator Vector<StringName>() const { - Vector<String> from = operator Vector<String>(); Vector<StringName> to; int len = from.size(); to.resize(len); for (int i = 0; i < len; i++) { - to.write[i] = from[i]; } return to; } Variant::operator Margin() const { - return (Margin) operator int(); } Variant::operator Orientation() const { - return (Orientation) operator int(); } Variant::operator IP_Address() const { - if (type == PACKED_FLOAT32_ARRAY || type == PACKED_INT32_ARRAY || type == PACKED_FLOAT64_ARRAY || type == PACKED_INT64_ARRAY || type == PACKED_BYTE_ARRAY) { - Vector<int> addr = operator Vector<int>(); if (addr.size() == 4) { return IP_Address(addr.get(0), addr.get(1), addr.get(2), addr.get(3)); @@ -2630,7 +2310,6 @@ Variant::operator IP_Address() const { } Variant::Variant(bool p_bool) { - type = BOOL; _data._bool = p_bool; } @@ -2644,12 +2323,10 @@ Variant::Variant(long unsigned int p_long) { */ Variant::Variant(signed int p_int) { - type = INT; _data._int = p_int; } Variant::Variant(unsigned int p_int) { - type = INT; _data._int = p_int; } @@ -2657,56 +2334,46 @@ Variant::Variant(unsigned int p_int) { #ifdef NEED_LONG_INT Variant::Variant(signed long p_int) { - type = INT; _data._int = p_int; } Variant::Variant(unsigned long p_int) { - type = INT; _data._int = p_int; } #endif Variant::Variant(int64_t p_int) { - type = INT; _data._int = p_int; } Variant::Variant(uint64_t p_int) { - type = INT; _data._int = p_int; } Variant::Variant(signed short p_short) { - type = INT; _data._int = p_short; } Variant::Variant(unsigned short p_short) { - type = INT; _data._int = p_short; } Variant::Variant(signed char p_char) { - type = INT; _data._int = p_char; } Variant::Variant(unsigned char p_char) { - type = INT; _data._int = p_char; } Variant::Variant(float p_float) { - type = FLOAT; _data._float = p_float; } Variant::Variant(double p_double) { - type = FLOAT; _data._float = p_double; } @@ -2717,121 +2384,100 @@ Variant::Variant(const ObjectID &p_id) { } Variant::Variant(const StringName &p_string) { - type = STRING_NAME; memnew_placement(_data._mem, StringName(p_string)); } Variant::Variant(const String &p_string) { - type = STRING; memnew_placement(_data._mem, String(p_string)); } Variant::Variant(const char *const p_cstring) { - type = STRING; memnew_placement(_data._mem, String((const char *)p_cstring)); } Variant::Variant(const CharType *p_wstring) { - type = STRING; memnew_placement(_data._mem, String(p_wstring)); } Variant::Variant(const Vector3 &p_vector3) { - type = VECTOR3; memnew_placement(_data._mem, Vector3(p_vector3)); } Variant::Variant(const Vector3i &p_vector3i) { - type = VECTOR3I; memnew_placement(_data._mem, Vector3i(p_vector3i)); } Variant::Variant(const Vector2 &p_vector2) { - type = VECTOR2; memnew_placement(_data._mem, Vector2(p_vector2)); } Variant::Variant(const Vector2i &p_vector2i) { - type = VECTOR2I; memnew_placement(_data._mem, Vector2i(p_vector2i)); } Variant::Variant(const Rect2 &p_rect2) { - type = RECT2; memnew_placement(_data._mem, Rect2(p_rect2)); } Variant::Variant(const Rect2i &p_rect2i) { - type = RECT2I; memnew_placement(_data._mem, Rect2i(p_rect2i)); } Variant::Variant(const Plane &p_plane) { - type = PLANE; memnew_placement(_data._mem, Plane(p_plane)); } Variant::Variant(const ::AABB &p_aabb) { - type = AABB; _data._aabb = memnew(::AABB(p_aabb)); } Variant::Variant(const Basis &p_matrix) { - type = BASIS; _data._basis = memnew(Basis(p_matrix)); } Variant::Variant(const Quat &p_quat) { - type = QUAT; memnew_placement(_data._mem, Quat(p_quat)); } Variant::Variant(const Transform &p_transform) { - type = TRANSFORM; _data._transform = memnew(Transform(p_transform)); } Variant::Variant(const Transform2D &p_transform) { - type = TRANSFORM2D; _data._transform2d = memnew(Transform2D(p_transform)); } Variant::Variant(const Color &p_color) { - type = COLOR; memnew_placement(_data._mem, Color(p_color)); } Variant::Variant(const NodePath &p_node_path) { - type = NODE_PATH; memnew_placement(_data._mem, NodePath(p_node_path)); } Variant::Variant(const RID &p_rid) { - type = _RID; memnew_placement(_data._mem, RID(p_rid)); } Variant::Variant(const Object *p_object) { - type = OBJECT; memnew_placement(_data._mem, ObjData); if (p_object) { - if (p_object->is_reference()) { Reference *reference = const_cast<Reference *>(static_cast<const Reference *>(p_object)); if (!reference->init_ref()) { @@ -2850,30 +2496,25 @@ Variant::Variant(const Object *p_object) { } Variant::Variant(const Callable &p_callable) { - type = CALLABLE; memnew_placement(_data._mem, Callable(p_callable)); } Variant::Variant(const Signal &p_callable) { - type = SIGNAL; memnew_placement(_data._mem, Signal(p_callable)); } Variant::Variant(const Dictionary &p_dictionary) { - type = DICTIONARY; memnew_placement(_data._mem, Dictionary(p_dictionary)); } Variant::Variant(const Array &p_array) { - type = ARRAY; memnew_placement(_data._mem, Array(p_array)); } Variant::Variant(const Vector<Plane> &p_array) { - type = ARRAY; Array *plane_array = memnew_placement(_data._mem, Array); @@ -2881,13 +2522,11 @@ Variant::Variant(const Vector<Plane> &p_array) { plane_array->resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { - plane_array->operator[](i) = Variant(p_array[i]); } } Variant::Variant(const Vector<RID> &p_array) { - type = ARRAY; Array *rid_array = memnew_placement(_data._mem, Array); @@ -2895,65 +2534,54 @@ Variant::Variant(const Vector<RID> &p_array) { rid_array->resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { - rid_array->set(i, Variant(p_array[i])); } } Variant::Variant(const Vector<uint8_t> &p_byte_array) { - type = PACKED_BYTE_ARRAY; _data.packed_array = PackedArrayRef<uint8_t>::create(p_byte_array); } Variant::Variant(const Vector<int32_t> &p_int32_array) { - type = PACKED_INT32_ARRAY; _data.packed_array = PackedArrayRef<int32_t>::create(p_int32_array); } Variant::Variant(const Vector<int64_t> &p_int64_array) { - type = PACKED_INT64_ARRAY; _data.packed_array = PackedArrayRef<int64_t>::create(p_int64_array); } Variant::Variant(const Vector<float> &p_float32_array) { - type = PACKED_FLOAT32_ARRAY; _data.packed_array = PackedArrayRef<float>::create(p_float32_array); } Variant::Variant(const Vector<double> &p_float64_array) { - type = PACKED_FLOAT64_ARRAY; _data.packed_array = PackedArrayRef<double>::create(p_float64_array); } Variant::Variant(const Vector<String> &p_string_array) { - type = PACKED_STRING_ARRAY; _data.packed_array = PackedArrayRef<String>::create(p_string_array); } Variant::Variant(const Vector<Vector3> &p_vector3_array) { - type = PACKED_VECTOR3_ARRAY; _data.packed_array = PackedArrayRef<Vector3>::create(p_vector3_array); } Variant::Variant(const Vector<Vector2> &p_vector2_array) { - type = PACKED_VECTOR2_ARRAY; _data.packed_array = PackedArrayRef<Vector2>::create(p_vector2_array); } Variant::Variant(const Vector<Color> &p_color_array) { - type = PACKED_COLOR_ARRAY; _data.packed_array = PackedArrayRef<Color>::create(p_color_array); } Variant::Variant(const Vector<Face3> &p_face_array) { - Vector<Vector3> vertices; int face_count = p_face_array.size(); vertices.resize(face_count * 3); @@ -2963,7 +2591,6 @@ Variant::Variant(const Vector<Face3> &p_face_array) { Vector3 *w = vertices.ptrw(); for (int i = 0; i < face_count; i++) { - for (int j = 0; j < 3; j++) w[i * 3 + j] = r[i].vertex[j]; } @@ -2986,7 +2613,6 @@ Variant::Variant(const Vector<Variant> &p_array) { } Variant::Variant(const Vector<StringName> &p_array) { - type = NIL; Vector<String> v; int len = p_array.size(); @@ -2997,7 +2623,6 @@ Variant::Variant(const Vector<StringName> &p_array) { } void Variant::operator=(const Variant &p_variant) { - if (unlikely(this == &p_variant)) return; @@ -3008,90 +2633,70 @@ void Variant::operator=(const Variant &p_variant) { switch (p_variant.type) { case NIL: { - // none } break; // atomic types case BOOL: { - _data._bool = p_variant._data._bool; } break; case INT: { - _data._int = p_variant._data._int; } break; case FLOAT: { - _data._float = p_variant._data._float; } break; case STRING: { - *reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem); } break; // math types case VECTOR2: { - *reinterpret_cast<Vector2 *>(_data._mem) = *reinterpret_cast<const Vector2 *>(p_variant._data._mem); } break; case VECTOR2I: { - *reinterpret_cast<Vector2i *>(_data._mem) = *reinterpret_cast<const Vector2i *>(p_variant._data._mem); } break; case RECT2: { - *reinterpret_cast<Rect2 *>(_data._mem) = *reinterpret_cast<const Rect2 *>(p_variant._data._mem); } break; case RECT2I: { - *reinterpret_cast<Rect2i *>(_data._mem) = *reinterpret_cast<const Rect2i *>(p_variant._data._mem); } break; case TRANSFORM2D: { - *_data._transform2d = *(p_variant._data._transform2d); } break; case VECTOR3: { - *reinterpret_cast<Vector3 *>(_data._mem) = *reinterpret_cast<const Vector3 *>(p_variant._data._mem); } break; case VECTOR3I: { - *reinterpret_cast<Vector3i *>(_data._mem) = *reinterpret_cast<const Vector3i *>(p_variant._data._mem); } break; case PLANE: { - *reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem); } break; case AABB: { - *_data._aabb = *(p_variant._data._aabb); } break; case QUAT: { - *reinterpret_cast<Quat *>(_data._mem) = *reinterpret_cast<const Quat *>(p_variant._data._mem); } break; case BASIS: { - *_data._basis = *(p_variant._data._basis); } break; case TRANSFORM: { - *_data._transform = *(p_variant._data._transform); } break; // misc types case COLOR: { - *reinterpret_cast<Color *>(_data._mem) = *reinterpret_cast<const Color *>(p_variant._data._mem); } break; case _RID: { - *reinterpret_cast<RID *>(_data._mem) = *reinterpret_cast<const RID *>(p_variant._data._mem); } break; case OBJECT: { - if (_get_obj().id.is_reference()) { //we are safe that there is a reference here Reference *reference = static_cast<Reference *>(_get_obj().obj); @@ -3114,66 +2719,51 @@ void Variant::operator=(const Variant &p_variant) { } break; case CALLABLE: { - *reinterpret_cast<Callable *>(_data._mem) = *reinterpret_cast<const Callable *>(p_variant._data._mem); } break; case SIGNAL: { - *reinterpret_cast<Signal *>(_data._mem) = *reinterpret_cast<const Signal *>(p_variant._data._mem); } break; case STRING_NAME: { - *reinterpret_cast<StringName *>(_data._mem) = *reinterpret_cast<const StringName *>(p_variant._data._mem); } break; case NODE_PATH: { - *reinterpret_cast<NodePath *>(_data._mem) = *reinterpret_cast<const NodePath *>(p_variant._data._mem); } break; case DICTIONARY: { - *reinterpret_cast<Dictionary *>(_data._mem) = *reinterpret_cast<const Dictionary *>(p_variant._data._mem); } break; case ARRAY: { - *reinterpret_cast<Array *>(_data._mem) = *reinterpret_cast<const Array *>(p_variant._data._mem); } break; // arrays case PACKED_BYTE_ARRAY: { - _data.packed_array = PackedArrayRef<uint8_t>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_INT32_ARRAY: { - _data.packed_array = PackedArrayRef<int32_t>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_INT64_ARRAY: { - _data.packed_array = PackedArrayRef<int64_t>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_FLOAT32_ARRAY: { - _data.packed_array = PackedArrayRef<float>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_FLOAT64_ARRAY: { - _data.packed_array = PackedArrayRef<double>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_STRING_ARRAY: { - _data.packed_array = PackedArrayRef<String>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_VECTOR2_ARRAY: { - _data.packed_array = PackedArrayRef<Vector2>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_VECTOR3_ARRAY: { - _data.packed_array = PackedArrayRef<Vector3>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_COLOR_ARRAY: { - _data.packed_array = PackedArrayRef<Color>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; default: { @@ -3182,70 +2772,56 @@ void Variant::operator=(const Variant &p_variant) { } Variant::Variant(const IP_Address &p_address) { - type = STRING; memnew_placement(_data._mem, String(p_address)); } Variant::Variant(const Variant &p_variant) { - reference(p_variant); } uint32_t Variant::hash() const { - switch (type) { case NIL: { - return 0; } break; case BOOL: { - return _data._bool ? 1 : 0; } break; case INT: { - return _data._int; } break; case FLOAT: { - return hash_djb2_one_float(_data._float); } break; case STRING: { - return reinterpret_cast<const String *>(_data._mem)->hash(); } break; // math types case VECTOR2: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Vector2 *>(_data._mem)->x); return hash_djb2_one_float(reinterpret_cast<const Vector2 *>(_data._mem)->y, hash); } break; case VECTOR2I: { - uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Vector2i *>(_data._mem)->x); return hash_djb2_one_32(reinterpret_cast<const Vector2i *>(_data._mem)->y, hash); } break; case RECT2: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.x); hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.y, hash); hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.x, hash); return hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.y, hash); } break; case RECT2I: { - uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->position.x); hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->position.y, hash); hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->size.x, hash); return hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->size.y, hash); } break; case TRANSFORM2D: { - uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 2; j++) { hash = hash_djb2_one_float(_data._transform2d->elements[i][j], hash); } @@ -3254,19 +2830,16 @@ uint32_t Variant::hash() const { return hash; } break; case VECTOR3: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->x); hash = hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->y, hash); return hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->z, hash); } break; case VECTOR3I: { - uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->x); hash = hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->y, hash); return hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->z, hash); } break; case PLANE: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.x); hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.y, hash); hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.z, hash); @@ -3279,10 +2852,8 @@ uint32_t Variant::hash() const { } break;*/ case AABB: { - uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - hash = hash_djb2_one_float(_data._aabb->position[i], hash); hash = hash_djb2_one_float(_data._aabb->size[i], hash); } @@ -3291,7 +2862,6 @@ uint32_t Variant::hash() const { } break; case QUAT: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->x); hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->y, hash); hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->z, hash); @@ -3299,10 +2869,8 @@ uint32_t Variant::hash() const { } break; case BASIS: { - uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { hash = hash_djb2_one_float(_data._basis->elements[i][j], hash); } @@ -3312,10 +2880,8 @@ uint32_t Variant::hash() const { } break; case TRANSFORM: { - uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { hash = hash_djb2_one_float(_data._transform->basis.elements[i][j], hash); } @@ -3328,7 +2894,6 @@ uint32_t Variant::hash() const { // misc types case COLOR: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->r); hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->g, hash); hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->b, hash); @@ -3336,45 +2901,36 @@ uint32_t Variant::hash() const { } break; case _RID: { - return hash_djb2_one_64(reinterpret_cast<const RID *>(_data._mem)->get_id()); } break; case OBJECT: { - return hash_djb2_one_64(make_uint64_t(_get_obj().obj)); } break; case STRING_NAME: { - return reinterpret_cast<const StringName *>(_data._mem)->hash(); } break; case NODE_PATH: { - return reinterpret_cast<const NodePath *>(_data._mem)->hash(); } break; case DICTIONARY: { - return reinterpret_cast<const Dictionary *>(_data._mem)->hash(); } break; case CALLABLE: { - return reinterpret_cast<const Callable *>(_data._mem)->hash(); } break; case SIGNAL: { - const Signal &s = *reinterpret_cast<const Signal *>(_data._mem); uint32_t hash = s.get_name().hash(); return hash_djb2_one_64(s.get_object_id(), hash); } break; case ARRAY: { - const Array &arr = *reinterpret_cast<const Array *>(_data._mem); return arr.hash(); } break; case PACKED_BYTE_ARRAY: { - const Vector<uint8_t> &arr = PackedArrayRef<uint8_t>::get_array(_data.packed_array); int len = arr.size(); if (likely(len)) { @@ -3386,7 +2942,6 @@ uint32_t Variant::hash() const { } break; case PACKED_INT32_ARRAY: { - const Vector<int32_t> &arr = PackedArrayRef<int32_t>::get_array(_data.packed_array); int len = arr.size(); if (likely(len)) { @@ -3398,7 +2953,6 @@ uint32_t Variant::hash() const { } break; case PACKED_INT64_ARRAY: { - const Vector<int64_t> &arr = PackedArrayRef<int64_t>::get_array(_data.packed_array); int len = arr.size(); if (likely(len)) { @@ -3410,7 +2964,6 @@ uint32_t Variant::hash() const { } break; case PACKED_FLOAT32_ARRAY: { - const Vector<float> &arr = PackedArrayRef<float>::get_array(_data.packed_array); int len = arr.size(); @@ -3423,7 +2976,6 @@ uint32_t Variant::hash() const { } break; case PACKED_FLOAT64_ARRAY: { - const Vector<double> &arr = PackedArrayRef<double>::get_array(_data.packed_array); int len = arr.size(); @@ -3436,7 +2988,6 @@ uint32_t Variant::hash() const { } break; case PACKED_STRING_ARRAY: { - uint32_t hash = 5831; const Vector<String> &arr = PackedArrayRef<String>::get_array(_data.packed_array); int len = arr.size(); @@ -3452,7 +3003,6 @@ uint32_t Variant::hash() const { return hash; } break; case PACKED_VECTOR2_ARRAY: { - uint32_t hash = 5831; const Vector<Vector2> &arr = PackedArrayRef<Vector2>::get_array(_data.packed_array); int len = arr.size(); @@ -3469,7 +3019,6 @@ uint32_t Variant::hash() const { return hash; } break; case PACKED_VECTOR3_ARRAY: { - uint32_t hash = 5831; const Vector<Vector3> &arr = PackedArrayRef<Vector3>::get_array(_data.packed_array); int len = arr.size(); @@ -3487,7 +3036,6 @@ uint32_t Variant::hash() const { return hash; } break; case PACKED_COLOR_ARRAY: { - uint32_t hash = 5831; const Vector<Color> &arr = PackedArrayRef<Color>::get_array(_data.packed_array); int len = arr.size(); @@ -3715,30 +3263,25 @@ bool Variant::hash_compare(const Variant &p_variant) const { } bool Variant::is_ref() const { - return type == OBJECT && _get_obj().id.is_reference(); } Vector<Variant> varray() { - return Vector<Variant>(); } Vector<Variant> varray(const Variant &p_arg1) { - Vector<Variant> v; v.push_back(p_arg1); return v; } Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2) { - Vector<Variant> v; v.push_back(p_arg1); v.push_back(p_arg2); return v; } Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3) { - Vector<Variant> v; v.push_back(p_arg1); v.push_back(p_arg2); @@ -3746,7 +3289,6 @@ Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Varia return v; } Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4) { - Vector<Variant> v; v.push_back(p_arg1); v.push_back(p_arg2); @@ -3756,7 +3298,6 @@ Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Varia } Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5) { - Vector<Variant> v; v.push_back(p_arg1); v.push_back(p_arg2); @@ -3770,9 +3311,7 @@ void Variant::static_assign(const Variant &p_variant) { } bool Variant::is_shared() const { - switch (type) { - case OBJECT: return true; case ARRAY: @@ -3800,20 +3339,16 @@ Variant Variant::call(const StringName &p_method, VARIANT_ARG_DECLARE) { Variant ret = call(p_method, argptr, argc, error); switch (error.error) { - case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: { - String err = "Invalid type for argument #" + itos(error.argument) + ", expected '" + Variant::get_type_name(Variant::Type(error.expected)) + "'."; ERR_PRINT(err.utf8().get_data()); } break; case Callable::CallError::CALL_ERROR_INVALID_METHOD: { - String err = "Invalid method '" + p_method + "' for type '" + Variant::get_type_name(type) + "'."; ERR_PRINT(err.utf8().get_data()); } break; case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: { - String err = "Too many arguments for method '" + p_method + "'"; ERR_PRINT(err.utf8().get_data()); } break; @@ -3825,12 +3360,10 @@ Variant Variant::call(const StringName &p_method, VARIANT_ARG_DECLARE) { } void Variant::construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct, void *p_construct_ud) { - r_value = Variant(); } String Variant::get_construct_string() const { - String vars; VariantWriter::write_to_string(*this, vars); @@ -3838,7 +3371,6 @@ String Variant::get_construct_string() const { } String Variant::get_call_error_text(Object *p_base, const StringName &p_method, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) { - String err_text; if (ce.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) { @@ -3863,14 +3395,12 @@ String Variant::get_call_error_text(Object *p_base, const StringName &p_method, String class_name = p_base->get_class(); Ref<Script> script = p_base->get_script(); if (script.is_valid() && script->get_path().is_resource_file()) { - class_name += "(" + script->get_path().get_file() + ")"; } return "'" + class_name + "::" + String(p_method) + "': " + err_text; } String Variant::get_callable_error_text(const Callable &p_callable, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) { - String err_text; if (ce.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) { @@ -3896,26 +3426,20 @@ String Variant::get_callable_error_text(const Callable &p_callable, const Varian } String vformat(const String &p_text, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4, const Variant &p5) { - Array args; if (p1.get_type() != Variant::NIL) { - args.push_back(p1); if (p2.get_type() != Variant::NIL) { - args.push_back(p2); if (p3.get_type() != Variant::NIL) { - args.push_back(p3); if (p4.get_type() != Variant::NIL) { - args.push_back(p4); if (p5.get_type() != Variant::NIL) { - args.push_back(p5); } } |