summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_lambda_callable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript_lambda_callable.cpp')
-rw-r--r--modules/gdscript/gdscript_lambda_callable.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_lambda_callable.cpp b/modules/gdscript/gdscript_lambda_callable.cpp
index 626ef6ccb0..2de5811bca 100644
--- a/modules/gdscript/gdscript_lambda_callable.cpp
+++ b/modules/gdscript/gdscript_lambda_callable.cpp
@@ -84,7 +84,7 @@ int GDScriptLambdaCallable::get_argument_count(bool &r_is_valid) const {
return 0;
}
r_is_valid = true;
- return function->get_argument_count();
+ return function->get_argument_count() - captures.size();
}
void GDScriptLambdaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
@@ -150,7 +150,7 @@ void GDScriptLambdaCallable::call(const Variant **p_arguments, int p_argcount, V
GDScriptLambdaCallable::GDScriptLambdaCallable(Ref<GDScript> p_script, GDScriptFunction *p_function, const Vector<Variant> &p_captures) :
function(p_function) {
- ERR_FAIL_NULL(p_script.ptr());
+ ERR_FAIL_COND(p_script.is_null());
ERR_FAIL_NULL(p_function);
script = p_script;
captures = p_captures;
@@ -198,13 +198,17 @@ ObjectID GDScriptLambdaSelfCallable::get_object() const {
return object->get_instance_id();
}
+StringName GDScriptLambdaSelfCallable::get_method() const {
+ return function->get_name();
+}
+
int GDScriptLambdaSelfCallable::get_argument_count(bool &r_is_valid) const {
if (function == nullptr) {
r_is_valid = false;
return 0;
}
r_is_valid = true;
- return function->get_argument_count();
+ return function->get_argument_count() - captures.size();
}
void GDScriptLambdaSelfCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
@@ -278,7 +282,7 @@ void GDScriptLambdaSelfCallable::call(const Variant **p_arguments, int p_argcoun
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Ref<RefCounted> p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) :
function(p_function) {
- ERR_FAIL_NULL(p_self.ptr());
+ ERR_FAIL_COND(p_self.is_null());
ERR_FAIL_NULL(p_function);
reference = p_self;
object = p_self.ptr();