diff --git a/core/class_db.h b/core/class_db.h index 4129a741474..490deb7873d 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -294,11 +294,11 @@ public: } template - static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector &p_default_args = Vector()) { + static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector &p_default_args = Vector(), bool p_return_nil_is_variant = true) { GLOBAL_LOCK_FUNCTION; - MethodBind *bind = create_vararg_method_bind(p_method, p_info); + MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant); ERR_FAIL_COND_V(!bind, NULL); bind->set_name(p_name); diff --git a/core/method_bind.h b/core/method_bind.h index 754d9f70e6a..1860d227f79 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -344,7 +344,7 @@ public: return (instance->*call_method)(p_args, p_arg_count, r_error); } - void set_method_info(const MethodInfo &p_info) { + void set_method_info(const MethodInfo &p_info, bool p_return_nil_is_variant) { set_argument_count(p_info.arguments.size()); #ifdef DEBUG_METHODS_ENABLED @@ -364,7 +364,9 @@ public: } argument_types = at; arguments = p_info; - arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + if (p_return_nil_is_variant) { + arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + } #endif } @@ -387,11 +389,11 @@ public: }; template -MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Variant::CallError &), const MethodInfo &p_info) { +MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Variant::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) { MethodBindVarArg *a = memnew((MethodBindVarArg)); a->set_method(p_method); - a->set_method_info(p_info); + a->set_method_info(p_info, p_return_nil_is_variant); return a; } diff --git a/core/object.cpp b/core/object.cpp index 984c2e3c55a..35ccc38d4e7 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1688,7 +1688,7 @@ void Object::_bind_methods() { mi.name = "emit_signal"; mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "emit_signal", &Object::_emit_signal, mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "emit_signal", &Object::_emit_signal, mi, varray(), false); } { @@ -1704,7 +1704,7 @@ void Object::_bind_methods() { mi.name = "call_deferred"; mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi, varray(), false); } ClassDB::bind_method(D_METHOD("set_deferred", "property", "value"), &Object::set_deferred); diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 98a9db5d3b2..5d1144e1f57 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -520,7 +520,7 @@ void UndoRedo::_bind_methods() { mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object")); mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_do_method", &UndoRedo::_add_do_method, mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_do_method", &UndoRedo::_add_do_method, mi, varray(), false); } { @@ -529,7 +529,7 @@ void UndoRedo::_bind_methods() { mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object")); mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi, varray(), false); } ClassDB::bind_method(D_METHOD("add_do_property", "object", "property", "value"), &UndoRedo::add_do_property); diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index 1e5b8669fd2..1d7e5f80808 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -99,12 +99,12 @@ - + - Calls the [code]method[/code] on the object during idle time and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: + Calls the [code]method[/code] on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblock] call_deferred("set", "position", Vector2(42.0, 0.0)) [/codeblock] @@ -178,7 +178,7 @@ - + diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index 7834719af63..52ff7ef38b1 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -32,7 +32,7 @@ - + @@ -65,7 +65,7 @@ - +