Merge branch '3-interface-standardization' into 3-interface-standardization-descrete-tests

This commit is contained in:
Gregory Lirent 2022-06-08 21:21:57 +03:00
commit f724be4042
18 changed files with 318 additions and 400 deletions

View File

@ -12,7 +12,7 @@
extern void array_init(vtype_array* x, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void* array_at(const vtype_array* s, ssize_t index) LIBCDSB_nt__ LIBCDSB_nn1__;
extern _Bool array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern _Bool array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void array_sort (vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;

View File

@ -6,20 +6,18 @@
#ifndef LIBCDSB_EXTRA_ARRAY_H
#define LIBCDSB_EXTRA_ARRAY_H
typedef int (*array_foreach_callback)(void* value, ssize_t index, vtype type, void* data);
typedef int (*array_access_callback)(void* value, ssize_t index, vtype type, void* data);
#define array_get(x, s, index) libcdsb_array_get(x, s, index, 0)
#define array_pop(x, s, index) libcdsb_array_get(x, s, index, 1)
#define array_remove(s, index) libcdsb_array_get(0, s, index, 1)
#define array_get(s, index, data, callback) libcdsb_array_get(s, index, data, callback, 0)
#define array_pop(s, index, data, callback) libcdsb_array_get(s, index, data, callback, 1)
#define array_remove(s, index) libcdsb_array_get(s, index, 0, 0, 1)
#define array_foreach(x, data, callback) libcdsb_array_foreach(x, data, callback, 0)
extern ssize_t libcdsb_array_get(vtype_value* x, vtype_array* s, ssize_t index, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn2__;
extern int libcdsb_array_get (vtype_array* x, ssize_t index, void* data, array_access_callback, vtype_bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_find(const vtype_array* x, const void* value, vtype value_type) LIBCDSB_nt__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_push( vtype_array* x, const void* value, vtype value_type) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_array_foreach(vtype_array* x, void* data, array_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
extern int libcdsb_array_foreach(vtype_array* x, void* data, array_access_callback, vtype_bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
#endif /* LIBCDSB_EXTRA_ARRAY_H */

View File

@ -6,22 +6,18 @@
#ifndef LIBCDSB_EXTRA_LIST_H
#define LIBCDSB_EXTRA_LIST_H
typedef int (*list_foreach_callback)(void* value, ssize_t index, vtype type, void* data);
#define list_get_by_index(x, s, index) libcdsb_list_get(x, s, index, 0)
#define list_pop_by_index(x, s, index) libcdsb_list_get(x, s, index, 1)
#define list_remove_by_index(s, index) libcdsb_list_get(0, s, index, 1)
#define list_get_by_index(x, index, data, callback) libcdsb_list_get(x, index, data, callback, 0)
#define list_pop_by_index(x, index, data, callback) libcdsb_list_get(x, index, data, callback, 1)
#define list_remove_by_index(x, index) libcdsb_list_get(x, index, 0, 0, 1)
#define list_foreach(x, data, callback) libcdsb_list_foreach(x, data, callback, 0)
extern ssize_t libcdsb_list_find (vtype_value* x, vtype_list* s, const void* value, vtype type, _Bool reverse, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn2__;
extern _Bool libcdsb_list_update(vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction) LIBCDSB_nt__ LIBCDSB_nn1__;
extern size_t libcdsb_list_count(const vtype_list* s, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__;
extern ssize_t libcdsb_list_get(vtype_value* x, vtype_list* s, ssize_t index, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn2__;
extern int libcdsb_list_foreach(vtype_list* x, void* data, list_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
extern int libcdsb_list_find (vtype_list* x, const void* value, vtype type, void* data, list_access_callback, _Bool reverse, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_list_get (vtype_list* x, ssize_t index, void* data, list_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_list_foreach(vtype_list* x, void* data, list_access_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
#endif /* LIBCDSB_EXTRA_LIST_H */

View File

@ -6,15 +6,12 @@
#ifndef LIBCDSB_EXTRA_MAP_H
#define LIBCDSB_EXTRA_MAP_H
typedef int (*map_foreach_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data);
#define map_foreach(x, data, callback) libcdsb_map_foreach(x, data, callback, 0)
extern _Bool libcdsb_map_find (vtype_value* x, vtype_map* s, const void* key, vtype key_type, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn23__;
extern _Bool libcdsb_map_update(vtype_map* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__;
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
extern int libcdsb_map_find (vtype_map* x, const void* key, vtype key_type, void* data, map_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_access_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
#endif /* LIBCDSB_EXTRA_MAP_H */

View File

@ -6,14 +6,11 @@
#ifndef LIBCDSB_EXTRA_SET_H
#define LIBCDSB_EXTRA_SET_H
typedef int (*vset_foreach_callback)(const void* value, vtype type, void* data);
#define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, 0)
extern _Bool libcdsb_vset_find (vtype_value* x, vtype_set* s, const void* value, vtype type, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn23__;
extern _Bool libcdsb_vset_insert(vtype_set* x, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn12__;
extern _Bool libcdsb_vset_insert(vtype_set* x, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn12__;
extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
#endif /* LIBCDSB_EXTRA_SET_H */

View File

@ -9,19 +9,20 @@
/*#####################################################################################################################*/
typedef int (*list_access_callback)(void* value, ssize_t index, vtype type, void* data);
extern void list_init(vtype_list* x);
extern void list_extend(vtype_list* x, const vtype_list* s);
extern void list_sort(vtype_list* x);
extern void list_reverse(vtype_list* x);
#define list_pop(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 0, 1)
#define list_find(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 0, 0)
#define list_rfind(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 1, 0)
#define list_countof(s, value) _LIBCDSB_Generic(libcdsb_list, count, value)(s, value)
#define list_indexof(s, value) list_find(0, s, value)
#define list_remove(s, value) list_pop(0, s, value)
#define in_list(s, value) (list_indexof(s, value) >= 0)
#define list_pop(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 0, 1)
#define list_find(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 0, 0)
#define list_rfind(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 1, 0)
#define list_countof(x, value) _LIBCDSB_Generic(libcdsb_list, count, value)(x, value)
#define list_remove(x, value) list_pop(x, value, 0, 0)
#define in_list(x, value) (list_find(x, value, 0, 0) == 0)
#define list_insert(x, index, value) _LIBCDSB_Generic(libcdsb_list, update, value)(x, index, value, -1)
#define list_replace(x, index, value) _LIBCDSB_Generic(libcdsb_list, update, value)(x, index, value, 0)
@ -30,25 +31,25 @@ extern void list_reverse(vtype_list* x);
/*#####################################################################################################################*/
extern ssize_t libcdsb_list_find_pointer(vtype_value* x, vtype_list* s, const void* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_cstring(vtype_value* x, vtype_list* s, const char* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_string (vtype_value* x, vtype_list* s, const vtype_string* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_array (vtype_value* x, vtype_list* s, const vtype_array* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_list (vtype_value* x, vtype_list* s, const vtype_list* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_map (vtype_value* x, vtype_list* s, const vtype_map* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_vset (vtype_value* x, vtype_list* s, const vtype_set* value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_boolean(vtype_value* x, vtype_list* s, vtype_bool value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_int8 (vtype_value* x, vtype_list* s, vtype_int8 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_int16 (vtype_value* x, vtype_list* s, vtype_int16 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_int32 (vtype_value* x, vtype_list* s, vtype_int32 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_int64 (vtype_value* x, vtype_list* s, vtype_int64 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_uint8 (vtype_value* x, vtype_list* s, vtype_uint8 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_uint16 (vtype_value* x, vtype_list* s, vtype_uint16 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_uint32 (vtype_value* x, vtype_list* s, vtype_uint32 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_uint64 (vtype_value* x, vtype_list* s, vtype_uint64 value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_float (vtype_value* x, vtype_list* s, vtype_float value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_double (vtype_value* x, vtype_list* s, vtype_double value, _Bool reverse, _Bool cut);
extern ssize_t libcdsb_list_find_ldouble(vtype_value* x, vtype_list* s, vtype_ldouble value, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_pointer(vtype_list* x, const void* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_cstring(vtype_list* x, const char* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_string (vtype_list* x, const vtype_string* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_array (vtype_list* x, const vtype_array* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_list (vtype_list* x, const vtype_list* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_map (vtype_list* x, const vtype_map* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_vset (vtype_list* x, const vtype_set* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_boolean(vtype_list* x, vtype_bool value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_int8 (vtype_list* x, vtype_int8 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_int16 (vtype_list* x, vtype_int16 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_int32 (vtype_list* x, vtype_int32 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_int64 (vtype_list* x, vtype_int64 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_uint8 (vtype_list* x, vtype_uint8 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_uint16 (vtype_list* x, vtype_uint16 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_uint32 (vtype_list* x, vtype_uint32 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_uint64 (vtype_list* x, vtype_uint64 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_float (vtype_list* x, vtype_float value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_double (vtype_list* x, vtype_double value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern int libcdsb_list_find_ldouble(vtype_list* x, vtype_ldouble value, void* data, list_access_callback, _Bool reverse, _Bool cut);
extern size_t libcdsb_list_count_pointer(const vtype_list* s, const void* value);
extern size_t libcdsb_list_count_cstring(const vtype_list* s, const char* value);

View File

@ -7,6 +7,8 @@
#ifndef LIBCDSB_MAP_H
#define LIBCDSB_MAP_H
typedef int (*map_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data);
extern void map_init(vtype_map* x, vtype key_type);
#define map_pop(x, s, key) _LIBCDSB_Generic (libcdsb_map, find, key)(x, s, key, 1)
@ -14,25 +16,25 @@ extern void map_init(vtype_map* x, vtype key_type);
#define map_update(x, key, value) _LIBCDSB_Generic2(libcdsb_map, update, key, value)(x, key, value)
#define map_remove(x, key) map_pop(0, x, key)
extern _Bool libcdsb_map_find_pointer(vtype_value* x, vtype_map* s, const void* key, _Bool cut);
extern _Bool libcdsb_map_find_cstring(vtype_value* x, vtype_map* s, const char* key, _Bool cut);
extern _Bool libcdsb_map_find_string (vtype_value* x, vtype_map* s, const vtype_string* key, _Bool cut);
extern _Bool libcdsb_map_find_array (vtype_value* x, vtype_map* s, const vtype_array* key, _Bool cut);
extern _Bool libcdsb_map_find_list (vtype_value* x, vtype_map* s, const vtype_list* key, _Bool cut);
extern _Bool libcdsb_map_find_map (vtype_value* x, vtype_map* s, const vtype_map* key, _Bool cut);
extern _Bool libcdsb_map_find_vset (vtype_value* x, vtype_map* s, const vtype_set* key, _Bool cut);
extern _Bool libcdsb_map_find_boolean(vtype_value* x, vtype_map* s, vtype_bool key, _Bool cut);
extern _Bool libcdsb_map_find_int8 (vtype_value* x, vtype_map* s, vtype_int8 key, _Bool cut);
extern _Bool libcdsb_map_find_int16 (vtype_value* x, vtype_map* s, vtype_int16 key, _Bool cut);
extern _Bool libcdsb_map_find_int32 (vtype_value* x, vtype_map* s, vtype_int32 key, _Bool cut);
extern _Bool libcdsb_map_find_int64 (vtype_value* x, vtype_map* s, vtype_int64 key, _Bool cut);
extern _Bool libcdsb_map_find_uint8 (vtype_value* x, vtype_map* s, vtype_uint8 key, _Bool cut);
extern _Bool libcdsb_map_find_uint16 (vtype_value* x, vtype_map* s, vtype_uint16 key, _Bool cut);
extern _Bool libcdsb_map_find_uint32 (vtype_value* x, vtype_map* s, vtype_uint32 key, _Bool cut);
extern _Bool libcdsb_map_find_uint64 (vtype_value* x, vtype_map* s, vtype_uint64 key, _Bool cut);
extern _Bool libcdsb_map_find_float (vtype_value* x, vtype_map* s, vtype_float key, _Bool cut);
extern _Bool libcdsb_map_find_double (vtype_value* x, vtype_map* s, vtype_double key, _Bool cut);
extern _Bool libcdsb_map_find_ldouble(vtype_value* x, vtype_map* s, vtype_ldouble key, _Bool cut);
extern int libcdsb_map_find_pointer(vtype_map* x, const void* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_cstring(vtype_map* x, const char* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_string (vtype_map* x, const vtype_string* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_array (vtype_map* x, const vtype_array* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_list (vtype_map* x, const vtype_list* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_map (vtype_map* x, const vtype_map* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_vset (vtype_map* x, const vtype_set* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_boolean(vtype_map* x, vtype_bool key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int8 (vtype_map* x, vtype_int8 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int16 (vtype_map* x, vtype_int16 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int32 (vtype_map* x, vtype_int32 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int64 (vtype_map* x, vtype_int64 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint8 (vtype_map* x, vtype_uint8 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint16 (vtype_map* x, vtype_uint16 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint32 (vtype_map* x, vtype_uint32 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint64 (vtype_map* x, vtype_uint64 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_float (vtype_map* x, vtype_float key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_double (vtype_map* x, vtype_double key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_ldouble(vtype_map* x, vtype_ldouble key, void* data, map_access_callback, _Bool cut);
extern _Bool libcdsb_map_update_pointer_pointer(vtype_map* x, const void* key, const void* value);
extern _Bool libcdsb_map_update_pointer_cstring(vtype_map* x, const void* key, const char* value);

View File

@ -7,6 +7,8 @@
#ifndef LIBCDSB_SET_H
#define LIBCDSB_SET_H
typedef int (*vset_access_callback)(const void* value, vtype type, void* data);
extern void vset_init(vtype_set* x, vtype type);
#define vset_remove(x, value) _LIBCDSB_Generic (libcdsb_vset, touch, value)(x, value, 1)
@ -34,24 +36,24 @@ extern _Bool libcdsb_vset_push_float (vtype_set* x, vtype_float value)
extern _Bool libcdsb_vset_push_double (vtype_set* x, vtype_double value);
extern _Bool libcdsb_vset_push_ldouble(vtype_set* x, vtype_ldouble value);
extern _Bool libcdsb_vset_touch_pointer(vtype_set* x, const void* value, _Bool cut);
extern _Bool libcdsb_vset_touch_cstring(vtype_set* x, const char* value, _Bool cut);
extern _Bool libcdsb_vset_touch_string (vtype_set* x, const vtype_string* value, _Bool cut);
extern _Bool libcdsb_vset_touch_array (vtype_set* x, const vtype_array* value, _Bool cut);
extern _Bool libcdsb_vset_touch_list (vtype_set* x, const vtype_list* value, _Bool cut);
extern _Bool libcdsb_vset_touch_map (vtype_set* x, const vtype_map* value, _Bool cut);
extern _Bool libcdsb_vset_touch_vset (vtype_set* x, const vtype_set* value, _Bool cut);
extern _Bool libcdsb_vset_touch_boolean(vtype_set* x, vtype_bool value, _Bool cut);
extern _Bool libcdsb_vset_touch_uint8 (vtype_set* x, vtype_uint8 value, _Bool cut);
extern _Bool libcdsb_vset_touch_uint16 (vtype_set* x, vtype_uint16 value, _Bool cut);
extern _Bool libcdsb_vset_touch_uint32 (vtype_set* x, vtype_uint32 value, _Bool cut);
extern _Bool libcdsb_vset_touch_uint64 (vtype_set* x, vtype_uint64 value, _Bool cut);
extern _Bool libcdsb_vset_touch_int8 (vtype_set* x, vtype_int8 value, _Bool cut);
extern _Bool libcdsb_vset_touch_int16 (vtype_set* x, vtype_int16 value, _Bool cut);
extern _Bool libcdsb_vset_touch_int32 (vtype_set* x, vtype_int32 value, _Bool cut);
extern _Bool libcdsb_vset_touch_int64 (vtype_set* x, vtype_int64 value, _Bool cut);
extern _Bool libcdsb_vset_touch_float (vtype_set* x, vtype_float value, _Bool cut);
extern _Bool libcdsb_vset_touch_double (vtype_set* x, vtype_double value, _Bool cut);
extern _Bool libcdsb_vset_touch_ldouble(vtype_set* x, vtype_ldouble value, _Bool cut);
extern int libcdsb_vset_find_pointer(vtype_set* x, const void* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_cstring(vtype_set* x, const char* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_string (vtype_set* x, const vtype_string* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_array (vtype_set* x, const vtype_array* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_list (vtype_set* x, const vtype_list* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_map (vtype_set* x, const vtype_map* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_vset (vtype_set* x, const vtype_set* value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_boolean(vtype_set* x, vtype_bool value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_uint8 (vtype_set* x, vtype_uint8 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_uint16 (vtype_set* x, vtype_uint16 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_uint32 (vtype_set* x, vtype_uint32 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_uint64 (vtype_set* x, vtype_uint64 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_int8 (vtype_set* x, vtype_int8 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_int16 (vtype_set* x, vtype_int16 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_int32 (vtype_set* x, vtype_int32 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_int64 (vtype_set* x, vtype_int64 value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_float (vtype_set* x, vtype_float value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_double (vtype_set* x, vtype_double value, void* data, vset_access_callback, _Bool cut);
extern int libcdsb_vset_find_ldouble(vtype_set* x, vtype_ldouble value, void* data, vset_access_callback, _Bool cut);
#endif /* LIBCDSB_SET_H */

View File

@ -37,7 +37,6 @@ typedef enum libcdsb_value_types {
struct libcdsb_string { char* buffer; };
struct libcdsb_array { void* mem; size_t size; vtype type; };
struct libcdsb_value { void* mem; int flags; vtype type; };
struct libcdsb_map { struct libcdsb_map_node* root; vtype type; };
struct libcdsb_set { struct libcdsb_rbtree_node* root; vtype type; };
@ -61,14 +60,11 @@ typedef float vtype_float;
typedef double vtype_double;
typedef long double vtype_ldouble;
typedef struct libcdsb_value_pair vtype_kvpair;
typedef struct libcdsb_value vtype_value;
typedef struct libcdsb_array vtype_array;
typedef struct libcdsb_map vtype_map;
typedef struct libcdsb_set vtype_set;
typedef struct libcdsb_list vtype_list;
typedef struct libcdsb_string vtype_string;
typedef struct libcdsb_iterator vtype_iterator;
typedef struct libcdsb_array vtype_array;
typedef struct libcdsb_map vtype_map;
typedef struct libcdsb_set vtype_set;
typedef struct libcdsb_list vtype_list;
typedef struct libcdsb_string vtype_string;
/* Get utf8 chars count in string */
@ -142,38 +138,4 @@ extern void map_free(vtype_map* x);
/* Free set resources */
extern void vset_free(vtype_set* x);
extern void value_init(vtype_value* dest);
extern void value_free(vtype_value* dest);
extern _Bool value_is_readonly (const vtype_value* node);
extern _Bool value_is_strict_type(const vtype_value* node);
extern void value_is_null (const vtype_value* dest);
extern void value_nmemb (const vtype_value* dest);
extern void* value_get_pointer (const vtype_value* src);
extern _Bool value_set_pointer(vtype_value* node, const void* src);
extern _Bool value_set_cstring(vtype_value* node, const char* src);
extern _Bool value_set_string (vtype_value* node, const vtype_string* src);
extern _Bool value_set_array (vtype_value* node, const vtype_array* src);
extern _Bool value_set_list (vtype_value* node, const vtype_list* src);
extern _Bool value_set_map (vtype_value* node, const vtype_map* src);
extern _Bool value_set_vset (vtype_value* node, const vtype_set* src);
extern _Bool value_set_boolean(vtype_value* node, vtype_bool src);
extern _Bool value_set_uint8 (vtype_value* node, vtype_uint8 src);
extern _Bool value_set_uint16 (vtype_value* node, vtype_uint16 src);
extern _Bool value_set_uint32 (vtype_value* node, vtype_uint32 src);
extern _Bool value_set_uint64 (vtype_value* node, vtype_uint64 src);
extern _Bool value_set_int8 (vtype_value* node, vtype_int8 src);
extern _Bool value_set_int16 (vtype_value* node, vtype_int16 src);
extern _Bool value_set_int32 (vtype_value* node, vtype_int32 src);
extern _Bool value_set_int64 (vtype_value* node, vtype_int64 src);
extern _Bool value_set_float (vtype_value* node, vtype_float src);
extern _Bool value_set_double (vtype_value* node, vtype_double src);
extern _Bool value_set_ldouble(vtype_value* node, vtype_ldouble src);
#endif /* LIBCDSB_VTYPE_H */

View File

@ -38,43 +38,26 @@
#include "__attributes.h"
typedef vtype_uint8 u8_t;
typedef vtype_uint16 u16_t;
typedef vtype_uint32 u32_t;
typedef vtype_uint64 u64_t;
typedef vtype_uint8 u8_t;
typedef vtype_uint16 u16_t;
typedef vtype_uint32 u32_t;
typedef vtype_uint64 u64_t;
typedef vtype_int8 s8_t;
typedef vtype_int16 s16_t;
typedef vtype_int32 s32_t;
typedef vtype_int64 s64_t;
typedef vtype_int8 s8_t;
typedef vtype_int16 s16_t;
typedef vtype_int32 s32_t;
typedef vtype_int64 s64_t;
typedef vtype_float fl_t;
typedef vtype_double dbl_t;
typedef vtype_ldouble ldbl_t;
typedef vtype_float fl_t;
typedef vtype_double dbl_t;
typedef vtype_ldouble ldbl_t;
typedef vtype_string str_t;
typedef vtype_array arr_t;
typedef vtype_list list_t;
typedef vtype_map map_t;
typedef vtype_set set_t;
typedef vtype_value val_t;
typedef vtype_kvpair kvp_t;
typedef vtype_iterator iter_t;
typedef vtype_string str_t;
typedef vtype_array arr_t;
typedef vtype_list list_t;
typedef vtype_map map_t;
typedef vtype_set set_t;
typedef enum {
VF_UNDEFINED = 0x00,
VF_WRITEABLE = 0x01,
VF_CHANGEABLE = 0x02,
VF_REMOVABLE = 0x0f
} vtype_value_flags;
ainline(val_t* value_set(val_t* d, void* ptr, vtype type, int flags)) {
d->mem = ptr;
d->type = type;
d->flags = flags;
return d;
}
extern int libcdsb_vtype_compare_values(const void* s0, vtype t0, const void* s1, vtype t1);
extern int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t);

View File

@ -38,6 +38,7 @@ ssize_t libcdsb_array_find(const arr_t* x, const void* v, vtype vt) {
return -1;
}
ssize_t libcdsb_array_push(arr_t* x, const void* v, vtype vt) {
ssize_t i = x->size;
vnode_t n = vnode_tcreate(x->type, v, vt);
@ -51,32 +52,23 @@ ssize_t libcdsb_array_push(arr_t* x, const void* v, vtype vt) {
return i;
}
ssize_t libcdsb_array_get(val_t* x, arr_t* s, ssize_t i, _Bool cut) {
if (i < 0 && (i += s->size) < 0) i = 0;
int libcdsb_array_get(vtype_array* x, ssize_t i, void* _, array_access_callback callback, vtype_bool cut) {
if (i < s->size) {
assert(!is_null(s->mem));
int r = 0;
if (cut) {
if (!is_null(x)) {
vnode_t n = vnode_create(array_internal_at(s, i), s->type);
value_set(x, n, s->type, VF_WRITEABLE|VF_REMOVABLE);
}
if (i < 0 && (i += x->size) < 0) i = 0;
array_cut(s, i, 1);
} else value_set(x, array_internal_at(s, i), s->type, VF_WRITEABLE);
} else {
i = -1;
memset(x, 0, sizeof(*x));
}
if (i < x->size) {
if (callback) r = callback(array_internal_at(x, i), i, x->type, _);
if (cut) array_cut(x, i, 1);
} else return -1;
return i;
return r;
}
/*#####################################################################################################################*/
int libcdsb_array_foreach(vtype_array* x, void* data, array_foreach_callback callback, _Bool flush) {
int libcdsb_array_foreach(vtype_array* x, void* data, array_access_callback callback, _Bool flush) {
void* p;
void* e;

View File

@ -3,12 +3,9 @@
#include "include.h"
/*#####################################################################################################################*/
static void lnode_cut(list_t* s, lnode_t* cur) {
static void lnode_cut(val_t* x, list_t* s, lnode_t* cur) {
if (!is_null(x)) {
value_set(x, cur->node, cur->type, VF_WRITEABLE|VF_REMOVABLE);
} else vnode_free(&cur->node, cur->type);
vnode_free(&cur->node, cur->type);
if (!is_null(cur->prev)) {
cur->prev->next = cur->next;
@ -21,93 +18,6 @@ static void lnode_cut(val_t* x, list_t* s, lnode_t* cur) {
free(cur);
}
/*#####################################################################################################################*/
ssize_t libcdsb_list_get(val_t* x, list_t* s, ssize_t i, _Bool cut) {
ldir_t dir;
lnode_t* c;
size_t n;
if (i < 0) {
n = (i = ~i);
dir = LD_PREV;
} else {
n = i;
dir = LD_NEXT;
}
c = ldir_dir((lnode_t*)s, dir);
if (!is_null(x)) memset(x, 0, sizeof(*x));
while (n && !is_null(c)) {
c = ldir_dir(c, dir);
--n;
}
if (n || is_null(c)) return -1;
if (!cut && !is_null(x)) {
value_set(x, &c->node, c->type, VF_WRITEABLE|VF_CHANGEABLE);
} else if (cut) lnode_cut(x, s, c);
return i;
}
/*#####################################################################################################################*/
ssize_t libcdsb_list_find(val_t* x, list_t* s, const void* v, vtype t, _Bool r, _Bool cut) {
ldir_t dir = r ? LD_PREV : LD_NEXT;
lnode_t* c;
ssize_t i;
int cmp;
c = ldir_dir((lnode_t*)s, dir);
i = 0;
if (!is_null(x)) memset(x, 0, sizeof(*x));
while (!is_null(c)) {
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, v, t);
if (cmp == 0) {
if (!cut && !is_null(x)) {
value_set(x, &c->node, c->type, VF_WRITEABLE|VF_CHANGEABLE);
} else if (cut) lnode_cut(x, s, c);
return i;
}
c = ldir_dir(c, dir);
++i;
}
return -1;
}
size_t libcdsb_list_count(const list_t* s, const void* v, vtype t) {
lnode_t* c;
size_t n;
int cmp;
c = s->first;
n = 0;
while (!is_null(c)) {
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, v, t);
if (cmp == 0) ++n;
c = c->next;
}
return n;
}
/*#####################################################################################################################*/
@ -160,10 +70,88 @@ _Bool libcdsb_list_update(list_t* x, ssize_t i, const void* v, vtype t, int ins)
}
/*#####################################################################################################################*/
size_t libcdsb_list_count(const list_t* s, const void* v, vtype t) {
lnode_t* c;
size_t n;
int cmp;
c = s->first;
n = 0;
while (!is_null(c)) {
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, v, t);
if (cmp == 0) ++n;
c = c->next;
}
return n;
}
int libcdsb_list_foreach(vtype_list* x, void* data, list_foreach_callback callback, _Bool flush) {
int libcdsb_list_get(vtype_list* x, ssize_t i, void* _, list_access_callback callback, _Bool cut) {
ldir_t dir;
lnode_t* c;
size_t n;
if (i < 0) {
n = ~i;
dir = LD_PREV;
} else {
n = i;
dir = LD_NEXT;
}
c = ldir_dir((lnode_t*)x, dir);
while (n && !is_null(c)) {
c = ldir_dir(c, dir);
--n;
}
if (n || is_null(c)) return -1;
i = (callback) ? callback(vnode_peek(&c->node, c->type), i, c->type, _) : 0;
if (cut) lnode_cut(x, c);
return i;
}
int libcdsb_list_find(vtype_list* x, const void* v, vtype t, void* _, list_access_callback callback, _Bool r, _Bool cut) {
ldir_t dir;
lnode_t* c;
ssize_t i;
int cmp;
dir = r ? LD_PREV : LD_NEXT;
c = ldir_dir((lnode_t*)x, dir);
i = 0;
while (!is_null(c)) {
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, v, t);
if (cmp == 0) {
i = (callback) ? callback(vnode_peek(&c->node, c->type), (r)?~i:i, c->type, _) : 0;
if (cut) lnode_cut(x, c);
return i;
}
c = ldir_dir(c, dir);
++i;
}
return -1;
}
int libcdsb_list_foreach(vtype_list* x, void* data, list_access_callback callback, _Bool flush) {
lnode_t* n;
lnode_t* c;
@ -178,7 +166,7 @@ int libcdsb_list_foreach(vtype_list* x, void* data, list_foreach_callback callba
break;
n = c->next;
if (flush) {
vnode_free(&c->node, c->type);
free(c);

View File

@ -3,25 +3,25 @@
#include "include.h"
ssize_t libcdsb_list_find_pointer(val_t* x, list_t* s, const void* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_cstring(val_t* x, list_t* s, const char* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_string (val_t* x, list_t* s, const str_t* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, v, vtypeof( v), r, cut); }
ssize_t libcdsb_list_find_array (val_t* x, list_t* s, const arr_t* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, v, vtypeof( v), r, cut); }
ssize_t libcdsb_list_find_list (val_t* x, list_t* s, const list_t* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, v, vtypeof( v), r, cut); }
ssize_t libcdsb_list_find_map (val_t* x, list_t* s, const map_t* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, v, vtypeof( v), r, cut); }
ssize_t libcdsb_list_find_vset (val_t* x, list_t* s, const set_t* v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, v, vtypeof( v), r, cut); }
ssize_t libcdsb_list_find_boolean(val_t* x, list_t* s, _Bool v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_int8 (val_t* x, list_t* s, s8_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_int16 (val_t* x, list_t* s, s16_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_int32 (val_t* x, list_t* s, s32_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_int64 (val_t* x, list_t* s, s64_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_uint8 (val_t* x, list_t* s, u8_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_uint16 (val_t* x, list_t* s, u16_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_uint32 (val_t* x, list_t* s, u32_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_uint64 (val_t* x, list_t* s, u64_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_float (val_t* x, list_t* s, fl_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_double (val_t* x, list_t* s, dbl_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
ssize_t libcdsb_list_find_ldouble(val_t* x, list_t* s, ldbl_t v, _Bool r, _Bool cut) { return libcdsb_list_find(x, s, &v, vtypeof(&v), r, cut); }
int libcdsb_list_find_pointer(list_t* x, const void* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_cstring(list_t* x, const char* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_string (list_t* x, const str_t* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, v, vtypeof( v), _, cb, r, cut); }
int libcdsb_list_find_array (list_t* x, const arr_t* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, v, vtypeof( v), _, cb, r, cut); }
int libcdsb_list_find_list (list_t* x, const list_t* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, v, vtypeof( v), _, cb, r, cut); }
int libcdsb_list_find_map (list_t* x, const map_t* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, v, vtypeof( v), _, cb, r, cut); }
int libcdsb_list_find_vset (list_t* x, const set_t* v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, v, vtypeof( v), _, cb, r, cut); }
int libcdsb_list_find_boolean(list_t* x, _Bool v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_int8 (list_t* x, s8_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_int16 (list_t* x, s16_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_int32 (list_t* x, s32_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_int64 (list_t* x, s64_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_uint8 (list_t* x, u8_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_uint16 (list_t* x, u16_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_uint32 (list_t* x, u32_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_uint64 (list_t* x, u64_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_float (list_t* x, fl_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_double (list_t* x, dbl_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
int libcdsb_list_find_ldouble(list_t* x, ldbl_t v, void* _, list_access_callback cb, _Bool r, _Bool cut) { return libcdsb_list_find(x, &v, vtypeof(&v), _, cb, r, cut); }
size_t libcdsb_list_count_pointer(const list_t* s, const void* v) { return libcdsb_list_count((void*)s, &v, vtypeof(&v)); }
size_t libcdsb_list_count_cstring(const list_t* s, const char* v) { return libcdsb_list_count((void*)s, &v, vtypeof(&v)); }

View File

@ -3,36 +3,6 @@
#include "include.h"
_Bool libcdsb_map_find(val_t* x, map_t* s, const void* k, vtype t, _Bool cut) {
mnode_t* c;
int cmp;
c = s->root;
while (!mnode_is_empty(c)) {
cmp = vtype_compare(vnode_peek(&c->key, s->type), s->type, k, t);
if (cmp == 0) {
if (cut) {
c = mnode_delete(&s->root, c);
if (!is_null(x)) {
value_set(x, c->value, c->type, VF_WRITEABLE|VF_REMOVABLE);
} else vnode_free(&c->value, c->type);
vnode_free(&c->key, s->type);
free(c);
} else if (!is_null(x)) value_set(x, &c->value, c->type, VF_WRITEABLE|VF_CHANGEABLE);
return true;
}
c = (cmp < 0) ? c->right : c->left;
}
return false;
}
_Bool libcdsb_map_update(map_t* x, const void* k, vtype kt, const void* v, vtype vt) {
int cmp;
mnode_t* n;
@ -80,7 +50,37 @@ _Bool libcdsb_map_update(map_t* x, const void* k, vtype kt, const void* v, vtype
}
int libcdsb_map_foreach(map_t* x, void* dt, map_foreach_callback callback, _Bool flush) {
int libcdsb_map_find(map_t* x, const void* k, vtype t, void* _, map_access_callback callback, _Bool cut) {
mnode_t* c;
void *key;
int cmp;
c = x->root;
while (!mnode_is_empty(c)) {
key = vnode_peek(&c->key, x->type);
cmp = vtype_compare(key, x->type, k, t);
if (cmp == 0) {
cmp = (callback) ? callback(key, x->type, vnode_peek(&c->value, c->type), c->type, _) : 0;
if (cut) {
c = mnode_delete(&x->root, c);
vnode_free(&c->key, x->type);
vnode_free(&c->value, c->type);
free(c);
}
return cmp;
}
}
return -1;
}
int libcdsb_map_foreach(map_t* x, void* dt, map_access_callback callback, _Bool flush) {
stack_t z = { .prev = 0, .value = x->root };
int r = 0;
mnode_t* c;

View File

@ -3,25 +3,25 @@
#include "include.h"
_Bool libcdsb_map_find_pointer(val_t* x, map_t* s, const void* k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_cstring(val_t* x, map_t* s, const char* k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_string (val_t* x, map_t* s, const str_t* k, _Bool cut) { return libcdsb_map_find(x, s, k, vtypeof( k), cut); }
_Bool libcdsb_map_find_array (val_t* x, map_t* s, const arr_t* k, _Bool cut) { return libcdsb_map_find(x, s, k, vtypeof( k), cut); }
_Bool libcdsb_map_find_list (val_t* x, map_t* s, const list_t* k, _Bool cut) { return libcdsb_map_find(x, s, k, vtypeof( k), cut); }
_Bool libcdsb_map_find_map (val_t* x, map_t* s, const map_t* k, _Bool cut) { return libcdsb_map_find(x, s, k, vtypeof( k), cut); }
_Bool libcdsb_map_find_vset (val_t* x, map_t* s, const set_t* k, _Bool cut) { return libcdsb_map_find(x, s, k, vtypeof( k), cut); }
_Bool libcdsb_map_find_boolean(val_t* x, map_t* s, _Bool k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_int8 (val_t* x, map_t* s, s8_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_int16 (val_t* x, map_t* s, s16_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_int32 (val_t* x, map_t* s, s32_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_int64 (val_t* x, map_t* s, s64_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_uint8 (val_t* x, map_t* s, u8_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_uint16 (val_t* x, map_t* s, u16_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_uint32 (val_t* x, map_t* s, u32_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_uint64 (val_t* x, map_t* s, u64_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_float (val_t* x, map_t* s, fl_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_double (val_t* x, map_t* s, dbl_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
_Bool libcdsb_map_find_ldouble(val_t* x, map_t* s, ldbl_t k, _Bool cut) { return libcdsb_map_find(x, s, &k, vtypeof(&k), cut); }
int libcdsb_map_find_pointer(map_t* x, const void* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_cstring(map_t* x, const char* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_string (map_t* x, const str_t* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, k, vtypeof( k), _, cb, cut); }
int libcdsb_map_find_array (map_t* x, const arr_t* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, k, vtypeof( k), _, cb, cut); }
int libcdsb_map_find_list (map_t* x, const list_t* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, k, vtypeof( k), _, cb, cut); }
int libcdsb_map_find_map (map_t* x, const map_t* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, k, vtypeof( k), _, cb, cut); }
int libcdsb_map_find_vset (map_t* x, const set_t* k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, k, vtypeof( k), _, cb, cut); }
int libcdsb_map_find_boolean(map_t* x, _Bool k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_int8 (map_t* x, s8_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_int16 (map_t* x, s16_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_int32 (map_t* x, s32_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_int64 (map_t* x, s64_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_uint8 (map_t* x, u8_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_uint16 (map_t* x, u16_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_uint32 (map_t* x, u32_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_uint64 (map_t* x, u64_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_float (map_t* x, fl_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_double (map_t* x, dbl_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
int libcdsb_map_find_ldouble(map_t* x, ldbl_t k, void* _, map_access_callback cb, _Bool cut) { return libcdsb_map_find(x, &k, vtypeof(&k), _, cb, cut); }
_Bool libcdsb_map_update_pointer_pointer(map_t* x, const void* k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); }
_Bool libcdsb_map_update_pointer_cstring(map_t* x, const void* k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); }

View File

@ -4,34 +4,6 @@
#include "../../include/extra/set.h"
#include "../__internal/rbtree.h"
_Bool libcdsb_vset_find(val_t* x, set_t* s, const void* v, vtype t, _Bool cut) {
rbnode_t* c;
int cmp;
c = s->root;
while (!rbnode_is_empty(c)) {
cmp = vtype_compare(vnode_peek(&c->value, s->type), s->type, v, t);
if (cmp == 0) {
if (cut) {
c = rbnode_delete(&s->root, c);
if (!is_null(x)) {
value_set(x, c->value, s->type, VF_WRITEABLE|VF_REMOVABLE);
} else vnode_free(&c->value, s->type);
free(c);
} else if (!is_null(x)) value_set(x, c->value, s->type, VF_UNDEFINED);
return true;
}
c = (cmp < 0) ? c->right : c->left;
}
return false;
}
_Bool libcdsb_vset_insert(set_t* x, const void* v, vtype t) {
int cmp;
rbnode_t* n;
@ -70,7 +42,35 @@ _Bool libcdsb_vset_insert(set_t* x, const void* v, vtype t) {
}
int libcdsb_vset_foreach(set_t* x, void* data, vset_foreach_callback callback, _Bool flush) {
int libcdsb_vset_find(vtype_set* x, const void* v, vtype t, void* _, vset_access_callback callback, _Bool cut) {
rbnode_t* c;
void *val;
int cmp;
c = x->root;
while (!rbnode_is_empty(c)) {
val = vnode_peek(&c->value, x->type);
cmp = vtype_compare(val, x->type, v, t);
if (cmp == 0) {
cmp = (callback) ? callback(val, x->type, _) : 0;
if (cut) {
c = rbnode_delete(&x->root, c);
vnode_free(&c->value, x->type);
free(c);
}
return cmp;
}
}
return -1;
}
int libcdsb_vset_foreach(set_t* x, void* data, vset_access_callback callback, _Bool flush) {
stack_t z = { .prev = 0, .value = x->root };
int r = 0;
rbnode_t* c;

View File

@ -4,25 +4,25 @@
#include "../../include/extra/set.h"
#include "../__internal/include.h"
_Bool libcdsb_vset_touch_pointer(set_t* x, const void* k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_cstring(set_t* x, const char* k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_string (set_t* x, const str_t* k, _Bool f) { return libcdsb_vset_find(0, x, k, vtypeof( k), f); }
_Bool libcdsb_vset_touch_array (set_t* x, const arr_t* k, _Bool f) { return libcdsb_vset_find(0, x, k, vtypeof( k), f); }
_Bool libcdsb_vset_touch_list (set_t* x, const list_t* k, _Bool f) { return libcdsb_vset_find(0, x, k, vtypeof( k), f); }
_Bool libcdsb_vset_touch_map (set_t* x, const map_t* k, _Bool f) { return libcdsb_vset_find(0, x, k, vtypeof( k), f); }
_Bool libcdsb_vset_touch_vset (set_t* x, const set_t* k, _Bool f) { return libcdsb_vset_find(0, x, k, vtypeof( k), f); }
_Bool libcdsb_vset_touch_boolean(set_t* x, _Bool k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_int8 (set_t* x, s8_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_int16 (set_t* x, s16_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_int32 (set_t* x, s32_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_int64 (set_t* x, s64_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_uint8 (set_t* x, u8_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_uint16 (set_t* x, u16_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_uint32 (set_t* x, u32_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_uint64 (set_t* x, u64_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_float (set_t* x, fl_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_double (set_t* x, dbl_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
_Bool libcdsb_vset_touch_ldouble(set_t* x, ldbl_t k, _Bool f) { return libcdsb_vset_find(0, x, &k, vtypeof(&k), f); }
int libcdsb_vset_find_pointer(set_t* x, const void* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_cstring(set_t* x, const char* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_string (set_t* x, const str_t* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, v, vtypeof( v), _, cb, cut); }
int libcdsb_vset_find_array (set_t* x, const arr_t* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, v, vtypeof( v), _, cb, cut); }
int libcdsb_vset_find_list (set_t* x, const list_t* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, v, vtypeof( v), _, cb, cut); }
int libcdsb_vset_find_map (set_t* x, const map_t* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, v, vtypeof( v), _, cb, cut); }
int libcdsb_vset_find_vset (set_t* x, const set_t* v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, v, vtypeof( v), _, cb, cut); }
int libcdsb_vset_find_boolean(set_t* x, _Bool v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_int8 (set_t* x, s8_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_int16 (set_t* x, s16_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_int32 (set_t* x, s32_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_int64 (set_t* x, s64_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_uint8 (set_t* x, u8_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_uint16 (set_t* x, u16_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_uint32 (set_t* x, u32_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_uint64 (set_t* x, u64_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_float (set_t* x, fl_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_double (set_t* x, dbl_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
int libcdsb_vset_find_ldouble(set_t* x, ldbl_t v, void* _, vset_access_callback cb, _Bool cut) { return libcdsb_vset_find(x, &v, vtypeof(&v), _, cb, cut); }
_Bool libcdsb_vset_push_pointer(set_t* x, const void* v) { return libcdsb_vset_insert(x, &v, vtypeof(&v)); }
_Bool libcdsb_vset_push_cstring(set_t* x, const char* v) { return libcdsb_vset_insert(x, &v, vtypeof(&v)); }