Merge pull request #31172 from creikey/add-array-slicing

Add array slice method
This commit is contained in:
Rémi Verschelde 2019-09-23 15:26:27 +02:00 committed by GitHub
commit 2114898cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 101 additions and 0 deletions

View file

@ -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;

View file

@ -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"]
]
}
]
},

View file

@ -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);