summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-03-12 14:30:38 -0500
committerGitHub <noreply@github.com>2024-03-12 14:30:38 -0500
commite6b6df5893c7d9ead150f9f058b36c6352a152a9 (patch)
treeb47e2f43afaad2e36fc9cfe159c6ebbbe64ec909 /test/src
parentd78fe9853f012e8594dfbe404327173386a0c76c (diff)
parent8c98a90f321cebdb70cabb46a84557355918848f (diff)
downloadredot-cpp-e6b6df5893c7d9ead150f9f058b36c6352a152a9.tar.gz
Merge pull request #1399 from bruvzg/init_list
[Packed*Array] Add support for initializer lists.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/example.cpp10
-rw-r--r--test/src/example.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index ede39ec..e51672f 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -197,6 +197,7 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("test_string_is_fourty_two"), &Example::test_string_is_fourty_two);
ClassDB::bind_method(D_METHOD("test_string_resize"), &Example::test_string_resize);
ClassDB::bind_method(D_METHOD("test_vector_ops"), &Example::test_vector_ops);
+ ClassDB::bind_method(D_METHOD("test_vector_init_list"), &Example::test_vector_init_list);
ClassDB::bind_method(D_METHOD("test_object_cast_to_node", "object"), &Example::test_object_cast_to_node);
ClassDB::bind_method(D_METHOD("test_object_cast_to_control", "object"), &Example::test_object_cast_to_control);
@@ -411,6 +412,15 @@ int Example::test_vector_ops() const {
return ret;
}
+int Example::test_vector_init_list() const {
+ PackedInt32Array arr = { 10, 20, 30, 45 };
+ int ret = 0;
+ for (const int32_t &E : arr) {
+ ret += E;
+ }
+ return ret;
+}
+
Callable Example::test_callable_mp() {
return callable_mp(this, &Example::unbound_method1);
}
diff --git a/test/src/example.h b/test/src/example.h
index c66ee96..0ad9493 100644
--- a/test/src/example.h
+++ b/test/src/example.h
@@ -130,6 +130,7 @@ public:
bool test_string_is_fourty_two(const String &p_str) const;
String test_string_resize(String p_original) const;
int test_vector_ops() const;
+ int test_vector_init_list() const;
bool test_object_cast_to_node(Object *p_object) const;
bool test_object_cast_to_control(Object *p_object) const;