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

Add call_deferred() method to Callable #67730

Merged
merged 1 commit into from Nov 6, 2022

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Oct 21, 2022

For whatever reason the C++ Callable never got call_deferred() method and to defer a call you had to call_deferredp(nullptr, 0);.

@@ -73,6 +73,16 @@ class Callable {
void call_deferredp(const Variant **p_arguments, int p_argcount) const;
Variant callv(const Array &p_arguments) const;

template <typename... VarArgs>
void call_deferred(VarArgs... p_args) const {
Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./core/variant/callable.h:78:54: error: invalid use of incomplete type 'Variant'
                Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
                                                                   ^~~~~~~~~
./core/variant/array.h:38:7: note: forward declaration of 'Variant'
class Variant;
      ^

Should likely be in the .cpp as we probably don't want to include Variant here to avoid circular deps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template functions can't be defined in cpp. I found a promising workaround though.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, should be good to merge once it builds :)

@akien-mga akien-mga merged commit 12b4a26 into godotengine:master Nov 6, 2022
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga modified the milestones: 4.x, 4.0 Nov 6, 2022
@KoBeWi KoBeWi deleted the late_to_the_call branch November 6, 2022 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants