diff options
| author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-01-10 11:48:21 +0100 |
|---|---|---|
| committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-01-10 12:55:41 +0100 |
| commit | 9fd33b5cdedd214f6defc89049f520770e164260 (patch) | |
| tree | 549c1461e7d19c97e3531b3708ff6090cd167d8c /test/src | |
| parent | 129c358a72ff7baad0ca1e03ddaad96564de239a (diff) | |
| download | redot-cpp-9fd33b5cdedd214f6defc89049f520770e164260.tar.gz | |
Allow method binds to take Object subclasses as arguments
As done in upstream Godot via GH-57205.
Add a test that ensures it works also for "gdextended" objects.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/example.cpp | 6 | ||||
| -rw-r--r-- | test/src/example.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp index 2697e45..6da1f52 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -122,6 +122,7 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("test_tarray_arg", "array"), &Example::test_tarray_arg); ClassDB::bind_method(D_METHOD("test_tarray"), &Example::test_tarray); ClassDB::bind_method(D_METHOD("test_dictionary"), &Example::test_dictionary); + ClassDB::bind_method(D_METHOD("test_node_argument"), &Example::test_node_argument); ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200)); @@ -212,6 +213,11 @@ ExampleRef *Example::return_extended_ref() const { return memnew(ExampleRef()); } +Example *Example::test_node_argument(Example *p_node) const { + UtilityFunctions::print(" Test node argument called with ", p_node ? String::num(p_node->get_instance_id()) : "null"); + return p_node; +} + Ref<ExampleRef> Example::extended_ref_checks(Ref<ExampleRef> p_ref) const { // This is therefor the prefered way of instancing and returning a refcounted object: Ref<ExampleRef> ref; diff --git a/test/src/example.h b/test/src/example.h index c181f0d..6857be2 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -100,6 +100,7 @@ public: void test_tarray_arg(const TypedArray<int64_t> &p_array); TypedArray<Vector2> test_tarray() const; Dictionary test_dictionary() const; + Example *test_node_argument(Example *p_node) const; // Property. void set_custom_position(const Vector2 &pos); |
