|
@@ -122,6 +122,9 @@ public:
|
|
RegEx keyword_gdscript_master = RegEx("^master func");
|
|
RegEx keyword_gdscript_master = RegEx("^master func");
|
|
RegEx keyword_gdscript_mastersync = RegEx("^mastersync func");
|
|
RegEx keyword_gdscript_mastersync = RegEx("^mastersync func");
|
|
|
|
|
|
|
|
+ RegEx gdscript_comment = RegEx("^\\s*#");
|
|
|
|
+ RegEx csharp_comment = RegEx("^\\s*\\/\\/");
|
|
|
|
+
|
|
// CSharp keywords.
|
|
// CSharp keywords.
|
|
RegEx keyword_csharp_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]");
|
|
RegEx keyword_csharp_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]");
|
|
RegEx keyword_csharp_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]");
|
|
RegEx keyword_csharp_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]");
|
|
@@ -139,6 +142,9 @@ public:
|
|
LocalVector<RegEx *> class_gd_regexes;
|
|
LocalVector<RegEx *> class_gd_regexes;
|
|
LocalVector<RegEx *> class_shader_regexes;
|
|
LocalVector<RegEx *> class_shader_regexes;
|
|
|
|
|
|
|
|
+ // Keycode.
|
|
|
|
+ RegEx input_map_keycode = RegEx("\\b,\"((physical_)?)scancode\":(\\d+)\\b");
|
|
|
|
+
|
|
LocalVector<RegEx *> class_regexes;
|
|
LocalVector<RegEx *> class_regexes;
|
|
|
|
|
|
RegEx class_temp_tscn = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b");
|
|
RegEx class_temp_tscn = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b");
|
|
@@ -304,7 +310,7 @@ bool ProjectConverter3To4::convert() {
|
|
maximum_line_length = 10000; // Use only for tests bigger value, to not break them.
|
|
maximum_line_length = 10000; // Use only for tests bigger value, to not break them.
|
|
|
|
|
|
ERR_FAIL_COND_V_MSG(!test_array_names(), false, "Cannot start converting due to problems with data in arrays.");
|
|
ERR_FAIL_COND_V_MSG(!test_array_names(), false, "Cannot start converting due to problems with data in arrays.");
|
|
- ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), false, "Cannot start converting due to problems with converting arrays.");
|
|
|
|
|
|
+ ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), false, "Aborting conversion due to validation tests failing");
|
|
|
|
|
|
maximum_line_length = cached_maximum_line_length;
|
|
maximum_line_length = cached_maximum_line_length;
|
|
|
|
|
|
@@ -334,17 +340,21 @@ bool ProjectConverter3To4::convert() {
|
|
// Check file by file.
|
|
// Check file by file.
|
|
for (int i = 0; i < collected_files.size(); i++) {
|
|
for (int i = 0; i < collected_files.size(); i++) {
|
|
String file_name = collected_files[i];
|
|
String file_name = collected_files[i];
|
|
- Vector<String> lines;
|
|
|
|
|
|
+ Vector<SourceLine> source_lines;
|
|
uint32_t ignored_lines = 0;
|
|
uint32_t ignored_lines = 0;
|
|
{
|
|
{
|
|
Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ);
|
|
Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ);
|
|
ERR_CONTINUE_MSG(file.is_null(), vformat("Unable to read content of \"%s\".", file_name));
|
|
ERR_CONTINUE_MSG(file.is_null(), vformat("Unable to read content of \"%s\".", file_name));
|
|
while (!file->eof_reached()) {
|
|
while (!file->eof_reached()) {
|
|
String line = file->get_line();
|
|
String line = file->get_line();
|
|
- lines.append(line);
|
|
|
|
|
|
+
|
|
|
|
+ SourceLine source_line;
|
|
|
|
+ source_line.line = line;
|
|
|
|
+ source_line.is_comment = reg_container.gdscript_comment.search_all(line).size() > 0 || reg_container.csharp_comment.search_all(line).size() > 0;
|
|
|
|
+ source_lines.append(source_line);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- String file_content_before = collect_string_from_vector(lines);
|
|
|
|
|
|
+ String file_content_before = collect_string_from_vector(source_lines);
|
|
uint64_t hash_before = file_content_before.hash();
|
|
uint64_t hash_before = file_content_before.hash();
|
|
uint64_t file_size = file_content_before.size();
|
|
uint64_t file_size = file_content_before.size();
|
|
print_line(vformat("Trying to convert\t%d/%d file - \"%s\" with size - %d KB", i + 1, collected_files.size(), file_name.trim_prefix("res://"), file_size / 1024));
|
|
print_line(vformat("Trying to convert\t%d/%d file - \"%s\" with size - %d KB", i + 1, collected_files.size(), file_name.trim_prefix("res://"), file_size / 1024));
|
|
@@ -361,67 +371,71 @@ bool ProjectConverter3To4::convert() {
|
|
if (file_size < uint64_t(maximum_file_size)) {
|
|
if (file_size < uint64_t(maximum_file_size)) {
|
|
// ".tscn" must work exactly the same as ".gd" files because they may contain built-in Scripts.
|
|
// ".tscn" must work exactly the same as ".gd" files because they may contain built-in Scripts.
|
|
if (file_name.ends_with(".gd")) {
|
|
if (file_name.ends_with(".gd")) {
|
|
- rename_classes(lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
+ fix_tool_declaration(source_lines, reg_container);
|
|
|
|
+
|
|
|
|
+ rename_classes(source_lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::enum_renames, reg_container.enum_regexes, lines);
|
|
|
|
- rename_colors(lines, reg_container); // Require to additional rename.
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::enum_renames, reg_container.enum_regexes, source_lines);
|
|
|
|
+ rename_colors(source_lines, reg_container); // Require to additional rename.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, lines);
|
|
|
|
- rename_gdscript_functions(lines, reg_container, false); // Require to additional rename.
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, source_lines);
|
|
|
|
+ rename_gdscript_functions(source_lines, reg_container, false); // Require to additional rename.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::project_settings_renames, reg_container.project_settings_regexes, lines);
|
|
|
|
- rename_gdscript_keywords(lines, reg_container);
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines);
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::project_settings_renames, reg_container.project_settings_regexes, source_lines);
|
|
|
|
+ rename_gdscript_keywords(source_lines, reg_container);
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_properties_renames, reg_container.gdscript_properties_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines);
|
|
|
|
|
|
- custom_rename(lines, "\\.shader", ".gdshader");
|
|
|
|
|
|
+ custom_rename(source_lines, "\\.shader", ".gdshader");
|
|
} else if (file_name.ends_with(".tscn")) {
|
|
} else if (file_name.ends_with(".tscn")) {
|
|
- rename_classes(lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
+ rename_classes(source_lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::enum_renames, reg_container.enum_regexes, lines);
|
|
|
|
- rename_colors(lines, reg_container); // Require to do additional renames.
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::enum_renames, reg_container.enum_regexes, source_lines);
|
|
|
|
+ rename_colors(source_lines, reg_container); // Require to do additional renames.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, lines);
|
|
|
|
- rename_gdscript_functions(lines, reg_container, true); // Require to do additional renames.
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, source_lines);
|
|
|
|
+ rename_gdscript_functions(source_lines, reg_container, true); // Require to do additional renames.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::project_settings_renames, reg_container.project_settings_regexes, lines);
|
|
|
|
- rename_gdscript_keywords(lines, reg_container);
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines);
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::project_settings_renames, reg_container.project_settings_regexes, source_lines);
|
|
|
|
+ rename_gdscript_keywords(source_lines, reg_container);
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_properties_renames, reg_container.gdscript_properties_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines);
|
|
|
|
|
|
- custom_rename(lines, "\\.shader", ".gdshader");
|
|
|
|
|
|
+ custom_rename(source_lines, "\\.shader", ".gdshader");
|
|
} else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods.
|
|
} else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods.
|
|
- rename_classes(lines, reg_container); // Using only specialized function.
|
|
|
|
- rename_common(RenamesMap3To4::csharp_function_renames, reg_container.csharp_function_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::csharp_properties_renames, reg_container.csharp_properties_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::csharp_signals_renames, reg_container.csharp_signal_regexes, lines);
|
|
|
|
- rename_csharp_functions(lines, reg_container);
|
|
|
|
- rename_csharp_attributes(lines, reg_container);
|
|
|
|
- custom_rename(lines, "public class ", "public partial class ");
|
|
|
|
|
|
+ rename_classes(source_lines, reg_container); // Using only specialized function.
|
|
|
|
+ rename_common(RenamesMap3To4::csharp_function_renames, reg_container.csharp_function_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::csharp_properties_renames, reg_container.csharp_properties_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::csharp_signals_renames, reg_container.csharp_signal_regexes, source_lines);
|
|
|
|
+ rename_csharp_functions(source_lines, reg_container);
|
|
|
|
+ rename_csharp_attributes(source_lines, reg_container);
|
|
|
|
+ custom_rename(source_lines, "public class ", "public partial class ");
|
|
} else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) {
|
|
} else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) {
|
|
- rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines);
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines);
|
|
} else if (file_name.ends_with("tres")) {
|
|
} else if (file_name.ends_with("tres")) {
|
|
- rename_classes(lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
+ rename_classes(source_lines, reg_container); // Using only specialized function.
|
|
|
|
|
|
- rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines);
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines);
|
|
|
|
|
|
- custom_rename(lines, "\\.shader", ".gdshader");
|
|
|
|
|
|
+ custom_rename(source_lines, "\\.shader", ".gdshader");
|
|
} else if (file_name.ends_with("project.godot")) {
|
|
} else if (file_name.ends_with("project.godot")) {
|
|
- rename_common(RenamesMap3To4::project_godot_renames, reg_container.project_godot_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines);
|
|
|
|
- rename_common(RenamesMap3To4::input_map_renames, reg_container.input_map_regexes, lines);
|
|
|
|
|
|
+ rename_common(RenamesMap3To4::project_godot_renames, reg_container.project_godot_regexes, source_lines);
|
|
|
|
+ rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines);
|
|
|
|
+ rename_input_map_scancode(source_lines, reg_container);
|
|
|
|
+ rename_common(RenamesMap3To4::input_map_renames, reg_container.input_map_regexes, source_lines);
|
|
} else if (file_name.ends_with(".csproj")) {
|
|
} else if (file_name.ends_with(".csproj")) {
|
|
// TODO
|
|
// TODO
|
|
} else if (file_name.ends_with(".import")) {
|
|
} else if (file_name.ends_with(".import")) {
|
|
- for (int x = 0; x < lines.size(); x++) {
|
|
|
|
- if (lines[x].contains("nodes/root_type=\"Spatial\"")) {
|
|
|
|
- lines.set(x, "nodes/root_type=\"Node3D\"");
|
|
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ String &line = source_line.line;
|
|
|
|
+ if (line.contains("nodes/root_type=\"Spatial\"")) {
|
|
|
|
+ line = "nodes/root_type=\"Node3D\"";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -429,7 +443,12 @@ bool ProjectConverter3To4::convert() {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) > maximum_line_length) {
|
|
if (uint64_t(line.length()) > maximum_line_length) {
|
|
ignored_lines += 1;
|
|
ignored_lines += 1;
|
|
}
|
|
}
|
|
@@ -444,7 +463,7 @@ bool ProjectConverter3To4::convert() {
|
|
String end_message = vformat(" Checking file took %d ms.", end_time - start_time);
|
|
String end_message = vformat(" Checking file took %d ms.", end_time - start_time);
|
|
print_line(end_message);
|
|
print_line(end_message);
|
|
} else {
|
|
} else {
|
|
- String file_content_after = collect_string_from_vector(lines);
|
|
|
|
|
|
+ String file_content_after = collect_string_from_vector(source_lines);
|
|
uint64_t hash_after = file_content_after.hash64();
|
|
uint64_t hash_after = file_content_after.hash64();
|
|
// Don't need to save file without any changes.
|
|
// Don't need to save file without any changes.
|
|
// Save if this is a shader, because it was renamed.
|
|
// Save if this is a shader, because it was renamed.
|
|
@@ -483,7 +502,7 @@ bool ProjectConverter3To4::validate_conversion() {
|
|
maximum_line_length = 10000; // To avoid breaking the tests, only use this for the their larger value.
|
|
maximum_line_length = 10000; // To avoid breaking the tests, only use this for the their larger value.
|
|
|
|
|
|
ERR_FAIL_COND_V_MSG(!test_array_names(), false, "Cannot start converting due to problems with data in arrays.");
|
|
ERR_FAIL_COND_V_MSG(!test_array_names(), false, "Cannot start converting due to problems with data in arrays.");
|
|
- ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), false, "Cannot start converting due to problems with converting arrays.");
|
|
|
|
|
|
+ ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), false, "Aborting conversion due to validation tests failing");
|
|
|
|
|
|
maximum_line_length = cached_maximum_line_length;
|
|
maximum_line_length = cached_maximum_line_length;
|
|
|
|
|
|
@@ -492,7 +511,7 @@ bool ProjectConverter3To4::validate_conversion() {
|
|
{
|
|
{
|
|
String conventer_text = "; Project was converted by built-in tool to Godot 4.0";
|
|
String conventer_text = "; Project was converted by built-in tool to Godot 4.0";
|
|
|
|
|
|
- ERR_FAIL_COND_V_MSG(!FileAccess::exists("project.godot"), false, "Current directory doesn't contains any Godot 3 project");
|
|
|
|
|
|
+ ERR_FAIL_COND_V_MSG(!FileAccess::exists("project.godot"), false, "Current directory doesn't contain any Godot 3 project");
|
|
|
|
|
|
Error err = OK;
|
|
Error err = OK;
|
|
String project_godot_content = FileAccess::get_file_as_string("project.godot", &err);
|
|
String project_godot_content = FileAccess::get_file_as_string("project.godot", &err);
|
|
@@ -587,6 +606,7 @@ bool ProjectConverter3To4::validate_conversion() {
|
|
} else if (file_name.ends_with("project.godot")) {
|
|
} else if (file_name.ends_with("project.godot")) {
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::project_godot_renames, reg_container.project_godot_regexes, lines));
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::project_godot_renames, reg_container.project_godot_regexes, lines));
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines));
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines));
|
|
|
|
+ changed_elements.append_array(check_for_rename_input_map_scancode(lines, reg_container));
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::input_map_renames, reg_container.input_map_regexes, lines));
|
|
changed_elements.append_array(check_for_rename_common(RenamesMap3To4::input_map_renames, reg_container.input_map_regexes, lines));
|
|
} else if (file_name.ends_with(".csproj")) {
|
|
} else if (file_name.ends_with(".csproj")) {
|
|
// TODO
|
|
// TODO
|
|
@@ -674,9 +694,23 @@ Vector<String> ProjectConverter3To4::check_for_files() {
|
|
return collected_files;
|
|
return collected_files;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Vector<SourceLine> ProjectConverter3To4::split_lines(const String &text) {
|
|
|
|
+ Vector<String> lines = text.split("\n");
|
|
|
|
+ Vector<SourceLine> source_lines;
|
|
|
|
+ for (String &line : lines) {
|
|
|
|
+ SourceLine source_line;
|
|
|
|
+ source_line.line = line;
|
|
|
|
+ source_line.is_comment = false;
|
|
|
|
+
|
|
|
|
+ source_lines.append(source_line);
|
|
|
|
+ }
|
|
|
|
+ return source_lines;
|
|
|
|
+}
|
|
|
|
+
|
|
// Test expected results of gdscript
|
|
// Test expected results of gdscript
|
|
-bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) {
|
|
|
|
- Vector<String> got = name.split("\n");
|
|
|
|
|
|
+bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) {
|
|
|
|
+ Vector<SourceLine> got = split_lines(name);
|
|
|
|
+
|
|
(this->*func)(got, reg_container, builtin_script);
|
|
(this->*func)(got, reg_container, builtin_script);
|
|
String got_str = collect_string_from_vector(got);
|
|
String got_str = collect_string_from_vector(got);
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
@@ -684,8 +718,9 @@ bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container) {
|
|
|
|
- Vector<String> got = name.split("\n");
|
|
|
|
|
|
+bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), String what, const RegExContainer ®_container) {
|
|
|
|
+ Vector<SourceLine> got = split_lines(name);
|
|
|
|
+
|
|
(this->*func)(got, reg_container);
|
|
(this->*func)(got, reg_container);
|
|
String got_str = collect_string_from_vector(got);
|
|
String got_str = collect_string_from_vector(got);
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
@@ -694,7 +729,8 @@ bool ProjectConverter3To4::test_conversion_with_regex(String name, String expect
|
|
}
|
|
}
|
|
|
|
|
|
bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what) {
|
|
bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what) {
|
|
- Vector<String> got = name.split("\n");
|
|
|
|
|
|
+ Vector<SourceLine> got = split_lines(name);
|
|
|
|
+
|
|
rename_common(array, regex_cache, got);
|
|
rename_common(array, regex_cache, got);
|
|
String got_str = collect_string_from_vector(got);
|
|
String got_str = collect_string_from_vector(got);
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
|
|
@@ -706,6 +742,10 @@ bool ProjectConverter3To4::test_conversion_basic(String name, String expected, c
|
|
bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
bool valid = true;
|
|
bool valid = true;
|
|
|
|
|
|
|
|
+ valid = valid && test_conversion_with_regex("tool", "@tool", &ProjectConverter3To4::fix_tool_declaration, "gdscript keyword", reg_container);
|
|
|
|
+ valid = valid && test_conversion_with_regex("\n tool", "\n tool", &ProjectConverter3To4::fix_tool_declaration, "gdscript keyword", reg_container);
|
|
|
|
+ valid = valid && test_conversion_with_regex("\n\ntool", "@tool\n\n", &ProjectConverter3To4::fix_tool_declaration, "gdscript keyword", reg_container);
|
|
|
|
+
|
|
valid = valid && test_conversion_basic("TYPE_REAL", "TYPE_FLOAT", RenamesMap3To4::enum_renames, reg_container.enum_regexes, "enum");
|
|
valid = valid && test_conversion_basic("TYPE_REAL", "TYPE_FLOAT", RenamesMap3To4::enum_renames, reg_container.enum_regexes, "enum");
|
|
|
|
|
|
valid = valid && test_conversion_basic("can_instance", "can_instantiate", RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, "gdscript function");
|
|
valid = valid && test_conversion_basic("can_instance", "can_instantiate", RenamesMap3To4::gdscript_function_renames, reg_container.gdscript_function_regexes, "gdscript function");
|
|
@@ -730,9 +770,9 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
|
|
|
|
// Custom Renames.
|
|
// Custom Renames.
|
|
|
|
|
|
- valid = valid && test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
|
|
|
|
- valid = valid && test_conversion_with_regex("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
|
|
|
|
- valid = valid && test_conversion_with_regex("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename", reg_container);
|
|
|
|
|
|
+ valid = valid && test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A, new Callable(B, C), D, E, F, G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
|
|
|
|
+ valid = valid && test_conversion_with_regex("(Disconnect(A,B,C) != OK):", "(Disconnect(A, new Callable(B, C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
|
|
|
|
+ valid = valid && test_conversion_with_regex("(IsConnected(A,B,C) != OK):", "(IsConnected(A, new Callable(B, C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename", reg_container);
|
|
|
|
|
|
valid = valid && test_conversion_with_regex("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
|
|
valid = valid && test_conversion_with_regex("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
|
|
valid = valid && test_conversion_with_regex("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
|
|
valid = valid && test_conversion_with_regex("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
|
|
@@ -788,11 +828,11 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
valid = valid && test_conversion_gdscript_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("sort_custom( a , b )", "sort_custom(Callable(a, b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1, 2, 3, 4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
@@ -816,9 +856,6 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
valid = valid && test_conversion_with_regex("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
- valid = valid && test_conversion_with_regex("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
|
|
- valid = valid && test_conversion_with_regex("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
|
|
- valid = valid && test_conversion_with_regex("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
|
|
valid = valid && test_conversion_with_regex("\n\nremote func", "\n\n@rpc(\"any_peer\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\n\nremote func", "\n\n@rpc(\"any_peer\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\n\nremotesync func", "\n\n@rpc(\"any_peer\", \"call_local\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\n\nremotesync func", "\n\n@rpc(\"any_peer\", \"call_local\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\n\nsync func", "\n\n@rpc(\"any_peer\", \"call_local\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
valid = valid && test_conversion_with_regex("\n\nsync func", "\n\n@rpc(\"any_peer\", \"call_local\") func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
|
|
@@ -838,8 +875,8 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
valid = valid && test_conversion_gdscript_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true);
|
|
valid = valid && test_conversion_gdscript_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin(" Transform.xform(Vector3(a,b,c) + Vector3.UP) ", " Transform * (Vector3(a,b,c) + Vector3.UP) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin(" Transform.xform_inv(Vector3(a,b,c) + Vector3.UP) ", " (Vector3(a,b,c) + Vector3.UP) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround
|
|
valid = valid && test_conversion_gdscript_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround
|
|
@@ -864,27 +901,30 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
valid = valid && test_conversion_gdscript_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E]) != OK):", "(connect(A,Callable(B,C).bind(D,E)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C) != OK):", "(connect(A, Callable(B, C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D) != OK):", "(connect(A, Callable(B, C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A, Callable(B, C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E]) != OK):", "(connect(A, Callable(B, C).bind(D,E)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A, Callable(B, C).bind(D,E), F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A, Callable(B, C).bind(D), E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(start(A,B) != OK):", "(start(Callable(A, B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
- valid = valid && test_conversion_gdscript_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A,B).bind(C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A, B).bind(C), D, E, F, G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("disconnect(A,B,C) != OK):", "disconnect(A, Callable(B, C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C) != OK):", "is_connected(A, Callable(B, C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C))", "is_connected(A, Callable(B, C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A, B), C, D, E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A, B).bind(F,G), C, D, E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A, B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A, B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
- valid = valid && test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("func _init(a,b,c).(d,e,f):", "func _init(a,b,c):\n\tsuper(d,e,f)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("func _init(a,b,c).(a.b(),c.d()):", "func _init(a,b,c):\n\tsuper(a.b(),c.d())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int)->void:", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("func _init(a: int).(d,e,f) -> void:", "func _init(a: int) -> void:\n\tsuper(d,e,f)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
@@ -894,18 +934,18 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
valid = valid && test_conversion_gdscript_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item(Vector3(a, b, c), d, e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
- valid = valid && test_conversion_gdscript_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
- valid = valid && test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_local(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a, b, c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a, b, c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_local(Vector3i(a, b, c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
valid = valid && test_conversion_gdscript_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
- valid = valid && test_conversion_gdscript_builtin("draw_rect(a,b,c,d,e).abc", "draw_rect(a,b,c,d).abc# e) TODOGODOT4 Antialiasing argument is missing", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
|
|
|
|
+ valid = valid && test_conversion_gdscript_builtin("draw_rect(a,b,c,d,e).abc", "draw_rect(a, b, c, d).abc# e) TODOGODOT4 Antialiasing argument is missing", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("get_focus_owner()", "get_viewport().gui_get_focus_owner()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("get_focus_owner()", "get_viewport().gui_get_focus_owner()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("button.pressed = 1", "button.button_pressed = 1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("button.pressed = 1", "button.button_pressed = 1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("button.pressed=1", "button.button_pressed=1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
valid = valid && test_conversion_gdscript_builtin("button.pressed=1", "button.button_pressed=1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
|
@@ -913,12 +953,18 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|
|
|
|
|
valid = valid && test_conversion_with_regex("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_colors, "custom rename", reg_container);
|
|
valid = valid && test_conversion_with_regex("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_colors, "custom rename", reg_container);
|
|
|
|
|
|
|
|
+ // Note: Do not change to *scancode*, it is applied before that conversion.
|
|
|
|
+ valid = valid && test_conversion_with_regex("\"device\":-1,\"scancode\":16777231,\"physical_scancode\":16777232", "\"device\":-1,\"scancode\":4194319,\"physical_scancode\":4194320", &ProjectConverter3To4::rename_input_map_scancode, "custom rename", reg_container);
|
|
|
|
+ valid = valid && test_conversion_with_regex("\"device\":-1,\"scancode\":65,\"physical_scancode\":66", "\"device\":-1,\"scancode\":65,\"physical_scancode\":66", &ProjectConverter3To4::rename_input_map_scancode, "custom rename", reg_container);
|
|
|
|
+
|
|
// Custom rule conversion
|
|
// Custom rule conversion
|
|
{
|
|
{
|
|
String from = "instance";
|
|
String from = "instance";
|
|
String to = "instantiate";
|
|
String to = "instantiate";
|
|
String name = "AA.instance()";
|
|
String name = "AA.instance()";
|
|
- Vector<String> got = String("AA.instance()").split("\n");
|
|
|
|
|
|
+
|
|
|
|
+ Vector<SourceLine> got = split_lines(name);
|
|
|
|
+
|
|
String expected = "AA.instantiate()";
|
|
String expected = "AA.instantiate()";
|
|
custom_rename(got, from, to);
|
|
custom_rename(got, from, to);
|
|
String got_str = collect_string_from_vector(got);
|
|
String got_str = collect_string_from_vector(got);
|
|
@@ -1255,13 +1301,13 @@ String ProjectConverter3To4::connect_arguments(const Vector<String> &arguments,
|
|
|
|
|
|
String value;
|
|
String value;
|
|
if (arguments.size() > 0 && from != 0 && from < to) {
|
|
if (arguments.size() > 0 && from != 0 && from < to) {
|
|
- value = ",";
|
|
|
|
|
|
+ value = ", ";
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = from; i < to; i++) {
|
|
for (int i = from; i < to; i++) {
|
|
value += arguments[i];
|
|
value += arguments[i];
|
|
if (i != to - 1) {
|
|
if (i != to - 1) {
|
|
- value += ',';
|
|
|
|
|
|
+ value += ", ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
return value;
|
|
@@ -1342,8 +1388,13 @@ String ProjectConverter3To4::get_object_of_execution(const String &line) const {
|
|
return line.substr(variable_start, (end - variable_start));
|
|
return line.substr(variable_start, (end - variable_start));
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_colors(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_colors(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (line.contains("Color.")) {
|
|
if (line.contains("Color.")) {
|
|
for (unsigned int current_index = 0; RenamesMap3To4::color_renames[current_index][0]; current_index++) {
|
|
for (unsigned int current_index = 0; RenamesMap3To4::color_renames[current_index][0]; current_index++) {
|
|
@@ -1375,8 +1426,24 @@ Vector<String> ProjectConverter3To4::check_for_rename_colors(Vector<String> &lin
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_classes(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+void ProjectConverter3To4::fix_tool_declaration(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
|
|
+ // In godot4, "tool" became "@tool" and must be located at the top of the file
|
|
|
|
+ for (int i = 0; i < source_lines.size(); ++i) {
|
|
|
|
+ if (source_lines[i].line == "tool") {
|
|
|
|
+ source_lines.remove_at(i);
|
|
|
|
+ source_lines.insert(0, { "@tool", false });
|
|
|
|
+ return; // assuming there's at most 1 tool declaration
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ProjectConverter3To4::rename_classes(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
for (unsigned int current_index = 0; RenamesMap3To4::class_renames[current_index][0]; current_index++) {
|
|
for (unsigned int current_index = 0; RenamesMap3To4::class_renames[current_index][0]; current_index++) {
|
|
if (line.contains(RenamesMap3To4::class_renames[current_index][0])) {
|
|
if (line.contains(RenamesMap3To4::class_renames[current_index][0])) {
|
|
@@ -1443,8 +1510,13 @@ Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &li
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) {
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_gdscript_functions(Vector<SourceLine> &source_lines, const RegExContainer ®_container, bool builtin) {
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
process_gdscript_line(line, reg_container, builtin);
|
|
process_gdscript_line(line, reg_container, builtin);
|
|
}
|
|
}
|
|
@@ -1753,7 +1825,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 2) {
|
|
if (parts.size() == 2) {
|
|
- line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + ", " + parts[1] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1767,14 +1839,14 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem
|
|
|
|
|
|
+ // -- draw_line(1,2,3,4,5) -> draw_line(1, 2, 3, 4) CanvasItem
|
|
if (line.contains("draw_line(")) {
|
|
if (line.contains("draw_line(")) {
|
|
int start = line.find("draw_line(");
|
|
int start = line.find("draw_line(");
|
|
int end = get_end_parenthesis(line.substr(start)) + 1;
|
|
int end = get_end_parenthesis(line.substr(start)) + 1;
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 5) {
|
|
if (parts.size() == 5) {
|
|
- line = line.substr(0, start) + "draw_line(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "draw_line(" + parts[0] + ", " + parts[1] + ", " + parts[2] + ", " + parts[3] + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1831,7 +1903,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 1) {
|
|
if (parts.size() == 1) {
|
|
- line = line.substr(0, start) + " * " + parts[0] + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + " * (" + parts[0] + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1846,13 +1918,13 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
int start2 = line.find(object_exec + ".xform");
|
|
int start2 = line.find(object_exec + ".xform");
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 1) {
|
|
if (parts.size() == 1) {
|
|
- line = line.substr(0, start2) + parts[0] + " * " + object_exec + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start2) + "(" + parts[0] + ") * " + object_exec + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // -- "(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) Object
|
|
|
|
|
|
+ // -- "(connect(A,B,C,D,E) != OK):", "(connect(A, Callable(B, C).bind(D), E) Object
|
|
if (line.contains("connect(")) {
|
|
if (line.contains("connect(")) {
|
|
int start = line.find("connect(");
|
|
int start = line.find("connect(");
|
|
// Protection from disconnect
|
|
// Protection from disconnect
|
|
@@ -1861,9 +1933,9 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "connect(" + parts[0] + ", Callable(" + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
} else if (parts.size() >= 4) {
|
|
} else if (parts.size() >= 4) {
|
|
- line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ").bind(" + parts[3].lstrip("[").rstrip("]") + ")" + connect_arguments(parts, 4) + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "connect(" + parts[0] + ", Callable(" + parts[1] + ", " + parts[2] + ").bind(" + parts[3].lstrip(" [").rstrip("] ") + ")" + connect_arguments(parts, 4) + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1875,7 +1947,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "disconnect(" + parts[0] + ", Callable(" + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1886,7 +1958,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "is_connected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "is_connected(" + parts[0] + ", Callable(" + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1898,9 +1970,9 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 5) {
|
|
if (parts.size() == 5) {
|
|
- line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + "," + parts[1] + ")," + parts[2] + "," + parts[3] + "," + parts[4] + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + ", " + parts[1] + "), " + parts[2] + ", " + parts[3] + ", " + parts[4] + ")" + line.substr(end + start);
|
|
} else if (parts.size() >= 6) {
|
|
} else if (parts.size() >= 6) {
|
|
- line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + "," + parts[1] + ").bind(" + connect_arguments(parts, 5).substr(1).lstrip("[").rstrip("]") + ")," + parts[2] + "," + parts[3] + "," + parts[4] + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + ", " + parts[1] + ").bind(" + connect_arguments(parts, 5).substr(1).lstrip(" [").rstrip("] ") + "), " + parts[2] + ", " + parts[3] + ", " + parts[4] + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1911,14 +1983,14 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 2) {
|
|
if (parts.size() == 2) {
|
|
- line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + ", " + parts[1] + "))" + line.substr(end + start);
|
|
} else if (parts.size() >= 3) {
|
|
} else if (parts.size() >= 3) {
|
|
- line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + "," + parts[1] + ").bind(" + connect_arguments(parts, 2).substr(1).lstrip("[").rstrip("]") + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + ", " + parts[1] + ").bind(" + connect_arguments(parts, 2).substr(1).lstrip(" [").rstrip("] ") + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // -- start(a,b) -> start(Callable(a,b)) Thread
|
|
|
|
- // -- start(a,b,c,d) -> start(Callable(a,b).bind(c),d) Thread
|
|
|
|
|
|
+ // -- start(a,b) -> start(Callable(a, b)) Thread
|
|
|
|
+ // -- start(a,b,c,d) -> start(Callable(a, b).bind(c), d) Thread
|
|
if (line.contains("start(")) {
|
|
if (line.contains("start(")) {
|
|
int start = line.find("start(");
|
|
int start = line.find("start(");
|
|
int end = get_end_parenthesis(line.substr(start)) + 1;
|
|
int end = get_end_parenthesis(line.substr(start)) + 1;
|
|
@@ -1927,24 +1999,25 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 2) {
|
|
if (parts.size() == 2) {
|
|
- line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "start(Callable(" + parts[0] + ", " + parts[1] + "))" + line.substr(end + start);
|
|
} else if (parts.size() >= 3) {
|
|
} else if (parts.size() >= 3) {
|
|
- line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + ").bind(" + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "start(Callable(" + parts[0] + ", " + parts[1] + ").bind(" + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589
|
|
|
|
- if (line.contains(" _init(")) {
|
|
|
|
- int start = line.find(" _init(");
|
|
|
|
- if (line.contains(":")) {
|
|
|
|
- int end = line.rfind(":") + 1;
|
|
|
|
- if (end > -1) {
|
|
|
|
- Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
|
|
- line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start);
|
|
|
|
- }
|
|
|
|
|
|
+ // -- func _init(p_x:int).(p_x): -> func _init(p_x:int):\n\tsuper(p_x) Object # https://github.com/godotengine/godot/issues/70542
|
|
|
|
+ if (line.contains(" _init(") && line.rfind(":") > 0) {
|
|
|
|
+ // func _init(p_arg1).(super4, super5, super6)->void:
|
|
|
|
+ // ^--^indent ^super_start super_end^
|
|
|
|
+ int indent = line.count("\t", 0, line.find("func"));
|
|
|
|
+ int super_start = line.find(".(");
|
|
|
|
+ int super_end = line.rfind(")");
|
|
|
|
+ if (super_start > 0 && super_end > super_start) {
|
|
|
|
+ line = line.substr(0, super_start) + line.substr(super_end + 1) + "\n" + String("\t").repeat(indent + 1) + "super" + line.substr(super_start + 1, super_end - super_start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
// assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message
|
|
// assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message
|
|
if (line.contains("assert(")) {
|
|
if (line.contains("assert(")) {
|
|
int start = line.find("assert(");
|
|
int start = line.find("assert(");
|
|
@@ -1974,7 +2047,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() > 2) {
|
|
if (parts.size() > 2) {
|
|
- line = line.substr(0, start) + "set_cell_item( Vector3(" + parts[0] + "," + parts[1] + "," + parts[2] + ") " + connect_arguments(parts, 3) + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "set_cell_item(Vector3(" + parts[0] + ", " + parts[1] + ", " + parts[2] + ")" + connect_arguments(parts, 3).lstrip(" ") + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1985,7 +2058,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + ", " + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1996,7 +2069,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + ", " + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2029,7 +2102,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "map_to_local(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "map_to_local(Vector3i(" + parts[0] + ", " + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
} else if (parts.size() == 1) {
|
|
} else if (parts.size() == 1) {
|
|
line = line.substr(0, start) + "map_to_local(" + parts[0] + ")" + line.substr(end + start);
|
|
line = line.substr(0, start) + "map_to_local(" + parts[0] + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
@@ -2067,7 +2140,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 5) {
|
|
if (parts.size() == 5) {
|
|
- line = line.substr(0, start) + "draw_rect(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start) + "# " + parts[4] + ") TODOGODOT4 Antialiasing argument is missing";
|
|
|
|
|
|
+ line = line.substr(0, start) + "draw_rect(" + parts[0] + ", " + parts[1] + ", " + parts[2] + ", " + parts[3] + ")" + line.substr(end + start) + "# " + parts[4] + ") TODOGODOT4 Antialiasing argument is missing";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2195,6 +2268,10 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|
if (line.contains("_unhandled_key_input(event: InputEventKey)")) {
|
|
if (line.contains("_unhandled_key_input(event: InputEventKey)")) {
|
|
line = line.replace("_unhandled_key_input(event: InputEventKey)", "_unhandled_key_input(event: InputEvent)");
|
|
line = line.replace("_unhandled_key_input(event: InputEventKey)", "_unhandled_key_input(event: InputEvent)");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (line.contains("Engine.editor_hint")) {
|
|
|
|
+ line = line.replace("Engine.editor_hint", "Engine.is_editor_hint()");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) {
|
|
void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) {
|
|
@@ -2220,7 +2297,7 @@ void ProjectConverter3To4::process_csharp_line(String &line, const RegExContaine
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() >= 3) {
|
|
if (parts.size() >= 3) {
|
|
- line = line.substr(0, start) + "Connect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "Connect(" + parts[0] + ", new Callable(" + parts[1] + ", " + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2232,7 +2309,7 @@ void ProjectConverter3To4::process_csharp_line(String &line, const RegExContaine
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "Disconnect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "Disconnect(" + parts[0] + ", new Callable(" + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2243,14 +2320,19 @@ void ProjectConverter3To4::process_csharp_line(String &line, const RegExContaine
|
|
if (end > -1) {
|
|
if (end > -1) {
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
Vector<String> parts = parse_arguments(line.substr(start, end));
|
|
if (parts.size() == 3) {
|
|
if (parts.size() == 3) {
|
|
- line = line.substr(0, start) + "IsConnected(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
|
|
|
|
|
|
+ line = line.substr(0, start) + "IsConnected(" + parts[0] + ", new Callable(" + parts[1] + ", " + parts[2] + "))" + line.substr(end + start);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_csharp_functions(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
process_csharp_line(line, reg_container);
|
|
process_csharp_line(line, reg_container);
|
|
}
|
|
}
|
|
@@ -2275,10 +2357,15 @@ Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<St
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_csharp_attributes(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n";
|
|
static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n";
|
|
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true);
|
|
line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true);
|
|
line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true);
|
|
line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true);
|
|
@@ -2340,14 +2427,16 @@ Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<S
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_gdscript_keywords(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n";
|
|
static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n";
|
|
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
- if (line.contains("tool")) {
|
|
|
|
- line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true);
|
|
|
|
- }
|
|
|
|
if (line.contains("export")) {
|
|
if (line.contains("export")) {
|
|
line = reg_container.keyword_gdscript_export_single.sub(line, "@export", true);
|
|
line = reg_container.keyword_gdscript_export_single.sub(line, "@export", true);
|
|
}
|
|
}
|
|
@@ -2495,10 +2584,73 @@ Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<S
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::custom_rename(Vector<String> &lines, String from, String to) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_input_map_scancode(Vector<SourceLine> &source_lines, const RegExContainer ®_container) {
|
|
|
|
+ // The old Special Key, now colliding with CMD_OR_CTRL.
|
|
|
|
+ const int old_spkey = (1 << 24);
|
|
|
|
+
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
|
|
+ if (uint64_t(line.length()) <= maximum_line_length) {
|
|
|
|
+ TypedArray<RegExMatch> reg_match = reg_container.input_map_keycode.search_all(line);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < reg_match.size(); ++i) {
|
|
|
|
+ Ref<RegExMatch> match = reg_match[i];
|
|
|
|
+ PackedStringArray strings = match->get_strings();
|
|
|
|
+ int key = strings[3].to_int();
|
|
|
|
+
|
|
|
|
+ if (key & old_spkey) {
|
|
|
|
+ // Create new key, clearing old Special Key and setting new one.
|
|
|
|
+ key = (key & ~old_spkey) | (int)Key::SPECIAL;
|
|
|
|
+
|
|
|
|
+ line = line.replace(strings[0], String(",\"") + strings[1] + "scancode\":" + String::num_int64(key));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Vector<String> ProjectConverter3To4::check_for_rename_input_map_scancode(Vector<String> &lines, const RegExContainer ®_container) {
|
|
|
|
+ Vector<String> found_renames;
|
|
|
|
+
|
|
|
|
+ // The old Special Key, now colliding with CMD_OR_CTRL.
|
|
|
|
+ const int old_spkey = (1 << 24);
|
|
|
|
+
|
|
|
|
+ int current_line = 1;
|
|
|
|
+ for (String &line : lines) {
|
|
|
|
+ if (uint64_t(line.length()) <= maximum_line_length) {
|
|
|
|
+ TypedArray<RegExMatch> reg_match = reg_container.input_map_keycode.search_all(line);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < reg_match.size(); ++i) {
|
|
|
|
+ Ref<RegExMatch> match = reg_match[i];
|
|
|
|
+ PackedStringArray strings = match->get_strings();
|
|
|
|
+ int key = strings[3].to_int();
|
|
|
|
+
|
|
|
|
+ if (key & old_spkey) {
|
|
|
|
+ // Create new key, clearing old Special Key and setting new one.
|
|
|
|
+ key = (key & ~old_spkey) | (int)Key::SPECIAL;
|
|
|
|
+
|
|
|
|
+ found_renames.append(line_formatter(current_line, strings[3], String::num_int64(key), line));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ current_line++;
|
|
|
|
+ }
|
|
|
|
+ return found_renames;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, String from, String to) {
|
|
RegEx reg = RegEx(String("\\b") + from + "\\b");
|
|
RegEx reg = RegEx(String("\\b") + from + "\\b");
|
|
CRASH_COND(!reg.is_valid());
|
|
CRASH_COND(!reg.is_valid());
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
line = reg.sub(line, to, true);
|
|
line = reg.sub(line, to, true);
|
|
}
|
|
}
|
|
@@ -2524,8 +2676,13 @@ Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lin
|
|
return found_renames;
|
|
return found_renames;
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) {
|
|
|
|
- for (String &line : lines) {
|
|
|
|
|
|
+void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<SourceLine> &source_lines) {
|
|
|
|
+ for (SourceLine &source_line : source_lines) {
|
|
|
|
+ if (source_line.is_comment) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String &line = source_line.line;
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
if (uint64_t(line.length()) <= maximum_line_length) {
|
|
for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) {
|
|
for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) {
|
|
if (line.contains(array[current_index][0])) {
|
|
if (line.contains(array[current_index][0])) {
|
|
@@ -2595,10 +2752,10 @@ String ProjectConverter3To4::simple_line_formatter(int current_line, String old_
|
|
}
|
|
}
|
|
|
|
|
|
// Collects string from vector strings
|
|
// Collects string from vector strings
|
|
-String ProjectConverter3To4::collect_string_from_vector(Vector<String> &vector) {
|
|
|
|
|
|
+String ProjectConverter3To4::collect_string_from_vector(Vector<SourceLine> &vector) {
|
|
String string = "";
|
|
String string = "";
|
|
for (int i = 0; i < vector.size(); i++) {
|
|
for (int i = 0; i < vector.size(); i++) {
|
|
- string += vector[i];
|
|
|
|
|
|
+ string += vector[i].line;
|
|
|
|
|
|
if (i != vector.size() - 1) {
|
|
if (i != vector.size() - 1) {
|
|
string += "\n";
|
|
string += "\n";
|