-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tutorial on how Godot uses c++ typedef #1
Comments
I agree with jak6jak, there are tons of good C++ tutorials or books around every corner, but the Godod source code is completely undocumented and in many ways completely confusing. It would probably be more useful to create a practical tutorial on how to use the tangled Godot's source (macros, classes, signals ...) to write some basic modules. |
Yes, I plan to cover those eventually. Those are all "function pointers" which are typedef'd so that you don't have to rewrite the absolute garbage syntax of function pointers in C++ over and over again as you reference the same data type. Basically, they are variables that hold a function as a piece of data and allow a third-party to execute the function remotely. They look awful because they have to detail the full function signature in the typedef and then wrap the name of the data type with When I cover function pointers, I'll be sure to mention them. And of course, in the main Deconstructing Godot series, we will address what things are doing as we look through code. In those later videos, if anyone has any questions, they'll be able to make a comment with a timestamp and their question, and I'll be sure to give a detailed answer for them. :-)
Undocumented, yeah, kinda. Completely confusing though, I would disagree. It's actually extremely readable in large portions of the codebase that I've seen, mostly because it relies on old-school C++ without too much complexity. The stuff OP referenced is actually pretty tame compared to other codebases I've seen.
This is a planned lesson. Both an introduction to Macros in the GDScript to C++ series and a full summary of implementing a class for a module in the Deconstructing Godot series (and a breakdown of what is actually happening at each stage of that process). |
That's true, and I appreciate that (the C++ committee extended C to a monster language;), but it also contains a lot of "feature" and "macro" junk that has been picked up and expanded over the years by the many different contributors... |
In the c++ tutorial would it be possible for you to cover typedef? Most of the tutorials online cover really simple cases like:
typedef int int_t;
Godot sometimes uses typedef in more confusing ways that I don't think most tutorials prepare you for. An example of Godot using typedefs in a complex way is here in visual_script.h:typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String &p_type);
they later use this typedef in a Map:
Map<String, VisualScriptNodeRegisterFunc> register_funcs;
Another example is here:
typedef bool (*CompareEqualFunc)(const CallableCustom *p_a, const CallableCustom *p_b);
Can you explain how these type of typedefs work and why they are used?
The text was updated successfully, but these errors were encountered: