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

Set vararg methods' ptrcall of builtin classes, and let them can be called without arguments. #76047

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions core/variant/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c
} \
static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
LocalVector<Variant> vars; \
vars.resize(p_argcount); \
LocalVector<const Variant *> vars_ptrs; \
vars.resize(p_argcount); \
Comment on lines -564 to +565
Copy link
Member

Choose a reason for hiding this comment

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

This reordering (leftover from the previous version) is not necessary, but it doesn't hurt either.

vars_ptrs.resize(p_argcount); \
for (int i = 0; i < p_argcount; i++) { \
vars[i] = PtrToArg<Variant>::convert(p_args[i]); \
Expand All @@ -571,7 +571,7 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c
Variant base = PtrToArg<m_class>::convert(p_base); \
Variant ret; \
Callable::CallError ce; \
m_method_ptr(&base, (const Variant **)&vars_ptrs[0], p_argcount, ret, ce); \
m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \
if (m_has_return) { \
m_return_type r = ret; \
PtrToArg<m_return_type>::encode(ret, r_ret); \
Expand Down Expand Up @@ -617,8 +617,8 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c
} \
static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
LocalVector<Variant> vars; \
vars.resize(p_argcount); \
LocalVector<const Variant *> vars_ptrs; \
vars.resize(p_argcount); \
vars_ptrs.resize(p_argcount); \
for (int i = 0; i < p_argcount; i++) { \
vars[i] = PtrToArg<Variant>::convert(p_args[i]); \
Expand All @@ -627,7 +627,7 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c
Variant base = PtrToArg<m_class>::convert(p_base); \
Variant ret; \
Callable::CallError ce; \
m_method_ptr(&base, (const Variant **)&vars_ptrs[0], p_argcount, ret, ce); \
m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \
} \
static int get_argument_count() { \
return 1; \
Expand Down Expand Up @@ -1132,11 +1132,7 @@ static void register_builtin_method(const Vector<String> &p_argnames, const Vect

imi.call = T::call;
imi.validated_call = T::validated_call;
if (T::is_vararg()) {
imi.ptrcall = nullptr;
} else {
imi.ptrcall = T::ptrcall;
}
imi.ptrcall = T::ptrcall;

imi.default_arguments = p_def_args;
imi.argument_names = p_argnames;
Expand Down