diff options
Diffstat (limited to 'core/variant_op.cpp')
-rw-r--r-- | core/variant_op.cpp | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 4c9848f26a..b7678d8f43 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -159,7 +159,6 @@ #endif Variant::operator bool() const { - return booleanize(); } @@ -435,7 +434,6 @@ bool Variant::booleanize() const { if (a_len m_opa array_b.size()) { \ _RETURN(m_ret_s); \ } else { \ - \ const m_type *ra = array_a.ptr(); \ const m_type *rb = array_b.ptr(); \ \ @@ -461,7 +459,6 @@ bool Variant::booleanize() const { void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b, Variant &r_ret, bool &r_valid) { - CASES(math); r_valid = true; @@ -1418,7 +1415,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, } void Variant::set_named(const StringName &p_index, const Variant &p_value, bool *r_valid) { - bool valid = false; switch (type) { case VECTOR2: { @@ -1466,7 +1462,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case RECT2: { - if (p_value.type == Variant::VECTOR2) { Rect2 *v = reinterpret_cast<Rect2 *>(_data._mem); //scalar name @@ -1483,7 +1478,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; case RECT2I: { - if (p_value.type == Variant::VECTOR2I) { Rect2i *v = reinterpret_cast<Rect2i *>(_data._mem); //scalar name @@ -1500,7 +1494,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; case TRANSFORM2D: { - if (p_value.type == Variant::VECTOR2) { Transform2D *v = _data._transform2d; if (p_index == CoreStringNames::singleton->x) { @@ -1517,7 +1510,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case VECTOR3: { - if (p_value.type == Variant::INT) { Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { @@ -1546,7 +1538,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case VECTOR3I: { - if (p_value.type == Variant::INT) { Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { @@ -1575,7 +1566,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case PLANE: { - if (p_value.type == Variant::INT) { Plane *v = reinterpret_cast<Plane *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { @@ -1617,7 +1607,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case QUAT: { - if (p_value.type == Variant::INT) { Quat *v = reinterpret_cast<Quat *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { @@ -1652,7 +1641,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case AABB: { - if (p_value.type == Variant::VECTOR3) { ::AABB *v = _data._aabb; //scalar name @@ -1669,7 +1657,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; case BASIS: { - if (p_value.type == Variant::VECTOR3) { Basis *v = _data._basis; //scalar name @@ -1686,7 +1673,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; case TRANSFORM: { - if (p_value.type == Variant::BASIS && p_index == CoreStringNames::singleton->basis) { _data._transform->basis = *p_value._data._basis; valid = true; @@ -1697,7 +1683,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } break; case COLOR: { - if (p_value.type == Variant::INT) { Color *v = reinterpret_cast<Color *>(_data._mem); if (p_index == CoreStringNames::singleton->r) { @@ -1773,7 +1758,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; case OBJECT: { - #ifdef DEBUG_ENABLED if (!_get_obj().obj) { break; @@ -1796,7 +1780,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { - if (r_valid) { *r_valid = true; } @@ -1820,7 +1803,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case RECT2: { - const Rect2 *v = reinterpret_cast<const Rect2 *>(_data._mem); //scalar name if (p_index == CoreStringNames::singleton->position) { @@ -1832,7 +1814,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; case RECT2I: { - const Rect2i *v = reinterpret_cast<const Rect2i *>(_data._mem); //scalar name if (p_index == CoreStringNames::singleton->position) { @@ -1844,7 +1825,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; case TRANSFORM2D: { - const Transform2D *v = _data._transform2d; if (p_index == CoreStringNames::singleton->x) { return v->elements[0]; @@ -1856,7 +1836,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case VECTOR3: { - const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { return v->x; @@ -1868,7 +1847,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case VECTOR3I: { - const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { return v->x; @@ -1880,7 +1858,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case PLANE: { - const Plane *v = reinterpret_cast<const Plane *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { return v->normal.x; @@ -1896,7 +1873,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case QUAT: { - const Quat *v = reinterpret_cast<const Quat *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { return v->x; @@ -1910,7 +1886,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case AABB: { - const ::AABB *v = _data._aabb; //scalar name if (p_index == CoreStringNames::singleton->position) { @@ -1922,7 +1897,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; case BASIS: { - const Basis *v = _data._basis; //scalar name if (p_index == CoreStringNames::singleton->x) { @@ -1935,7 +1909,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case TRANSFORM: { - if (p_index == CoreStringNames::singleton->basis) { return _data._transform->basis; } else if (p_index == CoreStringNames::singleton->origin) { @@ -1944,7 +1917,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; case COLOR: { - const Color *v = reinterpret_cast<const Color *>(_data._mem); if (p_index == CoreStringNames::singleton->r) { return v->r; @@ -1971,14 +1943,12 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; case OBJECT: { - #ifdef DEBUG_ENABLED if (!_get_obj().obj) { if (r_valid) *r_valid = false; return "Instance base is null."; } else { - if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (r_valid) *r_valid = false; @@ -2039,7 +2009,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { #define DEFAULT_OP_DVECTOR_GET(m_name, m_type) \ case m_name: { \ - \ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \ int index = p_index; \ const Vector<m_type> *arr = &PackedArrayRef<m_type>::get_array(_data.packed_array); \ @@ -2054,7 +2023,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } break; void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) { - static bool _dummy = false; bool &valid = r_valid ? *r_valid : _dummy; @@ -2074,7 +2042,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } break; case STRING: { - if (p_index.type != Variant::INT && p_index.type != Variant::FLOAT) return; @@ -2088,10 +2055,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) String chr; if (p_value.type == Variant::INT || p_value.type == Variant::FLOAT) { - chr = String::chr(p_value); } else if (p_value.type == Variant::STRING) { - chr = p_value; } else { return; @@ -2103,7 +2068,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR2: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; @@ -2114,7 +2078,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (idx < 0) idx += 2; if (idx >= 0 && idx < 2) { - Vector2 *v = reinterpret_cast<Vector2 *>(_data._mem); valid = true; (*v)[idx] = p_value; @@ -2138,7 +2101,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR2I: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; @@ -2149,7 +2111,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (idx < 0) idx += 2; if (idx >= 0 && idx < 2) { - Vector2i *v = reinterpret_cast<Vector2i *>(_data._mem); valid = true; (*v)[idx] = p_value; @@ -2173,7 +2134,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case RECT2: { - if (p_value.type != Variant::VECTOR2) return; @@ -2198,7 +2158,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; case RECT2I: { - if (p_value.type != Variant::VECTOR2I) return; @@ -2223,12 +2182,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; case TRANSFORM2D: { - if (p_value.type != Variant::VECTOR2) return; if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; if (index < 0) @@ -2241,7 +2198,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } else if (p_index.get_type() == Variant::STRING && p_value.get_type() == Variant::VECTOR2) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); Transform2D *v = _data._transform2d; @@ -2262,7 +2218,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR3: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; @@ -2272,14 +2227,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (idx < 0) idx += 3; if (idx >= 0 && idx < 3) { - Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem); valid = true; (*v)[idx] = p_value; return; } } else if (p_index.get_type() == Variant::STRING) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem); @@ -2300,7 +2253,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR3I: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; @@ -2310,14 +2262,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (idx < 0) idx += 3; if (idx >= 0 && idx < 3) { - Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem); valid = true; (*v)[idx] = p_value; return; } } else if (p_index.get_type() == Variant::STRING) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem); @@ -2338,7 +2288,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case PLANE: { - if (p_index.get_type() == Variant::STRING) { //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); @@ -2380,12 +2329,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case QUAT: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); Quat *v = reinterpret_cast<Quat *>(_data._mem); if (*str == "x") { @@ -2409,7 +2356,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case AABB: { - if (p_value.type != Variant::VECTOR3) return; @@ -2434,12 +2380,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; case BASIS: { - if (p_value.type != Variant::VECTOR3) return; if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; if (index < 0) @@ -2452,7 +2396,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } else if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); Basis *v = _data._basis; @@ -2473,9 +2416,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - if (p_value.type != Variant::VECTOR3) return; @@ -2493,12 +2434,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } else if (p_index.get_type() == Variant::STRING) { - Transform *v = _data._transform; const String *str = reinterpret_cast<const String *>(p_index._data._mem); if (*str == "basis") { - if (p_value.type != Variant::BASIS) return; valid = true; @@ -2516,12 +2455,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case COLOR: { - if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); Color *v = reinterpret_cast<Color *>(_data._mem); if (*str == "r") { @@ -2570,7 +2507,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } else if (p_index.get_type() == Variant::INT) { - int idx = p_index; if (idx < 0) idx += 4; @@ -2589,14 +2525,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) case _RID: { } break; case OBJECT: { - Object *obj = _get_obj().obj; //only if debugging! if (obj) { #ifdef DEBUG_ENABLED if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { - WARN_PRINT("Attempted use of previously freed pointer object."); valid = false; return; @@ -2613,7 +2547,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; case DICTIONARY: { - Dictionary *dic = reinterpret_cast<Dictionary *>(_data._mem); dic->operator[](p_index) = p_value; valid = true; //always valid, i guess? should this really be ok? @@ -2635,7 +2568,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } Variant Variant::get(const Variant &p_index, bool *r_valid) const { - static bool _dummy = false; bool &valid = r_valid ? *r_valid : _dummy; @@ -2656,7 +2588,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return Variant(); } break; case STRING: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //string index @@ -2665,7 +2596,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { if (idx < 0) idx += str->length(); if (idx >= 0 && idx < str->length()) { - valid = true; return str->substr(idx, 1); } @@ -2673,14 +2603,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case VECTOR2: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; if (idx < 0) idx += 2; if (idx >= 0 && idx < 2) { - const Vector2 *v = reinterpret_cast<const Vector2 *>(_data._mem); valid = true; return (*v)[idx]; @@ -2701,14 +2629,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case VECTOR2I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; if (idx < 0) idx += 2; if (idx >= 0 && idx < 2) { - const Vector2i *v = reinterpret_cast<const Vector2i *>(_data._mem); valid = true; return (*v)[idx]; @@ -2729,7 +2655,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case RECT2: { - if (p_index.get_type() == Variant::STRING) { //scalar name @@ -2748,7 +2673,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; case RECT2I: { - if (p_index.get_type() == Variant::STRING) { //scalar name @@ -2767,20 +2691,17 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; case VECTOR3: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) idx += 3; if (idx >= 0 && idx < 3) { - const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem); valid = true; return (*v)[idx]; } } else if (p_index.get_type() == Variant::STRING) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem); @@ -2798,20 +2719,17 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case VECTOR3I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) idx += 3; if (idx >= 0 && idx < 3) { - const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem); valid = true; return (*v)[idx]; } } else if (p_index.get_type() == Variant::STRING) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem); @@ -2829,9 +2747,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case TRANSFORM2D: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; if (index < 0) @@ -2843,7 +2759,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return v->elements[index]; } } else if (p_index.get_type() == Variant::STRING) { - //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Transform2D *v = _data._transform2d; @@ -2861,7 +2776,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case PLANE: { - if (p_index.get_type() == Variant::STRING) { //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); @@ -2886,9 +2800,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case QUAT: { - if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Quat *v = reinterpret_cast<const Quat *>(_data._mem); if (*str == "x") { @@ -2908,7 +2820,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case AABB: { - if (p_index.get_type() == Variant::STRING) { //scalar name @@ -2927,9 +2838,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; case BASIS: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; if (index < 0) index += 3; @@ -2940,7 +2849,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return v->get_axis(index); } } else if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Basis *v = _data._basis; @@ -2958,9 +2866,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; if (index < 0) index += 4; @@ -2970,7 +2876,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return index == 3 ? v->origin : v->basis.get_axis(index); } } else if (p_index.get_type() == Variant::STRING) { - const Transform *v = _data._transform; const String *str = reinterpret_cast<const String *>(p_index._data._mem); @@ -2986,9 +2891,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case COLOR: { - if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast<const String *>(p_index._data._mem); const Color *v = reinterpret_cast<const Color *>(_data._mem); if (*str == "r") { @@ -3026,7 +2929,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return (int)Math::round(v->a * 255.0); } } else if (p_index.get_type() == Variant::INT) { - int idx = p_index; if (idx < 0) idx += 4; @@ -3047,7 +2949,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { case OBJECT: { Object *obj = _get_obj().obj; if (obj) { - #ifdef DEBUG_ENABLED if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { @@ -3065,7 +2966,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case DICTIONARY: { - const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); const Variant *res = dic->getptr(p_index); if (res) { @@ -3091,14 +2991,11 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } bool Variant::in(const Variant &p_index, bool *r_valid) const { - if (r_valid) *r_valid = true; switch (type) { - case STRING: { - if (p_index.get_type() == Variant::STRING) { //string index String idx = p_index; @@ -3111,7 +3008,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { case OBJECT: { Object *obj = _get_obj().obj; if (obj) { - bool valid = false; #ifdef DEBUG_ENABLED @@ -3138,18 +3034,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { return false; } break; case DICTIONARY: { - const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); return dic->has(p_index); } break; case ARRAY: { - const Array *arr = reinterpret_cast<const Array *>(_data._mem); int l = arr->size(); if (l) { for (int i = 0; i < l; i++) { - if (evaluate(OP_EQUAL, (*arr)[i], p_index)) return true; } @@ -3160,7 +3053,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_BYTE_ARRAY: { if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array); int l = arr->size(); @@ -3178,7 +3070,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_INT32_ARRAY: { if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int32_t index = p_index; const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array); int32_t l = arr->size(); @@ -3195,7 +3086,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_INT64_ARRAY: { if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int64_t index = p_index; const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array); int64_t l = arr->size(); @@ -3211,9 +3101,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } } break; case PACKED_FLOAT32_ARRAY: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - real_t index = p_index; const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array); int l = arr->size(); @@ -3230,9 +3118,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_FLOAT64_ARRAY: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - real_t index = p_index; const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array); int l = arr->size(); @@ -3250,7 +3136,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_STRING_ARRAY: { if (p_index.get_type() == Variant::STRING) { - String index = p_index; const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array); @@ -3269,7 +3154,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; //25 case PACKED_VECTOR2_ARRAY: { if (p_index.get_type() == Variant::VECTOR2) { - Vector2 index = p_index; const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array); @@ -3288,7 +3172,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_VECTOR3_ARRAY: { if (p_index.get_type() == Variant::VECTOR3) { - Vector3 index = p_index; const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array); @@ -3306,9 +3189,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_COLOR_ARRAY: { - if (p_index.get_type() == Variant::COLOR) { - Color index = p_index; const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array); @@ -3334,57 +3215,48 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } void Variant::get_property_list(List<PropertyInfo> *p_list) const { - switch (type) { case VECTOR2: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); } break; case VECTOR2I: { - p_list->push_back(PropertyInfo(Variant::INT, "x")); p_list->push_back(PropertyInfo(Variant::INT, "y")); } break; case RECT2: { - p_list->push_back(PropertyInfo(Variant::VECTOR2, "position")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "size")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "end")); } break; case RECT2I: { - p_list->push_back(PropertyInfo(Variant::VECTOR2I, "position")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "end")); } break; case VECTOR3: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); p_list->push_back(PropertyInfo(Variant::FLOAT, "z")); } break; case VECTOR3I: { - p_list->push_back(PropertyInfo(Variant::INT, "x")); p_list->push_back(PropertyInfo(Variant::INT, "y")); p_list->push_back(PropertyInfo(Variant::INT, "z")); } break; case TRANSFORM2D: { - p_list->push_back(PropertyInfo(Variant::VECTOR2, "x")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "y")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "origin")); } break; case PLANE: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "normal")); p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); @@ -3393,7 +3265,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } break; case QUAT: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); p_list->push_back(PropertyInfo(Variant::FLOAT, "z")); @@ -3406,14 +3277,12 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::VECTOR3, "end")); } break; case BASIS: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "x")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "y")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "z")); } break; case TRANSFORM: { - p_list->push_back(PropertyInfo(Variant::BASIS, "basis")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "origin")); @@ -3439,7 +3308,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { case _RID: { } break; case OBJECT: { - Object *obj = _get_obj().obj; if (obj) { #ifdef DEBUG_ENABLED @@ -3456,7 +3324,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } break; case DICTIONARY: { - const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); List<Variant> keys; dic->get_key_list(&keys); @@ -3476,7 +3343,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { case PACKED_VECTOR2_ARRAY: case PACKED_VECTOR3_ARRAY: case PACKED_COLOR_ARRAY: { - //nothing } break; default: { @@ -3485,7 +3351,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } bool Variant::iter_init(Variant &r_iter, bool &valid) const { - valid = true; switch (type) { case INT: { @@ -3541,7 +3406,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return step < 0; } break; case OBJECT: { - if (!_get_obj().obj) { valid = false; return false; @@ -3573,7 +3437,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { } break; case STRING: { - const String *str = reinterpret_cast<const String *>(_data._mem); if (str->empty()) return false; @@ -3581,7 +3444,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return true; } break; case DICTIONARY: { - const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); if (dic->empty()) return false; @@ -3592,7 +3454,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { } break; case ARRAY: { - const Array *arr = reinterpret_cast<const Array *>(_data._mem); if (arr->empty()) return false; @@ -3647,7 +3508,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_VECTOR2_ARRAY: { - const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array); if (arr->size() == 0) return false; @@ -3655,7 +3515,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_VECTOR3_ARRAY: { - const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array); if (arr->size() == 0) return false; @@ -3663,7 +3522,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_COLOR_ARRAY: { - const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array); if (arr->size() == 0) return false; @@ -3679,7 +3537,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return false; } bool Variant::iter_next(Variant &r_iter, bool &valid) const { - valid = true; switch (type) { case INT: { @@ -3755,7 +3612,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case OBJECT: { - if (!_get_obj().obj) { valid = false; return false; @@ -3788,7 +3644,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { } break; case STRING: { - const String *str = reinterpret_cast<const String *>(_data._mem); int idx = r_iter; idx++; @@ -3798,7 +3653,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case DICTIONARY: { - const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); const Variant *next = dic->next(&r_iter); if (!next) @@ -3809,7 +3663,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { } break; case ARRAY: { - const Array *arr = reinterpret_cast<const Array *>(_data._mem); int idx = r_iter; idx++; @@ -3878,7 +3731,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_VECTOR2_ARRAY: { - const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array); int idx = r_iter; idx++; @@ -3888,7 +3740,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_VECTOR3_ARRAY: { - const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array); int idx = r_iter; idx++; @@ -3898,7 +3749,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case PACKED_COLOR_ARRAY: { - const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array); int idx = r_iter; idx++; @@ -3916,35 +3766,27 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { } Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { - r_valid = true; switch (type) { case INT: { - return r_iter; } break; case FLOAT: { - return r_iter; } break; case VECTOR2: { - return r_iter; } break; case VECTOR2I: { - return r_iter; } break; case VECTOR3: { - return r_iter; } break; case VECTOR3I: { - return r_iter; } break; case OBJECT: { - if (!_get_obj().obj) { r_valid = false; return Variant(); @@ -3972,17 +3814,14 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { } break; case STRING: { - const String *str = reinterpret_cast<const String *>(_data._mem); return str->substr(r_iter, 1); } break; case DICTIONARY: { - return r_iter; //iterator is the same as the key } break; case ARRAY: { - const Array *arr = reinterpret_cast<const Array *>(_data._mem); int idx = r_iter; #ifdef DEBUG_ENABLED @@ -4060,7 +3899,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { return arr->get(idx); } break; case PACKED_VECTOR2_ARRAY: { - const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array); int idx = r_iter; #ifdef DEBUG_ENABLED @@ -4072,7 +3910,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { return arr->get(idx); } break; case PACKED_VECTOR3_ARRAY: { - const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array); int idx = r_iter; #ifdef DEBUG_ENABLED @@ -4084,7 +3921,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { return arr->get(idx); } break; case PACKED_COLOR_ARRAY: { - const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array); int idx = r_iter; #ifdef DEBUG_ENABLED @@ -4237,7 +4073,6 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) } void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst) { - if (a.type != b.type) { if (a.is_num() && b.is_num()) { //not as efficient but.. @@ -4252,7 +4087,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } switch (a.type) { - case NIL: { r_dst = Variant(); } @@ -4290,18 +4124,15 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & int split = csize / 2; for (int i = 0; i < csize; i++) { - CharType chr = ' '; if (i < split) { - if (i < sa.length()) chr = sa[i]; else if (i < sb.length()) chr = sb[i]; } else { - if (i < sb.length()) chr = sb[i]; else if (i < sa.length()) @@ -4423,10 +4254,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<int32_t> *arr_b = &PackedArrayRef<int32_t>::get_array(b._data.packed_array); int32_t sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<int32_t> v; v.resize(sz); { @@ -4449,10 +4278,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<int64_t> *arr_b = &PackedArrayRef<int64_t>::get_array(b._data.packed_array); int64_t sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<int64_t> v; v.resize(sz); { @@ -4475,10 +4302,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<float> *arr_b = &PackedArrayRef<float>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<float> v; v.resize(sz); { @@ -4501,10 +4326,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<double> *arr_b = &PackedArrayRef<double>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<double> v; v.resize(sz); { @@ -4531,10 +4354,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<Vector2> *arr_b = &PackedArrayRef<Vector2>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<Vector2> v; v.resize(sz); { @@ -4551,15 +4372,12 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case PACKED_VECTOR3_ARRAY: { - const Vector<Vector3> *arr_a = &PackedArrayRef<Vector3>::get_array(a._data.packed_array); const Vector<Vector3> *arr_b = &PackedArrayRef<Vector3>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<Vector3> v; v.resize(sz); { @@ -4580,10 +4398,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector<Color> *arr_b = &PackedArrayRef<Color>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { - r_dst = a; } else { - Vector<Color> v; v.resize(sz); { @@ -4600,7 +4416,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; default: { - r_dst = a; } } @@ -4636,7 +4451,6 @@ static const char *_op_names[Variant::OP_MAX] = { }; String Variant::get_operator_name(Operator p_op) { - ERR_FAIL_INDEX_V(p_op, OP_MAX, ""); return _op_names[p_op]; } |