diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 28 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_extend_parser.cpp | 10 | ||||
-rw-r--r-- | modules/gdscript/language_server/lsp.hpp | 52 | ||||
-rw-r--r-- | modules/glslang/register_types.cpp | 2 | ||||
-rw-r--r-- | modules/lightmapper_rd/lightmapper_rd.cpp | 16 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 119 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs | 22 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 4 | ||||
-rw-r--r-- | modules/mono/editor/code_completion.cpp | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_assembly.cpp | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_class.cpp | 8 | ||||
-rw-r--r-- | modules/webrtc/webrtc_multiplayer_peer.cpp | 10 | ||||
-rw-r--r-- | modules/websocket/wsl_server.cpp | 4 |
13 files changed, 147 insertions, 136 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index bcb53508ea..8957b00a1b 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1804,10 +1804,10 @@ void GDScriptLanguage::reload_all_scripts() { scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (Ref<GDScript> E : scripts) { - print_verbose("GDScript: Reloading: " + E->get_path()); - E->load_source_code(E->get_path()); - E->reload(true); + for (Ref<GDScript> &script : scripts) { + print_verbose("GDScript: Reloading: " + script->get_path()); + script->load_source_code(script->get_path()); + script->reload(true); } #endif } @@ -1836,21 +1836,21 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (Ref<GDScript> E : scripts) { - bool reload = E == p_script || to_reload.has(E->get_base()); + for (Ref<GDScript> &script : scripts) { + bool reload = script == p_script || to_reload.has(script->get_base()); if (!reload) { continue; } - to_reload.insert(E, Map<ObjectID, List<Pair<StringName, Variant>>>()); + to_reload.insert(script, Map<ObjectID, List<Pair<StringName, Variant>>>()); if (!p_soft_reload) { //save state and remove script from instances - Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[E]; + Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[script]; - while (E->instances.front()) { - Object *obj = E->instances.front()->get(); + while (script->instances.front()) { + Object *obj = script->instances.front()->get(); //save instance info List<Pair<StringName, Variant>> state; if (obj->get_script_instance()) { @@ -1863,8 +1863,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so //same thing for placeholders #ifdef TOOLS_ENABLED - while (E->placeholders.size()) { - Object *obj = E->placeholders.front()->get()->get_owner(); + while (script->placeholders.size()) { + Object *obj = script->placeholders.front()->get()->get_owner(); //save instance info if (obj->get_script_instance()) { @@ -1874,13 +1874,13 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so obj->set_script(Variant()); } else { // no instance found. Let's remove it so we don't loop forever - E->placeholders.erase(E->placeholders.front()->get()); + script->placeholders.erase(script->placeholders.front()->get()); } } #endif - for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->pending_reload_state.front(); F; F = F->next()) { + for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = script->pending_reload_state.front(); F; F = F->next()) { map[F->key()] = F->get(); //pending to reload, use this one instead } } diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index b3469ec47c..d106b3b541 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -150,9 +150,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p } r_symbol.kind = lsp::SymbolKind::Class; r_symbol.deprecated = false; - r_symbol.range.start.line = LINE_NUMBER_TO_INDEX(p_class->start_line); - r_symbol.range.start.character = LINE_NUMBER_TO_INDEX(p_class->start_column); - r_symbol.range.end.line = LINE_NUMBER_TO_INDEX(p_class->end_line); + r_symbol.range.start.line = p_class->start_line; + r_symbol.range.start.character = p_class->start_column; + r_symbol.range.end.line = lines.size(); r_symbol.selectionRange.start.line = r_symbol.range.start.line; r_symbol.detail = "class " + r_symbol.name; bool is_root_class = &r_symbol == &class_symbol; @@ -165,7 +165,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p case ClassNode::Member::VARIABLE: { lsp::DocumentSymbol symbol; symbol.name = m.variable->identifier->name; - symbol.kind = lsp::SymbolKind::Variable; + symbol.kind = m.variable->property == VariableNode::PropertyStyle::PROP_NONE ? lsp::SymbolKind::Variable : lsp::SymbolKind::Property; symbol.deprecated = false; symbol.range.start.line = LINE_NUMBER_TO_INDEX(m.variable->start_line); symbol.range.start.character = LINE_NUMBER_TO_INDEX(m.variable->start_column); @@ -317,7 +317,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN const String uri = get_uri(); r_symbol.name = p_func->identifier->name; - r_symbol.kind = lsp::SymbolKind::Function; + r_symbol.kind = p_func->is_static ? lsp::SymbolKind::Function : lsp::SymbolKind::Method; r_symbol.detail = "func " + String(p_func->identifier->name) + "("; r_symbol.deprecated = false; r_symbol.range.start.line = LINE_NUMBER_TO_INDEX(p_func->start_line); diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index a7dcfdb22d..0138f132ad 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -1018,32 +1018,32 @@ struct CompletionList { * A symbol kind. */ namespace SymbolKind { -static const int File = 0; -static const int Module = 1; -static const int Namespace = 2; -static const int Package = 3; -static const int Class = 4; -static const int Method = 5; -static const int Property = 6; -static const int Field = 7; -static const int Constructor = 8; -static const int Enum = 9; -static const int Interface = 10; -static const int Function = 11; -static const int Variable = 12; -static const int Constant = 13; -static const int String = 14; -static const int Number = 15; -static const int Boolean = 16; -static const int Array = 17; -static const int Object = 18; -static const int Key = 19; -static const int Null = 20; -static const int EnumMember = 21; -static const int Struct = 22; -static const int Event = 23; -static const int Operator = 24; -static const int TypeParameter = 25; +static const int File = 1; +static const int Module = 2; +static const int Namespace = 3; +static const int Package = 4; +static const int Class = 5; +static const int Method = 6; +static const int Property = 7; +static const int Field = 8; +static const int Constructor = 9; +static const int Enum = 10; +static const int Interface = 11; +static const int Function = 12; +static const int Variable = 13; +static const int Constant = 14; +static const int String = 15; +static const int Number = 16; +static const int Boolean = 17; +static const int Array = 18; +static const int Object = 19; +static const int Key = 20; +static const int Null = 21; +static const int EnumMember = 22; +static const int Struct = 23; +static const int Event = 24; +static const int Operator = 25; +static const int TypeParameter = 26; }; // namespace SymbolKind /** diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index 730c6b89f7..dd545ff431 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -193,7 +193,7 @@ void preregister_glslang_types() { // initialize in case it's not initialized. This is done once per thread // and it's safe to call multiple times glslang::InitializeProcess(); - RenderingDevice::shader_set_compile_function(_compile_shader_glsl); + RenderingDevice::shader_set_compile_to_spirv_function(_compile_shader_glsl); RenderingDevice::shader_set_get_cache_key_function(_get_cache_key_function_glsl); } diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index b75cf6502e..fe941e25e7 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -794,7 +794,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID rasterize_shader = rd->shader_create_from_bytecode(raster_shader->get_bytecode()); + RID rasterize_shader = rd->shader_create_from_spirv(raster_shader->get_spirv_stages()); ERR_FAIL_COND_V(rasterize_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //this is a bug check, though, should not happen @@ -945,27 +945,27 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // Unoccluder - RID compute_shader_unocclude = rd->shader_create_from_bytecode(compute_shader->get_bytecode("unocclude")); + RID compute_shader_unocclude = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("unocclude")); ERR_FAIL_COND_V(compute_shader_unocclude.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // internal check, should not happen RID compute_shader_unocclude_pipeline = rd->compute_pipeline_create(compute_shader_unocclude); // Direct light - RID compute_shader_primary = rd->shader_create_from_bytecode(compute_shader->get_bytecode("primary")); + RID compute_shader_primary = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("primary")); ERR_FAIL_COND_V(compute_shader_primary.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // internal check, should not happen RID compute_shader_primary_pipeline = rd->compute_pipeline_create(compute_shader_primary); // Indirect light - RID compute_shader_secondary = rd->shader_create_from_bytecode(compute_shader->get_bytecode("secondary")); + RID compute_shader_secondary = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("secondary")); ERR_FAIL_COND_V(compute_shader_secondary.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_secondary_pipeline = rd->compute_pipeline_create(compute_shader_secondary); // Dilate - RID compute_shader_dilate = rd->shader_create_from_bytecode(compute_shader->get_bytecode("dilate")); + RID compute_shader_dilate = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("dilate")); ERR_FAIL_COND_V(compute_shader_dilate.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_dilate_pipeline = rd->compute_pipeline_create(compute_shader_dilate); // Light probes - RID compute_shader_light_probes = rd->shader_create_from_bytecode(compute_shader->get_bytecode("light_probes")); + RID compute_shader_light_probes = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("light_probes")); ERR_FAIL_COND_V(compute_shader_light_probes.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_light_probes_pipeline = rd->compute_pipeline_create(compute_shader_light_probes); @@ -1506,11 +1506,11 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID blendseams_line_raster_shader = rd->shader_create_from_bytecode(blendseams_shader->get_bytecode("lines")); + RID blendseams_line_raster_shader = rd->shader_create_from_spirv(blendseams_shader->get_spirv_stages("lines")); ERR_FAIL_COND_V(blendseams_line_raster_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID blendseams_triangle_raster_shader = rd->shader_create_from_bytecode(blendseams_shader->get_bytecode("triangles")); + RID blendseams_triangle_raster_shader = rd->shader_create_from_spirv(blendseams_shader->get_spirv_stages("triangles")); ERR_FAIL_COND_V(blendseams_triangle_raster_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index b52277974f..15a5807370 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -145,8 +145,8 @@ void CSharpLanguage::finalize() { finalizing = true; // Make sure all script binding gchandles are released before finalizing GDMono - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + CSharpScriptBinding &script_binding = E.value; if (!script_binding.gchandle.is_released()) { script_binding.gchandle.release(); @@ -163,8 +163,8 @@ void CSharpLanguage::finalize() { script_bindings.clear(); #ifdef DEBUG_ENABLED - for (Map<ObjectID, int>::Element *E = unsafe_object_references.front(); E; E = E->next()) { - const ObjectID &id = E->key(); + for (const KeyValue<ObjectID, int> &E : unsafe_object_references) { + const ObjectID &id = E.key; Object *obj = ObjectDB::get_instance(id); if (obj) { @@ -864,8 +864,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // We need to keep reference instances alive during reloading List<Ref<RefCounted>> rc_instances; - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (const KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + const CSharpScriptBinding &script_binding = E.value; RefCounted *rc = Object::cast_to<RefCounted>(script_binding.owner); if (rc) { rc_instances.push_back(Ref<RefCounted>(rc)); @@ -874,7 +874,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // As scripts are going to be reloaded, must proceed without locking here - for (Ref<CSharpScript> script : scripts) { + for (Ref<CSharpScript> &script : scripts) { to_reload.push_back(script); if (script->get_path().is_empty()) { @@ -885,8 +885,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Script::instances are deleted during managed object disposal, which happens on domain finalize. // Only placeholders are kept. Therefore we need to keep a copy before that happens. - for (Set<Object *>::Element *F = script->instances.front(); F; F = F->next()) { - Object *obj = F->get(); + for (Object *&obj : script->instances) { script->pending_reload_instances.insert(obj->get_instance_id()); RefCounted *rc = Object::cast_to<RefCounted>(obj); @@ -896,8 +895,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } #ifdef TOOLS_ENABLED - for (Set<PlaceHolderScriptInstance *>::Element *F = script->placeholders.front(); F; F = F->next()) { - Object *obj = F->get()->get_owner(); + for (PlaceHolderScriptInstance *&script_instance : script->placeholders) { + Object *obj = script_instance->get_owner(); script->pending_reload_instances.insert(obj->get_instance_id()); RefCounted *rc = Object::cast_to<RefCounted>(obj); @@ -910,9 +909,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Save state and remove script from instances Map<ObjectID, CSharpScript::StateBackup> &owners_map = script->pending_reload_state; - for (Set<Object *>::Element *F = script->instances.front(); F; F = F->next()) { - Object *obj = F->get(); - + for (Object *&obj : script->instances) { ERR_CONTINUE(!obj->get_script_instance()); CSharpInstance *csi = static_cast<CSharpInstance *>(obj->get_script_instance()); @@ -934,7 +931,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } // After the state of all instances is saved, clear scripts and script instances - for (Ref<CSharpScript> script : scripts) { + 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) @@ -947,9 +944,9 @@ 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 (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()); + for (Ref<CSharpScript> &scr : to_reload) { + for (const KeyValue<ObjectID, CSharpScript::StateBackup> &F : scr->pending_reload_state) { + Object *obj = ObjectDB::get_instance(F.key); if (!obj) { continue; @@ -969,8 +966,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { #endif // Restore Variant properties state, it will be kept by the placeholder until the next script reloading - for (List<Pair<StringName, Variant>>::Element *G = scr->pending_reload_state[obj_id].properties.front(); G; G = G->next()) { - placeholder->property_set_fallback(G->get().first, G->get().second, nullptr); + for (const Pair<StringName, Variant> &G : scr->pending_reload_state[obj_id].properties) { + placeholder->property_set_fallback(G.first, G.second, nullptr); } scr->pending_reload_state.erase(obj_id); @@ -982,7 +979,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript>> to_reload_state; - for (Ref<CSharpScript> script : to_reload) { + for (Ref<CSharpScript> &script : to_reload) { #ifdef TOOLS_ENABLED script->exports_invalidated = true; #endif @@ -1035,8 +1032,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { StringName native_name = NATIVE_GDMONOCLASS_NAME(script->native); { - for (Set<ObjectID>::Element *F = script->pending_reload_instances.front(); F; F = F->next()) { - ObjectID obj_id = F->get(); + for (const ObjectID &obj_id : script->pending_reload_instances) { Object *obj = ObjectDB::get_instance(obj_id); if (!obj) { @@ -1087,9 +1083,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload_state.push_back(script); } - 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(); + for (Ref<CSharpScript> &script : to_reload_state) { + for (const ObjectID &obj_id : script->pending_reload_instances) { Object *obj = ObjectDB::get_instance(obj_id); if (!obj) { @@ -1103,16 +1098,16 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { CSharpScript::StateBackup &state_backup = script->pending_reload_state[obj_id]; - for (List<Pair<StringName, Variant>>::Element *G = state_backup.properties.front(); G; G = G->next()) { - obj->get_script_instance()->set(G->get().first, G->get().second); + for (const Pair<StringName, Variant> &G : state_backup.properties) { + obj->get_script_instance()->set(G.first, G.second); } CSharpInstance *csi = CAST_CSHARP_INSTANCE(obj->get_script_instance()); if (csi) { - for (List<Pair<StringName, Array>>::Element *G = state_backup.event_signals.front(); G; G = G->next()) { - const StringName &name = G->get().first; - const Array &serialized_data = G->get().second; + for (const Pair<StringName, Array> &G : state_backup.event_signals) { + const StringName &name = G.first; + const Array &serialized_data = G.second; Map<StringName, CSharpScript::EventSignal>::Element *match = script->event_signals.find(name); @@ -1156,9 +1151,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { { MutexLock lock(ManagedCallable::instances_mutex); - for (Map<ManagedCallable *, Array>::Element *elem = ManagedCallable::instances_pending_reload.front(); elem; elem = elem->next()) { - ManagedCallable *managed_callable = elem->key(); - const Array &serialized_data = elem->value(); + for (const KeyValue<ManagedCallable *, Array> &elem : ManagedCallable::instances_pending_reload) { + ManagedCallable *managed_callable = elem.key; + const Array &serialized_data = elem.value; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); MonoDelegate *delegate = nullptr; @@ -1302,8 +1297,8 @@ bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) { } void CSharpLanguage::_on_scripts_domain_unloaded() { - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + CSharpScriptBinding &script_binding = E.value; script_binding.gchandle.release(); script_binding.inited = false; } @@ -1728,12 +1723,12 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const { } void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Variant>> &r_state) { - List<PropertyInfo> pinfo; - get_property_list(&pinfo); + List<PropertyInfo> property_list; + get_property_list(&property_list); - for (const PropertyInfo &E : pinfo) { + for (const PropertyInfo &prop_info : property_list) { Pair<StringName, Variant> state_pair; - state_pair.first = E.name; + state_pair.first = prop_info.name; ManagedType managedType; @@ -1756,8 +1751,8 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, MonoObject *owner_managed = get_mono_object(); ERR_FAIL_NULL(owner_managed); - for (const Map<StringName, CSharpScript::EventSignal>::Element *E = script->event_signals.front(); E; E = E->next()) { - const CSharpScript::EventSignal &event_signal = E->value(); + for (const KeyValue<StringName, CSharpScript::EventSignal> &E : script->event_signals) { + const CSharpScript::EventSignal &event_signal = E.value; MonoDelegate *delegate_field_value = (MonoDelegate *)event_signal.field->get_value(owner_managed); if (!delegate_field_value) { @@ -1784,8 +1779,8 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, } void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const { - for (Map<StringName, PropertyInfo>::Element *E = script->member_info.front(); E; E = E->next()) { - p_properties->push_back(E->value()); + for (const KeyValue<StringName, PropertyInfo> &E : script->member_info) { + p_properties->push_back(E.value); } // Call _get_property_list @@ -2024,8 +2019,8 @@ void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_f } void CSharpInstance::connect_event_signals() { - for (const Map<StringName, CSharpScript::EventSignal>::Element *E = script->event_signals.front(); E; E = E->next()) { - const CSharpScript::EventSignal &event_signal = E->value(); + for (const KeyValue<StringName, CSharpScript::EventSignal> &E : script->event_signals) { + const CSharpScript::EventSignal &event_signal = E.value; StringName signal_name = event_signal.field->get_name(); @@ -2309,12 +2304,12 @@ void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List base_cache->_update_exports_values(values, propnames); } - for (Map<StringName, Variant>::Element *E = exported_members_defval_cache.front(); E; E = E->next()) { - values[E->key()] = E->get(); + for (const KeyValue<StringName, Variant> &E : exported_members_defval_cache) { + values[E.key] = E.value; } - for (const PropertyInfo &E : exported_members_cache) { - propnames.push_back(E); + for (const PropertyInfo &prop_info : exported_members_cache) { + propnames.push_back(prop_info); } } @@ -2545,8 +2540,8 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda _update_exports_values(values, propnames); if (changed) { - for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { - E->get()->update(propnames, values); + for (PlaceHolderScriptInstance *&script_instance : placeholders) { + script_instance->update(propnames, values); } } else { p_instance_to_update->update(propnames, values); @@ -3378,11 +3373,11 @@ bool CSharpScript::has_script_signal(const StringName &p_signal) const { } void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - for (const Map<StringName, Vector<SignalParameter>>::Element *E = _signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, Vector<SignalParameter>> &E : _signals) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; - const Vector<SignalParameter> ¶ms = E->value(); + const Vector<SignalParameter> ¶ms = E.value; for (int i = 0; i < params.size(); i++) { const SignalParameter ¶m = params[i]; @@ -3397,11 +3392,11 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { r_signals->push_back(mi); } - for (const Map<StringName, EventSignal>::Element *E = event_signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, EventSignal> &E : event_signals) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; - const EventSignal &event_signal = E->value(); + const EventSignal &event_signal = E.value; const Vector<SignalParameter> ¶ms = event_signal.parameters; for (int i = 0; i < params.size(); i++) { const SignalParameter ¶m = params[i]; @@ -3441,8 +3436,8 @@ Ref<Script> CSharpScript::get_base_script() const { } void CSharpScript::get_script_property_list(List<PropertyInfo> *p_list) const { - for (Map<StringName, PropertyInfo>::Element *E = member_info.front(); E; E = E->next()) { - p_list->push_back(E->value()); + for (const KeyValue<StringName, PropertyInfo> &E : member_info) { + p_list->push_back(E.value); } } @@ -3525,8 +3520,8 @@ CSharpScript::~CSharpScript() { void CSharpScript::get_members(Set<StringName> *p_members) { #if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED) if (p_members) { - for (Set<StringName>::Element *E = exported_members_names.front(); E; E = E->next()) { - p_members->insert(E->get()); + for (const StringName &member_name : exported_members_names) { + p_members->insert(member_name); } } #endif diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index ee4e7ba9d4..4624439665 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -113,11 +113,20 @@ namespace GodotTools.Utils { string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? Array.Empty<string>(); string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } string nameExt = Path.GetExtension(name); bool hasPathExt = !string.IsNullOrEmpty(nameExt) && windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase); @@ -137,11 +146,20 @@ namespace GodotTools.Utils private static string PathWhichUnix([NotNull] string name) { string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index c134136e1c..632f7d61cc 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -655,9 +655,7 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { return 0; } - for (const List<ConstantInterface>::Element *E = p_ienum.constants.front()->next(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : p_ienum.constants) { Vector<String> parts = iconstant.name.split("_", /* p_allow_empty: */ true); int i; diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index fa7d418844..b7b36a92d8 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -123,8 +123,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr // AutoLoads Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); - for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) { - const ProjectSettings::AutoloadInfo &info = E->value(); + for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) { + const ProjectSettings::AutoloadInfo &info = E.value; suggestions.push_back(quoted("/root/" + String(info.name))); } } diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 67d6f3ef29..67f38bf127 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -330,8 +330,8 @@ no_pdb: void GDMonoAssembly::unload() { ERR_FAIL_NULL(image); // Should not be called if already unloaded - for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<MonoClass *, GDMonoClass *> &E : cached_raw) { + memdelete(E.value); } cached_classes.clear(); diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index f9fddd931b..27b4ac7fa7 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -522,12 +522,12 @@ GDMonoClass::~GDMonoClass() { mono_custom_attrs_free(attributes); } - for (Map<StringName, GDMonoField *>::Element *E = fields.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<StringName, GDMonoField *> &E : fields) { + memdelete(E.value); } - for (Map<StringName, GDMonoProperty *>::Element *E = properties.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<StringName, GDMonoProperty *> &E : properties) { + memdelete(E.value); } { diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index 77857255c1..9b08a26aed 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -154,7 +154,7 @@ void WebRTCMultiplayerPeer::_find_next_peer() { } // After last. while (E) { - for (Ref<WebRTCDataChannel> F : E->get()->channels) { + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; @@ -165,7 +165,7 @@ void WebRTCMultiplayerPeer::_find_next_peer() { E = peer_map.front(); // Before last while (E) { - for (Ref<WebRTCDataChannel> F : E->get()->channels) { + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; @@ -213,7 +213,7 @@ int WebRTCMultiplayerPeer::get_unique_id() const { void WebRTCMultiplayerPeer::_peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict) { Array channels; - for (Ref<WebRTCDataChannel> F : p_connected_peer->channels) { + for (Ref<WebRTCDataChannel> &F : p_connected_peer->channels) { channels.push_back(F); } r_dict["connection"] = p_connected_peer->connection; @@ -297,7 +297,7 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_ _find_next_peer(); ERR_FAIL_V(ERR_UNAVAILABLE); } - for (Ref<WebRTCDataChannel> E : peer_map[next_packet_peer]->channels) { + for (Ref<WebRTCDataChannel> &E : peer_map[next_packet_peer]->channels) { if (E->get_available_packet_count()) { Error err = E->get_packet(r_buffer, r_buffer_size); _find_next_peer(); @@ -357,7 +357,7 @@ int WebRTCMultiplayerPeer::get_available_packet_count() const { } int size = 0; for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { - for (Ref<WebRTCDataChannel> F : E->get()->channels) { + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { size += F->get_available_packet_count(); } } diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 1df001f86e..c6eb3d44b4 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -196,7 +196,7 @@ void WSLServer::poll() { remove_ids.clear(); List<Ref<PendingPeer>> remove_peers; - for (Ref<PendingPeer> E : _pending) { + for (const Ref<PendingPeer> &E : _pending) { String resource_name; Ref<PendingPeer> ppeer = E; Error err = ppeer->do_handshake(_protocols, handshake_timeout, resource_name); @@ -224,7 +224,7 @@ void WSLServer::poll() { remove_peers.push_back(ppeer); _on_connect(id, ppeer->protocol, resource_name); } - for (Ref<PendingPeer> E : remove_peers) { + for (const Ref<PendingPeer> &E : remove_peers) { _pending.erase(E); } remove_peers.clear(); |