-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Use GDExtensionCallableCustomInfo2
instead of deprecated GDExtensionCallableCustomInfo
.
#952
Conversation
277863e
to
0af2f6d
Compare
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-952 |
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 a lot!
godot-core/src/builtin/callable.rs
Outdated
#[cfg(before_api = "4.3")] | ||
#[cfg(since_api = "4.2")] | ||
type GDExtensionCallableCustomInfo = sys::GDExtensionCallableCustomInfo; |
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.
You can use all(...)
here 🙂
#[cfg(before_api = "4.3")] | |
#[cfg(since_api = "4.2")] | |
type GDExtensionCallableCustomInfo = sys::GDExtensionCallableCustomInfo; | |
#[cfg(all(since_api = "4.2", before_api = "4.3"))] | |
type GDExtensionCallableCustomInfo = sys::GDExtensionCallableCustomInfo; |
godot-core/src/builtin/callable.rs
Outdated
#[cfg(since_api = "4.3")] | ||
type GDExtensionCallableCustomInfo = sys::GDExtensionCallableCustomInfo2; |
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.
The naming is a bit confusing -- the use sites look like sys::
was forgotten and the code is referring to sys::GDExtensionCallableCustomInfo
.
Maybe just like this, to make clear it's not a typedef exported by the GDExtension API itself?
#[cfg(since_api = "4.3")] | |
type GDExtensionCallableCustomInfo = sys::GDExtensionCallableCustomInfo2; | |
#[cfg(since_api = "4.3")] | |
type CallableCustomInfo = sys::GDExtensionCallableCustomInfo2; |
…onCallableCustomInfo`. ====== The only difference between old and new `GDExtensionCallableCustomInfo` is an addition of `get_argument_count_func`. In godot-cpp implementation the only way to get this count is overriding method in the question; For now we are leaving nullptr – consider implementing builder pattern for the Callable (`Callable::from_…ex(…).arg_count(n).done()`) if the need to do so arise.
0af2f6d
to
6f21759
Compare
The only difference between old and new
GDExtensionCallableCustomInfo
is an addition ofget_argument_count_func
. In godot-cpp implementation the only way to provide an argument count is overriding the method in a question.For now I'm leaving the nullptr – consider implementing builder pattern for the Callable (
Callable::from_…ex(…).arg_count(n).done()
) if the need to do so arise (would require changes to userdata stored with the callable).One could provide blanket implementation, but IMO it would be only more confusing. Gdext checks if given function is present https://github.com/godotengine/godot/blob/0c45ace151f25de2ca54fe7a46b6f077be32ba6f/core/extension/gdextension_interface.cpp#L149, executes it and returns the result if it is valid (
r_is_valid
) – otherwise it returns "0" (in other words, the default implementation is already provided by the engine itself).