-
-
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
New callable_mp macro, for signals to call method pointers directly. #36393
Conversation
|
||
virtual uint32_t hash() const; | ||
}; | ||
|
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.
Behold the power of Voodoo below..
Making a straw doll gain life and dance is probably simpler than this.
I don't know if there is a debate, but with this signal rework are you going to implement lambdas in GDScript? |
#endif | ||
|
||
template <class T, class... P, size_t... Is> | ||
void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { |
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.
This one raises a warning with GCC 8:
In file included from editor/inspector_dock.cpp:33:
./core/callable_method_pointer.h: In instantiation of 'void call_with_variant_args_helper(T*, void (T::*)(P ...), const Variant**, Callable::CallError&, IndexSequence<Is ...>) [with T = InspectorDock; P = {}; long unsigned int ...Is = {}]':
./core/callable_method_pointer.h:125:40: required from 'void call_with_variant_args(T*, void (T::*)(P ...), const Variant**, int, Callable::CallError&) [with T = InspectorDock; P = {}]'
./core/callable_method_pointer.h:141:25: required from 'void CallableCustomMethodPointer<T, P>::call(const Variant**, int, Variant&, Callable::CallError&) const [with T = InspectorDock; P = {}]'
./core/callable_method_pointer.h:139:15: required from here
./core/callable_method_pointer.h:96:94: error: parameter 'p_args' set but not used [-Werror=unused-but-set-parameter]
96 | void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
|
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.
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.
I reported a GCC PR:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93999
93396e6
to
db38a28
Compare
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.
Rebased to fix style and silence a likely GCC false positive warning, should be good to merge now provided CI passes.
3fb3625
to
a9b2c8e
Compare
a9b2c8e
to
04bb6a7
Compare
Shouldn't it be |
|
Thanks! |
#if defined(DEBUG_METHODS_ENABLED) && defined(__GNUC__) && !defined(__clang__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter" | ||
#endif |
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.
@akien-mga Now with C++17 we can use [[maybe_unused]]
https://en.cppreference.com/w/cpp/language/attributes/maybe_unused
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, that could be used indeed. Though in this case it does look like a GCC bug, so we might want to keep the compiler-specific hack, at least until we know more about the issue.
If it turns out that GCC is correct and that other compilers simply don't catch the issue, we can use [[maybe_unused]]
indeed for p_args
.
Was missed in godotengine#36393 because no `callable_mp()` calls were actually compiled with `tools=no` in that PR. Also work around GCC warning that also affects the `call_with_variant_args_ret_helper` variant.
Implemented the callable_mp macro (simple on appearance and extremely complex under the hood).
Allows signals to call method pointers directly via Callable (using custom data). Should improve performance as well as not requiring internal methods to be registered in order to receive signals.