summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/core/Array.cpp
blob: 2d66eb74d7c0c423aa6d83f759c52f48d46d7de7 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#include "Array.h"

#include <cstdlib>

#include <godot/godot_array.h>

#include "Variant.h"

namespace godot {

class Object;

Array::Array()
{
	godot_array_new(&_godot_array);
}

Array::Array(const PoolByteArray& a)
{
	godot_array_new_pool_byte_array(&_godot_array, (godot_pool_byte_array *) &a);
}

Array::Array(const PoolIntArray& a)
{
	godot_array_new_pool_int_array(&_godot_array, (godot_pool_int_array *) &a);
}

Array::Array(const PoolRealArray& a)
{
	godot_array_new_pool_real_array(&_godot_array, (godot_pool_real_array *) &a);
}

Array::Array(const PoolStringArray& a)
{
	godot_array_new_pool_string_array(&_godot_array, (godot_pool_string_array *) &a);
}

Array::Array(const PoolVector2Array& a)
{
	godot_array_new_pool_vector2_array(&_godot_array, (godot_pool_vector2_array *) &a);
}

Array::Array(const PoolVector3Array& a)
{
	godot_array_new_pool_vector3_array(&_godot_array, (godot_pool_vector3_array *) &a);
}

Array::Array(const PoolColorArray& a)
{
	godot_array_new_pool_color_array(&_godot_array, (godot_pool_color_array *) &a);
}

Variant& Array::operator [](const int idx)
{
	godot_variant *v = godot_array_get(&_godot_array, idx);
	return *(Variant *) v;
}

Variant Array::operator [](const int idx) const
{
	// Yes, I'm casting away the const... you can hate me now.
	// since the result is
	godot_variant *v = godot_array_get((godot_array *) &_godot_array, idx);
	return *(Variant *) v;
}

void Array::append(const Variant& v)
{
	godot_array_append(&_godot_array, (godot_variant *) &v);
}

void Array::clear()
{
	godot_array_clear(&_godot_array);
}

int Array::count(const Variant& v)
{
	return godot_array_count(&_godot_array, (godot_variant *) &v);
}

bool Array::empty() const
{
	return godot_array_empty(&_godot_array);
}

void Array::erase(const Variant& v)
{
	godot_array_erase(&_godot_array, (godot_variant *) &v);
}

Variant Array::front() const
{
	godot_variant v = godot_array_front(&_godot_array);
	return *(Variant *) &v;
}

Variant Array::back() const
{
	godot_variant v = godot_array_back(&_godot_array);
	return *(Variant *) &v;
}

int Array::find(const Variant& what, const int from)
{
	return godot_array_find(&_godot_array, (godot_variant *) &what, from);
}

int Array::find_last(const Variant& what)
{
	return godot_array_find_last(&_godot_array, (godot_variant *) &what);
}

bool Array::has(const Variant& what) const
{
	return godot_array_has(&_godot_array, (godot_variant *) &what);
}

uint32_t Array::hash() const
{
	return godot_array_hash(&_godot_array);
}

void Array::insert(const int pos, const Variant& value)
{
	godot_array_insert(&_godot_array, pos, (godot_variant *) &value);
}

void Array::invert()
{
	godot_array_invert(&_godot_array);
}

bool Array::is_shared() const
{
	return godot_array_is_shared(&_godot_array);
}

Variant Array::pop_back()
{
	godot_variant v = godot_array_pop_back(&_godot_array);
	return *(Variant *) &v;
}

Variant Array::pop_front()
{
	godot_variant v = godot_array_pop_front(&_godot_array);
	return *(Variant *) &v;
}

void Array::push_back(const Variant& v)
{
	godot_array_push_back(&_godot_array, (godot_variant *) &v);
}

void Array::push_front(const Variant& v)
{
	godot_array_push_front(&_godot_array, (godot_variant *) &v);
}

void Array::remove(const int idx)
{
	godot_array_remove(&_godot_array, idx);
}

int Array::size() const
{
	return godot_array_size(&_godot_array);
}

void Array::resize(const int size)
{
	godot_array_resize(&_godot_array, size);
}

int Array::rfind(const Variant& what, const int from)
{
	return godot_array_rfind(&_godot_array, (godot_variant *) &what, from);
}

void Array::sort()
{
	godot_array_sort(&_godot_array);
}

void Array::sort_custom(Object *obj, const String& func)
{
	godot_array_sort_custom(&_godot_array, (godot_object *) obj, (godot_string *) &func);
}

Array::~Array()
{
	godot_array_destroy(&_godot_array);
}

}