summaryrefslogtreecommitdiff
path: root/core/variant
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/type_info.h2
-rw-r--r--core/variant/typed_array.h4
-rw-r--r--core/variant/variant.cpp60
-rw-r--r--core/variant/variant.h12
-rw-r--r--core/variant/variant_call.cpp2
-rw-r--r--core/variant/variant_construct.cpp4
-rw-r--r--core/variant/variant_internal.h20
-rw-r--r--core/variant/variant_op.cpp12
-rw-r--r--core/variant/variant_setget.cpp2
9 files changed, 60 insertions, 58 deletions
diff --git a/core/variant/type_info.h b/core/variant/type_info.h
index b9ae88d97c..ce7c2bfe14 100644
--- a/core/variant/type_info.h
+++ b/core/variant/type_info.h
@@ -153,7 +153,7 @@ MAKE_TYPE_INFO(Transform, Variant::TRANSFORM)
MAKE_TYPE_INFO(Color, Variant::COLOR)
MAKE_TYPE_INFO(StringName, Variant::STRING_NAME)
MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH)
-MAKE_TYPE_INFO(RID, Variant::_RID)
+MAKE_TYPE_INFO(RID, Variant::RID)
MAKE_TYPE_INFO(Callable, Variant::CALLABLE)
MAKE_TYPE_INFO(Signal, Variant::SIGNAL)
MAKE_TYPE_INFO(Dictionary, Variant::DICTIONARY)
diff --git a/core/variant/typed_array.h b/core/variant/typed_array.h
index 0f3985b2f1..ff42cb687e 100644
--- a/core/variant/typed_array.h
+++ b/core/variant/typed_array.h
@@ -105,7 +105,7 @@ MAKE_TYPED_ARRAY(Transform, Variant::TRANSFORM)
MAKE_TYPED_ARRAY(Color, Variant::COLOR)
MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME)
MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH)
-MAKE_TYPED_ARRAY(RID, Variant::_RID)
+MAKE_TYPED_ARRAY(RID, Variant::RID)
MAKE_TYPED_ARRAY(Callable, Variant::CALLABLE)
MAKE_TYPED_ARRAY(Signal, Variant::SIGNAL)
MAKE_TYPED_ARRAY(Dictionary, Variant::DICTIONARY)
@@ -207,7 +207,7 @@ MAKE_TYPED_ARRAY_INFO(Transform, Variant::TRANSFORM)
MAKE_TYPED_ARRAY_INFO(Color, Variant::COLOR)
MAKE_TYPED_ARRAY_INFO(StringName, Variant::STRING_NAME)
MAKE_TYPED_ARRAY_INFO(NodePath, Variant::NODE_PATH)
-MAKE_TYPED_ARRAY_INFO(RID, Variant::_RID)
+MAKE_TYPED_ARRAY_INFO(RID, Variant::RID)
MAKE_TYPED_ARRAY_INFO(Callable, Variant::CALLABLE)
MAKE_TYPED_ARRAY_INFO(Signal, Variant::SIGNAL)
MAKE_TYPED_ARRAY_INFO(Dictionary, Variant::DICTIONARY)
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 73916bbef9..3114a358f7 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -109,7 +109,7 @@ String Variant::get_type_name(Variant::Type p_type) {
return "Color";
} break;
- case _RID: {
+ case RID: {
return "RID";
} break;
case OBJECT: {
@@ -342,7 +342,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
- case _RID: {
+ case RID: {
static const Type valid[] = {
OBJECT,
NIL
@@ -649,7 +649,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
- case _RID: {
+ case RID: {
static const Type valid[] = {
OBJECT,
NIL
@@ -891,8 +891,8 @@ bool Variant::is_zero() const {
return *reinterpret_cast<const Color *>(_data._mem) == Color();
} break;
- case _RID: {
- return *reinterpret_cast<const RID *>(_data._mem) == RID();
+ case RID: {
+ return *reinterpret_cast<const ::RID *>(_data._mem) == ::RID();
} break;
case OBJECT: {
return _get_obj().obj == nullptr;
@@ -1109,8 +1109,8 @@ void Variant::reference(const Variant &p_variant) {
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)));
+ case RID: {
+ memnew_placement(_data._mem, ::RID(*reinterpret_cast<const ::RID *>(p_variant._data._mem)));
} break;
case OBJECT: {
memnew_placement(_data._mem, ObjData);
@@ -1311,9 +1311,11 @@ void Variant::_clear_internal() {
_get_obj().obj = nullptr;
_get_obj().id = ObjectID();
} break;
- case _RID: {
+ case RID: {
// not much need probably
- reinterpret_cast<RID *>(_data._mem)->~RID();
+ // Can't seem to use destructor + scoping operator, so hack.
+ typedef ::RID RID_Class;
+ reinterpret_cast<RID_Class *>(_data._mem)->~RID_Class();
} break;
case CALLABLE: {
reinterpret_cast<Callable *>(_data._mem)->~Callable();
@@ -1847,8 +1849,8 @@ String Variant::stringify(List<const void *> &stack) const {
const Signal &s = *reinterpret_cast<const Signal *>(_data._mem);
return s;
} break;
- case _RID: {
- const RID &s = *reinterpret_cast<const RID *>(_data._mem);
+ case RID: {
+ const ::RID &s = *reinterpret_cast<const ::RID *>(_data._mem);
return "RID(" + itos(s.get_id()) + ")";
} break;
default: {
@@ -2039,25 +2041,25 @@ Variant::operator NodePath() const {
}
}
-Variant::operator RID() const {
- if (type == _RID) {
- return *reinterpret_cast<const RID *>(_data._mem);
+Variant::operator ::RID() const {
+ if (type == RID) {
+ return *reinterpret_cast<const ::RID *>(_data._mem);
} else if (type == OBJECT && _get_obj().obj == nullptr) {
- return RID();
+ return ::RID();
} else if (type == OBJECT && _get_obj().obj) {
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_active()) {
- ERR_FAIL_COND_V_MSG(ObjectDB::get_instance(_get_obj().id) == nullptr, RID(), "Invalid pointer (object was freed).");
+ ERR_FAIL_COND_V_MSG(ObjectDB::get_instance(_get_obj().id) == nullptr, ::RID(), "Invalid pointer (object was freed).");
}
#endif
Callable::CallError ce;
Variant ret = _get_obj().obj->call(CoreStringNames::get_singleton()->get_rid, nullptr, 0, ce);
- if (ce.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::_RID) {
+ if (ce.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::RID) {
return ret;
}
- return RID();
+ return ::RID();
} else {
- return RID();
+ return ::RID();
}
}
@@ -2261,9 +2263,9 @@ Variant::operator Vector<Color>() const {
/* helpers */
-Variant::operator Vector<RID>() const {
+Variant::operator Vector<::RID>() const {
Array va = operator Array();
- Vector<RID> rids;
+ Vector<::RID> rids;
rids.resize(va.size());
for (int i = 0; i < rids.size(); i++) {
rids.write[i] = va[i];
@@ -2518,9 +2520,9 @@ Variant::Variant(const NodePath &p_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 ::RID &p_rid) {
+ type = RID;
+ memnew_placement(_data._mem, ::RID(p_rid));
}
Variant::Variant(const Object *p_object) {
@@ -2578,7 +2580,7 @@ Variant::Variant(const Vector<Plane> &p_array) {
}
}
-Variant::Variant(const Vector<RID> &p_array) {
+Variant::Variant(const Vector<::RID> &p_array) {
type = ARRAY;
Array *rid_array = memnew_placement(_data._mem, Array);
@@ -2751,8 +2753,8 @@ void Variant::operator=(const Variant &p_variant) {
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);
+ case RID: {
+ *reinterpret_cast<::RID *>(_data._mem) = *reinterpret_cast<const ::RID *>(p_variant._data._mem);
} break;
case OBJECT: {
if (_get_obj().id.is_reference()) {
@@ -2953,8 +2955,8 @@ uint32_t Variant::hash() const {
return hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->a, hash);
} break;
- case _RID: {
- return hash_djb2_one_64(reinterpret_cast<const RID *>(_data._mem)->get_id());
+ 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));
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 55927ff211..8bb28b2406 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -97,7 +97,7 @@ public:
COLOR,
STRING_NAME,
NODE_PATH,
- _RID,
+ RID,
OBJECT,
CALLABLE,
SIGNAL,
@@ -234,7 +234,7 @@ private:
false, //COLOR,
true, //STRING_NAME,
true, //NODE_PATH,
- false, //_RID,
+ false, //RID,
true, //OBJECT,
true, //CALLABLE,
true, //SIGNAL,
@@ -325,7 +325,7 @@ public:
operator Color() const;
operator NodePath() const;
- operator RID() const;
+ operator ::RID() const;
operator Object *() const;
operator Node *() const;
@@ -350,7 +350,7 @@ public:
operator Vector<Variant>() const;
operator Vector<StringName>() const;
- operator Vector<RID>() const;
+ operator Vector<::RID>() const;
operator Vector<Vector2>() const;
// some core type enums to convert to
@@ -397,7 +397,7 @@ public:
Variant(const Transform &p_transform);
Variant(const Color &p_color);
Variant(const NodePath &p_node_path);
- Variant(const RID &p_rid);
+ Variant(const ::RID &p_rid);
Variant(const Object *p_object);
Variant(const Callable &p_callable);
Variant(const Signal &p_signal);
@@ -417,7 +417,7 @@ public:
Variant(const Vector<Variant> &p_array);
Variant(const Vector<StringName> &p_array);
- Variant(const Vector<RID> &p_array); // helper
+ Variant(const Vector<::RID> &p_array); // helper
Variant(const Vector<Vector2> &p_array); // helper
Variant(const IP_Address &p_address);
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 5b9d9e9e8d..929a8e2cc8 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1219,7 +1219,7 @@ void Variant::_register_variant_methods() {
/* RID */
- bind_method(RID, get_id, sarray(), varray());
+ bind_method(::RID, get_id, sarray(), varray());
/* NodePath */
diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp
index b847ba09b9..e263d98815 100644
--- a/core/variant/variant_construct.cpp
+++ b/core/variant/variant_construct.cpp
@@ -577,7 +577,7 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructor<NodePath, NodePath>>(sarray("from"));
add_constructor<VariantConstructor<NodePath, String>>(sarray("from"));
- add_constructor<VariantConstructor<RID, RID>>(sarray("from"));
+ add_constructor<VariantConstructor<::RID, ::RID>>(sarray("from"));
add_constructor<VariantConstructorObject>(sarray("from"));
add_constructor<VariantConstructorNilObject>(sarray("from"));
@@ -654,7 +654,7 @@ void Variant::_register_variant_constructors() {
initialize_funcs[COLOR] = variant_initialize<Color>;
initialize_funcs[STRING_NAME] = variant_initialize<StringName>;
initialize_funcs[NODE_PATH] = variant_initialize<NodePath>;
- initialize_funcs[_RID] = variant_initialize<RID>;
+ initialize_funcs[RID] = variant_initialize<::RID>;
initialize_funcs[OBJECT] = variant_initialize_obj;
initialize_funcs[CALLABLE] = variant_initialize<Callable>;
initialize_funcs[SIGNAL] = variant_initialize<Signal>;
diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h
index 7fd165aa81..eca02ad4ae 100644
--- a/core/variant/variant_internal.h
+++ b/core/variant/variant_internal.h
@@ -83,8 +83,8 @@ public:
_FORCE_INLINE_ static const StringName *get_string_name(const Variant *v) { return reinterpret_cast<const StringName *>(v->_data._mem); }
_FORCE_INLINE_ static NodePath *get_node_path(Variant *v) { return reinterpret_cast<NodePath *>(v->_data._mem); }
_FORCE_INLINE_ static const NodePath *get_node_path(const Variant *v) { return reinterpret_cast<const NodePath *>(v->_data._mem); }
- _FORCE_INLINE_ static RID *get_rid(Variant *v) { return reinterpret_cast<RID *>(v->_data._mem); }
- _FORCE_INLINE_ static const RID *get_rid(const Variant *v) { return reinterpret_cast<const RID *>(v->_data._mem); }
+ _FORCE_INLINE_ static ::RID *get_rid(Variant *v) { return reinterpret_cast<::RID *>(v->_data._mem); }
+ _FORCE_INLINE_ static const ::RID *get_rid(const Variant *v) { return reinterpret_cast<const ::RID *>(v->_data._mem); }
_FORCE_INLINE_ static Callable *get_callable(Variant *v) { return reinterpret_cast<Callable *>(v->_data._mem); }
_FORCE_INLINE_ static const Callable *get_callable(const Variant *v) { return reinterpret_cast<const Callable *>(v->_data._mem); }
_FORCE_INLINE_ static Signal *get_signal(Variant *v) { return reinterpret_cast<Signal *>(v->_data._mem); }
@@ -405,9 +405,9 @@ struct VariantGetInternalPtr<NodePath> {
};
template <>
-struct VariantGetInternalPtr<RID> {
- static RID *get_ptr(Variant *v) { return VariantInternal::get_rid(v); }
- static const RID *get_ptr(const Variant *v) { return VariantInternal::get_rid(v); }
+struct VariantGetInternalPtr<::RID> {
+ static ::RID *get_ptr(Variant *v) { return VariantInternal::get_rid(v); }
+ static const ::RID *get_ptr(const Variant *v) { return VariantInternal::get_rid(v); }
};
template <>
@@ -632,9 +632,9 @@ struct VariantInternalAccessor<NodePath> {
};
template <>
-struct VariantInternalAccessor<RID> {
- static _FORCE_INLINE_ const RID &get(const Variant *v) { return *VariantInternal::get_rid(v); }
- static _FORCE_INLINE_ void set(Variant *v, const RID &p_value) { *VariantInternal::get_rid(v) = p_value; }
+struct VariantInternalAccessor<::RID> {
+ static _FORCE_INLINE_ const ::RID &get(const Variant *v) { return *VariantInternal::get_rid(v); }
+ static _FORCE_INLINE_ void set(Variant *v, const ::RID &p_value) { *VariantInternal::get_rid(v) = p_value; }
};
template <>
@@ -867,8 +867,8 @@ struct VariantInitializer<NodePath> {
};
template <>
-struct VariantInitializer<RID> {
- static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_generic<RID>(v); }
+struct VariantInitializer<::RID> {
+ static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_generic<::RID>(v); }
};
template <>
diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp
index 0def758388..4704deac20 100644
--- a/core/variant/variant_op.cpp
+++ b/core/variant/variant_op.cpp
@@ -1778,7 +1778,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorEqual<StringName, StringName>>(Variant::OP_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorEqual<NodePath, NodePath>>(Variant::OP_EQUAL, Variant::NODE_PATH, Variant::NODE_PATH);
- register_op<OperatorEvaluatorEqual<RID, RID>>(Variant::OP_EQUAL, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorEqual<::RID, ::RID>>(Variant::OP_EQUAL, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorEqualObject>(Variant::OP_EQUAL, Variant::OBJECT, Variant::OBJECT);
register_op<OperatorEvaluatorEqualObjectNil>(Variant::OP_EQUAL, Variant::OBJECT, Variant::NIL);
@@ -1824,7 +1824,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorNotEqual<StringName, StringName>>(Variant::OP_NOT_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorNotEqual<NodePath, NodePath>>(Variant::OP_NOT_EQUAL, Variant::NODE_PATH, Variant::NODE_PATH);
- register_op<OperatorEvaluatorNotEqual<RID, RID>>(Variant::OP_NOT_EQUAL, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorNotEqual<::RID, ::RID>>(Variant::OP_NOT_EQUAL, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorNotEqualObject>(Variant::OP_NOT_EQUAL, Variant::OBJECT, Variant::OBJECT);
register_op<OperatorEvaluatorNotEqualObjectNil>(Variant::OP_NOT_EQUAL, Variant::OBJECT, Variant::NIL);
@@ -1854,7 +1854,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLess<Vector2i, Vector2i>>(Variant::OP_LESS, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLess<Vector3, Vector3>>(Variant::OP_LESS, Variant::VECTOR3, Variant::VECTOR3);
register_op<OperatorEvaluatorLess<Vector3i, Vector3i>>(Variant::OP_LESS, Variant::VECTOR3I, Variant::VECTOR3I);
- register_op<OperatorEvaluatorLess<RID, RID>>(Variant::OP_LESS, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorLess<::RID, ::RID>>(Variant::OP_LESS, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorLess<Array, Array>>(Variant::OP_LESS, Variant::ARRAY, Variant::ARRAY);
register_op<OperatorEvaluatorLessEqual<int64_t, int64_t>>(Variant::OP_LESS_EQUAL, Variant::INT, Variant::INT);
@@ -1866,7 +1866,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLessEqual<Vector2i, Vector2i>>(Variant::OP_LESS_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLessEqual<Vector3, Vector3>>(Variant::OP_LESS_EQUAL, Variant::VECTOR3, Variant::VECTOR3);
register_op<OperatorEvaluatorLessEqual<Vector3i, Vector3i>>(Variant::OP_LESS_EQUAL, Variant::VECTOR3I, Variant::VECTOR3I);
- register_op<OperatorEvaluatorLessEqual<RID, RID>>(Variant::OP_LESS_EQUAL, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorLessEqual<::RID, ::RID>>(Variant::OP_LESS_EQUAL, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorLessEqual<Array, Array>>(Variant::OP_LESS_EQUAL, Variant::ARRAY, Variant::ARRAY);
register_op<OperatorEvaluatorGreater<bool, bool>>(Variant::OP_GREATER, Variant::BOOL, Variant::BOOL);
@@ -1879,7 +1879,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreater<Vector2i, Vector2i>>(Variant::OP_GREATER, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreater<Vector3, Vector3>>(Variant::OP_GREATER, Variant::VECTOR3, Variant::VECTOR3);
register_op<OperatorEvaluatorGreater<Vector3i, Vector3i>>(Variant::OP_GREATER, Variant::VECTOR3I, Variant::VECTOR3I);
- register_op<OperatorEvaluatorGreater<RID, RID>>(Variant::OP_GREATER, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorGreater<::RID, ::RID>>(Variant::OP_GREATER, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorGreater<Array, Array>>(Variant::OP_GREATER, Variant::ARRAY, Variant::ARRAY);
register_op<OperatorEvaluatorGreaterEqual<int64_t, int64_t>>(Variant::OP_GREATER_EQUAL, Variant::INT, Variant::INT);
@@ -1891,7 +1891,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreaterEqual<Vector2i, Vector2i>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreaterEqual<Vector3, Vector3>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR3, Variant::VECTOR3);
register_op<OperatorEvaluatorGreaterEqual<Vector3i, Vector3i>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR3I, Variant::VECTOR3I);
- register_op<OperatorEvaluatorGreaterEqual<RID, RID>>(Variant::OP_GREATER_EQUAL, Variant::_RID, Variant::_RID);
+ register_op<OperatorEvaluatorGreaterEqual<::RID, ::RID>>(Variant::OP_GREATER_EQUAL, Variant::RID, Variant::RID);
register_op<OperatorEvaluatorGreaterEqual<Array, Array>>(Variant::OP_GREATER_EQUAL, Variant::ARRAY, Variant::ARRAY);
register_op<OperatorEvaluatorAlwaysFalse<Variant::OP_OR, Variant::NIL, Variant::NIL>>(Variant::OP_OR, Variant::NIL, Variant::NIL);
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index cae64376d5..05fe2b80d9 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -2385,7 +2385,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = a;
}
return;
- case _RID: {
+ case RID: {
r_dst = a;
}
return;