Merge pull request #46954 from neikeq/reggr-46307

C#: Fix StringName leak warnings after generating bindings
This commit is contained in:
Rémi Verschelde 2021-03-13 09:13:34 +01:00 committed by GitHub
commit 8368f53941
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3631,67 +3631,17 @@ void BindingsGenerator::_initialize() {
initialized = true;
}
void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) {
const int NUM_OPTIONS = 2;
String generate_all_glue_option = "--generate-mono-glue";
String generate_cs_glue_option = "--generate-mono-cs-glue";
String generate_cpp_glue_option = "--generate-mono-cpp-glue";
static String generate_all_glue_option = "--generate-mono-glue";
static String generate_cs_glue_option = "--generate-mono-cs-glue";
static String generate_cpp_glue_option = "--generate-mono-cpp-glue";
String glue_dir_path;
String cs_dir_path;
String cpp_dir_path;
int options_left = NUM_OPTIONS;
const List<String>::Element *elem = p_cmdline_args.front();
while (elem && options_left) {
if (elem->get() == generate_all_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
glue_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_all_glue_option + ": No output directory specified (expected path to '{GODOT_ROOT}/modules/mono/glue').");
}
--options_left;
} else if (elem->get() == generate_cs_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
cs_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_cs_glue_option + ": No output directory specified.");
}
--options_left;
} else if (elem->get() == generate_cpp_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
cpp_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_cpp_glue_option + ": No output directory specified.");
}
--options_left;
}
elem = elem->next();
}
if (glue_dir_path.length() || cs_dir_path.length() || cpp_dir_path.length()) {
static void handle_cmdline_options(String glue_dir_path, String cs_dir_path, String cpp_dir_path) {
BindingsGenerator bindings_generator;
bindings_generator.set_log_print_enabled(true);
if (!bindings_generator.initialized) {
if (!bindings_generator.is_initialized()) {
ERR_PRINT("Failed to initialize the bindings generator");
Main::cleanup(true);
::exit(0);
return;
}
if (glue_dir_path.length()) {
@ -3715,7 +3665,69 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
ERR_PRINT(generate_cpp_glue_option + ": Failed to generate the C++ glue.");
}
}
}
void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) {
const int NUM_OPTIONS = 2;
String glue_dir_path;
String cs_dir_path;
String cpp_dir_path;
int options_left = NUM_OPTIONS;
bool exit_godot = false;
const List<String>::Element *elem = p_cmdline_args.front();
while (elem && options_left) {
if (elem->get() == generate_all_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
glue_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_all_glue_option + ": No output directory specified (expected path to '{GODOT_ROOT}/modules/mono/glue').");
exit_godot = true;
}
--options_left;
} else if (elem->get() == generate_cs_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
cs_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_cs_glue_option + ": No output directory specified.");
exit_godot = true;
}
--options_left;
} else if (elem->get() == generate_cpp_glue_option) {
const List<String>::Element *path_elem = elem->next();
if (path_elem) {
cpp_dir_path = path_elem->get();
elem = elem->next();
} else {
ERR_PRINT(generate_cpp_glue_option + ": No output directory specified.");
exit_godot = true;
}
--options_left;
}
elem = elem->next();
}
if (glue_dir_path.length() || cs_dir_path.length() || cpp_dir_path.length()) {
handle_cmdline_options(glue_dir_path, cs_dir_path, cpp_dir_path);
exit_godot = true;
}
if (exit_godot) {
// Exit once done
Main::cleanup(true);
::exit(0);