1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Properly report Callable bound arguments

Fixes #63213
Adds a function: Callable::get_amount_of_arguments_bound() to query this in callables. Exposed to the engine API.
This commit is contained in:
Juan Linietsky
2023-01-06 15:37:53 +01:00
parent b14f7aa9f9
commit 0e0ca01bce
7 changed files with 32 additions and 2 deletions

View File

@@ -87,6 +87,10 @@ const Callable *CallableCustomBind::get_base_comparator() const {
return &callable;
}
int CallableCustomBind::get_bound_arguments_count() const {
return callable.get_bound_arguments_count() + binds.size();
}
void CallableCustomBind::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
const Variant **args = (const Variant **)alloca(sizeof(const Variant **) * (binds.size() + p_argcount));
for (int i = 0; i < p_argcount; i++) {
@@ -164,6 +168,10 @@ const Callable *CallableCustomUnbind::get_base_comparator() const {
return &callable;
}
int CallableCustomUnbind::get_bound_arguments_count() const {
return callable.get_bound_arguments_count() - argcount;
}
void CallableCustomUnbind::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
if (argcount > p_argcount) {
r_call_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;