Merge pull request #22799 from vnen/gdscript-warning-fix

Fix compiler warnings in GDScript module
This commit is contained in:
Rémi Verschelde 2018-10-06 15:11:50 +02:00 committed by GitHub
commit ffe94ef4e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -419,8 +419,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
profile.call_count++; profile.call_count++;
profile.frame_call_count++; profile.frame_call_count++;
} }
#endif
bool exit_ok = false; bool exit_ok = false;
#endif
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
OPCODE_WHILE(ip < _code_size) { OPCODE_WHILE(ip < _code_size) {
@ -679,8 +679,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GET_VARIANT_PTR(src, 2); GET_VARIANT_PTR(src, 2);
bool valid; bool valid;
#ifndef DEBUG_ENABLED
ClassDB::set_property(p_instance->owner, *index, *src, &valid);
#else
bool ok = ClassDB::set_property(p_instance->owner, *index, *src, &valid); bool ok = ClassDB::set_property(p_instance->owner, *index, *src, &valid);
#ifdef DEBUG_ENABLED
if (!ok) { if (!ok) {
err_text = "Internal error setting property: " + String(*index); err_text = "Internal error setting property: " + String(*index);
OPCODE_BREAK; OPCODE_BREAK;
@ -700,9 +702,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
const StringName *index = &_global_names_ptr[indexname]; const StringName *index = &_global_names_ptr[indexname];
GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(dst, 2);
bool ok = ClassDB::get_property(p_instance->owner, *index, *dst);
#ifdef DEBUG_ENABLED #ifndef DEBUG_ENABLED
ClassDB::get_property(p_instance->owner, *index, *dst);
#else
bool ok = ClassDB::get_property(p_instance->owner, *index, *dst);
if (!ok) { if (!ok) {
err_text = "Internal error getting property: " + String(*index); err_text = "Internal error getting property: " + String(*index);
OPCODE_BREAK; OPCODE_BREAK;
@ -749,13 +753,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) { OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) {
CHECK_SPACE(4); CHECK_SPACE(4);
Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1];
GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3); GET_VARIANT_PTR(src, 3);
#ifdef DEBUG_ENABLED
Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1];
GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX); GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
#ifdef DEBUG_ENABLED
if (src->get_type() != var_type) { if (src->get_type() != var_type) {
if (Variant::can_convert_strict(src->get_type(), var_type)) { if (Variant::can_convert_strict(src->get_type(), var_type)) {
Variant::CallError ce; Variant::CallError ce;
@ -779,11 +783,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) { OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) {
CHECK_SPACE(4); CHECK_SPACE(4);
GET_VARIANT_PTR(type, 1);
GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3); GET_VARIANT_PTR(src, 3);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
GET_VARIANT_PTR(type, 1);
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(type->operator Object *()); GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(type->operator Object *());
GD_ERR_BREAK(!nc); GD_ERR_BREAK(!nc);
if (src->get_type() != Variant::OBJECT && src->get_type() != Variant::NIL) { if (src->get_type() != Variant::OBJECT && src->get_type() != Variant::NIL) {
@ -808,11 +812,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) { OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) {
CHECK_SPACE(4); CHECK_SPACE(4);
GET_VARIANT_PTR(type, 1);
GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3); GET_VARIANT_PTR(src, 3);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
GET_VARIANT_PTR(type, 1);
Script *base_type = Object::cast_to<Script>(type->operator Object *()); Script *base_type = Object::cast_to<Script>(type->operator Object *());
GD_ERR_BREAK(!base_type); GD_ERR_BREAK(!base_type);
@ -1310,7 +1314,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif #endif
} }
#ifdef DEBUG_ENABLED
exit_ok = true; exit_ok = true;
#endif
OPCODE_BREAK; OPCODE_BREAK;
} }
@ -1387,7 +1393,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
CHECK_SPACE(2); CHECK_SPACE(2);
GET_VARIANT_PTR(r, 1); GET_VARIANT_PTR(r, 1);
retvalue = *r; retvalue = *r;
#ifdef DEBUG_ENABLED
exit_ok = true; exit_ok = true;
#endif
OPCODE_BREAK; OPCODE_BREAK;
} }
@ -1459,9 +1467,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSERT) { OPCODE(OPCODE_ASSERT) {
CHECK_SPACE(2); CHECK_SPACE(2);
GET_VARIANT_PTR(test, 1);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
GET_VARIANT_PTR(test, 1);
bool result = test->booleanize(); bool result = test->booleanize();
if (!result) { if (!result) {
@ -1516,8 +1524,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE; DISPATCH_OPCODE;
OPCODE(OPCODE_END) { OPCODE(OPCODE_END) {
#ifdef DEBUG_ENABLED
exit_ok = true; exit_ok = true;
#endif
OPCODE_BREAK; OPCODE_BREAK;
} }