2023-05-23 18:02:01 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* array.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
2023-05-26 10:58:14 +02:00
|
|
|
/* PANDEMONIUM ENGINE */
|
|
|
|
/* https://pandemoniumengine.org */
|
2023-05-23 18:02:01 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef GDNATIVE_ARRAY_H
|
|
|
|
#define GDNATIVE_ARRAY_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
#define PANDEMONIUM_ARRAY_SIZE sizeof(void *)
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
#ifndef PANDEMONIUM_CORE_API_PANDEMONIUM_ARRAY_TYPE_DEFINED
|
|
|
|
#define PANDEMONIUM_CORE_API_PANDEMONIUM_ARRAY_TYPE_DEFINED
|
2023-05-23 18:02:01 +02:00
|
|
|
typedef struct {
|
2023-05-26 10:58:14 +02:00
|
|
|
uint8_t _dont_touch_that[PANDEMONIUM_ARRAY_SIZE];
|
|
|
|
} pandemonium_array;
|
2023-05-23 18:02:01 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// reduce extern "C" nesting for VS2013
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-05-25 21:54:24 +02:00
|
|
|
#include <gdn/pool_arrays.h>
|
|
|
|
#include <gdn/variant.h>
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-25 21:54:24 +02:00
|
|
|
#include <gdn/gdnative.h>
|
2023-05-23 18:02:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_variant GDAPI *pandemonium_array_operator_index(pandemonium_array *p_self, const pandemonium_int p_idx);
|
|
|
|
const pandemonium_variant GDAPI *pandemonium_array_operator_index_const(const pandemonium_array *p_self, const pandemonium_int p_idx);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_set(pandemonium_array *p_self, const pandemonium_int p_idx, const pandemonium_variant *p_value);
|
|
|
|
pandemonium_variant GDAPI pandemonium_array_get(const pandemonium_array *p_self, const pandemonium_int p_idx);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
pandemonium_int GDAPI pandemonium_array_size(const pandemonium_array *p_self);
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_bool GDAPI pandemonium_array_empty(const pandemonium_array *p_self);
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_clear(pandemonium_array *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
//bool deep_equal(const Array &p_array, int p_recursion_count = 0) const;
|
|
|
|
//bool operator==(const Array &p_array) const;
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_int GDAPI pandemonium_array_hash(const pandemonium_array *p_self);
|
2023-05-26 20:13:13 +02:00
|
|
|
//void operator=(const Array &p_array);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
void GDAPI pandemonium_array_push_back(pandemonium_array *p_self, const pandemonium_variant *p_value);
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_append(pandemonium_array *p_self, const pandemonium_variant *p_value);
|
|
|
|
//void append_array(const Array &p_array);
|
2023-05-26 10:58:14 +02:00
|
|
|
void GDAPI pandemonium_array_resize(pandemonium_array *p_self, const pandemonium_int p_size);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_insert(pandemonium_array *p_self, const pandemonium_int p_pos, const pandemonium_variant *p_value);
|
|
|
|
void GDAPI pandemonium_array_remove(pandemonium_array *p_self, const pandemonium_int p_idx);
|
|
|
|
//void fill(const Variant &p_value);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
pandemonium_variant GDAPI pandemonium_array_front(const pandemonium_array *p_self);
|
|
|
|
pandemonium_variant GDAPI pandemonium_array_back(const pandemonium_array *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
void GDAPI pandemonium_array_sort(pandemonium_array *p_self);
|
|
|
|
void GDAPI pandemonium_array_sort_custom(pandemonium_array *p_self, pandemonium_object *p_obj, const pandemonium_string *p_func);
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_shuffle(pandemonium_array *p_self);
|
|
|
|
//before variant
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_int GDAPI pandemonium_array_bsearch(pandemonium_array *p_self, const pandemonium_variant *p_value, const pandemonium_bool p_before);
|
|
|
|
pandemonium_int GDAPI pandemonium_array_bsearch_custom(pandemonium_array *p_self, const pandemonium_variant *p_value, pandemonium_object *p_obj, const pandemonium_string *p_func, const pandemonium_bool p_before);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_invert(pandemonium_array *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
//int find(const Variant &p_value, int p_from = 0) const; p_from version
|
|
|
|
pandemonium_int GDAPI pandemonium_array_find(const pandemonium_array *p_self, const pandemonium_variant *p_what, const pandemonium_int p_from);
|
|
|
|
//int rfind(const Variant &p_value, int p_from = -1) const; p_from version
|
|
|
|
pandemonium_int GDAPI pandemonium_array_rfind(const pandemonium_array *p_self, const pandemonium_variant *p_what, const pandemonium_int p_from);
|
|
|
|
pandemonium_int GDAPI pandemonium_array_find_last(const pandemonium_array *p_self, const pandemonium_variant *p_what);
|
|
|
|
pandemonium_int GDAPI pandemonium_array_count(const pandemonium_array *p_self, const pandemonium_variant *p_value);
|
|
|
|
pandemonium_bool GDAPI pandemonium_array_has(const pandemonium_array *p_self, const pandemonium_variant *p_value);
|
|
|
|
|
|
|
|
void GDAPI pandemonium_array_erase(pandemonium_array *p_self, const pandemonium_variant *p_value);
|
|
|
|
|
|
|
|
void GDAPI pandemonium_array_push_front(pandemonium_array *p_self, const pandemonium_variant *p_value);
|
|
|
|
pandemonium_variant GDAPI pandemonium_array_pop_back(pandemonium_array *p_self);
|
|
|
|
pandemonium_variant GDAPI pandemonium_array_pop_front(pandemonium_array *p_self);
|
|
|
|
//Variant pop_at(int p_pos);
|
|
|
|
|
|
|
|
//Array duplicate(bool p_deep = false) const; deep variant
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_array GDAPI pandemonium_array_duplicate(const pandemonium_array *p_self, const pandemonium_bool p_deep);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
//Array slice(int p_begin, int p_end, int p_step = 1, bool p_deep = false) const; variants
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_array GDAPI pandemonium_array_slice(const pandemonium_array *p_self, const pandemonium_int p_begin, const pandemonium_int p_end, const pandemonium_int p_step, const pandemonium_bool p_deep);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
pandemonium_variant GDAPI pandemonium_array_min(const pandemonium_array *p_self);
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_variant GDAPI pandemonium_array_max(const pandemonium_array *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_new(pandemonium_array *r_dest);
|
|
|
|
void GDAPI pandemonium_array_new_copy(pandemonium_array *r_dest, const pandemonium_array *p_src);
|
|
|
|
void GDAPI pandemonium_array_new_pool_color_array(pandemonium_array *r_dest, const pandemonium_pool_color_array *p_pca);
|
|
|
|
void GDAPI pandemonium_array_new_pool_vector3_array(pandemonium_array *r_dest, const pandemonium_pool_vector3_array *p_pv3a);
|
|
|
|
void GDAPI pandemonium_array_new_pool_vector2_array(pandemonium_array *r_dest, const pandemonium_pool_vector2_array *p_pv2a);
|
|
|
|
void GDAPI pandemonium_array_new_pool_string_array(pandemonium_array *r_dest, const pandemonium_pool_string_array *p_psa);
|
|
|
|
void GDAPI pandemonium_array_new_pool_real_array(pandemonium_array *r_dest, const pandemonium_pool_real_array *p_pra);
|
|
|
|
void GDAPI pandemonium_array_new_pool_int_array(pandemonium_array *r_dest, const pandemonium_pool_int_array *p_pia);
|
|
|
|
void GDAPI pandemonium_array_new_pool_byte_array(pandemonium_array *r_dest, const pandemonium_pool_byte_array *p_pba);
|
|
|
|
//Add the new ones
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:13:13 +02:00
|
|
|
void GDAPI pandemonium_array_destroy(pandemonium_array *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // GDNATIVE_ARRAY_H
|