1 /*************************************************************************/ 2 /* array.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ 10 /* */ 11 /* Permission is hereby granted, free of charge, to any person obtaining */ 12 /* a copy of this software and associated documentation files (the */ 13 /* "Software"), to deal in the Software without restriction, including */ 14 /* without limitation the rights to use, copy, modify, merge, publish, */ 15 /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 /* permit persons to whom the Software is furnished to do so, subject to */ 17 /* the following conditions: */ 18 /* */ 19 /* The above copyright notice and this permission notice shall be */ 20 /* included in all copies or substantial portions of the Software. */ 21 /* */ 22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 /*************************************************************************/ 30 31 #ifndef GODOT_ARRAY_H 32 #define GODOT_ARRAY_H 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <stdint.h> 39 40 #define GODOT_ARRAY_SIZE sizeof(void *) 41 42 #ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED 43 #define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED 44 typedef struct { 45 uint8_t _dont_touch_that[GODOT_ARRAY_SIZE]; 46 } godot_array; 47 #endif 48 49 // reduce extern "C" nesting for VS2013 50 #ifdef __cplusplus 51 } 52 #endif 53 54 #include <gdnative/pool_arrays.h> 55 #include <gdnative/variant.h> 56 57 #include <gdnative/gdnative.h> 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif 62 63 void GDAPI godot_array_new(godot_array *r_dest); 64 void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); 65 void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca); 66 void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a); 67 void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a); 68 void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa); 69 void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra); 70 void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia); 71 void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba); 72 73 void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value); 74 75 godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx); 76 77 godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx); 78 79 const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, const godot_int p_idx); 80 81 void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value); 82 83 void GDAPI godot_array_clear(godot_array *p_self); 84 85 godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value); 86 87 godot_bool GDAPI godot_array_empty(const godot_array *p_self); 88 89 void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value); 90 91 godot_variant GDAPI godot_array_front(const godot_array *p_self); 92 93 godot_variant GDAPI godot_array_back(const godot_array *p_self); 94 95 godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); 96 97 godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what); 98 99 godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value); 100 101 godot_int GDAPI godot_array_hash(const godot_array *p_self); 102 103 void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value); 104 105 void GDAPI godot_array_invert(godot_array *p_self); 106 107 godot_variant GDAPI godot_array_pop_back(godot_array *p_self); 108 109 godot_variant GDAPI godot_array_pop_front(godot_array *p_self); 110 111 void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value); 112 113 void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value); 114 115 void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx); 116 117 void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size); 118 119 godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); 120 121 godot_int GDAPI godot_array_size(const godot_array *p_self); 122 123 void GDAPI godot_array_sort(godot_array *p_self); 124 125 void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func); 126 127 godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool p_before); 128 129 godot_int GDAPI godot_array_bsearch_custom(godot_array *p_self, const godot_variant *p_value, godot_object *p_obj, const godot_string *p_func, const godot_bool p_before); 130 131 void GDAPI godot_array_destroy(godot_array *p_self); 132 133 godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_bool p_deep); 134 135 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); 136 137 godot_variant GDAPI godot_array_max(const godot_array *p_self); 138 139 godot_variant GDAPI godot_array_min(const godot_array *p_self); 140 141 void GDAPI godot_array_shuffle(godot_array *p_self); 142 143 #ifdef __cplusplus 144 } 145 #endif 146 147 #endif // GODOT_ARRAY_H 148