diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-28 15:49:53 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-28 15:49:53 +0200 |
commit | b28853aff1a917c3a9ad47915856ea0fd2373254 (patch) | |
tree | 217069f13d881c9f7078999026cc8a3fe0d48bca /test/src/example.cpp | |
parent | b90d0ac555035c4db9ebc2a3516acff72e5cfb43 (diff) | |
download | redot-cpp-b28853aff1a917c3a9ad47915856ea0fd2373254.tar.gz |
Add test for Reference passing/returning.
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r-- | test/src/example.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp index e3ed316..4d34d4c 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -53,6 +53,7 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("return_something"), &Example::return_something); ClassDB::bind_method(D_METHOD("return_something_const"), &Example::return_something_const); ClassDB::bind_method(D_METHOD("return_extended_ref"), &Example::return_extended_ref); + ClassDB::bind_method(D_METHOD("extended_ref_checks"), &Example::extended_ref_checks); { MethodInfo mi; @@ -107,6 +108,15 @@ ExampleRef *Example::return_extended_ref() const { return memnew(ExampleRef()); } +Ref<ExampleRef> Example::extended_ref_checks(Ref<ExampleRef> p_ref) const { + Ref<ExampleRef> ref; + ref.instantiate(); + // TODO the returned value gets dereferenced too early and return a null object otherwise. + ref->reference(); + UtilityFunctions::print("Example ref checks called with value: ", p_ref->get_instance_id(), ", returning value: ", ref->get_instance_id()); + return ref; +} + Variant Example::varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) { UtilityFunctions::print("Varargs called with ", String::num(arg_count), " arguments"); return arg_count; |