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
use sys;
use get_api;
use Variant;
use GodotType;
use VariantArray;
pub struct Float32Array(pub(crate) sys::godot_pool_real_array);
impl Float32Array {
pub fn new() -> Self { Float32Array::default() }
pub fn from_variant_array(array: &VariantArray) -> Self {
unsafe {
let mut result = sys::godot_pool_real_array::default();
(get_api().godot_pool_real_array_new_with_array)(&mut result, &array.0);
Float32Array(result)
}
}
pub fn push(&mut self, val: f32) {
unsafe {
(get_api().godot_pool_real_array_append)(&mut self.0, val);
}
}
pub fn push_array(&mut self, array: &Float32Array) {
unsafe {
(get_api().godot_pool_real_array_append_array)(&mut self.0, &array.0);
}
}
pub fn insert(&mut self, offset: i32, val: f32) -> bool {
unsafe {
let status = (get_api().godot_pool_real_array_insert)(&mut self.0, offset, val);
status != sys::godot_error::GODOT_OK
}
}
pub fn invert(&mut self) {
unsafe {
(get_api().godot_pool_real_array_invert)(&mut self.0)
}
}
pub fn remove(&mut self, idx: i32) {
unsafe {
(get_api().godot_pool_real_array_remove)(&mut self.0, idx);
}
}
pub fn resize(&mut self, size: i32) {
unsafe {
(get_api().godot_pool_real_array_resize)(&mut self.0, size);
}
}
pub fn get(&self, idx: i32) -> f32 {
unsafe {
(get_api().godot_pool_real_array_get)(&self.0, idx)
}
}
pub fn set(&mut self, idx: i32, val: f32) {
unsafe {
(get_api().godot_pool_real_array_set)(&mut self.0, idx, val);
}
}
pub fn len(&self) -> i32 {
unsafe {
(get_api().godot_pool_real_array_size)(&self.0)
}
}
impl_common_methods! {
pub fn new_ref(&self) -> Float32Array : godot_pool_real_array_new_copy;
}
}
impl_basic_traits!(
for Float32Array as godot_pool_real_array {
Drop => godot_pool_real_array_destroy;
Default => godot_pool_real_array_new;
}
);
impl GodotType for Float32Array {
fn to_variant(&self) -> Variant { Variant::from_float32_array(self) }
fn from_variant(variant: &Variant) -> Option<Self> { variant.try_to_float32_array() }
}