summaryrefslogtreecommitdiffstats
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript.cpp24
-rw-r--r--modules/gdscript/gdscript.h3
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp53
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp8
-rw-r--r--modules/gdscript/gdscript_compiler.cpp9
-rw-r--r--modules/gdscript/gdscript_disassembler.cpp2
-rw-r--r--modules/gdscript/gdscript_editor.cpp30
-rw-r--r--modules/gdscript/gdscript_function.h3
-rw-r--r--modules/gdscript/gdscript_parser.cpp5
-rw-r--r--modules/gdscript/gdscript_utility_functions.cpp6
-rw-r--r--modules/gdscript/gdscript_vm.cpp8
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp6
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp4
-rw-r--r--modules/gdscript/tests/gdscript_test_runner_suite.h18
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.gd9
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.out6
-rw-r--r--modules/gdscript/tests/scripts/parser/features/export_arrays.gd2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/export_arrays.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/argument_count.gd2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/stringify.gd1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/stringify.out1
-rw-r--r--modules/gdscript/tests/test_gdscript.cpp6
31 files changed, 169 insertions, 61 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 73abf71bde..19b264d764 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -678,6 +678,27 @@ Error GDScript::_static_init() {
#ifdef TOOLS_ENABLED
+void GDScript::_static_default_init() {
+ for (const KeyValue<StringName, MemberInfo> &E : static_variables_indices) {
+ const GDScriptDataType &type = E.value.data_type;
+ // Only initialize builtin types, which are not expected to be `null`.
+ if (!type.has_type || type.kind != GDScriptDataType::BUILTIN) {
+ continue;
+ }
+ if (type.builtin_type == Variant::ARRAY && type.has_container_element_type(0)) {
+ Array default_value;
+ const GDScriptDataType &element_type = type.get_container_element_type(0);
+ default_value.set_typed(element_type.builtin_type, element_type.native_type, element_type.script_type);
+ static_variables.write[E.value.index] = default_value;
+ } else {
+ Variant default_value;
+ Callable::CallError err;
+ Variant::construct(type.builtin_type, default_value, nullptr, 0, err);
+ static_variables.write[E.value.index] = default_value;
+ }
+ }
+}
+
void GDScript::_save_old_static_data() {
old_static_variables_indices = static_variables_indices;
old_static_variables = static_variables;
@@ -841,6 +862,9 @@ Error GDScript::reload(bool p_keep_state) {
#ifdef TOOLS_ENABLED
if (can_run && p_keep_state) {
_restore_old_static_data();
+ } else if (!can_run) {
+ // Initialize static variables with sane default values even if the constructor isn't called.
+ _static_default_init();
}
#endif
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 51267ecb84..f63b0da745 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -169,6 +169,9 @@ private:
GDScriptFunction *static_initializer = nullptr;
Error _static_init();
+#ifdef TOOLS_ENABLED
+ void _static_default_init(); // Initialize static variables with default values based on their types.
+#endif
int subclass_count = 0;
RBSet<Object *> instances;
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index ec20811385..4b6cc47218 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -3030,6 +3030,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
+ case Variant::PACKED_VECTOR4_ARRAY:
safe_to_fold = false;
break;
default:
@@ -3128,24 +3129,28 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
bool types_match = true;
- for (int i = 0; i < p_call->arguments.size(); i++) {
- GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
- GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
- if (!is_type_compatible(par_type, arg_type, true)) {
- types_match = false;
- break;
+ {
+ List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
+ for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
+ GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
+ GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
+ if (!is_type_compatible(par_type, arg_type, true)) {
+ types_match = false;
+ break;
#ifdef DEBUG_ENABLED
- } else {
- if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
- parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
- }
+ } else {
+ if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
+ parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
+ }
#endif
+ }
}
}
if (types_match) {
- for (int i = 0; i < p_call->arguments.size(); i++) {
- GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
+ List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
+ for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
+ GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
if (p_call->arguments[i]->is_constant) {
update_const_expression_builtin_type(p_call->arguments[i], par_type, "pass");
}
@@ -3365,8 +3370,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
// If the function requires typed arrays we must make literals be typed.
for (const KeyValue<int, GDScriptParser::ArrayNode *> &E : arrays) {
int index = E.key;
- if (index < par_types.size() && par_types[index].is_hard_type() && par_types[index].has_container_element_type(0)) {
- update_array_literal_element_type(E.value, par_types[index].get_container_element_type(0));
+ if (index < par_types.size() && par_types.get(index).is_hard_type() && par_types.get(index).has_container_element_type(0)) {
+ update_array_literal_element_type(E.value, par_types.get(index).get_container_element_type(0));
}
}
validate_call_arg(par_types, default_arg_count, method_flags.has_flag(METHOD_FLAG_VARARG), p_call);
@@ -4425,7 +4430,6 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
switch (base_type.builtin_type) {
// Expect int or real as index.
case Variant::PACKED_BYTE_ARRAY:
- case Variant::PACKED_COLOR_ARRAY:
case Variant::PACKED_FLOAT32_ARRAY:
case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_INT32_ARRAY:
@@ -4433,6 +4437,8 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::PACKED_VECTOR4_ARRAY:
case Variant::ARRAY:
case Variant::STRING:
error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::FLOAT;
@@ -4531,10 +4537,6 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
case Variant::QUATERNION:
result_type.builtin_type = Variant::FLOAT;
break;
- // Return Color.
- case Variant::PACKED_COLOR_ARRAY:
- result_type.builtin_type = Variant::COLOR;
- break;
// Return String.
case Variant::PACKED_STRING_ARRAY:
case Variant::STRING:
@@ -4556,6 +4558,14 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
case Variant::BASIS:
result_type.builtin_type = Variant::VECTOR3;
break;
+ // Return Color.
+ case Variant::PACKED_COLOR_ARRAY:
+ result_type.builtin_type = Variant::COLOR;
+ break;
+ // Return Vector4.
+ case Variant::PACKED_VECTOR4_ARRAY:
+ result_type.builtin_type = Variant::VECTOR4;
+ break;
// Depends on the index.
case Variant::TRANSFORM3D:
case Variant::PROJECTION:
@@ -5219,12 +5229,13 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
push_error(vformat(R"*(Too many arguments for "%s()" call. Expected at most %d but received %d.)*", p_call->function_name, p_par_types.size(), p_call->arguments.size()), p_call->arguments[p_par_types.size()]);
}
- for (int i = 0; i < p_call->arguments.size(); i++) {
+ List<GDScriptParser::DataType>::ConstIterator par_itr = p_par_types.begin();
+ for (int i = 0; i < p_call->arguments.size(); ++par_itr, ++i) {
if (i >= p_par_types.size()) {
// Already on vararg place.
break;
}
- GDScriptParser::DataType par_type = p_par_types[i];
+ GDScriptParser::DataType par_type = *par_itr;
if (par_type.is_hard_type() && p_call->arguments[i]->is_constant) {
update_const_expression_builtin_type(p_call->arguments[i], par_type, "pass");
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index 5a50bd8648..4cda3d3037 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -109,6 +109,7 @@ uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
+ case Variant::PACKED_VECTOR4_ARRAY:
case Variant::VARIANT_MAX:
// Arrays, dictionaries, and objects are reference counted, so we don't use the pool for them.
temp_type = Variant::NIL;
@@ -543,6 +544,9 @@ void GDScriptByteCodeGenerator::write_type_adjust(const Address &p_target, Varia
case Variant::PACKED_COLOR_ARRAY:
append_opcode(GDScriptFunction::OPCODE_TYPE_ADJUST_PACKED_COLOR_ARRAY);
break;
+ case Variant::PACKED_VECTOR4_ARRAY:
+ append_opcode(GDScriptFunction::OPCODE_TYPE_ADJUST_PACKED_VECTOR4_ARRAY);
+ break;
case Variant::NIL:
case Variant::VARIANT_MAX:
return;
@@ -1573,6 +1577,10 @@ void GDScriptByteCodeGenerator::write_for(const Address &p_variable, bool p_use_
begin_opcode = GDScriptFunction::OPCODE_ITERATE_BEGIN_PACKED_COLOR_ARRAY;
iterate_opcode = GDScriptFunction::OPCODE_ITERATE_PACKED_COLOR_ARRAY;
break;
+ case Variant::PACKED_VECTOR4_ARRAY:
+ begin_opcode = GDScriptFunction::OPCODE_ITERATE_BEGIN_PACKED_VECTOR4_ARRAY;
+ iterate_opcode = GDScriptFunction::OPCODE_ITERATE_PACKED_VECTOR4_ARRAY;
+ break;
default:
break;
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index a8a7f3d9f7..01e5751dc8 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -241,9 +241,9 @@ static bool _can_use_validate_call(const MethodBind *p_method, const Vector<GDSc
}
MethodInfo info;
ClassDB::get_method_info(p_method->get_instance_class(), p_method->get_name(), &info);
- for (int i = 0; i < p_arguments.size(); i++) {
- const PropertyInfo &prop = info.arguments[i];
- if (!_is_exact_type(prop, p_arguments[i].type)) {
+ int i = 0;
+ for (List<PropertyInfo>::ConstIterator itr = info.arguments.begin(); itr != info.arguments.end(); ++itr, ++i) {
+ if (!_is_exact_type(*itr, p_arguments[i].type)) {
return false;
}
}
@@ -2666,7 +2666,10 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
GDScriptDataType base_type = _gdtype_from_datatype(p_class->base_type, p_script, false);
+ ERR_FAIL_COND_V_MSG(base_type.native_type == StringName(), ERR_BUG, vformat(R"(Failed to get base class for "%s")", p_script->path));
+
int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type];
+
p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx];
ERR_FAIL_COND_V(p_script->native.is_null(), ERR_BUG);
diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp
index 8dd04c76dd..0331045078 100644
--- a/modules/gdscript/gdscript_disassembler.cpp
+++ b/modules/gdscript/gdscript_disassembler.cpp
@@ -1046,6 +1046,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
m_macro(PACKED_VECTOR2_ARRAY); \
m_macro(PACKED_VECTOR3_ARRAY); \
m_macro(PACKED_COLOR_ARRAY); \
+ m_macro(PACKED_VECTOR4_ARRAY); \
m_macro(OBJECT)
case OPCODE_ITERATE_BEGIN: {
@@ -1150,6 +1151,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
DISASSEMBLE_TYPE_ADJUST(PACKED_VECTOR2_ARRAY);
DISASSEMBLE_TYPE_ADJUST(PACKED_VECTOR3_ARRAY);
DISASSEMBLE_TYPE_ADJUST(PACKED_COLOR_ARRAY);
+ DISASSEMBLE_TYPE_ADJUST(PACKED_VECTOR4_ARRAY);
case OPCODE_ASSERT: {
text += "assert (";
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 74d383c57f..9caf772b5c 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -2733,9 +2733,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
// Handle user preference.
if (opt.is_quoted()) {
opt = opt.unquote().quote(quote_style);
- if (use_string_names && info.arguments[p_argidx].type == Variant::STRING_NAME) {
+ if (use_string_names && info.arguments.get(p_argidx).type == Variant::STRING_NAME) {
opt = opt.indent("&");
- } else if (use_node_paths && info.arguments[p_argidx].type == Variant::NODE_PATH) {
+ } else if (use_node_paths && info.arguments.get(p_argidx).type == Variant::NODE_PATH) {
opt = opt.indent("^");
}
}
@@ -2746,7 +2746,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
if (p_argidx < method_args) {
- PropertyInfo arg_info = info.arguments[p_argidx];
+ const PropertyInfo &arg_info = info.arguments.get(p_argidx);
if (arg_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM | PROPERTY_USAGE_CLASS_IS_BITFIELD)) {
_find_enumeration_candidates(p_context, arg_info.class_name, r_result);
}
@@ -3334,19 +3334,17 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
method_hint += "(";
- if (mi.arguments.size()) {
- for (int i = 0; i < mi.arguments.size(); i++) {
- if (i > 0) {
- method_hint += ", ";
- }
- String arg = mi.arguments[i].name;
- if (arg.contains(":")) {
- arg = arg.substr(0, arg.find(":"));
- }
- method_hint += arg;
- if (use_type_hint) {
- method_hint += ": " + _get_visual_datatype(mi.arguments[i], true, class_name);
- }
+ for (List<PropertyInfo>::ConstIterator arg_itr = mi.arguments.begin(); arg_itr != mi.arguments.end(); ++arg_itr) {
+ if (arg_itr != mi.arguments.begin()) {
+ method_hint += ", ";
+ }
+ String arg = arg_itr->name;
+ if (arg.contains(":")) {
+ arg = arg.substr(0, arg.find(":"));
+ }
+ method_hint += arg;
+ if (use_type_hint) {
+ method_hint += ": " + _get_visual_datatype(*arg_itr, true, class_name);
}
}
method_hint += ")";
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 430b96115b..759e92d68c 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -301,6 +301,7 @@ public:
OPCODE_ITERATE_BEGIN_PACKED_VECTOR2_ARRAY,
OPCODE_ITERATE_BEGIN_PACKED_VECTOR3_ARRAY,
OPCODE_ITERATE_BEGIN_PACKED_COLOR_ARRAY,
+ OPCODE_ITERATE_BEGIN_PACKED_VECTOR4_ARRAY,
OPCODE_ITERATE_BEGIN_OBJECT,
OPCODE_ITERATE,
OPCODE_ITERATE_INT,
@@ -321,6 +322,7 @@ public:
OPCODE_ITERATE_PACKED_VECTOR2_ARRAY,
OPCODE_ITERATE_PACKED_VECTOR3_ARRAY,
OPCODE_ITERATE_PACKED_COLOR_ARRAY,
+ OPCODE_ITERATE_PACKED_VECTOR4_ARRAY,
OPCODE_ITERATE_OBJECT,
OPCODE_STORE_GLOBAL,
OPCODE_STORE_NAMED_GLOBAL,
@@ -361,6 +363,7 @@ public:
OPCODE_TYPE_ADJUST_PACKED_VECTOR2_ARRAY,
OPCODE_TYPE_ADJUST_PACKED_VECTOR3_ARRAY,
OPCODE_TYPE_ADJUST_PACKED_COLOR_ARRAY,
+ OPCODE_TYPE_ADJUST_PACKED_VECTOR4_ARRAY,
OPCODE_ASSERT,
OPCODE_BREAKPOINT,
OPCODE_LINE,
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 9799c6e610..634d4fc867 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -4129,6 +4129,9 @@ static String _get_annotation_error_string(const StringName &p_annotation_name,
case Variant::COLOR:
types.push_back("PackedColorArray");
break;
+ case Variant::VECTOR4:
+ types.push_back("PackedVector4Array");
+ break;
default:
break;
}
@@ -4827,6 +4830,8 @@ static Variant::Type _variant_type_to_typed_array_element_type(Variant::Type p_t
return Variant::VECTOR3;
case Variant::PACKED_COLOR_ARRAY:
return Variant::COLOR;
+ case Variant::PACKED_VECTOR4_ARRAY:
+ return Variant::VECTOR4;
default:
return Variant::NIL;
}
diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp
index e5b0f55df8..3e1de628d2 100644
--- a/modules/gdscript/gdscript_utility_functions.cpp
+++ b/modules/gdscript/gdscript_utility_functions.cpp
@@ -519,6 +519,10 @@ struct GDScriptUtilityFunctionsDefinitions {
Vector<Color> d = *p_args[0];
*r_ret = d.size();
} break;
+ case Variant::PACKED_VECTOR4_ARRAY: {
+ Vector<Vector4> d = *p_args[0];
+ *r_ret = d.size();
+ } break;
default: {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -756,7 +760,7 @@ Variant::Type GDScriptUtilityFunctions::get_function_argument_type(const StringN
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
ERR_FAIL_NULL_V(info, Variant::NIL);
ERR_FAIL_COND_V(p_arg >= info->info.arguments.size(), Variant::NIL);
- return info->info.arguments[p_arg].type;
+ return info->info.arguments.get(p_arg).type;
}
int GDScriptUtilityFunctions::get_function_argument_count(const StringName &p_function) {
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 4e76965889..11bd1d224a 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -208,6 +208,7 @@ void (*type_init_function_table[])(Variant *) = {
&VariantInitializer<PackedVector2Array>::init, // PACKED_VECTOR2_ARRAY.
&VariantInitializer<PackedVector3Array>::init, // PACKED_VECTOR3_ARRAY.
&VariantInitializer<PackedColorArray>::init, // PACKED_COLOR_ARRAY.
+ &VariantInitializer<PackedVector4Array>::init, // PACKED_VECTOR4_ARRAY.
};
#if defined(__GNUC__)
@@ -298,6 +299,7 @@ void (*type_init_function_table[])(Variant *) = {
&&OPCODE_ITERATE_BEGIN_PACKED_VECTOR2_ARRAY, \
&&OPCODE_ITERATE_BEGIN_PACKED_VECTOR3_ARRAY, \
&&OPCODE_ITERATE_BEGIN_PACKED_COLOR_ARRAY, \
+ &&OPCODE_ITERATE_BEGIN_PACKED_VECTOR4_ARRAY, \
&&OPCODE_ITERATE_BEGIN_OBJECT, \
&&OPCODE_ITERATE, \
&&OPCODE_ITERATE_INT, \
@@ -318,6 +320,7 @@ void (*type_init_function_table[])(Variant *) = {
&&OPCODE_ITERATE_PACKED_VECTOR2_ARRAY, \
&&OPCODE_ITERATE_PACKED_VECTOR3_ARRAY, \
&&OPCODE_ITERATE_PACKED_COLOR_ARRAY, \
+ &&OPCODE_ITERATE_PACKED_VECTOR4_ARRAY, \
&&OPCODE_ITERATE_OBJECT, \
&&OPCODE_STORE_GLOBAL, \
&&OPCODE_STORE_NAMED_GLOBAL, \
@@ -358,6 +361,7 @@ void (*type_init_function_table[])(Variant *) = {
&&OPCODE_TYPE_ADJUST_PACKED_VECTOR2_ARRAY, \
&&OPCODE_TYPE_ADJUST_PACKED_VECTOR3_ARRAY, \
&&OPCODE_TYPE_ADJUST_PACKED_COLOR_ARRAY, \
+ &&OPCODE_TYPE_ADJUST_PACKED_VECTOR4_ARRAY, \
&&OPCODE_ASSERT, \
&&OPCODE_BREAKPOINT, \
&&OPCODE_LINE, \
@@ -430,6 +434,7 @@ void (*type_init_function_table[])(Variant *) = {
#define OP_GET_PACKED_VECTOR2_ARRAY get_vector2_array
#define OP_GET_PACKED_VECTOR3_ARRAY get_vector3_array
#define OP_GET_PACKED_COLOR_ARRAY get_color_array
+#define OP_GET_PACKED_VECTOR4_ARRAY get_vector4_array
#define OP_GET_TRANSFORM3D get_transform
#define OP_GET_TRANSFORM2D get_transform2d
#define OP_GET_PROJECTION get_projection
@@ -3059,6 +3064,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_ITERATE_BEGIN_PACKED_ARRAY(VECTOR2, Vector2, get_vector2_array, VECTOR2, Vector2, get_vector2);
OPCODE_ITERATE_BEGIN_PACKED_ARRAY(VECTOR3, Vector3, get_vector3_array, VECTOR3, Vector3, get_vector3);
OPCODE_ITERATE_BEGIN_PACKED_ARRAY(COLOR, Color, get_color_array, COLOR, Color, get_color);
+ OPCODE_ITERATE_BEGIN_PACKED_ARRAY(VECTOR4, Vector4, get_vector4_array, VECTOR4, Vector4, get_vector4);
OPCODE(OPCODE_ITERATE_BEGIN_OBJECT) {
CHECK_SPACE(4);
@@ -3394,6 +3400,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_ITERATE_PACKED_ARRAY(VECTOR2, Vector2, get_vector2_array, get_vector2);
OPCODE_ITERATE_PACKED_ARRAY(VECTOR3, Vector3, get_vector3_array, get_vector3);
OPCODE_ITERATE_PACKED_ARRAY(COLOR, Color, get_color_array, get_color);
+ OPCODE_ITERATE_PACKED_ARRAY(VECTOR4, Vector4, get_vector4_array, get_vector4);
OPCODE(OPCODE_ITERATE_OBJECT) {
CHECK_SPACE(4);
@@ -3525,6 +3532,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_TYPE_ADJUST(PACKED_VECTOR2_ARRAY, PackedVector2Array);
OPCODE_TYPE_ADJUST(PACKED_VECTOR3_ARRAY, PackedVector3Array);
OPCODE_TYPE_ADJUST(PACKED_COLOR_ARRAY, PackedColorArray);
+ OPCODE_TYPE_ADJUST(PACKED_VECTOR4_ARRAY, PackedVector4Array);
OPCODE(OPCODE_ASSERT) {
CHECK_SPACE(3);
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index ad7af34bf1..2a3db4f508 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -510,7 +510,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
node_stack.push_back(p_func->body);
while (!node_stack.is_empty()) {
- GDScriptParser::Node *node = node_stack[0];
+ GDScriptParser::Node *node = node_stack.front()->get();
node_stack.pop_front();
switch (node->type) {
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index a63d32ef30..819611099e 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -223,7 +223,7 @@ void GDScriptWorkspace::reload_all_workspace_scripts() {
HashMap<String, ExtendGDScriptParser *>::Iterator S = parse_results.find(path);
String err_msg = "Failed parse script " + path;
if (S) {
- err_msg += "\n" + S->value->get_errors()[0].message;
+ err_msg += "\n" + S->value->get_errors().front()->get().message;
}
ERR_CONTINUE_MSG(err != OK, err_msg);
}
@@ -619,8 +619,8 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
_get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners);
- for (int i = 0; i < owners.size(); i++) {
- NodePath owner_path = owners[i];
+ for (const String &owner : owners) {
+ NodePath owner_path = owner;
Ref<Resource> owner_res = ResourceLoader::load(owner_path);
if (Object::cast_to<PackedScene>(owner_res.ptr())) {
Ref<PackedScene> owner_packed_scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*owner_res));
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index e3d16eaf42..a949c44d78 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -573,7 +573,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
if (!errors.is_empty()) {
// Only the first error since the following might be cascading.
- result.output += errors[0].message + "\n"; // TODO: line, column?
+ result.output += errors.front()->get().message + "\n"; // TODO: line, column?
}
if (!p_is_generating) {
result.passed = check_output(result.output);
@@ -592,7 +592,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
if (!errors.is_empty()) {
// Only the first error since the following might be cascading.
- result.output += errors[0].message + "\n"; // TODO: line, column?
+ result.output += errors.front()->get().message + "\n"; // TODO: line, column?
}
if (!p_is_generating) {
result.passed = check_output(result.output);
diff --git a/modules/gdscript/tests/gdscript_test_runner_suite.h b/modules/gdscript/tests/gdscript_test_runner_suite.h
index b2289ef9cc..d6befd2db3 100644
--- a/modules/gdscript/tests/gdscript_test_runner_suite.h
+++ b/modules/gdscript/tests/gdscript_test_runner_suite.h
@@ -81,11 +81,10 @@ TEST_CASE("[Modules][GDScript] Validate built-in API") {
SUBCASE("[Modules][GDScript] Validate built-in methods") {
for (const MethodInfo &mi : builtin_methods) {
- for (int j = 0; j < mi.arguments.size(); j++) {
- PropertyInfo arg = mi.arguments[j];
-
- TEST_COND((arg.name.is_empty() || arg.name.begins_with("_unnamed_arg")),
- vformat("Unnamed argument in position %d of built-in method '%s'.", j, mi.name));
+ int i = 0;
+ for (List<PropertyInfo>::ConstIterator itr = mi.arguments.begin(); itr != mi.arguments.end(); ++itr, ++i) {
+ TEST_COND((itr->name.is_empty() || itr->name.begins_with("_unnamed_arg")),
+ vformat("Unnamed argument in position %d of built-in method '%s'.", i, mi.name));
}
}
}
@@ -96,11 +95,10 @@ TEST_CASE("[Modules][GDScript] Validate built-in API") {
SUBCASE("[Modules][GDScript] Validate built-in annotations") {
for (const MethodInfo &ai : builtin_annotations) {
- for (int j = 0; j < ai.arguments.size(); j++) {
- PropertyInfo arg = ai.arguments[j];
-
- TEST_COND((arg.name.is_empty() || arg.name.begins_with("_unnamed_arg")),
- vformat("Unnamed argument in position %d of built-in annotation '%s'.", j, ai.name));
+ int i = 0;
+ for (List<PropertyInfo>::ConstIterator itr = ai.arguments.begin(); itr != ai.arguments.end(); ++itr, ++i) {
+ TEST_COND((itr->name.is_empty() || itr->name.begins_with("_unnamed_arg")),
+ vformat("Unnamed argument in position %d of built-in annotation '%s'.", i, ai.name));
}
}
}
diff --git a/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.gd b/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.gd
index 73d0f9096c..18675e5725 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.gd
@@ -345,3 +345,12 @@ func test():
prints(x and true)
prints(x or false)
prints(x or true)
+
+ # TYPE_PACKED_VECTOR4_ARRAY
+ x = PackedVector4Array([Vector4.ONE])
+ prints("TYPE_PACKED_VECTOR4_ARRAY")
+ prints(not x)
+ prints(x and false)
+ prints(x and true)
+ prints(x or false)
+ prints(x or true)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.out b/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.out
index e2945c910a..47f9d7548b 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.out
+++ b/modules/gdscript/tests/scripts/analyzer/features/boolean_operators_for_all_types.out
@@ -227,3 +227,9 @@ false
true
true
true
+TYPE_PACKED_VECTOR4_ARRAY
+false
+false
+true
+true
+true
diff --git a/modules/gdscript/tests/scripts/parser/features/export_arrays.gd b/modules/gdscript/tests/scripts/parser/features/export_arrays.gd
index ddfb186aa4..0d97135a7b 100644
--- a/modules/gdscript/tests/scripts/parser/features/export_arrays.gd
+++ b/modules/gdscript/tests/scripts/parser/features/export_arrays.gd
@@ -63,6 +63,7 @@ var temp_packed_float64_array: PackedFloat64Array
var temp_packed_color_array: PackedColorArray
var temp_packed_vector2_array: PackedVector2Array
var temp_packed_vector3_array: PackedVector3Array
+var temp_packed_vector4_array: PackedVector4Array
@export var test_weak_packed_byte_array = temp_packed_byte_array
@export var test_weak_packed_int32_array = temp_packed_int32_array
@@ -72,6 +73,7 @@ var temp_packed_vector3_array: PackedVector3Array
@export var test_weak_packed_color_array = temp_packed_color_array
@export var test_weak_packed_vector2_array = temp_packed_vector2_array
@export var test_weak_packed_vector3_array = temp_packed_vector3_array
+@export var test_weak_packed_vector4_array = temp_packed_vector4_array
@export_range(1, 10) var test_range_weak_packed_byte_array = temp_packed_byte_array
@export_range(1, 10) var test_range_weak_packed_int32_array = temp_packed_int32_array
diff --git a/modules/gdscript/tests/scripts/parser/features/export_arrays.out b/modules/gdscript/tests/scripts/parser/features/export_arrays.out
index 00e75fcc43..acbf389645 100644
--- a/modules/gdscript/tests/scripts/parser/features/export_arrays.out
+++ b/modules/gdscript/tests/scripts/parser/features/export_arrays.out
@@ -123,6 +123,8 @@ var test_weak_packed_vector2_array: PackedVector2Array
hint=TYPE_STRING hint_string="Vector2:Vector2" usage=DEFAULT|SCRIPT_VARIABLE
var test_weak_packed_vector3_array: PackedVector3Array
hint=TYPE_STRING hint_string="Vector3:Vector3" usage=DEFAULT|SCRIPT_VARIABLE
+var test_weak_packed_vector4_array: PackedVector4Array
+ hint=TYPE_STRING hint_string="Vector4:Vector4" usage=DEFAULT|SCRIPT_VARIABLE
var test_range_weak_packed_byte_array: PackedByteArray
hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE
var test_range_weak_packed_int32_array: PackedInt32Array
diff --git a/modules/gdscript/tests/scripts/runtime/features/argument_count.gd b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd
index c67ce25cbe..104489cfe6 100644
--- a/modules/gdscript/tests/scripts/runtime/features/argument_count.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd
@@ -57,7 +57,7 @@ func test():
var lambda_callable_2 : Callable = func(_foo, _bar, _baz): pass
print(lambda_callable_2.get_argument_count()) # Should print 3.
- # Test lambas with self.
+ # Test lambdas with self.
var lambda_self_callable_1 : Callable = func(_foo, _bar): return self
print(lambda_self_callable_1.get_argument_count()) # Should print 2.
var lambda_self_callable_2 : Callable = func(_foo, _bar, _baz): return self
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd
index 809d0d28a9..5d8dafc4a1 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd
@@ -140,3 +140,7 @@ func test():
# PackedColorArray
value = PackedColorArray()
print(value == null)
+
+ # PackedVector4Array
+ value = PackedVector4Array()
+ print(value == null)
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out
index 27423ab8e7..e0e222eccc 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out
@@ -34,3 +34,4 @@ false
false
false
false
+false
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd
index f46afb0f18..88286ede03 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd
@@ -140,3 +140,7 @@ func test():
# PackedColorArray
value = PackedColorArray()
print(value != null)
+
+ # PackedVector4Array
+ value = PackedVector4Array()
+ print(value != null)
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out
index a11c47854a..f6e72aedd5 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out
@@ -34,3 +34,4 @@ true
true
true
true
+true
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd
index 7649062fda..6ca1b3e490 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd
@@ -136,3 +136,7 @@ func test():
# PackedColorArray
value = PackedColorArray()
print(null == value)
+
+ # PackedVector4Array
+ value = PackedVector4Array()
+ print(null == value)
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out
index 639f6027b9..27423ab8e7 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out
@@ -33,3 +33,4 @@ false
false
false
false
+false
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd
index 8d5f9df1b8..d7addfa390 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd
@@ -136,3 +136,7 @@ func test():
# PackedColorArray
value = PackedColorArray()
print(null != value)
+
+ # PackedVector4Array
+ value = PackedVector4Array()
+ print(null != value)
diff --git a/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out
index d1e332afba..a11c47854a 100644
--- a/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out
+++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out
@@ -33,3 +33,4 @@ true
true
true
true
+true
diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.gd b/modules/gdscript/tests/scripts/runtime/features/stringify.gd
index 0dbb252b0e..8579baf876 100644
--- a/modules/gdscript/tests/scripts/runtime/features/stringify.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/stringify.gd
@@ -40,3 +40,4 @@ func test():
print(PackedVector2Array([Vector2.ONE, Vector2.ZERO]))
print(PackedVector3Array([Vector3.ONE, Vector3.ZERO]))
print(PackedColorArray([Color.RED, Color.BLUE, Color.GREEN]))
+ print(PackedVector4Array([Vector4.ONE, Vector4.ZERO]))
diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.out b/modules/gdscript/tests/scripts/runtime/features/stringify.out
index 1f33de00cc..7833b6e213 100644
--- a/modules/gdscript/tests/scripts/runtime/features/stringify.out
+++ b/modules/gdscript/tests/scripts/runtime/features/stringify.out
@@ -32,3 +32,4 @@ Node::[signal]property_list_changed
[(1, 1), (0, 0)]
[(1, 1, 1), (0, 0, 0)]
[(1, 0, 0, 1), (0, 0, 1, 1), (0, 1, 0, 1)]
+[(1, 1, 1, 1), (0, 0, 0, 0)]
diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp
index f6965cf7cf..fbc72a0508 100644
--- a/modules/gdscript/tests/test_gdscript.cpp
+++ b/modules/gdscript/tests/test_gdscript.cpp
@@ -188,11 +188,11 @@ static void recursively_disassemble_functions(const Ref<GDScript> script, const
const MethodInfo &mi = func->get_method_info();
String signature = "Disassembling " + mi.name + "(";
- for (int i = 0; i < mi.arguments.size(); i++) {
- if (i > 0) {
+ for (List<PropertyInfo>::ConstIterator arg_itr = mi.arguments.begin(); arg_itr != mi.arguments.end(); ++arg_itr) {
+ if (arg_itr != mi.arguments.begin()) {
signature += ", ";
}
- signature += mi.arguments[i].name;
+ signature += arg_itr->name;
}
print_line(signature + ")");
#ifdef TOOLS_ENABLED