diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-08-25 08:37:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 08:37:38 +0200 |
commit | 490aef93699abc00da58f73b1596fb3473fd53c6 (patch) | |
tree | 7912c7a540eca6b09392bbd2aa2f30fefe37f51a /modules/gdscript/gd_editor.cpp | |
parent | b1c0e45b03aa14453846c9a888763077eef2476b (diff) | |
parent | cacced7e507f7603bacc03ae2616e58f0ede122a (diff) | |
download | redot-engine-490aef93699abc00da58f73b1596fb3473fd53c6.tar.gz |
Merge pull request #10581 from hpvb/fix-gcc6+
Make cast_to a static member of Object.
Diffstat (limited to 'modules/gdscript/gd_editor.cpp')
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 115 |
1 files changed, 54 insertions, 61 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 95091831a9..d06da08551 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -372,8 +372,8 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) { Object *obj = p_variant; if (obj) { /* - if (obj->cast_to<GDNativeClass>()) { - t.obj_type=obj->cast_to<GDNativeClass>()->get_name(); + if (Object::cast_to<GDNativeClass>(obj)) { + t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name(); t.value=Variant(); } else { */ @@ -597,8 +597,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) { Object *obj = base.value; - if (obj && obj->cast_to<GDNativeClass>()) { - GDNativeClass *gdnc = obj->cast_to<GDNativeClass>(); + if (GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj)) { r_type.type = Variant::OBJECT; r_type.value = Variant(); r_type.obj_type = gdnc->get_name(); @@ -1509,48 +1508,45 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (id.value.get_type()) { Object *obj = id.value; - if (obj) { - - GDScript *scr = obj->cast_to<GDScript>(); - if (scr) { - while (scr) { + GDScript *scr = Object::cast_to<GDScript>(obj); + if (scr) { + while (scr) { - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { - if (E->get()->is_static() && p_method == E->get()->get_name()) { - arghint = "static func " + String(p_method) + "("; - for (int i = 0; i < E->get()->get_argument_count(); i++) { - if (i > 0) - arghint += ", "; - else - arghint += " "; - if (i == p_argidx) { - arghint += String::chr(0xFFFF); - } - arghint += "var " + E->get()->get_argument_name(i); - int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count(); - if (i >= deffrom) { - int defidx = deffrom - i; - if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) { - arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string(); - } - } - if (i == p_argidx) { - arghint += String::chr(0xFFFF); + for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + if (E->get()->is_static() && p_method == E->get()->get_name()) { + arghint = "static func " + String(p_method) + "("; + for (int i = 0; i < E->get()->get_argument_count(); i++) { + if (i > 0) + arghint += ", "; + else + arghint += " "; + if (i == p_argidx) { + arghint += String::chr(0xFFFF); + } + arghint += "var " + E->get()->get_argument_name(i); + int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count(); + if (i >= deffrom) { + int defidx = deffrom - i; + if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) { + arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string(); } } - arghint += ")"; - return; //found + if (i == p_argidx) { + arghint += String::chr(0xFFFF); + } } + arghint += ")"; + return; //found } - - if (scr->get_base().is_valid()) - scr = scr->get_base().ptr(); - else - scr = NULL; } - } else { - on_script = obj->get_script(); + + if (scr->get_base().is_valid()) + scr = scr->get_base().ptr(); + else + scr = NULL; } + } else { + on_script = obj->get_script(); } } @@ -2221,30 +2217,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base if (t.value.get_type()) { Object *obj = t.value; - if (obj) { - - GDScript *scr = obj->cast_to<GDScript>(); - if (scr) { - while (scr) { + GDScript *scr = Object::cast_to<GDScript>(obj); + if (scr) { + while (scr) { - if (!isfunction) { - for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) { - options.insert(E->key()); - } + if (!isfunction) { + for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) { + options.insert(E->key()); } - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { - if (E->get()->is_static()) - options.insert(E->key()); - } - - if (scr->get_base().is_valid()) - scr = scr->get_base().ptr(); - else - scr = NULL; } - } else { - on_script = obj->get_script(); + for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + if (E->get()->is_static()) + options.insert(E->key()); + } + + if (scr->get_base().is_valid()) + scr = scr->get_base().ptr(); + else + scr = NULL; } + } else { + on_script = obj->get_script(); } } @@ -2836,9 +2829,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol Object *obj = value; if (obj) { - if (obj->cast_to<GDNativeClass>()) { + if (Object::cast_to<GDNativeClass>(obj)) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = obj->cast_to<GDNativeClass>()->get_name(); + r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name(); } else { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; |