summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-10-21 23:40:06 +0200
committerkobewi <kobewi4e@gmail.com>2022-11-04 17:24:34 +0100
commit1778301cd008bb791fd27239e0f2659ae640e351 (patch)
tree8eb98e2e6175b5b86b18113f7a4fa4e7181e7474 /core
parent191c8ed12f624ec97b650b2726fed4e8c4bcf04c (diff)
Add call_deferred() method to Callable
Diffstat (limited to 'core')
-rw-r--r--core/variant/callable.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/variant/callable.h b/core/variant/callable.h
index 0305dc55c3..32770bd663 100644
--- a/core/variant/callable.h
+++ b/core/variant/callable.h
@@ -73,6 +73,16 @@ public:
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..., 0 }; // +1 makes sure zero sized arrays are also supported.
+ const Variant *argptrs[sizeof...(p_args) + 1];
+ for (uint32_t i = 0; i < sizeof...(p_args); i++) {
+ argptrs[i] = &args[i];
+ }
+ return call_deferredp(sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
+ }
+
Error rpcp(int p_id, const Variant **p_arguments, int p_argcount, CallError &r_call_error) const;
_FORCE_INLINE_ bool is_null() const {