Merge 8bbb204fd3
into 1aa3c8419b
This commit is contained in:
commit
4376f08962
12
.github/workflows/linux_builds.yml
vendored
12
.github/workflows/linux_builds.yml
vendored
|
@ -27,6 +27,7 @@ jobs:
|
|||
doc-test: true
|
||||
bin: "./bin/godot.linuxbsd.opt.tools.64.mono"
|
||||
build-mono: true
|
||||
proj-conv: true
|
||||
artifact: true
|
||||
|
||||
- name: Editor and sanitizers (target=debug, tools=yes, tests=yes, use_asan=yes, use_ubsan=yes)
|
||||
|
@ -124,6 +125,17 @@ jobs:
|
|||
curr="$(pwd)/libvk_swiftshader.so"
|
||||
sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json
|
||||
|
||||
# Test 3.x -> 4.0 project converter
|
||||
- name: Test project converter
|
||||
if: ${{ matrix.proj-conv }}
|
||||
run: |
|
||||
mkdir converter_test
|
||||
cd converter_test
|
||||
touch project.godot
|
||||
../${{ matrix.bin }} --headless --audio-driver Dummy --validate-convert-to-godot40
|
||||
cd ..
|
||||
rm converter_test -rf
|
||||
|
||||
# Download and extract zip archive with project, folder is renamed to be able to easy change used project
|
||||
- name: Download test project
|
||||
if: ${{ matrix.proj-test }}
|
||||
|
|
|
@ -2096,7 +2096,26 @@ bool ClassDB::is_class_enabled(StringName p_class) const {
|
|||
return ::ClassDB::is_class_enabled(p_class);
|
||||
}
|
||||
|
||||
Array ClassDB::get_variant_method_list(Variant::Type p_type) const {
|
||||
List<MethodInfo> methods;
|
||||
Variant::get_method_list_by_type(&methods, p_type);
|
||||
Array ret;
|
||||
|
||||
for (const MethodInfo &E : methods) {
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
ret.push_back(E.operator Dictionary());
|
||||
#else
|
||||
Dictionary dict;
|
||||
dict["name"] = E.name;
|
||||
ret.push_back(dict);
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ClassDB::_bind_methods() {
|
||||
::ClassDB::bind_method(D_METHOD("get_variant_method_list", "type"), &ClassDB::get_variant_method_list);
|
||||
::ClassDB::bind_method(D_METHOD("get_class_list"), &ClassDB::get_class_list);
|
||||
::ClassDB::bind_method(D_METHOD("get_inheriters_from_class", "class"), &ClassDB::get_inheriters_from_class);
|
||||
::ClassDB::bind_method(D_METHOD("get_parent_class", "class"), &ClassDB::get_parent_class);
|
||||
|
|
|
@ -588,6 +588,7 @@ public:
|
|||
bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const;
|
||||
|
||||
Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
|
||||
Array get_variant_method_list(Variant::Type p_type) const;
|
||||
|
||||
PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
||||
bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
||||
|
|
|
@ -519,6 +519,7 @@ public:
|
|||
static String get_callable_error_text(const Callable &p_callable, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce);
|
||||
|
||||
//dynamic (includes Object)
|
||||
static void get_method_list_by_type(List<MethodInfo> *p_list, Variant::Type p_type);
|
||||
void get_method_list(List<MethodInfo> *p_list) const;
|
||||
bool has_method(const StringName &p_method) const;
|
||||
|
||||
|
|
|
@ -1185,6 +1185,51 @@ uint32_t Variant::get_builtin_method_hash(Variant::Type p_type, const StringName
|
|||
return hash;
|
||||
}
|
||||
|
||||
void Variant::get_method_list_by_type(List<MethodInfo> *p_list, Variant::Type p_type) {
|
||||
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
|
||||
for (const StringName &E : builtin_method_names[p_type]) {
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(E);
|
||||
ERR_CONTINUE(!method);
|
||||
|
||||
MethodInfo mi;
|
||||
mi.name = E;
|
||||
|
||||
//return type
|
||||
if (method->has_return_type) {
|
||||
mi.return_val.type = method->return_type;
|
||||
if (mi.return_val.type == Variant::NIL) {
|
||||
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
}
|
||||
|
||||
if (method->is_const) {
|
||||
mi.flags |= METHOD_FLAG_CONST;
|
||||
}
|
||||
if (method->is_vararg) {
|
||||
mi.flags |= METHOD_FLAG_VARARG;
|
||||
}
|
||||
if (method->is_static) {
|
||||
mi.flags |= METHOD_FLAG_STATIC;
|
||||
}
|
||||
for (int i = 0; i < method->argument_count; i++) {
|
||||
PropertyInfo pi;
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
pi.name = method->argument_names[i];
|
||||
#else
|
||||
pi.name = "arg" + itos(i + 1);
|
||||
#endif
|
||||
pi.type = method->get_argument_type(i);
|
||||
if (pi.type == Variant::NIL) {
|
||||
pi.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
mi.arguments.push_back(pi);
|
||||
}
|
||||
|
||||
mi.default_arguments = method->default_arguments;
|
||||
p_list->push_back(mi);
|
||||
}
|
||||
}
|
||||
|
||||
void Variant::get_method_list(List<MethodInfo> *p_list) const {
|
||||
if (type == OBJECT) {
|
||||
Object *obj = get_validated_object();
|
||||
|
@ -1192,47 +1237,7 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
|
|||
obj->get_method_list(p_list);
|
||||
}
|
||||
} else {
|
||||
for (const StringName &E : builtin_method_names[type]) {
|
||||
const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E);
|
||||
ERR_CONTINUE(!method);
|
||||
|
||||
MethodInfo mi;
|
||||
mi.name = E;
|
||||
|
||||
//return type
|
||||
if (method->has_return_type) {
|
||||
mi.return_val.type = method->return_type;
|
||||
if (mi.return_val.type == Variant::NIL) {
|
||||
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
}
|
||||
|
||||
if (method->is_const) {
|
||||
mi.flags |= METHOD_FLAG_CONST;
|
||||
}
|
||||
if (method->is_vararg) {
|
||||
mi.flags |= METHOD_FLAG_VARARG;
|
||||
}
|
||||
if (method->is_static) {
|
||||
mi.flags |= METHOD_FLAG_STATIC;
|
||||
}
|
||||
for (int i = 0; i < method->argument_count; i++) {
|
||||
PropertyInfo pi;
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
pi.name = method->argument_names[i];
|
||||
#else
|
||||
pi.name = "arg" + itos(i + 1);
|
||||
#endif
|
||||
pi.type = method->get_argument_type(i);
|
||||
if (pi.type == Variant::NIL) {
|
||||
pi.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
mi.arguments.push_back(pi);
|
||||
}
|
||||
|
||||
mi.default_arguments = method->default_arguments;
|
||||
p_list->push_back(mi);
|
||||
}
|
||||
Variant::get_method_list_by_type(p_list, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,12 @@
|
|||
Returns the parent class of [code]class[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_variant_method_list" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<argument index="0" name="type" type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="instantiate" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="class" type="StringName" />
|
||||
|
|
3574
editor/converter.cpp
Normal file
3574
editor/converter.cpp
Normal file
File diff suppressed because it is too large
Load diff
83
editor/converter.h
Normal file
83
editor/converter.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*************************************************************************/
|
||||
/* converter.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef CONVERTER_H
|
||||
#define CONVERTER_H
|
||||
|
||||
#include "core/core_bind.h"
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
class GodotConverter4 {
|
||||
void rename_enums(String &file_content);
|
||||
Vector<String> check_for_rename_enums(Vector<String> &file_content);
|
||||
|
||||
void rename_classes(String &file_content);
|
||||
Vector<String> check_for_rename_classes(Vector<String> &file_content);
|
||||
|
||||
void rename_gdscript_functions(String &file_content);
|
||||
Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content);
|
||||
|
||||
void rename_csharp_functions(String &file_content);
|
||||
Vector<String> check_for_rename_csharp_functions(Vector<String> &file_content);
|
||||
|
||||
void rename_gdscript_keywords(String &file_content);
|
||||
Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content);
|
||||
|
||||
void custom_rename(String &file_content, String from, String to);
|
||||
Vector<String> check_for_custom_rename(Vector<String> &file_content, String from, String to);
|
||||
|
||||
void rename_common(const char *array[][2], String &file_content);
|
||||
Vector<String> check_for_rename_common(const char *array[][2], Vector<String> &file_content);
|
||||
|
||||
Vector<String> check_for_files();
|
||||
|
||||
Vector<String> parse_arguments(const String &line);
|
||||
int get_end_parenthess(const String &line) const;
|
||||
String connect_arguments(const Vector<String> &line, int from, int to = -1) const;
|
||||
String get_starting_space(const String &line) const;
|
||||
String get_object_of_execution(const String &line) const;
|
||||
|
||||
String line_formatter(int current_line, String from, String to, String line);
|
||||
String simple_line_formatter(int current_line, String old_line, String line);
|
||||
|
||||
bool test_single_array(const char *array[][2], bool ignore_second_check = false);
|
||||
bool test_conversion_single_additional(String name, String expected, void (GodotConverter4::*func)(String &), String what);
|
||||
bool test_conversion_single_normal(String name, String expected, const char *array[][2], String what);
|
||||
bool test_array_names();
|
||||
bool test_conversion();
|
||||
|
||||
public:
|
||||
int converter_validation();
|
||||
int converter();
|
||||
};
|
||||
|
||||
#endif // CONVERTER_H
|
|
@ -82,6 +82,7 @@
|
|||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "editor/converter.h"
|
||||
#include "editor/doc_data_class_path.gen.h"
|
||||
#include "editor/doc_tools.h"
|
||||
#include "editor/editor_node.h"
|
||||
|
@ -369,6 +370,8 @@ void Main::print_help(const char *p_binary) {
|
|||
OS::get_singleton()->print(" -s, --script <script> Run a script.\n");
|
||||
OS::get_singleton()->print(" --check-only Only parse for errors and quit (use with --script).\n");
|
||||
#ifdef TOOLS_ENABLED
|
||||
OS::get_singleton()->print(" --convert-to-godot40 Converts project from Godot 3.x to Godot 4.0.\n");
|
||||
OS::get_singleton()->print(" --validate-convert-to-godot40 Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.0.\n");
|
||||
OS::get_singleton()->print(" --export <preset> <path> Export the project using the given preset and matching release template. The preset name should match one defined in export_presets.cfg.\n");
|
||||
OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n");
|
||||
OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n");
|
||||
|
@ -974,6 +977,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
} else if (I->get() == "--convert-to-godot40") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
} else if (I->get() == "--validate-convert-to-godot40") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
#endif
|
||||
} else if (I->get() == "--path") { // set path of project to start or edit
|
||||
|
||||
|
@ -1953,6 +1964,8 @@ bool Main::start() {
|
|||
String _export_preset;
|
||||
bool export_debug = false;
|
||||
bool export_pack_only = false;
|
||||
bool converting_project = false;
|
||||
bool validating_converting_project = false;
|
||||
#endif
|
||||
|
||||
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
|
||||
|
@ -1968,6 +1981,10 @@ bool Main::start() {
|
|||
#ifdef TOOLS_ENABLED
|
||||
} else if (args[i] == "--no-docbase") {
|
||||
doc_base = false;
|
||||
} else if (args[i] == "--convert-to-godot40") {
|
||||
converting_project = true;
|
||||
} else if (args[i] == "--validate-convert-to-godot40") {
|
||||
validating_converting_project = true;
|
||||
} else if (args[i] == "-e" || args[i] == "--editor") {
|
||||
editor = true;
|
||||
} else if (args[i] == "-p" || args[i] == "--project-manager") {
|
||||
|
@ -2109,6 +2126,18 @@ bool Main::start() {
|
|||
NativeExtensionAPIDump::generate_extension_json_file("extension_api.json");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (converting_project) {
|
||||
int exit_code = GodotConverter4().converter();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
if (validating_converting_project) {
|
||||
int exit_code = GodotConverter4().converter_validation();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (script == "" && game_path == "" && String(GLOBAL_GET("application/run/main_scene")) != "") {
|
||||
|
|
2
misc/dist/shell/_godot.zsh-completion
vendored
2
misc/dist/shell/_godot.zsh-completion
vendored
|
@ -65,6 +65,8 @@ _arguments \
|
|||
'--print-fps[print the frames per second to the stdout]' \
|
||||
'(-s, --script)'{-s,--script}'[run a script]:path to script:_files' \
|
||||
'--check-only[only parse for errors and quit (use with --script)]' \
|
||||
'--convert-to-godot40'converts project from Godot 3.x to Godot 4.0' \
|
||||
'--validate-convert-to-godot40'shows what elements will be renamed when converting project from Godot 3.x to Godot 4.0' \
|
||||
'--export[export the project using the given preset and matching release template]:export preset name' \
|
||||
'--export-debug[same as --export, but using the debug template]:export preset name' \
|
||||
'--export-pack[same as --export, but only export the game pack for the given preset]:export preset name' \
|
||||
|
|
2
misc/dist/shell/godot.bash-completion
vendored
2
misc/dist/shell/godot.bash-completion
vendored
|
@ -76,6 +76,8 @@ _complete_godot_options() {
|
|||
--build-solutions
|
||||
--gdnative-generate-json-api
|
||||
--test
|
||||
--convert-to-godot40
|
||||
--validate-convert-to-godot40
|
||||
" -- "$1"))
|
||||
}
|
||||
|
||||
|
|
2
misc/dist/shell/godot.fish
vendored
2
misc/dist/shell/godot.fish
vendored
|
@ -79,6 +79,8 @@ complete -c godot -l print-fps -d "Print the frames per second to the stdout"
|
|||
# Standalone tools:
|
||||
complete -c godot -s s -l script -d "Run a script" -r
|
||||
complete -c godot -l check-only -d "Only parse for errors and quit (use with --script)"
|
||||
complete -c godot -l convert-to-godot40 -d "Converts project from Godot 3.x to Godot 4.0"
|
||||
complete -c godot -l validate-convert-to-godot40 -d "Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.0"
|
||||
complete -c godot -l export -d "Export the project using the given preset and matching release template" -x
|
||||
complete -c godot -l export-debug -d "Same as --export, but using the debug template" -x
|
||||
complete -c godot -l export-pack -d "Same as --export, but only export the game pack for the given preset" -x
|
||||
|
|
Loading…
Reference in a new issue