Merge pull request #34745 from timothyqiu/vararg-return-nil-34743
Allows to doc vararg method return type as void
This commit is contained in:
commit
a97b08e7d2
6 changed files with 17 additions and 15 deletions
|
@ -294,11 +294,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
|
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
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);
|
ERR_FAIL_COND_V(!bind, NULL);
|
||||||
|
|
||||||
bind->set_name(p_name);
|
bind->set_name(p_name);
|
||||||
|
|
|
@ -344,7 +344,7 @@ public:
|
||||||
return (instance->*call_method)(p_args, p_arg_count, r_error);
|
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());
|
set_argument_count(p_info.arguments.size());
|
||||||
#ifdef DEBUG_METHODS_ENABLED
|
#ifdef DEBUG_METHODS_ENABLED
|
||||||
|
@ -364,7 +364,9 @@ public:
|
||||||
}
|
}
|
||||||
argument_types = at;
|
argument_types = at;
|
||||||
arguments = p_info;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,11 +389,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
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<T> *a = memnew((MethodBindVarArg<T>));
|
MethodBindVarArg<T> *a = memnew((MethodBindVarArg<T>));
|
||||||
a->set_method(p_method);
|
a->set_method(p_method);
|
||||||
a->set_method_info(p_info);
|
a->set_method_info(p_info, p_return_nil_is_variant);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1688,7 +1688,7 @@ void Object::_bind_methods() {
|
||||||
mi.name = "emit_signal";
|
mi.name = "emit_signal";
|
||||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "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.name = "call_deferred";
|
||||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
|
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);
|
ClassDB::bind_method(D_METHOD("set_deferred", "property", "value"), &Object::set_deferred);
|
||||||
|
|
|
@ -520,7 +520,7 @@ void UndoRedo::_bind_methods() {
|
||||||
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
|
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
|
||||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
|
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::OBJECT, "object"));
|
||||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
|
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);
|
ClassDB::bind_method(D_METHOD("add_do_property", "object", "property", "value"), &UndoRedo::add_do_property);
|
||||||
|
|
|
@ -99,12 +99,12 @@
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="call_deferred" qualifiers="vararg">
|
<method name="call_deferred" qualifiers="vararg">
|
||||||
<return type="Variant">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="method" type="String">
|
<argument index="0" name="method" type="String">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
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]
|
[codeblock]
|
||||||
call_deferred("set", "position", Vector2(42.0, 0.0))
|
call_deferred("set", "position", Vector2(42.0, 0.0))
|
||||||
[/codeblock]
|
[/codeblock]
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="emit_signal" qualifiers="vararg">
|
<method name="emit_signal" qualifiers="vararg">
|
||||||
<return type="Variant">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="signal" type="String">
|
<argument index="0" name="signal" type="String">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
<method name="add_do_method" qualifiers="vararg">
|
<method name="add_do_method" qualifiers="vararg">
|
||||||
<return type="Variant">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="object" type="Object">
|
<argument index="0" name="object" type="Object">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="add_undo_method" qualifiers="vararg">
|
<method name="add_undo_method" qualifiers="vararg">
|
||||||
<return type="Variant">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="object" type="Object">
|
<argument index="0" name="object" type="Object">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
Loading…
Reference in a new issue