Add support for variadic method binds with the typed return. Sync headers.
This commit is contained in:
@@ -13,6 +13,8 @@ func _ready():
|
||||
var ref = ExampleRef.new()
|
||||
prints("sending ref: ", ref.get_instance_id(), "returned ref: ", $Example.extended_ref_checks(ref).get_instance_id())
|
||||
prints("vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
|
||||
prints("vararg_nv ret", $Example.varargs_func_nv("some", "arguments", "to", "test"))
|
||||
$Example.varargs_func_void("some", "arguments", "to", "test")
|
||||
|
||||
prints("test array", $Example.test_array())
|
||||
prints("test dictionary", $Example.test_dictionary())
|
||||
|
||||
@@ -65,6 +65,20 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "varargs_func", &Example::varargs_func, mi);
|
||||
}
|
||||
|
||||
{
|
||||
MethodInfo mi;
|
||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
|
||||
mi.name = "varargs_func_nv";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "varargs_func_nv", &Example::varargs_func_nv, mi);
|
||||
}
|
||||
|
||||
{
|
||||
MethodInfo mi;
|
||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
|
||||
mi.name = "varargs_func_void";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "varargs_func_void", &Example::varargs_func_void, mi);
|
||||
}
|
||||
|
||||
// Properties.
|
||||
ADD_GROUP("Test group", "group_");
|
||||
ADD_SUBGROUP("Test subgroup", "group_subgroup_");
|
||||
@@ -129,10 +143,19 @@ Ref<ExampleRef> Example::extended_ref_checks(Ref<ExampleRef> p_ref) const {
|
||||
}
|
||||
|
||||
Variant Example::varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) {
|
||||
UtilityFunctions::print("Varargs called with ", String::num((double)arg_count), " arguments");
|
||||
UtilityFunctions::print("Varargs (Variant return) called with ", String::num((double)arg_count), " arguments");
|
||||
return arg_count;
|
||||
}
|
||||
|
||||
int Example::varargs_func_nv(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) {
|
||||
UtilityFunctions::print("Varargs (int return) called with ", String::num((double)arg_count), " arguments");
|
||||
return 42;
|
||||
}
|
||||
|
||||
void Example::varargs_func_void(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) {
|
||||
UtilityFunctions::print("Varargs (no return) called with ", String::num((double)arg_count), " arguments");
|
||||
}
|
||||
|
||||
void Example::emit_custom_signal(const String &name, int value) {
|
||||
emit_signal("custom_signal", name, value);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,8 @@ public:
|
||||
ExampleRef *return_extended_ref() const;
|
||||
Ref<ExampleRef> extended_ref_checks(Ref<ExampleRef> p_ref) const;
|
||||
Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
||||
int varargs_func_nv(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
||||
void varargs_func_void(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
||||
void emit_custom_signal(const String &name, int value);
|
||||
|
||||
Array test_array() const;
|
||||
|
||||
Reference in New Issue
Block a user