[Core] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable
This commit is contained in:
@ -52,7 +52,7 @@ public:
|
||||
void Array::_ref(const Array &p_from) const {
|
||||
ArrayPrivate *_fp = p_from._p;
|
||||
|
||||
ERR_FAIL_COND(!_fp); // should NOT happen.
|
||||
ERR_FAIL_NULL(_fp); // Should NOT happen.
|
||||
|
||||
if (_fp == _p) {
|
||||
return; // whatever it is, nothing to do here move along
|
||||
|
||||
@ -465,20 +465,20 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const {
|
||||
|
||||
Error Signal::connect(const Callable &p_callable, uint32_t p_flags) {
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND_V(!obj, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(obj, ERR_UNCONFIGURED);
|
||||
|
||||
return obj->connect(name, p_callable, p_flags);
|
||||
}
|
||||
|
||||
void Signal::disconnect(const Callable &p_callable) {
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND(!obj);
|
||||
ERR_FAIL_NULL(obj);
|
||||
obj->disconnect(name, p_callable);
|
||||
}
|
||||
|
||||
bool Signal::is_connected(const Callable &p_callable) const {
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND_V(!obj, false);
|
||||
ERR_FAIL_NULL_V(obj, false);
|
||||
|
||||
return obj->is_connected(name, p_callable);
|
||||
}
|
||||
@ -500,7 +500,7 @@ Array Signal::get_connections() const {
|
||||
}
|
||||
|
||||
Signal::Signal(const Object *p_object, const StringName &p_name) {
|
||||
ERR_FAIL_COND_MSG(p_object == nullptr, "Object argument to Signal constructor must be non-null");
|
||||
ERR_FAIL_NULL_MSG(p_object, "Object argument to Signal constructor must be non-null.");
|
||||
|
||||
object = p_object->get_instance_id();
|
||||
name = p_name;
|
||||
|
||||
@ -113,7 +113,7 @@ struct ContainerTypeValidate {
|
||||
return true; // This is fine, it's null.
|
||||
}
|
||||
Object *object = ObjectDB::get_instance(object_id);
|
||||
ERR_FAIL_COND_V_MSG(object == nullptr, false, "Attempted to " + String(p_operation) + " an invalid (previously freed?) object instance into a '" + String(where) + ".");
|
||||
ERR_FAIL_NULL_V_MSG(object, false, "Attempted to " + String(p_operation) + " an invalid (previously freed?) object instance into a '" + String(where) + ".");
|
||||
#else
|
||||
Object *object = p_variant;
|
||||
if (object == nullptr) {
|
||||
|
||||
@ -248,7 +248,7 @@ void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) {
|
||||
}
|
||||
|
||||
void Dictionary::_unref() const {
|
||||
ERR_FAIL_COND(!_p);
|
||||
ERR_FAIL_NULL(_p);
|
||||
if (_p->refcount.unref()) {
|
||||
if (_p->read_only) {
|
||||
memdelete(_p->read_only);
|
||||
|
||||
@ -1259,28 +1259,28 @@ bool Variant::has_builtin_method(Variant::Type p_type, const StringName &p_metho
|
||||
Variant::ValidatedBuiltInMethod Variant::get_validated_builtin_method(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, nullptr);
|
||||
ERR_FAIL_NULL_V(method, nullptr);
|
||||
return method->validated_call;
|
||||
}
|
||||
|
||||
Variant::PTRBuiltInMethod Variant::get_ptr_builtin_method(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, nullptr);
|
||||
ERR_FAIL_NULL_V(method, nullptr);
|
||||
return method->ptrcall;
|
||||
}
|
||||
|
||||
int Variant::get_builtin_method_argument_count(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, 0);
|
||||
ERR_FAIL_NULL_V(method, 0);
|
||||
return method->argument_count;
|
||||
}
|
||||
|
||||
Variant::Type Variant::get_builtin_method_argument_type(Variant::Type p_type, const StringName &p_method, int p_argument) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, Variant::NIL);
|
||||
ERR_FAIL_NULL_V(method, Variant::NIL);
|
||||
ERR_FAIL_INDEX_V(p_argument, method->argument_count, Variant::NIL);
|
||||
return method->get_argument_type(p_argument);
|
||||
}
|
||||
@ -1288,7 +1288,7 @@ Variant::Type Variant::get_builtin_method_argument_type(Variant::Type p_type, co
|
||||
String Variant::get_builtin_method_argument_name(Variant::Type p_type, const StringName &p_method, int p_argument) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, String());
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, String());
|
||||
ERR_FAIL_NULL_V(method, String());
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
ERR_FAIL_INDEX_V(p_argument, method->argument_count, String());
|
||||
return method->argument_names[p_argument];
|
||||
@ -1300,14 +1300,14 @@ String Variant::get_builtin_method_argument_name(Variant::Type p_type, const Str
|
||||
Vector<Variant> Variant::get_builtin_method_default_arguments(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Vector<Variant>());
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, Vector<Variant>());
|
||||
ERR_FAIL_NULL_V(method, Vector<Variant>());
|
||||
return method->default_arguments;
|
||||
}
|
||||
|
||||
bool Variant::has_builtin_method_return_value(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, false);
|
||||
ERR_FAIL_NULL_V(method, false);
|
||||
return method->has_return_type;
|
||||
}
|
||||
|
||||
@ -1326,35 +1326,35 @@ int Variant::get_builtin_method_count(Variant::Type p_type) {
|
||||
Variant::Type Variant::get_builtin_method_return_type(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, Variant::NIL);
|
||||
ERR_FAIL_NULL_V(method, Variant::NIL);
|
||||
return method->return_type;
|
||||
}
|
||||
|
||||
bool Variant::is_builtin_method_const(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, false);
|
||||
ERR_FAIL_NULL_V(method, false);
|
||||
return method->is_const;
|
||||
}
|
||||
|
||||
bool Variant::is_builtin_method_static(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, false);
|
||||
ERR_FAIL_NULL_V(method, false);
|
||||
return method->is_static;
|
||||
}
|
||||
|
||||
bool Variant::is_builtin_method_vararg(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, false);
|
||||
ERR_FAIL_NULL_V(method, false);
|
||||
return method->is_vararg;
|
||||
}
|
||||
|
||||
uint32_t Variant::get_builtin_method_hash(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
|
||||
ERR_FAIL_COND_V(!method, 0);
|
||||
ERR_FAIL_NULL_V(method, 0);
|
||||
uint32_t hash = hash_murmur3_one_32(method->is_const);
|
||||
hash = hash_murmur3_one_32(method->is_static, hash);
|
||||
hash = hash_murmur3_one_32(method->is_vararg, hash);
|
||||
|
||||
@ -1493,7 +1493,7 @@ public:
|
||||
}
|
||||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
Object *l = right->get_validated_object();
|
||||
ERR_FAIL_COND(l == nullptr);
|
||||
ERR_FAIL_NULL(l);
|
||||
const String &a = *VariantGetInternalPtr<String>::get_ptr(left);
|
||||
|
||||
bool valid;
|
||||
@ -1527,7 +1527,7 @@ public:
|
||||
}
|
||||
static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
|
||||
Object *l = right->get_validated_object();
|
||||
ERR_FAIL_COND(l == nullptr);
|
||||
ERR_FAIL_NULL(l);
|
||||
const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left);
|
||||
|
||||
bool valid;
|
||||
|
||||
@ -318,7 +318,7 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
#define NULL_TEST(m_key) \
|
||||
ERR_FAIL_COND(!m_key)
|
||||
ERR_FAIL_NULL(m_key)
|
||||
|
||||
#else
|
||||
|
||||
@ -1068,7 +1068,7 @@ struct VariantKeyedSetGetObject {
|
||||
}
|
||||
static uint32_t ptr_has(const void *base, const void *key) {
|
||||
const Object *obj = PtrToArg<Object *>::convert(base);
|
||||
ERR_FAIL_COND_V(!obj, false);
|
||||
ERR_FAIL_NULL_V(obj, false);
|
||||
bool valid;
|
||||
obj->getvar(PtrToArg<Variant>::convert(key), &valid);
|
||||
return valid;
|
||||
@ -1245,7 +1245,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
|
||||
}
|
||||
} else if (type == OBJECT) {
|
||||
Object *obj = get_validated_object();
|
||||
ERR_FAIL_COND(!obj);
|
||||
ERR_FAIL_NULL(obj);
|
||||
obj->get_property_list(p_list);
|
||||
|
||||
} else {
|
||||
|
||||
@ -1873,7 +1873,7 @@ bool Variant::is_utility_function_vararg(const StringName &p_name) {
|
||||
|
||||
uint32_t Variant::get_utility_function_hash(const StringName &p_name) {
|
||||
const VariantUtilityFunctionInfo *bfi = utility_function_table.lookup_ptr(p_name);
|
||||
ERR_FAIL_COND_V(!bfi, 0);
|
||||
ERR_FAIL_NULL_V(bfi, 0);
|
||||
|
||||
uint32_t hash = hash_murmur3_one_32(bfi->is_vararg);
|
||||
hash = hash_murmur3_one_32(bfi->returns_value, hash);
|
||||
|
||||
Reference in New Issue
Block a user