Merge pull request #95166 from aaronp64/variant_op_err_return
Assign return value on `Variant` operator failure
This commit is contained in:
commit
1b19ecb360
|
@ -923,7 +923,10 @@ public:
|
|||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
bool valid = true;
|
||||
String result = do_mod(*VariantGetInternalPtr<S>::get_ptr(left), &valid);
|
||||
ERR_FAIL_COND_MSG(!valid, result);
|
||||
if (unlikely(!valid)) {
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = *VariantGetInternalPtr<S>::get_ptr(left);
|
||||
ERR_FAIL_MSG(vformat("String formatting error: %s.", result));
|
||||
}
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = result;
|
||||
}
|
||||
static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
|
||||
|
@ -948,7 +951,10 @@ public:
|
|||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
bool valid = true;
|
||||
String result = do_mod(*VariantGetInternalPtr<S>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right), &valid);
|
||||
ERR_FAIL_COND_MSG(!valid, result);
|
||||
if (unlikely(!valid)) {
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = *VariantGetInternalPtr<S>::get_ptr(left);
|
||||
ERR_FAIL_MSG(vformat("String formatting error: %s.", result));
|
||||
}
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = result;
|
||||
}
|
||||
static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
|
||||
|
@ -976,7 +982,10 @@ public:
|
|||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
bool valid = true;
|
||||
String result = do_mod(*VariantGetInternalPtr<S>::get_ptr(left), right->get_validated_object(), &valid);
|
||||
ERR_FAIL_COND_MSG(!valid, result);
|
||||
if (unlikely(!valid)) {
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = *VariantGetInternalPtr<S>::get_ptr(left);
|
||||
ERR_FAIL_MSG(vformat("String formatting error: %s.", result));
|
||||
}
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = result;
|
||||
}
|
||||
static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
|
||||
|
@ -1003,7 +1012,10 @@ public:
|
|||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
bool valid = true;
|
||||
String result = do_mod(*VariantGetInternalPtr<S>::get_ptr(left), *VariantGetInternalPtr<T>::get_ptr(right), &valid);
|
||||
ERR_FAIL_COND_MSG(!valid, result);
|
||||
if (unlikely(!valid)) {
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = *VariantGetInternalPtr<S>::get_ptr(left);
|
||||
ERR_FAIL_MSG(vformat("String formatting error: %s.", result));
|
||||
}
|
||||
*VariantGetInternalPtr<String>::get_ptr(r_ret) = result;
|
||||
}
|
||||
static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
|
||||
|
@ -1492,7 +1504,10 @@ public:
|
|||
}
|
||||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
Object *l = right->get_validated_object();
|
||||
ERR_FAIL_NULL(l);
|
||||
if (unlikely(!l)) {
|
||||
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = false;
|
||||
ERR_FAIL_MSG("Invalid base object for 'in'.");
|
||||
}
|
||||
const String &a = *VariantGetInternalPtr<String>::get_ptr(left);
|
||||
|
||||
bool valid;
|
||||
|
@ -1526,7 +1541,10 @@ public:
|
|||
}
|
||||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
Object *l = right->get_validated_object();
|
||||
ERR_FAIL_NULL(l);
|
||||
if (unlikely(!l)) {
|
||||
*VariantGetInternalPtr<bool>::get_ptr(r_ret) = false;
|
||||
ERR_FAIL_MSG("Invalid base object for 'in'.");
|
||||
}
|
||||
const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left);
|
||||
|
||||
bool valid;
|
||||
|
|
Loading…
Reference in New Issue