diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2023-09-09 17:40:07 +0200 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2023-09-26 16:44:52 +0200 |
commit | 517e9f8aefed8925c1b66932a0d3cb887e99d267 (patch) | |
tree | e62fccf23a2f155d5c5799aebe5b0837e33c6377 /modules/gdscript | |
parent | 36945dad0730ee013547493df60c4c59567b4290 (diff) | |
download | redot-engine-517e9f8aefed8925c1b66932a0d3cb887e99d267.tar.gz |
[Modules] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_cache.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_function.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_function.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_rpc_callable.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_utility_functions.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_language_protocol.cpp | 4 |
11 files changed, 21 insertions, 21 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 62d2c14c17..22be26fdc1 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -83,7 +83,7 @@ void GDScriptNativeClass::_bind_methods() { Variant GDScriptNativeClass::_new() { Object *o = instantiate(); - ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable."); + ERR_FAIL_NULL_V_MSG(o, Variant(), "Class type: '" + String(name) + "' is not instantiable."); RefCounted *rc = Object::cast_to<RefCounted>(o); if (rc) { @@ -215,7 +215,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr } else { owner = memnew(RefCounted); //by default, no base means use reference } - ERR_FAIL_COND_V_MSG(!owner, Variant(), "Can't inherit from a virtual class."); + ERR_FAIL_NULL_V_MSG(owner, Variant(), "Can't inherit from a virtual class."); RefCounted *r = Object::cast_to<RefCounted>(owner); if (r) { diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 5b47ed1a46..55bb99133a 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1419,7 +1419,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, bo } void GDScriptAnalyzer::resolve_node(GDScriptParser::Node *p_node, bool p_is_root) { - ERR_FAIL_COND_MSG(p_node == nullptr, "Trying to resolve type of a null node."); + ERR_FAIL_NULL_MSG(p_node, "Trying to resolve type of a null node."); switch (p_node->type) { case GDScriptParser::Node::NONE: diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index d191bd0224..18609d0b80 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -59,7 +59,7 @@ GDScriptAnalyzer *GDScriptParserRef::get_analyzer() { } Error GDScriptParserRef::raise_status(Status p_new_status) { - ERR_FAIL_COND_V(parser == nullptr, ERR_INVALID_DATA); + ERR_FAIL_NULL_V(parser, ERR_INVALID_DATA); if (result != OK) { return result; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 9a9e96b8e8..97e02ac716 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -60,7 +60,7 @@ bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringNa scr = scr->_base; } - ERR_FAIL_COND_V(!nc, false); + ERR_FAIL_NULL_V(nc, false); return ClassDB::has_property(nc->get_name(), p_name); } diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 4f5a65a709..3e13d1525d 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -188,7 +188,7 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const { } Variant GDScriptFunctionState::resume(const Variant &p_arg) { - ERR_FAIL_COND_V(!function, Variant()); + ERR_FAIL_NULL_V(function, Variant()); { MutexLock lock(GDScriptLanguage::singleton->mutex); diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 31da70f9ae..e984d97149 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -152,7 +152,7 @@ public: } GDScriptDataType get_container_element_type() const { - ERR_FAIL_COND_V(container_element_type == nullptr, GDScriptDataType()); + ERR_FAIL_NULL_V(container_element_type, GDScriptDataType()); return *container_element_type; } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1202e7e235..0801582dbd 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -170,7 +170,7 @@ void GDScriptParser::push_error(const String &p_message, const Node *p_origin) { #ifdef DEBUG_ENABLED void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_code, const Vector<String> &p_symbols) { - ERR_FAIL_COND(p_source == nullptr); + ERR_FAIL_NULL(p_source); if (is_ignoring_warnings) { return; } diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 988524d058..3bd3696e99 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -156,7 +156,7 @@ public: } _FORCE_INLINE_ DataType get_container_element_type() const { - ERR_FAIL_COND_V(container_element_type == nullptr, DataType()); + ERR_FAIL_NULL_V(container_element_type, DataType()); return *container_element_type; } diff --git a/modules/gdscript/gdscript_rpc_callable.cpp b/modules/gdscript/gdscript_rpc_callable.cpp index 199ea81330..a6d2388a91 100644 --- a/modules/gdscript/gdscript_rpc_callable.cpp +++ b/modules/gdscript/gdscript_rpc_callable.cpp @@ -78,7 +78,7 @@ GDScriptRPCCallable::GDScriptRPCCallable(Object *p_object, const StringName &p_m h = method.hash(); h = hash_murmur3_one_64(object->get_instance_id(), h); node = Object::cast_to<Node>(object); - ERR_FAIL_COND_MSG(!node, "RPC can only be defined on class that extends Node."); + ERR_FAIL_NULL_MSG(node, "RPC can only be defined on class that extends Node."); } Error GDScriptRPCCallable::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const { diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 39cf9d79c8..d85b12b7fe 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -729,50 +729,50 @@ void GDScriptUtilityFunctions::unregister_functions() { GDScriptUtilityFunctions::FunctionPtr GDScriptUtilityFunctions::get_function(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, nullptr); + ERR_FAIL_NULL_V(info, nullptr); return info->function; } bool GDScriptUtilityFunctions::has_function_return_value(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, false); + ERR_FAIL_NULL_V(info, false); return info->info.return_val.type != Variant::NIL || bool(info->info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT); } Variant::Type GDScriptUtilityFunctions::get_function_return_type(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, Variant::NIL); + ERR_FAIL_NULL_V(info, Variant::NIL); return info->info.return_val.type; } StringName GDScriptUtilityFunctions::get_function_return_class(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, StringName()); + ERR_FAIL_NULL_V(info, StringName()); return info->info.return_val.class_name; } Variant::Type GDScriptUtilityFunctions::get_function_argument_type(const StringName &p_function, int p_arg) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, Variant::NIL); + ERR_FAIL_NULL_V(info, Variant::NIL); ERR_FAIL_COND_V(p_arg >= info->info.arguments.size(), Variant::NIL); return info->info.arguments[p_arg].type; } int GDScriptUtilityFunctions::get_function_argument_count(const StringName &p_function, int p_arg) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, 0); + ERR_FAIL_NULL_V(info, 0); return info->info.arguments.size(); } bool GDScriptUtilityFunctions::is_function_vararg(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, false); + ERR_FAIL_NULL_V(info, false); return (bool)(info->info.flags & METHOD_FLAG_VARARG); } bool GDScriptUtilityFunctions::is_function_constant(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, false); + ERR_FAIL_NULL_V(info, false); return info->is_constant; } @@ -788,6 +788,6 @@ void GDScriptUtilityFunctions::get_function_list(List<StringName> *r_functions) MethodInfo GDScriptUtilityFunctions::get_function_info(const StringName &p_function) { GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function); - ERR_FAIL_COND_V(!info, MethodInfo()); + ERR_FAIL_NULL_V(info, MethodInfo()); return info->info; } diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 14fc21d7dc..8489fc08c1 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -290,7 +290,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia } ERR_FAIL_COND(!clients.has(p_client_id)); Ref<LSPeer> peer = clients.get(p_client_id); - ERR_FAIL_COND(peer == nullptr); + ERR_FAIL_NULL(peer); Dictionary message = make_notification(p_method, p_params); String msg = Variant(message).to_json_string(); @@ -311,7 +311,7 @@ void GDScriptLanguageProtocol::request_client(const String &p_method, const Vari } ERR_FAIL_COND(!clients.has(p_client_id)); Ref<LSPeer> peer = clients.get(p_client_id); - ERR_FAIL_COND(peer == nullptr); + ERR_FAIL_NULL(peer); Dictionary message = make_request(p_method, p_params, next_server_id); next_server_id++; |