diff options
Diffstat (limited to 'core/variant_call.cpp')
-rw-r--r-- | core/variant_call.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 0055138582..84015d2b04 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -249,6 +249,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(String,ends_with); VCALL_LOCALMEM1R(String,is_subsequence_of); VCALL_LOCALMEM1R(String,is_subsequence_ofi); + VCALL_LOCALMEM0R(String,bigrams); + VCALL_LOCALMEM1R(String,similarity); VCALL_LOCALMEM2R(String,replace); VCALL_LOCALMEM2R(String,replacen); VCALL_LOCALMEM2R(String,insert); @@ -937,26 +939,32 @@ _VariantCall::ConstantData* _VariantCall::constant_data=NULL; Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error) { Variant ret; + call_ptr(p_method,p_args,p_argcount,&ret,r_error); + return ret; +} + +void Variant::call_ptr(const StringName& p_method,const Variant** p_args,int p_argcount,Variant* r_ret,CallError &r_error) { + Variant ret; if (type==Variant::OBJECT) { //call object Object *obj = _get_obj().obj; if (!obj) { r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL; - return ret; + return; } #ifdef DEBUG_ENABLED if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) { //only if debugging! if (!ObjectDB::instance_validate(obj)) { r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL; - return ret; + return; } } #endif - return _get_obj().obj->call(p_method,p_args,p_argcount,r_error); + ret=_get_obj().obj->call(p_method,p_args,p_argcount,r_error); //else if (type==Variant::METHOD) { @@ -968,14 +976,15 @@ Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_ar #ifdef DEBUG_ENABLED if (!E) { r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; - return Variant(); + return; } #endif _VariantCall::FuncData& funcdata = E->get(); funcdata.call(ret,*this,p_args,p_argcount,r_error); } - return ret; + if (r_error.error==Variant::CallError::CALL_OK && r_ret) + *r_ret=ret; } #define VCALL(m_type,m_method) _VariantCall::_call_##m_type##_##m_method @@ -1274,6 +1283,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(STRING,BOOL,String,ends_with,STRING,"text",varray()); ADDFUNC1(STRING,BOOL,String,is_subsequence_of,STRING,"text",varray()); ADDFUNC1(STRING,BOOL,String,is_subsequence_ofi,STRING,"text",varray()); + ADDFUNC0(STRING,STRING_ARRAY,String,bigrams,varray()); + ADDFUNC1(STRING,REAL,String,similarity,STRING,"text",varray()); ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray()); ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray()); |