1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use sys;
use get_api;
use Variant;
use GodotType;
use VariantArray;
use GodotString;
pub struct StringArray(pub(crate) sys::godot_pool_string_array);
impl StringArray {
pub fn new() -> Self { StringArray::default() }
pub fn from_variant_array(array: &VariantArray) -> Self {
unsafe {
let mut result = sys::godot_pool_string_array::default();
(get_api().godot_pool_string_array_new_with_array)(&mut result, &array.0);
StringArray(result)
}
}
pub fn push(&mut self, s: &GodotString) {
unsafe {
(get_api().godot_pool_string_array_append)(&mut self.0, &s.0);
}
}
pub fn push_string_array(&mut self, strings: &StringArray) {
unsafe {
(get_api().godot_pool_string_array_append_array)(&mut self.0, &strings.0);
}
}
pub fn insert(&mut self, offset: i32, string: &GodotString) -> bool {
unsafe {
let status = (get_api().godot_pool_string_array_insert)(&mut self.0, offset, &string.0);
status != sys::godot_error::GODOT_OK
}
}
pub fn invert(&mut self) {
unsafe {
(get_api().godot_pool_string_array_invert)(&mut self.0)
}
}
pub fn remove(&mut self, idx: i32) {
unsafe {
(get_api().godot_pool_string_array_remove)(&mut self.0, idx);
}
}
pub fn resize(&mut self, size: i32) {
unsafe {
(get_api().godot_pool_string_array_resize)(&mut self.0, size);
}
}
pub fn get(&self, idx: i32) -> GodotString {
unsafe {
GodotString((get_api().godot_pool_string_array_get)(&self.0, idx))
}
}
pub fn set(&mut self, idx: i32, string: &GodotString) {
unsafe {
(get_api().godot_pool_string_array_set)(&mut self.0, idx, &string.0);
}
}
pub fn len(&self) -> i32 {
unsafe {
(get_api().godot_pool_string_array_size)(&self.0)
}
}
impl_common_methods! {
pub fn new_ref(&self) -> StringArray : godot_pool_string_array_new_copy;
}
}
impl_basic_traits!(
for StringArray as godot_pool_string_array {
Drop => godot_pool_string_array_destroy;
Default => godot_pool_string_array_new;
}
);
impl GodotType for StringArray {
fn to_variant(&self) -> Variant { Variant::from_string_array(self) }
fn from_variant(variant: &Variant) -> Option<Self> { variant.try_to_string_array() }
}