summaryrefslogtreecommitdiffstats
path: root/core/variant.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-04 09:35:21 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-04 09:35:21 -0300
commit3d0bd1a3f38d39c62dd3471d07b7bcb40acfc5e7 (patch)
tree216c8bde3eafb2300fd5d4c49ec95354dcc7306e /core/variant.cpp
parent30d4a50b424c927b178cabfe30302de1e9d4c836 (diff)
downloadredot-engine-3d0bd1a3f38d39c62dd3471d07b7bcb40acfc5e7.tar.gz
-make signals throw an error when target method is not found, fixes #2036
-removed 4 arguments limit for emit_signal() from script -remvoed 4 arguments limit for call_deferred() from script
Diffstat (limited to 'core/variant.cpp')
-rw-r--r--core/variant.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/variant.cpp b/core/variant.cpp
index 674c57a0fc..3bd8d80528 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -2992,3 +2992,32 @@ String Variant::get_construct_string() const {
return vars;
}
+
+String Variant::get_call_error_text(Object* p_base, const StringName& p_method,const Variant** p_argptrs,int p_argcount,const Variant::CallError &ce) {
+
+
+ String err_text;
+
+ if (ce.error==Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
+ int errorarg=ce.argument;
+ err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+".";
+ } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
+ err_text="Expected "+itos(ce.argument)+" arguments.";
+ } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
+ err_text="Expected "+itos(ce.argument)+" arguments.";
+ } else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ err_text="Method not found.";
+ } else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
+ err_text="Instance is null";
+ } else if (ce.error==Variant::CallError::CALL_OK){
+ return "Call OK";
+ }
+
+ String class_name = p_base->get_type();
+ Ref<Script> script = p_base->get_script();
+ if (script.is_valid() && script->get_path().is_resource_file()) {
+
+ class_name+="("+script->get_path().get_file()+")";
+ }
+ return "'"+class_name+"::"+String(p_method)+"': "+err_text;
+}