Merge pull request #10581 from hpvb/fix-gcc6+

Make cast_to a static member of Object.
This commit is contained in:
Rémi Verschelde 2017-08-25 08:37:38 +02:00 committed by GitHub
commit 490aef9369
185 changed files with 1336 additions and 1490 deletions

View file

@ -1971,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->placeholders.erase(psi); //remove placeholder
GDInstance *instance = memnew(GDInstance);
instance->base_ref = E->get()->cast_to<Reference>();
instance->base_ref = Object::cast_to<Reference>(E->get());
instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script);
instance->owner = E->get();

View file

@ -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 = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>();
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 = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>();
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;

View file

@ -371,7 +371,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
Object *obj_A = *a;
Object *obj_B = *b;
GDScript *scr_B = obj_B->cast_to<GDScript>();
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
bool extends_ok = false;
@ -397,7 +397,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else {
GDNativeClass *nc = obj_B->cast_to<GDNativeClass>();
GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
if (!nc) {
@ -1434,7 +1434,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@ -1490,7 +1490,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
if (gdfs && gdfs->function == function)
completed = false;
}

View file

@ -3959,7 +3959,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
if (cn->value.get_type() == Variant::OBJECT) {
Object *obj = cn->value;
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
if (res == NULL) {
_set_error("Exported constant not a type or resource.");
return;

View file

@ -73,7 +73,7 @@ Variant GDNativeClass::_new() {
ERR_FAIL_COND_V(!o, Variant());
}
Reference *ref = o->cast_to<Reference>();
Reference *ref = Object::cast_to<Reference>(o);
if (ref) {
return REF(ref);
} else {
@ -161,7 +161,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
owner = memnew(Reference); //by default, no base means use reference
}
Reference *r = owner->cast_to<Reference>();
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
}
@ -397,7 +397,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
return _create_instance(NULL, 0, p_this, p_this->cast_to<Reference>(), unchecked_error);
return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
}
bool GDScript::instance_has(const Object *p_this) const {
@ -575,9 +575,7 @@ void GDScript::update_exports() {
//print_line("update exports for "+get_path()+" ic: "+itos(copy.size()));
for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
Object *id = ObjectDB::get_instance(E->get());
if (!id)
continue;
GDScript *s = id->cast_to<GDScript>();
GDScript *s = Object::cast_to<GDScript>(id);
if (!s)
continue;
s->update_exports();
@ -2006,11 +2004,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou
void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (p_resource->cast_to<GDScript>()) {
if (Object::cast_to<GDScript>(*p_resource)) {
p_extensions->push_back("gd");
}
}
bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
return p_resource->cast_to<GDScript>() != NULL;
return Object::cast_to<GDScript>(*p_resource) != NULL;
}