Skip to content
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

Separate definition of templates to solve the vararg/template issues #837

Closed
wants to merge 2 commits into from

Conversation

PapyChacal
Copy link
Contributor

Hi,

I stumbled upon #802 - I wanted to call Callable::call from GDExtension, but realized all varargs methods were not generated.
Digging a bit, I saw that the deeper problem is the circular dependency between Callable and Variant - at least in my tentative. So I went for a classical approach, defining the template methods separately in an .impl file.

This way, at least, it compiles and links properly when I try to use Callable::call in my code. (by including "godot_cpp/variant/callable.impl")
But this is a first draft: not clean at all and crashes badly! I just wanted to open the PR already to start discussing the idea itself. If this could be the way to go, I can clean up in the coming days. Please feel welcome to do it if you have time and motivation before I do!

@Calinou Calinou added bug This has been identified as a bug topic:gdextension This relates to the new Godot 4 extension implementation labels Sep 12, 2022
@Calinou Calinou marked this pull request as draft September 12, 2022 00:52
@PapyChacal
Copy link
Contributor Author

Okay, this is still far from clean and not working, but I made a draft for varargs methods argument encoding.
If anyone is interested, please check the generated gen/include/godot_cpp/variant.impl and gen/include/godot_cpp/encode.hpp
The weird templates in encode.hpp are to mimic bindings_generator.py's get_encoded_arg by the C++ compiler, because it needs to be done when the types Args... are known. They are probably far from correct, but seems to work in some cases including mine (calling Callable::call<Vector3i>).
Now it compiles and runs until it hits the 0x00 _method_bindings.method_call of Callable.

Faless and others added 2 commits September 27, 2022 20:06
optimize = auto|none|debug|speed|size|0|1|2|3
debug_symbol = True|False

optimize == "auto" will produce:
- "debug" for "debug" builds
- "speed" for "release" builds
@PapyChacal
Copy link
Contributor Author

I made it simpler and working by using Variant for every argument.

I am not sure it could even work with "native pointers", because how would the callee know the pointed type? If it could, please tell me and I will try to implement it.

Either way, this depends on godotengine/godot#65718.

@PapyChacal
Copy link
Contributor Author

I am closing this PR as I see no reaction and I had a good idea to do it with my master branch.
I kept my branch safe, feel free to ping me if somebody wants this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived bug This has been identified as a bug topic:gdextension This relates to the new Godot 4 extension implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants