summaryrefslogtreecommitdiffstats
path: root/test/src/example.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-23 09:19:37 +0200
committerGitHub <noreply@github.com>2022-09-23 09:19:37 +0200
commite40aa112ee8e784f21c86083095b391672c709b6 (patch)
tree6dc49d29ada00ecae5b964a3d9de27045ba732a5 /test/src/example.cpp
parent86703055894cb2555f0ec704eff11e3c1c81a5d3 (diff)
parentc001d0e5c7cb4651196d63bc5a385dad5509c827 (diff)
downloadredot-cpp-e40aa112ee8e784f21c86083095b391672c709b6.tar.gz
Merge pull request #841 from bruvzg/typed_array
Implement support for typed arrays.
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r--test/src/example.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 09258f4..890319d 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -103,6 +103,8 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("extended_ref_checks"), &Example::extended_ref_checks);
ClassDB::bind_method(D_METHOD("test_array"), &Example::test_array);
+ 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("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200));
@@ -223,6 +225,22 @@ Array Example::test_array() const {
return arr;
}
+void Example::test_tarray_arg(const TypedArray<int64_t> &p_array) {
+ for (int i = 0; i < p_array.size(); i++) {
+ UtilityFunctions::print(p_array[i]);
+ }
+}
+
+TypedArray<Vector2> Example::test_tarray() const {
+ TypedArray<Vector2> arr;
+
+ arr.resize(2);
+ arr[0] = Vector2(1, 2);
+ arr[1] = Vector2(2, 3);
+
+ return arr;
+}
+
Dictionary Example::test_dictionary() const {
Dictionary dict;