summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r--modules/gdscript/gdscript.cpp134
1 files changed, 67 insertions, 67 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 340f2af693..0a9dad04c7 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -111,9 +111,9 @@ GDScriptFunction *GDScript::_super_constructor(GDScript *p_script) {
if (p_script->initializer) {
return p_script->initializer;
} else {
- GDScript *base = p_script->_base;
- if (base != nullptr) {
- return _super_constructor(base);
+ GDScript *base_src = p_script->_base;
+ if (base_src != nullptr) {
+ return _super_constructor(base_src);
} else {
return nullptr;
}
@@ -121,9 +121,9 @@ GDScriptFunction *GDScript::_super_constructor(GDScript *p_script) {
}
void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error) {
- GDScript *base = p_script->_base;
- if (base != nullptr) {
- _super_implicit_constructor(base, p_instance, r_error);
+ GDScript *base_src = p_script->_base;
+ if (base_src != nullptr) {
+ _super_implicit_constructor(base_src, p_instance, r_error);
if (r_error.error != Callable::CallError::CALL_OK) {
return;
}
@@ -151,7 +151,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
/* STEP 2, INITIALIZE AND CONSTRUCT */
{
- MutexLock lock(GDScriptLanguage::singleton->lock);
+ MutexLock lock(GDScriptLanguage::singleton->mutex);
instances.insert(instance->owner);
}
@@ -160,7 +160,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
instance->script = Ref<GDScript>();
instance->owner->set_script_instance(nullptr);
{
- MutexLock lock(GDScriptLanguage::singleton->lock);
+ MutexLock lock(GDScriptLanguage::singleton->mutex);
instances.erase(p_owner);
}
ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance.");
@@ -177,7 +177,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
instance->script = Ref<GDScript>();
instance->owner->set_script_instance(nullptr);
{
- MutexLock lock(GDScriptLanguage::singleton->lock);
+ MutexLock lock(GDScriptLanguage::singleton->mutex);
instances.erase(p_owner);
}
ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance.");
@@ -418,7 +418,7 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this)
}
bool GDScript::instance_has(const Object *p_this) const {
- MutexLock lock(GDScriptLanguage::singleton->lock);
+ MutexLock lock(GDScriptLanguage::singleton->mutex);
return instances.has((Object *)p_this);
}
@@ -620,11 +620,11 @@ void GDScript::_update_doc() {
}
if (!is_enum) {
DocData::ConstantDoc constant_doc;
- String doc_description;
+ String const_description;
if (doc_constants.has(E.key)) {
- doc_description = doc_constants[E.key];
+ const_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, const_description);
doc.constants.push_back(constant_doc);
}
}
@@ -675,35 +675,35 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc
}
if (c->extends_used) {
- String path = "";
+ String ext_path = "";
if (String(c->extends_path) != "" && String(c->extends_path) != get_path()) {
- path = c->extends_path;
- if (path.is_relative_path()) {
- String base = get_path();
- if (base.is_empty() || base.is_relative_path()) {
- ERR_PRINT(("Could not resolve relative path for parent class: " + path).utf8().get_data());
+ ext_path = c->extends_path;
+ if (ext_path.is_relative_path()) {
+ String base_path = get_path();
+ if (base_path.is_empty() || base_path.is_relative_path()) {
+ ERR_PRINT(("Could not resolve relative path for parent class: " + ext_path).utf8().get_data());
} else {
- path = base.get_base_dir().path_join(path);
+ ext_path = base_path.get_base_dir().path_join(ext_path);
}
}
} else if (c->extends.size() != 0) {
- const StringName &base = c->extends[0];
+ const StringName &base_class = c->extends[0];
- if (ScriptServer::is_global_class(base)) {
- path = ScriptServer::get_global_class_path(base);
+ if (ScriptServer::is_global_class(base_class)) {
+ ext_path = ScriptServer::get_global_class_path(base_class);
}
}
- if (!path.is_empty()) {
- if (path != get_path()) {
- Ref<GDScript> bf = ResourceLoader::load(path);
+ if (!ext_path.is_empty()) {
+ if (ext_path != get_path()) {
+ Ref<GDScript> bf = ResourceLoader::load(ext_path);
if (bf.is_valid()) {
base_cache = bf;
bf->inheriters_cache.insert(get_instance_id());
}
} else {
- ERR_PRINT(("Path extending itself in " + path).utf8().get_data());
+ ERR_PRINT(("Path extending itself in " + ext_path).utf8().get_data());
}
}
}
@@ -843,7 +843,7 @@ String GDScript::_get_debug_path() const {
Error GDScript::reload(bool p_keep_state) {
bool has_instances;
{
- MutexLock lock(GDScriptLanguage::singleton->lock);
+ MutexLock lock(GDScriptLanguage::singleton->mutex);
has_instances = instances.size();
}
@@ -1187,7 +1187,7 @@ GDScript::GDScript() :
script_list(this) {
#ifdef DEBUG_ENABLED
{
- MutexLock lock(GDScriptLanguage::get_singleton()->lock);
+ MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
GDScriptLanguage::get_singleton()->script_list.add(&script_list);
}
@@ -1258,7 +1258,7 @@ void GDScript::_init_rpc_methods_properties() {
GDScript::~GDScript() {
{
- MutexLock lock(GDScriptLanguage::get_singleton()->lock);
+ MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
// Order matters since clearing the stack may already cause
@@ -1295,7 +1295,7 @@ GDScript::~GDScript() {
#ifdef DEBUG_ENABLED
{
- MutexLock lock(GDScriptLanguage::get_singleton()->lock);
+ MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
GDScriptLanguage::get_singleton()->script_list.remove(&script_list);
}
@@ -1722,7 +1722,7 @@ GDScriptInstance::GDScriptInstance() {
}
GDScriptInstance::~GDScriptInstance() {
- MutexLock lock(GDScriptLanguage::get_singleton()->lock);
+ MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
// Order matters since clearing the stack may already cause
@@ -1825,7 +1825,7 @@ void GDScriptLanguage::finish() {
void GDScriptLanguage::profiling_start() {
#ifdef DEBUG_ENABLED
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
@@ -1847,7 +1847,7 @@ void GDScriptLanguage::profiling_start() {
void GDScriptLanguage::profiling_stop() {
#ifdef DEBUG_ENABLED
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
profiling = false;
#endif
@@ -1857,7 +1857,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
int current = 0;
#ifdef DEBUG_ENABLED
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
@@ -1880,7 +1880,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
int current = 0;
#ifdef DEBUG_ENABLED
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
@@ -1926,7 +1926,7 @@ void GDScriptLanguage::reload_all_scripts() {
print_verbose("GDScript: Reloading all scripts");
List<Ref<GDScript>> scripts;
{
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScript> *elem = script_list.first();
while (elem) {
@@ -1942,10 +1942,10 @@ void GDScriptLanguage::reload_all_scripts() {
scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order
- for (Ref<GDScript> &script : scripts) {
- print_verbose("GDScript: Reloading: " + script->get_path());
- script->load_source_code(script->get_path());
- script->reload(true);
+ for (Ref<GDScript> &scr : scripts) {
+ print_verbose("GDScript: Reloading: " + scr->get_path());
+ scr->load_source_code(scr->get_path());
+ scr->reload(true);
}
#endif
}
@@ -1955,7 +1955,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
List<Ref<GDScript>> scripts;
{
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScript> *elem = script_list.first();
while (elem) {
@@ -1974,21 +1974,21 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order
- for (Ref<GDScript> &script : scripts) {
- bool reload = script == p_script || to_reload.has(script->get_base());
+ for (Ref<GDScript> &scr : scripts) {
+ bool reload = scr == p_script || to_reload.has(scr->get_base());
if (!reload) {
continue;
}
- to_reload.insert(script, HashMap<ObjectID, List<Pair<StringName, Variant>>>());
+ to_reload.insert(scr, HashMap<ObjectID, List<Pair<StringName, Variant>>>());
if (!p_soft_reload) {
//save state and remove script from instances
- HashMap<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[script];
+ HashMap<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[scr];
- while (script->instances.front()) {
- Object *obj = script->instances.front()->get();
+ while (scr->instances.front()) {
+ Object *obj = scr->instances.front()->get();
//save instance info
List<Pair<StringName, Variant>> state;
if (obj->get_script_instance()) {
@@ -2001,8 +2001,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
//same thing for placeholders
#ifdef TOOLS_ENABLED
- while (script->placeholders.size()) {
- Object *obj = (*script->placeholders.begin())->get_owner();
+ while (scr->placeholders.size()) {
+ Object *obj = (*scr->placeholders.begin())->get_owner();
//save instance info
if (obj->get_script_instance()) {
@@ -2012,13 +2012,13 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
obj->set_script(Variant());
} else {
// no instance found. Let's remove it so we don't loop forever
- script->placeholders.erase(*script->placeholders.begin());
+ scr->placeholders.erase(*scr->placeholders.begin());
}
}
#endif
- for (const KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : script->pending_reload_state) {
+ for (const KeyValue<ObjectID, List<Pair<StringName, Variant>>> &F : scr->pending_reload_state) {
map[F.key] = F.value; //pending to reload, use this one instead
}
}
@@ -2043,9 +2043,9 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
}
obj->set_script(scr);
- ScriptInstance *script_instance = obj->get_script_instance();
+ ScriptInstance *script_inst = obj->get_script_instance();
- if (!script_instance) {
+ if (!script_inst) {
//failed, save reload state for next time if not saved
if (!scr->pending_reload_state.has(obj->get_instance_id())) {
scr->pending_reload_state[obj->get_instance_id()] = saved_state;
@@ -2053,14 +2053,14 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
continue;
}
- if (script_instance->is_placeholder() && scr->is_placeholder_fallback_enabled()) {
- PlaceHolderScriptInstance *placeholder = static_cast<PlaceHolderScriptInstance *>(script_instance);
+ if (script_inst->is_placeholder() && scr->is_placeholder_fallback_enabled()) {
+ PlaceHolderScriptInstance *placeholder = static_cast<PlaceHolderScriptInstance *>(script_inst);
for (List<Pair<StringName, Variant>>::Element *G = saved_state.front(); G; G = G->next()) {
placeholder->property_set_fallback(G->get().first, G->get().second);
}
} else {
for (List<Pair<StringName, Variant>>::Element *G = saved_state.front(); G; G = G->next()) {
- script_instance->set(G->get().first, G->get().second);
+ script_inst->set(G->get().first, G->get().second);
}
}
@@ -2078,7 +2078,7 @@ void GDScriptLanguage::frame() {
#ifdef DEBUG_ENABLED
if (profiling) {
- MutexLock lock(this->lock);
+ MutexLock lock(this->mutex);
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
@@ -2339,26 +2339,26 @@ GDScriptLanguage::~GDScriptLanguage() {
// Clear dependencies between scripts, to ensure cyclic references are broken (to avoid leaks at exit).
SelfList<GDScript> *s = script_list.first();
while (s) {
- GDScript *script = s->self();
+ GDScript *scr = s->self();
// This ensures the current script is not released before we can check what's the next one
// in the list (we can't get the next upfront because we don't know if the reference breaking
// will cause it -or any other after it, for that matter- to be released so the next one
// is not the same as before).
- script->reference();
+ scr->reference();
- for (KeyValue<StringName, GDScriptFunction *> &E : script->member_functions) {
+ for (KeyValue<StringName, GDScriptFunction *> &E : scr->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 (KeyValue<StringName, GDScript::MemberInfo> &E : script->member_indices) {
+ for (KeyValue<StringName, GDScript::MemberInfo> &E : scr->member_indices) {
E.value.data_type.script_type_ref = Ref<Script>();
}
s = s->next();
- script->unreference();
+ scr->unreference();
}
singleton = nullptr;
@@ -2390,20 +2390,20 @@ Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const Str
}
Error err;
- Ref<GDScript> script = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE);
+ Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE);
// TODO: Reintroduce binary and encrypted scripts.
- if (script.is_null()) {
+ if (scr.is_null()) {
// Don't fail loading because of parsing error.
- script.instantiate();
+ scr.instantiate();
}
if (r_error) {
*r_error = OK;
}
- return script;
+ return scr;
}
void ResourceFormatLoaderGDScript::get_recognized_extensions(List<String> *p_extensions) const {