Path: blob/master/editor/project_upgrade/project_converter_3_to_4.h
9896 views
/**************************************************************************/1/* project_converter_3_to_4.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#ifndef DISABLE_DEPRECATED3334#include "core/string/ustring.h"35#include "core/templates/local_vector.h"36#include "core/templates/vector.h"3738struct SourceLine {39String line;40bool is_comment;41};4243class RegEx;4445class ProjectConverter3To4 {46class RegExContainer;4748uint64_t maximum_file_size;49uint64_t maximum_line_length;5051void fix_tool_declaration(Vector<SourceLine> &source_lines, const RegExContainer ®_container);52void fix_pause_mode(Vector<SourceLine> &source_lines, const RegExContainer ®_container);5354void rename_colors(Vector<SourceLine> &source_lines, const RegExContainer ®_container);55void convert_hexadecimal_colors(Vector<SourceLine> &source_lines, const RegExContainer ®_container);56Vector<String> check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container);5758void rename_classes(Vector<SourceLine> &source_lines, const RegExContainer ®_container);59Vector<String> check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container);6061void rename_gdscript_functions(Vector<SourceLine> &source_lines, const RegExContainer ®_container, bool builtin);62Vector<String> check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin);63void process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin);6465void rename_csharp_functions(Vector<SourceLine> &source_lines, const RegExContainer ®_container);66Vector<String> check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container);67void process_csharp_line(String &line, const RegExContainer ®_container);6869void rename_csharp_attributes(Vector<SourceLine> &source_lines, const RegExContainer ®_container);70Vector<String> check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container);7172void rename_gdscript_keywords(Vector<SourceLine> &r_source_lines, const RegExContainer &p_reg_container, bool p_builtin);73Vector<String> check_for_rename_gdscript_keywords(Vector<String> &r_lines, const RegExContainer &p_reg_container, bool p_builtin);7475void rename_input_map_scancode(Vector<SourceLine> &source_lines, const RegExContainer ®_container);76Vector<String> check_for_rename_input_map_scancode(Vector<String> &lines, const RegExContainer ®_container);7778void rename_joypad_buttons_and_axes(Vector<SourceLine> &source_lines, const RegExContainer ®_container);79Vector<String> check_for_rename_joypad_buttons_and_axes(Vector<String> &lines, const RegExContainer ®_container);8081void custom_rename(Vector<SourceLine> &source_lines, const String &from, const String &to);82Vector<String> check_for_custom_rename(Vector<String> &lines, const String &from, const String &to);8384void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<SourceLine> &source_lines);85Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines);8687Vector<String> check_for_files();8889Vector<String> parse_arguments(const String &line);90int get_end_parenthesis(const String &line) const;91String connect_arguments(const Vector<String> &line, int from, int to = -1) const;92String get_starting_space(const String &line) const;93String get_object_of_execution(const String &line) const;94bool contains_function_call(const String &line, const String &function) const;9596String line_formatter(int current_line, String from, String to, String line);97String simple_line_formatter(int current_line, String old_line, String line);98String collect_string_from_vector(Vector<SourceLine> &vector);99Vector<SourceLine> split_lines(const String &text);100101bool test_single_array(const char *array[][2], bool ignore_second_check = false);102bool 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);103bool test_conversion_with_regex(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), const String &what, const RegExContainer ®_container);104bool test_conversion_basic(const String &name, const String &expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, const String &what);105bool test_array_names();106bool test_conversion(RegExContainer ®_container);107108public:109ProjectConverter3To4(int, int);110bool validate_conversion();111bool convert();112};113114#endif // DISABLE_DEPRECATED115116117