diff options
author | Lightning_A <aaronjrecord@gmail.com> | 2021-08-09 14:13:42 -0600 |
---|---|---|
committer | Lightning_A <aaronjrecord@gmail.com> | 2021-09-30 15:09:12 -0600 |
commit | c63b18507d21b8a213c073bced9057b571cdcd7a (patch) | |
tree | 96b8f7532ae5d923b75bfbac8d6763015b6646bb /modules | |
parent | e4dfa69bcf58e4d50acdde32c590364e43fce3ab (diff) |
Use range iterators for `Map`
Diffstat (limited to 'modules')
34 files changed, 603 insertions, 603 deletions
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 3054debaec..6b2b0c4ad0 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -1404,8 +1404,8 @@ void BulletPhysicsServer3D::free(RID p_rid) { ShapeBullet *shape = shape_owner.get_or_null(p_rid); // Notify the shape is configured - for (Map<ShapeOwnerBullet *, int>::Element *element = shape->get_owners().front(); element; element = element->next()) { - static_cast<ShapeOwnerBullet *>(element->key())->remove_shape_full(shape); + for (const KeyValue<ShapeOwnerBullet *, int> &element : shape->get_owners()) { + static_cast<ShapeOwnerBullet *>(element.key)->remove_shape_full(shape); } shape_owner.free(p_rid); diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index 88ffb9ec67..ec039ba842 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -63,8 +63,8 @@ btCollisionShape *ShapeBullet::prepare(btCollisionShape *p_btShape) const { } void ShapeBullet::notifyShapeChanged() { - for (Map<ShapeOwnerBullet *, int>::Element *E = owners.front(); E; E = E->next()) { - ShapeOwnerBullet *owner = static_cast<ShapeOwnerBullet *>(E->key()); + for (const KeyValue<ShapeOwnerBullet *, int> &E : owners) { + ShapeOwnerBullet *owner = static_cast<ShapeOwnerBullet *>(E.key); owner->shape_changed(owner->find_shape(this)); } } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 229e1e2724..53694035dc 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -258,8 +258,8 @@ void CSGBrush::build_from_faces(const Vector<Vector3> &p_vertices, const Vector< } materials.resize(material_map.size()); - for (Map<Ref<Material>, int>::Element *E = material_map.front(); E; E = E->next()) { - materials.write[E->get()] = E->key(); + for (const KeyValue<Ref<Material>, int> &E : material_map) { + materials.write[E.value] = E.key; } _regen_face_aabbs(); @@ -457,8 +457,8 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b // Update the list of materials. r_merged_brush.materials.resize(mesh_merge.materials.size()); - for (const Map<Ref<Material>, int>::Element *E = mesh_merge.materials.front(); E; E = E->next()) { - r_merged_brush.materials.write[E->get()] = E->key(); + for (const KeyValue<Ref<Material>, int> &E : mesh_merge.materials) { + r_merged_brush.materials.write[E.value] = E.key; } } diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp index 1ac4922acf..3dc163964c 100644 --- a/modules/fbx/data/fbx_skeleton.cpp +++ b/modules/fbx/data/fbx_skeleton.cpp @@ -98,9 +98,9 @@ void FBXSkeleton::init_skeleton(const ImportState &state) { ERR_FAIL_COND_MSG(skeleton->get_bone_count() != bone_count, "Not all bones got added, is the file corrupted?"); - for (Map<int, Ref<FBXBone>>::Element *bone_element = bone_map.front(); bone_element; bone_element = bone_element->next()) { - const Ref<FBXBone> bone = bone_element->value(); - int bone_index = bone_element->key(); + for (const KeyValue<int, Ref<FBXBone>> &bone_element : bone_map) { + const Ref<FBXBone> bone = bone_element.value; + int bone_index = bone_element.key; print_verbose("working on bone: " + itos(bone_index) + " bone name:" + bone->bone_name); skeleton->set_bone_rest(bone->godot_bone_id, get_unscaled_transform(bone->node->pivot_transform->LocalTransform, state.scale)); diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index e3f36ef3e3..e0663ab49d 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -567,8 +567,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // this means that the nodes from maya kLocators will be preserved as bones // in the same rig without having to match this across skeletons and merge by detection // we can just merge and undo any parent transforms - for (Map<uint64_t, Ref<FBXBone>>::Element *bone_element = state.fbx_bone_map.front(); bone_element; bone_element = bone_element->next()) { - Ref<FBXBone> bone = bone_element->value(); + for (KeyValue<uint64_t, Ref<FBXBone>> &bone_element : state.fbx_bone_map) { + Ref<FBXBone> bone = bone_element.value; Ref<FBXSkeleton> fbx_skeleton_inst; uint64_t armature_id = bone->armature_id; @@ -609,8 +609,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // setup skeleton instances if required :) - for (Map<uint64_t, Ref<FBXSkeleton>>::Element *skeleton_node = state.skeleton_map.front(); skeleton_node; skeleton_node = skeleton_node->next()) { - Ref<FBXSkeleton> &skeleton = skeleton_node->value(); + for (KeyValue<uint64_t, Ref<FBXSkeleton>> &skeleton_node : state.skeleton_map) { + Ref<FBXSkeleton> &skeleton = skeleton_node.value; skeleton->init_skeleton(state); ERR_CONTINUE_MSG(skeleton->fbx_node.is_null(), "invalid fbx target map, missing skeleton"); @@ -699,9 +699,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } } - for (Map<uint64_t, Ref<FBXMeshData>>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - const uint64_t mesh_id = mesh_data->key(); - Ref<FBXMeshData> mesh = mesh_data->value(); + for (KeyValue<uint64_t, Ref<FBXMeshData>> &mesh_data : state.renderer_mesh_data) { + const uint64_t mesh_id = mesh_data.key; + Ref<FBXMeshData> mesh = mesh_data.value; const FBXDocParser::MeshGeometry *mesh_geometry = p_document->GetObject(mesh_id)->Get<FBXDocParser::MeshGeometry>(); @@ -765,9 +765,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // mesh data iteration for populating skeleton mapping - for (Map<uint64_t, Ref<FBXMeshData>>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - Ref<FBXMeshData> mesh = mesh_data->value(); - const uint64_t mesh_id = mesh_data->key(); + for (KeyValue<uint64_t, Ref<FBXMeshData>> &mesh_data : state.renderer_mesh_data) { + Ref<FBXMeshData> mesh = mesh_data.value; + const uint64_t mesh_id = mesh_data.key; EditorSceneImporterMeshNode3D *mesh_instance = mesh->godot_mesh_instance; const int mesh_weights = mesh->max_weight_count; Ref<FBXSkeleton> skeleton; @@ -1004,13 +1004,13 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // target id, [ track name, [time index, vector] ] //std::map<uint64_t, std::map<StringName, FBXTrack > > AnimCurveNodes; - for (Map<uint64_t, Map<StringName, FBXTrack>>::Element *track = AnimCurveNodes.front(); track; track = track->next()) { + for (KeyValue<uint64_t, Map<StringName, FBXTrack>> &track : AnimCurveNodes) { // 5 tracks // current track index // track count is 5 // track count is 5. // next track id is 5. - const uint64_t target_id = track->key(); + const uint64_t target_id = track.key; int track_idx = animation->add_track(Animation::TYPE_TRANSFORM3D); // animation->track_set_path(track_idx, node_path); @@ -1072,7 +1072,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene( const FBXDocParser::Model *model = target_node->fbx_model; const FBXDocParser::PropertyTable *props = dynamic_cast<const FBXDocParser::PropertyTable *>(model); - Map<StringName, FBXTrack> &track_data = track->value(); + Map<StringName, FBXTrack> &track_data = track.value; FBXTrack &translation_keys = track_data[StringName("T")]; FBXTrack &rotation_keys = track_data[StringName("R")]; FBXTrack &scale_keys = track_data[StringName("S")]; @@ -1259,15 +1259,15 @@ Node3D *EditorSceneImporterFBX::_generate_scene( state.fbx_target_map.clear(); state.fbx_node_list.clear(); - for (Map<uint64_t, Ref<FBXBone>>::Element *element = state.fbx_bone_map.front(); element; element = element->next()) { - Ref<FBXBone> bone = element->value(); + for (KeyValue<uint64_t, Ref<FBXBone>> &element : state.fbx_bone_map) { + Ref<FBXBone> bone = element.value; bone->parent_bone.unref(); bone->node.unref(); bone->fbx_skeleton.unref(); } - for (Map<uint64_t, Ref<FBXSkeleton>>::Element *element = state.skeleton_map.front(); element; element = element->next()) { - Ref<FBXSkeleton> skel = element->value(); + for (KeyValue<uint64_t, Ref<FBXSkeleton>> &element : state.skeleton_map) { + Ref<FBXSkeleton> skel = element.value; skel->fbx_node.unref(); skel->skeleton_bones.clear(); } diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 906a721045..12d644ee94 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -53,9 +53,9 @@ protected: String csv_header = "file_path, error message, extra data\n"; massive_log_file += csv_header; - for (Map<String, LocalVector<String>>::Element *element = validation_entries.front(); element; element = element->next()) { - for (unsigned int x = 0; x < element->value().size(); x++) { - const String &line_entry = element->key() + ", " + element->value()[x].c_escape() + "\n"; + for (const KeyValue<String, LocalVector<String>> &element : validation_entries) { + for (unsigned int x = 0; x < element.value.size(); x++) { + const String &line_entry = element.key + ", " + element.value[x].c_escape() + "\n"; massive_log_file += line_entry; } } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index f965bcd014..9dad13a615 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -38,9 +38,9 @@ void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) { library = p_library; Ref<ConfigFile> config = p_library->get_config_file(); - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + for (KeyValue<String, NativePlatformConfig> &E : platforms) { + for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) { + String target = E.key + "." + it->get(); TargetConfig ecfg; ecfg.library = config->get_value("entry", target, ""); ecfg.dependencies = config->get_value("dependencies", target, Array()); @@ -245,9 +245,9 @@ void GDNativeLibraryEditor::_translate_to_config_file() { config->erase_section("entry"); config->erase_section("dependencies"); - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + for (KeyValue<String, NativePlatformConfig> &E : platforms) { + for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) { + String target = E.key + "." + it->get(); if (entry_configs[target].library.is_empty() && entry_configs[target].dependencies.is_empty()) { continue; } @@ -341,9 +341,9 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { filter_list->set_hide_on_checkable_item_selection(false); int idx = 0; - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - filter_list->add_check_item(E->get().name, idx); - filter_list->set_item_metadata(idx, E->key()); + for (const KeyValue<String, NativePlatformConfig> &E : platforms) { + filter_list->add_check_item(E.value.name, idx); + filter_list->set_item_metadata(idx, E.key); filter_list->set_item_checked(idx, true); idx += 1; } diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 2d9b45cb07..598f7c7ad0 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -223,8 +223,8 @@ List<ClassAPI> generate_c_api_classes() { enum_api_map[enum_name] = enum_api; } } - for (const Map<StringName, EnumAPI>::Element *E = enum_api_map.front(); E; E = E->next()) { - global_constants_api.enums.push_back(E->get()); + for (const KeyValue<StringName, EnumAPI> &E : enum_api_map) { + global_constants_api.enums.push_back(E.value); } global_constants_api.constants.sort_custom<ConstantAPIComparator>(); api.push_back(global_constants_api); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 92ba9bd452..fb46bafb3c 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -360,8 +360,8 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { Set<MethodInfo> signals_; while (script_data) { - for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) { - signals_.insert(S->get().signal); + for (const KeyValue<StringName, NativeScriptDesc::Signal> &S : script_data->signals_) { + signals_.insert(S.value.signal); } script_data = script_data->base_data; @@ -401,8 +401,8 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const { Set<MethodInfo> methods; while (script_data) { - for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) { - methods.insert(E->get().info); + for (const KeyValue<StringName, NativeScriptDesc::Method> &E : script_data->methods) { + methods.insert(E.value.info); } script_data = script_data->base_data; @@ -857,9 +857,9 @@ NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { Map<String, Ref<GDNative>> erase_and_unload; - for (Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) { - String lib_path = L->key(); - Map<StringName, NativeScriptDesc> classes = L->get(); + for (KeyValue<String, Map<StringName, NativeScriptDesc>> &L : library_classes) { + String lib_path = L.key; + Map<StringName, NativeScriptDesc> classes = L.value; if (p_reload) { Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); @@ -890,9 +890,9 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { gdn = E->get(); } - for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue<StringName, NativeScriptDesc> &C : classes) { // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C.value.properties.front(); P; P = P.next()) { if (P.get().getter.free_func) { P.get().getter.free_func(P.get().getter.method_data); } @@ -903,28 +903,28 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } // free method stuff - for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + for (const KeyValue<StringName, NativeScriptDesc::Method> &M : C.value.methods) { + if (M.value.method.free_func) { + M.value.method.free_func(M.value.method.method_data); } } // free constructor/destructor - if (C->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); + if (C.value.destroy_func.free_func) { + C.value.destroy_func.free_func(C.value.destroy_func.method_data); } } erase_and_unload.insert(lib_path, gdn); } - for (Map<String, Ref<GDNative>>::Element *E = erase_and_unload.front(); E; E = E->next()) { - String lib_path = E->key(); - Ref<GDNative> gdn = E->get(); + for (KeyValue<String, Ref<GDNative>> &E : erase_and_unload) { + String lib_path = E.key; + Ref<GDNative> gdn = E.value; library_classes.erase(lib_path); @@ -957,8 +957,8 @@ NativeScriptLanguage::NativeScriptLanguage() { } NativeScriptLanguage::~NativeScriptLanguage() { - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> lib = L->get(); + for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { + Ref<GDNative> lib = L.value; // only shut down valid libs, duh! if (lib.is_valid()) { // If it's a singleton-library then the gdnative module @@ -1157,15 +1157,15 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a int current = 0; - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue<StringName, ProfileData> &d : profile_data) { if (current >= p_info_max) { break; } - p_info_arr[current].call_count = d->get().call_count; - p_info_arr[current].self_time = d->get().self_time; - p_info_arr[current].total_time = d->get().total_time; - p_info_arr[current].signature = d->get().signature; + p_info_arr[current].call_count = d.value.call_count; + p_info_arr[current].self_time = d.value.self_time; + p_info_arr[current].total_time = d.value.total_time; + p_info_arr[current].signature = d.value.signature; current++; } @@ -1181,16 +1181,16 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in int current = 0; - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue<StringName, ProfileData> &d : profile_data) { if (current >= p_info_max) { break; } - if (d->get().last_frame_call_count) { - p_info_arr[current].call_count = d->get().last_frame_call_count; - p_info_arr[current].self_time = d->get().last_frame_self_time; - p_info_arr[current].total_time = d->get().last_frame_total_time; - p_info_arr[current].signature = d->get().signature; + if (d.value.last_frame_call_count) { + p_info_arr[current].call_count = d.value.last_frame_call_count; + p_info_arr[current].self_time = d.value.last_frame_self_time; + p_info_arr[current].total_time = d.value.last_frame_total_time; + p_info_arr[current].signature = d.value.signature; current++; } } @@ -1503,9 +1503,9 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { if (L) { Map<StringName, NativeScriptDesc> classes = L->get(); - for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue<StringName, NativeScriptDesc> &C : classes) { // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C.value.properties.front(); P; P = P.next()) { if (P.get().getter.free_func) { P.get().getter.free_func(P.get().getter.method_data); } @@ -1516,19 +1516,19 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { } // free method stuff - for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + for (const KeyValue<StringName, NativeScriptDesc::Method> &M : C.value.methods) { + if (M.value.method.free_func) { + M.value.method.free_func(M.value.method.method_data); } } // free constructor/destructor - if (C->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); + if (C.value.destroy_func.free_func) { + C.value.destroy_func.free_func(C.value.destroy_func.method_data); } } @@ -1548,14 +1548,14 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here - for (Map<String, Ref<GDNative>>::Element *L = library_gdnatives.front(); L; L = L->next()) { - if (L->get().is_null()) { + for (KeyValue<String, Ref<GDNative>> &L : library_gdnatives) { + if (L.value.is_null()) { continue; } - if (L->get()->is_initialized()) { + if (L.value->is_initialized()) { void *proc_ptr; - Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr); + Error err = L.value->get_symbol(L.value->get_library()->get_symbol_prefix() + name, proc_ptr); if (!err) { ((void (*)())proc_ptr)(); @@ -1584,13 +1584,13 @@ void NativeScriptLanguage::frame() { { MutexLock lock(mutex); - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { - d->get().last_frame_call_count = d->get().frame_call_count; - d->get().last_frame_self_time = d->get().frame_self_time; - d->get().last_frame_total_time = d->get().frame_total_time; - d->get().frame_call_count = 0; - d->get().frame_self_time = 0; - d->get().frame_total_time = 0; + for (KeyValue<StringName, ProfileData> &d : profile_data) { + d.value.last_frame_call_count = d.value.frame_call_count; + d.value.last_frame_self_time = d.value.frame_self_time; + d.value.last_frame_total_time = d.value.frame_total_time; + d.value.frame_call_count = 0; + d.value.frame_self_time = 0; + d.value.frame_total_time = 0; } } #endif @@ -1651,8 +1651,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); NSL->_unload_stuff(true); - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> gdn = L->get(); + for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { + Ref<GDNative> gdn = L.value; if (gdn.is_null()) { continue; @@ -1685,8 +1685,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); Set<StringName> libs_to_remove; - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> gdn = L->get(); + for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { + Ref<GDNative> gdn = L.value; if (gdn.is_null()) { continue; @@ -1703,24 +1703,24 @@ void NativeReloadNode::_notification(int p_what) { } if (!gdn->initialize()) { - libs_to_remove.insert(L->key()); + libs_to_remove.insert(L.key); continue; } - NSL->library_classes.insert(L->key(), Map<StringName, NativeScriptDesc>()); + NSL->library_classes.insert(L.key, Map<StringName, NativeScriptDesc>()); // here the library registers all the classes and stuff. void *proc_ptr; Error err = gdn->get_symbol(gdn->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr); if (err != OK) { - ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data()); + ERR_PRINT(String("No godot_nativescript_init in \"" + L.key + "\" found").utf8().get_data()); } else { - ((void (*)(void *))proc_ptr)((void *)&L->key()); + ((void (*)(void *))proc_ptr)((void *)&L.key); } - for (Map<String, Set<NativeScript *>>::Element *U = NSL->library_script_users.front(); U; U = U->next()) { - for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) { + for (KeyValue<String, Set<NativeScript *>> &U : NSL->library_script_users) { + for (Set<NativeScript *>::Element *S = U.value.front(); S; S = S->next()) { NativeScript *script = S->get(); if (script->placeholders.size() == 0) { diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index bc8801b8b9..2bae838543 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -122,8 +122,8 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco instance->owner_id = p_owner->get_instance_id(); #ifdef DEBUG_ENABLED //needed for hot reloading - for (Map<StringName, MemberInfo>::Element *E = member_indices.front(); E; E = E->next()) { - instance->member_indices_cache[E->key()] = E->get().index; + for (const KeyValue<StringName, MemberInfo> &E : member_indices) { + instance->member_indices_cache[E.key] = E.value.index; } #endif instance->owner->set_script_instance(instance); @@ -253,10 +253,10 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_base) const { const GDScript *current = this; while (current) { - for (const Map<StringName, GDScriptFunction *>::Element *E = current->member_functions.front(); E; E = E->next()) { - GDScriptFunction *func = E->get(); + for (const KeyValue<StringName, GDScriptFunction *> &E : current->member_functions) { + GDScriptFunction *func = E.value; MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arginfo = func->get_argument_type(i); #ifdef TOOLS_ENABLED @@ -286,11 +286,11 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl while (sptr) { Vector<_GDScriptMemberSort> msort; - for (Map<StringName, PropertyInfo>::Element *E = sptr->member_info.front(); E; E = E->next()) { + for (const KeyValue<StringName, PropertyInfo> &E : sptr->member_info) { _GDScriptMemberSort ms; - ERR_CONTINUE(!sptr->member_indices.has(E->key())); - ms.index = sptr->member_indices[E->key()].index; - ms.name = E->key(); + ERR_CONTINUE(!sptr->member_indices.has(E.key)); + ms.index = sptr->member_indices[E.key].index; + ms.name = E.key; msort.push_back(ms); } @@ -412,8 +412,8 @@ void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<Pro base_cache->_update_exports_values(values, propnames); } - for (Map<StringName, Variant>::Element *E = member_default_values_cache.front(); E; E = E->next()) { - values[E->key()] = E->get(); + for (const KeyValue<StringName, Variant> &E : member_default_values_cache) { + values[E.key] = E.value; } for (const PropertyInfo &E : members_cache) { @@ -471,9 +471,9 @@ void GDScript::_update_doc() { doc.description = doc_description; doc.tutorials = doc_tutorials; - for (Map<String, DocData::EnumDoc>::Element *E = doc_enums.front(); E; E = E->next()) { - if (E->value().description != "") { - doc.enums[E->key()] = E->value().description; + for (const KeyValue<String, DocData::EnumDoc> &E : doc_enums) { + if (E.value.description != "") { + doc.enums[E.key] = E.value.description; } } @@ -552,29 +552,29 @@ void GDScript::_update_doc() { doc.signals.push_back(signal_doc); } - for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) { - if (subclasses.has(E->key())) { + for (const KeyValue<StringName, Variant> &E : constants) { + if (subclasses.has(E.key)) { continue; } // Enums. bool is_enum = false; - if (E->value().get_type() == Variant::DICTIONARY) { - if (doc_enums.has(E->key())) { + if (E.value.get_type() == Variant::DICTIONARY) { + if (doc_enums.has(E.key)) { is_enum = true; - for (int i = 0; i < doc_enums[E->key()].values.size(); i++) { - doc_enums[E->key()].values.write[i].enumeration = E->key(); - doc.constants.push_back(doc_enums[E->key()].values[i]); + for (int i = 0; i < doc_enums[E.key].values.size(); i++) { + doc_enums[E.key].values.write[i].enumeration = E.key; + doc.constants.push_back(doc_enums[E.key].values[i]); } } } if (!is_enum && doc_enums.has("@unnamed_enums")) { for (int i = 0; i < doc_enums["@unnamed_enums"].values.size(); i++) { - if (E->key() == doc_enums["@unnamed_enums"].values[i].name) { + if (E.key == doc_enums["@unnamed_enums"].values[i].name) { is_enum = true; DocData::ConstantDoc constant_doc; constant_doc.enumeration = "@unnamed_enums"; - DocData::constant_doc_from_variant(constant_doc, E->key(), E->value(), doc_enums["@unnamed_enums"].values[i].description); + DocData::constant_doc_from_variant(constant_doc, E.key, E.value, doc_enums["@unnamed_enums"].values[i].description); doc.constants.push_back(constant_doc); break; } @@ -583,16 +583,16 @@ void GDScript::_update_doc() { if (!is_enum) { DocData::ConstantDoc constant_doc; String doc_description; - if (doc_constants.has(E->key())) { - doc_description = doc_constants[E->key()]; + if (doc_constants.has(E.key)) { + doc_description = doc_constants[E.key]; } - DocData::constant_doc_from_variant(constant_doc, E->key(), E->value(), doc_description); + DocData::constant_doc_from_variant(constant_doc, E.key, E.value, doc_description); doc.constants.push_back(constant_doc); } } - for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) { - E->get()->_update_doc(); + for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) { + E.value->_update_doc(); } _add_doc(doc); @@ -784,8 +784,8 @@ void GDScript::update_exports() { void GDScript::_set_subclass_path(Ref<GDScript> &p_sc, const String &p_path) { p_sc->path = p_path; - for (Map<StringName, Ref<GDScript>>::Element *E = p_sc->subclasses.front(); E; E = E->next()) { - _set_subclass_path(E->get(), p_path); + for (KeyValue<StringName, Ref<GDScript>> &E : p_sc->subclasses) { + _set_subclass_path(E.value, p_path); } } @@ -886,8 +886,8 @@ Error GDScript::reload(bool p_keep_state) { valid = true; - for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) { - _set_subclass_path(E->get(), path); + for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) { + _set_subclass_path(E.value, path); } _init_rpc_methods_properties(); @@ -901,8 +901,8 @@ ScriptLanguage *GDScript::get_language() const { void GDScript::get_constants(Map<StringName, Variant> *p_constants) { if (p_constants) { - for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) { - (*p_constants)[E->key()] = E->value(); + for (const KeyValue<StringName, Variant> &E : constants) { + (*p_constants)[E.key] = E.value; } } } @@ -1032,9 +1032,9 @@ const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions( } StringName GDScript::debug_get_member_by_index(int p_idx) const { - for (const Map<StringName, MemberInfo>::Element *E = member_indices.front(); E; E = E->next()) { - if (E->get().index == p_idx) { - return E->key(); + for (const KeyValue<StringName, MemberInfo> &E : member_indices) { + if (E.value.index == p_idx) { + return E.key; } } @@ -1079,12 +1079,12 @@ bool GDScript::has_script_signal(const StringName &p_signal) const { } void GDScript::_get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const { - for (const Map<StringName, Vector<StringName>>::Element *E = _signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, Vector<StringName>> &E : _signals) { MethodInfo mi; - mi.name = E->key(); - for (int i = 0; i < E->get().size(); i++) { + mi.name = E.key; + for (int i = 0; i < E.value.size(); i++) { PropertyInfo arg; - arg.name = E->get()[i]; + arg.name = E.value[i]; mi.arguments.push_back(arg); } r_list->push_back(mi); @@ -1142,11 +1142,11 @@ void GDScript::_save_orphaned_subclasses() { }; Vector<ClassRefWithName> weak_subclasses; // collect subclasses ObjectID and name - for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) { - E->get()->_owner = nullptr; //bye, you are no longer owned cause I died + for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) { + E.value->_owner = nullptr; //bye, you are no longer owned cause I died ClassRefWithName subclass; - subclass.id = E->get()->get_instance_id(); - subclass.fully_qualified_name = E->get()->fully_qualified_name; + subclass.id = E.value->get_instance_id(); + subclass.fully_qualified_name = E.value->fully_qualified_name; weak_subclasses.push_back(subclass); } @@ -1178,10 +1178,10 @@ void GDScript::_init_rpc_methods_properties() { Map<StringName, Ref<GDScript>>::Element *sub_E = subclasses.front(); while (cscript) { // RPC Methods - for (Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.front(); E; E = E->next()) { - Multiplayer::RPCConfig config = E->get()->get_rpc_config(); + for (KeyValue<StringName, GDScriptFunction *> &E : cscript->member_functions) { + Multiplayer::RPCConfig config = E.value->get_rpc_config(); if (config.rpc_mode != Multiplayer::RPC_MODE_DISABLED) { - config.name = E->get()->get_name(); + config.name = E.value->get_name(); if (rpc_functions.find(config) == -1) { rpc_functions.push_back(config); } @@ -1215,8 +1215,8 @@ GDScript::~GDScript() { } } - for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<StringName, GDScriptFunction *> &E : member_functions) { + memdelete(E.value); } if (GDScriptCache::singleton) { // Cache may have been already destroyed at engine shutdown. @@ -1442,11 +1442,11 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const //instance a fake script for editing the values Vector<_GDScriptMemberSort> msort; - for (Map<StringName, PropertyInfo>::Element *F = sptr->member_info.front(); F; F = F->next()) { + for (const KeyValue<StringName, PropertyInfo> &F : sptr->member_info) { _GDScriptMemberSort ms; - ERR_CONTINUE(!sptr->member_indices.has(F->key())); - ms.index = sptr->member_indices[F->key()].index; - ms.name = F->key(); + ERR_CONTINUE(!sptr->member_indices.has(F.key)); + ms.index = sptr->member_indices[F.key].index; + ms.name = F.key; msort.push_back(ms); } @@ -1467,11 +1467,11 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const { const GDScript *sptr = script.ptr(); while (sptr) { - for (Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) { + for (const KeyValue<StringName, GDScriptFunction *> &E : sptr->member_functions) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; mi.flags |= METHOD_FLAG_FROM_SCRIPT; - for (int i = 0; i < E->get()->get_argument_count(); i++) { + for (int i = 0; i < E.value->get_argument_count(); i++) { mi.arguments.push_back(PropertyInfo(Variant::NIL, "arg" + itos(i))); } p_list->push_back(mi); @@ -1569,10 +1569,10 @@ void GDScriptInstance::reload_members() { new_members.resize(script->member_indices.size()); //pass the values to the new indices - for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) { - if (member_indices_cache.has(E->key())) { - Variant value = members[member_indices_cache[E->key()]]; - new_members.write[E->get().index] = value; + for (KeyValue<StringName, GDScript::MemberInfo> &E : script->member_indices) { + if (member_indices_cache.has(E.key)) { + Variant value = members[member_indices_cache[E.key]]; + new_members.write[E.value.index] = value; } } @@ -1581,8 +1581,8 @@ void GDScriptInstance::reload_members() { //pass the values to the new indices member_indices_cache.clear(); - for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) { - member_indices_cache[E->key()] = E->get().index; + for (const KeyValue<StringName, GDScript::MemberInfo> &E : script->member_indices) { + member_indices_cache[E.key] = E.value.index; } #endif @@ -1890,21 +1890,21 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so #endif - 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 + for (const KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : script->pending_reload_state) { + map[F.key] = F.value; //pending to reload, use this one instead } } } - for (Map<Ref<GDScript>, Map<ObjectID, List<Pair<StringName, Variant>>>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<GDScript> scr = E->key(); + for (KeyValue<Ref<GDScript>, Map<ObjectID, List<Pair<StringName, Variant>>>> &E : to_reload) { + Ref<GDScript> scr = E.key; scr->reload(p_soft_reload); //restore state if saved - for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->get().front(); F; F = F->next()) { - List<Pair<StringName, Variant>> &saved_state = F->get(); + for (KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : E.value) { + List<Pair<StringName, Variant>> &saved_state = F.value; - Object *obj = ObjectDB::get_instance(F->key()); + Object *obj = ObjectDB::get_instance(F.key); if (!obj) { continue; } @@ -2210,15 +2210,15 @@ GDScriptLanguage::~GDScriptLanguage() { // is not the same as before). script->reference(); - for (Map<StringName, GDScriptFunction *>::Element *E = script->member_functions.front(); E; E = E->next()) { - GDScriptFunction *func = E->get(); + for (KeyValue<StringName, GDScriptFunction *> &E : script->member_functions) { + GDScriptFunction *func = E.value; for (int i = 0; i < func->argument_types.size(); i++) { func->argument_types.write[i].script_type_ref = Ref<Script>(); } func->return_type.script_type_ref = Ref<Script>(); } - for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) { - E->get().data_type.script_type_ref = Ref<Script>(); + for (KeyValue<StringName, GDScript::MemberInfo> &E : script->member_indices) { + E.value.data_type.script_type_ref = Ref<Script>(); } s = s->next(); diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 032e08f5a0..c35af9ca5b 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2270,10 +2270,10 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa if (get_function_signature(p_call, base_type, p_call->function_name, return_type, par_types, default_arg_count, is_static, is_vararg)) { // If the function require typed arrays we must make literals be typed. - for (Map<int, GDScriptParser::ArrayNode *>::Element *E = arrays.front(); E; E = E->next()) { - int index = E->key(); + for (const KeyValue<int, GDScriptParser::ArrayNode *> &E : arrays) { + int index = E.key; if (index < par_types.size() && par_types[index].has_container_element_type()) { - update_array_literal_element_type(par_types[index], E->get()); + update_array_literal_element_type(par_types[index], E.value); } } validate_call_arg(par_types, default_arg_count, is_vararg, p_call); diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index 1127488db8..b8300cd872 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -209,8 +209,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { if (name_map.size()) { function->global_names.resize(name_map.size()); function->_global_names_ptr = &function->global_names[0]; - for (Map<StringName, int>::Element *E = name_map.front(); E; E = E->next()) { - function->global_names.write[E->get()] = E->key(); + for (const KeyValue<StringName, int> &E : name_map) { + function->global_names.write[E.value] = E.key; } function->_global_names_count = function->global_names.size(); @@ -241,8 +241,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->operator_funcs.resize(operator_func_map.size()); function->_operator_funcs_count = function->operator_funcs.size(); function->_operator_funcs_ptr = function->operator_funcs.ptr(); - for (const Map<Variant::ValidatedOperatorEvaluator, int>::Element *E = operator_func_map.front(); E; E = E->next()) { - function->operator_funcs.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedOperatorEvaluator, int> &E : operator_func_map) { + function->operator_funcs.write[E.value] = E.key; } } else { function->_operator_funcs_count = 0; @@ -253,8 +253,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->setters.resize(setters_map.size()); function->_setters_count = function->setters.size(); function->_setters_ptr = function->setters.ptr(); - for (const Map<Variant::ValidatedSetter, int>::Element *E = setters_map.front(); E; E = E->next()) { - function->setters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedSetter, int> &E : setters_map) { + function->setters.write[E.value] = E.key; } } else { function->_setters_count = 0; @@ -265,8 +265,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->getters.resize(getters_map.size()); function->_getters_count = function->getters.size(); function->_getters_ptr = function->getters.ptr(); - for (const Map<Variant::ValidatedGetter, int>::Element *E = getters_map.front(); E; E = E->next()) { - function->getters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedGetter, int> &E : getters_map) { + function->getters.write[E.value] = E.key; } } else { function->_getters_count = 0; @@ -277,8 +277,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->keyed_setters.resize(keyed_setters_map.size()); function->_keyed_setters_count = function->keyed_setters.size(); function->_keyed_setters_ptr = function->keyed_setters.ptr(); - for (const Map<Variant::ValidatedKeyedSetter, int>::Element *E = keyed_setters_map.front(); E; E = E->next()) { - function->keyed_setters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedKeyedSetter, int> &E : keyed_setters_map) { + function->keyed_setters.write[E.value] = E.key; } } else { function->_keyed_setters_count = 0; @@ -289,8 +289,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->keyed_getters.resize(keyed_getters_map.size()); function->_keyed_getters_count = function->keyed_getters.size(); function->_keyed_getters_ptr = function->keyed_getters.ptr(); - for (const Map<Variant::ValidatedKeyedGetter, int>::Element *E = keyed_getters_map.front(); E; E = E->next()) { - function->keyed_getters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedKeyedGetter, int> &E : keyed_getters_map) { + function->keyed_getters.write[E.value] = E.key; } } else { function->_keyed_getters_count = 0; @@ -301,8 +301,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->indexed_setters.resize(indexed_setters_map.size()); function->_indexed_setters_count = function->indexed_setters.size(); function->_indexed_setters_ptr = function->indexed_setters.ptr(); - for (const Map<Variant::ValidatedIndexedSetter, int>::Element *E = indexed_setters_map.front(); E; E = E->next()) { - function->indexed_setters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedIndexedSetter, int> &E : indexed_setters_map) { + function->indexed_setters.write[E.value] = E.key; } } else { function->_indexed_setters_count = 0; @@ -313,8 +313,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->indexed_getters.resize(indexed_getters_map.size()); function->_indexed_getters_count = function->indexed_getters.size(); function->_indexed_getters_ptr = function->indexed_getters.ptr(); - for (const Map<Variant::ValidatedIndexedGetter, int>::Element *E = indexed_getters_map.front(); E; E = E->next()) { - function->indexed_getters.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedIndexedGetter, int> &E : indexed_getters_map) { + function->indexed_getters.write[E.value] = E.key; } } else { function->_indexed_getters_count = 0; @@ -325,8 +325,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->builtin_methods.resize(builtin_method_map.size()); function->_builtin_methods_ptr = function->builtin_methods.ptr(); function->_builtin_methods_count = builtin_method_map.size(); - for (const Map<Variant::ValidatedBuiltInMethod, int>::Element *E = builtin_method_map.front(); E; E = E->next()) { - function->builtin_methods.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedBuiltInMethod, int> &E : builtin_method_map) { + function->builtin_methods.write[E.value] = E.key; } } else { function->_builtin_methods_ptr = nullptr; @@ -337,8 +337,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->constructors.resize(constructors_map.size()); function->_constructors_ptr = function->constructors.ptr(); function->_constructors_count = constructors_map.size(); - for (const Map<Variant::ValidatedConstructor, int>::Element *E = constructors_map.front(); E; E = E->next()) { - function->constructors.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedConstructor, int> &E : constructors_map) { + function->constructors.write[E.value] = E.key; } } else { function->_constructors_ptr = nullptr; @@ -349,8 +349,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->utilities.resize(utilities_map.size()); function->_utilities_ptr = function->utilities.ptr(); function->_utilities_count = utilities_map.size(); - for (const Map<Variant::ValidatedUtilityFunction, int>::Element *E = utilities_map.front(); E; E = E->next()) { - function->utilities.write[E->get()] = E->key(); + for (const KeyValue<Variant::ValidatedUtilityFunction, int> &E : utilities_map) { + function->utilities.write[E.value] = E.key; } } else { function->_utilities_ptr = nullptr; @@ -361,8 +361,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->gds_utilities.resize(gds_utilities_map.size()); function->_gds_utilities_ptr = function->gds_utilities.ptr(); function->_gds_utilities_count = gds_utilities_map.size(); - for (const Map<GDScriptUtilityFunctions::FunctionPtr, int>::Element *E = gds_utilities_map.front(); E; E = E->next()) { - function->gds_utilities.write[E->get()] = E->key(); + for (const KeyValue<GDScriptUtilityFunctions::FunctionPtr, int> &E : gds_utilities_map) { + function->gds_utilities.write[E.value] = E.key; } } else { function->_gds_utilities_ptr = nullptr; @@ -373,8 +373,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->methods.resize(method_bind_map.size()); function->_methods_ptr = function->methods.ptrw(); function->_methods_count = method_bind_map.size(); - for (const Map<MethodBind *, int>::Element *E = method_bind_map.front(); E; E = E->next()) { - function->methods.write[E->get()] = E->key(); + for (const KeyValue<MethodBind *, int> &E : method_bind_map) { + function->methods.write[E.value] = E.key; } } else { function->_methods_ptr = nullptr; @@ -385,8 +385,8 @@ GDScriptFunction *GDScriptByteCodeGenerator::write_end() { function->lambdas.resize(lambdas_map.size()); function->_lambdas_ptr = function->lambdas.ptrw(); function->_lambdas_count = lambdas_map.size(); - for (const Map<GDScriptFunction *, int>::Element *E = lambdas_map.front(); E; E = E->next()) { - function->lambdas.write[E->get()] = E->key(); + for (const KeyValue<GDScriptFunction *, int> &E : lambdas_map) { + function->lambdas.write[E.value] = E.key; } } else { function->_lambdas_ptr = nullptr; diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h index dcc11ebdce..fbbf5802fd 100644 --- a/modules/gdscript/gdscript_byte_codegen.h +++ b/modules/gdscript/gdscript_byte_codegen.h @@ -153,12 +153,12 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator { #endif locals.resize(current_locals); if (debug_stack) { - for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) { + for (const KeyValue<StringName, int> &E : block_identifiers) { GDScriptFunction::StackDebug sd; sd.added = false; - sd.identifier = E->key(); + sd.identifier = E.key; sd.line = current_line; - sd.pos = E->get(); + sd.pos = E.value; stack_debug.push_back(sd); } block_identifiers = block_identifier_stack.back()->get(); diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 947224e93e..2c02291795 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2193,8 +2193,8 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar p_script->_base = nullptr; p_script->members.clear(); p_script->constants.clear(); - for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<StringName, GDScriptFunction *> &E : p_script->member_functions) { + memdelete(E.value); } p_script->member_functions.clear(); p_script->member_indices.clear(); @@ -2519,8 +2519,8 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa instance->owner = E->get(); //needed for hot reloading - for (Map<StringName, GDScript::MemberInfo>::Element *F = p_script->member_indices.front(); F; F = F->next()) { - instance->member_indices_cache[F->key()] = F->get().index; + for (const KeyValue<StringName, GDScript::MemberInfo> &F : p_script->member_indices) { + instance->member_indices_cache[F.key] = F.value.index; } instance->owner->set_script_instance(instance); diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 044ac4b661..83805f626a 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -173,8 +173,8 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li get_function_names_recursively(cl, "", funcs); - for (Map<int, String>::Element *E = funcs.front(); E; E = E->next()) { - r_functions->push_back(E->get() + ":" + itos(E->key())); + for (const KeyValue<int, String> &E : funcs) { + r_functions->push_back(E.value + ":" + itos(E.key)); } } @@ -344,9 +344,9 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> * const Map<StringName, GDScript::MemberInfo> &mi = script->debug_get_member_indices(); - for (const Map<StringName, GDScript::MemberInfo>::Element *E = mi.front(); E; E = E->next()) { - p_members->push_back(E->key()); - p_values->push_back(instance->debug_get_member_by_index(E->get().index)); + for (const KeyValue<StringName, GDScript::MemberInfo> &E : mi) { + p_members->push_back(E.key); + p_values->push_back(instance->debug_get_member_by_index(E.value.index)); } } @@ -370,14 +370,14 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> List<Pair<String, Variant>> cinfo; get_public_constants(&cinfo); - for (const Map<StringName, int>::Element *E = name_idx.front(); E; E = E->next()) { - if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key())) { + for (const KeyValue<StringName, int> &E : name_idx) { + if (ClassDB::class_exists(E.key) || Engine::get_singleton()->has_singleton(E.key)) { continue; } bool is_script_constant = false; for (List<Pair<String, Variant>>::Element *CE = cinfo.front(); CE; CE = CE->next()) { - if (CE->get().first == E->key()) { + if (CE->get().first == E.key) { is_script_constant = true; break; } @@ -386,7 +386,7 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> continue; } - const Variant &var = globals[E->value()]; + const Variant &var = globals[E.value]; if (Object *obj = var) { if (Object::cast_to<GDScriptNativeClass>(obj)) { continue; @@ -395,7 +395,7 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> bool skip = false; for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) { - if (E->key() == CoreConstants::get_global_constant_name(i)) { + if (E.key == CoreConstants::get_global_constant_name(i)) { skip = true; break; } @@ -404,7 +404,7 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> continue; } - p_globals->push_back(E->key()); + p_globals->push_back(E.key); p_values->push_back(var); } } @@ -875,8 +875,8 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base } Map<StringName, Variant> constants; scr->get_constants(&constants); - for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->key().operator String(), ScriptCodeCompletionOption::KIND_CONSTANT); + for (const KeyValue<StringName, Variant> &E : constants) { + ScriptCodeCompletionOption option(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT); r_result.insert(option.display, option); } @@ -1099,12 +1099,12 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool } // Native classes and global constants. - for (const Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) { + for (const KeyValue<StringName, int> &E : GDScriptLanguage::get_singleton()->get_global_map()) { ScriptCodeCompletionOption option; - if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key())) { - option = ScriptCodeCompletionOption(E->key().operator String(), ScriptCodeCompletionOption::KIND_CLASS); + if (ClassDB::class_exists(E.key) || Engine::get_singleton()->has_singleton(E.key)) { + option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CLASS); } else { - option = ScriptCodeCompletionOption(E->key().operator String(), ScriptCodeCompletionOption::KIND_CONSTANT); + option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT); } r_result.insert(option.display, option); } @@ -2680,8 +2680,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } break; } - for (Map<String, ScriptCodeCompletionOption>::Element *E = options.front(); E; E = E->next()) { - r_options->push_back(E->get()); + for (const KeyValue<String, ScriptCodeCompletionOption> &E : options) { + r_options->push_back(E.value); } return OK; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 876c508689..a3f0c7dfef 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -120,11 +120,11 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String } List<_GDFKCS> stackpositions; - for (Map<StringName, _GDFKC>::Element *E = sdmap.front(); E; E = E->next()) { + for (const KeyValue<StringName, _GDFKC> &E : sdmap) { _GDFKCS spp; - spp.id = E->key(); - spp.order = E->get().order; - spp.pos = E->get().pos.back()->get(); + spp.id = E.key; + spp.order = E.value.order; + spp.pos = E.value.pos.back()->get(); stackpositions.push_back(spp); } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 025accf4ba..4e71eb32e9 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -582,9 +582,9 @@ void GDScriptParser::parse_program() { parse_class_body(true); #ifdef TOOLS_ENABLED - for (Map<int, GDScriptTokenizer::CommentData>::Element *E = tokenizer.get_comments().front(); E; E = E->next()) { - if (E->get().new_line && E->get().comment.begins_with("##")) { - class_doc_line = MIN(class_doc_line, E->key()); + for (const KeyValue<int, GDScriptTokenizer::CommentData> &E : tokenizer.get_comments()) { + if (E.value.new_line && E.value.comment.begins_with("##")) { + class_doc_line = MIN(class_doc_line, E.key); } } if (has_comment(class_doc_line)) { diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 62531473c3..f1b0079536 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -317,9 +317,9 @@ struct GDScriptUtilityFunctionsDefinitions { d["@subpath"] = cp; d["@path"] = p->get_path(); - for (Map<StringName, GDScript::MemberInfo>::Element *E = base->member_indices.front(); E; E = E->next()) { - if (!d.has(E->key())) { - d[E->key()] = ins->members[E->get().index]; + for (const KeyValue<StringName, GDScript::MemberInfo> &E : base->member_indices) { + if (!d.has(E.key)) { + d[E.key] = ins->members[E.value.index]; } } *r_ret = d; @@ -396,9 +396,9 @@ struct GDScriptUtilityFunctionsDefinitions { GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(*r_ret)->get_script_instance()); Ref<GDScript> gd_ref = ins->get_script(); - for (Map<StringName, GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) { - if (d.has(E->key())) { - ins->members.write[E->get().index] = d[E->key()]; + for (KeyValue<StringName, GDScript::MemberInfo> &E : gd_ref->member_indices) { + if (d.has(E.key)) { + ins->members.write[E.value.index] = d[E.key]; } } } diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 6186d0edee..c89cf2f25c 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -531,8 +531,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a memnew_placement(&stack[ADDR_STACK_CLASS], Variant(script)); - for (const Map<int, Variant::Type>::Element *E = temporary_slots.front(); E; E = E->next()) { - type_init_function_table[E->get()](&stack[E->key()]); + for (const KeyValue<int, Variant::Type> &E : temporary_slots) { + type_init_function_table[E.value](&stack[E.key]); } String err_text; diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index bd5a9f01b2..5cf1e0fc5f 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -212,11 +212,11 @@ void GDScriptLanguageProtocol::initialized(const Variant &p_params) { lsp::GodotCapabilities capabilities; DocTools *doc = EditorHelp::get_doc_data(); - for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { + for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) { lsp::GodotNativeClassInfo gdclass; - gdclass.name = E->get().name; - gdclass.class_doc = &(E->get()); - if (ClassDB::ClassInfo *ptr = ClassDB::classes.getptr(StringName(E->get().name))) { + gdclass.name = E.value.name; + gdclass.class_doc = &(E.value); + if (ClassDB::ClassInfo *ptr = ClassDB::classes.getptr(StringName(E.value.name))) { gdclass.class_info = ptr; } capabilities.native_classes.push_back(gdclass); diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 03b1e3fa44..d2e033d7de 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -217,8 +217,8 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { } else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { arr = native_member_completions.duplicate(); - for (Map<String, ExtendGDScriptParser *>::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.front(); E; E = E->next()) { - ExtendGDScriptParser *script = E->get(); + for (KeyValue<String, ExtendGDScriptParser *> &E : GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts) { + ExtendGDScriptParser *script = E.value; const Array &items = script->get_member_completions(); const int start_size = arr.size(); diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index f4b55cac02..371e3de419 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -261,9 +261,9 @@ Array GDScriptWorkspace::symbol(const Dictionary &p_params) { String query = p_params["query"]; Array arr; if (!query.is_empty()) { - for (Map<String, ExtendGDScriptParser *>::Element *E = scripts.front(); E; E = E->next()) { + for (const KeyValue<String, ExtendGDScriptParser *> &E : scripts) { Vector<lsp::DocumentedSymbolInformation> script_symbols; - E->get()->get_symbols().symbol_tree_as_list(E->key(), script_symbols); + E.value->get_symbols().symbol_tree_as_list(E.key, script_symbols); for (int i = 0; i < script_symbols.size(); ++i) { if (query.is_subsequence_ofi(script_symbols[i].name)) { lsp::DocumentedSymbolInformation symbol = script_symbols[i]; @@ -282,10 +282,10 @@ Error GDScriptWorkspace::initialize() { } DocTools *doc = EditorHelp::get_doc_data(); - for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { - const DocData::ClassDoc &class_data = E->value(); + for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) { + const DocData::ClassDoc &class_data = E.value; lsp::DocumentSymbol class_symbol; - String class_name = E->key(); + String class_name = E.key; class_symbol.name = class_name; class_symbol.native_class = class_name; class_symbol.kind = lsp::SymbolKind::Class; @@ -393,19 +393,19 @@ Error GDScriptWorkspace::initialize() { reload_all_workspace_scripts(); if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { - for (Map<StringName, lsp::DocumentSymbol>::Element *E = native_symbols.front(); E; E = E->next()) { + for (const KeyValue<StringName, lsp::DocumentSymbol> &E : native_symbols) { ClassMembers members; - const lsp::DocumentSymbol &class_symbol = E->get(); + const lsp::DocumentSymbol &class_symbol = E.value; for (int i = 0; i < class_symbol.children.size(); i++) { const lsp::DocumentSymbol &symbol = class_symbol.children[i]; members.set(symbol.name, &symbol); } - native_members.set(E->key(), members); + native_members.set(E.key, members); } // cache member completions - for (Map<String, ExtendGDScriptParser *>::Element *S = scripts.front(); S; S = S->next()) { - S->get()->get_member_completions(); + for (const KeyValue<String, ExtendGDScriptParser *> &S : scripts) { + S.value->get_member_completions(); } } @@ -685,8 +685,8 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP class_ptr = native_members.next(class_ptr); } - for (Map<String, ExtendGDScriptParser *>::Element *E = scripts.front(); E; E = E->next()) { - const ExtendGDScriptParser *script = E->get(); + for (const KeyValue<String, ExtendGDScriptParser *> &E : scripts) { + const ExtendGDScriptParser *script = E.value; const ClassMembers &members = script->get_members(); if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) { r_list.push_back(*symbol); @@ -786,12 +786,12 @@ GDScriptWorkspace::GDScriptWorkspace() { GDScriptWorkspace::~GDScriptWorkspace() { Set<String> cached_parsers; - for (Map<String, ExtendGDScriptParser *>::Element *E = parse_results.front(); E; E = E->next()) { - cached_parsers.insert(E->key()); + for (const KeyValue<String, ExtendGDScriptParser *> &E : parse_results) { + cached_parsers.insert(E.key); } - for (Map<String, ExtendGDScriptParser *>::Element *E = scripts.front(); E; E = E->next()) { - cached_parsers.insert(E->key()); + for (const KeyValue<String, ExtendGDScriptParser *> &E : scripts) { + cached_parsers.insert(E.key); } for (Set<String>::Element *E = cached_parsers.front(); E; E = E->next()) { diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 662382d279..3710a84a28 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -277,15 +277,15 @@ struct WorkspaceEdit { Dictionary dict; Dictionary out_changes; - for (Map<String, Vector<TextEdit>>::Element *E = changes.front(); E; E = E->next()) { + for (const KeyValue<String, Vector<TextEdit>> &E : changes) { Array edits; - for (int i = 0; i < E->get().size(); ++i) { + for (int i = 0; i < E.value.size(); ++i) { Dictionary text_edit; - text_edit["range"] = E->get()[i].range.to_json(); - text_edit["newText"] = E->get()[i].newText; + text_edit["range"] = E.value[i].range.to_json(); + text_edit["newText"] = E.value[i].newText; edits.push_back(text_edit); } - out_changes[E->key()] = edits; + out_changes[E.key] = edits; } dict["changes"] = out_changes; diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index e54f055f2b..80eabc1596 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -172,8 +172,8 @@ static void test_compiler(const String &p_code, const String &p_script_path, con return; } - for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) { - const GDScriptFunction *func = E->value(); + for (const KeyValue<StringName, GDScriptFunction *> &E : script->get_member_functions()) { + const GDScriptFunction *func = E.value; String signature = "Disassembling " + func->get_name().operator String() + "("; for (int i = 0; i < func->get_argument_count(); i++) { diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 5f2e8d4ba6..3f1f218e78 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -4673,8 +4673,8 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { Array channels; Array samplers; - for (Map<int, GLTFAnimation::Track>::Element *track_i = gltf_animation->get_tracks().front(); track_i; track_i = track_i->next()) { - GLTFAnimation::Track track = track_i->get(); + for (KeyValue<int, GLTFAnimation::Track> &track_i : gltf_animation->get_tracks()) { + GLTFAnimation::Track track = track_i.value; if (track.position_track.times.size()) { Dictionary t; t["sampler"] = samplers.size(); @@ -4690,7 +4690,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { Dictionary target; target["path"] = "translation"; - target["node"] = track_i->key(); + target["node"] = track_i.key; t["target"] = target; channels.push_back(t); @@ -4710,7 +4710,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { Dictionary target; target["path"] = "rotation"; - target["node"] = track_i->key(); + target["node"] = track_i.key; t["target"] = target; channels.push_back(t); @@ -4730,7 +4730,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { Dictionary target; target["path"] = "scale"; - target["node"] = track_i->key(); + target["node"] = track_i.key; t["target"] = target; channels.push_back(t); @@ -4809,7 +4809,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { Dictionary target; target["path"] = "weights"; - target["node"] = track_i->key(); + target["node"] = track_i.key; t["target"] = target; channels.push_back(t); @@ -5800,16 +5800,16 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, float length = 0.0; - for (Map<int, GLTFAnimation::Track>::Element *track_i = anim->get_tracks().front(); track_i; track_i = track_i->next()) { - const GLTFAnimation::Track &track = track_i->get(); + for (const KeyValue<int, GLTFAnimation::Track> &track_i : anim->get_tracks()) { + const GLTFAnimation::Track &track = track_i.value; //need to find the path: for skeletons, weight tracks will affect the mesh NodePath node_path; //for skeletons, transform tracks always affect bones NodePath transform_node_path; - GLTFNodeIndex node_index = track_i->key(); + GLTFNodeIndex node_index = track_i.key; - const Ref<GLTFNode> gltf_node = state->nodes[track_i->key()]; + const Ref<GLTFNode> gltf_node = state->nodes[track_i.key]; Node *root = ap->get_parent(); ERR_FAIL_COND(root == nullptr); @@ -5861,15 +5861,15 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, Vector3 base_scale = Vector3(1, 1, 1); if (!track.rotation_track.values.size()) { - base_rot = state->nodes[track_i->key()]->rotation.normalized(); + base_rot = state->nodes[track_i.key]->rotation.normalized(); } if (!track.position_track.values.size()) { - base_pos = state->nodes[track_i->key()]->position; + base_pos = state->nodes[track_i.key]->position; } if (!track.scale_track.values.size()) { - base_scale = state->nodes[track_i->key()]->scale; + base_scale = state->nodes[track_i.key]->scale; } bool last = false; @@ -6322,9 +6322,9 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, const Vector<String> node_suffix = String(orig_track_path).split(":position"); const NodePath path = node_suffix[0]; const Node *node = ap->get_parent()->get_node_or_null(path); - for (Map<GLTFNodeIndex, Node *>::Element *position_scene_node_i = state->scene_nodes.front(); position_scene_node_i; position_scene_node_i = position_scene_node_i->next()) { - if (position_scene_node_i->get() == node) { - GLTFNodeIndex node_index = position_scene_node_i->key(); + for (const KeyValue<GLTFNodeIndex, Node *> &position_scene_node_i : state->scene_nodes) { + if (position_scene_node_i.value == node) { + GLTFNodeIndex node_index = position_scene_node_i.key; Map<int, GLTFAnimation::Track>::Element *position_track_i = gltf_animation->get_tracks().find(node_index); GLTFAnimation::Track track; if (position_track_i) { @@ -6338,9 +6338,9 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, const Vector<String> node_suffix = String(orig_track_path).split(":rotation_degrees"); const NodePath path = node_suffix[0]; const Node *node = ap->get_parent()->get_node_or_null(path); - for (Map<GLTFNodeIndex, Node *>::Element *rotation_degree_scene_node_i = state->scene_nodes.front(); rotation_degree_scene_node_i; rotation_degree_scene_node_i = rotation_degree_scene_node_i->next()) { - if (rotation_degree_scene_node_i->get() == node) { - GLTFNodeIndex node_index = rotation_degree_scene_node_i->key(); + for (const KeyValue<GLTFNodeIndex, Node *> &rotation_degree_scene_node_i : state->scene_nodes) { + if (rotation_degree_scene_node_i.value == node) { + GLTFNodeIndex node_index = rotation_degree_scene_node_i.key; Map<int, GLTFAnimation::Track>::Element *rotation_degree_track_i = gltf_animation->get_tracks().find(node_index); GLTFAnimation::Track track; if (rotation_degree_track_i) { @@ -6354,9 +6354,9 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, const Vector<String> node_suffix = String(orig_track_path).split(":scale"); const NodePath path = node_suffix[0]; const Node *node = ap->get_parent()->get_node_or_null(path); - for (Map<GLTFNodeIndex, Node *>::Element *scale_scene_node_i = state->scene_nodes.front(); scale_scene_node_i; scale_scene_node_i = scale_scene_node_i->next()) { - if (scale_scene_node_i->get() == node) { - GLTFNodeIndex node_index = scale_scene_node_i->key(); + for (const KeyValue<GLTFNodeIndex, Node *> &scale_scene_node_i : state->scene_nodes) { + if (scale_scene_node_i.value == node) { + GLTFNodeIndex node_index = scale_scene_node_i.key; Map<int, GLTFAnimation::Track>::Element *scale_track_i = gltf_animation->get_tracks().find(node_index); GLTFAnimation::Track track; if (scale_track_i) { @@ -6370,11 +6370,11 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, const Vector<String> node_suffix = String(orig_track_path).split(":transform"); const NodePath path = node_suffix[0]; const Node *node = ap->get_parent()->get_node_or_null(path); - for (Map<GLTFNodeIndex, Node *>::Element *transform_track_i = state->scene_nodes.front(); transform_track_i; transform_track_i = transform_track_i->next()) { - if (transform_track_i->get() == node) { + for (const KeyValue<GLTFNodeIndex, Node *> &transform_track_i : state->scene_nodes) { + if (transform_track_i.value == node) { GLTFAnimation::Track track; - track = _convert_animation_track(state, track, animation, Transform3D(), track_i, transform_track_i->key()); - gltf_animation->get_tracks().insert(transform_track_i->key(), track); + track = _convert_animation_track(state, track, animation, Transform3D(), track_i, transform_track_i.key); + gltf_animation->get_tracks().insert(transform_track_i.key, track); } } } else if (String(orig_track_path).find(":blend_shapes/") != -1) { @@ -6386,9 +6386,9 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, Ref<Mesh> mesh = mi->get_mesh(); ERR_CONTINUE(mesh.is_null()); int32_t mesh_index = -1; - for (Map<GLTFNodeIndex, Node *>::Element *mesh_track_i = state->scene_nodes.front(); mesh_track_i; mesh_track_i = mesh_track_i->next()) { - if (mesh_track_i->get() == node) { - mesh_index = mesh_track_i->key(); + for (const KeyValue<GLTFNodeIndex, Node *> &mesh_track_i : state->scene_nodes) { + if (mesh_track_i.value == node) { + mesh_index = mesh_track_i.key; } } ERR_CONTINUE(mesh_index == -1); @@ -6469,9 +6469,9 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, for (int32_t node_i = 0; node_i < ap->get_parent()->get_child_count(); node_i++) { const Node *child = ap->get_parent()->get_child(node_i); const Node *node = child->get_node_or_null(orig_track_path); - for (Map<GLTFNodeIndex, Node *>::Element *scene_node_i = state->scene_nodes.front(); scene_node_i; scene_node_i = scene_node_i->next()) { - if (scene_node_i->get() == node) { - GLTFNodeIndex node_index = scene_node_i->key(); + for (const KeyValue<GLTFNodeIndex, Node *> &scene_node_i : state->scene_nodes) { + if (scene_node_i.value == node) { + GLTFNodeIndex node_index = scene_node_i.key; Map<int, GLTFAnimation::Track>::Element *node_track_i = gltf_animation->get_tracks().find(node_index); GLTFAnimation::Track track; if (node_track_i) { diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 116c0e00f9..c9d8f2b42b 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -420,8 +420,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) { } //erase navigation - for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { - NavigationServer3D::get_singleton()->free(E->get().region); + for (const KeyValue<IndexKey, Octant::NavMesh> &E : g.navmesh_ids) { + NavigationServer3D::get_singleton()->free(E.value.region); } g.navmesh_ids.clear(); @@ -512,15 +512,15 @@ bool GridMap::_octant_update(const OctantKey &p_key) { //update multimeshes, only if not baked if (baked_meshes.size() == 0) { - for (Map<int, List<Pair<Transform3D, IndexKey>>>::Element *E = multimesh_items.front(); E; E = E->next()) { + for (const KeyValue<int, List<Pair<Transform3D, IndexKey>>> &E : multimesh_items) { Octant::MultimeshInstance mmi; RID mm = RS::get_singleton()->multimesh_create(); - RS::get_singleton()->multimesh_allocate_data(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D); - RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); + RS::get_singleton()->multimesh_allocate_data(mm, E.value.size(), RS::MULTIMESH_TRANSFORM_3D); + RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E.key)->get_rid()); int idx = 0; - for (const Pair<Transform3D, IndexKey> &F : E->get()) { + for (const Pair<Transform3D, IndexKey> &F : E.value) { RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F.first); #ifdef TOOLS_ENABLED @@ -567,9 +567,9 @@ bool GridMap::_octant_update(const OctantKey &p_key) { } void GridMap::_reset_physic_bodies_collision_filters() { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - PhysicsServer3D::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer); - PhysicsServer3D::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask); + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { + PhysicsServer3D::get_singleton()->body_set_collision_layer(E.value->static_body, collision_layer); + PhysicsServer3D::get_singleton()->body_set_collision_mask(E.value->static_body, collision_mask); } } @@ -590,17 +590,17 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { } if (bake_navigation && mesh_library.is_valid()) { - for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { - if (cell_map.has(F->key()) && F->get().region.is_valid() == false) { - Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item); + for (KeyValue<IndexKey, Octant::NavMesh> &F : g.navmesh_ids) { + if (cell_map.has(F.key) && F.value.region.is_valid() == false) { + Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F.key].item); if (nm.is_valid()) { RID region = NavigationServer3D::get_singleton()->region_create(); NavigationServer3D::get_singleton()->region_set_layers(region, navigation_layers); NavigationServer3D::get_singleton()->region_set_navmesh(region, nm); - NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * F->get().xform); + NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * F.value.xform); NavigationServer3D::get_singleton()->region_set_map(region, get_world_3d()->get_navigation_map()); - F->get().region = region; + F.value.region = region; } } } @@ -621,10 +621,10 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID()); } - for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { - if (F->get().region.is_valid()) { - NavigationServer3D::get_singleton()->free(F->get().region); - F->get().region = RID(); + for (KeyValue<IndexKey, Octant::NavMesh> &F : g.navmesh_ids) { + if (F.value.region.is_valid()) { + NavigationServer3D::get_singleton()->free(F.value.region); + F.value.region = RID(); } } } @@ -643,8 +643,8 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) { PhysicsServer3D::get_singleton()->free(g.static_body); // Erase navigation - for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { - NavigationServer3D::get_singleton()->free(E->get().region); + for (const KeyValue<IndexKey, Octant::NavMesh> &E : g.navmesh_ids) { + NavigationServer3D::get_singleton()->free(E.value.region); } g.navmesh_ids.clear(); @@ -662,8 +662,8 @@ void GridMap::_notification(int p_what) { case NOTIFICATION_ENTER_WORLD: { last_transform = get_global_transform(); - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - _octant_enter_world(E->key()); + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { + _octant_enter_world(E.key); } for (int i = 0; i < baked_meshes.size(); i++) { @@ -678,8 +678,8 @@ void GridMap::_notification(int p_what) { break; } //update run - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - _octant_transform(E->key()); + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { + _octant_transform(E.key); } last_transform = new_xform; @@ -689,8 +689,8 @@ void GridMap::_notification(int p_what) { } } break; case NOTIFICATION_EXIT_WORLD: { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - _octant_exit_world(E->key()); + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { + _octant_exit_world(E.key); } //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); @@ -712,8 +712,8 @@ void GridMap::_update_visibility() { return; } - for (Map<OctantKey, Octant *>::Element *e = octant_map.front(); e; e = e->next()) { - Octant *octant = e->value(); + for (KeyValue<OctantKey, Octant *> &e : octant_map) { + Octant *octant = e.value; for (int i = 0; i < octant->multimesh_instances.size(); i++) { const Octant::MultimeshInstance &mi = octant->multimesh_instances[i]; RS::get_singleton()->instance_set_visible(mi.instance, is_visible_in_tree()); @@ -738,20 +738,20 @@ void GridMap::_recreate_octant_data() { recreating_octants = true; Map<IndexKey, Cell> cell_copy = cell_map; _clear_internal(); - for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) { - set_cell_item(Vector3i(E->key()), E->get().item, E->get().rot); + for (const KeyValue<IndexKey, Cell> &E : cell_copy) { + set_cell_item(Vector3i(E.key), E.value.item, E.value.rot); } recreating_octants = false; } void GridMap::_clear_internal() { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { if (is_inside_world()) { - _octant_exit_world(E->key()); + _octant_exit_world(E.key); } - _octant_clean_up(E->key()); - memdelete(E->get()); + _octant_clean_up(E.key); + memdelete(E.value); } octant_map.clear(); @@ -773,9 +773,9 @@ void GridMap::_update_octants_callback() { } List<OctantKey> to_delete; - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - if (_octant_update(E->key())) { - to_delete.push_back(E->key()); + for (const KeyValue<OctantKey, Octant *> &E : octant_map) { + if (_octant_update(E.key)) { + to_delete.push_back(E.key); } } @@ -883,8 +883,8 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3:: clip_above = p_clip_above; //make it all update - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - Octant *g = E->get(); + for (KeyValue<OctantKey, Octant *> &E : octant_map) { + Octant *g = E.value; g->dirty = true; } awaiting_update = true; @@ -904,8 +904,8 @@ Array GridMap::get_used_cells() const { Array a; a.resize(cell_map.size()); int i = 0; - for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) { - Vector3 p(E->key().x, E->key().y, E->key().z); + for (const KeyValue<IndexKey, Cell> &E : cell_map) { + Vector3 p(E.key.x, E.key.y, E.key.z); a[i++] = p; } @@ -920,8 +920,8 @@ Array GridMap::get_meshes() { Vector3 ofs = _get_offset(); Array meshes; - for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) { - int id = E->get().item; + for (KeyValue<IndexKey, Cell> &E : cell_map) { + int id = E.value.item; if (!mesh_library->has_item(id)) { continue; } @@ -930,13 +930,13 @@ Array GridMap::get_meshes() { continue; } - IndexKey ik = E->key(); + IndexKey ik = E.key; Vector3 cellpos = Vector3(ik.x, ik.y, ik.z); Transform3D xform; - xform.basis.set_orthogonal_index(E->get().rot); + xform.basis.set_orthogonal_index(E.value.rot); xform.set_origin(cellpos * cell_size + ofs); xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale)); @@ -972,10 +972,10 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe //generate Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>> surface_map; - for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) { - IndexKey key = E->key(); + for (KeyValue<IndexKey, Cell> &E : cell_map) { + IndexKey key = E.key; - int item = E->get().item; + int item = E.value.item; if (!mesh_library->has_item(item)) { continue; } @@ -990,7 +990,7 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe Transform3D xform; - xform.basis.set_orthogonal_index(E->get().rot); + xform.basis.set_orthogonal_index(E.value.rot); xform.set_origin(cellpos * cell_size + ofs); xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale)); @@ -1023,11 +1023,11 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe } } - for (Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>>::Element *E = surface_map.front(); E; E = E->next()) { + for (KeyValue<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>> &E : surface_map) { Ref<ArrayMesh> mesh; mesh.instantiate(); - for (Map<Ref<Material>, Ref<SurfaceTool>>::Element *F = E->get().front(); F; F = F->next()) { - F->get()->commit(mesh); + for (KeyValue<Ref<Material>, Ref<SurfaceTool>> &F : E.value) { + F.value->commit(mesh); } BakedMesh bm; diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 962bf79150..0c8f0ed8c9 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -613,17 +613,17 @@ void NavMap::sync() { } Vector<gd::Edge::Connection> free_edges; - for (Map<gd::EdgeKey, Vector<gd::Edge::Connection>>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().size() == 2) { + for (KeyValue<gd::EdgeKey, Vector<gd::Edge::Connection>> &E : connections) { + if (E.value.size() == 2) { // Connect edge that are shared in different polygons. - gd::Edge::Connection &c1 = E->get().write[0]; - gd::Edge::Connection &c2 = E->get().write[1]; + gd::Edge::Connection &c1 = E.value.write[0]; + gd::Edge::Connection &c2 = E.value.write[1]; c1.polygon->edges[c1.edge].connections.push_back(c2); c2.polygon->edges[c2.edge].connections.push_back(c1); // Note: The pathway_start/end are full for those connection and do not need to be modified. } else { - CRASH_COND_MSG(E->get().size() != 1, vformat("Number of connection != 1. Found: %d", E->get().size())); - free_edges.push_back(E->get()[0]); + CRASH_COND_MSG(E.value.size() != 1, vformat("Number of connection != 1. Found: %d", E.value.size())); + free_edges.push_back(E.value[0]); } } diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index acc447018d..b5b7342e87 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -1585,8 +1585,8 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced } _FORCE_INLINE_ void TextServerAdvanced::_font_clear_cache(FontDataAdvanced *p_font_data) { - for (const Map<Vector2i, FontDataForSizeAdvanced *>::Element *E = p_font_data->cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<Vector2i, FontDataForSizeAdvanced *> &E : p_font_data->cache) { + memdelete(E.value); } p_font_data->cache.clear(); p_font_data->face_init = false; @@ -1822,8 +1822,8 @@ void TextServerAdvanced::font_clear_size_cache(RID p_font_rid) { ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); - for (const Map<Vector2i, FontDataForSizeAdvanced *>::Element *E = fd->cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<Vector2i, FontDataForSizeAdvanced *> &E : fd->cache) { + memdelete(E.value); } fd->cache.clear(); } @@ -2678,8 +2678,8 @@ Vector<String> TextServerAdvanced::font_get_language_support_overrides(RID p_fon MutexLock lock(fd->mutex); Vector<String> out; - for (const Map<String, bool>::Element *E = fd->language_support_overrides.front(); E; E = E->next()) { - out.push_back(E->key()); + for (const KeyValue<String, bool> &E : fd->language_support_overrides) { + out.push_back(E.key); } return out; } @@ -2839,9 +2839,9 @@ void TextServerAdvanced::invalidate(TextServerAdvanced::ShapedTextDataAdvanced * void TextServerAdvanced::full_copy(ShapedTextDataAdvanced *p_shaped) { ShapedTextDataAdvanced *parent = shaped_owner.get_or_null(p_shaped->parent); - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = parent->objects.front(); E; E = E->next()) { - if (E->get().pos >= p_shaped->start && E->get().pos < p_shaped->end) { - p_shaped->objects[E->key()] = E->get(); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : parent->objects) { + if (E.value.pos >= p_shaped->start && E.value.pos < p_shaped->end) { + p_shaped->objects[E.key] = E.value; } } @@ -3065,9 +3065,9 @@ bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, Glyph gl = sd->glyphs[i]; Variant key; if (gl.count == 1) { - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if (E->get().pos == gl.start) { - key = E->key(); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if (E.value.pos == gl.start) { + key = E.key; break; } } @@ -3110,64 +3110,64 @@ bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, // Align embedded objects to baseline. real_t full_ascent = sd->ascent; real_t full_descent = sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if ((E->get().pos >= sd->start) && (E->get().pos < sd->end)) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if ((E.value.pos >= sd->start) && (E.value.pos < sd->end)) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -sd->ascent; + E.value.rect.position.y = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.y = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = sd->descent; + E.value.rect.position.y = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -sd->ascent; + E.value.rect.position.x = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.x = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = sd->descent; + E.value.rect.position.x = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } } @@ -3254,11 +3254,11 @@ RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_leng Variant key; bool find_embedded = false; if (gl.count == 1) { - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if (E->get().pos == gl.start) { + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if (E.value.pos == gl.start) { find_embedded = true; - key = E->key(); - new_sd->objects[key] = E->get(); + key = E.key; + new_sd->objects[key] = E.value; break; } } @@ -3301,64 +3301,64 @@ RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_leng // Align embedded objects to baseline. real_t full_ascent = new_sd->ascent; real_t full_descent = new_sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = new_sd->objects.front(); E; E = E->next()) { - if ((E->get().pos >= new_sd->start) && (E->get().pos < new_sd->end)) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : new_sd->objects) { + if ((E.value.pos >= new_sd->start) && (E.value.pos < new_sd->end)) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -new_sd->ascent; + E.value.rect.position.y = -new_sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-new_sd->ascent + new_sd->descent) / 2; + E.value.rect.position.y = (-new_sd->ascent + new_sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = new_sd->descent; + E.value.rect.position.y = new_sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -new_sd->ascent; + E.value.rect.position.x = -new_sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-new_sd->ascent + new_sd->descent) / 2; + E.value.rect.position.x = (-new_sd->ascent + new_sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = new_sd->descent; + E.value.rect.position.x = new_sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } } @@ -4413,63 +4413,63 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { // Align embedded objects to baseline. real_t full_ascent = sd->ascent; real_t full_descent = sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -sd->ascent; + E.value.rect.position.y = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.y = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = sd->descent; + E.value.rect.position.y = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -sd->ascent; + E.value.rect.position.x = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.x = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = sd->descent; + E.value.rect.position.x = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } sd->ascent = full_ascent; @@ -4529,8 +4529,8 @@ Array TextServerAdvanced::shaped_text_get_objects(RID p_shaped) const { ERR_FAIL_COND_V(!sd, ret); MutexLock lock(sd->mutex); - for (const Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + ret.push_back(E.key); } return ret; diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index b1ce85d505..62adf458aa 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -795,8 +795,8 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback } _FORCE_INLINE_ void TextServerFallback::_font_clear_cache(FontDataFallback *p_font_data) { - for (const Map<Vector2i, FontDataForSizeFallback *>::Element *E = p_font_data->cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<Vector2i, FontDataForSizeFallback *> &E : p_font_data->cache) { + memdelete(E.value); } p_font_data->cache.clear(); @@ -1008,8 +1008,8 @@ Array TextServerFallback::font_get_size_cache_list(RID p_font_rid) const { MutexLock lock(fd->mutex); Array ret; - for (const Map<Vector2i, FontDataForSizeFallback *>::Element *E = fd->cache.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue<Vector2i, FontDataForSizeFallback *> &E : fd->cache) { + ret.push_back(E.key); } return ret; } @@ -1019,8 +1019,8 @@ void TextServerFallback::font_clear_size_cache(RID p_font_rid) { ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); - for (const Map<Vector2i, FontDataForSizeFallback *>::Element *E = fd->cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<Vector2i, FontDataForSizeFallback *> &E : fd->cache) { + memdelete(E.value); } fd->cache.clear(); } @@ -1578,8 +1578,8 @@ Array TextServerFallback::font_get_kerning_list(RID p_font_rid, int p_size) cons ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Array()); Array ret; - for (const Map<Vector2i, Vector2>::Element *E = fd->cache[size]->kerning_map.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue<Vector2i, Vector2> &E : fd->cache[size]->kerning_map) { + ret.push_back(E.key); } return ret; } @@ -1852,8 +1852,8 @@ Vector<String> TextServerFallback::font_get_language_support_overrides(RID p_fon MutexLock lock(fd->mutex); Vector<String> out; - for (const Map<String, bool>::Element *E = fd->language_support_overrides.front(); E; E = E->next()) { - out.push_back(E->key()); + for (const KeyValue<String, bool> &E : fd->language_support_overrides) { + out.push_back(E.key); } return out; } @@ -1902,8 +1902,8 @@ Vector<String> TextServerFallback::font_get_script_support_overrides(RID p_font_ MutexLock lock(fd->mutex); Vector<String> out; - for (const Map<String, bool>::Element *E = fd->script_support_overrides.front(); E; E = E->next()) { - out.push_back(E->key()); + for (const KeyValue<String, bool> &E : fd->script_support_overrides) { + out.push_back(E.key); } return out; } @@ -1971,9 +1971,9 @@ void TextServerFallback::invalidate(ShapedTextData *p_shaped) { void TextServerFallback::full_copy(ShapedTextData *p_shaped) { ShapedTextData *parent = shaped_owner.get_or_null(p_shaped->parent); - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = parent->objects.front(); E; E = E->next()) { - if (E->get().pos >= p_shaped->start && E->get().pos < p_shaped->end) { - p_shaped->objects[E->key()] = E->get(); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : parent->objects) { + if (E.value.pos >= p_shaped->start && E.value.pos < p_shaped->end) { + p_shaped->objects[E.key] = E.value; } } @@ -2192,9 +2192,9 @@ bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, Glyph gl = sd->glyphs[i]; Variant key; if (gl.count == 1) { - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if (E->get().pos == gl.start) { - key = E->key(); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if (E.value.pos == gl.start) { + key = E.key; break; } } @@ -2237,64 +2237,64 @@ bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, // Align embedded objects to baseline. real_t full_ascent = sd->ascent; real_t full_descent = sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if ((E->get().pos >= sd->start) && (E->get().pos < sd->end)) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if ((E.value.pos >= sd->start) && (E.value.pos < sd->end)) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -sd->ascent; + E.value.rect.position.y = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.y = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = sd->descent; + E.value.rect.position.y = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -sd->ascent; + E.value.rect.position.x = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.x = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = sd->descent; + E.value.rect.position.x = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } } @@ -2344,11 +2344,11 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng Variant key; bool find_embedded = false; if (gl.count == 1) { - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - if (E->get().pos == gl.start) { + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + if (E.value.pos == gl.start) { find_embedded = true; - key = E->key(); - new_sd->objects[key] = E->get(); + key = E.key; + new_sd->objects[key] = E.value; break; } } @@ -2389,64 +2389,64 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng // Align embedded objects to baseline. real_t full_ascent = new_sd->ascent; real_t full_descent = new_sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = new_sd->objects.front(); E; E = E->next()) { - if ((E->get().pos >= new_sd->start) && (E->get().pos < new_sd->end)) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : new_sd->objects) { + if ((E.value.pos >= new_sd->start) && (E.value.pos < new_sd->end)) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -new_sd->ascent; + E.value.rect.position.y = -new_sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-new_sd->ascent + new_sd->descent) / 2; + E.value.rect.position.y = (-new_sd->ascent + new_sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = new_sd->descent; + E.value.rect.position.y = new_sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -new_sd->ascent; + E.value.rect.position.x = -new_sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-new_sd->ascent + new_sd->descent) / 2; + E.value.rect.position.x = (-new_sd->ascent + new_sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = new_sd->descent; + E.value.rect.position.x = new_sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } } @@ -2907,63 +2907,63 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) { // Align embedded objects to baseline. real_t full_ascent = sd->ascent; real_t full_descent = sd->descent; - for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { + for (KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.y = -sd->ascent; + E.value.rect.position.y = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.y = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.y = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.y = 0; + E.value.rect.position.y = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.y = sd->descent; + E.value.rect.position.y = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.y -= E->get().rect.size.y; + E.value.rect.position.y -= E.value.rect.size.y; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.y -= E->get().rect.size.y / 2; + E.value.rect.position.y -= E.value.rect.size.y / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.y); - full_descent = MAX(full_descent, E->get().rect.position.y + E->get().rect.size.y); + full_ascent = MAX(full_ascent, -E.value.rect.position.y); + full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); } else { - switch (E->get().inline_align & INLINE_ALIGN_TEXT_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_TEXT_MASK) { case INLINE_ALIGN_TO_TOP: { - E->get().rect.position.x = -sd->ascent; + E.value.rect.position.x = -sd->ascent; } break; case INLINE_ALIGN_TO_CENTER: { - E->get().rect.position.x = (-sd->ascent + sd->descent) / 2; + E.value.rect.position.x = (-sd->ascent + sd->descent) / 2; } break; case INLINE_ALIGN_TO_BASELINE: { - E->get().rect.position.x = 0; + E.value.rect.position.x = 0; } break; case INLINE_ALIGN_TO_BOTTOM: { - E->get().rect.position.x = sd->descent; + E.value.rect.position.x = sd->descent; } break; } - switch (E->get().inline_align & INLINE_ALIGN_IMAGE_MASK) { + switch (E.value.inline_align & INLINE_ALIGN_IMAGE_MASK) { case INLINE_ALIGN_BOTTOM_TO: { - E->get().rect.position.x -= E->get().rect.size.x; + E.value.rect.position.x -= E.value.rect.size.x; } break; case INLINE_ALIGN_CENTER_TO: { - E->get().rect.position.x -= E->get().rect.size.x / 2; + E.value.rect.position.x -= E.value.rect.size.x / 2; } break; case INLINE_ALIGN_TOP_TO: { //NOP } break; } - full_ascent = MAX(full_ascent, -E->get().rect.position.x); - full_descent = MAX(full_descent, E->get().rect.position.x + E->get().rect.size.x); + full_ascent = MAX(full_ascent, -E.value.rect.position.x); + full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); } } sd->ascent = full_ascent; @@ -3017,8 +3017,8 @@ Array TextServerFallback::shaped_text_get_objects(RID p_shaped) const { ERR_FAIL_COND_V(!sd, ret); MutexLock lock(sd->mutex); - for (const Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = sd->objects.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue<Variant, ShapedTextData::EmbeddedObject> &E : sd->objects) { + ret.push_back(E.key); } return ret; diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 4d5f3420b8..54d310e636 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -702,8 +702,8 @@ void VisualScript::rename_custom_signal(const StringName &p_name, const StringNa } void VisualScript::get_custom_signal_list(List<StringName> *r_custom_signals) const { - for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) { - r_custom_signals->push_back(E->key()); + for (const KeyValue<StringName, Vector<Argument>> &E : custom_signals) { + r_custom_signals->push_back(E.key); } r_custom_signals->sort_custom<StringName::AlphCompare>(); @@ -848,13 +848,13 @@ bool VisualScript::has_script_signal(const StringName &p_signal) const { } void VisualScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, Vector<Argument>> &E : custom_signals) { MethodInfo mi; - mi.name = E->key(); - for (int i = 0; i < E->get().size(); i++) { + mi.name = E.key; + for (int i = 0; i < E.value.size(); i++) { PropertyInfo arg; - arg.type = E->get()[i].type; - arg.name = E->get()[i].name; + arg.type = E.value[i].type; + arg.name = E.value[i].name; mi.arguments.push_back(arg); } @@ -1056,13 +1056,13 @@ Dictionary VisualScript::_get_data() const { d["variables"] = vars; Array sigs; - for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, Vector<Argument>> &E : custom_signals) { Dictionary cs; - cs["name"] = E->key(); + cs["name"] = E.key; Array args; - for (int i = 0; i < E->get().size(); i++) { - args.push_back(E->get()[i].name); - args.push_back(E->get()[i].type); + for (int i = 0; i < E.value.size(); i++) { + args.push_back(E.value[i].name); + args.push_back(E.value[i].type); } cs["arguments"] = args; @@ -2093,8 +2093,8 @@ VisualScriptInstance::~VisualScriptInstance() { script->instances.erase(owner); } - for (Map<int, VisualScriptNodeInstance *>::Element *E = instances.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<int, VisualScriptNodeInstance *> &E : instances) { + memdelete(E.value); } } @@ -2516,8 +2516,8 @@ Ref<VisualScriptNode> VisualScriptLanguage::create_node_from_name(const String & } void VisualScriptLanguage::get_registered_node_names(List<String> *r_names) { - for (Map<String, VisualScriptNodeRegisterFunc>::Element *E = register_funcs.front(); E; E = E->next()) { - r_names->push_back(E->key()); + for (const KeyValue<String, VisualScriptNodeRegisterFunc> &E : register_funcs) { + r_names->push_back(E.key); } } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 0a6bcedf31..8cb701ea20 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -3632,17 +3632,17 @@ void VisualScriptEditor::_notification(int p_what) { node_colors["constants"] = Color(0.94, 0.18, 0.49); } - for (Map<StringName, Color>::Element *E = node_colors.front(); E; E = E->next()) { + for (const KeyValue<StringName, Color> &E : node_colors) { const Ref<StyleBoxFlat> sb = tm->get_stylebox(SNAME("frame"), SNAME("GraphNode")); if (!sb.is_null()) { Ref<StyleBoxFlat> frame_style = sb->duplicate(); // Adjust the border color to be close to the GraphNode's background color. // This keeps the node's title area from being too distracting. - Color color = dark_theme ? E->get().darkened(0.75) : E->get().lightened(0.75); + Color color = dark_theme ? E.value.darkened(0.75) : E.value.lightened(0.75); color.a = 0.9; frame_style->set_border_color(color); - node_styles[E->key()] = frame_style; + node_styles[E.key] = frame_style; } } @@ -3813,15 +3813,15 @@ void VisualScriptEditor::_menu_option(int p_what) { } } - for (Map<int, Ref<VisualScriptNode>>::Element *E = clipboard->nodes.front(); E; E = E->next()) { - Ref<VisualScriptNode> node = E->get()->duplicate(); + for (KeyValue<int, Ref<VisualScriptNode>> &E : clipboard->nodes) { + Ref<VisualScriptNode> node = E.value->duplicate(); int new_id = idc++; to_select.insert(new_id); - remap[E->key()] = new_id; + remap[E.key] = new_id; - Vector2 paste_pos = clipboard->nodes_positions[E->key()]; + Vector2 paste_pos = clipboard->nodes_positions[E.key]; while (existing_positions.has(paste_pos.snapped(Vector2(2, 2)))) { paste_pos += Vector2(20, 20) * EDSCALE; @@ -3906,16 +3906,16 @@ void VisualScriptEditor::_menu_option(int p_what) { // the user wants to connect the nodes. int top_nd = -1; Vector2 top; - for (Map<int, Ref<VisualScriptNode>>::Element *E = nodes.front(); E; E = E->next()) { - Ref<VisualScriptNode> nd = script->get_node(E->key()); + for (const KeyValue<int, Ref<VisualScriptNode>> &E : nodes) { + Ref<VisualScriptNode> nd = script->get_node(E.key); if (nd.is_valid() && nd->has_input_sequence_port()) { if (top_nd < 0) { - top_nd = E->key(); + top_nd = E.key; top = script->get_node_position(top_nd); } - Vector2 pos = script->get_node_position(E->key()); + Vector2 pos = script->get_node_position(E.key); if (top.y > pos.y) { - top_nd = E->key(); + top_nd = E.key; top = pos; } } diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index 48117f05f2..4e5174fc33 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -63,8 +63,8 @@ void WebRTCMultiplayerPeer::poll() { List<int> remove; List<int> add; - for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { - Ref<ConnectedPeer> peer = E->get(); + for (KeyValue<int, Ref<ConnectedPeer>> &E : peer_map) { + Ref<ConnectedPeer> peer = E.value; peer->connection->poll(); // Check peer state switch (peer->connection->get_connection_state()) { @@ -77,7 +77,7 @@ void WebRTCMultiplayerPeer::poll() { break; default: // Peer is closed or in error state. Got to next peer. - remove.push_back(E->key()); + remove.push_back(E.key); continue; } // Check channels state @@ -92,7 +92,7 @@ void WebRTCMultiplayerPeer::poll() { continue; default: // Channel was closed or in error state, remove peer id. - remove.push_back(E->key()); + remove.push_back(E.key); } // We got a closed channel break out, the peer will be removed. break; @@ -100,7 +100,7 @@ void WebRTCMultiplayerPeer::poll() { // This peer has newly connected, and all channels are now open. if (ready == peer->channels.size() && !peer->connected) { peer->connected = true; - add.push_back(E->key()); + add.push_back(E.key); } } // Remove disconnected peers @@ -125,9 +125,9 @@ void WebRTCMultiplayerPeer::poll() { emit_signal(SNAME("peer_connected"), TARGET_PEER_SERVER); emit_signal(SNAME("connection_succeeded")); // Notify of all previously connected peers - for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) { - if (F->key() != 1 && F->get()->connected) { - emit_signal(SNAME("peer_connected"), F->key()); + for (const KeyValue<int, Ref<ConnectedPeer>> &F : peer_map) { + if (F.key != 1 && F.value->connected) { + emit_signal(SNAME("peer_connected"), F.key); } } break; // Because we already notified of all newly added peers. @@ -244,10 +244,10 @@ Dictionary WebRTCMultiplayerPeer::get_peer(int p_peer_id) { Dictionary WebRTCMultiplayerPeer::get_peers() { Dictionary out; - for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { + for (const KeyValue<int, Ref<ConnectedPeer>> &E : peer_map) { Dictionary d; - _peer_to_dict(E->get(), d); - out[E->key()] = d; + _peer_to_dict(E.value, d); + out[E.key] = d; } return out; } @@ -358,15 +358,15 @@ Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_si } else { int exclude = -target_peer; - for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) { + for (KeyValue<int, Ref<ConnectedPeer>> &F : peer_map) { // Exclude packet. If target_peer == 0 then don't exclude any packets - if (target_peer != 0 && F->key() == exclude) { + if (target_peer != 0 && F.key == exclude) { continue; } - ERR_CONTINUE_MSG(F->value()->channels.size() <= ch, vformat("Unable to send packet on channel %d, max channels: %d", ch, E->value()->channels.size())); - ERR_CONTINUE(F->value()->channels[ch].is_null()); - F->value()->channels[ch]->put_packet(p_buffer, p_buffer_size); + ERR_CONTINUE_MSG(F.value->channels.size() <= ch, vformat("Unable to send packet on channel %d, max channels: %d", ch, E->value()->channels.size())); + ERR_CONTINUE(F.value->channels[ch].is_null()); + F.value->channels[ch]->put_packet(p_buffer, p_buffer_size); } } return OK; @@ -377,8 +377,8 @@ int WebRTCMultiplayerPeer::get_available_packet_count() const { return 0; // To be sure next call to get_packet works if size > 0 . } int size = 0; - for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { - for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + for (const KeyValue<int, Ref<ConnectedPeer>> &E : peer_map) { + for (const Ref<WebRTCDataChannel> &F : E.value->channels) { size += F->get_available_packet_count(); } } diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 3a27855a5e..e54bfbca12 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -148,8 +148,8 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { // Then send the server peer (which will trigger connection_succeded in client) _send_sys(get_peer(p_peer_id), SYS_ADD, 1); - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - int32_t id = E->key(); + for (const KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + int32_t id = E.key; if (p_peer_id == id) { continue; // Skip the newly added peer (already confirmed) } @@ -162,8 +162,8 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { } void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) { - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - int32_t id = E->key(); + for (const KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + int32_t id = E.key; if (p_peer_id != id) { _send_sys(get_peer(id), SYS_DEL, p_peer_id); } @@ -186,17 +186,17 @@ Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, cons return OK; // Will not send to self } else if (p_to == 0) { - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - if (E->key() != p_from) { - E->get()->put_packet(p_buffer, p_buffer_size); + for (KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + if (E.key != p_from) { + E.value->put_packet(p_buffer, p_buffer_size); } } return OK; // Sent to all but sender } else if (p_to < 0) { - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - if (E->key() != p_from && E->key() != -p_to) { - E->get()->put_packet(p_buffer, p_buffer_size); + for (KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + if (E.key != p_from && E.key != -p_to) { + E.value->put_packet(p_buffer, p_buffer_size); } } return OK; // Sent to all but sender and excluded diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 7402bbb46e..514b2d055f 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -182,12 +182,12 @@ Error WSLServer::listen(int p_port, const Vector<String> p_protocols, bool gd_mp void WSLServer::poll() { List<int> remove_ids; - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - Ref<WSLPeer> peer = (WSLPeer *)E->get().ptr(); + for (const KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + Ref<WSLPeer> peer = (WSLPeer *)E.value.ptr(); peer->poll(); if (!peer->is_connected_to_host()) { - _on_disconnect(E->key(), peer->close_code != -1); - remove_ids.push_back(E->key()); + _on_disconnect(E.key, peer->close_code != -1); + remove_ids.push_back(E.key); } } for (int &E : remove_ids) { @@ -265,8 +265,8 @@ int WSLServer::get_max_packet_size() const { void WSLServer::stop() { _server->stop(); - for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - Ref<WSLPeer> peer = (WSLPeer *)E->get().ptr(); + for (const KeyValue<int, Ref<WebSocketPeer>> &E : _peer_map) { + Ref<WSLPeer> peer = (WSLPeer *)E.value.ptr(); peer->close_now(); } _pending.clear(); |