summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/engine.cpp2
-rw-r--r--core/config/project_settings.cpp4
-rw-r--r--core/core_bind.cpp34
-rw-r--r--core/core_bind.h6
-rw-r--r--core/debugger/debugger_marshalls.cpp2
-rw-r--r--core/debugger/remote_debugger.cpp2
-rw-r--r--core/extension/extension_api_dump.cpp34
-rw-r--r--core/extension/gdnative_interface.cpp3
-rw-r--r--core/extension/gdnative_interface.h2
-rw-r--r--core/extension/native_extension.cpp2
-rw-r--r--core/input/input.cpp2
-rw-r--r--core/input/input_map.cpp4
-rw-r--r--core/io/dir_access.cpp6
-rw-r--r--core/io/image_loader.cpp2
-rw-r--r--core/io/ip.cpp2
-rw-r--r--core/io/json.cpp7
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/io/multiplayer_api.cpp2
-rw-r--r--core/io/packed_data_container.cpp4
-rw-r--r--core/io/resource.cpp10
-rw-r--r--core/io/resource_format_binary.cpp23
-rw-r--r--core/io/resource_importer.cpp8
-rw-r--r--core/io/resource_loader.cpp6
-rw-r--r--core/io/resource_loader.h8
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/io/resource_uid.cpp2
-rw-r--r--core/math/face3.h4
-rw-r--r--core/math/geometry_3d.h2
-rw-r--r--core/math/quick_hull.cpp4
-rw-r--r--core/object/class_db.cpp30
-rw-r--r--core/object/object.cpp14
-rw-r--r--core/object/script_language.cpp12
-rw-r--r--core/os/main_loop.cpp4
-rw-r--r--core/os/main_loop.h4
-rw-r--r--core/os/pool_allocator.h2
-rw-r--r--core/register_core_types.cpp2
-rw-r--r--core/string/optimized_translation.cpp2
-rw-r--r--core/string/translation.cpp2
-rw-r--r--core/string/translation_po.cpp12
-rw-r--r--core/string/ustring.cpp2
-rw-r--r--core/templates/command_queue_mt.h2
-rw-r--r--core/templates/rid_owner.h2
-rw-r--r--core/templates/set.h7
-rw-r--r--core/variant/binder_common.h6
-rw-r--r--core/variant/callable.cpp2
-rw-r--r--core/variant/method_ptrcall.h2
-rw-r--r--core/variant/variant.cpp2
-rw-r--r--core/variant/variant.h2
-rw-r--r--core/variant/variant_call.cpp4
-rw-r--r--core/variant/variant_parser.cpp2
-rw-r--r--core/variant/variant_setget.cpp4
-rw-r--r--core/variant/variant_utility.cpp2
52 files changed, 164 insertions, 156 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index c03c872f17..0b5b5627af 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -214,7 +214,7 @@ bool Engine::has_singleton(const String &p_name) const {
}
void Engine::get_singletons(List<Singleton> *p_singletons) {
- for (Singleton &E : singletons) {
+ for (const Singleton &E : singletons) {
p_singletons->push_back(E);
}
}
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 22acb23bce..c5e6c6d685 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -800,7 +800,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
if (E->key() != "") {
file->store_string("[" + E->key() + "]\n\n");
}
- for (String &F : E->get()) {
+ for (const String &F : E->get()) {
String key = F;
if (E->key() != "") {
key = E->key() + "/" + key;
@@ -928,7 +928,7 @@ Vector<String> ProjectSettings::get_optimizer_presets() const {
ProjectSettings::get_singleton()->get_property_list(&pi);
Vector<String> names;
- for (PropertyInfo &E : pi) {
+ for (const PropertyInfo &E : pi) {
if (!E.name.begins_with("optimizer_presets/")) {
continue;
}
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 7a1ba63233..9e96d4b079 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -75,7 +75,7 @@ Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type(p_type, &exts);
Vector<String> ret;
- for (String &E : exts) {
+ for (const String &E : exts) {
ret.push_back(E);
}
@@ -91,7 +91,7 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
ResourceLoader::get_dependencies(p_path, &deps);
PackedStringArray ret;
- for (String &E : deps) {
+ for (const String &E : deps) {
ret.push_back(E);
}
@@ -141,7 +141,7 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource)
List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts);
Vector<String> ret;
- for (String &E : exts) {
+ for (const String &E : exts) {
ret.push_back(E);
}
return ret;
@@ -268,7 +268,7 @@ String _OS::get_name() const {
Vector<String> _OS::get_cmdline_args() {
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
Vector<String> cmdlinev;
- for (String &E : cmdline) {
+ for (const String &E : cmdline) {
cmdlinev.push_back(E);
}
@@ -355,20 +355,20 @@ void _OS::print_all_textures_by_size() {
List<Ref<Resource>> rsrc;
ResourceCache::get_cached_resources(&rsrc);
- for (Ref<Resource> E : rsrc) {
- if (!E->is_class("ImageTexture")) {
+ for (Ref<Resource> &res : rsrc) {
+ if (!res->is_class("ImageTexture")) {
continue;
}
- Size2 size = E->call("get_size");
- int fmt = E->call("get_format");
+ Size2 size = res->call("get_size");
+ int fmt = res->call("get_format");
_OSCoreBindImg img;
img.size = size;
img.fmt = fmt;
- img.path = E->get_path();
+ img.path = res->get_path();
img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt));
- img.id = E->get_instance_id();
+ img.id = res->get_instance_id();
total += img.vram;
imgs.push_back(img);
}
@@ -387,7 +387,7 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
List<Ref<Resource>> resources;
ResourceCache::get_cached_resources(&resources);
- for (Ref<Resource> r : resources) {
+ for (const Ref<Resource> &r : resources) {
bool found = false;
for (int i = 0; i < p_types.size(); i++) {
@@ -1822,7 +1822,7 @@ PackedStringArray _ClassDB::get_class_list() const {
PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
ret.set(idx++, E);
}
@@ -1836,7 +1836,7 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class)
PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
ret.set(idx++, E);
}
@@ -1891,7 +1891,7 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const
ClassDB::get_signal_list(p_class, &signals, p_no_inheritance);
Array ret;
- for (MethodInfo &E : signals) {
+ for (const MethodInfo &E : signals) {
ret.push_back(E.operator Dictionary());
}
@@ -1902,7 +1902,7 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con
List<PropertyInfo> plist;
ClassDB::get_property_list(p_class, &plist, p_no_inheritance);
Array ret;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
ret.push_back(E.operator Dictionary());
}
@@ -1935,7 +1935,7 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
ClassDB::get_method_list(p_class, &methods, p_no_inheritance);
Array ret;
- for (MethodInfo &E : methods) {
+ for (const MethodInfo &E : methods) {
#ifdef DEBUG_METHODS_ENABLED
ret.push_back(E.operator Dictionary());
#else
@@ -1955,7 +1955,7 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class,
PackedStringArray ret;
ret.resize(constants.size());
int idx = 0;
- for (String &E : constants) {
+ for (const String &E : constants) {
ret.set(idx++, E);
}
diff --git a/core/core_bind.h b/core/core_bind.h
index 43f74dc9bd..1574c36d3c 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -58,9 +58,9 @@ public:
};
enum CacheMode {
- CACHE_MODE_IGNORE, //resource and subresources do not use path cache, no path is set into resource.
- CACHE_MODE_REUSE, //resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available
- CACHE_MODE_REPLACE, //resource and and subresource use path cache, but replace existing loaded resources when available with information from disk
+ CACHE_MODE_IGNORE, // Resource and subresources do not use path cache, no path is set into resource.
+ CACHE_MODE_REUSE, // Resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available.
+ CACHE_MODE_REPLACE, // Resource and subresource use path cache, but replace existing loaded resources when available with information from disk.
};
static _ResourceLoader *get_singleton() { return singleton; }
diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp
index b832dd58d5..2353a6ebf8 100644
--- a/core/debugger/debugger_marshalls.cpp
+++ b/core/debugger/debugger_marshalls.cpp
@@ -40,7 +40,7 @@ Array DebuggerMarshalls::ResourceUsage::serialize() {
Array arr;
arr.push_back(infos.size() * 4);
- for (ResourceInfo &E : infos) {
+ for (const ResourceInfo &E : infos) {
arr.push_back(E.path);
arr.push_back(E.format);
arr.push_back(E.type);
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index 7d3abc9b46..0add12ff3d 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -427,7 +427,7 @@ void RemoteDebugger::_send_resource_usage() {
List<RS::TextureInfo> tinfo;
RS::get_singleton()->texture_debug_usage(&tinfo);
- for (RS::TextureInfo &E : tinfo) {
+ for (const RS::TextureInfo &E : tinfo) {
DebuggerMarshalls::ResourceInfo info;
info.path = E.path;
info.vram = E.bytes;
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index cc2974cbdb..660e215478 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -94,8 +94,8 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
{ Variant::NODE_PATH, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
{ Variant::RID, sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t) },
{ Variant::OBJECT, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
- { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, //harcoded align
- { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, //harcoded align
+ { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, // Hardcoded align.
+ { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, // Hardcoded align.
{ Variant::DICTIONARY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
{ Variant::ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
{ Variant::PACKED_BYTE_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
@@ -146,7 +146,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
}
{
- //member offsets sizes
+ // Member offsets sizes.
struct {
Variant::Type type;
const char *member;
@@ -180,7 +180,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
{ Variant::QUATERNION, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(double), 3 * sizeof(double) },
{ Variant::AABB, "position", 0, 0, 0, 0 },
{ Variant::AABB, "size", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
- //rememer that basis vectors are flipped!
+ // Remember that basis vectors are flipped!
{ Variant::BASIS, "x", 0, 0, 0, 0 },
{ Variant::BASIS, "y", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
{ Variant::BASIS, "z", vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(double), vec3_elems * 2 * sizeof(double) },
@@ -251,7 +251,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
}
{
- // global enums and constants
+ // Global enums and constants.
Array constants;
Map<String, List<Pair<String, int>>> enum_list;
@@ -276,7 +276,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Dictionary d1;
d1["name"] = E->key();
Array values;
- for (Pair<String, int> &F : E->get()) {
+ for (const Pair<String, int> &F : E->get()) {
Dictionary d2;
d2["name"] = F.first;
d2["value"] = F.second;
@@ -294,7 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> utility_func_names;
Variant::get_utility_function_list(&utility_func_names);
- for (StringName &name : utility_func_names) {
+ for (const StringName &name : utility_func_names) {
Dictionary func;
func["name"] = String(name);
if (Variant::has_utility_function_return_value(name)) {
@@ -362,7 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> member_names;
Variant::get_member_list(type, &member_names);
- for (StringName &member_name : member_names) {
+ for (const StringName &member_name : member_names) {
Dictionary d2;
d2["name"] = String(member_name);
d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name));
@@ -378,7 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> constant_names;
Variant::get_constants_for_type(type, &constant_names);
- for (StringName &constant_name : constant_names) {
+ for (const StringName &constant_name : constant_names) {
Dictionary d2;
d2["name"] = String(constant_name);
Variant constant = Variant::get_constant_value(type, constant_name);
@@ -417,7 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<StringName> method_names;
Variant::get_builtin_method_list(type, &method_names);
- for (StringName &method_name : method_names) {
+ for (const StringName &method_name : method_names) {
Dictionary d2;
d2["name"] = String(method_name);
if (Variant::has_builtin_method_return_value(type, method_name)) {
@@ -499,7 +499,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
class_list.sort_custom<StringName::AlphCompare>();
- for (StringName &class_name : class_list) {
+ for (const StringName &class_name : class_list) {
Dictionary d;
d["name"] = String(class_name);
d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted");
@@ -520,7 +520,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array constants;
List<String> constant_list;
ClassDB::get_integer_constant_list(class_name, &constant_list, true);
- for (String &F : constant_list) {
+ for (const String &F : constant_list) {
StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F);
if (enum_name != StringName()) {
continue; //enums will be handled on their own
@@ -542,7 +542,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array enums;
List<StringName> enum_list;
ClassDB::get_enum_list(class_name, &enum_list, true);
- for (StringName &F : enum_list) {
+ for (const StringName &F : enum_list) {
Dictionary d2;
d2["name"] = String(F);
@@ -570,7 +570,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array methods;
List<MethodInfo> method_list;
ClassDB::get_method_list(class_name, &method_list, true);
- for (MethodInfo &F : method_list) {
+ for (const MethodInfo &F : method_list) {
StringName method_name = F.name;
if (F.flags & METHOD_FLAG_VIRTUAL) {
//virtual method
@@ -687,7 +687,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array signals;
List<MethodInfo> signal_list;
ClassDB::get_signal_list(class_name, &signal_list, true);
- for (MethodInfo &F : signal_list) {
+ for (const MethodInfo &F : signal_list) {
StringName signal_name = F.name;
Dictionary d2;
d2["name"] = String(signal_name);
@@ -723,7 +723,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Array properties;
List<PropertyInfo> property_list;
ClassDB::get_property_list(class_name, &property_list, true);
- for (PropertyInfo &F : property_list) {
+ for (const PropertyInfo &F : property_list) {
if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) {
continue; //not real properties
}
@@ -766,7 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
List<Engine::Singleton> singleton_list;
Engine::get_singleton()->get_singletons(&singleton_list);
- for (Engine::Singleton &s : singleton_list) {
+ for (const Engine::Singleton &s : singleton_list) {
Dictionary d;
d["name"] = s.name;
if (s.class_name != StringName()) {
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp
index 8f68b8d848..88fff342ee 100644
--- a/core/extension/gdnative_interface.cpp
+++ b/core/extension/gdnative_interface.cpp
@@ -281,8 +281,9 @@ static GDNativeBool gdnative_variant_has_key(const GDNativeVariantPtr p_self, co
const Variant *self = (const Variant *)p_self;
const Variant *key = (const Variant *)p_key;
bool valid;
- return self->has_key(*key, valid);
+ bool ret = self->has_key(*key, valid);
*r_valid = valid;
+ return ret;
}
static void gdnative_variant_get_type_name(GDNativeVariantType p_type, GDNativeStringPtr r_ret) {
diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h
index c1ebb3e76a..3e69a28d59 100644
--- a/core/extension/gdnative_interface.h
+++ b/core/extension/gdnative_interface.h
@@ -134,7 +134,7 @@ typedef void *GDNativeObjectPtr;
typedef void *GDNativeTypePtr;
typedef void *GDNativeMethodBindPtr;
typedef int64_t GDNativeInt;
-typedef uint32_t GDNativeBool;
+typedef uint8_t GDNativeBool;
typedef uint64_t GDObjectInstanceID;
/* VARIANT DATA I/O */
diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp
index 5f91e61102..16bc28e0a2 100644
--- a/core/extension/native_extension.cpp
+++ b/core/extension/native_extension.cpp
@@ -351,7 +351,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or
String library_path;
- for (String &E : libraries) {
+ for (const String &E : libraries) {
Vector<String> tags = E.split(".");
bool all_tags_met = true;
for (int i = 0; i < tags.size(); i++) {
diff --git a/core/input/input.cpp b/core/input/input.cpp
index e30e7c814f..c205726b0a 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -174,7 +174,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
- for (PropertyInfo &pi : pinfo) {
+ for (const PropertyInfo &pi : pinfo) {
if (!pi.name.begins_with("input/")) {
continue;
}
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 0c8705b263..6714705bb5 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -65,7 +65,7 @@ String InputMap::_suggest_actions(const StringName &p_action) const {
float closest_similarity = 0.0;
// Find the most action with the most similar name.
- for (StringName &action : actions) {
+ for (const StringName &action : actions) {
const float similarity = String(action).similarity(p_action);
if (similarity > closest_similarity) {
@@ -261,7 +261,7 @@ void InputMap::load_from_project_settings() {
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
- for (PropertyInfo &pi : pinfo) {
+ for (const PropertyInfo &pi : pinfo) {
if (!pi.name.begins_with("input/")) {
continue;
}
diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp
index e30a8dfdd0..8234adea06 100644
--- a/core/io/dir_access.cpp
+++ b/core/io/dir_access.cpp
@@ -93,7 +93,7 @@ static Error _erase_recursive(DirAccess *da) {
da->list_dir_end();
- for (String &E : dirs) {
+ for (const String &E : dirs) {
Error err = da->change_dir(E);
if (err == OK) {
err = _erase_recursive(da);
@@ -114,7 +114,7 @@ static Error _erase_recursive(DirAccess *da) {
}
}
- for (String &E : files) {
+ for (const String &E : files) {
Error err = da->remove(da->get_current_dir().plus_file(E));
if (err) {
return err;
@@ -362,7 +362,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
list_dir_end();
- for (String &rel_path : dirs) {
+ for (const String &rel_path : dirs) {
String target_dir = p_to + rel_path;
if (!p_target_da->dir_exists(target_dir)) {
Error err = p_target_da->make_dir(target_dir);
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index b0bd328d21..b9fc416f65 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -35,7 +35,7 @@
bool ImageFormatLoader::recognize(const String &p_extension) const {
List<String> extensions;
get_recognized_extensions(&extensions);
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(p_extension) == 0) {
return true;
}
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 132c69b7da..cd1b6d1994 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -252,7 +252,7 @@ Array IP::_get_local_addresses() const {
Array addresses;
List<IPAddress> ip_addresses;
get_local_addresses(&ip_addresses);
- for (IPAddress &E : ip_addresses) {
+ for (const IPAddress &E : ip_addresses) {
addresses.push_back(E);
}
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 77a6181931..5823afbdcd 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -121,8 +121,11 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_
keys.sort();
}
- for (Variant &E : keys) {
- if (E != keys.front()) {
+ bool first_key = true;
+ for (const Variant &E : keys) {
+ if (first_key) {
+ first_key = false;
+ } else {
s += ",";
s += end_statement;
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 34d37dc99b..4a1d3e5212 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1358,7 +1358,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
obj->get_property_list(&props);
int pc = 0;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -1372,7 +1372,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -1418,7 +1418,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
/*
CharString utf8 = E->->utf8();
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index ee49335f55..80610e12cb 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -917,7 +917,7 @@ void MultiplayerAPI::_del_peer(int p_id) {
// Some refactoring is needed to make this faster and do paths GC.
List<NodePath> keys;
path_send_cache.get_key_list(&keys);
- for (NodePath &E : keys) {
+ for (const NodePath &E : keys) {
PathSentCache *psc = path_send_cache.getptr(E);
psc->confirmed_peers.erase(p_id);
}
diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp
index ec43ea9311..4a76f0191d 100644
--- a/core/io/packed_data_container.cpp
+++ b/core/io/packed_data_container.cpp
@@ -268,7 +268,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
d.get_key_list(&keys);
List<DictKey> sortk;
- for (Variant &key : keys) {
+ for (const Variant &key : keys) {
DictKey dk;
dk.hash = key.hash();
dk.key = key;
@@ -278,7 +278,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
sortk.sort();
int idx = 0;
- for (DictKey &E : sortk) {
+ for (const DictKey &E : sortk) {
encode_uint32(E.hash, &tmpdata.write[pos + 8 + idx * 12 + 0]);
uint32_t ofs = _pack(E.key, tmpdata, string_cache);
encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]);
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 695988bd71..727611a573 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -165,7 +165,7 @@ Error Resource::copy_from(const Ref<Resource> &p_resource) {
List<PropertyInfo> pi;
p_resource->get_property_list(&pi);
- for (PropertyInfo &E : pi) {
+ for (const PropertyInfo &E : pi) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -201,7 +201,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
r->local_scene = p_for_scene;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -233,7 +233,7 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R
local_scene = p_for_scene;
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -259,7 +259,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class());
ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -317,7 +317,7 @@ uint32_t Resource::hash_edited_version() const {
List<PropertyInfo> plist;
get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) {
RES res = get(E.name);
if (res.is_valid()) {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 81ba5cc68d..a3ebc32cc5 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -935,7 +935,7 @@ void ResourceLoaderBinary::open(FileAccess *p_f, bool p_no_resources, bool p_kee
// If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path.
er.path = ResourceUID::get_singleton()->get_id_path(er.uid);
} else {
- WARN_PRINT(String(res_path + ": In external resouce #" + itos(i) + ", invalid UUID: " + ResourceUID::get_singleton()->id_to_text(er.uid) + " - using text path instead: " + er.path).utf8().get_data());
+ WARN_PRINT(String(res_path + ": In external resource #" + itos(i) + ", invalid UUID: " + ResourceUID::get_singleton()->id_to_text(er.uid) + " - using text path instead: " + er.path).utf8().get_data());
}
}
}
@@ -1054,7 +1054,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String
extensions.sort();
- for (String &E : extensions) {
+ for (const String &E : extensions) {
String ext = E.to_lower();
p_extensions->push_back(ext);
}
@@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten
ClassDB::get_resource_base_extensions(&extensions);
extensions.sort();
- for (String &E : extensions) {
+ for (const String &E : extensions) {
String ext = E.to_lower();
p_extensions->push_back(ext);
}
@@ -1603,7 +1603,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
/*
if (!_check_type(dict[E]))
continue;
@@ -1760,7 +1760,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
res->get_property_list(&property_list);
- for (PropertyInfo &E : property_list) {
+ for (const PropertyInfo &E : property_list) {
if (E.usage & PROPERTY_USAGE_STORAGE) {
Variant value = res->get(E.name);
if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
@@ -1798,7 +1798,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
Dictionary d = p_variant;
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_find_resources(E);
Variant v = d[E];
_find_resources(v);
@@ -1909,14 +1909,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
List<ResourceData> resources;
{
- for (RES &E : saved_resources) {
+ for (const RES &E : saved_resources) {
ResourceData &rd = resources.push_back(ResourceData())->get();
rd.type = E->get_class();
List<PropertyInfo> property_list;
E->get_property_list(&property_list);
- for (PropertyInfo &F : property_list) {
+ for (const PropertyInfo &F : property_list) {
if (skip_editor && F.name.begins_with("__editor")) {
continue;
}
@@ -2024,15 +2024,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Vector<uint64_t> ofs_table;
//now actually save the resources
- for (ResourceData &rd : resources) {
+ for (const ResourceData &rd : resources) {
ofs_table.push_back(f->get_position());
save_unicode_string(f, rd.type);
f->store_32(rd.properties.size());
- for (Property &F : rd.properties) {
- Property &p = F;
+ for (const Property &p : rd.properties) {
f->store_32(p.name_idx);
- write_variant(f, p.value, resource_map, external_resources, string_map, F.pi);
+ write_variant(f, p.value, resource_map, external_resources, string_map, p.pi);
}
}
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index e7c0176e5a..1e166015b0 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -148,7 +148,7 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (!found.has(F)) {
p_extensions->push_back(F);
found.insert(F);
@@ -177,7 +177,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (!found.has(F)) {
p_extensions->push_back(F);
found.insert(F);
@@ -385,7 +385,7 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (p_extension.to_lower() == F) {
r_importers->push_back(importers[i]);
}
@@ -406,7 +406,7 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
- for (String &F : local_exts) {
+ for (const String &F : local_exts) {
if (p_extension.to_lower() == F && importers[i]->get_priority() > priority) {
importer = importers[i];
priority = importers[i]->get_priority();
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 7e69b2ecab..d02d827443 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -58,7 +58,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
get_recognized_extensions_for_type(p_for_type, &extensions);
}
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(extension) == 0) {
return true;
}
@@ -937,7 +937,7 @@ void ResourceLoader::load_translation_remaps() {
Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
Array langs = remaps[E];
Vector<String> lang_remaps;
lang_remaps.resize(langs.size());
@@ -1030,7 +1030,7 @@ void ResourceLoader::add_custom_loaders() {
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
- for (StringName &class_name : global_classes) {
+ for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
if (base_class == custom_loader_base_class) {
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index b9e234fdd2..e525e80a9d 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -40,9 +40,9 @@ class ResourceFormatLoader : public RefCounted {
public:
enum CacheMode {
- CACHE_MODE_IGNORE, //resource and subresources do not use path cache, no path is set into resource.
- CACHE_MODE_REUSE, //resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available
- CACHE_MODE_REPLACE, //resource and and subresource use path cache, but replace existing loaded resources when available with information from disk
+ CACHE_MODE_IGNORE, // Resource and subresources do not use path cache, no path is set into resource.
+ CACHE_MODE_REUSE, // Resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available.
+ CACHE_MODE_REPLACE, // Resource and subresource use path cache, but replace existing loaded resources when available with information from disk.
};
protected:
@@ -108,7 +108,7 @@ private:
friend class ResourceFormatImporter;
friend class ResourceInteractiveLoader;
- //internal load function
+ // Internal load function.
static RES _load(const String &p_path, const String &p_original_path, const String &p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error *r_error, bool p_use_sub_threads, float *r_progress);
static ResourceLoadedCallback _loaded_callback;
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 6158f421d1..564de5ee69 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -95,7 +95,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
bool recognized = false;
saver[i]->get_recognized_extensions(p_resource, &extensions);
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (E.nocasecmp_to(extension) == 0) {
recognized = true;
}
@@ -237,7 +237,7 @@ void ResourceSaver::add_custom_savers() {
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
- for (StringName &class_name : global_classes) {
+ for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
if (base_class == custom_saver_base_class) {
diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp
index d4e8fcb6b0..97d683f415 100644
--- a/core/io/resource_uid.cpp
+++ b/core/io/resource_uid.cpp
@@ -249,7 +249,7 @@ void ResourceUID::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_id", "id", "path"), &ResourceUID::add_id);
ClassDB::bind_method(D_METHOD("set_id", "id", "path"), &ResourceUID::set_id);
ClassDB::bind_method(D_METHOD("get_id_path", "id"), &ResourceUID::get_id_path);
- ClassDB::bind_method(D_METHOD("remove_id", "id", "path"), &ResourceUID::remove_id);
+ ClassDB::bind_method(D_METHOD("remove_id", "id"), &ResourceUID::remove_id);
BIND_CONSTANT(INVALID_ID)
}
diff --git a/core/math/face3.h b/core/math/face3.h
index 5091b338ef..9e9026e54e 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -50,8 +50,8 @@ public:
/**
*
* @param p_plane plane used to split the face
- * @param p_res array of at least 3 faces, amount used in functio return
- * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in functio return
+ * @param p_res array of at least 3 faces, amount used in function return
+ * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in function return
* @param _epsilon constant used for numerical error rounding, to add "thickness" to the plane (so coplanar points can happen)
* @return amount of faces generated by the split, either 0 (means no split possible), 2 or 3
*/
diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h
index 4ef9b4dbe6..766689e222 100644
--- a/core/math/geometry_3d.h
+++ b/core/math/geometry_3d.h
@@ -40,7 +40,7 @@ class Geometry3D {
public:
static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) {
-// Do the function 'd' as defined by pb. I think is is dot product of some sort.
+// Do the function 'd' as defined by pb. I think it's a dot product of some sort.
#define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
// Calculate the parametric position on the 2 curves, mua and mub.
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 9b506269ea..0960fe19a6 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -336,7 +336,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
Map<Edge, RetFaceConnect> ret_edges;
List<Geometry3D::MeshData::Face> ret_faces;
- for (Face &E : faces) {
+ for (const Face &E : faces) {
Geometry3D::MeshData::Face f;
f.plane = E.plane;
@@ -439,7 +439,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
r_mesh.faces.resize(ret_faces.size());
int idx = 0;
- for (Geometry3D::MeshData::Face &E : ret_faces) {
+ for (const Geometry3D::MeshData::Face &E : ret_faces) {
r_mesh.faces.write[idx++] = E;
}
r_mesh.edges.resize(ret_edges.size());
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 57495a4fbd..c6ba39be94 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -359,7 +359,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
//must be alphabetically sorted for hash to compute
names.sort_custom<StringName::AlphCompare>();
- for (StringName &E : names) {
+ for (const StringName &E : names) {
ClassInfo *t = classes.getptr(E);
ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E) + "'.");
if (t->api != p_api || !t->exposed) {
@@ -388,7 +388,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
MethodBind *mb = t->method_map[F];
hash = hash_djb2_one_64(mb->get_name().hash(), hash);
hash = hash_djb2_one_64(mb->get_argument_count(), hash);
@@ -426,7 +426,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
hash = hash_djb2_one_64(F.hash(), hash);
hash = hash_djb2_one_64(t->constant_map[F], hash);
}
@@ -444,7 +444,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
MethodInfo &mi = t->signal_map[F];
hash = hash_djb2_one_64(F.hash(), hash);
for (int i = 0; i < mi.arguments.size(); i++) {
@@ -465,7 +465,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
- for (StringName &F : snames) {
+ for (const StringName &F : snames) {
PropertySetGet *psg = t->property_setget.getptr(F);
ERR_FAIL_COND_V(!psg, 0);
@@ -476,7 +476,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
//property list
- for (PropertyInfo &F : t->property_list) {
+ for (const PropertyInfo &F : t->property_list) {
hash = hash_djb2_one_64(F.name.hash(), hash);
hash = hash_djb2_one_64(F.type, hash);
hash = hash_djb2_one_64(F.hint, hash);
@@ -619,11 +619,11 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met
#ifdef DEBUG_METHODS_ENABLED
- for (MethodInfo &E : type->virtual_methods) {
+ for (const MethodInfo &E : type->virtual_methods) {
p_methods->push_back(E);
}
- for (StringName &E : type->method_order) {
+ for (const StringName &E : type->method_order) {
if (p_exclude_from_properties && type->methods_in_properties.has(E)) {
continue;
}
@@ -763,7 +763,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
while (type) {
#ifdef DEBUG_METHODS_ENABLED
- for (StringName &E : type->constant_order) {
+ for (const StringName &E : type->constant_order) {
p_constants->push_back(E);
}
#else
@@ -1073,10 +1073,12 @@ void ClassDB::get_property_list(const StringName &p_class, List<PropertyInfo> *p
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- for (PropertyInfo pi : check->property_list) {
+ for (const PropertyInfo &pi : check->property_list) {
if (p_validator) {
- p_validator->_validate_property(pi);
- p_list->push_back(pi);
+ // Making a copy as we may modify it.
+ PropertyInfo pi_mut = pi;
+ p_validator->_validate_property(pi_mut);
+ p_list->push_back(pi_mut);
} else {
p_list->push_back(pi);
}
@@ -1428,7 +1430,7 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- for (MethodInfo &E : check->virtual_methods) {
+ for (const MethodInfo &E : check->virtual_methods) {
p_methods->push_back(E);
}
@@ -1533,7 +1535,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
if (c) {
List<PropertyInfo> plist;
c->get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
if (!default_values[p_class].has(E.name)) {
Variant v = c->get(E.name);
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 0e397d8518..d552d5e5e0 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -969,7 +969,7 @@ Vector<StringName> Object::_get_meta_list_bind() const {
List<Variant> keys;
metadata.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_metaret.push_back(E);
}
@@ -979,7 +979,7 @@ Vector<StringName> Object::_get_meta_list_bind() const {
void Object::get_meta_list(List<StringName> *p_list) const {
List<Variant> keys;
metadata.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
p_list->push_back(E);
}
}
@@ -1184,7 +1184,7 @@ Array Object::_get_signal_list() const {
get_signal_list(&signal_list);
Array ret;
- for (MethodInfo &E : signal_list) {
+ for (const MethodInfo &E : signal_list) {
ret.push_back(Dictionary(E));
}
@@ -1197,7 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
Array ret;
- for (Connection &c : conns) {
+ for (const Connection &c : conns) {
if (c.signal.get_name() == p_signal) {
ret.push_back(c);
}
@@ -1499,7 +1499,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_clear_internal_resource_paths(E);
_clear_internal_resource_paths(d[E]);
}
@@ -1530,7 +1530,7 @@ void Object::clear_internal_resource_paths() {
get_property_list(&pinfo);
- for (PropertyInfo &E : pinfo) {
+ for (const PropertyInfo &E : pinfo) {
_clear_internal_resource_paths(get(E.name));
}
}
@@ -1665,7 +1665,7 @@ void Object::get_translatable_strings(List<String> *p_strings) const {
List<PropertyInfo> plist;
get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) {
continue;
}
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 5aa032192e..0fb8c7350c 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -63,7 +63,7 @@ Array Script::_get_script_property_list() {
Array ret;
List<PropertyInfo> list;
get_script_property_list(&list);
- for (PropertyInfo &E : list) {
+ for (const PropertyInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -73,7 +73,7 @@ Array Script::_get_script_method_list() {
Array ret;
List<MethodInfo> list;
get_script_method_list(&list);
- for (MethodInfo &E : list) {
+ for (const MethodInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -83,7 +83,7 @@ Array Script::_get_script_signal_list() {
Array ret;
List<MethodInfo> list;
get_script_signal_list(&list);
- for (MethodInfo &E : list) {
+ for (const MethodInfo &E : list) {
ret.append(E.operator Dictionary());
}
return ret;
@@ -257,7 +257,7 @@ void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
classes.push_back(*K);
}
classes.sort_custom<StringName::AlphCompare>();
- for (StringName &E : classes) {
+ for (const StringName &E : classes) {
r_global_classes->push_back(E);
}
}
@@ -266,7 +266,7 @@ void ScriptServer::save_global_classes() {
List<StringName> gc;
get_global_class_list(&gc);
Array gcarr;
- for (StringName &E : gc) {
+ for (const StringName &E : gc) {
Dictionary d;
d["class"] = E;
d["language"] = global_classes[E].language;
@@ -297,7 +297,7 @@ void ScriptServer::save_global_classes() {
void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
List<PropertyInfo> pinfo;
get_property_list(&pinfo);
- for (PropertyInfo &E : pinfo) {
+ for (const PropertyInfo &E : pinfo) {
if (E.usage & PROPERTY_USAGE_STORAGE) {
Pair<StringName, Variant> p;
p.first = E.name;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 016d9d0a09..3c0e56f5a8 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -66,7 +66,7 @@ void MainLoop::initialize() {
}
}
-bool MainLoop::physics_process(float p_time) {
+bool MainLoop::physics_process(double p_time) {
if (get_script_instance()) {
return get_script_instance()->call("_physics_process", p_time);
}
@@ -74,7 +74,7 @@ bool MainLoop::physics_process(float p_time) {
return false;
}
-bool MainLoop::process(float p_time) {
+bool MainLoop::process(double p_time) {
if (get_script_instance()) {
return get_script_instance()->call("_process", p_time);
}
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 34e944709b..b42e9b18ff 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -60,8 +60,8 @@ public:
};
virtual void initialize();
- virtual bool physics_process(float p_time);
- virtual bool process(float p_time);
+ virtual bool physics_process(double p_time);
+ virtual bool process(double p_time);
virtual void finalize();
void set_initialize_script(const Ref<Script> &p_initialize_script);
diff --git a/core/os/pool_allocator.h b/core/os/pool_allocator.h
index 15e50dac90..49f433ba97 100644
--- a/core/os/pool_allocator.h
+++ b/core/os/pool_allocator.h
@@ -37,7 +37,7 @@
@author Juan Linietsky <reduzio@gmail.com>
* Generic Pool Allocator.
* This is a generic memory pool allocator, with locking, compacting and alignment. (@TODO alignment)
- * It used as a standard way to manage alloction in a specific region of memory, such as texture memory,
+ * It used as a standard way to manage allocation in a specific region of memory, such as texture memory,
* audio sample memory, or just any kind of memory overall.
* (@TODO) abstraction should be greater, because in many platforms, you need to manage a nonreachable memory.
*/
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index c088390cf0..3d1cb4a8e1 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -297,7 +297,7 @@ void register_core_singletons() {
}
void register_core_extensions() {
- //harcoded for now
+ // Hardcoded for now.
if (ProjectSettings::get_singleton()->has_setting("native_extensions/paths")) {
Vector<String> paths = ProjectSettings::get_singleton()->get("native_extensions/paths");
for (int i = 0; i < paths.size(); i++) {
diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp
index cf0b8d10db..5863bd1c46 100644
--- a/core/string/optimized_translation.cpp
+++ b/core/string/optimized_translation.cpp
@@ -66,7 +66,7 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
int total_compression_size = 0;
int total_string_size = 0;
- for (StringName &E : keys) {
+ for (const StringName &E : keys) {
//hash string
CharString cs = E.operator String().utf8();
uint32_t h = hash(0, cs.get_data());
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 981954c8ae..19d23fd375 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -841,7 +841,7 @@ Vector<String> Translation::_get_message_list() const {
void Translation::_set_messages(const Dictionary &p_messages) {
List<Variant> keys;
p_messages.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
translation_map[E] = p_messages[E];
}
}
diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp
index afd3b76588..1da00aa54b 100644
--- a/core/string/translation_po.cpp
+++ b/core/string/translation_po.cpp
@@ -47,7 +47,7 @@ void TranslationPO::print_translation_map() {
List<StringName> context_l;
translation_map.get_key_list(&context_l);
- for (StringName &ctx : context_l) {
+ for (const StringName &ctx : context_l) {
file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== ");
const HashMap<StringName, Vector<StringName>> &inner_map = translation_map[ctx];
@@ -73,7 +73,7 @@ Dictionary TranslationPO::_get_messages() const {
List<StringName> context_l;
translation_map.get_key_list(&context_l);
- for (StringName &ctx : context_l) {
+ for (const StringName &ctx : context_l) {
const HashMap<StringName, Vector<StringName>> &id_str_map = translation_map[ctx];
Dictionary d2;
@@ -96,7 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) {
List<Variant> context_l;
p_messages.get_key_list(&context_l);
- for (Variant &ctx : context_l) {
+ for (const Variant &ctx : context_l) {
const Dictionary &id_str_map = p_messages[ctx];
HashMap<StringName, Vector<StringName>> temp_map;
@@ -118,7 +118,7 @@ Vector<String> TranslationPO::_get_message_list() const {
get_message_list(&msgs);
Vector<String> v;
- for (StringName &E : msgs) {
+ for (const StringName &E : msgs) {
v.push_back(E);
}
@@ -278,7 +278,7 @@ void TranslationPO::get_message_list(List<StringName> *r_messages) const {
List<StringName> context_l;
translation_map.get_key_list(&context_l);
- for (StringName &E : context_l) {
+ for (const StringName &E : context_l) {
if (String(E) != "") {
continue;
}
@@ -297,7 +297,7 @@ int TranslationPO::get_message_count() const {
translation_map.get_key_list(&context_l);
int count = 0;
- for (StringName &E : context_l) {
+ for (const StringName &E : context_l) {
count += translation_map[E].size();
}
return count;
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index dbb8dc8283..7beecdb6b5 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3421,7 +3421,7 @@ String String::format(const Variant &values, String placeholder) const {
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &key : keys) {
+ for (const Variant &key : keys) {
new_string = new_string.replace(placeholder.replace("_", key), d[key]);
}
} else {
diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h
index acc46da0d5..519a896ffc 100644
--- a/core/templates/command_queue_mt.h
+++ b/core/templates/command_queue_mt.h
@@ -321,7 +321,7 @@ class CommandQueueMT {
DECL_CMD(0)
SPACE_SEP_LIST(DECL_CMD, 15)
- /* comands that return */
+ // Commands that return.
DECL_CMD_RET(0)
SPACE_SEP_LIST(DECL_CMD_RET, 15)
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h
index 4f5c74ca46..8d139551ef 100644
--- a/core/templates/rid_owner.h
+++ b/core/templates/rid_owner.h
@@ -101,7 +101,7 @@ class RID_Alloc : public RID_AllocBase {
//initialize
for (uint32_t i = 0; i < elements_in_chunk; i++) {
- //dont initialize chunk
+ // Don't initialize chunk.
validator_chunks[chunk_count][i] = 0xFFFFFFFF;
free_list_chunks[chunk_count][i] = alloc_count + i;
}
diff --git a/core/templates/set.h b/core/templates/set.h
index 245c174862..9261d2d3d2 100644
--- a/core/templates/set.h
+++ b/core/templates/set.h
@@ -71,6 +71,9 @@ public:
Element *prev() {
return _prev;
}
+ T &get() {
+ return value;
+ }
const T &get() const {
return value;
};
@@ -118,8 +121,8 @@ public:
return *this;
}
- _FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; }
- _FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; }
+ _FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return E == b.E; }
+ _FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return E != b.E; }
_FORCE_INLINE_ ConstIterator(const Element *p_E) { E = p_E; }
_FORCE_INLINE_ ConstIterator() {}
diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h
index ef5867c685..3cb2a6bfb5 100644
--- a/core/variant/binder_common.h
+++ b/core/variant/binder_common.h
@@ -69,17 +69,17 @@ struct VariantCaster<const T &> {
template <> \
struct VariantCaster<m_enum> { \
static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
- return (m_enum)p_variant.operator int(); \
+ return (m_enum)p_variant.operator int64_t(); \
} \
}; \
template <> \
struct PtrToArg<m_enum> { \
_FORCE_INLINE_ static m_enum convert(const void *p_ptr) { \
- return m_enum(*reinterpret_cast<const int *>(p_ptr)); \
+ return m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \
typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(m_enum p_val, const void *p_ptr) { \
- *(int *)p_ptr = p_val; \
+ *(int64_t *)p_ptr = p_val; \
} \
};
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index 2a3a9a4f1a..f487e718f4 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -407,7 +407,7 @@ Array Signal::get_connections() const {
object->get_signal_connection_list(name, &connections);
Array arr;
- for (Object::Connection &E : connections) {
+ for (const Object::Connection &E : connections) {
arr.push_back(E);
}
return arr;
diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h
index 7852187b77..8836e257a9 100644
--- a/core/variant/method_ptrcall.h
+++ b/core/variant/method_ptrcall.h
@@ -105,7 +105,7 @@ struct PtrToArg {};
} \
}
-MAKE_PTRARGCONV(bool, uint32_t);
+MAKE_PTRARGCONV(bool, uint8_t);
// Integer types.
MAKE_PTRARGCONV(uint8_t, int64_t);
MAKE_PTRARGCONV(int8_t, int64_t);
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 12b6465005..97a1b4c02a 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -1681,7 +1681,7 @@ String Variant::stringify(List<const void *> &stack) const {
Vector<_VariantStrPair> pairs;
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
_VariantStrPair sp;
sp.key = E.stringify(stack);
sp.value = d[E].stringify(stack);
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 6d1b4da9e8..4dc706e853 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -253,7 +253,7 @@ private:
true, //PACKED_COLOR_ARRAY,
};
- if (unlikely(needs_deinit[type])) { //make it fast for types that dont need deinit
+ if (unlikely(needs_deinit[type])) { // Make it fast for types that don't need deinit.
_clear_internal();
}
type = NIL;
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index a9645da045..f8538f71d3 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1124,7 +1124,7 @@ bool Variant::has_builtin_method_return_value(Variant::Type p_type, const String
void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) {
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
- for (StringName &E : builtin_method_names[p_type]) {
+ for (const StringName &E : builtin_method_names[p_type]) {
p_list->push_back(E);
}
}
@@ -1188,7 +1188,7 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
obj->get_method_list(p_list);
}
} else {
- for (StringName &E : builtin_method_names[type]) {
+ for (const StringName &E : builtin_method_names[type]) {
const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E);
ERR_CONTINUE(!method);
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index dc92ac8ac4..50c48fd386 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1586,7 +1586,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
List<PropertyInfo> props;
obj->get_property_list(&props);
bool first = true;
- for (PropertyInfo &E : props) {
+ for (const PropertyInfo &E : props) {
if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) {
//must be serialized
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index 62228ea87c..ae3c7685fd 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -1093,7 +1093,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
List<Variant> keys;
dic->get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
if (E.get_type() == Variant::STRING) {
p_list->push_back(PropertyInfo(Variant::STRING, E));
}
@@ -1106,7 +1106,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} else {
List<StringName> members;
get_member_list(type, &members);
- for (StringName &E : members) {
+ for (const StringName &E : members) {
PropertyInfo pi;
pi.name = E;
pi.type = get_member_type(type, E);
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index e9fa952af3..64f07e075e 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -1397,7 +1397,7 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) {
}
void Variant::get_utility_function_list(List<StringName> *r_functions) {
- for (StringName &E : utility_function_name_table) {
+ for (const StringName &E : utility_function_name_table) {
r_functions->push_back(E);
}
}