Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/project_upgrade/project_converter_3_to_4.h
9896 views
1
/**************************************************************************/
2
/* project_converter_3_to_4.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#ifndef DISABLE_DEPRECATED
34
35
#include "core/string/ustring.h"
36
#include "core/templates/local_vector.h"
37
#include "core/templates/vector.h"
38
39
struct SourceLine {
40
String line;
41
bool is_comment;
42
};
43
44
class RegEx;
45
46
class ProjectConverter3To4 {
47
class RegExContainer;
48
49
uint64_t maximum_file_size;
50
uint64_t maximum_line_length;
51
52
void fix_tool_declaration(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
53
void fix_pause_mode(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
54
55
void rename_colors(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
56
void convert_hexadecimal_colors(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
57
Vector<String> check_for_rename_colors(Vector<String> &lines, const RegExContainer &reg_container);
58
59
void rename_classes(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
60
Vector<String> check_for_rename_classes(Vector<String> &lines, const RegExContainer &reg_container);
61
62
void rename_gdscript_functions(Vector<SourceLine> &source_lines, const RegExContainer &reg_container, bool builtin);
63
Vector<String> check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer &reg_container, bool builtin);
64
void process_gdscript_line(String &line, const RegExContainer &reg_container, bool builtin);
65
66
void rename_csharp_functions(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
67
Vector<String> check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer &reg_container);
68
void process_csharp_line(String &line, const RegExContainer &reg_container);
69
70
void rename_csharp_attributes(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
71
Vector<String> check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer &reg_container);
72
73
void rename_gdscript_keywords(Vector<SourceLine> &r_source_lines, const RegExContainer &p_reg_container, bool p_builtin);
74
Vector<String> check_for_rename_gdscript_keywords(Vector<String> &r_lines, const RegExContainer &p_reg_container, bool p_builtin);
75
76
void rename_input_map_scancode(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
77
Vector<String> check_for_rename_input_map_scancode(Vector<String> &lines, const RegExContainer &reg_container);
78
79
void rename_joypad_buttons_and_axes(Vector<SourceLine> &source_lines, const RegExContainer &reg_container);
80
Vector<String> check_for_rename_joypad_buttons_and_axes(Vector<String> &lines, const RegExContainer &reg_container);
81
82
void custom_rename(Vector<SourceLine> &source_lines, const String &from, const String &to);
83
Vector<String> check_for_custom_rename(Vector<String> &lines, const String &from, const String &to);
84
85
void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<SourceLine> &source_lines);
86
Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines);
87
88
Vector<String> check_for_files();
89
90
Vector<String> parse_arguments(const String &line);
91
int get_end_parenthesis(const String &line) const;
92
String connect_arguments(const Vector<String> &line, int from, int to = -1) const;
93
String get_starting_space(const String &line) const;
94
String get_object_of_execution(const String &line) const;
95
bool contains_function_call(const String &line, const String &function) const;
96
97
String line_formatter(int current_line, String from, String to, String line);
98
String simple_line_formatter(int current_line, String old_line, String line);
99
String collect_string_from_vector(Vector<SourceLine> &vector);
100
Vector<SourceLine> split_lines(const String &text);
101
102
bool test_single_array(const char *array[][2], bool ignore_second_check = false);
103
bool test_conversion_gdscript_builtin(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), const String &what, const RegExContainer &reg_container, bool builtin);
104
bool test_conversion_with_regex(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), const String &what, const RegExContainer &reg_container);
105
bool test_conversion_basic(const String &name, const String &expected, const char *array[][2], LocalVector<RegEx *> &regex_cache, const String &what);
106
bool test_array_names();
107
bool test_conversion(RegExContainer &reg_container);
108
109
public:
110
ProjectConverter3To4(int, int);
111
bool validate_conversion();
112
bool convert();
113
};
114
115
#endif // DISABLE_DEPRECATED
116
117