-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command-line option to run a MainLoop
by its global class name
#78045
Conversation
2639be4
to
8f32218
Compare
That's a pretty good approach! It definitely makes things cleaner and easier to extend from thirdparty modules. Some minor concerns or nitpicks:
|
8f32218
to
496fd4d
Compare
375f00c
to
7f89a1c
Compare
@akien-mga I agree the command is more convoluted, so it would be great to combine this with #76542. I removed the unnecessary Is there something I can do about the |
I don't really like the idea of exposing the bindings generator class. Also, as previously mentioned, it makes building Godot with .NET more convoluted. I wonder if we could have a method implemented by modules to register options instead. Then, main could show registered options in // Called by main before parsing args.
void bind_options(ArgsDB p_args_db) {
p_args_db.bind_arg(sarray("-e", "--editor"), "Start the editor instead of running the scene.");
p_args_db.bind_arg(sarray("-p", "--project-manager"), "Start the project manager, even if a project is auto-detected.");
p_args_db.bind_arg(sarray("--quit"), "Quit after the first iteration.");
}
// Called by main after handling args.
void handle_options(const List<String> &p_cmdline_args) {
const List<String>::Element *elem = p_cmdline_args.front();
while (elem) {
if (elem->get() == "--my-option") {
// Handle option.
}
}
} On second thought, we probably don't need to make it that complicated. We could just have a |
7f89a1c
to
de5b48e
Compare
MainLoop
by its global class name; use for C# bindings generatorMainLoop
by its global class name
@raulsntos I've removed the C# changes from this PR. The fact that the previous version did work shows that the Adding more elegant argument handling to modules would be nice to do in the future indeed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice and clean!
If we merge this PR right after the 4.1 release, wouldn't it remove the need for you to fork Godot, @rburing? |
Technically this can be worked around by running a Godot project (just a This PR is pretty harmless but since the main use case for it (godot-julia) is in early development, I think there's no need to breach the feature freeze for 4.1, we can keep this for 4.2. |
Thanks! |
This PR allows e.g. creating language bindings in the same way as C#, but without hacking
main.cpp
.See 7f89a1c for an example of usage.
Original (outdated) description
Removes this hack from
main.cpp
:godot/main/main.cpp
Lines 2519 to 2526 in 300748e
With this PR, the bindings generator can be run as:
Here I named the main loop class
CSharpBindingsGenerator
. The class could also be renamedCSharpGlueGenerator
, and then the argument parsing could be simplified to useOS::get_cmdline_user_args
:This PR allows creating other language bindings in the same way without hacking
main.cpp
(which was my motivation).