summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCameron Reikes <cameronreikes@gmail.com>2019-07-16 18:31:58 -0700
committerCameron Reikes <cameronreikes@gmail.com>2019-09-14 13:08:28 -0700
commit757c509437720b50056bd67f8d4e463c38c5b13e (patch)
tree2a1f4235d5e4c340472972dba0d39b504d2e54c8 /modules
parent24e1039eb6fe32115e8d1a62a84965e9be19a2ed (diff)
Add array slice method
Diffstat (limited to 'modules')
-rw-r--r--modules/gdnative/gdnative/array.cpp9
-rw-r--r--modules/gdnative/gdnative_api.json11
-rw-r--r--modules/gdnative/include/gdnative/array.h2
3 files changed, 22 insertions, 0 deletions
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 1ef8e9f900..e97a75cca8 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -327,6 +327,15 @@ godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_b
return res;
}
+godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_step, const godot_bool p_deep) {
+ const Array *self = (const Array *)p_self;
+ godot_array res;
+ Array *val = (Array *)&res;
+ memnew_placement(val, Array);
+ *val = self->slice(p_begin, p_end, p_step, p_deep);
+ return res;
+}
+
godot_variant GDAPI godot_array_max(const godot_array *p_self) {
const Array *self = (const Array *)p_self;
godot_variant v;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 03258584ce..55ba4ecc1e 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -80,6 +80,17 @@
["const godot_vector2 *", "p_self"],
["const godot_vector2 *", "p_to"]
]
+ },
+ {
+ "name": "godot_array_slice",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_array *", "p_self"],
+ ["const godot_int", "p_begin"],
+ ["const godot_int", "p_end"],
+ ["const godot_int", "p_step"],
+ ["const godot_bool", "p_deep"]
+ ]
}
]
},
diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h
index 10ef8a73d2..2e3ce58033 100644
--- a/modules/gdnative/include/gdnative/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -132,6 +132,8 @@ void GDAPI godot_array_destroy(godot_array *p_self);
godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_bool p_deep);
+godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_delta, const godot_bool p_deep);
+
godot_variant GDAPI godot_array_max(const godot_array *p_self);
godot_variant GDAPI godot_array_min(const godot_array *p_self);