diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2021-07-15 23:45:57 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-07-23 17:38:28 -0400 |
commit | 4e6efd1b07f1c6d53d226977ddc729333b74306a (patch) | |
tree | a52f672e7f622bb65e3b65f2a2edc9d19b1ecdcf /modules/mono | |
parent | b918c4c3ce84af1f8af2d06ef31784f48a15551a (diff) |
Use C++ iterators for Lists in many situations
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/class_db_api_json.cpp | 38 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 31 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 144 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.h | 30 | ||||
-rw-r--r-- | modules/mono/editor/code_completion.cpp | 28 | ||||
-rw-r--r-- | modules/mono/glue/base_object_glue.cpp | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 4 |
7 files changed, 124 insertions, 155 deletions
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 25193a1352..01d0e13515 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -50,8 +50,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - ClassDB::ClassInfo *t = ClassDB::classes.getptr(E->get()); + for (StringName &E : names) { + ClassDB::ClassInfo *t = ClassDB::classes.getptr(E); ERR_FAIL_COND(!t); if (t->api != p_api || !t->exposed) { continue; @@ -84,11 +84,11 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array methods; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary method_dict; methods.push_back(method_dict); - MethodBind *mb = t->method_map[F->get()]; + MethodBind *mb = t->method_map[F]; method_dict["name"] = mb->get_name(); method_dict["argument_count"] = mb->get_argument_count(); method_dict["return_type"] = mb->get_argument_type(-1); @@ -141,12 +141,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array constants; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary constant_dict; constants.push_back(constant_dict); - constant_dict["name"] = F->get(); - constant_dict["value"] = t->constant_map[F->get()]; + constant_dict["name"] = F; + constant_dict["value"] = t->constant_map[F]; } if (!constants.is_empty()) { @@ -168,12 +168,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array signals; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary signal_dict; signals.push_back(signal_dict); - MethodInfo &mi = t->signal_map[F->get()]; - signal_dict["name"] = F->get(); + MethodInfo &mi = t->signal_map[F]; + signal_dict["name"] = F; Array arguments; signal_dict["arguments"] = arguments; @@ -203,13 +203,13 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array properties; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary property_dict; properties.push_back(property_dict); - ClassDB::PropertySetGet *psg = t->property_setget.getptr(F->get()); + ClassDB::PropertySetGet *psg = t->property_setget.getptr(F); - property_dict["name"] = F->get(); + property_dict["name"] = F; property_dict["setter"] = psg->setter; property_dict["getter"] = psg->getter; } @@ -222,15 +222,15 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array property_list; //property list - for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) { + for (PropertyInfo &F : t->property_list) { Dictionary property_dict; property_list.push_back(property_dict); - property_dict["name"] = F->get().name; - property_dict["type"] = F->get().type; - property_dict["hint"] = F->get().hint; - property_dict["hint_string"] = F->get().hint_string; - property_dict["usage"] = F->get().usage; + property_dict["name"] = F.name; + property_dict["type"] = F.type; + property_dict["hint"] = F.hint; + property_dict["hint_string"] = F.hint_string; + property_dict["usage"] = F.usage; } if (!property_list.is_empty()) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 80675feb3b..0eea0f543b 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -874,9 +874,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // As scripts are going to be reloaded, must proceed without locking here - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> script : scripts) { to_reload.push_back(script); if (script->get_path().is_empty()) { @@ -936,9 +934,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } // After the state of all instances is saved, clear scripts and script instances - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> script : scripts) { while (script->instances.front()) { Object *obj = script->instances.front()->get(); obj->set_script(REF()); // Remove script and existing script instances (placeholder are not removed before domain reload) @@ -951,9 +947,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { if (gdmono->reload_scripts_domain() != OK) { // Failed to reload the scripts domain // Make sure to add the scripts back to their owners before returning - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> scr = E->get(); - + for (Ref<CSharpScript> scr : to_reload) { for (const Map<ObjectID, CSharpScript::StateBackup>::Element *F = scr->pending_reload_state.front(); F; F = F->next()) { Object *obj = ObjectDB::get_instance(F->key()); @@ -988,9 +982,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript>> to_reload_state; - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - + for (Ref<CSharpScript> script : to_reload) { #ifdef TOOLS_ENABLED script->exports_invalidated = true; #endif @@ -1095,9 +1087,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload_state.push_back(script); } - for (List<Ref<CSharpScript>>::Element *E = to_reload_state.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - + for (Ref<CSharpScript> script : to_reload_state) { for (Set<ObjectID>::Element *F = script->pending_reload_instances.front(); F; F = F->next()) { ObjectID obj_id = F->get(); Object *obj = ObjectDB::get_instance(obj_id); @@ -1741,9 +1731,9 @@ void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Va List<PropertyInfo> pinfo; get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + for (PropertyInfo &E : pinfo) { Pair<StringName, Variant> state_pair; - state_pair.first = E->get().name; + state_pair.first = E.name; ManagedType managedType; @@ -2049,8 +2039,7 @@ void CSharpInstance::connect_event_signals() { } void CSharpInstance::disconnect_event_signals() { - for (const List<Callable>::Element *E = connected_event_signals.front(); E; E = E->next()) { - const Callable &callable = E->get(); + for (const Callable &callable : connected_event_signals) { const EventSignalCallable *event_signal_callable = static_cast<const EventSignalCallable *>(callable.get_custom()); owner->disconnect(event_signal_callable->get_signal(), callable); } @@ -2324,8 +2313,8 @@ void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List values[E->key()] = E->get(); } - for (List<PropertyInfo>::Element *E = exported_members_cache.front(); E; E = E->next()) { - propnames.push_back(E->get()); + for (PropertyInfo &E : exported_members_cache) { + propnames.push_back(E); } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 620b031ddb..6ae7c88213 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -416,8 +416,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as global enum constant const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &E : global_enums) { + target_ienum = &E; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -455,8 +455,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as enum constant in the current class const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &E : target_itype->enums) { + target_ienum = &E; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -682,10 +682,10 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) { if (p_prefix_length > 0) { - for (List<ConstantInterface>::Element *E = p_ienum.constants.front(); E; E = E->next()) { + for (ConstantInterface &E : p_ienum.constants) { int curr_prefix_length = p_prefix_length; - ConstantInterface &curr_const = E->get(); + ConstantInterface &curr_const = E; String constant_name = curr_const.name; @@ -719,9 +719,7 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI } void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { - for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); - + for (const MethodInterface &imethod : p_itype.methods) { if (imethod.is_virtual) { continue; } @@ -735,8 +733,8 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = imethod.arguments.front(); F; F = F->next()) { - const TypeInterface *arg_type = _get_type_or_placeholder(F->get().type); + for (const ArgumentInterface &F : imethod.arguments) { + const TypeInterface *arg_type = _get_type_or_placeholder(F.type); im_sig += ", "; im_sig += arg_type->im_type_in; @@ -776,10 +774,10 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { if (p_itype.api_type != ClassDB::API_EDITOR) { match->get().editor_only = false; } - method_icalls_map.insert(&E->get(), &match->get()); + method_icalls_map.insert(&E, &match->get()); } else { List<InternalCall>::Element *added = method_icalls.push_back(im_icall); - method_icalls_map.insert(&E->get(), &added->get()); + method_icalls_map.insert(&E, &added->get()); } } } @@ -859,9 +857,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK); p_output.append(INDENT1 "public static partial class " BINDINGS_GLOBAL_SCOPE_CLASS "\n" INDENT1 "{"); - for (const List<ConstantInterface>::Element *E = global_constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : global_constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -894,9 +890,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { // Enums - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (EnumInterface &ienum : global_enums) { CRASH_COND(ienum.constants.is_empty()); String enum_proxy_name = ienum.cname.operator String(); @@ -921,8 +915,8 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(enum_proxy_name); p_output.append("\n" INDENT1 OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); + for (const ConstantInterface &F : ienum.constants) { + const ConstantInterface &iconstant = F; if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); @@ -1053,11 +1047,11 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : core_custom_icalls) { + ADD_INTERNAL_CALL(E); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : method_icalls) { + ADD_INTERNAL_CALL(E); } #undef ADD_INTERNAL_CALL @@ -1161,11 +1155,11 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : editor_custom_icalls) { + ADD_INTERNAL_CALL(E); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : method_icalls) { + ADD_INTERNAL_CALL(E); } #undef ADD_INTERNAL_CALL @@ -1327,9 +1321,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add constants - for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : itype.constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1360,17 +1352,15 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add enums - for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (const EnumInterface &ienum : itype.enums) { ERR_FAIL_COND_V(ienum.constants.is_empty(), ERR_BUG); output.append(MEMBER_BEGIN "public enum "); output.append(ienum.cname.operator String()); output.append(MEMBER_BEGIN OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); + for (const ConstantInterface &F : ienum.constants) { + const ConstantInterface &iconstant = F; if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); @@ -1401,8 +1391,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add properties - for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) { - const PropertyInterface &iprop = E->get(); + for (const PropertyInterface &iprop : itype.properties) { Error prop_err = _generate_cs_property(itype, iprop, output); ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err, "Failed to generate property '" + iprop.cname.operator String() + @@ -1463,15 +1452,13 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str } int method_bind_count = 0; - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_cs_method(itype, imethod, method_bind_count, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); } - for (const List<SignalInterface>::Element *E = itype.signals_.front(); E; E = E->next()) { - const SignalInterface &isignal = E->get(); + for (const SignalInterface &isignal : itype.signals_) { Error method_err = _generate_cs_signal(itype, isignal, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate signal '" + isignal.name + "' for class '" + itype.name + "'."); @@ -1678,8 +1665,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf StringBuilder default_args_doc; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_imethod.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -1855,9 +1842,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf p_output.append(p_imethod.name); p_output.append("\""); - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { + for (const ArgumentInterface &F : p_imethod.arguments) { p_output.append(", "); - p_output.append(F->get().name); + p_output.append(F.name); } p_output.append(");\n" CLOSE_BLOCK_L2); @@ -1899,8 +1886,8 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf String arguments_sig; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_isignal.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_isignal.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -2042,8 +2029,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { String ctor_method(ICALL_PREFIX + itype.proxy_name + "_Ctor"); // Used only for derived types - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_glue_method(itype, imethod, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); @@ -2114,20 +2100,20 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } bool tools_sequence = false; - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { + for (const InternalCall &E : core_custom_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!E.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (E.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(E); } if (tools_sequence) { @@ -2136,24 +2122,24 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } output.append("#ifdef TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + for (const InternalCall &E : editor_custom_icalls) + ADD_INTERNAL_CALL_REGISTRATION(E); output.append("#endif // TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { + for (const InternalCall &E : method_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!E.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (E.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(E); } if (tools_sequence) { @@ -2209,8 +2195,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_imethod.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); String c_param_name = "arg" + itos(i + 1); @@ -2623,9 +2609,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { Map<StringName, StringName> accessor_methods; - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - const PropertyInfo &property = E->get(); - + for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; } @@ -2684,8 +2668,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_method_list(type_cname, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - const MethodInfo &method_info = E->get(); + for (MethodInfo &E : method_list) { + const MethodInfo &method_info = E; int argc = method_info.arguments.size(); @@ -2840,8 +2824,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // Classes starting with an underscore are ignored unless they're used as a property setter or getter if (!imethod.is_virtual && imethod.name[0] == '_') { - for (const List<PropertyInterface>::Element *F = itype.properties.front(); F; F = F->next()) { - const PropertyInterface &iprop = F->get(); + for (const PropertyInterface &F : itype.properties) { + const PropertyInterface &iprop = F; if (iprop.setter == imethod.name || iprop.getter == imethod.name) { imethod.is_internal = true; @@ -2952,8 +2936,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } EnumInterface ienum(enum_proxy_cname); const List<StringName> &enum_constants = enum_map.get(*k); - for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - const StringName &constant_cname = E->get(); + for (const StringName &E : enum_constants) { + const StringName &constant_cname = E; String constant_name = constant_cname.operator String(); int *value = class_info->constant_map.getptr(constant_cname); ERR_FAIL_NULL_V(value, false); @@ -2989,9 +2973,9 @@ bool BindingsGenerator::_populate_object_type_interfaces() { enum_types.insert(enum_itype.cname, enum_itype); } - for (const List<String>::Element *E = constants.front(); E; E = E->next()) { - const String &constant_name = E->get(); - int *value = class_info->constant_map.getptr(StringName(E->get())); + for (const String &E : constants) { + const String &constant_name = E; + int *value = class_info->constant_map.getptr(StringName(E)); ERR_FAIL_NULL_V(value, false); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -3539,9 +3523,7 @@ void BindingsGenerator::_populate_global_constants() { } } - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - EnumInterface &ienum = E->get(); - + for (EnumInterface &ienum : global_enums) { TypeInterface enum_itype; enum_itype.is_enum = true; enum_itype.name = ienum.cname.operator String(); @@ -3571,13 +3553,13 @@ void BindingsGenerator::_populate_global_constants() { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) { + for (StringName &E : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore TypeInterface enum_itype; enum_itype.is_enum = true; - enum_itype.name = E->get().operator String(); - enum_itype.cname = E->get(); + enum_itype.name = E.operator String(); + enum_itype.cname = E; enum_itype.proxy_name = enum_itype.name; TypeInterface::postsetup_enum_type(enum_itype); enum_types.insert(enum_itype.cname, enum_itype); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 48c0e02723..a649181b20 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -357,9 +357,9 @@ class BindingsGenerator { List<SignalInterface> signals_; const MethodInterface *find_method_by_name(const StringName &p_cname) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.cname == p_cname) { + return &E; } } @@ -367,9 +367,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_name(const StringName &p_cname) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.cname == p_cname) { + return &E; } } @@ -377,9 +377,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -387,9 +387,9 @@ class BindingsGenerator { } const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -613,9 +613,9 @@ class BindingsGenerator { } const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { - for (const List<ConstantInterface>::Element *E = p_constants.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const ConstantInterface &E : p_constants) { + if (E.name == p_name) { + return &E; } } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index bbfba83e6f..308c15e7c9 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -109,9 +109,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<PropertyInfo> project_props; ProjectSettings::get_singleton()->get_property_list(&project_props); - for (List<PropertyInfo>::Element *E = project_props.front(); E; E = E->next()) { - const PropertyInfo &prop = E->get(); - + for (PropertyInfo &prop : project_props) { if (!prop.name.begins_with("input/")) { continue; } @@ -187,8 +185,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr ClassDB::get_signal_list(native, &signals, /* p_no_inheritance: */ false); } - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - const String &signal = E->get().name; + for (MethodInfo &E : signals) { + const String &signal = E.name; suggestions.push_back(quoted(signal)); } } break; @@ -199,8 +197,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_color_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -211,8 +209,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_constant_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -223,8 +221,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -235,8 +233,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_size_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -247,8 +245,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_stylebox_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 2d04cedb9b..358e390784 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -177,8 +177,8 @@ MonoArray *godot_icall_DynamicGodotObject_SetMemberList(Object *p_ptr) { MonoArray *result = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), property_list.size()); int i = 0; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get().name); + for (PropertyInfo &E : property_list) { + MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E.name); mono_array_setref(result, i, boxed); i++; } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 02d875f669..d7c5850005 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -100,8 +100,8 @@ void gd_mono_setup_runtime_main_args() { main_args.write[0] = execpath.ptrw(); int i = 1; - for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { - CharString &stored = cmdline_args_utf8.push_back(E->get().utf8())->get(); + for (String &E : cmdline_args) { + CharString &stored = cmdline_args_utf8.push_back(E.utf8())->get(); main_args.write[i] = stored.ptrw(); i++; } |