#include "project_converter_3_to_4.h"
#ifndef DISABLE_DEPRECATED
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_REGEX_ENABLED
#include "core/error/error_macros.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/object/ref_counted.h"
#include "core/os/time.h"
#include "core/templates/hash_map.h"
#include "core/templates/list.h"
#include "editor/renames_map_3_to_4.h"
#include "modules/regex/regex.h"
static String make_regex_gds_os_property_set(const String &name_set) { … }
static String make_regex_gds_os_property_assign(const String &name) { … }
static String make_regex_gds_os_property_get(const String &name, const String &get) { … }
class ProjectConverter3To4::RegExContainer { … };
ProjectConverter3To4::ProjectConverter3To4(int p_maximum_file_size_kb, int p_maximum_line_length) { … }
bool ProjectConverter3To4::convert() { … }
bool ProjectConverter3To4::validate_conversion() { … }
Vector<String> ProjectConverter3To4::check_for_files() { … }
Vector<SourceLine> ProjectConverter3To4::split_lines(const String &text) { … }
bool ProjectConverter3To4::test_conversion_gdscript_builtin(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), const String &what, const RegExContainer ®_container, bool builtin_script) { … }
bool ProjectConverter3To4::test_conversion_with_regex(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), const String &what, const RegExContainer ®_container) { … }
bool ProjectConverter3To4::test_conversion_basic(const String &name, const String &expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, const String &what) { … }
bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { … }
bool ProjectConverter3To4::test_array_names() { … }
bool ProjectConverter3To4::test_single_array(const char *p_array[][2], bool p_ignore_4_0_name) {
bool valid = true;
Vector<String> names = Vector<String>();
for (unsigned int current_index = 0; p_array[current_index][0]; current_index++) {
String name_3_x = p_array[current_index][0];
String name_4_0 = p_array[current_index][1];
if (name_3_x != name_3_x.strip_edges()) {
ERR_PRINT(vformat("Invalid Entry \"%s\" contains leading or trailing spaces.", name_3_x));
valid = false;
}
if (names.has(name_3_x)) {
ERR_PRINT(vformat("Found duplicated entry, pair ( -> %s , %s)", name_3_x, name_4_0));
valid = false;
}
names.append(name_3_x);
if (name_4_0 != name_4_0.strip_edges()) {
ERR_PRINT(vformat("Invalid Entry \"%s\" contains leading or trailing spaces.", name_3_x));
valid = false;
}
if (names.has(name_4_0)) {
ERR_PRINT(vformat("Found duplicated entry, pair ( -> %s , %s)", name_3_x, name_4_0));
valid = false;
}
if (!p_ignore_4_0_name) {
names.append(name_4_0);
}
}
return valid;
};
Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { … }
int ProjectConverter3To4::get_end_parenthesis(const String &line) const { … }
String ProjectConverter3To4::connect_arguments(const Vector<String> &arguments, int from, int to) const { … }
String ProjectConverter3To4::get_starting_space(const String &line) const { … }
String ProjectConverter3To4::get_object_of_execution(const String &line) const { … }
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 (line.contains("Color.")) {
for (unsigned int current_index = 0; RenamesMap3To4::color_renames[current_index][0]; current_index++) {
line = reg_container.color_regexes[current_index]->sub(line, reg_container.color_renamed[current_index], true);
}
}
}
}
};
void ProjectConverter3To4::convert_hexadecimal_colors(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
Vector<String> ProjectConverter3To4::check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container) { … }
void ProjectConverter3To4::fix_tool_declaration(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
void ProjectConverter3To4::fix_pause_mode(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
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) {
for (unsigned int current_index = 0; RenamesMap3To4::class_renames[current_index][0]; current_index++) {
if (line.contains(RenamesMap3To4::class_renames[current_index][0])) {
bool found_ignored_items = false;
if (line.contains(String(RenamesMap3To4::class_renames[current_index][0]) + ".")) {
found_ignored_items = true;
line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true);
line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true);
line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true);
}
line = reg_container.class_regexes[current_index]->sub(line, RenamesMap3To4::class_renames[current_index][1], true);
if (found_ignored_items) {
line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true);
line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true);
line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true);
}
}
}
}
}
};
Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container) { … }
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) {
process_gdscript_line(line, reg_container, builtin);
}
}
};
Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { … }
bool ProjectConverter3To4::contains_function_call(const String &line, const String &function) const { … }
void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin) { … }
void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) { … }
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) {
process_csharp_line(line, reg_container);
}
}
};
Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { … }
void ProjectConverter3To4::rename_csharp_attributes(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) { … }
_FORCE_INLINE_ static String builtin_escape(const String &p_str, bool p_builtin) { … }
void ProjectConverter3To4::rename_gdscript_keywords(Vector<SourceLine> &source_lines, const RegExContainer ®_container, bool builtin) { … }
Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { … }
void ProjectConverter3To4::rename_input_map_scancode(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
void ProjectConverter3To4::rename_joypad_buttons_and_axes(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { … }
Vector<String> ProjectConverter3To4::check_for_rename_joypad_buttons_and_axes(Vector<String> &lines, const RegExContainer ®_container) { … }
Vector<String> ProjectConverter3To4::check_for_rename_input_map_scancode(Vector<String> &lines, const RegExContainer ®_container) { … }
void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, const String &from, const String &to) {
RegEx reg = RegEx(String("\\b") + from + "\\b");
CRASH_COND(!reg.is_valid());
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) {
line = reg.sub(line, to, true);
}
}
};
Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, const String &from, const String &to) { … }
void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<SourceLine> &source_lines) { … }
Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) { … }
String ProjectConverter3To4::line_formatter(int current_line, String from, String to, String line) { … }
String ProjectConverter3To4::simple_line_formatter(int current_line, String old_line, String new_line) { … }
String ProjectConverter3To4::collect_string_from_vector(Vector<SourceLine> &vector) { … }
#endif
#endif