summaryrefslogtreecommitdiffstats
path: root/core/variant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant.cpp')
-rw-r--r--core/variant.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/variant.cpp b/core/variant.cpp
index ab560e0d45..3bd8d80528 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -706,6 +706,17 @@ bool Variant::operator==(const Variant& p_variant) const {
}
+bool Variant::operator!=(const Variant& p_variant) const {
+
+ if (type!=p_variant.type) //evaluation of operator== needs to be more strict
+ return true;
+ bool v;
+ Variant r;
+ evaluate(OP_NOT_EQUAL,*this,p_variant,r,v);
+ return r;
+
+}
+
bool Variant::operator<(const Variant& p_variant) const {
if (type!=p_variant.type) //if types differ, then order by type first
return type<p_variant.type;
@@ -2981,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;
+}