From af80bcd2f8e01130357b090126c26717b736665a Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 20 Feb 2020 23:19:00 -0500 Subject: Add sort and has methods to PackedArrays --- modules/gdnative/gdnative/packed_arrays.cpp | 94 +++++++++++++ modules/gdnative/gdnative_api.json | 157 ++++++++++++++++++++-- modules/gdnative/include/gdnative/packed_arrays.h | 36 +++++ 3 files changed, 276 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/gdnative/gdnative/packed_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp index fc71d50289..de93c1d9b3 100644 --- a/modules/gdnative/gdnative/packed_arrays.cpp +++ b/modules/gdnative/gdnative/packed_arrays.cpp @@ -104,6 +104,16 @@ godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self return (godot_error)self->insert(p_idx, p_data); } +godot_bool GDAPI godot_packed_byte_array_has(godot_packed_byte_array *p_self, const uint8_t p_value) { + Vector *self = (Vector *)p_self; + return (godot_bool)self->has(p_value); +} + +void GDAPI godot_packed_byte_array_sort(godot_packed_byte_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -198,6 +208,16 @@ godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_se return (godot_error)self->insert(p_idx, p_data); } +godot_bool GDAPI godot_packed_int32_array_has(godot_packed_int32_array *p_self, const int32_t p_value) { + Vector *self = (Vector *)p_self; + return (godot_bool)self->has(p_value); +} + +void GDAPI godot_packed_int32_array_sort(godot_packed_int32_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -292,6 +312,16 @@ godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_se return (godot_error)self->insert(p_idx, p_data); } +godot_bool GDAPI godot_packed_int64_array_has(godot_packed_int64_array *p_self, const int64_t p_value) { + Vector *self = (Vector *)p_self; + return (godot_bool)self->has(p_value); +} + +void GDAPI godot_packed_int64_array_sort(godot_packed_int64_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -386,6 +416,16 @@ godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array * return (godot_error)self->insert(p_idx, p_data); } +godot_bool GDAPI godot_packed_float32_array_has(godot_packed_float32_array *p_self, const float p_value) { + Vector *self = (Vector *)p_self; + return (godot_bool)self->has(p_value); +} + +void GDAPI godot_packed_float32_array_sort(godot_packed_float32_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -480,6 +520,16 @@ godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array * return (godot_error)self->insert(p_idx, p_data); } +godot_bool GDAPI godot_packed_float64_array_has(godot_packed_float64_array *p_self, const double p_value) { + Vector *self = (Vector *)p_self; + return (godot_bool)self->has(p_value); +} + +void GDAPI godot_packed_float64_array_sort(godot_packed_float64_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -576,6 +626,17 @@ godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_ return (godot_error)self->insert(p_idx, s); } +godot_bool GDAPI godot_packed_string_array_has(godot_packed_string_array *p_self, const godot_string *p_value) { + Vector *self = (Vector *)p_self; + String &s = *(String *)p_value; + return (godot_bool)self->has(s); +} + +void GDAPI godot_packed_string_array_sort(godot_packed_string_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -678,6 +739,17 @@ godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array * return (godot_error)self->insert(p_idx, s); } +godot_bool GDAPI godot_packed_vector2_array_has(godot_packed_vector2_array *p_self, const godot_vector2 *p_value) { + Vector *self = (Vector *)p_self; + Vector2 &v = *(Vector2 *)p_value; + return (godot_bool)self->has(v); +} + +void GDAPI godot_packed_vector2_array_sort(godot_packed_vector2_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -779,6 +851,17 @@ godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array * return (godot_error)self->insert(p_idx, s); } +godot_bool GDAPI godot_packed_vector3_array_has(godot_packed_vector3_array *p_self, const godot_vector3 *p_value) { + Vector *self = (Vector *)p_self; + Vector3 &v = *(Vector3 *)p_value; + return (godot_bool)self->has(v); +} + +void GDAPI godot_packed_vector3_array_sort(godot_packed_vector3_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); @@ -880,6 +963,17 @@ godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_se return (godot_error)self->insert(p_idx, s); } +godot_bool GDAPI godot_packed_color_array_has(godot_packed_color_array *p_self, const godot_color *p_value) { + Vector *self = (Vector *)p_self; + Color &c = *(Color *)p_value; + return (godot_bool)self->has(c); +} + +void GDAPI godot_packed_color_array_sort(godot_packed_color_array *p_self) { + Vector *self = (Vector *)p_self; + self->sort(); +} + void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self) { Vector *self = (Vector *)p_self; self->invert(); diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 1284ebbd66..eb122089b6 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -918,42 +918,42 @@ ["const godot_variant **", "p_arguments"], ["godot_int", "p_argcount"] ] - }, + }, { "name": "godot_callable_is_null", "return_type": "godot_bool", "arguments": [ ["const godot_callable *", "p_self"] ] - }, + }, { "name": "godot_callable_is_custom", "return_type": "godot_bool", "arguments": [ ["const godot_callable *", "p_self"] ] - }, + }, { "name": "godot_callable_is_standard", "return_type": "godot_bool", "arguments": [ ["const godot_callable *", "p_self"] ] - }, + }, { "name": "godot_callable_get_object", "return_type": "godot_object *", "arguments": [ ["const godot_callable *", "p_self"] ] - }, + }, { "name": "godot_callable_get_object_id", "return_type": "uint64_t", "arguments": [ ["const godot_callable *", "p_self"] ] - }, + }, { "name": "godot_callable_get_method", "return_type": "godot_string_name", @@ -1093,14 +1093,14 @@ "arguments": [ ["const godot_signal *", "p_self"] ] - }, + }, { "name": "godot_signal_as_string", "return_type": "godot_string", "arguments": [ ["const godot_signal *", "p_self"] ] - }, + }, { "name": "godot_signal_operator_equal", "return_type": "godot_bool", @@ -1108,7 +1108,7 @@ ["const godot_signal *", "p_self"], ["const godot_signal *", "p_other"] ] - }, + }, { "name": "godot_signal_operator_less", "return_type": "godot_bool", @@ -1670,6 +1670,21 @@ ["const uint8_t", "p_data"] ] }, + { + "name": "godot_packed_byte_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_byte_array *", "p_self"], + ["const uint8_t", "p_value"] + ] + }, + { + "name": "godot_packed_byte_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_byte_array *", "p_self"] + ] + }, { "name": "godot_packed_byte_array_invert", "return_type": "void", @@ -1801,6 +1816,21 @@ ["const int32_t", "p_data"] ] }, + { + "name": "godot_packed_int32_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_int32_array *", "p_self"], + ["const int32_t", "p_value"] + ] + }, + { + "name": "godot_packed_int32_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_int32_array *", "p_self"] + ] + }, { "name": "godot_packed_int32_array_invert", "return_type": "void", @@ -1932,6 +1962,21 @@ ["const int64_t", "p_data"] ] }, + { + "name": "godot_packed_int64_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const int64_t", "p_value"] + ] + }, + { + "name": "godot_packed_int64_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"] + ] + }, { "name": "godot_packed_int64_array_invert", "return_type": "void", @@ -2063,6 +2108,21 @@ ["const float", "p_data"] ] }, + { + "name": "godot_packed_float32_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_float32_array *", "p_self"], + ["const float", "p_value"] + ] + }, + { + "name": "godot_packed_float32_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_float32_array *", "p_self"] + ] + }, { "name": "godot_packed_float32_array_invert", "return_type": "void", @@ -2194,6 +2254,21 @@ ["const double", "p_data"] ] }, + { + "name": "godot_packed_float64_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const double", "p_value"] + ] + }, + { + "name": "godot_packed_float64_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"] + ] + }, { "name": "godot_packed_float64_array_invert", "return_type": "void", @@ -2325,6 +2400,21 @@ ["const godot_string *", "p_data"] ] }, + { + "name": "godot_packed_string_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_string_array *", "p_self"], + ["const godot_string *", "p_value"] + ] + }, + { + "name": "godot_packed_string_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_string_array *", "p_self"] + ] + }, { "name": "godot_packed_string_array_invert", "return_type": "void", @@ -2456,6 +2546,21 @@ ["const godot_vector2 *", "p_data"] ] }, + { + "name": "godot_packed_vector2_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_vector2_array *", "p_self"], + ["const godot_vector2 *", "p_value"] + ] + }, + { + "name": "godot_packed_vector2_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_vector2_array *", "p_self"] + ] + }, { "name": "godot_packed_vector2_array_invert", "return_type": "void", @@ -2587,6 +2692,21 @@ ["const godot_vector3 *", "p_data"] ] }, + { + "name": "godot_packed_vector3_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_vector3_array *", "p_self"], + ["const godot_vector3 *", "p_value"] + ] + }, + { + "name": "godot_packed_vector3_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_vector3_array *", "p_self"] + ] + }, { "name": "godot_packed_vector3_array_invert", "return_type": "void", @@ -2718,6 +2838,21 @@ ["const godot_color *", "p_data"] ] }, + { + "name": "godot_packed_color_array_has", + "return_type": "godot_bool", + "arguments": [ + ["godot_packed_color_array *", "p_self"], + ["const godot_color *", "p_value"] + ] + }, + { + "name": "godot_packed_color_array_sort", + "return_type": "void", + "arguments": [ + ["godot_packed_color_array *", "p_self"] + ] + }, { "name": "godot_packed_color_array_invert", "return_type": "void", @@ -2748,7 +2883,7 @@ ["godot_packed_color_array *", "p_self"], ["const godot_int", "p_size"] ] - }, + }, { "name": "godot_packed_color_array_ptr", "return_type": "const godot_color *", @@ -5463,7 +5598,7 @@ ["godot_variant *", "r_dest"], ["const godot_packed_int64_array *", "p_pia"] ] - }, + }, { "name": "godot_variant_new_packed_float32_array", "return_type": "void", diff --git a/modules/gdnative/include/gdnative/packed_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h index 87d467a5b8..6a1727d76f 100644 --- a/modules/gdnative/include/gdnative/packed_arrays.h +++ b/modules/gdnative/include/gdnative/packed_arrays.h @@ -167,6 +167,10 @@ void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); +godot_bool GDAPI godot_packed_byte_array_has(godot_packed_byte_array *p_self, const uint8_t p_value); + +void GDAPI godot_packed_byte_array_sort(godot_packed_byte_array *p_self); + void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self); void GDAPI godot_packed_byte_array_push_back(godot_packed_byte_array *p_self, const uint8_t p_data); @@ -199,6 +203,10 @@ void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_sel godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data); +godot_bool GDAPI godot_packed_int32_array_has(godot_packed_int32_array *p_self, const int32_t p_value); + +void GDAPI godot_packed_int32_array_sort(godot_packed_int32_array *p_self); + void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self); void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data); @@ -231,6 +239,10 @@ void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_sel godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data); +godot_bool GDAPI godot_packed_int64_array_has(godot_packed_int64_array *p_self, const int64_t p_value); + +void GDAPI godot_packed_int64_array_sort(godot_packed_int64_array *p_self); + void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self); void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data); @@ -263,6 +275,10 @@ void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data); +godot_bool GDAPI godot_packed_float32_array_has(godot_packed_float32_array *p_self, const float p_value); + +void GDAPI godot_packed_float32_array_sort(godot_packed_float32_array *p_self); + void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self); void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data); @@ -295,6 +311,10 @@ void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data); +godot_bool GDAPI godot_packed_float64_array_has(godot_packed_float64_array *p_self, const double p_value); + +void GDAPI godot_packed_float64_array_sort(godot_packed_float64_array *p_self); + void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self); void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data); @@ -327,6 +347,10 @@ void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_s godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data); +godot_bool GDAPI godot_packed_string_array_has(godot_packed_string_array *p_self, const godot_string *p_value); + +void GDAPI godot_packed_string_array_sort(godot_packed_string_array *p_self); + void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self); void GDAPI godot_packed_string_array_push_back(godot_packed_string_array *p_self, const godot_string *p_data); @@ -359,6 +383,10 @@ void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); +godot_bool GDAPI godot_packed_vector2_array_has(godot_packed_vector2_array *p_self, const godot_vector2 *p_value); + +void GDAPI godot_packed_vector2_array_sort(godot_packed_vector2_array *p_self); + void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self); void GDAPI godot_packed_vector2_array_push_back(godot_packed_vector2_array *p_self, const godot_vector2 *p_data); @@ -391,6 +419,10 @@ void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); +godot_bool GDAPI godot_packed_vector3_array_has(godot_packed_vector3_array *p_self, const godot_vector3 *p_value); + +void GDAPI godot_packed_vector3_array_sort(godot_packed_vector3_array *p_self); + void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self); void GDAPI godot_packed_vector3_array_push_back(godot_packed_vector3_array *p_self, const godot_vector3 *p_data); @@ -423,6 +455,10 @@ void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_sel godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data); +godot_bool GDAPI godot_packed_color_array_has(godot_packed_color_array *p_self, const godot_color *p_value); + +void GDAPI godot_packed_color_array_sort(godot_packed_color_array *p_self); + void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self); void GDAPI godot_packed_color_array_push_back(godot_packed_color_array *p_self, const godot_color *p_data); -- cgit v1.2.3