diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-08-08 18:23:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-08 18:23:36 +0200 |
commit | 5d9967ef0071b8ecc36db45640cb3eb66adb5f14 (patch) | |
tree | 5f2661deaee0f5dce013ecc80e9cdda2c0c51f09 | |
parent | 4f6a21b0df772804b67073dc65f000f571a4511e (diff) | |
parent | 4cd246898e00bd029af95f3b5fafe7a1e979ceff (diff) |
Merge pull request #6055 from eska014/native-bind-rettype
Allow documenting unexposed return types in bind_native_method
-rw-r--r-- | core/object.cpp | 2 | ||||
-rw-r--r-- | core/object_type_db.h | 11 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/core/object.cpp b/core/object.cpp index dc3d531927..26319d42dd 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1651,7 +1651,7 @@ void Object::_bind_methods() { } - ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call",&Object::_call_bind,mi,defargs); + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call:Variant",&Object::_call_bind,mi,defargs); } { diff --git a/core/object_type_db.h b/core/object_type_db.h index 9f7463e58b..3fcd38aa31 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -415,7 +415,7 @@ public: #endif template<class M> - static MethodBind* bind_native_method(uint32_t p_flags, const StringName& p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) { + static MethodBind* bind_native_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) { GLOBAL_LOCK_FUNCTION; @@ -423,6 +423,13 @@ public: MethodBind *bind = create_native_method_bind(p_method,p_info); ERR_FAIL_COND_V(!bind,NULL); + + String rettype; + if (p_name.operator String().find(":")!=-1) { + rettype = p_name.operator String().get_slice(":",1); + p_name = p_name.operator String().get_slice(":",0); + } + bind->set_name(p_name); bind->set_default_arguments(p_default_args); @@ -442,6 +449,8 @@ public: } type->method_map[p_name]=bind; #ifdef DEBUG_METHODS_ENABLED + if (!rettype.empty()) + bind->set_return_type(rettype); type->method_order.push_back(p_name); #endif diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 2f5c7956d1..2b8d6e86e2 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -707,7 +707,7 @@ void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const { void GDScript::_bind_methods() { - ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo("new")); + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo(Variant::OBJECT,"new")); ObjectTypeDB::bind_method(_MD("get_as_byte_code"),&GDScript::get_as_byte_code); |