summaryrefslogtreecommitdiffstats
path: root/test/src/example.cpp
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2021-09-16 17:21:40 +1000
committerBastiaan Olij <mux213@gmail.com>2021-11-12 14:29:54 +1100
commitc2b690439f77e3152835bb94bba006705618661d (patch)
treec89d4f3b69e61ef5155a797ec4848e6569c0fa81 /test/src/example.cpp
parent271e33658db6558698153472b4a2dec15a4253ba (diff)
downloadredot-cpp-c2b690439f77e3152835bb94bba006705618661d.tar.gz
Implement index operators for Arrays
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r--test/src/example.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 4d34d4c..5eaa4bb 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -54,6 +54,7 @@ void Example::_bind_methods() {
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);
+ ClassDB::bind_method(D_METHOD("test_array"), &Example::test_array);
{
MethodInfo mi;
@@ -81,6 +82,14 @@ void Example::_bind_methods() {
BIND_CONSTANT(CONSTANT_WITHOUT_ENUM);
}
+Example::Example() {
+ UtilityFunctions::print("Constructor.");
+}
+
+Example::~Example() {
+ UtilityFunctions::print("Destructor.");
+}
+
// Methods.
void Example::simple_func() {
UtilityFunctions::print("Simple func called.");
@@ -126,6 +135,16 @@ void Example::emit_custom_signal(const String &name, int value) {
emit_signal("custom_signal", name, value);
}
+Array Example::test_array() const {
+ Array arr;
+
+ arr.resize(2);
+ arr[0] = Variant(1);
+ arr[1] = Variant(2);
+
+ return arr;
+}
+
// Properties.
void Example::set_custom_position(const Vector2 &pos) {
custom_position = pos;