diff options
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 1b4711804c..e3c9101733 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -340,14 +340,14 @@ bool GDScript::has_method(const StringName &p_method) const { } MethodInfo GDScript::get_method_info(const StringName &p_method) const { - const Map<StringName, GDScriptFunction *>::Element *E = member_functions.find(p_method); + HashMap<StringName, GDScriptFunction *>::ConstIterator E = member_functions.find(p_method); if (!E) { return MethodInfo(); } - GDScriptFunction *func = E->get(); + GDScriptFunction *func = E->value; MethodInfo mi; - mi.name = E->key(); + mi.name = E->key; for (int i = 0; i < func->get_argument_count(); i++) { mi.arguments.push_back(func->get_argument_type(i)); } @@ -359,9 +359,9 @@ MethodInfo GDScript::get_method_info(const StringName &p_method) const { bool GDScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { #ifdef TOOLS_ENABLED - const Map<StringName, Variant>::Element *E = member_default_values_cache.find(p_property); + HashMap<StringName, Variant>::ConstIterator E = member_default_values_cache.find(p_property); if (E) { - r_value = E->get(); + r_value = E->value; return true; } @@ -427,7 +427,7 @@ void GDScript::set_source_code(const String &p_code) { } #ifdef TOOLS_ENABLED -void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames) { +void GDScript::_update_exports_values(HashMap<StringName, Variant> &values, List<PropertyInfo> &propnames) { if (base_cache.is_valid()) { base_cache->_update_exports_values(values, propnames); } @@ -759,12 +759,12 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc if ((changed || p_instance_to_update) && placeholders.size()) { //hm :( // update placeholders if any - Map<StringName, Variant> values; + HashMap<StringName, Variant> values; List<PropertyInfo> propnames; _update_exports_values(values, propnames); if (changed) { - for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { + for (RBSet<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { E->get()->update(propnames, values); } } else { @@ -788,9 +788,9 @@ void GDScript::update_exports() { return; } - Set<ObjectID> copy = inheriters_cache; //might get modified + RBSet<ObjectID> copy = inheriters_cache; //might get modified - for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) { + for (RBSet<ObjectID>::Element *E = copy.front(); E; E = E->next()) { Object *id = ObjectDB::get_instance(E->get()); GDScript *s = Object::cast_to<GDScript>(id); if (!s) { @@ -929,7 +929,7 @@ ScriptLanguage *GDScript::get_language() const { return GDScriptLanguage::get_singleton(); } -void GDScript::get_constants(Map<StringName, Variant> *p_constants) { +void GDScript::get_constants(HashMap<StringName, Variant> *p_constants) { if (p_constants) { for (const KeyValue<StringName, Variant> &E : constants) { (*p_constants)[E.key] = E.value; @@ -937,9 +937,9 @@ void GDScript::get_constants(Map<StringName, Variant> *p_constants) { } } -void GDScript::get_members(Set<StringName> *p_members) { +void GDScript::get_members(RBSet<StringName> *p_members) { if (p_members) { - for (Set<StringName>::Element *E = members.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = members.front(); E; E = E->next()) { p_members->insert(E->get()); } } @@ -952,11 +952,11 @@ const Vector<Multiplayer::RPCConfig> GDScript::get_rpc_methods() const { Variant GDScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { GDScript *top = this; while (top) { - Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method); + HashMap<StringName, GDScriptFunction *>::Iterator E = top->member_functions.find(p_method); if (E) { - ERR_FAIL_COND_V_MSG(!E->get()->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script."); + ERR_FAIL_COND_V_MSG(!E->value->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script."); - return E->get()->call(nullptr, p_args, p_argcount, r_error); + return E->value->call(nullptr, p_args, p_argcount, r_error); } top = top->_base; } @@ -971,17 +971,17 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const { const GDScript *top = this; while (top) { { - const Map<StringName, Variant>::Element *E = top->constants.find(p_name); + HashMap<StringName, Variant>::ConstIterator E = top->constants.find(p_name); if (E) { - r_ret = E->get(); + r_ret = E->value; return true; } } { - const Map<StringName, Ref<GDScript>>::Element *E = subclasses.find(p_name); + HashMap<StringName, Ref<GDScript>>::ConstIterator E = subclasses.find(p_name); if (E) { - r_ret = E->get(); + r_ret = E->value; return true; } } @@ -1061,7 +1061,7 @@ Error GDScript::load_source_code(const String &p_path) { return OK; } -const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const { +const HashMap<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const { return member_functions; } @@ -1209,7 +1209,7 @@ void GDScript::_init_rpc_methods_properties() { } GDScript *cscript = this; - Map<StringName, Ref<GDScript>>::Element *sub_E = subclasses.front(); + HashMap<StringName, Ref<GDScript>>::Iterator sub_E = subclasses.begin(); while (cscript) { // RPC Methods for (KeyValue<StringName, GDScriptFunction *> &E : cscript->member_functions) { @@ -1223,11 +1223,11 @@ void GDScript::_init_rpc_methods_properties() { } if (cscript != this) { - sub_E = sub_E->next(); + ++sub_E; } if (sub_E) { - cscript = sub_E->get().ptr(); + cscript = sub_E->value.ptr(); } else { cscript = nullptr; } @@ -1282,9 +1282,9 @@ GDScript::~GDScript() { bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) { //member { - const Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name); + HashMap<StringName, GDScript::MemberInfo>::Iterator E = script->member_indices.find(p_name); if (E) { - const GDScript::MemberInfo *member = &E->get(); + const GDScript::MemberInfo *member = &E->value; if (member->setter) { const Variant *val = &p_value; Callable::CallError err; @@ -1325,13 +1325,13 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) { GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); + HashMap<StringName, GDScriptFunction *>::Iterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); if (E) { Variant name = p_name; const Variant *args[2] = { &name, &p_value }; Callable::CallError err; - Variant ret = E->get()->call(this, (const Variant **)args, 2, err); + Variant ret = E->value->call(this, (const Variant **)args, 2, err); if (err.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::BOOL && ret.operator bool()) { return true; } @@ -1346,16 +1346,16 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { const GDScript *sptr = script.ptr(); while (sptr) { { - const Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name); + HashMap<StringName, GDScript::MemberInfo>::ConstIterator E = script->member_indices.find(p_name); if (E) { - if (E->get().getter) { + if (E->value.getter) { Callable::CallError err; - r_ret = const_cast<GDScriptInstance *>(this)->callp(E->get().getter, nullptr, 0, err); + r_ret = const_cast<GDScriptInstance *>(this)->callp(E->value.getter, nullptr, 0, err); if (err.error == Callable::CallError::CALL_OK) { return true; } } - r_ret = members[E->get().index]; + r_ret = members[E->value.index]; return true; //index found } } @@ -1363,9 +1363,9 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { { const GDScript *sl = sptr; while (sl) { - const Map<StringName, Variant>::Element *E = sl->constants.find(p_name); + HashMap<StringName, Variant>::ConstIterator E = sl->constants.find(p_name); if (E) { - r_ret = E->get(); + r_ret = E->value; return true; //index found } sl = sl->_base; @@ -1376,9 +1376,9 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { // Signals. const GDScript *sl = sptr; while (sl) { - const Map<StringName, Vector<StringName>>::Element *E = sl->_signals.find(p_name); + HashMap<StringName, Vector<StringName>>::ConstIterator E = sl->_signals.find(p_name); if (E) { - r_ret = Signal(this->owner, E->key()); + r_ret = Signal(this->owner, E->key); return true; //index found } sl = sl->_base; @@ -1389,14 +1389,14 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { // Methods. const GDScript *sl = sptr; while (sl) { - const Map<StringName, GDScriptFunction *>::Element *E = sl->member_functions.find(p_name); + HashMap<StringName, GDScriptFunction *>::ConstIterator E = sl->member_functions.find(p_name); if (E) { Multiplayer::RPCConfig config; config.name = p_name; if (sptr->rpc_functions.find(config) != -1) { - r_ret = Callable(memnew(GDScriptRPCCallable(this->owner, E->key()))); + r_ret = Callable(memnew(GDScriptRPCCallable(this->owner, E->key))); } else { - r_ret = Callable(this->owner, E->key()); + r_ret = Callable(this->owner, E->key); } return true; //index found } @@ -1405,13 +1405,13 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { } { - const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); + HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); if (E) { Variant name = p_name; const Variant *args[1] = { &name }; Callable::CallError err; - Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err); + Variant ret = const_cast<GDScriptFunction *>(E->value)->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err); if (err.error == Callable::CallError::CALL_OK && ret.get_type() != Variant::NIL) { r_ret = ret; return true; @@ -1449,10 +1449,10 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const List<PropertyInfo> props; while (sptr) { - const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); + HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); if (E) { Callable::CallError err; - Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err); + Variant ret = const_cast<GDScriptFunction *>(E->value)->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err); if (err.error == Callable::CallError::CALL_OK) { ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries."); @@ -1525,7 +1525,7 @@ void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const { bool GDScriptInstance::has_method(const StringName &p_method) const { const GDScript *sptr = script.ptr(); while (sptr) { - const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); + HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(p_method); if (E) { return true; } @@ -1538,9 +1538,9 @@ bool GDScriptInstance::has_method(const StringName &p_method) const { Variant GDScriptInstance::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); + HashMap<StringName, GDScriptFunction *>::Iterator E = sptr->member_functions.find(p_method); if (E) { - return E->get()->call(this, p_args, p_argcount, r_error); + return E->value->call(this, p_args, p_argcount, r_error); } sptr = sptr->_base; } @@ -1555,10 +1555,10 @@ void GDScriptInstance::notification(int p_notification) { GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); + HashMap<StringName, GDScriptFunction *>::Iterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); if (E) { Callable::CallError err; - E->get()->call(this, args, 1, err); + E->value->call(this, args, 1, err); if (err.error != Callable::CallError::CALL_OK) { //print error about notification call } @@ -1882,7 +1882,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so //when someone asks you why dynamically typed languages are easier to write.... - Map<Ref<GDScript>, Map<ObjectID, List<Pair<StringName, Variant>>>> to_reload; + HashMap<Ref<GDScript>, HashMap<ObjectID, List<Pair<StringName, Variant>>>> to_reload; //as scripts are going to be reloaded, must proceed without locking here @@ -1895,11 +1895,11 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so continue; } - to_reload.insert(script, Map<ObjectID, List<Pair<StringName, Variant>>>()); + to_reload.insert(script, HashMap<ObjectID, List<Pair<StringName, Variant>>>()); if (!p_soft_reload) { //save state and remove script from instances - Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[script]; + HashMap<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[script]; while (script->instances.front()) { Object *obj = script->instances.front()->get(); @@ -1938,7 +1938,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so } } - for (KeyValue<Ref<GDScript>, Map<ObjectID, List<Pair<StringName, Variant>>>> &E : to_reload) { + for (KeyValue<Ref<GDScript>, HashMap<ObjectID, List<Pair<StringName, Variant>>>> &E : to_reload) { Ref<GDScript> scr = E.key; scr->reload(p_soft_reload); @@ -2277,13 +2277,13 @@ void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const } Ref<GDScript> GDScriptLanguage::get_orphan_subclass(const String &p_qualified_name) { - Map<String, ObjectID>::Element *orphan_subclass_element = orphan_subclasses.find(p_qualified_name); + HashMap<String, ObjectID>::Iterator orphan_subclass_element = orphan_subclasses.find(p_qualified_name); if (!orphan_subclass_element) { return Ref<GDScript>(); } - ObjectID orphan_subclass = orphan_subclass_element->get(); + ObjectID orphan_subclass = orphan_subclass_element->value; Object *obj = ObjectDB::get_instance(orphan_subclass); - orphan_subclasses.erase(orphan_subclass_element); + orphan_subclasses.remove(orphan_subclass_element); if (!obj) { return Ref<GDScript>(); } |