diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-03-13 22:57:24 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-03-13 22:57:24 -0300 |
commit | 31ce3c5fd0300aac1e86bced1efc5f9ec94bdb6b (patch) | |
tree | b6d3a290333c72940b49ed4c930ff6858a59515e /modules/gdscript | |
parent | a65edb4caabec21654c56552e11aacf0fd9291de (diff) |
-fix bug in cache for atlas import/export
-fix some menus
-fixed bug in out transition curves
-detect and remove file:/// in collada
-remove multiscript for now
-remove dependencies on mouse in OS, moved to Input
-avoid fscache from screwing up (fix might make it slower, but it works)
-funcref was missing, it's there now
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 41 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 1 |
2 files changed, 41 insertions, 1 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 2930d9322c..c099c3f33c 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -31,6 +31,7 @@ #include "object_type_db.h" #include "reference.h" #include "gd_script.h" +#include "func_ref.h" #include "os/os.h" const char *GDFunctions::get_func_name(Function p_func) { @@ -80,6 +81,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "clamp", "nearest_po2", "weakref", + "funcref", "convert", "typeof", "str", @@ -452,6 +454,36 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } break; + case FUNC_FUNCREF: { + VALIDATE_ARG_COUNT(2); + if (p_args[0]->get_type()!=Variant::OBJECT) { + + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + r_ret=Variant(); + return; + + } + if (p_args[1]->get_type()!=Variant::STRING && p_args[1]->get_type()!=Variant::NODE_PATH) { + + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + r_ret=Variant(); + return; + + } + + Ref<FuncRef> fr = memnew( FuncRef); + + Object *obj = *p_args[0]; + fr->set_instance(*p_args[0]); + fr->set_function(*p_args[1]); + + r_ret=fr; + + } break; case TYPE_CONVERT: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(1); @@ -678,7 +710,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } r_ret=ResourceLoader::load(*p_args[0]); - } + } break; case INST2DICT: { VALIDATE_ARG_COUNT(1); @@ -1130,6 +1162,13 @@ MethodInfo GDFunctions::get_info(Function p_func) { return mi; } break; + case FUNC_FUNCREF: { + + MethodInfo mi("funcref",PropertyInfo(Variant::OBJECT,"instance"),PropertyInfo(Variant::STRING,"funcname")); + mi.return_val.type=Variant::OBJECT; + return mi; + + } break; case TYPE_CONVERT: { MethodInfo mi("convert",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::INT,"type")); diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 2ab397d18a..9255e5e2c5 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -77,6 +77,7 @@ public: LOGIC_CLAMP, LOGIC_NEAREST_PO2, OBJ_WEAKREF, + FUNC_FUNCREF, TYPE_CONVERT, TYPE_OF, TEXT_STR, |