Merge pull request #80844 from dalexeev/fix-callable-expected-argc
Fix expected argument count for `Callable` call errors
This commit is contained in:
commit
e95b7e84a4
|
@ -617,7 +617,7 @@ void Object::get_method_list(List<MethodInfo> *p_list) const {
|
|||
Variant Object::_call_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ Variant Object::_call_bind(const Variant **p_args, int p_argcount, Callable::Cal
|
|||
Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -715,12 +715,11 @@ Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_
|
|||
//free must be here, before anything, always ready
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_argcount != 0) {
|
||||
r_error.argument = 0;
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.expected = 0;
|
||||
return Variant();
|
||||
}
|
||||
if (Object::cast_to<RefCounted>(this)) {
|
||||
r_error.argument = 0;
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference.");
|
||||
}
|
||||
|
@ -1036,14 +1035,17 @@ struct _ObjectSignalDisconnectData {
|
|||
};
|
||||
|
||||
Error Object::_emit_signal(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
if (unlikely(p_argcount < 1)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.expected = 1;
|
||||
ERR_FAIL_V(Error::ERR_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(p_argcount < 1, Error::ERR_INVALID_PARAMETER);
|
||||
if (p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING) {
|
||||
if (unlikely(p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::STRING_NAME;
|
||||
ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING, Error::ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_V(Error::ERR_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
r_error.error = Callable::CallError::CALL_OK;
|
||||
|
|
|
@ -404,13 +404,13 @@ void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Vari
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -422,7 +422,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const V
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -433,7 +433,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const V
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -455,13 +455,13 @@ void call_with_variant_argsc(T *p_instance, void (T::*p_method)(P...) const, con
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -473,7 +473,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -484,7 +484,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -506,7 +506,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -517,7 +517,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -539,7 +539,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -550,7 +550,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -785,13 +785,13 @@ void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Var
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -815,13 +815,13 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -833,13 +833,13 @@ void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -851,13 +851,13 @@ void call_with_variant_args_retc(T *p_instance, R (T::*p_method)(P...) const, co
|
|||
#ifdef DEBUG_METHODS_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)p_argcount < sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -882,7 +882,7 @@ void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -893,7 +893,7 @@ void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -928,7 +928,7 @@ void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -939,7 +939,7 @@ void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -961,7 +961,7 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -972,7 +972,7 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -994,7 +994,7 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const Variant **p_
|
|||
#ifdef DEBUG_ENABLED
|
||||
if ((size_t)p_argcount > sizeof...(P)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1005,7 +1005,7 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const Variant **p_
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (missing > dvs) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = sizeof...(P);
|
||||
r_error.expected = sizeof...(P);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -245,9 +245,8 @@ void CallableCustomUnbind::get_bound_arguments(Vector<Variant> &r_arguments, int
|
|||
}
|
||||
|
||||
void CallableCustomUnbind::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
|
||||
if (argcount > p_argcount) {
|
||||
if (p_argcount < argcount) {
|
||||
r_call_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_call_error.argument = 0;
|
||||
r_call_error.expected = argcount;
|
||||
return;
|
||||
}
|
||||
|
@ -255,9 +254,8 @@ void CallableCustomUnbind::call(const Variant **p_arguments, int p_argcount, Var
|
|||
}
|
||||
|
||||
Error CallableCustomUnbind::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const {
|
||||
if (argcount > p_argcount) {
|
||||
if (p_argcount < argcount) {
|
||||
r_call_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_call_error.argument = 0;
|
||||
r_call_error.expected = argcount;
|
||||
return ERR_UNCONFIGURED;
|
||||
}
|
||||
|
|
|
@ -1037,9 +1037,7 @@ struct _VariantCall {
|
|||
static void func_Callable_rpc_id(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
|
||||
if (p_argcount == 0) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
|
||||
} else if (p_args[0]->get_type() != Variant::INT) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = 0;
|
||||
|
|
|
@ -337,6 +337,7 @@ Variant VariantUtilityFunctions::snapped(const Variant &x, const Variant &step,
|
|||
if (x.get_type() != step.get_type() && !((x.get_type() == Variant::INT && step.get_type() == Variant::FLOAT) || (x.get_type() == Variant::FLOAT && step.get_type() == Variant::INT))) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = x.get_type();
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -384,8 +385,8 @@ Variant VariantUtilityFunctions::lerp(const Variant &from, const Variant &to, do
|
|||
r_error.error = Callable::CallError::CALL_OK;
|
||||
if (from.get_type() != to.get_type()) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = from.get_type();
|
||||
r_error.argument = 1;
|
||||
r_error.expected = from.get_type();
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -500,7 +501,7 @@ Variant VariantUtilityFunctions::wrap(const Variant &p_x, const Variant &p_min,
|
|||
if (x_type != Variant::INT && x_type != Variant::FLOAT) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = x_type;
|
||||
r_error.expected = Variant::FLOAT;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -566,8 +567,8 @@ Variant VariantUtilityFunctions::max(const Variant **p_args, int p_argcount, Cal
|
|||
Variant::Type arg_type = p_args[i]->get_type();
|
||||
if (arg_type != Variant::INT && arg_type != Variant::FLOAT) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = Variant::FLOAT;
|
||||
r_error.argument = i;
|
||||
r_error.expected = Variant::FLOAT;
|
||||
return Variant();
|
||||
}
|
||||
if (i == 0) {
|
||||
|
@ -577,8 +578,8 @@ Variant VariantUtilityFunctions::max(const Variant **p_args, int p_argcount, Cal
|
|||
Variant::evaluate(Variant::OP_LESS, base, *p_args[i], ret, valid);
|
||||
if (!valid) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = base.get_type();
|
||||
r_error.argument = i;
|
||||
r_error.expected = base.get_type();
|
||||
return Variant();
|
||||
}
|
||||
if (ret.booleanize()) {
|
||||
|
@ -610,8 +611,8 @@ Variant VariantUtilityFunctions::min(const Variant **p_args, int p_argcount, Cal
|
|||
Variant::Type arg_type = p_args[i]->get_type();
|
||||
if (arg_type != Variant::INT && arg_type != Variant::FLOAT) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = Variant::FLOAT;
|
||||
r_error.argument = i;
|
||||
r_error.expected = Variant::FLOAT;
|
||||
return Variant();
|
||||
}
|
||||
if (i == 0) {
|
||||
|
@ -621,8 +622,8 @@ Variant VariantUtilityFunctions::min(const Variant **p_args, int p_argcount, Cal
|
|||
Variant::evaluate(Variant::OP_GREATER, base, *p_args[i], ret, valid);
|
||||
if (!valid) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = base.get_type();
|
||||
r_error.argument = i;
|
||||
r_error.expected = base.get_type();
|
||||
return Variant();
|
||||
}
|
||||
if (ret.booleanize()) {
|
||||
|
@ -650,8 +651,8 @@ Variant VariantUtilityFunctions::clamp(const Variant &x, const Variant &min, con
|
|||
Variant::evaluate(Variant::OP_LESS, value, min, ret, valid);
|
||||
if (!valid) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = value.get_type();
|
||||
r_error.argument = 1;
|
||||
r_error.expected = value.get_type();
|
||||
return Variant();
|
||||
}
|
||||
if (ret.booleanize()) {
|
||||
|
@ -660,8 +661,8 @@ Variant VariantUtilityFunctions::clamp(const Variant &x, const Variant &min, con
|
|||
Variant::evaluate(Variant::OP_GREATER, value, max, ret, valid);
|
||||
if (!valid) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected = value.get_type();
|
||||
r_error.argument = 2;
|
||||
r_error.expected = value.get_type();
|
||||
return Variant();
|
||||
}
|
||||
if (ret.booleanize()) {
|
||||
|
@ -847,7 +848,7 @@ Variant VariantUtilityFunctions::type_convert(const Variant &p_variant, const Va
|
|||
String VariantUtilityFunctions::str(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
||||
if (p_arg_count < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
return String();
|
||||
}
|
||||
String s;
|
||||
|
@ -991,7 +992,7 @@ void VariantUtilityFunctions::printraw(const Variant **p_args, int p_arg_count,
|
|||
void VariantUtilityFunctions::push_error(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
||||
if (p_arg_count < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
}
|
||||
String s;
|
||||
for (int i = 0; i < p_arg_count; i++) {
|
||||
|
@ -1011,7 +1012,7 @@ void VariantUtilityFunctions::push_error(const Variant **p_args, int p_arg_count
|
|||
void VariantUtilityFunctions::push_warning(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
||||
if (p_arg_count < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
}
|
||||
String s;
|
||||
for (int i = 0; i < p_arg_count; i++) {
|
||||
|
@ -1759,14 +1760,12 @@ void Variant::call_utility_function(const StringName &p_name, Variant *r_ret, co
|
|||
|
||||
if (unlikely(!bfi->is_vararg && p_argcount < bfi->argcount)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = bfi->argcount;
|
||||
return;
|
||||
}
|
||||
|
||||
if (unlikely(!bfi->is_vararg && p_argcount > bfi->argcount)) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = bfi->argcount;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ void EditorUndoRedoManager::add_undo_methodp(Object *p_object, const StringName
|
|||
void EditorUndoRedoManager::_add_do_method(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 2) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ void EditorUndoRedoManager::_add_do_method(const Variant **p_args, int p_argcoun
|
|||
void EditorUndoRedoManager::_add_undo_method(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 2) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
|
|||
|
||||
if (p_argcount == 0) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
return Variant();
|
||||
} else if (p_argcount == 1) {
|
||||
//noooneee
|
||||
|
|
|
@ -45,14 +45,12 @@
|
|||
#define VALIDATE_ARG_COUNT(m_count) \
|
||||
if (p_arg_count < m_count) { \
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; \
|
||||
r_error.argument = m_count; \
|
||||
r_error.expected = m_count; \
|
||||
*r_ret = Variant(); \
|
||||
return; \
|
||||
} \
|
||||
if (p_arg_count > m_count) { \
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; \
|
||||
r_error.argument = m_count; \
|
||||
r_error.expected = m_count; \
|
||||
*r_ret = Variant(); \
|
||||
return; \
|
||||
|
@ -119,7 +117,6 @@ struct GDScriptUtilityFunctionsDefinitions {
|
|||
switch (p_arg_count) {
|
||||
case 0: {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
*r_ret = Variant();
|
||||
} break;
|
||||
|
@ -223,7 +220,6 @@ struct GDScriptUtilityFunctionsDefinitions {
|
|||
} break;
|
||||
default: {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = 3;
|
||||
r_error.expected = 3;
|
||||
*r_ret = Variant();
|
||||
|
||||
|
@ -251,6 +247,7 @@ struct GDScriptUtilityFunctionsDefinitions {
|
|||
} else if (p_args[0]->get_type() != Variant::OBJECT) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::OBJECT;
|
||||
*r_ret = Variant();
|
||||
} else {
|
||||
Object *obj = *p_args[0];
|
||||
|
@ -390,13 +387,13 @@ struct GDScriptUtilityFunctionsDefinitions {
|
|||
static inline void Color8(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
||||
if (p_arg_count < 3) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 3;
|
||||
r_error.expected = 3;
|
||||
*r_ret = Variant();
|
||||
return;
|
||||
}
|
||||
if (p_arg_count > 4) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = 4;
|
||||
r_error.expected = 4;
|
||||
*r_ret = Variant();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -519,7 +519,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
if (p_argcount > _argument_count) {
|
||||
r_err.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_err.expected = _argument_count;
|
||||
|
||||
call_depth--;
|
||||
return _get_default_variant_for_data_type(return_type);
|
||||
} else if (p_argcount < _argument_count - _default_arg_count) {
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace Godot.NativeInterop
|
|||
}
|
||||
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS:
|
||||
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS:
|
||||
return $"Invalid call to {where}. Expected {error.Argument} arguments.";
|
||||
return $"Invalid call to {where}. Expected {error.Expected} arguments.";
|
||||
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD:
|
||||
return $"Invalid call. Nonexistent {where}.";
|
||||
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL:
|
||||
|
|
|
@ -50,14 +50,14 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
|||
}
|
||||
|
||||
int pc = E.param_types.size();
|
||||
if (pc > p_argcount) {
|
||||
if (p_argcount < pc) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = pc;
|
||||
r_error.expected = pc;
|
||||
continue;
|
||||
}
|
||||
if (pc < p_argcount) {
|
||||
if (p_argcount > pc) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||
r_error.argument = pc;
|
||||
r_error.expected = pc;
|
||||
continue;
|
||||
}
|
||||
uint32_t *ptypes = E.param_types.ptrw();
|
||||
|
|
|
@ -96,7 +96,7 @@ Ref<JavaScriptObject> JavaScriptBridge::create_callback(const Callable &p_callab
|
|||
Variant JavaScriptBridge::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Ref<JavaScriptObject>();
|
||||
}
|
||||
if (p_args[0]->get_type() != Variant::STRING) {
|
||||
|
|
|
@ -289,7 +289,7 @@ Ref<JavaScriptObject> JavaScriptBridge::get_interface(const String &p_interface)
|
|||
Variant JavaScriptBridge::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Ref<JavaScriptObject>();
|
||||
}
|
||||
if (p_args[0]->get_type() != Variant::STRING) {
|
||||
|
|
|
@ -1476,7 +1476,7 @@ Size2 TreeItem::get_minimum_size(int p_column) {
|
|||
void TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ const Variant Node::get_node_rpc_config() const {
|
|||
Error Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 1;
|
||||
r_error.expected = 1;
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -697,7 +697,7 @@ Error Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallErro
|
|||
Error Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 2) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 2;
|
||||
r_error.expected = 2;
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -3162,7 +3162,7 @@ void Node::unhandled_key_input(const Ref<InputEvent> &p_key_event) {
|
|||
Variant Node::_call_deferred_thread_group_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -3185,7 +3185,7 @@ Variant Node::_call_deferred_thread_group_bind(const Variant **p_args, int p_arg
|
|||
Variant Node::_call_thread_safe_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
r_error.expected = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue