-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Implement vararg methods of builtin classes. #1091
Implement vararg methods of builtin classes. #1091
Conversation
a05f1c7
to
964b15a
Compare
964b15a
to
72cf9bb
Compare
Thanks! I tested this (using The one thing I'm unsure about is putting these implementations into the |
Discussed at the GDExtension meeting, and agreed that the generated functions would be better in the *.hpp files associated with the class that the methods are on. |
I had tried to put implements in theirs *.hpp file, it will occur some compile issue. |
Hm. How does Godot itself workaround this problem? The same issue should exist there, because |
I roughly skimmed the implement of So, I think this pr is reasonable. |
I just attempted to modify this PR to put the template implementations in the same header file as the their classes (so, Looking at the Godot code, it doesn't have this problem, because it doesn't have a I'm not sure on the best way forward. This PR does include the new header it creates at the end of Maybe we could include the definition of all the methods except for Probably worth discussing again at a GDExtension meeting! |
Probably worth pointing out that |
That's a good point! In a GDExtension, you are very, very likely to be declaring a child class of So, perhaps this PR is fine as-is? |
binding_generator.py
Outdated
@@ -342,6 +343,101 @@ def generate_builtin_bindings(api, output_dir, build_config): | |||
|
|||
builtin_binds_file.write("\n".join(builtin_binds)) | |||
|
|||
# Craete a header to implement all builin class vararg methods and be included in `variant.hpp``. |
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.
Some minor typos here, like Craete
, builin
and a redundant backtick at the end.
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.
Thanks for your warning.
e27ec9b
to
165dc52
Compare
@dsnopek , @mihe If user include
It wiil occur a compile error "LNK2019" about So, we still need to deal this problem. |
I found that I have omitted a template in "callable.h" in godot sourc code:
Dose it means that if user want to call I written a simple test for this in godot module:
As the code comment show, if I include "callable.h" only and call The conclusion is that, if we want to using these templates, we must include "variant.h"/"variant.hpp" both in GDExtension and godot module. But there has a problem confuse me: why |
That is indeed a bit strange, but seeing as how you will likely run into compile errors with either of the two solutions (if you fail to include Clearly there's some precedence for this circular dependency in Godot as well, as you point out, so I would put my vote on just going with the pull request as-is. The case for utility functions creating problems seems niche enough to not be a major concern. |
74b751f
to
c3418a9
Compare
c3418a9
to
3ce83c1
Compare
3ce83c1
to
3536803
Compare
There's a PR to add a vararg Looking at the CI, it appears to be encountering the same problem with |
In godotengine/godot#79341, I think if we keep the "variant.hpp" include "callable.hpp", we have not a perfect solution to use What about to generate a comment line before these templates to warn users? like this:
If user encounter this compile issue and go to function definitions, they can get the solution by this comment. |
We could add a comment, however, I'm not sure we're really encouraging users of godot-cpp to read the generated source code. I've personally come around to liking this PR as-is. IMO, if we see users having issues with this, we can re-evaluate then. But that's just my opinion! We have this PR on the agenda for discussion at an upcoming GDExtension meeting. |
Discussed at GDExtension meeting, and we think this fine - templates are tricky, and it looks like core is going to solve the problem in a similar way. |
I had forgotten that this on depends on Godot PR godotengine/godot#76047 I've just re-reviewed that one (which is looking great!) but we'll have to wait for it to be merged before this one can be |
PR godotengine/godot#76047 has been merged, so we can finally merge this one :-) |
Implement builtin classes' vararg methods.
Need #76047.
Now,
call()
,call_deferred()
,rpc()
,rpc_id()
,bind()
inCallable
, andSignal::emit()
can be called with any count of arguments.Fixes #802
Fixes #1093