Merge pull request #93809 from akien-mga/revert-73896

Revert "Make freed object different than null in comparison operators"
This commit is contained in:
Rémi Verschelde 2024-07-01 18:28:55 +02:00
commit 8d76f0e81f
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 17 additions and 17 deletions

View file

@ -951,7 +951,7 @@ bool Variant::is_zero() const {
return *reinterpret_cast<const ::RID *>(_data._mem) == ::RID(); return *reinterpret_cast<const ::RID *>(_data._mem) == ::RID();
} }
case OBJECT: { case OBJECT: {
return get_validated_object() == nullptr; return _get_obj().obj == nullptr;
} }
case CALLABLE: { case CALLABLE: {
return reinterpret_cast<const Callable *>(_data._mem)->is_null(); return reinterpret_cast<const Callable *>(_data._mem)->is_null();

View file

@ -548,14 +548,14 @@ public:
class OperatorEvaluatorEqualObject { class OperatorEvaluatorEqualObject {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
const ObjectID &a = VariantInternal::get_object_id(&p_left); const Object *a = p_left.get_validated_object();
const ObjectID &b = VariantInternal::get_object_id(&p_right); const Object *b = p_right.get_validated_object();
*r_ret = a == b; *r_ret = a == b;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
const ObjectID &a = VariantInternal::get_object_id(left); const Object *a = left->get_validated_object();
const ObjectID &b = VariantInternal::get_object_id(right); const Object *b = right->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
@ -567,12 +567,12 @@ public:
class OperatorEvaluatorEqualObjectNil { class OperatorEvaluatorEqualObjectNil {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
const Object *a = p_left.operator Object *(); const Object *a = p_left.get_validated_object();
*r_ret = a == nullptr; *r_ret = a == nullptr;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
const Object *a = left->operator Object *(); const Object *a = left->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
@ -584,12 +584,12 @@ public:
class OperatorEvaluatorEqualNilObject { class OperatorEvaluatorEqualNilObject {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
const Object *b = p_right.operator Object *(); const Object *b = p_right.get_validated_object();
*r_ret = nullptr == b; *r_ret = nullptr == b;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
const Object *b = right->operator Object *(); const Object *b = right->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
@ -619,14 +619,14 @@ public:
class OperatorEvaluatorNotEqualObject { class OperatorEvaluatorNotEqualObject {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
const ObjectID &a = VariantInternal::get_object_id(&p_left); Object *a = p_left.get_validated_object();
const ObjectID &b = VariantInternal::get_object_id(&p_right); Object *b = p_right.get_validated_object();
*r_ret = a != b; *r_ret = a != b;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
const ObjectID &a = VariantInternal::get_object_id(left); Object *a = left->get_validated_object();
const ObjectID &b = VariantInternal::get_object_id(right); Object *b = right->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
@ -638,12 +638,12 @@ public:
class OperatorEvaluatorNotEqualObjectNil { class OperatorEvaluatorNotEqualObjectNil {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
Object *a = p_left.operator Object *(); Object *a = p_left.get_validated_object();
*r_ret = a != nullptr; *r_ret = a != nullptr;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
Object *a = left->operator Object *(); Object *a = left->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
@ -655,12 +655,12 @@ public:
class OperatorEvaluatorNotEqualNilObject { class OperatorEvaluatorNotEqualNilObject {
public: public:
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
Object *b = p_right.operator Object *(); Object *b = p_right.get_validated_object();
*r_ret = nullptr != b; *r_ret = nullptr != b;
r_valid = true; r_valid = true;
} }
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
Object *b = right->operator Object *(); Object *b = right->get_validated_object();
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b; *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b;
} }
static void ptr_evaluate(const void *left, const void *right, void *r_ret) { static void ptr_evaluate(const void *left, const void *right, void *r_ret) {