summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp30
-rw-r--r--core/object/object.cpp14
-rw-r--r--core/object/script_language.cpp12
3 files changed, 29 insertions, 27 deletions
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;