From f73f8010133a5bffcc6ae52b0cfdb7315dc52bae Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 2 Jun 2022 21:41:06 +0300 Subject: [PATCH 01/63] Add tests base --- tests/include/random.h | 26 +++++++++ tests/include/test.h | 12 +++++ tests/include/time.h | 24 +++++++++ tests/src/random.c | 80 +++++++++++++++++++++++++++ tests/src/test.c | 41 ++++++++++++++ tests/src/time.c | 120 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 303 insertions(+) create mode 100644 tests/include/random.h create mode 100644 tests/include/test.h create mode 100644 tests/include/time.h create mode 100644 tests/src/random.c create mode 100644 tests/src/test.c create mode 100644 tests/src/time.c diff --git a/tests/include/random.h b/tests/include/random.h new file mode 100644 index 0000000..fa24373 --- /dev/null +++ b/tests/include/random.h @@ -0,0 +1,26 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../include/vtype.h" + +#ifndef LIBCDSB_TESTS_RANDOM_H +#define LIBCDSB_TESTS_RANDOM_H + +extern int random_init(int argc, char** argv); + +extern vtype_bool random_boolean(); +extern vtype_float random_float(); +extern vtype_double random_double(); +extern vtype_ldouble random_ldouble(); + +extern vtype_uint8 random_uint8(); +extern vtype_uint16 random_uint16(); +extern vtype_uint32 random_uint32(); +extern vtype_uint64 random_uint64(); + +extern vtype_int8 random_int8(); +extern vtype_int16 random_int16(); +extern vtype_int32 random_int32(); +extern vtype_int64 random_int64(); + +#endif /* LIBCDSB_TESTS_RANDOM_H */ diff --git a/tests/include/test.h b/tests/include/test.h new file mode 100644 index 0000000..4a6a4c5 --- /dev/null +++ b/tests/include/test.h @@ -0,0 +1,12 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include + +#ifndef LIBCDSB_TESTS_TEST_H +#define LIBCDSB_TESTS_TEST_H + +extern void put_separator(); +extern void test_init(int argc, char** argv); + +#endif /* LIBCDSB_TESTS_TEST_H */ diff --git a/tests/include/time.h b/tests/include/time.h new file mode 100644 index 0000000..0558e5c --- /dev/null +++ b/tests/include/time.h @@ -0,0 +1,24 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../include/vtype.h" + +#ifndef LIBCDSB_TESTS_TIME_H +#define LIBCDSB_TESTS_TIME_H + +typedef struct timer { + void* info; +} TIMER; + + +extern void timer_init (TIMER* timer); +extern void timer_start(TIMER* timer); +extern void timer_stop (TIMER* timer); +extern void timer_free (TIMER* timer); + +extern vtype_ldouble timer_value(TIMER* timer); + +extern void psleep(unsigned long microsec); + + +#endif /* LIBCDSB_TESTS_TIME_H */ diff --git a/tests/src/random.c b/tests/src/random.c new file mode 100644 index 0000000..a09ea4a --- /dev/null +++ b/tests/src/random.c @@ -0,0 +1,80 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include + +#include "../include/test.h" +#include "../include/random.h" + + +static void init(unsigned int seed) { + printf("\e[36mRandom module initialized with seed: \e[m\e[32m%u\n\e[m", seed); + put_separator(); + srand(seed); +} + +int random_init(int argc, char** argv) { + if (argc < 2) { + init(time(0)); + } else init(atol(argv[1])); + + return 0; +} + +vtype_bool random_boolean() { + return rand()&1; +} + +vtype_float random_float() { + if (rand()&1) { + return ((vtype_float)random_uint16() / (vtype_float)random_int16()) * -1; + } + return (vtype_float)random_uint16() / (vtype_float)random_int16(); +} + +vtype_double random_double() { + if (rand()&1) { + return ((vtype_double)random_uint32() / (vtype_double)random_int32()) * -1; + } + return (vtype_double)random_uint32() / (vtype_double)random_int32(); +} + +vtype_ldouble random_ldouble() { + if (rand()&1) { + return ((vtype_ldouble)random_uint64() / (vtype_ldouble)random_int64()) * -1; + } + return (vtype_ldouble)random_uint64() / (vtype_ldouble)random_int64(); +} + +vtype_int8 random_int8() { + return random_uint8(); +} + +vtype_int16 random_int16() { + return random_uint16(); +} + +vtype_int32 random_int32() { + return rand() | ((rand()&1) << 31); +} + +vtype_uint8 random_uint8() { + return rand() % 0x100; +} + +vtype_uint16 random_uint16() { + return rand() % 0x10000; +} + +vtype_uint32 random_uint32() { + return rand() << 1 | rand()&1; +} + +vtype_uint64 random_uint64() { + return random_int32() * random_int32(); +} + +vtype_int64 random_int64() { + return random_uint32() * random_uint32(); +} diff --git a/tests/src/test.c b/tests/src/test.c new file mode 100644 index 0000000..397a067 --- /dev/null +++ b/tests/src/test.c @@ -0,0 +1,41 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include "../include/test.h" +#include "../include/time.h" +#include "../include/random.h" + +static TIMER GLOBAL_TIMER; +static const char* TEST_NAME = 0; + +static void test_uload() __attribute__((destructor)); + +static void test_uload() { + if (TEST_NAME) { + timer_stop(&GLOBAL_TIMER); + puts(""); + put_separator(); + printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is end.\nExecusion time: \e[m\e[32m%.6Lf sec\e[m\n", TEST_NAME, timer_value(&GLOBAL_TIMER)); + put_separator(); + /////////////////////////// + timer_free(&GLOBAL_TIMER); + } +} + +void put_separator() { puts("\e[37;2m=== === === === === === === ===\e[m"); } + +void test_init(int argc, char** argv) { + timer_init(&GLOBAL_TIMER); + timer_start(&GLOBAL_TIMER); + + TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0]; + + put_separator(); + printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME); + put_separator(); + + random_init(argc, argv); + + puts(""); +} diff --git a/tests/src/time.c b/tests/src/time.c new file mode 100644 index 0000000..1151708 --- /dev/null +++ b/tests/src/time.c @@ -0,0 +1,120 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#define __USE_MISC +#include +#include +#include +#include "../include/time.h" + +typedef struct timer_internal { + struct rusage begin; + struct rusage end; + struct rusage br; + unsigned long offset; + struct { + int isbr:1; + int isend:1; + }; +} TIMER_INFO; + + +void timer_init(TIMER* timer) { + TIMER_INFO *t; + if (!(t = timer->info = malloc(sizeof(TIMER_INFO)))) + abort(); + memset(t, 0, sizeof(*t)); +} + +void timer_start(TIMER* timer) { + TIMER_INFO *t = timer->info; + + if (t->isend) + return; + + if (t->isbr) { + struct rusage br; + + if (getrusage(RUSAGE_SELF, &br) < 0) + abort(); + + t->offset += br.ru_utime.tv_sec * 1000000 - t->br.ru_utime.tv_sec * 1000000; + t->offset -= t->br.ru_utime.tv_usec; + t->offset += br.ru_utime.tv_usec; + + memset(&t->br, 0, sizeof(t->br)); + t->isbr = 0; + } else if (getrusage(RUSAGE_SELF, &t->begin) < 0) + abort(); +} + +void timer_pause (TIMER* timer) { + TIMER_INFO *t = timer->info; + + if (t->isend) + return; + + if (!t->isbr) { + if (getrusage(RUSAGE_SELF, &t->br) < 0) + abort(); + + t->isbr = 1; + } +} + +void timer_stop (TIMER* timer) { + TIMER_INFO *t = timer->info; + + if (t->isend) + return; + + if (getrusage(RUSAGE_SELF, &t->end) < 0) + abort(); + + if (t->isbr) { + t->offset += t->end.ru_utime.tv_sec * 1000000 - t->br.ru_utime.tv_sec * 1000000; + t->offset -= t->br.ru_utime.tv_usec; + t->offset += t->end.ru_utime.tv_usec; + + memset(&t->br, 0, sizeof(t->br)); + t->isbr = 0; + } + + t->isend = 1; +} + +void timer_free (TIMER* timer) { + free(timer->info); +} + +vtype_ldouble timer_value(TIMER* timer) { + static char empty[sizeof(struct rusage)] = { 0 }; + + TIMER_INFO *t = timer->info; + + struct rusage _; + struct rusage *end; + vtype_ldouble value; + + if (memcmp(&t->begin, empty, sizeof(struct rusage)) == 0) { + return 0; + } + + if (!t->isend) { + if (getrusage(RUSAGE_SELF, end = &_) < 0) + abort(); + } else end = &t->end; + + value = end->ru_utime.tv_sec * 1000000 - t->begin.ru_utime.tv_sec * 1000000; + value -= t->begin.ru_utime.tv_usec; + value += end->ru_utime.tv_usec; + value -= t->offset; + + return value / 1000000; +} + +void psleep(unsigned long microsec) { + usleep(microsec); +} From ddca5c14cce785329871bcb3b1bc92b757b6755b Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 2 Jun 2022 21:48:56 +0300 Subject: [PATCH 02/63] Update tests base --- tests/src/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/random.c b/tests/src/random.c index a09ea4a..340b935 100644 --- a/tests/src/random.c +++ b/tests/src/random.c @@ -68,7 +68,7 @@ vtype_uint16 random_uint16() { } vtype_uint32 random_uint32() { - return rand() << 1 | rand()&1; + return (rand()<<1) | (rand()&1); } vtype_uint64 random_uint64() { From 4c2d6df0eeb6f08fd14bf95e2d876ffef7ec6491 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 2 Jun 2022 22:22:13 +0300 Subject: [PATCH 03/63] Add tests .gitignore --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/.gitignore diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +/bin From 6d09188fdd1d23a4ece9e7757235c1f369b4a025 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 2 Jun 2022 22:23:01 +0300 Subject: [PATCH 04/63] Add tests skeleton --- tests/Makefile | 81 +++++++++++++++++++++++++++++++++++++++++ tests/src/array/main.c | 8 ++++ tests/src/array/plug.h | 29 +++++++++++++++ tests/src/list/main.c | 13 +++++++ tests/src/list/plug.h | 23 ++++++++++++ tests/src/map/main.c | 13 +++++++ tests/src/map/plug.h | 23 ++++++++++++ tests/src/set/main.c | 13 +++++++ tests/src/set/plug.h | 23 ++++++++++++ tests/src/string/main.c | 8 ++++ tests/src/string/plug.h | 23 ++++++++++++ 11 files changed, 257 insertions(+) create mode 100644 tests/Makefile create mode 100644 tests/src/array/main.c create mode 100644 tests/src/array/plug.h create mode 100644 tests/src/list/main.c create mode 100644 tests/src/list/plug.h create mode 100644 tests/src/map/main.c create mode 100644 tests/src/map/plug.h create mode 100644 tests/src/set/main.c create mode 100644 tests/src/set/plug.h create mode 100644 tests/src/string/main.c create mode 100644 tests/src/string/plug.h diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..0bd0ddf --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,81 @@ +# This software is licensed by the MIT License, see LICENSE file +# Copyright © 2022 Gregory Lirent + +######################################################################################################################## + +BUILD_PATH ?= ./bin + +######################################################################################################################## + +CC = clang +MKDIR = mkdir -p +RMRF = rm -rf +AR = ar crs +CP = cp + +$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall + +######################################################################################################################## + + +c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c))))) + +OBJECTS_TESTS := $(call c_objects,./src/,) +OBJECTS_BASE := $(call c_objects,../src/,) +OBJECTS_STRING := $(OBJECTS_BASE) $(call c_objects,../src/string/,string-) +OBJECTS_ARRAY := $(OBJECTS_BASE) $(call c_objects,../src/array/,array-) +OBJECTS_LIST := $(OBJECTS_BASE) $(call c_objects,../src/list/,list-) +OBJECTS_MAP := $(OBJECTS_BASE) $(call c_objects,../src/map/,map-) +OBJECTS_SET := $(OBJECTS_BASE) $(call c_objects,../src/set/,set-) + +OBJECTS_BASE := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_BASE)) +OBJECTS_STRING := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_STRING)) +OBJECTS_ARRAY := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_ARRAY)) +OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_LIST)) +OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP)) +OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET)) + +######################################################################################################################## + +tests: modules +tests: $(BUILD_PATH)/array +tests: $(BUILD_PATH)/string +tests: $(BUILD_PATH)/list +tests: $(BUILD_PATH)/map +tests: $(BUILD_PATH)/set + +######################################################################################################################## + +$(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) + +$(BUILD_PATH)/array: ./src/array/main.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/string: ./src/string/main.c $(OBJECTS_STRING) | $(BUILD_PATH)/ + $(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) +$(BUILD_PATH)/list: ./src/list/main.c $(OBJECTS_LIST) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/map: ./src/map/main.c $(OBJECTS_MAP) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/set: ./src/set/main.c $(OBJECTS_SET) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) + +######################################################################################################################## + +$(BUILD_PATH)/: + $(MKDIR) $@ +$(BUILD_PATH)/obj/: | $(BUILD_PATH)/ + $(MKDIR) $@ + +######################################################################################################################## + +clean: + $(RMRF) ./bin/ + cd ../ && $(MAKE) clean + +######################################################################################################################## + +modules: ../bin/debug/libcdsb.a + +../bin/debug/libcdsb.a: + cd ../ && $(MAKE) debug diff --git a/tests/src/array/main.c b/tests/src/array/main.c new file mode 100644 index 0000000..5c9f26c --- /dev/null +++ b/tests/src/array/main.c @@ -0,0 +1,8 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h new file mode 100644 index 0000000..74bf6d4 --- /dev/null +++ b/tests/src/array/plug.h @@ -0,0 +1,29 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include "../../../include/array.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + +extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } +extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } +extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } +extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } diff --git a/tests/src/list/main.c b/tests/src/list/main.c new file mode 100644 index 0000000..8fa9908 --- /dev/null +++ b/tests/src/list/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_list* list_duplicate(const vtype_list* x) { return 0; } +int list_compare(const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +void list_free(vtype_list* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h new file mode 100644 index 0000000..76e2ed4 --- /dev/null +++ b/tests/src/list/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/list.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/map/main.c b/tests/src/map/main.c new file mode 100644 index 0000000..a0638f1 --- /dev/null +++ b/tests/src/map/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_map* map_duplicate(const vtype_map* x) { return 0; } +int map_compare(const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +void map_free(vtype_map* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h new file mode 100644 index 0000000..093107c --- /dev/null +++ b/tests/src/map/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/map.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/set/main.c b/tests/src/set/main.c new file mode 100644 index 0000000..3ba1d93 --- /dev/null +++ b/tests/src/set/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_set* vset_duplicate(const vtype_set* x) { return 0; } +int vset_compare(const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +void vset_free(vtype_set* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h new file mode 100644 index 0000000..661c878 --- /dev/null +++ b/tests/src/set/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/set.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } diff --git a/tests/src/string/main.c b/tests/src/string/main.c new file mode 100644 index 0000000..5c9f26c --- /dev/null +++ b/tests/src/string/main.c @@ -0,0 +1,8 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h new file mode 100644 index 0000000..257d6e9 --- /dev/null +++ b/tests/src/string/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/extra/string.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } From 8ed715965594b072a41dd90c4bb2440db0e5cdaa Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 11:53:54 +0300 Subject: [PATCH 05/63] Add debug symbols to tests --- tests/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 0bd0ddf..7f10ce4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -13,7 +13,7 @@ RMRF = rm -rf AR = ar crs CP = cp -$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall +$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall ######################################################################################################################## @@ -50,15 +50,15 @@ $(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) $(BUILD_PATH)/array: ./src/array/main.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ - $(CC) $^ -o $@ $(CFLAGS) + $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/string: ./src/string/main.c $(OBJECTS_STRING) | $(BUILD_PATH)/ - $(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) + $(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) -g3 -Wall $(BUILD_PATH)/list: ./src/list/main.c $(OBJECTS_LIST) | $(BUILD_PATH)/ - $(CC) $^ -o $@ $(CFLAGS) + $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/map: ./src/map/main.c $(OBJECTS_MAP) | $(BUILD_PATH)/ - $(CC) $^ -o $@ $(CFLAGS) + $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/set: ./src/set/main.c $(OBJECTS_SET) | $(BUILD_PATH)/ - $(CC) $^ -o $@ $(CFLAGS) + $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall ######################################################################################################################## From ee602d91b90aa395aa96a64cb9a18dd381ed92d7 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 11:54:22 +0300 Subject: [PATCH 06/63] Update tests base --- tests/src/random.c | 3 ++- tests/src/time.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/src/random.c b/tests/src/random.c index 340b935..1fa5a28 100644 --- a/tests/src/random.c +++ b/tests/src/random.c @@ -9,6 +9,7 @@ static void init(unsigned int seed) { + if (!seed) seed = time(0); printf("\e[36mRandom module initialized with seed: \e[m\e[32m%u\n\e[m", seed); put_separator(); srand(seed); @@ -16,7 +17,7 @@ static void init(unsigned int seed) { int random_init(int argc, char** argv) { if (argc < 2) { - init(time(0)); + init(0); } else init(atol(argv[1])); return 0; diff --git a/tests/src/time.c b/tests/src/time.c index 1151708..255f799 100644 --- a/tests/src/time.c +++ b/tests/src/time.c @@ -3,7 +3,9 @@ #include #include +#ifndef __USE_MISC #define __USE_MISC +#endif #include #include #include From f2742661fb6d50acbb62ba4aafc65e4e97e32c45 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 11:54:40 +0300 Subject: [PATCH 07/63] Update array test --- tests/src/array/main.c | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/tests/src/array/main.c b/tests/src/array/main.c index 5c9f26c..1586be0 100644 --- a/tests/src/array/main.c +++ b/tests/src/array/main.c @@ -1,8 +1,102 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include "../../../include/extra/vtype.h" #include "plug.h" +static void array_push_random_value(vtype_array* x) { + switch (random_uint8()%10) { + default: + case 0: array_push(x, random_boolean()); break; + case 1: array_push(x, random_uint8()); break; + case 2: array_push(x, random_uint16()); break; + case 3: array_push(x, random_uint32()); break; + case 4: array_push(x, random_uint64()); break; + case 5: array_push(x, random_int8()); break; + case 6: array_push(x, random_int16()); break; + case 7: array_push(x, random_int32()); break; + case 8: array_push(x, random_int64()); break; + case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; + } +} + +static void array_push_random_float(vtype_array* x) { + switch (random_uint8()%3) { + default: + case 0: array_push(x, random_float()); break; + case 1: array_push(x, random_double()); break; + case 2: array_push(x, random_ldouble()); break; + } +} + +static void array_push_random(vtype_array* x) { + if (x->type < VTYPE_FLOAT) { + array_push_random_value(x); + } else array_push_random_float(x); +} + +static void array_init_random(vtype_array* x) { + switch (random_uint8()%13) { + default: + case 0: array_init(x, VTYPE_BOOLEAN); break; + case 1: array_init(x, VTYPE_UINT8); break; + case 2: array_init(x, VTYPE_UINT16); break; + case 3: array_init(x, VTYPE_UINT32); break; + case 4: array_init(x, VTYPE_UINT64); break; + case 5: array_init(x, VTYPE_INT8); break; + case 6: array_init(x, VTYPE_INT16); break; + case 7: array_init(x, VTYPE_INT32); break; + case 8: array_init(x, VTYPE_INT64); break; + case 9: array_init(x, VTYPE_POINTER); break; + case 10: array_init(x, VTYPE_FLOAT); break; + case 11: array_init(x, VTYPE_DOUBLE); break; + case 12: array_init(x, VTYPE_LDOUBLE); break; + } +} + +static vtype_array array_random() { + unsigned short n = random_int16(); + + vtype_array x; + + array_init_random(&x); + + for (int i = 0; i < 10; ++i) { + array_push_random(&x); + } + + return x; +} + + int main(int argc, char** argv) { test_init(argc, argv); + + vtype_array x = { .mem = 0 }; + + do { + array_free(&x); + x = array_random(); + } while (x.type >= VTYPE_FLOAT); + + printf("Array initialized with type `%s`;\n", libcdsb_vtype_name(x.type)); + printf("Array has %lu elements (%lu bytes);\n", array_size(&x), array_nmemb(&x)); + puts(""); + + for (int i = 0; i < x.size; ++i) { + printf("%s\n", libcdsb_vtype_stringify(array_at(&x, i), x.type)); + } + + for (vtype_uint64 v = 0; v < UINT64_MAX; ++v) { + ssize_t index = array_indexof(&x, v); + if (index >= 0) { + printf("Value %lu was found on the position %ld\n", v, index); + break; + } + } + + + + + array_free(&x); } From 6a6b558979cbd6f302dbe8f809f7d05a376b3fa8 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 12:18:58 +0300 Subject: [PATCH 08/63] Delete test's .gitignore --- tests/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/.gitignore diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 5e56e04..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin From 315e35e7f6b515b67c4575608268a1d64628f11a Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 14:09:11 +0300 Subject: [PATCH 09/63] Update tests base --- tests/src/test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/src/test.c b/tests/src/test.c index 397a067..7e24bc4 100644 --- a/tests/src/test.c +++ b/tests/src/test.c @@ -18,7 +18,6 @@ static void test_uload() { put_separator(); printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is end.\nExecusion time: \e[m\e[32m%.6Lf sec\e[m\n", TEST_NAME, timer_value(&GLOBAL_TIMER)); put_separator(); - /////////////////////////// timer_free(&GLOBAL_TIMER); } } @@ -32,7 +31,7 @@ void test_init(int argc, char** argv) { TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0]; put_separator(); - printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME); + printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME); put_separator(); random_init(argc, argv); From ed737e31774a8ff3f3bbe9067f53023ec89ed0c1 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 14:09:23 +0300 Subject: [PATCH 10/63] Update array tests --- tests/src/array/change.c | 29 ++++++++++++ tests/src/array/main.c | 96 +++++++--------------------------------- tests/src/array/plug.h | 80 +++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 80 deletions(-) create mode 100644 tests/src/array/change.c diff --git a/tests/src/array/change.c b/tests/src/array/change.c new file mode 100644 index 0000000..92a6fa0 --- /dev/null +++ b/tests/src/array/change.c @@ -0,0 +1,29 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); + + vtype_array y; + vtype_array x = array_random(8); + + array_info(&x); + array_sort(&x); + array_print(&x, 0); + + array_slice(&y, &x, 2, 4, 1); + + array_print(&x, "source"); + array_print(&y, "cutted"); + + array_remove_by_index(&x, -1); + array_remove_by_index(&y, -1); + + array_print(&x, "source (last removed)"); + array_print(&y, "cutted (last removed)"); + + array_free(&x); + array_free(&y); +} diff --git a/tests/src/array/main.c b/tests/src/array/main.c index 1586be0..a8b5ab4 100644 --- a/tests/src/array/main.c +++ b/tests/src/array/main.c @@ -1,74 +1,20 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../../include/extra/vtype.h" #include "plug.h" -static void array_push_random_value(vtype_array* x) { - switch (random_uint8()%10) { - default: - case 0: array_push(x, random_boolean()); break; - case 1: array_push(x, random_uint8()); break; - case 2: array_push(x, random_uint16()); break; - case 3: array_push(x, random_uint32()); break; - case 4: array_push(x, random_uint64()); break; - case 5: array_push(x, random_int8()); break; - case 6: array_push(x, random_int16()); break; - case 7: array_push(x, random_int32()); break; - case 8: array_push(x, random_int64()); break; - case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; +static void array_find_minimal(const vtype_array* x) { + array_print(x, 0); + for (vtype_uint64 v = 0; v < UINT64_MAX; ++v) { + ssize_t index = array_indexof(x, v); + if (index >= 0) { + printf("\e[36mValue \e[m\e[31m%lu\e[m\e[36m was found at the position \e[m\e[32;1m%ld\e[m\n", v, index); + break; + } } + put_separator(); } -static void array_push_random_float(vtype_array* x) { - switch (random_uint8()%3) { - default: - case 0: array_push(x, random_float()); break; - case 1: array_push(x, random_double()); break; - case 2: array_push(x, random_ldouble()); break; - } -} - -static void array_push_random(vtype_array* x) { - if (x->type < VTYPE_FLOAT) { - array_push_random_value(x); - } else array_push_random_float(x); -} - -static void array_init_random(vtype_array* x) { - switch (random_uint8()%13) { - default: - case 0: array_init(x, VTYPE_BOOLEAN); break; - case 1: array_init(x, VTYPE_UINT8); break; - case 2: array_init(x, VTYPE_UINT16); break; - case 3: array_init(x, VTYPE_UINT32); break; - case 4: array_init(x, VTYPE_UINT64); break; - case 5: array_init(x, VTYPE_INT8); break; - case 6: array_init(x, VTYPE_INT16); break; - case 7: array_init(x, VTYPE_INT32); break; - case 8: array_init(x, VTYPE_INT64); break; - case 9: array_init(x, VTYPE_POINTER); break; - case 10: array_init(x, VTYPE_FLOAT); break; - case 11: array_init(x, VTYPE_DOUBLE); break; - case 12: array_init(x, VTYPE_LDOUBLE); break; - } -} - -static vtype_array array_random() { - unsigned short n = random_int16(); - - vtype_array x; - - array_init_random(&x); - - for (int i = 0; i < 10; ++i) { - array_push_random(&x); - } - - return x; -} - - int main(int argc, char** argv) { test_init(argc, argv); @@ -76,27 +22,17 @@ int main(int argc, char** argv) { do { array_free(&x); - x = array_random(); + x = array_random(8); } while (x.type >= VTYPE_FLOAT); - printf("Array initialized with type `%s`;\n", libcdsb_vtype_name(x.type)); - printf("Array has %lu elements (%lu bytes);\n", array_size(&x), array_nmemb(&x)); - puts(""); - - for (int i = 0; i < x.size; ++i) { - printf("%s\n", libcdsb_vtype_stringify(array_at(&x, i), x.type)); - } - - for (vtype_uint64 v = 0; v < UINT64_MAX; ++v) { - ssize_t index = array_indexof(&x, v); - if (index >= 0) { - printf("Value %lu was found on the position %ld\n", v, index); - break; - } - } - + array_info(&x); + array_find_minimal(&x); + array_reverse(&x); + array_print(&x, "reversed"); + array_sort(&x); + array_print(&x, "sorted"); array_free(&x); } diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index 74bf6d4..8e17da4 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -2,6 +2,7 @@ /* Copyright © 2022 Gregory Lirent */ #include +#include "../../../include/extra/vtype.h" #include "../../../include/array.h" #include "../../include/random.h" @@ -27,3 +28,82 @@ extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } + + +static void array_push_random_value(vtype_array* x) { + switch (random_uint8()%10) { + default: + case 0: array_push(x, random_boolean()); break; + case 1: array_push(x, random_uint8()); break; + case 2: array_push(x, random_uint16()); break; + case 3: array_push(x, random_uint32()); break; + case 4: array_push(x, random_uint64()); break; + case 5: array_push(x, random_int8()); break; + case 6: array_push(x, random_int16()); break; + case 7: array_push(x, random_int32()); break; + case 8: array_push(x, random_int64()); break; + case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; + } +} + +static void array_push_random_float(vtype_array* x) { + switch (random_uint8()%3) { + default: + case 0: array_push(x, random_float()); break; + case 1: array_push(x, random_double()); break; + case 2: array_push(x, random_ldouble()); break; + } +} + +static void array_push_random(vtype_array* x) { + if (x->type < VTYPE_FLOAT) { + array_push_random_value(x); + } else array_push_random_float(x); +} + +static void array_init_random(vtype_array* x) { + switch (random_uint8()%13) { + default: + case 0: array_init(x, VTYPE_BOOLEAN); break; + case 1: array_init(x, VTYPE_UINT8); break; + case 2: array_init(x, VTYPE_UINT16); break; + case 3: array_init(x, VTYPE_UINT32); break; + case 4: array_init(x, VTYPE_UINT64); break; + case 5: array_init(x, VTYPE_INT8); break; + case 6: array_init(x, VTYPE_INT16); break; + case 7: array_init(x, VTYPE_INT32); break; + case 8: array_init(x, VTYPE_INT64); break; + case 9: array_init(x, VTYPE_POINTER); break; + case 10: array_init(x, VTYPE_FLOAT); break; + case 11: array_init(x, VTYPE_DOUBLE); break; + case 12: array_init(x, VTYPE_LDOUBLE); break; + } +} + +static vtype_array array_random(unsigned int n) { + vtype_array x; + + array_init_random(&x); + + for (int i = 0; i < n; ++i) { + array_push_random(&x); + } + + return x; +} + +static void array_print(const vtype_array* x, const char* prefix) { + if (!prefix) puts("\e[36mArray values:\e[m"); + else printf("\e[36mArray %s values:\e[m\n", prefix); + for (int i = 0; i < x->size; ++i) { + printf("\e[32;1m%5d: \e[m\e[31m%24s\e[m\n", i, libcdsb_vtype_stringify(array_at(x, i), x->type)); + } + put_separator(); +} + + +static void array_info(const vtype_array* x) { + printf("\e[36mArray initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", libcdsb_vtype_name(x->type)); + printf("Array has \e[m\e[32m%lu\e[m\e[36m elements (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", array_size(x), array_nmemb(x)); + put_separator(); +} From 005014319fe070b5d6c7955a167b4219c4c1b853 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 14:09:41 +0300 Subject: [PATCH 11/63] Update tests Makefile --- tests/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 7f10ce4..67d4238 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -38,26 +38,27 @@ OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix . ######################################################################################################################## tests: modules -tests: $(BUILD_PATH)/array -tests: $(BUILD_PATH)/string -tests: $(BUILD_PATH)/list -tests: $(BUILD_PATH)/map -tests: $(BUILD_PATH)/set +tests: $(addprefix $(BUILD_PATH)/array-,$(notdir $(basename $(wildcard ./src/array/*.c)))) +tests: $(addprefix $(BUILD_PATH)/string-,$(notdir $(basename $(wildcard ./src/string/*.c)))) +tests: $(addprefix $(BUILD_PATH)/list-,$(notdir $(basename $(wildcard ./src/list/*.c)))) +tests: $(addprefix $(BUILD_PATH)/map-,$(notdir $(basename $(wildcard ./src/map/*.c)))) +tests: $(addprefix $(BUILD_PATH)/set-,$(notdir $(basename $(wildcard ./src/set/*.c)))) + ######################################################################################################################## $(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) -$(BUILD_PATH)/array: ./src/array/main.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ +$(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall -$(BUILD_PATH)/string: ./src/string/main.c $(OBJECTS_STRING) | $(BUILD_PATH)/ +$(BUILD_PATH)/string-%: ./src/string/%.c $(OBJECTS_STRING) | $(BUILD_PATH)/ $(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) -g3 -Wall -$(BUILD_PATH)/list: ./src/list/main.c $(OBJECTS_LIST) | $(BUILD_PATH)/ +$(BUILD_PATH)/list-%: ./src/list/%.c $(OBJECTS_LIST) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall -$(BUILD_PATH)/map: ./src/map/main.c $(OBJECTS_MAP) | $(BUILD_PATH)/ +$(BUILD_PATH)/map-%: ./src/map/%.c $(OBJECTS_MAP) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall -$(BUILD_PATH)/set: ./src/set/main.c $(OBJECTS_SET) | $(BUILD_PATH)/ +$(BUILD_PATH)/set-%: ./src/set/%.c $(OBJECTS_SET) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall ######################################################################################################################## From c32d771793ed4bd42077df77d268327ea9dae9ea Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 19:28:44 +0300 Subject: [PATCH 12/63] Update tests Makefile --- tests/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 67d4238..d810ace 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -76,7 +76,8 @@ clean: ######################################################################################################################## +FORCE: modules: ../bin/debug/libcdsb.a -../bin/debug/libcdsb.a: +../bin/debug/libcdsb.a: FORCE cd ../ && $(MAKE) debug From 25bb3904084f48d7d3e5966f1913192370cada16 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 19:29:06 +0300 Subject: [PATCH 13/63] Update tests base --- tests/include/random.h | 2 ++ tests/src/random.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/include/random.h b/tests/include/random.h index fa24373..69b2b07 100644 --- a/tests/include/random.h +++ b/tests/include/random.h @@ -23,4 +23,6 @@ extern vtype_int16 random_int16(); extern vtype_int32 random_int32(); extern vtype_int64 random_int64(); +extern char random_ascii_char(); +extern unsigned int random_unicode_symbol(); #endif /* LIBCDSB_TESTS_RANDOM_H */ diff --git a/tests/src/random.c b/tests/src/random.c index 1fa5a28..c77e74a 100644 --- a/tests/src/random.c +++ b/tests/src/random.c @@ -79,3 +79,33 @@ vtype_uint64 random_uint64() { vtype_int64 random_int64() { return random_uint32() * random_uint32(); } + +char random_ascii_char() { + return (rand()%0x5f) + 0x20; +} + +unsigned int random_unicode_symbol() { + switch (rand()%20) { + default: + case 0: return (random_uint16()%0x005f) + 0x000020; + case 1: return (random_uint16()%0x020f) + 0x0000a1; + case 2: return (random_uint16()%0x01a8) + 0x000388; + case 3: return (random_uint16()%0x0026) + 0x000531; + case 4: return (random_uint16()%0x002a) + 0x000560; + case 5: return (random_uint16()%0x00c6) + 0x001000; + case 6: return (random_uint16()%0x0030) + 0x0010d0; + case 7: return (random_uint16()%0x029d) + 0x001400; + case 8: return (random_uint16()%0x0058) + 0x0016a0; + case 9: return (random_uint16()%0x0074) + 0x001b80; + case 10: return (random_uint16()%0x00f4) + 0x001d00; + case 11: return (random_uint16()%0x0115) + 0x001e00; + case 12: return (random_uint16()%0x008b) + 0x002100; + case 13: return (random_uint16()%0x0297) + 0x002190; + case 14: return (random_uint16()%0x0714) + 0x002460; + case 15: return (random_uint16()%0x00b7) + 0x00a640; + case 16: return (random_uint16()%0x0074) + 0x00a8e0; + case 17: return (random_uint16()%0x009e) + 0x010400; + case 18: return (random_uint16()%0x0137) + 0x010600; + case 19: return (random_uint16()%0x03d8) + 0x01f300; + } +} From 0e0346c368a75879ee4acd0592478e132de5c768 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 19:29:46 +0300 Subject: [PATCH 14/63] Update string tests --- tests/src/string/main.c | 53 +++++++++++++++++++++++++++++++++++++++++ tests/src/string/plug.h | 26 ++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/tests/src/string/main.c b/tests/src/string/main.c index 5c9f26c..4eb7e31 100644 --- a/tests/src/string/main.c +++ b/tests/src/string/main.c @@ -3,6 +3,59 @@ #include "plug.h" + +static vtype_string string_random(unsigned int n) { + vtype_string x; + + if (random_boolean()) { + x.buffer = random_utf8_cstring(n); + } else x.buffer = random_ascii_cstring(n); + + return x; +} + +static void string_concat_random(vtype_string* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_concat(x, v); + free(v); +} + +static void string_info(vtype_string* x) { + printf("\e[36mString consists of \e[m\e[32m%lu\e[m\e[36m utf8 chars (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", string_size(x), string_nmemb(x)); +} + +static void string_print(const vtype_string* x, const char* prefix) { + if (!prefix) puts("\e[36mString content:\e[m\n"); + else printf("\e[36mString %s content:\e[m\n\n", prefix); + printf("\e[33m%s\e[m\n", x->buffer); + put_separator(); +} + + int main(int argc, char** argv) { test_init(argc, argv); + vtype_string x; + + x = string_random(31); + string_print(&x, "(part 1)"); + + string_concat(&x, '\n'); + string_concat_random(&x, 31); + + { + void* hack = string_at(&x, 32); + string_print((void*)&hack, "(part 2)"); + } + + string_info(&x); + string_print(&x, "concatenated"); + + + + string_free(&x); } diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h index 257d6e9..c144b5e 100644 --- a/tests/src/string/plug.h +++ b/tests/src/string/plug.h @@ -1,6 +1,8 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include +#include "../../../modules/libunic/include.h" #include "../../../include/extra/string.h" #include "../../include/random.h" @@ -21,3 +23,27 @@ int array_compare (const vtype_array* s0, const vtype_array* s1) { return rand int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + +static char* random_ascii_cstring(size_t size) { + char* v = malloc(size + 1); + char* p = v; + + while (size--) { + *(p++) = random_ascii_char(); + } + *p = 0; + + return v; +} + +static char* random_utf8_cstring(size_t size) { + char* v = malloc(size * 4 + 1); + char* p = v; + + while (size--) { + p = tochar_unicode(p, random_unicode_symbol()); + } + + *p = 0; + return v; +} From f178825ce6e6b11bd3feda578103956459137dbe Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sat, 4 Jun 2022 00:30:23 +0300 Subject: [PATCH 15/63] Update string tests --- tests/src/string/main.c | 70 ++++++++++++++++++++++------------------- tests/src/string/plug.h | 44 ++++++++++++++++++++++++++ tests/src/string/trim.c | 20 ++++++++++++ 3 files changed, 102 insertions(+), 32 deletions(-) create mode 100644 tests/src/string/trim.c diff --git a/tests/src/string/main.c b/tests/src/string/main.c index 4eb7e31..8b90e66 100644 --- a/tests/src/string/main.c +++ b/tests/src/string/main.c @@ -3,59 +3,65 @@ #include "plug.h" +static void string_print_compare(const vtype_string* s0, const vtype_string* s1) { + int c = string_compare(s0, s1); + char* m; + if (c == 0) m = "=="; + else m = (c < 0) ? "<" : ">"; -static vtype_string string_random(unsigned int n) { - vtype_string x; - - if (random_boolean()) { - x.buffer = random_utf8_cstring(n); - } else x.buffer = random_ascii_cstring(n); - - return x; + puts("\e[36mStrings comparsion:\e[m\n"); + printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); } -static void string_concat_random(vtype_string* x, unsigned int n) { - char* v; +static void string_print_case_compare(const vtype_string* s0, const vtype_string* s1) { + int c = string_case_compare(s0, s1); + char* m; + if (c == 0) m = "=="; + else m = (c < 0) ? "<" : ">"; - if (random_boolean()) { - v = random_utf8_cstring(n); - } else v = random_ascii_cstring(n); - - string_concat(x, v); - free(v); + puts("\e[36mStrings case insensitive comparsion:\e[m\n"); + printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); } -static void string_info(vtype_string* x) { - printf("\e[36mString consists of \e[m\e[32m%lu\e[m\e[36m utf8 chars (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", string_size(x), string_nmemb(x)); -} - -static void string_print(const vtype_string* x, const char* prefix) { - if (!prefix) puts("\e[36mString content:\e[m\n"); - else printf("\e[36mString %s content:\e[m\n\n", prefix); - printf("\e[33m%s\e[m\n", x->buffer); - put_separator(); -} - - int main(int argc, char** argv) { test_init(argc, argv); - vtype_string x; + vtype_string x, y; - x = string_random(31); + x = string_random(30); string_print(&x, "(part 1)"); string_concat(&x, '\n'); - string_concat_random(&x, 31); + string_concat_random(&x, 30); { - void* hack = string_at(&x, 32); + char* repl = random_utf8_cstring(30); + void* hack = string_at(&x, 31); string_print((void*)&hack, "(part 2)"); + string_print((void*)&repl, "(part 2 replaced)"); + string_replace(&x, hack, repl, -1); + free(repl); } string_info(&x); string_print(&x, "concatenated"); + do { + string_replace_random(&x, 12); + } while (string_size(&x) == string_nmemb(&x)); + y = string_copy(&x); + + string_to_lower(&x); + string_to_upper(&y); + + string_print_compare(&x, &y); + string_print_case_compare(&x, &y); + + string_reverse(&y); + string_capitalize(&y); + + string_print(&y, "reversed & capitalized"); string_free(&x); + string_free(&y); } diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h index c144b5e..d0fc750 100644 --- a/tests/src/string/plug.h +++ b/tests/src/string/plug.h @@ -47,3 +47,47 @@ static char* random_utf8_cstring(size_t size) { *p = 0; return v; } + +static void string_info(vtype_string* x) { + printf("\e[36mString consists of \e[m\e[32m%lu\e[m\e[36m utf8 chars (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", string_size(x), string_nmemb(x)); +} + +static void string_print(const vtype_string* x, const char* prefix) { + if (!prefix) puts("\e[36mString content:\e[m\n"); + else printf("\e[36mString %s content:\e[m\n\n", prefix); + printf("\e[33m\"%s\"\e[m\n", x->buffer); + put_separator(); +} + +static vtype_string string_random(unsigned int n) { + vtype_string x; + + if (random_boolean()) { + x.buffer = random_utf8_cstring(n); + } else x.buffer = random_ascii_cstring(n); + + return x; +} + +static void string_concat_random(vtype_string* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_concat(x, v); + free(v); +} + +static void string_replace_random(vtype_string* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_replace(x, x, v, -1); + + free(v); +} diff --git a/tests/src/string/trim.c b/tests/src/string/trim.c new file mode 100644 index 0000000..a320ce8 --- /dev/null +++ b/tests/src/string/trim.c @@ -0,0 +1,20 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); + vtype_string x; + + x = string_random(12); + + string_align_center(&x, 30, 0); + + string_print(&x, 0); + + string_trim(&x, 0); + string_print(&x, 0); + + string_free(&x); +} From 46a7f69a381cbe084f23d97816168bf2649df860 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sat, 4 Jun 2022 15:38:55 +0300 Subject: [PATCH 16/63] Update string tests --- tests/src/string/trim.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/src/string/trim.c b/tests/src/string/trim.c index a320ce8..4111e50 100644 --- a/tests/src/string/trim.c +++ b/tests/src/string/trim.c @@ -3,18 +3,27 @@ #include "plug.h" + int main(int argc, char** argv) { test_init(argc, argv); vtype_string x; + int c = random_unicode_symbol(); x = string_random(12); string_align_center(&x, 30, 0); - string_print(&x, 0); - string_trim(&x, 0); + string_trim_spaces(&x); string_print(&x, 0); + + string_align_center(&x, 30, c); + string_print(&x, 0); + + string_trim(&x, c); + string_print(&x, 0); + + string_free(&x); } From f6033d0c4f006809b5989ecfbaad6e4dc1b59143 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sat, 4 Jun 2022 22:17:03 +0300 Subject: [PATCH 17/63] Update used array symbols --- tests/src/array/change.c | 4 ++-- tests/src/array/plug.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/array/change.c b/tests/src/array/change.c index 92a6fa0..989193a 100644 --- a/tests/src/array/change.c +++ b/tests/src/array/change.c @@ -18,8 +18,8 @@ int main(int argc, char** argv) { array_print(&x, "source"); array_print(&y, "cutted"); - array_remove_by_index(&x, -1); - array_remove_by_index(&y, -1); + array_remove(&x, -1); + array_remove(&y, -1); array_print(&x, "source (last removed)"); array_print(&y, "cutted (last removed)"); diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index 8e17da4..63e22d0 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -3,7 +3,7 @@ #include #include "../../../include/extra/vtype.h" -#include "../../../include/array.h" +#include "../../../include/extra/array.h" #include "../../include/random.h" #include "../../include/test.h" From a6a623bff6d193e9cff287aecb90934252bed9ce Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sat, 4 Jun 2022 22:17:26 +0300 Subject: [PATCH 18/63] Refactor string tests --- tests/src/string/main.c | 23 +++++++++++++++++++++++ tests/src/string/plug.h | 23 ----------------------- tests/src/string/trim.c | 10 +++++++--- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/tests/src/string/main.c b/tests/src/string/main.c index 8b90e66..141e0cc 100644 --- a/tests/src/string/main.c +++ b/tests/src/string/main.c @@ -3,6 +3,29 @@ #include "plug.h" +static void string_concat_random(vtype_string* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_concat(x, v); + free(v); +} + +static void string_replace_random(vtype_string* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_replace(x, x, v, -1); + + free(v); +} + static void string_print_compare(const vtype_string* s0, const vtype_string* s1) { int c = string_compare(s0, s1); char* m; diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h index d0fc750..472bbf1 100644 --- a/tests/src/string/plug.h +++ b/tests/src/string/plug.h @@ -68,26 +68,3 @@ static vtype_string string_random(unsigned int n) { return x; } - -static void string_concat_random(vtype_string* x, unsigned int n) { - char* v; - - if (random_boolean()) { - v = random_utf8_cstring(n); - } else v = random_ascii_cstring(n); - - string_concat(x, v); - free(v); -} - -static void string_replace_random(vtype_string* x, unsigned int n) { - char* v; - - if (random_boolean()) { - v = random_utf8_cstring(n); - } else v = random_ascii_cstring(n); - - string_replace(x, x, v, -1); - - free(v); -} diff --git a/tests/src/string/trim.c b/tests/src/string/trim.c index 4111e50..c5329d8 100644 --- a/tests/src/string/trim.c +++ b/tests/src/string/trim.c @@ -12,17 +12,21 @@ int main(int argc, char** argv) { x = string_random(12); string_align_center(&x, 30, 0); + string_info(&x); string_print(&x, 0); string_trim_spaces(&x); - string_print(&x, 0); - + string_info(&x); + string_print(&x, "trimmed"); + put_separator(); string_align_center(&x, 30, c); + string_info(&x); string_print(&x, 0); string_trim(&x, c); - string_print(&x, 0); + string_info(&x); + string_print(&x, "trimmed"); string_free(&x); From 8774804289eacc61f4bf5900efaec60730b8d688 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 5 Jun 2022 18:31:19 +0300 Subject: [PATCH 19/63] Update list tests --- tests/src/list/main.c | 21 +++++++++++---- tests/src/list/plug.h | 61 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/tests/src/list/main.c b/tests/src/list/main.c index 8fa9908..93809b5 100644 --- a/tests/src/list/main.c +++ b/tests/src/list/main.c @@ -3,11 +3,22 @@ #include "plug.h" -vtype_list* list_duplicate(const vtype_list* x) { return 0; } -int list_compare(const vtype_list* s0, const vtype_list* s1) { return random_int8(); } -void list_free(vtype_list* x) {} - - int main(int argc, char** argv) { test_init(argc, argv); + + vtype_list x; + + list_init(&x); + + for (int i = 0, n = 12 + random_boolean(); i < n; ++i) { + list_push_random(&x, 0); + } + list_sort(&x); + list_info(&x); + list_print(&x, "sorted"); + + list_reverse(&x); + list_print(&x, "reversed"); + + list_free(&x); } diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index 76e2ed4..6e7ddf9 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -1,12 +1,14 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../../include/list.h" +#include "../../../include/extra/list.h" #include "../../include/random.h" #include "../../include/test.h" #include "../../include/time.h" +#include "../../../src/__internal/vnode.h" + vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } @@ -21,3 +23,60 @@ int string_compare(const vtype_string* s0, const vtype_string* s1) { return rand int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + + +static void list_push_random(vtype_list* x, vtype_bool front) { + + if (!front) switch (random_uint8()%13) { + default: + case 0: list_push_back(x, random_boolean()); break; + case 1: list_push_back(x, random_uint8()); break; + case 2: list_push_back(x, random_uint16()); break; + case 3: list_push_back(x, random_uint32()); break; + case 4: list_push_back(x, random_uint64()); break; + case 5: list_push_back(x, random_int8()); break; + case 6: list_push_back(x, random_int16()); break; + case 7: list_push_back(x, random_int32()); break; + case 8: list_push_back(x, random_int64()); break; + case 9: list_push_back(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; + case 10: list_push_back(x, random_float()); break; + case 11: list_push_back(x, random_double()); break; + case 12: list_push_back(x, random_ldouble()); break; + } else switch (random_uint8()%13) { + default: + case 0: list_push_front(x, random_boolean()); break; + case 1: list_push_front(x, random_uint8()); break; + case 2: list_push_front(x, random_uint16()); break; + case 3: list_push_front(x, random_uint32()); break; + case 4: list_push_front(x, random_uint64()); break; + case 5: list_push_front(x, random_int8()); break; + case 6: list_push_front(x, random_int16()); break; + case 7: list_push_front(x, random_int32()); break; + case 8: list_push_front(x, random_int64()); break; + case 9: list_push_front(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; + case 10: list_push_front(x, random_float()); break; + case 11: list_push_front(x, random_double()); break; + case 12: list_push_front(x, random_ldouble()); break; + } +} + +static int list_node_print(void* v, ssize_t i, vtype t) { + printf("\e[32;1m%5ld: \e[m\e[31m%24s\e[m \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", i, + libcdsb_vtype_stringify(v, t), + libcdsb_vtype_name(t)); + return 0; +} + + +static void list_print(const vtype_list* x, const char* prefix) { + if (!prefix) puts("\e[36mList values:\e[m"); + else printf("\e[36mList %s values:\e[m\n", prefix); + + list_foreach(x, list_node_print); + put_separator(); +} + +static void list_info(const vtype_list* x) { + printf("List has \e[m\e[32m%lu\e[m\e[36m elements\e[m\n", list_size(x)); + put_separator(); +} From ab8aad910c2b5efcf09cd286dd355bd407023796 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 5 Jun 2022 19:28:24 +0300 Subject: [PATCH 20/63] Update list tests --- tests/src/list/main.c | 2 +- tests/src/list/plug.h | 2 +- tests/src/list/remove.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/src/list/remove.c diff --git a/tests/src/list/main.c b/tests/src/list/main.c index 93809b5..529a266 100644 --- a/tests/src/list/main.c +++ b/tests/src/list/main.c @@ -11,7 +11,7 @@ int main(int argc, char** argv) { list_init(&x); for (int i = 0, n = 12 + random_boolean(); i < n; ++i) { - list_push_random(&x, 0); + list_push_random(&x, random_boolean()); } list_sort(&x); list_info(&x); diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index 6e7ddf9..1da67d2 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -77,6 +77,6 @@ static void list_print(const vtype_list* x, const char* prefix) { } static void list_info(const vtype_list* x) { - printf("List has \e[m\e[32m%lu\e[m\e[36m elements\e[m\n", list_size(x)); + printf("\e[36mList has \e[m\e[32m%lu\e[m\e[36m elements\e[m\n", list_size(x)); put_separator(); } diff --git a/tests/src/list/remove.c b/tests/src/list/remove.c new file mode 100644 index 0000000..2f83e7e --- /dev/null +++ b/tests/src/list/remove.c @@ -0,0 +1,32 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); + + vtype_list x; + + list_init(&x); + + for (int i = 0, c = random_uint8()%16; i < 12; ++i) { + if (i == c) { + list_push_back(&x, 0); + } else list_push_random(&x, random_boolean()); + } + + list_info(&x); + list_print(&x, 0); + + for (int i = 0, n = list_countof(&x, 0); i < n; ++i) { + int index = list_indexof(&x, 0); + list_remove(&x, 0); + + printf("\e[36mRemove element with index \e[m\e[32;1m%d\e[m\e[36m from list\e[m\n", index); + } + put_separator(); + list_print(&x, "cleaned"); + + list_free(&x); +} From 96b06906f851e12a1b03a7565bb074fc6b1de1dc Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 5 Jun 2022 19:49:48 +0300 Subject: [PATCH 21/63] Update list tests --- tests/src/list/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/list/remove.c b/tests/src/list/remove.c index 2f83e7e..b3c7039 100644 --- a/tests/src/list/remove.c +++ b/tests/src/list/remove.c @@ -10,7 +10,7 @@ int main(int argc, char** argv) { list_init(&x); - for (int i = 0, c = random_uint8()%16; i < 12; ++i) { + for (int i = 0, c = random_uint8()%12; i < 12; ++i) { if (i == c) { list_push_back(&x, 0); } else list_push_random(&x, random_boolean()); From 566de8019e0f8c3b10fd64c21ceaf9591d877ca0 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 6 Jun 2022 22:07:35 +0300 Subject: [PATCH 22/63] Refactor test plugs --- tests/include/test.h | 5 ++++ tests/src/array/plug.h | 62 +++++++++++++++++------------------------ tests/src/list/plug.h | 11 ++------ tests/src/string/plug.h | 9 ++++-- tests/src/test.c | 44 +++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 48 deletions(-) diff --git a/tests/include/test.h b/tests/include/test.h index 4a6a4c5..2b689ce 100644 --- a/tests/include/test.h +++ b/tests/include/test.h @@ -2,11 +2,16 @@ /* Copyright © 2022 Gregory Lirent */ #include +#include "../../include/extra/vtype.h" #ifndef LIBCDSB_TESTS_TEST_H #define LIBCDSB_TESTS_TEST_H extern void put_separator(); +extern void print_container_values_prefix(const char* name, const char* prefix); +extern void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type); +extern void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb); + extern void test_init(int argc, char** argv); #endif /* LIBCDSB_TESTS_TEST_H */ diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index 63e22d0..afd1616 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -30,35 +30,23 @@ extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } -static void array_push_random_value(vtype_array* x) { - switch (random_uint8()%10) { - default: - case 0: array_push(x, random_boolean()); break; - case 1: array_push(x, random_uint8()); break; - case 2: array_push(x, random_uint16()); break; - case 3: array_push(x, random_uint32()); break; - case 4: array_push(x, random_uint64()); break; - case 5: array_push(x, random_int8()); break; - case 6: array_push(x, random_int16()); break; - case 7: array_push(x, random_int32()); break; - case 8: array_push(x, random_int64()); break; - case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; - } -} - -static void array_push_random_float(vtype_array* x) { - switch (random_uint8()%3) { - default: - case 0: array_push(x, random_float()); break; - case 1: array_push(x, random_double()); break; - case 2: array_push(x, random_ldouble()); break; - } -} - static void array_push_random(vtype_array* x) { - if (x->type < VTYPE_FLOAT) { - array_push_random_value(x); - } else array_push_random_float(x); + switch (random_uint8()%13) { + default: + case 0: array_push(x, random_boolean()); break; + case 1: array_push(x, random_uint8()); break; + case 2: array_push(x, random_uint16()); break; + case 3: array_push(x, random_uint32()); break; + case 4: array_push(x, random_uint64()); break; + case 5: array_push(x, random_int8()); break; + case 6: array_push(x, random_int16()); break; + case 7: array_push(x, random_int32()); break; + case 8: array_push(x, random_int64()); break; + case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; + case 10: array_push(x, random_float()); break; + case 11: array_push(x, random_double()); break; + case 12: array_push(x, random_ldouble()); break; + } } static void array_init_random(vtype_array* x) { @@ -92,18 +80,18 @@ static vtype_array array_random(unsigned int n) { return x; } -static void array_print(const vtype_array* x, const char* prefix) { - if (!prefix) puts("\e[36mArray values:\e[m"); - else printf("\e[36mArray %s values:\e[m\n", prefix); - for (int i = 0; i < x->size; ++i) { - printf("\e[32;1m%5d: \e[m\e[31m%24s\e[m\n", i, libcdsb_vtype_stringify(array_at(x, i), x->type)); - } - put_separator(); +static int array_value_print(void* v, ssize_t i, vtype t) { + print_container_value(&i, v, t, false); + return 0; } +static void array_print(const vtype_array* x, const char* prefix) { + print_container_values_prefix("Array", prefix); + array_foreach(x, array_value_print); + put_separator(); +} static void array_info(const vtype_array* x) { - printf("\e[36mArray initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", libcdsb_vtype_name(x->type)); - printf("Array has \e[m\e[32m%lu\e[m\e[36m elements (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", array_size(x), array_nmemb(x)); + print_container_info("Array", 0, &x->type, array_size(x), array_nmemb(x)); put_separator(); } diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index 1da67d2..b700edd 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -61,22 +61,17 @@ static void list_push_random(vtype_list* x, vtype_bool front) { } static int list_node_print(void* v, ssize_t i, vtype t) { - printf("\e[32;1m%5ld: \e[m\e[31m%24s\e[m \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", i, - libcdsb_vtype_stringify(v, t), - libcdsb_vtype_name(t)); + print_container_value(&i, v, t, 1); return 0; } - static void list_print(const vtype_list* x, const char* prefix) { - if (!prefix) puts("\e[36mList values:\e[m"); - else printf("\e[36mList %s values:\e[m\n", prefix); - + print_container_values_prefix("List", prefix); list_foreach(x, list_node_print); put_separator(); } static void list_info(const vtype_list* x) { - printf("\e[36mList has \e[m\e[32m%lu\e[m\e[36m elements\e[m\n", list_size(x)); + print_container_info("List", "nodes", 0, list_size(x), -1); put_separator(); } diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h index 472bbf1..e0b2ad5 100644 --- a/tests/src/string/plug.h +++ b/tests/src/string/plug.h @@ -49,12 +49,15 @@ static char* random_utf8_cstring(size_t size) { } static void string_info(vtype_string* x) { - printf("\e[36mString consists of \e[m\e[32m%lu\e[m\e[36m utf8 chars (\e[m\e[32m%lu bytes\e[m\e[36m)\e[m\n", string_size(x), string_nmemb(x)); + print_container_info("String", "utf8 chars", 0, string_size(x), string_nmemb(x)); + put_separator(); } static void string_print(const vtype_string* x, const char* prefix) { - if (!prefix) puts("\e[36mString content:\e[m\n"); - else printf("\e[36mString %s content:\e[m\n\n", prefix); + if (prefix) { + printf("\e[36m%s %s content:\e[m\n", "String", prefix); + } else printf("\e[36m%s content:\e[m\n", "String"); + printf("\e[33m\"%s\"\e[m\n", x->buffer); put_separator(); } diff --git a/tests/src/test.c b/tests/src/test.c index 7e24bc4..1d570cf 100644 --- a/tests/src/test.c +++ b/tests/src/test.c @@ -24,6 +24,50 @@ static void test_uload() { void put_separator() { puts("\e[37;2m=== === === === === === === ===\e[m"); } +void print_container_values_prefix(const char* name, const char* prefix) { + if (prefix) { + printf("\e[36m%s %s values:\e[m\n", name, prefix); + } else printf("\e[36m%s values:\e[m\n", name); +} + +void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type) { + if (index) { + printf("\e[32;1m%5ld: \e[m", *index); + } else fputs(" ", stdout); + + printf("\e[31m%24s\e[m", libcdsb_vtype_stringify(value, type)); + + if (print_type) { + printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m", libcdsb_vtype_name(type)); + } + + puts(""); +} + +void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb) { + if (!el_name) el_name = "elements"; + + if (type) { + printf("\e[36m%s initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", name, libcdsb_vtype_name(*type)); + } + + if (size >= 0 || nmemb >= 0) { + printf("\e[36m%s consists of \e[m", name); + } + + if (size >= 0) { + printf("\e[32m%ld\e[m \e[36m%s", size, el_name); + + if (nmemb >= 0) { + printf(" (\e[m\e[32m%ld bytes\e[m\e[36m)\e[m\n", nmemb); + } else puts("\e[m"); + + } else if (nmemb >= 0) { + printf("\e[32m%ld bytes\e[m\n", nmemb); + } +} + + void test_init(int argc, char** argv) { timer_init(&GLOBAL_TIMER); timer_start(&GLOBAL_TIMER); From aedc18c9fa8fbbef955c84b3ecb09bcbdaf4b75f Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 6 Jun 2022 22:08:10 +0300 Subject: [PATCH 23/63] Update set tests --- tests/src/set/main.c | 8 ++- tests/src/set/plug.h | 123 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 6 deletions(-) diff --git a/tests/src/set/main.c b/tests/src/set/main.c index 3ba1d93..61f3ef6 100644 --- a/tests/src/set/main.c +++ b/tests/src/set/main.c @@ -3,11 +3,9 @@ #include "plug.h" -vtype_set* vset_duplicate(const vtype_set* x) { return 0; } -int vset_compare(const vtype_set* s0, const vtype_set* s1) { return random_int8(); } -void vset_free(vtype_set* x) {} - - int main(int argc, char** argv) { test_init(argc, argv); + + vtype_set x = vset_random(32); + vset_free(&x); } diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h index 661c878..ab7abdb 100644 --- a/tests/src/set/plug.h +++ b/tests/src/set/plug.h @@ -1,7 +1,8 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../../include/set.h" +#include "../../../include/extra/set.h" +#include "../../../src/__internal/rbtree.h" #include "../../include/random.h" #include "../../include/test.h" @@ -21,3 +22,123 @@ int string_compare(const vtype_string* s0, const vtype_string* s1) { return rand int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } + + +static int vset_node_print(const void* v, vtype t) { + print_container_value(0, v, t, false); + return 0; +} + +static void vset_print(const vtype_set* x, const char* prefix) { + print_container_values_prefix("Set", prefix); + vset_foreach(x, vset_node_print); + put_separator(); +} + +static void vset_info(const vtype_set* x) { + print_container_info("Set", "nodes", &x->type, vset_size(x), -1); + put_separator(); +} + +static void rbtree_print(const rbnode_t* s, vtype t, const char* ind, bool br) { + if (!ind) { + ind = "\e[36m"; + br = 1; + } + + size_t n = strlen(ind); + char x[n + 10]; + + if (rbnode_is_empty(s)) return; + + + memcpy(x, ind, n); + memcpy(x + n, " \0 ", 9); + fputs(ind, stdout); + + if (br) { + fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); + } else { + fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); + memcpy(x + n, "│", 3); + x[n + 5] = ' '; + } + + + fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); + printf("%s\e[m\n", libcdsb_vtype_stringify(vnode_peek(&s->value, t), t)); + + rbtree_print(s->left, t, x, false); + rbtree_print(s->right, t, x, true); +} + +static void vset_push_random(vtype_set* x, double pause) { + var_t _; + vtype t; + + printf("\e[s\e[36mTry to insert into set (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); + + switch (random_uint8()%13) { + default: + case 0: _.b = random_boolean(); print_container_value(0, &_, t = VTYPE_BOOLEAN, 1); break; + case 1: _.u8 = random_uint8(); print_container_value(0, &_, t = VTYPE_UINT8, 1); break; + case 2: _.u16 = random_uint16(); print_container_value(0, &_, t = VTYPE_UINT16, 1); break; + case 3: _.u32 = random_uint32(); print_container_value(0, &_, t = VTYPE_UINT32, 1); break; + case 4: _.u64 = random_uint64(); print_container_value(0, &_, t = VTYPE_UINT64, 1); break; + case 5: _.u8 = random_int8(); print_container_value(0, &_, t = VTYPE_INT8, 1); break; + case 6: _.u16 = random_int16(); print_container_value(0, &_, t = VTYPE_INT16, 1); break; + case 7: _.u32 = random_int32(); print_container_value(0, &_, t = VTYPE_INT32, 1); break; + case 8: _.u64 = random_int64(); print_container_value(0, &_, t = VTYPE_INT64, 1); break; + case 9: _.f = random_float(); print_container_value(0, &_, t = VTYPE_FLOAT, 1); break; + case 10: _.d = random_double(); print_container_value(0, &_, t = VTYPE_DOUBLE, 1); break; + case 11: _.ld = random_ldouble(); print_container_value(0, &_, t = VTYPE_LDOUBLE, 1); break; + + case 12: if (sizeof(void*) == 8) { + _.u64 = random_uint64(); print_container_value(0, &_, t = VTYPE_POINTER, 1); break; + } else { + _.u32 = random_uint32(); print_container_value(0, &_, t = VTYPE_POINTER, 1); break; + } + } + + if (libcdsb_vset_insert(x, &_, t)) { + puts("\e[32;1mSUCCESS\e[m"); + } else { + puts("\e[31;1mFAILURE\e[m"); + } + put_separator(); + + rbtree_print(x->root, x->type, 0, 0); + put_separator(); + psleep(pause * 1000000); + fputs("\e[u\e[J", stdout); +} + +static vtype_set vset_random(unsigned int n) { + vtype_set x; + + switch (random_uint8()%12) { + default: + case 0: vset_init(&x, VTYPE_UINT8); break; + case 1: vset_init(&x, VTYPE_UINT16); break; + case 2: vset_init(&x, VTYPE_UINT32); break; + case 3: vset_init(&x, VTYPE_UINT64); break; + case 4: vset_init(&x, VTYPE_INT8); break; + case 5: vset_init(&x, VTYPE_INT16); break; + case 6: vset_init(&x, VTYPE_INT32); break; + case 7: vset_init(&x, VTYPE_INT64); break; + case 8: vset_init(&x, VTYPE_POINTER); break; + case 9: vset_init(&x, VTYPE_FLOAT); break; + case 10: vset_init(&x, VTYPE_DOUBLE); break; + case 11: vset_init(&x, VTYPE_LDOUBLE); break; + } + + if (n) { + while (--n) vset_push_random(&x, 0.95); + vset_push_random(&x, 1.95); + } + + vset_info(&x); + vset_print(&x, 0); + + return x; +} From 0fdca5e083caeb0a1a149cff1ae2a9fca67ca047 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 7 Jun 2022 21:24:17 +0300 Subject: [PATCH 24/63] Update tests --- tests/src/array/plug.h | 4 +-- tests/src/list/plug.h | 4 +-- tests/src/set/main.c | 4 ++- tests/src/set/plug.h | 77 +++++++++++++++++++++++++++++++++++------- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index afd1616..a54e99f 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -80,14 +80,14 @@ static vtype_array array_random(unsigned int n) { return x; } -static int array_value_print(void* v, ssize_t i, vtype t) { +static int array_value_print(void* v, ssize_t i, vtype t, void* _) { print_container_value(&i, v, t, false); return 0; } static void array_print(const vtype_array* x, const char* prefix) { print_container_values_prefix("Array", prefix); - array_foreach(x, array_value_print); + array_foreach(x, 0, array_value_print); put_separator(); } diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index b700edd..d3571ed 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -60,14 +60,14 @@ static void list_push_random(vtype_list* x, vtype_bool front) { } } -static int list_node_print(void* v, ssize_t i, vtype t) { +static int list_node_print(void* v, ssize_t i, vtype t, void* _) { print_container_value(&i, v, t, 1); return 0; } static void list_print(const vtype_list* x, const char* prefix) { print_container_values_prefix("List", prefix); - list_foreach(x, list_node_print); + list_foreach(x, 0, list_node_print); put_separator(); } diff --git a/tests/src/set/main.c b/tests/src/set/main.c index 61f3ef6..d6bd747 100644 --- a/tests/src/set/main.c +++ b/tests/src/set/main.c @@ -6,6 +6,8 @@ int main(int argc, char** argv) { test_init(argc, argv); - vtype_set x = vset_random(32); + vtype_set x = vset_random(36, 0.1); + + while(vset_remove_random(&x, 0.1)) {} vset_free(&x); } diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h index ab7abdb..68265d3 100644 --- a/tests/src/set/plug.h +++ b/tests/src/set/plug.h @@ -24,18 +24,18 @@ int list_compare (const vtype_list* s0, const vtype_list* s1) { return rand int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } -static int vset_node_print(const void* v, vtype t) { +static int vset_node_print(const void* v, vtype t, void* _) { print_container_value(0, v, t, false); return 0; } -static void vset_print(const vtype_set* x, const char* prefix) { +static void vset_print(const set_t* x, const char* prefix) { print_container_values_prefix("Set", prefix); - vset_foreach(x, vset_node_print); + vset_foreach(x, 0, vset_node_print); put_separator(); } -static void vset_info(const vtype_set* x) { +static void vset_info(const set_t* x) { print_container_info("Set", "nodes", &x->type, vset_size(x), -1); put_separator(); } @@ -51,7 +51,6 @@ static void rbtree_print(const rbnode_t* s, vtype t, const char* ind, bool br) { if (rbnode_is_empty(s)) return; - memcpy(x, ind, n); memcpy(x + n, " \0 ", 9); fputs(ind, stdout); @@ -72,7 +71,7 @@ static void rbtree_print(const rbnode_t* s, vtype t, const char* ind, bool br) { rbtree_print(s->right, t, x, true); } -static void vset_push_random(vtype_set* x, double pause) { +static void vset_push_random(set_t* x, double pause) { var_t _; vtype t; @@ -113,8 +112,63 @@ static void vset_push_random(vtype_set* x, double pause) { fputs("\e[u\e[J", stdout); } -static vtype_set vset_random(unsigned int n) { - vtype_set x; +static int vset_node_remove_random(const void* v, vtype t, void* data) { + struct { + size_t n; + set_t* set; + double pause; + } *d = data; + + if (!d->n--) { + print_container_value(0, v, t, 1); + + if (libcdsb_vset_find(0, d->set, v, t, 1)) { + puts("\e[32;1mSUCCESS\e[m"); + } else { + puts("\e[31;1mFAILURE\e[m"); + abort(); + } + + put_separator(); + + rbtree_print(d->set->root, d->set->type, 0, 0); + put_separator(); + psleep(d->pause * 1000000); + + return true; + } + return 0; +} + + +static bool vset_remove_random(set_t* x, double pause) { + struct { + size_t n; + set_t* set; + double pause; + } d; + d.n = vset_size(x); + d.set = x; + d.pause = pause; + + printf("\e[s\e[36mTry to remove value from set (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); + + if (d.n) { + d.n = random_uint32()%d.n; + } else goto end_; + + if (!vset_foreach(x, &d, vset_node_remove_random)) { + end_: + puts("\e[u\e[J\e[32;1mSet is empty\e[m"); + return false; + } + + fputs("\e[u\e[J", stdout); + return true; +} + +static set_t vset_random(unsigned int n, double pause) { + set_t x; switch (random_uint8()%12) { default: @@ -133,12 +187,9 @@ static vtype_set vset_random(unsigned int n) { } if (n) { - while (--n) vset_push_random(&x, 0.95); - vset_push_random(&x, 1.95); + while (--n) vset_push_random(&x, pause); + vset_push_random(&x, pause); } - vset_info(&x); - vset_print(&x, 0); - return x; } From 48ed3d3fab10863cac0311f17c24f70c88cc40af Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 8 Jun 2022 10:52:29 +0300 Subject: [PATCH 25/63] Update tests --- tests/src/array/plug.h | 2 +- tests/src/map/main.c | 10 +-- tests/src/map/plug.h | 199 ++++++++++++++++++++++++++++++++++++++++- tests/src/set/main.c | 2 +- tests/src/set/plug.h | 2 +- 5 files changed, 206 insertions(+), 9 deletions(-) diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index a54e99f..dd8ed86 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -85,7 +85,7 @@ static int array_value_print(void* v, ssize_t i, vtype t, void* _) { return 0; } -static void array_print(const vtype_array* x, const char* prefix) { +static void array_print(vtype_array* x, const char* prefix) { print_container_values_prefix("Array", prefix); array_foreach(x, 0, array_value_print); put_separator(); diff --git a/tests/src/map/main.c b/tests/src/map/main.c index a0638f1..f08ef64 100644 --- a/tests/src/map/main.c +++ b/tests/src/map/main.c @@ -3,11 +3,11 @@ #include "plug.h" -vtype_map* map_duplicate(const vtype_map* x) { return 0; } -int map_compare(const vtype_map* s0, const vtype_map* s1) { return random_int8(); } -void map_free(vtype_map* x) {} - - int main(int argc, char** argv) { test_init(argc, argv); + + map_t x = map_random(36, 0.1); + + while(map_remove_random(&x, 0.1)) {} + map_free(&x); } diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h index 093107c..2ea8ee7 100644 --- a/tests/src/map/plug.h +++ b/tests/src/map/plug.h @@ -1,7 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../../include/map.h" +#include "../../../src/map/include.h" #include "../../include/random.h" #include "../../include/test.h" @@ -21,3 +21,200 @@ int string_compare(const vtype_string* s0, const vtype_string* s1) { return rand int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + + +static int map_node_print(const void* k, vtype kt, void* v, vtype vt, void* _) { + printf(" \e[31m%24s\e[m \e[36m:\e[m", vtype_stringify(k, kt)); + printf(" \e[31m%s\e[m", vtype_stringify(v, vt)); + printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(vt)); + return 0; +} + +static void map_print(map_t* x, const char* prefix) { + print_container_values_prefix("Map", prefix); + map_foreach(x, 0, map_node_print); + put_separator(); +} + +static void map_info(const map_t* x) { + print_container_info("Map", "nodes", &x->type, map_size(x), -1); + put_separator(); +} + +static void map_rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br) { + if (!ind) { + ind = "\e[36m"; + br = 1; + } + + size_t n = strlen(ind); + char x[n + 10]; + + if (mnode_is_empty(s)) return; + + memcpy(x, ind, n); + memcpy(x + n, " \0 ", 9); + fputs(ind, stdout); + + if (br) { + fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); + } else { + fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); + memcpy(x + n, "│", 3); + x[n + 5] = ' '; + } + + fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); + printf("%s\e[m \e[36m:\e[m ", vnode_stringify(&s->key, t)); + printf("\e[31m%s\e[m", vnode_stringify(&s->value, s->type)); + printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(s->type)); + + map_rbtree_print(s->left, t, x, false); + map_rbtree_print(s->right, t, x, true); +} + +static void map_push_random(map_t* x, double pause) { + var_t _[2]; + vtype t[2]; + + printf("\e[s\e[36mUpdate value in map (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", vtype_name(x->type)); + + switch (random_uint8()%13) { + default: + case 0: _[0].b = random_boolean(); print_container_value(0, _, t[0] = VTYPE_BOOLEAN, 1); break; + case 1: _[0].u8 = random_uint8(); print_container_value(0, _, t[0] = VTYPE_UINT8, 1); break; + case 2: _[0].u16 = random_uint16(); print_container_value(0, _, t[0] = VTYPE_UINT16, 1); break; + case 3: _[0].u32 = random_uint32(); print_container_value(0, _, t[0] = VTYPE_UINT32, 1); break; + case 4: _[0].u64 = random_uint64(); print_container_value(0, _, t[0] = VTYPE_UINT64, 1); break; + case 5: _[0].u8 = random_int8(); print_container_value(0, _, t[0] = VTYPE_INT8, 1); break; + case 6: _[0].u16 = random_int16(); print_container_value(0, _, t[0] = VTYPE_INT16, 1); break; + case 7: _[0].u32 = random_int32(); print_container_value(0, _, t[0] = VTYPE_INT32, 1); break; + case 8: _[0].u64 = random_int64(); print_container_value(0, _, t[0] = VTYPE_INT64, 1); break; + case 9: _[0].f = random_float(); print_container_value(0, _, t[0] = VTYPE_FLOAT, 1); break; + case 10: _[0].d = random_double(); print_container_value(0, _, t[0] = VTYPE_DOUBLE, 1); break; + case 11: _[0].ld = random_ldouble(); print_container_value(0, _, t[0] = VTYPE_LDOUBLE, 1); break; + + case 12: if (sizeof(void*) == 8) { + _[0].u64 = random_uint64(); print_container_value(0, _, t[0] = VTYPE_POINTER, 1); break; + } else { + _[0].u32 = random_uint32(); print_container_value(0, _, t[0] = VTYPE_POINTER, 1); break; + } + } + + switch (random_uint8()%13) { + default: + case 0: _[1].b = random_boolean(); print_container_value(0, _+1, t[1] = VTYPE_BOOLEAN, 1); break; + case 1: _[1].u8 = random_uint8(); print_container_value(0, _+1, t[1] = VTYPE_UINT8, 1); break; + case 2: _[1].u16 = random_uint16(); print_container_value(0, _+1, t[1] = VTYPE_UINT16, 1); break; + case 3: _[1].u32 = random_uint32(); print_container_value(0, _+1, t[1] = VTYPE_UINT32, 1); break; + case 4: _[1].u64 = random_uint64(); print_container_value(0, _+1, t[1] = VTYPE_UINT64, 1); break; + case 5: _[1].u8 = random_int8(); print_container_value(0, _+1, t[1] = VTYPE_INT8, 1); break; + case 6: _[1].u16 = random_int16(); print_container_value(0, _+1, t[1] = VTYPE_INT16, 1); break; + case 7: _[1].u32 = random_int32(); print_container_value(0, _+1, t[1] = VTYPE_INT32, 1); break; + case 8: _[1].u64 = random_int64(); print_container_value(0, _+1, t[1] = VTYPE_INT64, 1); break; + case 9: _[1].f = random_float(); print_container_value(0, _+1, t[1] = VTYPE_FLOAT, 1); break; + case 10: _[1].d = random_double(); print_container_value(0, _+1, t[1] = VTYPE_DOUBLE, 1); break; + case 11: _[1].ld = random_ldouble(); print_container_value(0, _+1, t[1] = VTYPE_LDOUBLE, 1); break; + + case 12: if (sizeof(void*) == 8) { + _[1].u64 = random_uint64(); print_container_value(0, _+1, t[1] = VTYPE_POINTER, 1); break; + } else { + _[1].u32 = random_uint32(); print_container_value(0, _+1, t[1] = VTYPE_POINTER, 1); break; + } + } + + if (libcdsb_map_update(x, _, t[0], _+1, t[1])) { + puts("\e[33;1mCHANGE\e[m"); + } else { + puts("\e[32;1mINSERT\e[m"); + } + + put_separator(); + + map_rbtree_print(x->root, x->type, 0, 0); + put_separator(); + psleep(pause * 1000000); + fputs("\e[u\e[J", stdout); +} + +static int map_node_remove_random(const void* k, vtype kt, void* v, vtype vt, void* data) { + struct { + size_t n; + map_t* set; + double pause; + } *d = data; + + if (!d->n--) { + map_node_print(k, kt, v, vt, 0); + + if (libcdsb_map_find(0, d->set, k, kt, 1)) { + puts("\e[32;1mSUCCESS\e[m"); + } else { + puts("\e[s\e[31;1mFAILURE\e[m"); + abort(); + } + + put_separator(); + + map_rbtree_print(d->set->root, d->set->type, 0, 0); + put_separator(); + psleep(d->pause * 1000000); + + return true; + } + return 0; +} + + +static bool map_remove_random(map_t* x, double pause) { + struct { + size_t n; + map_t* set; + double pause; + } d; + d.n = map_size(x); + d.set = x; + d.pause = pause; + + printf("\e[s\e[36mTry to remove value from map (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); + + if (d.n) { + d.n = random_uint32()%d.n; + } else goto end_; + + if (!map_foreach(x, &d, map_node_remove_random)) { + end_: + puts("\e[u\e[J\e[32;1mMap is empty\e[m"); + return false; + } + + fputs("\e[u\e[J", stdout); + return true; +} + +static map_t map_random(unsigned int n, double pause) { + map_t x; + + switch (random_uint8()%12) { + default: + case 0: map_init(&x, VTYPE_UINT8); break; + case 1: map_init(&x, VTYPE_UINT16); break; + case 2: map_init(&x, VTYPE_UINT32); break; + case 3: map_init(&x, VTYPE_UINT64); break; + case 4: map_init(&x, VTYPE_INT8); break; + case 5: map_init(&x, VTYPE_INT16); break; + case 6: map_init(&x, VTYPE_INT32); break; + case 7: map_init(&x, VTYPE_INT64); break; + case 8: map_init(&x, VTYPE_POINTER); break; + case 9: map_init(&x, VTYPE_FLOAT); break; + case 10: map_init(&x, VTYPE_DOUBLE); break; + case 11: map_init(&x, VTYPE_LDOUBLE); break; + } + + if (n) { + while (--n) map_push_random(&x, pause); + map_push_random(&x, pause); + } + + return x; +} diff --git a/tests/src/set/main.c b/tests/src/set/main.c index d6bd747..be56d43 100644 --- a/tests/src/set/main.c +++ b/tests/src/set/main.c @@ -6,7 +6,7 @@ int main(int argc, char** argv) { test_init(argc, argv); - vtype_set x = vset_random(36, 0.1); + set_t x = vset_random(36, 0.1); while(vset_remove_random(&x, 0.1)) {} vset_free(&x); diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h index 68265d3..fd4e092 100644 --- a/tests/src/set/plug.h +++ b/tests/src/set/plug.h @@ -29,7 +29,7 @@ static int vset_node_print(const void* v, vtype t, void* _) { return 0; } -static void vset_print(const set_t* x, const char* prefix) { +static void vset_print(set_t* x, const char* prefix) { print_container_values_prefix("Set", prefix); vset_foreach(x, 0, vset_node_print); put_separator(); From c6cc57575999a4095437f1cdf7f8bc81a0b50e84 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 9 Jun 2022 11:39:19 +0300 Subject: [PATCH 26/63] Update tests base --- tests/Makefile | 17 ++++++++++ tests/include/random.h | 9 +++++ tests/include/test.h | 8 ++--- tests/src/random.c | 24 ++++++++++++- tests/src/test.c | 77 ++++++++++++++++++++++++++---------------- 5 files changed, 101 insertions(+), 34 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index d810ace..f9a6205 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -35,6 +35,12 @@ OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix . OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP)) OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET)) +OBJECTS_STRING := $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-)) +OBJECTS_ARRAY := $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-)) +OBJECTS_LIST := $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-)) +OBJECTS_MAP := $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-)) +OBJECTS_SET := $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-)) + ######################################################################################################################## tests: modules @@ -50,6 +56,17 @@ tests: $(addprefix $(BUILD_PATH)/set-,$(notdir $(basename $(wildcard ./src/set/* $(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/array-%.o: ./src/array/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/string-%.o: ./src/string/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/list-%.o: ./src/list/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/map-%.o: ./src/map/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/set-%.o: ./src/set/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) + $(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/string-%: ./src/string/%.c $(OBJECTS_STRING) | $(BUILD_PATH)/ diff --git a/tests/include/random.h b/tests/include/random.h index 69b2b07..517c27b 100644 --- a/tests/include/random.h +++ b/tests/include/random.h @@ -2,10 +2,16 @@ /* Copyright © 2022 Gregory Lirent */ #include "../../include/vtype.h" +#include "../../src/__internal/vnode.h" #ifndef LIBCDSB_TESTS_RANDOM_H #define LIBCDSB_TESTS_RANDOM_H +typedef struct { + var_t value[1]; + vtype type; +} value_t; + extern int random_init(int argc, char** argv); extern vtype_bool random_boolean(); @@ -25,4 +31,7 @@ extern vtype_int64 random_int64(); extern char random_ascii_char(); extern unsigned int random_unicode_symbol(); + +extern value_t random_value(); + #endif /* LIBCDSB_TESTS_RANDOM_H */ diff --git a/tests/include/test.h b/tests/include/test.h index 2b689ce..ac3d5e9 100644 --- a/tests/include/test.h +++ b/tests/include/test.h @@ -7,10 +7,10 @@ #ifndef LIBCDSB_TESTS_TEST_H #define LIBCDSB_TESTS_TEST_H -extern void put_separator(); -extern void print_container_values_prefix(const char* name, const char* prefix); -extern void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type); -extern void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb); +extern void put_separator(unsigned int hpos); +extern void print_container_values_prefix(const char* name, const char* prefix, unsigned int hpos); +extern void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type, unsigned int hpos); +extern void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb, unsigned int hpos); extern void test_init(int argc, char** argv); diff --git a/tests/src/random.c b/tests/src/random.c index c77e74a..337932c 100644 --- a/tests/src/random.c +++ b/tests/src/random.c @@ -11,7 +11,7 @@ static void init(unsigned int seed) { if (!seed) seed = time(0); printf("\e[36mRandom module initialized with seed: \e[m\e[32m%u\n\e[m", seed); - put_separator(); + put_separator(0); srand(seed); } @@ -109,3 +109,25 @@ unsigned int random_unicode_symbol() { case 19: return (random_uint16()%0x03d8) + 0x01f300; } } + +value_t random_value() { + value_t v; + switch (random_uint8()%13) { + default: + case 0: v.value[0].b = random_boolean(); v.type = VTYPE_BOOLEAN; break; + case 1: v.value[0].u8 = random_uint8 (); v.type = VTYPE_UINT8; break; + case 2: v.value[0].u16 = random_uint16 (); v.type = VTYPE_UINT16; break; + case 3: v.value[0].u32 = random_uint32 (); v.type = VTYPE_UINT32; break; + case 4: v.value[0].u64 = random_uint64 (); v.type = VTYPE_UINT64; break; + case 5: v.value[0].u8 = random_int8 (); v.type = VTYPE_INT8; break; + case 6: v.value[0].u16 = random_int16 (); v.type = VTYPE_INT16; break; + case 7: v.value[0].u32 = random_int32 (); v.type = VTYPE_INT32; break; + case 8: v.value[0].u64 = random_int64 (); v.type = VTYPE_INT64; break; + case 9: v.value[0].f = random_float (); v.type = VTYPE_FLOAT; break; + case 10: v.value[0].d = random_double (); v.type = VTYPE_DOUBLE; break; + case 11: v.value[0].ld = random_ldouble(); v.type = VTYPE_LDOUBLE; break; + case 12: v.value[0].ptr = (void*)(uintptr_t)random_uint64(); v.type = VTYPE_POINTER; break; + } + + return v; +} diff --git a/tests/src/test.c b/tests/src/test.c index 1d570cf..32e11e4 100644 --- a/tests/src/test.c +++ b/tests/src/test.c @@ -1,6 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include #include #include "../include/test.h" #include "../include/time.h" @@ -15,25 +16,59 @@ static void test_uload() { if (TEST_NAME) { timer_stop(&GLOBAL_TIMER); puts(""); - put_separator(); + put_separator(0); printf("\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is end.\nExecusion time: \e[m\e[32m%.6Lf sec\e[m\n", TEST_NAME, timer_value(&GLOBAL_TIMER)); - put_separator(); + put_separator(0); timer_free(&GLOBAL_TIMER); } } -void put_separator() { puts("\e[37;2m=== === === === === === === ===\e[m"); } +void test_init(int argc, char** argv) { + timer_init(&GLOBAL_TIMER); + timer_start(&GLOBAL_TIMER); -void print_container_values_prefix(const char* name, const char* prefix) { - if (prefix) { - printf("\e[36m%s %s values:\e[m\n", name, prefix); - } else printf("\e[36m%s values:\e[m\n", name); + TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0]; + + put_separator(0); + printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME); + put_separator(0); + + random_init(argc, argv); + + puts(""); } -void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type) { +void hp_printf(unsigned int hpos, const char* format, ...) { + va_list args; + + va_start(args, format); + vprintf(format, args); + + printf("\e[%dG", hpos+1); + + vprintf(format, args); + va_end(args); +} + + +void put_separator(unsigned int hpos) { + printf("\e[%dG\e[37;2m=== === === === === === === ===\e[m\n", hpos+1); +} + +void print_container_values_prefix(const char* name, const char* prefix, unsigned int hpos) { + if (prefix) { + printf("\e[%dG\e[36m%s %s values:\e[m\n", hpos+1, name, prefix); + } else { + printf("\e[%dG\e[36m%s values:\e[m\n", hpos+1, name); + } +} + +void print_container_value(const ssize_t* index, const void* value, const vtype type, _Bool print_type, unsigned int hpos) { if (index) { - printf("\e[32;1m%5ld: \e[m", *index); - } else fputs(" ", stdout); + printf("\e[%dG\e[32;1m%5ld: \e[m", hpos+1, *index); + } else { + printf("\e[%dG ", hpos+1); + } printf("\e[31m%24s\e[m", libcdsb_vtype_stringify(value, type)); @@ -44,15 +79,15 @@ void print_container_value(const ssize_t* index, const void* value, const vtype puts(""); } -void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb) { +void print_container_info(const char* name, const char* el_name, const vtype* type, ssize_t size, ssize_t nmemb, unsigned int hpos) { if (!el_name) el_name = "elements"; if (type) { - printf("\e[36m%s initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", name, libcdsb_vtype_name(*type)); + printf("\e[%dG\e[36m%s initialized with type `\e[m\e[32;1m%s\e[m\e[36m`\n", hpos+1, name, libcdsb_vtype_name(*type)); } if (size >= 0 || nmemb >= 0) { - printf("\e[36m%s consists of \e[m", name); + printf("\e[%dG\e[36m%s consists of \e[m", hpos+1, name); } if (size >= 0) { @@ -66,19 +101,3 @@ void print_container_info(const char* name, const char* el_name, const vtype* ty printf("\e[32m%ld bytes\e[m\n", nmemb); } } - - -void test_init(int argc, char** argv) { - timer_init(&GLOBAL_TIMER); - timer_start(&GLOBAL_TIMER); - - TEST_NAME = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0]; - - put_separator(); - printf("\e[H\e[J\e[36mTest \"\e[m\e[32;1m%s\e[m\e[36m\" is loaded\e[m\n", TEST_NAME); - put_separator(); - - random_init(argc, argv); - - puts(""); -} From 760c04fb498850a1e25666d8c9c70d287dc67354 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 9 Jun 2022 11:39:37 +0300 Subject: [PATCH 27/63] Update list tests --- tests/src/list/main.c | 25 +++-- tests/src/list/plug.h | 74 +++----------- tests/src/list/remove.c | 32 ------ tests/src/list/src/io.c | 188 ++++++++++++++++++++++++++++++++++++ tests/src/list/src/plug.c | 20 ++++ tests/src/list/src/random.c | 83 ++++++++++++++++ 6 files changed, 314 insertions(+), 108 deletions(-) delete mode 100644 tests/src/list/remove.c create mode 100644 tests/src/list/src/io.c create mode 100644 tests/src/list/src/plug.c create mode 100644 tests/src/list/src/random.c diff --git a/tests/src/list/main.c b/tests/src/list/main.c index 529a266..cfee210 100644 --- a/tests/src/list/main.c +++ b/tests/src/list/main.c @@ -6,19 +6,18 @@ int main(int argc, char** argv) { test_init(argc, argv); - vtype_list x; - - list_init(&x); - - for (int i = 0, n = 12 + random_boolean(); i < n; ++i) { - list_push_random(&x, random_boolean()); - } - list_sort(&x); - list_info(&x); - list_print(&x, "sorted"); - - list_reverse(&x); - list_print(&x, "reversed"); + list_t x = { .first = 0, .last = 0 }; + list_t y = { .first = 0, .last = 0 }; list_free(&x); + + visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%5) + 12); + + visual_extend(&x, &y); + + visual_sort2(&x, &y); + visual_remove2(&x, &y); + + list_free(&y); + list_free(&y); } diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index d3571ed..7362e9d 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -9,69 +9,17 @@ #include "../../../src/__internal/vnode.h" -vtype_string* string_duplicate(const vtype_string* x) { return 0; } -vtype_array* array_duplicate (const vtype_array* x) { return 0; } -vtype_map* map_duplicate (const vtype_map* x) { return 0; } -vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +extern void list_print(list_t* x, const char* prefix, unsigned int hpos); +extern void list_info (list_t* x, unsigned int hpos); -void string_free(vtype_string* x) {} -void array_free (vtype_array* x) {} -void map_free (vtype_map* x) {} -void vset_free (vtype_set* x) {} +extern void list_push_random(list_t* x, _Bool silent, unsigned int hpos); +extern void list_remove_random(list_t* x, _Bool silent, unsigned int hpos); -int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } -int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } -int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } -int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +extern void visual_push(list_t* x, size_t n); +extern void visual_sort(list_t* x); +extern void visual_remove(list_t* x); - -static void list_push_random(vtype_list* x, vtype_bool front) { - - if (!front) switch (random_uint8()%13) { - default: - case 0: list_push_back(x, random_boolean()); break; - case 1: list_push_back(x, random_uint8()); break; - case 2: list_push_back(x, random_uint16()); break; - case 3: list_push_back(x, random_uint32()); break; - case 4: list_push_back(x, random_uint64()); break; - case 5: list_push_back(x, random_int8()); break; - case 6: list_push_back(x, random_int16()); break; - case 7: list_push_back(x, random_int32()); break; - case 8: list_push_back(x, random_int64()); break; - case 9: list_push_back(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; - case 10: list_push_back(x, random_float()); break; - case 11: list_push_back(x, random_double()); break; - case 12: list_push_back(x, random_ldouble()); break; - } else switch (random_uint8()%13) { - default: - case 0: list_push_front(x, random_boolean()); break; - case 1: list_push_front(x, random_uint8()); break; - case 2: list_push_front(x, random_uint16()); break; - case 3: list_push_front(x, random_uint32()); break; - case 4: list_push_front(x, random_uint64()); break; - case 5: list_push_front(x, random_int8()); break; - case 6: list_push_front(x, random_int16()); break; - case 7: list_push_front(x, random_int32()); break; - case 8: list_push_front(x, random_int64()); break; - case 9: list_push_front(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; - case 10: list_push_front(x, random_float()); break; - case 11: list_push_front(x, random_double()); break; - case 12: list_push_front(x, random_ldouble()); break; - } -} - -static int list_node_print(void* v, ssize_t i, vtype t, void* _) { - print_container_value(&i, v, t, 1); - return 0; -} - -static void list_print(const vtype_list* x, const char* prefix) { - print_container_values_prefix("List", prefix); - list_foreach(x, 0, list_node_print); - put_separator(); -} - -static void list_info(const vtype_list* x) { - print_container_info("List", "nodes", 0, list_size(x), -1); - put_separator(); -} +extern void visual_push2(list_t* x0, size_t n0, list_t* x1, size_t n1); +extern void visual_remove2(list_t* x0, list_t* x1); +extern void visual_sort2(list_t* x0, list_t* x1); +extern void visual_extend(list_t* x, list_t* s); diff --git a/tests/src/list/remove.c b/tests/src/list/remove.c deleted file mode 100644 index b3c7039..0000000 --- a/tests/src/list/remove.c +++ /dev/null @@ -1,32 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "plug.h" - -int main(int argc, char** argv) { - test_init(argc, argv); - - vtype_list x; - - list_init(&x); - - for (int i = 0, c = random_uint8()%12; i < 12; ++i) { - if (i == c) { - list_push_back(&x, 0); - } else list_push_random(&x, random_boolean()); - } - - list_info(&x); - list_print(&x, 0); - - for (int i = 0, n = list_countof(&x, 0); i < n; ++i) { - int index = list_indexof(&x, 0); - list_remove(&x, 0); - - printf("\e[36mRemove element with index \e[m\e[32;1m%d\e[m\e[36m from list\e[m\n", index); - } - put_separator(); - list_print(&x, "cleaned"); - - list_free(&x); -} diff --git a/tests/src/list/src/io.c b/tests/src/list/src/io.c new file mode 100644 index 0000000..5ed0ed0 --- /dev/null +++ b/tests/src/list/src/io.c @@ -0,0 +1,188 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int list_node_print(void* v, ssize_t i, vtype t, void* _) { + print_container_value(&i, v, t, 1, *(unsigned int*)_); + return 0; +} + +void list_print(list_t* x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("List", prefix, hpos); + list_foreach(x, &hpos, list_node_print); +} + +void list_info(list_t* x, unsigned int hpos) { + print_container_info("List", "nodes", 0, list_size(x), -1, hpos); +} + + +void visual_push(list_t* x, size_t n) { + for (int i = 0; i < n; ++i) { + fputs("\e[s", stdout); + + list_push_random(x, 0, 0); + + list_info(x, 0); + list_print(x, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} + +void visual_sort(list_t* x) { + puts("\e[s\e[36mTry to sort list values:\e[m\n\n"); + put_separator(0); + list_sort(x); + list_info(x, 0); + list_print(x, "sorted", 0); + psleep(900000); + fputs("\e[u\e[J", stdout); + + puts("\e[s\e[36mTry to reverse list values:\e[m\n\n"); + put_separator(0); + list_reverse(x); + list_info(x, 0); + list_print(x, "reversed", 0); + psleep(900000); + fputs("\e[u\e[J", stdout); +} + +void visual_remove(list_t* x) { + while (x->first) { + fputs("\e[s", stdout); + list_remove_random(x, 0, 0); + list_info(x, 0); + list_print(x, 0, 0); + + psleep(100000); + if (!0) fputs("\e[u\e[J", stdout); + } +} + +void visual_push2(list_t* x0, size_t n0, list_t* x1, size_t n1) { + + for (;n0 || n1;) { + fputs("\e[s", stdout); + if (n0) { + list_push_random(x0, 0, 0); + --n0; + } else { + puts("\n\n"); + put_separator(0); + } + + fputs("\e[u\e[s", stdout); + + if (n1) { + list_push_random(x1, 0, 60); + --n1; + } else { + puts("\n\n"); + put_separator(60); + } + + list_info(x0, 0); + list_print(x0, 0, 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(x1, 60); + list_print(x1, 0, 60); + psleep(100000); + + fputs("\e[u\e[J", stdout); + } +} + +void visual_remove2(list_t* x0, list_t* x1) { + + for (;x0->first || x1->first;) { + fputs("\e[s", stdout); + + if (x0->first) { + list_remove_random(x0, 0, 0); + } else { + puts("\n\n"); + put_separator(0); + } + + fputs("\e[u\e[s", stdout); + + if (x1->first) { + list_remove_random(x1, 0, 60); + } else { + puts("\n\n"); + put_separator(60); + } + + list_info(x0, 0); + list_print(x0, 0, 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(x1, 60); + list_print(x1, 0, 60); + psleep(100000); + + fputs("\e[u\e[J", stdout); + } +} + + +void visual_sort2(list_t* x0, list_t* x1) { + printf("\e[s\e[36m%-60s%s\e[m\n\n","Try to sort list values:", "Try to sort list values:"); + printf("\e[32;1m%-60s%s\e[m\n", "SUCCESS", "SUCCESS"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + list_sort(x0); + list_sort(x1); + + list_info(x0, 0); + list_print(x0, "sorted", 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(x1, 60); + list_print(x1, "sorted", 60); + + psleep(900000); + fputs("\e[u\e[J", stdout); + + printf("\e[s\e[36m%-60s%s\e[m\n\n","Try to reverse list values:", "Try to reverse list values:"); + printf("\e[32;1m%-60s%s\e[m\n", "SUCCESS", "SUCCESS"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + list_reverse(x0); + list_reverse(x1); + + list_info(x0, 0); + list_print(x0, "reversed", 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(x1, 60); + list_print(x1, "reversed", 60); + + psleep(900000); + fputs("\e[u\e[J", stdout); +} + +void visual_extend(list_t* x, list_t* s) { + + puts("\e[s\e[36mTry to extend list:\e[m\n\n"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + list_info(x, 0); + list_print(x, "(dest)", 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(s, 60); + list_print(s, "(src)", 60); + + psleep(900000); + fputs("\e[u\e[s\e[2E\e[32;1mSUCCESS\e[m\e[J", stdout); + + list_extend(x, s); + + puts(""); + put_separator(0); + + list_info(x, 0); + list_print(x, "(dest)", 0); + psleep(900000); + fputs("\e[u\e[J", stdout); +} diff --git a/tests/src/list/src/plug.c b/tests/src/list/src/plug.c new file mode 100644 index 0000000..eff34f8 --- /dev/null +++ b/tests/src/list/src/plug.c @@ -0,0 +1,20 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../../src/__internal/include.h" +#include "../../../include/random.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/list/src/random.c b/tests/src/list/src/random.c new file mode 100644 index 0000000..9d74048 --- /dev/null +++ b/tests/src/list/src/random.c @@ -0,0 +1,83 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int remove_callback(void* v, ssize_t i, vtype t, void* _) { + struct { list_t* x; _Bool s; unsigned int p; } *x = _; + if (!x->s) { + print_container_value(0, v, t, 1, x->p); + } + + if (libcdsb_list_find(x->x, v, t, 0, 0, 1, 1)) { + return -2; + } + + return 0; +} + + +void list_push_random(list_t* x, _Bool silent, unsigned int hpos) { + + value_t v = random_value(); + _Bool r; + + if (random_boolean()) { + if (!silent) { + printf("\e[%dG\e[36mTry to push value to back of the list:\e[m\n", hpos+1); + } + r = libcdsb_list_update(x, -1, v.value, v.type, 1); + } else if (random_boolean()) { + if (!silent) { + printf("\e[%dG\e[36mTry to push value to front of the list:\e[m\n", hpos+1); + } + r = libcdsb_list_update(x, -1, v.value, v.type, 1); + } else { + ssize_t i = list_size(x); + i = random_uint64()% (i ? i : 1); + if (random_boolean()) i = ~i + 1; + + if (!silent) { + printf("\e[%dG\e[36mTry to change value with index \e[32;1m%ld\e[36m into list:\e[m\n", hpos+1, i); + } + + r = libcdsb_list_update(x, i, v.value, v.type, 0); + } + + if (!silent) { + print_container_value(0, v.value, v.type, 1, hpos); + printf("\e[%dG%s\n", hpos+1, r ? "\e[32;1mSUCCESS\e[m" : "\e[31;1mFAILURE\e[m"); + put_separator(hpos); + } +} + +void list_remove_random(list_t* x, _Bool silent, unsigned int hpos) { + + size_t n = list_size(x); + ssize_t i = random_uint64()%n; + + if (random_boolean()) i = ~i + 1; + + if (random_boolean()) { + if (!silent) { + printf("\e[%dG\e[36mTry to remove value from list by index:\e[m\n", hpos+1); + print_container_value(0, &i, (sizeof(ssize_t) == 8) ? VTYPE_INT64 : VTYPE_INT32, 0, hpos); + } + switch (list_remove_by_index(x, i)) { + case 0: if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); break; + default: if (!silent) printf("\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; + } + } else { + struct { list_t* x; _Bool s; unsigned int p; } v = { .x = x, .s = silent, .p = hpos }; + + if (!silent) printf("\e[%dG\e[36mTry to remove value from list:\e[m\n", hpos+1); + + switch (libcdsb_list_get(x, i, &v, remove_callback, 0)) { + case 0: if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); break; + case 2: if (!silent) printf("\n\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; + default: if (!silent) printf("\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; + } + } + + put_separator(hpos); +} From f804d4277cf633d90e123b8b107ece285d46c950 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 9 Jun 2022 22:02:12 +0300 Subject: [PATCH 28/63] Update list tests --- tests/src/list/main.c | 3 --- tests/src/list/src/random.c | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/src/list/main.c b/tests/src/list/main.c index cfee210..9cdcbcd 100644 --- a/tests/src/list/main.c +++ b/tests/src/list/main.c @@ -9,10 +9,7 @@ int main(int argc, char** argv) { list_t x = { .first = 0, .last = 0 }; list_t y = { .first = 0, .last = 0 }; - list_free(&x); - visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%5) + 12); - visual_extend(&x, &y); visual_sort2(&x, &y); diff --git a/tests/src/list/src/random.c b/tests/src/list/src/random.c index 9d74048..2552978 100644 --- a/tests/src/list/src/random.c +++ b/tests/src/list/src/random.c @@ -38,7 +38,7 @@ void list_push_random(list_t* x, _Bool silent, unsigned int hpos) { if (random_boolean()) i = ~i + 1; if (!silent) { - printf("\e[%dG\e[36mTry to change value with index \e[32;1m%ld\e[36m into list:\e[m\n", hpos+1, i); + printf("\e[%dG\e[36mTry to change value with index \e[32;1m%ld\e[36m in the list:\e[m\n", hpos+1, i); } r = libcdsb_list_update(x, i, v.value, v.type, 0); @@ -74,7 +74,6 @@ void list_remove_random(list_t* x, _Bool silent, unsigned int hpos) { switch (libcdsb_list_get(x, i, &v, remove_callback, 0)) { case 0: if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); break; - case 2: if (!silent) printf("\n\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; default: if (!silent) printf("\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; } } From 26a33062e7ed0c504846fb3043ba8b3703732510 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 9 Jun 2022 22:02:38 +0300 Subject: [PATCH 29/63] Update array tests --- tests/src/array/change.c | 29 ------ tests/src/array/main.c | 33 ++---- tests/src/array/plug.h | 30 +++--- tests/src/array/src/io.c | 197 +++++++++++++++++++++++++++++++++++ tests/src/array/src/plug.c | 25 +++++ tests/src/array/src/random.c | 83 +++++++++++++++ 6 files changed, 327 insertions(+), 70 deletions(-) delete mode 100644 tests/src/array/change.c create mode 100644 tests/src/array/src/io.c create mode 100644 tests/src/array/src/plug.c create mode 100644 tests/src/array/src/random.c diff --git a/tests/src/array/change.c b/tests/src/array/change.c deleted file mode 100644 index 989193a..0000000 --- a/tests/src/array/change.c +++ /dev/null @@ -1,29 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "plug.h" - -int main(int argc, char** argv) { - test_init(argc, argv); - - vtype_array y; - vtype_array x = array_random(8); - - array_info(&x); - array_sort(&x); - array_print(&x, 0); - - array_slice(&y, &x, 2, 4, 1); - - array_print(&x, "source"); - array_print(&y, "cutted"); - - array_remove(&x, -1); - array_remove(&y, -1); - - array_print(&x, "source (last removed)"); - array_print(&y, "cutted (last removed)"); - - array_free(&x); - array_free(&y); -} diff --git a/tests/src/array/main.c b/tests/src/array/main.c index a8b5ab4..18b31fd 100644 --- a/tests/src/array/main.c +++ b/tests/src/array/main.c @@ -3,36 +3,21 @@ #include "plug.h" -static void array_find_minimal(const vtype_array* x) { - array_print(x, 0); - for (vtype_uint64 v = 0; v < UINT64_MAX; ++v) { - ssize_t index = array_indexof(x, v); - if (index >= 0) { - printf("\e[36mValue \e[m\e[31m%lu\e[m\e[36m was found at the position \e[m\e[32;1m%ld\e[m\n", v, index); - break; - } - } - put_separator(); -} int main(int argc, char** argv) { test_init(argc, argv); - vtype_array x = { .mem = 0 }; + arr_t x = { .mem = 0, .size = 0, .type = random_uint8()%(VTYPE_LDOUBLE + 1) }; + arr_t y = { .mem = 0, .size = 0, .type = x.type }; - do { - array_free(&x); - x = array_random(8); - } while (x.type >= VTYPE_FLOAT); + visual_push(&x, (random_uint8()%17) + 16); - array_info(&x); - array_find_minimal(&x); + visual_slice(&x, &y); + visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%5) + 12); - array_reverse(&x); - array_print(&x, "reversed"); + visual_sort2(&x, &y); + visual_remove2(&x, &y); - array_sort(&x); - array_print(&x, "sorted"); - - array_free(&x); + array_free(&y); + array_free(&y); } diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index dd8ed86..254611a 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -9,27 +9,22 @@ #include "../../include/test.h" #include "../../include/time.h" -vtype_string* string_duplicate(const vtype_string* x) { return 0; } -vtype_list* list_duplicate (const vtype_list* x) { return 0; } -vtype_map* map_duplicate (const vtype_map* x) { return 0; } -vtype_set* vset_duplicate (const vtype_set* x) { return 0; } -void string_free(vtype_string* x) {} -void list_free (vtype_list* x) {} -void map_free (vtype_map* x) {} -void vset_free (vtype_set* x) {} +extern void array_print(arr_t* x, const char* prefix, unsigned int hpos); +extern void array_info(arr_t* x, unsigned int hpos); -int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } -int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } -int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } -int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } - -extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } -extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } -extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } -extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } +extern void visual_push(arr_t* x, size_t n); +extern void visual_sort(arr_t* x); +extern void visual_remove(arr_t* x); +extern void visual_push2(arr_t* x0, size_t n0, arr_t* x1, size_t n1); +extern void visual_remove2(arr_t* x0, arr_t* x1); +extern void visual_sort2(arr_t* x0, arr_t* x1); +extern void visual_slice(arr_t* x, arr_t* s); +extern void array_push_random (arr_t* x, _Bool silent, unsigned int hpos); +extern void array_remove_random(arr_t* x, _Bool silent, unsigned int hpos); +/* static void array_push_random(vtype_array* x) { switch (random_uint8()%13) { default: @@ -95,3 +90,4 @@ static void array_info(const vtype_array* x) { print_container_info("Array", 0, &x->type, array_size(x), array_nmemb(x)); put_separator(); } +*/ diff --git a/tests/src/array/src/io.c b/tests/src/array/src/io.c new file mode 100644 index 0000000..127eaec --- /dev/null +++ b/tests/src/array/src/io.c @@ -0,0 +1,197 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int array_value_print(void* v, ssize_t i, vtype t, void* _) { + print_container_value(&i, v, t, 1, *(unsigned int*)_); + return 0; +} + +void array_print(arr_t* x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Array", prefix, hpos); + array_foreach(x, &hpos, array_value_print); +} + +void array_info(arr_t* x, unsigned int hpos) { + print_container_info("Array", "nodes", 0, array_size(x), -1, hpos); +} + + +void visual_push(arr_t* x, size_t n) { + for (int i = 0; i < n; ++i) { + fputs("\e[s", stdout); + + array_push_random(x, 0, 0); + + array_info(x, 0); + array_print(x, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} + +void visual_sort(arr_t* x) { + puts("\e[s\e[36mTry to sort array values:\e[m\n\n"); + put_separator(0); + array_sort(x); + array_info(x, 0); + array_print(x, "sorted", 0); + psleep(900000); + fputs("\e[u\e[J", stdout); + + puts("\e[s\e[36mTry to reverse array values:\e[m\n\n"); + put_separator(0); + array_reverse(x); + array_info(x, 0); + array_print(x, "reversed", 0); + psleep(900000); + fputs("\e[u\e[J", stdout); +} + +void visual_remove(arr_t* x) { + while (x->size) { + fputs("\e[s", stdout); + array_remove_random(x, 0, 0); + array_info(x, 0); + array_print(x, 0, 0); + + psleep(100000); + if (!0) fputs("\e[u\e[J", stdout); + } +} + +void visual_push2(arr_t* x0, size_t n0, arr_t* x1, size_t n1) { + + for (;n0 || n1;) { + fputs("\e[s", stdout); + if (n0) { + array_push_random(x0, 0, 0); + --n0; + } else { + puts("\n\n"); + put_separator(0); + } + + fputs("\e[u\e[s", stdout); + + if (n1) { + array_push_random(x1, 0, 60); + --n1; + } else { + puts("\n\n"); + put_separator(60); + } + + array_info(x0, 0); + array_print(x0, 0, 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(x1, 60); + array_print(x1, 0, 60); + psleep(100000); + + fputs("\e[u\e[J", stdout); + } +} + +void visual_remove2(arr_t* x0, arr_t* x1) { + + for (;x0->size || x1->size;) { + fputs("\e[s", stdout); + + if (x0->size) { + array_remove_random(x0, 0, 0); + } else { + puts("\n\n"); + put_separator(0); + } + + fputs("\e[u\e[s", stdout); + + if (x1->size) { + array_remove_random(x1, 0, 60); + } else { + puts("\n\n"); + put_separator(60); + } + + array_info(x0, 0); + array_print(x0, 0, 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(x1, 60); + array_print(x1, 0, 60); + psleep(100000); + + fputs("\e[u\e[J", stdout); + } +} + + +void visual_sort2(arr_t* x0, arr_t* x1) { + printf("\e[s\e[36m%-60s%s\e[m\n\n","Try to sort array values:", "Try to sort array values:"); + printf("\e[32;1m%-60s%s\e[m\n", "SUCCESS", "SUCCESS"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + array_sort(x0); + array_sort(x1); + + array_info(x0, 0); + array_print(x0, "sorted", 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(x1, 60); + array_print(x1, "sorted", 60); + + psleep(900000); + fputs("\e[u\e[J", stdout); + + printf("\e[s\e[36m%-60s%s\e[m\n\n","Try to reverse array values:", "Try to reverse array values:"); + printf("\e[32;1m%-60s%s\e[m\n", "SUCCESS", "SUCCESS"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + array_reverse(x0); + array_reverse(x1); + + array_info(x0, 0); + array_print(x0, "reversed", 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(x1, 60); + array_print(x1, "reversed", 60); + + psleep(900000); + fputs("\e[u\e[J", stdout); +} + +void visual_slice(arr_t* x, arr_t* s) { + + size_t n = array_size(x); + ssize_t i = random_uint64()%(n - 1); + + n = n - (i + 1); + + puts("\e[s\e[36mTry to slice array:\e[m\n\n"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + array_info(x, 0); + array_print(x, "(src)", 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(s, 60); + array_print(s, "(dest)", 60); + + psleep(900000); + + array_slice(s, x, i, n, 1); + fputs("\e[u\e[s\e[2E\e[32;1mSUCCESS\e[m\e[J", stdout); + + puts(""); + put_separator(0); + + array_info(x, 0); + array_print(x, "(src)", 0); + fputs("\e[u\e[s\e[4E", stdout); + array_info(s, 60); + array_print(s, "(dest)", 60); + psleep(900000); + + fputs("\e[u\e[J", stdout); +} diff --git a/tests/src/array/src/plug.c b/tests/src/array/src/plug.c new file mode 100644 index 0000000..30511e8 --- /dev/null +++ b/tests/src/array/src/plug.c @@ -0,0 +1,25 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include "../../../../include/extra/vtype.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { random_int8(); } + +extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } +extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } +extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } +extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } diff --git a/tests/src/array/src/random.c b/tests/src/array/src/random.c new file mode 100644 index 0000000..22af216 --- /dev/null +++ b/tests/src/array/src/random.c @@ -0,0 +1,83 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int remove_callback(void* v, ssize_t i, vtype t, void* _) { + struct { arr_t* x; _Bool s; unsigned int p; } *x = _; + if (!x->s) print_container_value(0, v, t, 1, x->p); + + if (libcdsb_array_find(x->x, v, t, 0, 0, 1, 1)) + return -2; + return 0; +} + +static int change_callback(void* v, ssize_t i, vtype t, void* _) { + struct { value_t v; _Bool s; unsigned int p; } *x = _; + + while (x->v.type != t) { x->v = random_value(); } + + memcpy(v, &x->v, vtype_size(t)); + return 0; +} + +void array_push_random(arr_t* x, _Bool silent, unsigned int hpos) { + + struct { value_t v; _Bool s; unsigned int p; } _ = { .v = random_value(), .s = silent, .p = hpos }; + _Bool r; + + if (random_boolean()) { + if (!silent) { + printf("\e[%dG\e[36mTry to push value to back of the array:\e[m\n", hpos+1); + } + + r = libcdsb_array_push(x, _.v.value, _.v.type) >= 0; + } else { + ssize_t i = array_size(x); + + i = random_uint64() % (i ? i : 1); + i = random_boolean() ? ~i + 1 : i ; + + if (!silent) { + printf("\e[%dG\e[36mTry to change value in the array with index \e[32;1m%ld\e[36m:\e[m\n", hpos+1, i); + } + + r = array_get_by_index(x, i, &_, change_callback) == 0; + } + + if (!silent) { + print_container_value(0, _.v.value, _.v.type, 1, hpos); + printf("\e[%dG%s\n", hpos+1, r ? "\e[32;1mSUCCESS\e[m" : "\e[31;1mFAILURE\e[m"); + put_separator(hpos); + } +} + +void array_remove_random(arr_t* x, _Bool silent, unsigned int hpos) { + + size_t n = array_size(x); + ssize_t i = random_uint64()%n; + + if (random_boolean()) i = ~i + 1; + + if (random_boolean()) { + if (!silent) { + printf("\e[%dG\e[36mTry to remove value from list by index:\e[m\n", hpos+1); + print_container_value(0, &i, (sizeof(ssize_t) == 8) ? VTYPE_INT64 : VTYPE_INT32, 0, hpos); + } + switch (array_remove_by_index(x, i)) { + case 0: if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); break; + default: if (!silent) printf("\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; + } + } else { + struct { arr_t* x; _Bool s; unsigned int p; } v = { .x = x, .s = silent, .p = hpos }; + + if (!silent) printf("\e[%dG\e[36mTry to remove value from list:\e[m\n", hpos+1); + + switch (libcdsb_array_get(x, i, &v, remove_callback, 0)) { + case 0: if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); break; + default: if (!silent) printf("\e[%dG\e[32;1mFAILURE\e[m\n", hpos+1); break; + } + } + + put_separator(hpos); +} From 11db0557b9b6b27b021e6563b6d091976a8fff8c Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 17:08:06 +0300 Subject: [PATCH 30/63] Update list tests --- tests/src/list/main.c | 5 ++++- tests/src/list/plug.h | 1 + tests/src/list/src/io.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/src/list/main.c b/tests/src/list/main.c index 9cdcbcd..71a3352 100644 --- a/tests/src/list/main.c +++ b/tests/src/list/main.c @@ -9,7 +9,10 @@ int main(int argc, char** argv) { list_t x = { .first = 0, .last = 0 }; list_t y = { .first = 0, .last = 0 }; - visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%5) + 12); + visual_push(&x, (random_uint8()%9) + 8); + visual_slice(&x, &y); + + visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%3) + 6); visual_extend(&x, &y); visual_sort2(&x, &y); diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h index 7362e9d..21c7aa5 100644 --- a/tests/src/list/plug.h +++ b/tests/src/list/plug.h @@ -23,3 +23,4 @@ extern void visual_push2(list_t* x0, size_t n0, list_t* x1, size_t n1); extern void visual_remove2(list_t* x0, list_t* x1); extern void visual_sort2(list_t* x0, list_t* x1); extern void visual_extend(list_t* x, list_t* s); +extern void visual_slice(list_t* x, list_t* s); diff --git a/tests/src/list/src/io.c b/tests/src/list/src/io.c index 5ed0ed0..bbb441f 100644 --- a/tests/src/list/src/io.c +++ b/tests/src/list/src/io.c @@ -186,3 +186,38 @@ void visual_extend(list_t* x, list_t* s) { psleep(900000); fputs("\e[u\e[J", stdout); } + + +void visual_slice(list_t* x, list_t* s) { + + size_t n = list_size(x); + ssize_t i = random_uint64()%(n - 1); + + n = n - (i + 1); + + puts("\e[s\e[36mTry to slice list:\e[m\n\n"); + printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ==="); + + list_info(x, 0); + list_print(x, "(src)", 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(s, 60); + list_print(s, "(dest)", 60); + + psleep(900000); + + list_slice(s, x, i, n, 1); + fputs("\e[u\e[s\e[2E\e[32;1mSUCCESS\e[m\e[J", stdout); + + puts(""); + put_separator(0); + + list_info(x, 0); + list_print(x, "(src)", 0); + fputs("\e[u\e[s\e[4E", stdout); + list_info(s, 60); + list_print(s, "(dest)", 60); + psleep(900000); + + fputs("\e[u\e[J", stdout); +} From fe6732a39b37240a0fa7fb657fef49a931b6c955 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 17:08:36 +0300 Subject: [PATCH 31/63] Update array tests --- tests/src/array/src/plug.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/src/array/src/plug.c b/tests/src/array/src/plug.c index 30511e8..364b6fc 100644 --- a/tests/src/array/src/plug.c +++ b/tests/src/array/src/plug.c @@ -3,6 +3,7 @@ #include #include "../../../../include/extra/vtype.h" +#include "../../../include/random.h" vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_list* list_duplicate (const vtype_list* x) { return 0; } @@ -14,10 +15,10 @@ void list_free (vtype_list* x) {} void map_free (vtype_map* x) {} void vset_free (vtype_set* x) {} -int string_compare(const vtype_string* s0, const vtype_string* s1) { random_int8(); } -int list_compare (const vtype_list* s0, const vtype_list* s1) { random_int8(); } -int map_compare (const vtype_map* s0, const vtype_map* s1) { random_int8(); } -int vset_compare (const vtype_set* s0, const vtype_set* s1) { random_int8(); } +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } From 8dc5a84d49737861715b2c91b0fadcafefa63f56 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 20:50:03 +0300 Subject: [PATCH 32/63] Update tests --- tests/src/array/src/random.c | 2 +- tests/src/list/src/io.c | 2 +- tests/src/list/src/random.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/array/src/random.c b/tests/src/array/src/random.c index 22af216..4dcc8b7 100644 --- a/tests/src/array/src/random.c +++ b/tests/src/array/src/random.c @@ -79,5 +79,5 @@ void array_remove_random(arr_t* x, _Bool silent, unsigned int hpos) { } } - put_separator(hpos); + if (!silent) put_separator(hpos); } diff --git a/tests/src/list/src/io.c b/tests/src/list/src/io.c index bbb441f..793ae33 100644 --- a/tests/src/list/src/io.c +++ b/tests/src/list/src/io.c @@ -58,7 +58,7 @@ void visual_remove(list_t* x) { list_print(x, 0, 0); psleep(100000); - if (!0) fputs("\e[u\e[J", stdout); + fputs("\e[u\e[J", stdout); } } diff --git a/tests/src/list/src/random.c b/tests/src/list/src/random.c index 2552978..5a4a1a9 100644 --- a/tests/src/list/src/random.c +++ b/tests/src/list/src/random.c @@ -78,5 +78,5 @@ void list_remove_random(list_t* x, _Bool silent, unsigned int hpos) { } } - put_separator(hpos); + if (!silent) put_separator(hpos); } From 41c220b50766ee7e29bd0e825ce152507605dae9 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 20:50:20 +0300 Subject: [PATCH 33/63] Update map tests --- tests/src/map/main.c | 8 +- tests/src/map/plug.h | 217 ++----------------------------------- tests/src/map/src/io.c | 83 ++++++++++++++ tests/src/map/src/plug.c | 20 ++++ tests/src/map/src/random.c | 53 +++++++++ 5 files changed, 169 insertions(+), 212 deletions(-) create mode 100644 tests/src/map/src/io.c create mode 100644 tests/src/map/src/plug.c create mode 100644 tests/src/map/src/random.c diff --git a/tests/src/map/main.c b/tests/src/map/main.c index f08ef64..d054ec0 100644 --- a/tests/src/map/main.c +++ b/tests/src/map/main.c @@ -6,8 +6,10 @@ int main(int argc, char** argv) { test_init(argc, argv); - map_t x = map_random(36, 0.1); + map_t x; - while(map_remove_random(&x, 0.1)) {} - map_free(&x); + map_init(&x, random_uint8()%VTYPE_LDOUBLE + 1); + + visual_push(&x, random_uint8()%17 + 16); + visual_remove(&x); } diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h index 2ea8ee7..bb64636 100644 --- a/tests/src/map/plug.h +++ b/tests/src/map/plug.h @@ -7,214 +7,13 @@ #include "../../include/test.h" #include "../../include/time.h" -vtype_string* string_duplicate(const vtype_string* x) { return 0; } -vtype_array* array_duplicate (const vtype_array* x) { return 0; } -vtype_list* list_duplicate (const vtype_list* x) { return 0; } -vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +void map_push_random(map_t* x, _Bool silent, unsigned int hpos); +void map_remove_random(map_t* x, _Bool silent, unsigned int hpos); -void string_free(vtype_string* x) {} -void array_free (vtype_array* x) {} -void list_free (vtype_list* x) {} -void vset_free (vtype_set* x) {} +void rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br); +void map_print(map_t* x, const char* prefix, unsigned int hpos); +void map_info(const map_t* x, unsigned int hpos); +void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos); -int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } -int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } -int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } -int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } - - -static int map_node_print(const void* k, vtype kt, void* v, vtype vt, void* _) { - printf(" \e[31m%24s\e[m \e[36m:\e[m", vtype_stringify(k, kt)); - printf(" \e[31m%s\e[m", vtype_stringify(v, vt)); - printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(vt)); - return 0; -} - -static void map_print(map_t* x, const char* prefix) { - print_container_values_prefix("Map", prefix); - map_foreach(x, 0, map_node_print); - put_separator(); -} - -static void map_info(const map_t* x) { - print_container_info("Map", "nodes", &x->type, map_size(x), -1); - put_separator(); -} - -static void map_rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br) { - if (!ind) { - ind = "\e[36m"; - br = 1; - } - - size_t n = strlen(ind); - char x[n + 10]; - - if (mnode_is_empty(s)) return; - - memcpy(x, ind, n); - memcpy(x + n, " \0 ", 9); - fputs(ind, stdout); - - if (br) { - fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); - } else { - fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); - memcpy(x + n, "│", 3); - x[n + 5] = ' '; - } - - fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); - printf("%s\e[m \e[36m:\e[m ", vnode_stringify(&s->key, t)); - printf("\e[31m%s\e[m", vnode_stringify(&s->value, s->type)); - printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(s->type)); - - map_rbtree_print(s->left, t, x, false); - map_rbtree_print(s->right, t, x, true); -} - -static void map_push_random(map_t* x, double pause) { - var_t _[2]; - vtype t[2]; - - printf("\e[s\e[36mUpdate value in map (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", vtype_name(x->type)); - - switch (random_uint8()%13) { - default: - case 0: _[0].b = random_boolean(); print_container_value(0, _, t[0] = VTYPE_BOOLEAN, 1); break; - case 1: _[0].u8 = random_uint8(); print_container_value(0, _, t[0] = VTYPE_UINT8, 1); break; - case 2: _[0].u16 = random_uint16(); print_container_value(0, _, t[0] = VTYPE_UINT16, 1); break; - case 3: _[0].u32 = random_uint32(); print_container_value(0, _, t[0] = VTYPE_UINT32, 1); break; - case 4: _[0].u64 = random_uint64(); print_container_value(0, _, t[0] = VTYPE_UINT64, 1); break; - case 5: _[0].u8 = random_int8(); print_container_value(0, _, t[0] = VTYPE_INT8, 1); break; - case 6: _[0].u16 = random_int16(); print_container_value(0, _, t[0] = VTYPE_INT16, 1); break; - case 7: _[0].u32 = random_int32(); print_container_value(0, _, t[0] = VTYPE_INT32, 1); break; - case 8: _[0].u64 = random_int64(); print_container_value(0, _, t[0] = VTYPE_INT64, 1); break; - case 9: _[0].f = random_float(); print_container_value(0, _, t[0] = VTYPE_FLOAT, 1); break; - case 10: _[0].d = random_double(); print_container_value(0, _, t[0] = VTYPE_DOUBLE, 1); break; - case 11: _[0].ld = random_ldouble(); print_container_value(0, _, t[0] = VTYPE_LDOUBLE, 1); break; - - case 12: if (sizeof(void*) == 8) { - _[0].u64 = random_uint64(); print_container_value(0, _, t[0] = VTYPE_POINTER, 1); break; - } else { - _[0].u32 = random_uint32(); print_container_value(0, _, t[0] = VTYPE_POINTER, 1); break; - } - } - - switch (random_uint8()%13) { - default: - case 0: _[1].b = random_boolean(); print_container_value(0, _+1, t[1] = VTYPE_BOOLEAN, 1); break; - case 1: _[1].u8 = random_uint8(); print_container_value(0, _+1, t[1] = VTYPE_UINT8, 1); break; - case 2: _[1].u16 = random_uint16(); print_container_value(0, _+1, t[1] = VTYPE_UINT16, 1); break; - case 3: _[1].u32 = random_uint32(); print_container_value(0, _+1, t[1] = VTYPE_UINT32, 1); break; - case 4: _[1].u64 = random_uint64(); print_container_value(0, _+1, t[1] = VTYPE_UINT64, 1); break; - case 5: _[1].u8 = random_int8(); print_container_value(0, _+1, t[1] = VTYPE_INT8, 1); break; - case 6: _[1].u16 = random_int16(); print_container_value(0, _+1, t[1] = VTYPE_INT16, 1); break; - case 7: _[1].u32 = random_int32(); print_container_value(0, _+1, t[1] = VTYPE_INT32, 1); break; - case 8: _[1].u64 = random_int64(); print_container_value(0, _+1, t[1] = VTYPE_INT64, 1); break; - case 9: _[1].f = random_float(); print_container_value(0, _+1, t[1] = VTYPE_FLOAT, 1); break; - case 10: _[1].d = random_double(); print_container_value(0, _+1, t[1] = VTYPE_DOUBLE, 1); break; - case 11: _[1].ld = random_ldouble(); print_container_value(0, _+1, t[1] = VTYPE_LDOUBLE, 1); break; - - case 12: if (sizeof(void*) == 8) { - _[1].u64 = random_uint64(); print_container_value(0, _+1, t[1] = VTYPE_POINTER, 1); break; - } else { - _[1].u32 = random_uint32(); print_container_value(0, _+1, t[1] = VTYPE_POINTER, 1); break; - } - } - - if (libcdsb_map_update(x, _, t[0], _+1, t[1])) { - puts("\e[33;1mCHANGE\e[m"); - } else { - puts("\e[32;1mINSERT\e[m"); - } - - put_separator(); - - map_rbtree_print(x->root, x->type, 0, 0); - put_separator(); - psleep(pause * 1000000); - fputs("\e[u\e[J", stdout); -} - -static int map_node_remove_random(const void* k, vtype kt, void* v, vtype vt, void* data) { - struct { - size_t n; - map_t* set; - double pause; - } *d = data; - - if (!d->n--) { - map_node_print(k, kt, v, vt, 0); - - if (libcdsb_map_find(0, d->set, k, kt, 1)) { - puts("\e[32;1mSUCCESS\e[m"); - } else { - puts("\e[s\e[31;1mFAILURE\e[m"); - abort(); - } - - put_separator(); - - map_rbtree_print(d->set->root, d->set->type, 0, 0); - put_separator(); - psleep(d->pause * 1000000); - - return true; - } - return 0; -} - - -static bool map_remove_random(map_t* x, double pause) { - struct { - size_t n; - map_t* set; - double pause; - } d; - d.n = map_size(x); - d.set = x; - d.pause = pause; - - printf("\e[s\e[36mTry to remove value from map (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); - - if (d.n) { - d.n = random_uint32()%d.n; - } else goto end_; - - if (!map_foreach(x, &d, map_node_remove_random)) { - end_: - puts("\e[u\e[J\e[32;1mMap is empty\e[m"); - return false; - } - - fputs("\e[u\e[J", stdout); - return true; -} - -static map_t map_random(unsigned int n, double pause) { - map_t x; - - switch (random_uint8()%12) { - default: - case 0: map_init(&x, VTYPE_UINT8); break; - case 1: map_init(&x, VTYPE_UINT16); break; - case 2: map_init(&x, VTYPE_UINT32); break; - case 3: map_init(&x, VTYPE_UINT64); break; - case 4: map_init(&x, VTYPE_INT8); break; - case 5: map_init(&x, VTYPE_INT16); break; - case 6: map_init(&x, VTYPE_INT32); break; - case 7: map_init(&x, VTYPE_INT64); break; - case 8: map_init(&x, VTYPE_POINTER); break; - case 9: map_init(&x, VTYPE_FLOAT); break; - case 10: map_init(&x, VTYPE_DOUBLE); break; - case 11: map_init(&x, VTYPE_LDOUBLE); break; - } - - if (n) { - while (--n) map_push_random(&x, pause); - map_push_random(&x, pause); - } - - return x; -} +void visual_push(map_t* x, size_t n); +void visual_remove(map_t* x); diff --git a/tests/src/map/src/io.c b/tests/src/map/src/io.c new file mode 100644 index 0000000..5bb48f4 --- /dev/null +++ b/tests/src/map/src/io.c @@ -0,0 +1,83 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int node_print_callback(const void* k, vtype kt, void* v, vtype vt, void* _) { + print_container_value(0, k, kt, 0, *(unsigned int*)_); + return 0; +} + +void map_print(map_t* x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Map", prefix, 0); + map_foreach(x, &hpos, node_print_callback); + put_separator(0); +} + +void map_info(const map_t* x, unsigned int hpos) { + print_container_info("Map", "nodes", &x->type, map_size(x), -1, 0); + put_separator(0); +} + +void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Map", prefix, 0); + rbtree_print(x->root, x->type, 0, 0); +} + +void rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br) { + if (!ind) { + ind = "\e[36m"; + br = 1; + } + + size_t n = strlen(ind); + char x[n + 10]; + + if (mnode_is_empty(s)) return; + + memcpy(x, ind, n); + memcpy(x + n, " \0 ", 9); + + fputs(ind, stdout); + + if (br) { + fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); + } else { + fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); + memcpy(x + n, "│", 3); + x[n + 5] = ' '; + } + + fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); + printf("%s\e[m \e[36m:\e[m ", vnode_stringify(&s->key, t)); + printf("\e[31m%s\e[m", vnode_stringify(&s->value, s->type)); + printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(s->type)); + + rbtree_print(s->left, t, x, false); + rbtree_print(s->right, t, x, true); +} + +void visual_push(map_t* x, size_t n) { + while (n--) { + fputs("\e[s", stdout); + + map_push_random(x, 0, 0); + + map_info(x, 0); + rbtree_print(x->root, x->type, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} + +void visual_remove(map_t* x) { + while (!mnode_is_empty(x->root)) { + fputs("\e[s", stdout); + map_remove_random(x, 0, 0); + map_info(x, 0); + rbtree_print(x->root, x->type, 0, 0); + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} diff --git a/tests/src/map/src/plug.c b/tests/src/map/src/plug.c new file mode 100644 index 0000000..b2a8764 --- /dev/null +++ b/tests/src/map/src/plug.c @@ -0,0 +1,20 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../../src/__internal/include.h" +#include "../../../include/random.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/map/src/random.c b/tests/src/map/src/random.c new file mode 100644 index 0000000..e917874 --- /dev/null +++ b/tests/src/map/src/random.c @@ -0,0 +1,53 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int remove_callback(const void* k, vtype kt, void* v, vtype vt, void* _) { + struct { size_t n; map_t* x; unsigned int hp; } *d = _; + + if (!d->n--) { + print_container_value(0, k, kt, 0, d->hp); + + if (libcdsb_map_find(d->x, k, kt, 0, 0, 1)) { + printf("\e[%dG\e[32;1mSUCCESS\e[m", d->hp+1); + } else printf("\e[%dG\e[31;1mFAILURE\e[m", d->hp+1); + + return -2; + } + return 0; +} + +void map_push_random(map_t* x, _Bool silent, unsigned int hpos) { + + value_t k = random_value(); + value_t v = random_value(); + + if (!silent) { + printf("\e[%dG\e[36mUpdate value in map (\e[m\e[32;1m%s\e[m\e[36m) with key:\e[m\n", hpos+1, vtype_name(x->type)); + print_container_value(0, k.value, k.type, 1, hpos); + } + + if (libcdsb_map_update(x, k.value, k.type, v.value, v.type)) { + if (!silent) printf("\e[%dG\\e[33;1mCHANGE\e[m", hpos+1); + } else if (!silent) printf("\e[%dG\\e[32;1mINSERT\e[m", hpos+1); + + if (!silent) put_separator(0); +} + + +void map_remove_random(map_t* x, _Bool silent, unsigned int hpos) { + struct { size_t n; map_t* x; unsigned int hp; } d = { .n = map_size(x), .x = x, .hp = hpos }; + + if (!silent) + printf("\e[%dG\e[36mTry to remove value from map (\e[m\e[32;1m%s\e[m\e[36m) by key:\e[m\n", hpos+1, libcdsb_vtype_name(x->type)); + + if (d.n) { + d.n = random_uint32()%d.n; + map_foreach(x, &d, remove_callback); + } else if (!silent) { + printf("\e[%dG\e[32;1m\nFAILURE\e[m\n", hpos+1); + } + + if (!silent) put_separator(hpos); +} From d57f5ed2c6ef9435867e83e21fefdb5ee14ba3b7 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 21:17:07 +0300 Subject: [PATCH 34/63] Update map tests --- tests/src/map/plug.h | 1 - tests/src/map/src/io.c | 71 +++++++++++++++++++------------------- tests/src/map/src/random.c | 10 +++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h index bb64636..a2ae449 100644 --- a/tests/src/map/plug.h +++ b/tests/src/map/plug.h @@ -10,7 +10,6 @@ void map_push_random(map_t* x, _Bool silent, unsigned int hpos); void map_remove_random(map_t* x, _Bool silent, unsigned int hpos); -void rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br); void map_print(map_t* x, const char* prefix, unsigned int hpos); void map_info(const map_t* x, unsigned int hpos); void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos); diff --git a/tests/src/map/src/io.c b/tests/src/map/src/io.c index 5bb48f4..a01da4b 100644 --- a/tests/src/map/src/io.c +++ b/tests/src/map/src/io.c @@ -8,6 +8,39 @@ static int node_print_callback(const void* k, vtype kt, void* v, vtype vt, void* return 0; } +static void rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br, unsigned int hpos) { + if (!ind) { + ind = "\e[36m"; + br = 1; + } + + size_t n = strlen(ind); + char x[n + 10]; + + if (mnode_is_empty(s)) return; + + memcpy(x, ind, n); + memcpy(x + n, " \0 ", 9); + + printf("\e[%dG%s", hpos+1, ind); + + if (br) { + fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); + } else { + fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); + memcpy(x + n, "│", 3); + x[n + 5] = ' '; + } + + fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); + printf("%s\e[m \e[36m:\e[m ", vnode_stringify(&s->key, t)); + printf("\e[31m%s\e[m", vnode_stringify(&s->value, s->type)); + printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(s->type)); + + rbtree_print(s->left, t, x, false, hpos); + rbtree_print(s->right, t, x, true, hpos); +} + void map_print(map_t* x, const char* prefix, unsigned int hpos) { print_container_values_prefix("Map", prefix, 0); map_foreach(x, &hpos, node_print_callback); @@ -21,41 +54,9 @@ void map_info(const map_t* x, unsigned int hpos) { void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos) { print_container_values_prefix("Map", prefix, 0); - rbtree_print(x->root, x->type, 0, 0); + rbtree_print(x->root, x->type, 0, 0, hpos); } -void rbtree_print(const mnode_t* s, vtype t, const char* ind, bool br) { - if (!ind) { - ind = "\e[36m"; - br = 1; - } - - size_t n = strlen(ind); - char x[n + 10]; - - if (mnode_is_empty(s)) return; - - memcpy(x, ind, n); - memcpy(x + n, " \0 ", 9); - - fputs(ind, stdout); - - if (br) { - fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); - } else { - fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); - memcpy(x + n, "│", 3); - x[n + 5] = ' '; - } - - fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); - printf("%s\e[m \e[36m:\e[m ", vnode_stringify(&s->key, t)); - printf("\e[31m%s\e[m", vnode_stringify(&s->value, s->type)); - printf(" \e[36m(\e[m\e[32;1m%s\e[m\e[36m)\e[m\n", vtype_name(s->type)); - - rbtree_print(s->left, t, x, false); - rbtree_print(s->right, t, x, true); -} void visual_push(map_t* x, size_t n) { while (n--) { @@ -64,7 +65,7 @@ void visual_push(map_t* x, size_t n) { map_push_random(x, 0, 0); map_info(x, 0); - rbtree_print(x->root, x->type, 0, 0); + map_rbtree_print(x, 0, 0); psleep(100000); fputs("\e[u\e[J", stdout); @@ -76,7 +77,7 @@ void visual_remove(map_t* x) { fputs("\e[s", stdout); map_remove_random(x, 0, 0); map_info(x, 0); - rbtree_print(x->root, x->type, 0, 0); + map_rbtree_print(x, 0, 0); psleep(100000); fputs("\e[u\e[J", stdout); } diff --git a/tests/src/map/src/random.c b/tests/src/map/src/random.c index e917874..c4615f2 100644 --- a/tests/src/map/src/random.c +++ b/tests/src/map/src/random.c @@ -9,9 +9,9 @@ static int remove_callback(const void* k, vtype kt, void* v, vtype vt, void* _) if (!d->n--) { print_container_value(0, k, kt, 0, d->hp); - if (libcdsb_map_find(d->x, k, kt, 0, 0, 1)) { - printf("\e[%dG\e[32;1mSUCCESS\e[m", d->hp+1); - } else printf("\e[%dG\e[31;1mFAILURE\e[m", d->hp+1); + if (libcdsb_map_find(d->x, k, kt, 0, 0, 1) == 0) { + printf("\e[%dG\e[32;1mSUCCESS\e[m\n", d->hp+1); + } else printf("\e[%dG\e[31;1mFAILURE\e[m\n", d->hp+1); return -2; } @@ -29,8 +29,8 @@ void map_push_random(map_t* x, _Bool silent, unsigned int hpos) { } if (libcdsb_map_update(x, k.value, k.type, v.value, v.type)) { - if (!silent) printf("\e[%dG\\e[33;1mCHANGE\e[m", hpos+1); - } else if (!silent) printf("\e[%dG\\e[32;1mINSERT\e[m", hpos+1); + if (!silent) printf("\e[%dG\e[33;1mCHANGE\e[m\n", hpos+1); + } else if (!silent) printf("\e[%dG\e[32;1mINSERT\e[m\n", hpos+1); if (!silent) put_separator(0); } From f8878390a792dbefc7a07fda79abe349bdbf064a Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 21:17:35 +0300 Subject: [PATCH 35/63] Update set tests --- tests/src/set/main.c | 8 +- tests/src/set/plug.h | 191 ++----------------------------------- tests/src/set/src/io.c | 82 ++++++++++++++++ tests/src/set/src/plug.c | 20 ++++ tests/src/set/src/random.c | 52 ++++++++++ 5 files changed, 166 insertions(+), 187 deletions(-) create mode 100644 tests/src/set/src/io.c create mode 100644 tests/src/set/src/plug.c create mode 100644 tests/src/set/src/random.c diff --git a/tests/src/set/main.c b/tests/src/set/main.c index be56d43..1ba5f76 100644 --- a/tests/src/set/main.c +++ b/tests/src/set/main.c @@ -6,8 +6,10 @@ int main(int argc, char** argv) { test_init(argc, argv); - set_t x = vset_random(36, 0.1); + set_t x; - while(vset_remove_random(&x, 0.1)) {} - vset_free(&x); + vset_init(&x, random_uint8()%VTYPE_LDOUBLE + 1); + + visual_push(&x, random_uint8()%17 + 16); + visual_remove(&x); } diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h index fd4e092..756e649 100644 --- a/tests/src/set/plug.h +++ b/tests/src/set/plug.h @@ -8,188 +8,11 @@ #include "../../include/test.h" #include "../../include/time.h" -vtype_string* string_duplicate(const vtype_string* x) { return 0; } -vtype_array* array_duplicate (const vtype_array* x) { return 0; } -vtype_list* list_duplicate (const vtype_list* x) { return 0; } -vtype_map* map_duplicate (const vtype_map* x) { return 0; } +extern void vset_push_random(set_t* x, _Bool silent, unsigned int hpos); +extern void vset_remove_random(set_t* x, _Bool silent, unsigned int hpos); -void string_free(vtype_string* x) {} -void array_free (vtype_array* x) {} -void list_free (vtype_list* x) {} -void map_free (vtype_map* x) {} - -int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } -int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } -int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } -int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } - - -static int vset_node_print(const void* v, vtype t, void* _) { - print_container_value(0, v, t, false); - return 0; -} - -static void vset_print(set_t* x, const char* prefix) { - print_container_values_prefix("Set", prefix); - vset_foreach(x, 0, vset_node_print); - put_separator(); -} - -static void vset_info(const set_t* x) { - print_container_info("Set", "nodes", &x->type, vset_size(x), -1); - put_separator(); -} - -static void rbtree_print(const rbnode_t* s, vtype t, const char* ind, bool br) { - if (!ind) { - ind = "\e[36m"; - br = 1; - } - - size_t n = strlen(ind); - char x[n + 10]; - - if (rbnode_is_empty(s)) return; - - memcpy(x, ind, n); - memcpy(x + n, " \0 ", 9); - fputs(ind, stdout); - - if (br) { - fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); - } else { - fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); - memcpy(x + n, "│", 3); - x[n + 5] = ' '; - } - - - fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); - printf("%s\e[m\n", libcdsb_vtype_stringify(vnode_peek(&s->value, t), t)); - - rbtree_print(s->left, t, x, false); - rbtree_print(s->right, t, x, true); -} - -static void vset_push_random(set_t* x, double pause) { - var_t _; - vtype t; - - printf("\e[s\e[36mTry to insert into set (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); - - switch (random_uint8()%13) { - default: - case 0: _.b = random_boolean(); print_container_value(0, &_, t = VTYPE_BOOLEAN, 1); break; - case 1: _.u8 = random_uint8(); print_container_value(0, &_, t = VTYPE_UINT8, 1); break; - case 2: _.u16 = random_uint16(); print_container_value(0, &_, t = VTYPE_UINT16, 1); break; - case 3: _.u32 = random_uint32(); print_container_value(0, &_, t = VTYPE_UINT32, 1); break; - case 4: _.u64 = random_uint64(); print_container_value(0, &_, t = VTYPE_UINT64, 1); break; - case 5: _.u8 = random_int8(); print_container_value(0, &_, t = VTYPE_INT8, 1); break; - case 6: _.u16 = random_int16(); print_container_value(0, &_, t = VTYPE_INT16, 1); break; - case 7: _.u32 = random_int32(); print_container_value(0, &_, t = VTYPE_INT32, 1); break; - case 8: _.u64 = random_int64(); print_container_value(0, &_, t = VTYPE_INT64, 1); break; - case 9: _.f = random_float(); print_container_value(0, &_, t = VTYPE_FLOAT, 1); break; - case 10: _.d = random_double(); print_container_value(0, &_, t = VTYPE_DOUBLE, 1); break; - case 11: _.ld = random_ldouble(); print_container_value(0, &_, t = VTYPE_LDOUBLE, 1); break; - - case 12: if (sizeof(void*) == 8) { - _.u64 = random_uint64(); print_container_value(0, &_, t = VTYPE_POINTER, 1); break; - } else { - _.u32 = random_uint32(); print_container_value(0, &_, t = VTYPE_POINTER, 1); break; - } - } - - if (libcdsb_vset_insert(x, &_, t)) { - puts("\e[32;1mSUCCESS\e[m"); - } else { - puts("\e[31;1mFAILURE\e[m"); - } - put_separator(); - - rbtree_print(x->root, x->type, 0, 0); - put_separator(); - psleep(pause * 1000000); - fputs("\e[u\e[J", stdout); -} - -static int vset_node_remove_random(const void* v, vtype t, void* data) { - struct { - size_t n; - set_t* set; - double pause; - } *d = data; - - if (!d->n--) { - print_container_value(0, v, t, 1); - - if (libcdsb_vset_find(0, d->set, v, t, 1)) { - puts("\e[32;1mSUCCESS\e[m"); - } else { - puts("\e[31;1mFAILURE\e[m"); - abort(); - } - - put_separator(); - - rbtree_print(d->set->root, d->set->type, 0, 0); - put_separator(); - psleep(d->pause * 1000000); - - return true; - } - return 0; -} - - -static bool vset_remove_random(set_t* x, double pause) { - struct { - size_t n; - set_t* set; - double pause; - } d; - d.n = vset_size(x); - d.set = x; - d.pause = pause; - - printf("\e[s\e[36mTry to remove value from set (\e[m\e[32;1m%s\e[m\e[36m)\e[m:\n", libcdsb_vtype_name(x->type)); - - if (d.n) { - d.n = random_uint32()%d.n; - } else goto end_; - - if (!vset_foreach(x, &d, vset_node_remove_random)) { - end_: - puts("\e[u\e[J\e[32;1mSet is empty\e[m"); - return false; - } - - fputs("\e[u\e[J", stdout); - return true; -} - -static set_t vset_random(unsigned int n, double pause) { - set_t x; - - switch (random_uint8()%12) { - default: - case 0: vset_init(&x, VTYPE_UINT8); break; - case 1: vset_init(&x, VTYPE_UINT16); break; - case 2: vset_init(&x, VTYPE_UINT32); break; - case 3: vset_init(&x, VTYPE_UINT64); break; - case 4: vset_init(&x, VTYPE_INT8); break; - case 5: vset_init(&x, VTYPE_INT16); break; - case 6: vset_init(&x, VTYPE_INT32); break; - case 7: vset_init(&x, VTYPE_INT64); break; - case 8: vset_init(&x, VTYPE_POINTER); break; - case 9: vset_init(&x, VTYPE_FLOAT); break; - case 10: vset_init(&x, VTYPE_DOUBLE); break; - case 11: vset_init(&x, VTYPE_LDOUBLE); break; - } - - if (n) { - while (--n) vset_push_random(&x, pause); - vset_push_random(&x, pause); - } - - return x; -} +extern void vset_print(set_t* x, const char* prefix, unsigned int hpos); +extern void vset_info(const set_t* x, unsigned int hpos); +extern void vset_rbtree_print(set_t *x, const char* prefix, unsigned int hpos); +extern void visual_push(set_t* x, size_t n); +extern void visual_remove(set_t* x); diff --git a/tests/src/set/src/io.c b/tests/src/set/src/io.c new file mode 100644 index 0000000..378aaf6 --- /dev/null +++ b/tests/src/set/src/io.c @@ -0,0 +1,82 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + + +static int node_print_callback(const void* v, vtype t, void* _) { + print_container_value(0, v, t, 0, *(unsigned int*)_); + return 0; +} + +static void rbtree_print(const rbnode_t* s, vtype t, const char* ind, bool br, unsigned int hpos) { + if (!ind) { + ind = "\e[36m"; + br = 1; + } + + size_t n = strlen(ind); + char x[n + 10]; + + if (rbnode_is_empty(s)) return; + + memcpy(x, ind, n); + memcpy(x + n, " \0 ", 9); + + printf("\e[%dG%s", hpos+1, ind); + + if (br) { + fputs("\e[m\e[36;1mR\e[m\e[36m────\e[m", stdout); + } else { + fputs("\e[m\e[36;1mL\e[m\e[36m────\e[m", stdout); + memcpy(x + n, "│", 3); + x[n + 5] = ' '; + } + + fputs((s->colored) ? "\e[31;1m" : "\e[37m", stdout); + printf("%s\e[m \e[36m\e[m\n", vnode_stringify(&s->value, t)); + + rbtree_print(s->left, t, x, false, hpos); + rbtree_print(s->right, t, x, true, hpos); +} + +void vset_print(set_t* x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Set", prefix, 0); + vset_foreach(x, &hpos, node_print_callback); + put_separator(0); +} + +void vset_info(const set_t* x, unsigned int hpos) { + print_container_info("Set", "nodes", &x->type, vset_size(x), -1, 0); + put_separator(0); +} + +void vset_rbtree_print(set_t *x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Set", prefix, 0); + rbtree_print(x->root, x->type, 0, 0, hpos); +} + +void visual_push(set_t* x, size_t n) { + while (n--) { + fputs("\e[s", stdout); + + vset_push_random(x, 0, 0); + + vset_info(x, 0); + vset_rbtree_print(x, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} + +void visual_remove(set_t* x) { + while (!rbnode_is_empty(x->root)) { + fputs("\e[s", stdout); + vset_remove_random(x, 0, 0); + vset_info(x, 0); + vset_rbtree_print(x, 0, 0); + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} diff --git a/tests/src/set/src/plug.c b/tests/src/set/src/plug.c new file mode 100644 index 0000000..00cf60d --- /dev/null +++ b/tests/src/set/src/plug.c @@ -0,0 +1,20 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../../src/__internal/include.h" +#include "../../../include/random.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } diff --git a/tests/src/set/src/random.c b/tests/src/set/src/random.c new file mode 100644 index 0000000..dc6d6d5 --- /dev/null +++ b/tests/src/set/src/random.c @@ -0,0 +1,52 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int remove_callback(const void* v, vtype t, void* _) { + struct { size_t n; set_t* x; unsigned int hp; } *d = _; + + if (!d->n--) { + print_container_value(0, v, t, 0, d->hp); + + if (libcdsb_vset_find(d->x, v, t, 0, 0, 1) == 0) { + printf("\e[%dG\e[32;1mSUCCESS\e[m\n", d->hp+1); + } else printf("\e[%dG\e[31;1mFAILURE\e[m\n", d->hp+1); + + return -2; + } + return 0; +} + +void vset_push_random(set_t* x, _Bool silent, unsigned int hpos) { + + value_t v = random_value(); + + if (!silent) { + printf("\e[%dG\e[36mUpdate value in set (\e[m\e[32;1m%s\e[m\e[36m):\e[m\n", hpos+1, vtype_name(x->type)); + print_container_value(0, v.value, v.type, 1, hpos); + } + + if (libcdsb_vset_insert(x, v.value, v.type)) { + if (!silent) printf("\e[%dG\e[32;1mSUCCESS\e[m\n", hpos+1); + } else if (!silent) printf("\e[%dG\e[31;1mFAILURE\e[m\n", hpos+1); + + if (!silent) put_separator(0); +} + + +void vset_remove_random(set_t* x, _Bool silent, unsigned int hpos) { + struct { size_t n; set_t* x; unsigned int hp; } d = { .n = vset_size(x), .x = x, .hp = hpos }; + + if (!silent) + printf("\e[%dG\e[36mTry to remove value from set (\e[m\e[32;1m%s\e[m\e[36m):\e[m\n", hpos+1, libcdsb_vtype_name(x->type)); + + if (d.n) { + d.n = random_uint32()%d.n; + vset_foreach(x, &d, remove_callback); + } else if (!silent) { + printf("\e[%dG\e[32;1m\nFAILURE\e[m\n", hpos+1); + } + + if (!silent) put_separator(hpos); +} From a44a6d701ee02f0cb9bab5b003b45e8e59e1589c Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 10 Jun 2022 21:42:24 +0300 Subject: [PATCH 36/63] Update string tests --- tests/src/string/main.c | 77 +++++++++++++++-------------------- tests/src/string/plug.h | 69 ++++--------------------------- tests/src/string/src/io.c | 48 ++++++++++++++++++++++ tests/src/string/src/plug.c | 20 +++++++++ tests/src/string/src/random.c | 51 +++++++++++++++++++++++ tests/src/string/trim.c | 33 --------------- 6 files changed, 160 insertions(+), 138 deletions(-) create mode 100644 tests/src/string/src/io.c create mode 100644 tests/src/string/src/plug.c create mode 100644 tests/src/string/src/random.c delete mode 100644 tests/src/string/trim.c diff --git a/tests/src/string/main.c b/tests/src/string/main.c index 141e0cc..522b3f8 100644 --- a/tests/src/string/main.c +++ b/tests/src/string/main.c @@ -3,53 +3,13 @@ #include "plug.h" -static void string_concat_random(vtype_string* x, unsigned int n) { - char* v; - - if (random_boolean()) { - v = random_utf8_cstring(n); - } else v = random_ascii_cstring(n); - - string_concat(x, v); - free(v); -} - -static void string_replace_random(vtype_string* x, unsigned int n) { - char* v; - - if (random_boolean()) { - v = random_utf8_cstring(n); - } else v = random_ascii_cstring(n); - - string_replace(x, x, v, -1); - - free(v); -} - -static void string_print_compare(const vtype_string* s0, const vtype_string* s1) { - int c = string_compare(s0, s1); - char* m; - if (c == 0) m = "=="; - else m = (c < 0) ? "<" : ">"; - - puts("\e[36mStrings comparsion:\e[m\n"); - printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); -} - -static void string_print_case_compare(const vtype_string* s0, const vtype_string* s1) { - int c = string_case_compare(s0, s1); - char* m; - if (c == 0) m = "=="; - else m = (c < 0) ? "<" : ">"; - - puts("\e[36mStrings case insensitive comparsion:\e[m\n"); - printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); -} int main(int argc, char** argv) { test_init(argc, argv); - vtype_string x, y; + str_t x, y; + int c = random_unicode_symbol(); + fputs("\e[s", stdout); x = string_random(30); string_print(&x, "(part 1)"); @@ -77,8 +37,8 @@ int main(int argc, char** argv) { string_to_lower(&x); string_to_upper(&y); - string_print_compare(&x, &y); - string_print_case_compare(&x, &y); + visual_compare(&x, &y); + visual_case_compare(&x, &y); string_reverse(&y); string_capitalize(&y); @@ -87,4 +47,31 @@ int main(int argc, char** argv) { string_free(&x); string_free(&y); + + psleep(900000); + + fputs("\e[u\e[J", stdout); + + x = string_random(12); + + string_align_center(&x, 30, 0); + string_info(&x); + string_print(&x, 0); + + string_trim_spaces(&x); + string_info(&x); + string_print(&x, "trimmed"); + + put_separator(0); + string_align_center(&x, 30, c); + string_info(&x); + string_print(&x, 0); + + string_trim(&x, c); + string_info(&x); + string_print(&x, "trimmed"); + + psleep(900000); + + string_free(&x); } diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h index e0b2ad5..241dc93 100644 --- a/tests/src/string/plug.h +++ b/tests/src/string/plug.h @@ -9,65 +9,14 @@ #include "../../include/test.h" #include "../../include/time.h" -vtype_array* array_duplicate (const vtype_array* x) { return 0; } -vtype_list* list_duplicate (const vtype_list* x) { return 0; } -vtype_map* map_duplicate (const vtype_map* x) { return 0; } -vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +extern char* random_ascii_cstring(size_t size); +extern char* random_utf8_cstring(size_t size); +extern void string_concat_random(str_t* x, unsigned int n); +extern void string_replace_random(str_t* x, unsigned int n); -void array_free (vtype_array* x) {} -void list_free (vtype_list* x) {} -void map_free (vtype_map* x) {} -void vset_free (vtype_set* x) {} +extern void string_info(str_t* x); +extern void string_print(const str_t* x, const char* prefix); +extern str_t string_random(unsigned int n); -int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } -int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } -int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } -int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } - -static char* random_ascii_cstring(size_t size) { - char* v = malloc(size + 1); - char* p = v; - - while (size--) { - *(p++) = random_ascii_char(); - } - *p = 0; - - return v; -} - -static char* random_utf8_cstring(size_t size) { - char* v = malloc(size * 4 + 1); - char* p = v; - - while (size--) { - p = tochar_unicode(p, random_unicode_symbol()); - } - - *p = 0; - return v; -} - -static void string_info(vtype_string* x) { - print_container_info("String", "utf8 chars", 0, string_size(x), string_nmemb(x)); - put_separator(); -} - -static void string_print(const vtype_string* x, const char* prefix) { - if (prefix) { - printf("\e[36m%s %s content:\e[m\n", "String", prefix); - } else printf("\e[36m%s content:\e[m\n", "String"); - - printf("\e[33m\"%s\"\e[m\n", x->buffer); - put_separator(); -} - -static vtype_string string_random(unsigned int n) { - vtype_string x; - - if (random_boolean()) { - x.buffer = random_utf8_cstring(n); - } else x.buffer = random_ascii_cstring(n); - - return x; -} +extern void visual_compare(const str_t* s0, const str_t* s1); +extern void visual_case_compare(const str_t* s0, const str_t* s1); diff --git a/tests/src/string/src/io.c b/tests/src/string/src/io.c new file mode 100644 index 0000000..1da8654 --- /dev/null +++ b/tests/src/string/src/io.c @@ -0,0 +1,48 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +void string_info(str_t* x) { + print_container_info("String", "utf8 chars", 0, string_size(x), string_nmemb(x), 0); + put_separator(0); +} + +void string_print(const str_t* x, const char* prefix) { + if (prefix) { + printf("\e[36m%s %s content:\e[m\n", "String", prefix); + } else printf("\e[36m%s content:\e[m\n", "String"); + + printf("\e[33m\"%s\"\e[m\n", x->buffer); + put_separator(0); +} + +str_t string_random(unsigned int n) { + str_t x; + + if (random_boolean()) { + x.buffer = random_utf8_cstring(n); + } else x.buffer = random_ascii_cstring(n); + + return x; +} + +void visual_compare(const str_t* s0, const str_t* s1) { + int c = string_compare(s0, s1); + char* m; + if (c == 0) m = "=="; + else m = (c < 0) ? "<" : ">"; + + puts("\e[36mStrings comparsion:\e[m\n"); + printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); +} + +void visual_case_compare(const str_t* s0, const str_t* s1) { + int c = string_case_compare(s0, s1); + char* m; + if (c == 0) m = "=="; + else m = (c < 0) ? "<" : ">"; + + puts("\e[36mStrings case insensitive comparsion:\e[m\n"); + printf("\e[33m\"%s\"\e[m \e[31m%s\e[m \e[33m\"%s\"\e[m\n", s0->buffer, m, s1->buffer); +} diff --git a/tests/src/string/src/plug.c b/tests/src/string/src/plug.c new file mode 100644 index 0000000..6da62c4 --- /dev/null +++ b/tests/src/string/src/plug.c @@ -0,0 +1,20 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../../src/__internal/include.h" +#include "../../../include/random.h" + +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/string/src/random.c b/tests/src/string/src/random.c new file mode 100644 index 0000000..36a587c --- /dev/null +++ b/tests/src/string/src/random.c @@ -0,0 +1,51 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +char* random_ascii_cstring(size_t size) { + char* v = malloc(size + 1); + char* p = v; + + while (size--) { + *(p++) = random_ascii_char(); + } + *p = 0; + + return v; +} + +char* random_utf8_cstring(size_t size) { + char* v = malloc(size * 4 + 1); + char* p = v; + + while (size--) { + p = tochar_unicode(p, random_unicode_symbol()); + } + + *p = 0; + return v; +} + +void string_concat_random(str_t* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_concat(x, v); + free(v); +} + +void string_replace_random(str_t* x, unsigned int n) { + char* v; + + if (random_boolean()) { + v = random_utf8_cstring(n); + } else v = random_ascii_cstring(n); + + string_replace(x, x, v, -1); + + free(v); +} diff --git a/tests/src/string/trim.c b/tests/src/string/trim.c deleted file mode 100644 index c5329d8..0000000 --- a/tests/src/string/trim.c +++ /dev/null @@ -1,33 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "plug.h" - - -int main(int argc, char** argv) { - test_init(argc, argv); - vtype_string x; - int c = random_unicode_symbol(); - - x = string_random(12); - - string_align_center(&x, 30, 0); - string_info(&x); - string_print(&x, 0); - - string_trim_spaces(&x); - string_info(&x); - string_print(&x, "trimmed"); - - put_separator(); - string_align_center(&x, 30, c); - string_info(&x); - string_print(&x, 0); - - string_trim(&x, c); - string_info(&x); - string_print(&x, "trimmed"); - - - string_free(&x); -} From aa4828b4ed950287e99477d5b3103cad3ebd4d88 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 14 Aug 2022 18:18:34 +0300 Subject: [PATCH 37/63] Add dict type --- include/__generics.h | 23 +- include/array.h | 43 ++-- include/dict.h | 460 +++++++++++++++++++++++++++++++++++++++ include/extra/dict.h | 18 ++ include/list.h | 3 + include/map.h | 49 ++++- include/set.h | 2 + include/vtype.h | 33 +++ src/__internal/include.h | 8 + src/__internal/vnode.h | 2 + src/array/generics.c | 15 +- src/dict/generics.c | 445 +++++++++++++++++++++++++++++++++++++ src/list/generics.c | 3 + src/map/generics.c | 269 +++++++++++++---------- src/set/generics.c | 26 ++- 15 files changed, 1222 insertions(+), 177 deletions(-) create mode 100644 include/dict.h create mode 100644 include/extra/dict.h create mode 100644 src/dict/generics.c diff --git a/include/__generics.h b/include/__generics.h index 5ec0e7b..3f93adb 100644 --- a/include/__generics.h +++ b/include/__generics.h @@ -12,6 +12,7 @@ vtype_list*: T ## _ ## f ## _list, const vtype_list*: T ## _ ## f ## _list,\ vtype_map*: T ## _ ## f ## _map, const vtype_map*: T ## _ ## f ## _map,\ vtype_set*: T ## _ ## f ## _vset, const vtype_set*: T ## _ ## f ## _vset,\ + vtype_dict*: T ## _ ## f ## _dict, const vtype_dict*: T ## _ ## f ## _dict,\ vtype_bool: T ## _ ## f ## _boolean,\ vtype_uint8: T ## _ ## f ## _uint8,\ vtype_uint16: T ## _ ## f ## _uint16,\ @@ -34,6 +35,7 @@ vtype_list*: _LIBCDSB_Generic(T, f ## _list, v), const vtype_list*: _LIBCDSB_Generic(T, f ## _list, v),\ vtype_map*: _LIBCDSB_Generic(T, f ## _map, v), const vtype_map*: _LIBCDSB_Generic(T, f ## _map, v),\ vtype_set*: _LIBCDSB_Generic(T, f ## _vset, v), const vtype_set*: _LIBCDSB_Generic(T, f ## _vset, v),\ + vtype_dict*: _LIBCDSB_Generic(T, f ## _dict, v), const vtype_dict*: _LIBCDSB_Generic(T, f ## _dict, v),\ vtype_bool: _LIBCDSB_Generic(T, f ## _boolean, v),\ vtype_uint8: _LIBCDSB_Generic(T, f ## _uint8, v),\ vtype_uint16: _LIBCDSB_Generic(T, f ## _uint16, v),\ @@ -66,25 +68,4 @@ short: _LIBCDSB_GenericS(T, f ## _char, d), unsigned short: _LIBCDSB_GenericS(T, f ## _char, d)\ ) -#define _LIBCDSB_GenericP(T, f, v) _Generic((v),\ - void**: T ## _ ## f ## _pointers, const void**: T ## _ ## f ## _pointers,\ - STRING_VIEW*: T ## _ ## f ## _strings, const STRING_VIEW*: T ## _ ## f ## _strings,\ - ARRAY*: T ## _ ## f ## _arrays, const ARRAY*: T ## _ ## f ## _arrays,\ - LIST*: T ## _ ## f ## _lists, const LIST*: T ## _ ## f ## _lists,\ - MAP*: T ## _ ## f ## _maps, const MAP*: T ## _ ## f ## _maps,\ - VSET*: T ## _ ## f ## _vsets, const VSET*: T ## _ ## f ## _vsets,\ - vtype_bool*: T ## _ ## f ## _booleans, const vtype_bool*: T ## _ ## f ## _booleans,\ - vtype_uint8*: T ## _ ## f ## _uint8s, const vtype_uint8*: T ## _ ## f ## _uint8s,\ - vtype_uint16*: T ## _ ## f ## _uint16s, const vtype_uint16*: T ## _ ## f ## _uint16s,\ - vtype_uint32*: T ## _ ## f ## _uint32s, const vtype_uint32*: T ## _ ## f ## _uint32s,\ - vtype_uint64*: T ## _ ## f ## _uint64s, const vtype_uint64*: T ## _ ## f ## _uint64s,\ - vtype_int8*: T ## _ ## f ## _int8s, const vtype_int8*: T ## _ ## f ## _int8s,\ - vtype_int16*: T ## _ ## f ## _int16s, const vtype_int16*: T ## _ ## f ## _int16s,\ - vtype_int32*: T ## _ ## f ## _int32s, const vtype_int32*: T ## _ ## f ## _int32s,\ - vtype_int64*: T ## _ ## f ## _int64s, const vtype_int64*: T ## _ ## f ## _int64s,\ - vtype_float*: T ## _ ## f ## _floats, const vtype_float*: T ## _ ## f ## _floats,\ - vtype_double*: T ## _ ## f ## _doubles, const vtype_double*: T ## _ ## f ## _doubles,\ - vtype_ldouble*: T ## _ ## f ## _ldoubles, const vtype_ldouble*: T ## _ ## f ## _ldoubles\ -) - #endif /* LIBCDSB_CORE_GENERICS_H */ diff --git a/include/array.h b/include/array.h index 3e4e0f2..24b875d 100644 --- a/include/array.h +++ b/include/array.h @@ -14,7 +14,7 @@ typedef int (*array_access_callback)(void* value, ssize_t index, vtype type, voi 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 size_t array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; extern void array_sort (vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; @@ -37,6 +37,7 @@ extern void libcdsb_array_push_array (vtype_array* x, const vtype_array* value extern void libcdsb_array_push_list (vtype_array* x, const vtype_list* value) LIBCDSB_nt__ LIBCDSB_nn12__; extern void libcdsb_array_push_map (vtype_array* x, const vtype_map* value) LIBCDSB_nt__ LIBCDSB_nn12__; extern void libcdsb_array_push_vset (vtype_array* x, const vtype_set* value) LIBCDSB_nt__ LIBCDSB_nn12__; +extern void libcdsb_array_push_dict (vtype_array* x, const vtype_dict* value) LIBCDSB_nt__ LIBCDSB_nn12__; extern void libcdsb_array_push_boolean(vtype_array* x, vtype_bool value) LIBCDSB_nt__ LIBCDSB_nn1__; extern void libcdsb_array_push_uint8 (vtype_array* x, vtype_uint8 value) LIBCDSB_nt__ LIBCDSB_nn1__; extern void libcdsb_array_push_uint16 (vtype_array* x, vtype_uint16 value) LIBCDSB_nt__ LIBCDSB_nn1__; @@ -57,6 +58,7 @@ extern size_t libcdsb_array_count_array (const vtype_array* s, const vtype_arr extern size_t libcdsb_array_count_list (const vtype_array* s, const vtype_list* value); extern size_t libcdsb_array_count_map (const vtype_array* s, const vtype_map* value); extern size_t libcdsb_array_count_vset (const vtype_array* s, const vtype_set* value); +extern size_t libcdsb_array_count_dict (const vtype_array* s, const vtype_dict* value); extern size_t libcdsb_array_count_boolean(const vtype_array* s, vtype_bool value); extern size_t libcdsb_array_count_int8 (const vtype_array* s, vtype_int8 value); extern size_t libcdsb_array_count_int16 (const vtype_array* s, vtype_int16 value); @@ -70,24 +72,25 @@ extern size_t libcdsb_array_count_float (const vtype_array* s, vtype_fl extern size_t libcdsb_array_count_double (const vtype_array* s, vtype_double value); extern size_t libcdsb_array_count_ldouble(const vtype_array* s, vtype_ldouble value); -extern int libcdsb_array_find_pointer(vtype_array* x, const void* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_string (vtype_array* x, const char* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_array (vtype_array* x, const vtype_string* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_list (vtype_array* x, const vtype_array* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_map (vtype_array* x, const vtype_list* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_vset (vtype_array* x, const vtype_map* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_cstring(vtype_array* x, const vtype_set* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_boolean(vtype_array* x, vtype_bool value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint8 (vtype_array* x, vtype_uint8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint16 (vtype_array* x, vtype_uint16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint32 (vtype_array* x, vtype_uint32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint64 (vtype_array* x, vtype_uint64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int8 (vtype_array* x, vtype_int8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int16 (vtype_array* x, vtype_int16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int32 (vtype_array* x, vtype_int32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int64 (vtype_array* x, vtype_int64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_float (vtype_array* x, vtype_float value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_double (vtype_array* x, vtype_double value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_ldouble(vtype_array* x, vtype_ldouble value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_pointer(vtype_array* x, const void* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_cstring(vtype_array* x, const char* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_string (vtype_array* x, const vtype_string* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_array (vtype_array* x, const vtype_array* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_list (vtype_array* x, const vtype_list* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_map (vtype_array* x, const vtype_map* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_vset (vtype_array* x, const vtype_set* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern int libcdsb_array_find_dict (vtype_array* x, const vtype_dict* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_boolean(vtype_array* x, vtype_bool value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_uint8 (vtype_array* x, vtype_uint8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_uint16 (vtype_array* x, vtype_uint16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_uint32 (vtype_array* x, vtype_uint32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_uint64 (vtype_array* x, vtype_uint64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_int8 (vtype_array* x, vtype_int8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_int16 (vtype_array* x, vtype_int16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_int32 (vtype_array* x, vtype_int32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_int64 (vtype_array* x, vtype_int64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_float (vtype_array* x, vtype_float value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_double (vtype_array* x, vtype_double value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_ldouble(vtype_array* x, vtype_ldouble value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; #endif /* LIBCDSB_ARRAY_H */ diff --git a/include/dict.h b/include/dict.h new file mode 100644 index 0000000..a434ad4 --- /dev/null +++ b/include/dict.h @@ -0,0 +1,460 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "__generics.h" +#include "vtype.h" + +#ifndef LIBCDSB_DICT_H +#define LIBCDSB_DICT_H + +typedef int (*dict_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data); + +extern void dict_init(vtype_dict* x); + +#define dict_pop(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 1) +#define dict_get(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 0) +#define dict_update(x, key, value) _LIBCDSB_Generic2(libcdsb_dict, update, key, value)(x, key, value) +#define dict_remove(x, key) dict_pop(x, key, 0, 0) + +extern int libcdsb_dict_get_by_pointer(vtype_dict* x, const void* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_cstring(vtype_dict* x, const char* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_string (vtype_dict* x, const vtype_string* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_array (vtype_dict* x, const vtype_array* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_list (vtype_dict* x, const vtype_list* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_map (vtype_dict* x, const vtype_map* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_vset (vtype_dict* x, const vtype_set* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_dict (vtype_dict* x, const vtype_dict* key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_boolean(vtype_dict* x, vtype_bool key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_int8 (vtype_dict* x, vtype_int8 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_int16 (vtype_dict* x, vtype_int16 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_int32 (vtype_dict* x, vtype_int32 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_int64 (vtype_dict* x, vtype_int64 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_uint8 (vtype_dict* x, vtype_uint8 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_uint16 (vtype_dict* x, vtype_uint16 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_uint32 (vtype_dict* x, vtype_uint32 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_uint64 (vtype_dict* x, vtype_uint64 key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_float (vtype_dict* x, vtype_float key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_double (vtype_dict* x, vtype_double key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_ldouble(vtype_dict* x, vtype_ldouble key, void* data, dict_access_callback, bool cut); + +extern bool libcdsb_dict_update_pointer_pointer(vtype_dict* x, const void* key, const void* value); +extern bool libcdsb_dict_update_pointer_cstring(vtype_dict* x, const void* key, const char* value); +extern bool libcdsb_dict_update_pointer_string (vtype_dict* x, const void* key, const vtype_string* value); +extern bool libcdsb_dict_update_pointer_array (vtype_dict* x, const void* key, const vtype_array* value); +extern bool libcdsb_dict_update_pointer_list (vtype_dict* x, const void* key, const vtype_list* value); +extern bool libcdsb_dict_update_pointer_map (vtype_dict* x, const void* key, const vtype_map* value); +extern bool libcdsb_dict_update_pointer_vset (vtype_dict* x, const void* key, const vtype_set* value); +extern bool libcdsb_dict_update_pointer_dict (vtype_dict* x, const void* key, const vtype_dict* value); +extern bool libcdsb_dict_update_pointer_boolean(vtype_dict* x, const void* key, vtype_bool value); +extern bool libcdsb_dict_update_pointer_int8 (vtype_dict* x, const void* key, vtype_int8 value); +extern bool libcdsb_dict_update_pointer_int16 (vtype_dict* x, const void* key, vtype_int16 value); +extern bool libcdsb_dict_update_pointer_int32 (vtype_dict* x, const void* key, vtype_int32 value); +extern bool libcdsb_dict_update_pointer_int64 (vtype_dict* x, const void* key, vtype_int64 value); +extern bool libcdsb_dict_update_pointer_uint8 (vtype_dict* x, const void* key, vtype_uint8 value); +extern bool libcdsb_dict_update_pointer_uint16 (vtype_dict* x, const void* key, vtype_uint16 value); +extern bool libcdsb_dict_update_pointer_uint32 (vtype_dict* x, const void* key, vtype_uint32 value); +extern bool libcdsb_dict_update_pointer_uint64 (vtype_dict* x, const void* key, vtype_uint64 value); +extern bool libcdsb_dict_update_pointer_float (vtype_dict* x, const void* key, vtype_float value); +extern bool libcdsb_dict_update_pointer_double (vtype_dict* x, const void* key, vtype_double value); +extern bool libcdsb_dict_update_pointer_ldouble(vtype_dict* x, const void* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_string_pointer(vtype_dict* x, const vtype_string* key, const void* value); +extern bool libcdsb_dict_update_string_cstring(vtype_dict* x, const vtype_string* key, const char* value); +extern bool libcdsb_dict_update_string_string (vtype_dict* x, const vtype_string* key, const vtype_string* value); +extern bool libcdsb_dict_update_string_array (vtype_dict* x, const vtype_string* key, const vtype_array* value); +extern bool libcdsb_dict_update_string_list (vtype_dict* x, const vtype_string* key, const vtype_list* value); +extern bool libcdsb_dict_update_string_map (vtype_dict* x, const vtype_string* key, const vtype_map* value); +extern bool libcdsb_dict_update_string_vset (vtype_dict* x, const vtype_string* key, const vtype_set* value); +extern bool libcdsb_dict_update_string_dict (vtype_dict* x, const vtype_string* key, const vtype_dict* value); +extern bool libcdsb_dict_update_string_boolean(vtype_dict* x, const vtype_string* key, vtype_bool value); +extern bool libcdsb_dict_update_string_int8 (vtype_dict* x, const vtype_string* key, vtype_int8 value); +extern bool libcdsb_dict_update_string_int16 (vtype_dict* x, const vtype_string* key, vtype_int16 value); +extern bool libcdsb_dict_update_string_int32 (vtype_dict* x, const vtype_string* key, vtype_int32 value); +extern bool libcdsb_dict_update_string_int64 (vtype_dict* x, const vtype_string* key, vtype_int64 value); +extern bool libcdsb_dict_update_string_uint8 (vtype_dict* x, const vtype_string* key, vtype_uint8 value); +extern bool libcdsb_dict_update_string_uint16 (vtype_dict* x, const vtype_string* key, vtype_uint16 value); +extern bool libcdsb_dict_update_string_uint32 (vtype_dict* x, const vtype_string* key, vtype_uint32 value); +extern bool libcdsb_dict_update_string_uint64 (vtype_dict* x, const vtype_string* key, vtype_uint64 value); +extern bool libcdsb_dict_update_string_float (vtype_dict* x, const vtype_string* key, vtype_float value); +extern bool libcdsb_dict_update_string_double (vtype_dict* x, const vtype_string* key, vtype_double value); +extern bool libcdsb_dict_update_string_ldouble(vtype_dict* x, const vtype_string* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_array_pointer(vtype_dict* x, const vtype_array* key, const void* value); +extern bool libcdsb_dict_update_array_cstring(vtype_dict* x, const vtype_array* key, const char* value); +extern bool libcdsb_dict_update_array_string (vtype_dict* x, const vtype_array* key, const vtype_string* value); +extern bool libcdsb_dict_update_array_array (vtype_dict* x, const vtype_array* key, const vtype_array* value); +extern bool libcdsb_dict_update_array_list (vtype_dict* x, const vtype_array* key, const vtype_list* value); +extern bool libcdsb_dict_update_array_map (vtype_dict* x, const vtype_array* key, const vtype_map* value); +extern bool libcdsb_dict_update_array_vset (vtype_dict* x, const vtype_array* key, const vtype_set* value); +extern bool libcdsb_dict_update_array_dict (vtype_dict* x, const vtype_array* key, const vtype_dict* value); +extern bool libcdsb_dict_update_array_boolean(vtype_dict* x, const vtype_array* key, vtype_bool value); +extern bool libcdsb_dict_update_array_int8 (vtype_dict* x, const vtype_array* key, vtype_int8 value); +extern bool libcdsb_dict_update_array_int16 (vtype_dict* x, const vtype_array* key, vtype_int16 value); +extern bool libcdsb_dict_update_array_int32 (vtype_dict* x, const vtype_array* key, vtype_int32 value); +extern bool libcdsb_dict_update_array_int64 (vtype_dict* x, const vtype_array* key, vtype_int64 value); +extern bool libcdsb_dict_update_array_uint8 (vtype_dict* x, const vtype_array* key, vtype_uint8 value); +extern bool libcdsb_dict_update_array_uint16 (vtype_dict* x, const vtype_array* key, vtype_uint16 value); +extern bool libcdsb_dict_update_array_uint32 (vtype_dict* x, const vtype_array* key, vtype_uint32 value); +extern bool libcdsb_dict_update_array_uint64 (vtype_dict* x, const vtype_array* key, vtype_uint64 value); +extern bool libcdsb_dict_update_array_float (vtype_dict* x, const vtype_array* key, vtype_float value); +extern bool libcdsb_dict_update_array_double (vtype_dict* x, const vtype_array* key, vtype_double value); +extern bool libcdsb_dict_update_array_ldouble(vtype_dict* x, const vtype_array* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_list_pointer(vtype_dict* x, const vtype_list* key, const void* value); +extern bool libcdsb_dict_update_list_cstring(vtype_dict* x, const vtype_list* key, const char* value); +extern bool libcdsb_dict_update_list_string (vtype_dict* x, const vtype_list* key, const vtype_string* value); +extern bool libcdsb_dict_update_list_array (vtype_dict* x, const vtype_list* key, const vtype_array* value); +extern bool libcdsb_dict_update_list_list (vtype_dict* x, const vtype_list* key, const vtype_list* value); +extern bool libcdsb_dict_update_list_map (vtype_dict* x, const vtype_list* key, const vtype_map* value); +extern bool libcdsb_dict_update_list_vset (vtype_dict* x, const vtype_list* key, const vtype_set* value); +extern bool libcdsb_dict_update_list_dict (vtype_dict* x, const vtype_list* key, const vtype_dict* value); +extern bool libcdsb_dict_update_list_boolean(vtype_dict* x, const vtype_list* key, vtype_bool value); +extern bool libcdsb_dict_update_list_int8 (vtype_dict* x, const vtype_list* key, vtype_int8 value); +extern bool libcdsb_dict_update_list_int16 (vtype_dict* x, const vtype_list* key, vtype_int16 value); +extern bool libcdsb_dict_update_list_int32 (vtype_dict* x, const vtype_list* key, vtype_int32 value); +extern bool libcdsb_dict_update_list_int64 (vtype_dict* x, const vtype_list* key, vtype_int64 value); +extern bool libcdsb_dict_update_list_uint8 (vtype_dict* x, const vtype_list* key, vtype_uint8 value); +extern bool libcdsb_dict_update_list_uint16 (vtype_dict* x, const vtype_list* key, vtype_uint16 value); +extern bool libcdsb_dict_update_list_uint32 (vtype_dict* x, const vtype_list* key, vtype_uint32 value); +extern bool libcdsb_dict_update_list_uint64 (vtype_dict* x, const vtype_list* key, vtype_uint64 value); +extern bool libcdsb_dict_update_list_float (vtype_dict* x, const vtype_list* key, vtype_float value); +extern bool libcdsb_dict_update_list_double (vtype_dict* x, const vtype_list* key, vtype_double value); +extern bool libcdsb_dict_update_list_ldouble(vtype_dict* x, const vtype_list* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_map_pointer(vtype_dict* x, const vtype_map* key, const void* value); +extern bool libcdsb_dict_update_map_cstring(vtype_dict* x, const vtype_map* key, const char* value); +extern bool libcdsb_dict_update_map_string (vtype_dict* x, const vtype_map* key, const vtype_string* value); +extern bool libcdsb_dict_update_map_array (vtype_dict* x, const vtype_map* key, const vtype_array* value); +extern bool libcdsb_dict_update_map_list (vtype_dict* x, const vtype_map* key, const vtype_list* value); +extern bool libcdsb_dict_update_map_map (vtype_dict* x, const vtype_map* key, const vtype_map* value); +extern bool libcdsb_dict_update_map_vset (vtype_dict* x, const vtype_map* key, const vtype_set* value); +extern bool libcdsb_dict_update_map_dict (vtype_dict* x, const vtype_map* key, const vtype_dict* value); +extern bool libcdsb_dict_update_map_boolean(vtype_dict* x, const vtype_map* key, vtype_bool value); +extern bool libcdsb_dict_update_map_int8 (vtype_dict* x, const vtype_map* key, vtype_int8 value); +extern bool libcdsb_dict_update_map_int16 (vtype_dict* x, const vtype_map* key, vtype_int16 value); +extern bool libcdsb_dict_update_map_int32 (vtype_dict* x, const vtype_map* key, vtype_int32 value); +extern bool libcdsb_dict_update_map_int64 (vtype_dict* x, const vtype_map* key, vtype_int64 value); +extern bool libcdsb_dict_update_map_uint8 (vtype_dict* x, const vtype_map* key, vtype_uint8 value); +extern bool libcdsb_dict_update_map_uint16 (vtype_dict* x, const vtype_map* key, vtype_uint16 value); +extern bool libcdsb_dict_update_map_uint32 (vtype_dict* x, const vtype_map* key, vtype_uint32 value); +extern bool libcdsb_dict_update_map_uint64 (vtype_dict* x, const vtype_map* key, vtype_uint64 value); +extern bool libcdsb_dict_update_map_float (vtype_dict* x, const vtype_map* key, vtype_float value); +extern bool libcdsb_dict_update_map_double (vtype_dict* x, const vtype_map* key, vtype_double value); +extern bool libcdsb_dict_update_map_ldouble(vtype_dict* x, const vtype_map* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_vset_pointer(vtype_dict* x, const vtype_set* key, const void* value); +extern bool libcdsb_dict_update_vset_cstring(vtype_dict* x, const vtype_set* key, const char* value); +extern bool libcdsb_dict_update_vset_string (vtype_dict* x, const vtype_set* key, const vtype_string* value); +extern bool libcdsb_dict_update_vset_array (vtype_dict* x, const vtype_set* key, const vtype_array* value); +extern bool libcdsb_dict_update_vset_list (vtype_dict* x, const vtype_set* key, const vtype_list* value); +extern bool libcdsb_dict_update_vset_map (vtype_dict* x, const vtype_set* key, const vtype_map* value); +extern bool libcdsb_dict_update_vset_vset (vtype_dict* x, const vtype_set* key, const vtype_set* value); +extern bool libcdsb_dict_update_vset_dict (vtype_dict* x, const vtype_set* key, const vtype_dict* value); +extern bool libcdsb_dict_update_vset_boolean(vtype_dict* x, const vtype_set* key, vtype_bool value); +extern bool libcdsb_dict_update_vset_int8 (vtype_dict* x, const vtype_set* key, vtype_int8 value); +extern bool libcdsb_dict_update_vset_int16 (vtype_dict* x, const vtype_set* key, vtype_int16 value); +extern bool libcdsb_dict_update_vset_int32 (vtype_dict* x, const vtype_set* key, vtype_int32 value); +extern bool libcdsb_dict_update_vset_int64 (vtype_dict* x, const vtype_set* key, vtype_int64 value); +extern bool libcdsb_dict_update_vset_uint8 (vtype_dict* x, const vtype_set* key, vtype_uint8 value); +extern bool libcdsb_dict_update_vset_uint16 (vtype_dict* x, const vtype_set* key, vtype_uint16 value); +extern bool libcdsb_dict_update_vset_uint32 (vtype_dict* x, const vtype_set* key, vtype_uint32 value); +extern bool libcdsb_dict_update_vset_uint64 (vtype_dict* x, const vtype_set* key, vtype_uint64 value); +extern bool libcdsb_dict_update_vset_float (vtype_dict* x, const vtype_set* key, vtype_float value); +extern bool libcdsb_dict_update_vset_double (vtype_dict* x, const vtype_set* key, vtype_double value); +extern bool libcdsb_dict_update_vset_ldouble(vtype_dict* x, const vtype_set* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_dict_pointer(vtype_dict* x, const vtype_dict* key, const void* value); +extern bool libcdsb_dict_update_dict_cstring(vtype_dict* x, const vtype_dict* key, const char* value); +extern bool libcdsb_dict_update_dict_string (vtype_dict* x, const vtype_dict* key, const vtype_string* value); +extern bool libcdsb_dict_update_dict_array (vtype_dict* x, const vtype_dict* key, const vtype_array* value); +extern bool libcdsb_dict_update_dict_list (vtype_dict* x, const vtype_dict* key, const vtype_list* value); +extern bool libcdsb_dict_update_dict_map (vtype_dict* x, const vtype_dict* key, const vtype_map* value); +extern bool libcdsb_dict_update_dict_vset (vtype_dict* x, const vtype_dict* key, const vtype_set* value); +extern bool libcdsb_dict_update_dict_dict (vtype_dict* x, const vtype_dict* key, const vtype_dict* value); +extern bool libcdsb_dict_update_dict_boolean(vtype_dict* x, const vtype_dict* key, vtype_bool value); +extern bool libcdsb_dict_update_dict_int8 (vtype_dict* x, const vtype_dict* key, vtype_int8 value); +extern bool libcdsb_dict_update_dict_int16 (vtype_dict* x, const vtype_dict* key, vtype_int16 value); +extern bool libcdsb_dict_update_dict_int32 (vtype_dict* x, const vtype_dict* key, vtype_int32 value); +extern bool libcdsb_dict_update_dict_int64 (vtype_dict* x, const vtype_dict* key, vtype_int64 value); +extern bool libcdsb_dict_update_dict_uint8 (vtype_dict* x, const vtype_dict* key, vtype_uint8 value); +extern bool libcdsb_dict_update_dict_uint16 (vtype_dict* x, const vtype_dict* key, vtype_uint16 value); +extern bool libcdsb_dict_update_dict_uint32 (vtype_dict* x, const vtype_dict* key, vtype_uint32 value); +extern bool libcdsb_dict_update_dict_uint64 (vtype_dict* x, const vtype_dict* key, vtype_uint64 value); +extern bool libcdsb_dict_update_dict_float (vtype_dict* x, const vtype_dict* key, vtype_float value); +extern bool libcdsb_dict_update_dict_double (vtype_dict* x, const vtype_dict* key, vtype_double value); +extern bool libcdsb_dict_update_dict_ldouble(vtype_dict* x, const vtype_dict* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_cstring_pointer(vtype_dict* x, const char* key, const void* value); +extern bool libcdsb_dict_update_cstring_cstring(vtype_dict* x, const char* key, const char* value); +extern bool libcdsb_dict_update_cstring_string (vtype_dict* x, const char* key, const vtype_string* value); +extern bool libcdsb_dict_update_cstring_array (vtype_dict* x, const char* key, const vtype_array* value); +extern bool libcdsb_dict_update_cstring_list (vtype_dict* x, const char* key, const vtype_list* value); +extern bool libcdsb_dict_update_cstring_map (vtype_dict* x, const char* key, const vtype_map* value); +extern bool libcdsb_dict_update_cstring_vset (vtype_dict* x, const char* key, const vtype_set* value); +extern bool libcdsb_dict_update_cstring_dict (vtype_dict* x, const char* key, const vtype_dict* value); +extern bool libcdsb_dict_update_cstring_boolean(vtype_dict* x, const char* key, vtype_bool value); +extern bool libcdsb_dict_update_cstring_int8 (vtype_dict* x, const char* key, vtype_int8 value); +extern bool libcdsb_dict_update_cstring_int16 (vtype_dict* x, const char* key, vtype_int16 value); +extern bool libcdsb_dict_update_cstring_int32 (vtype_dict* x, const char* key, vtype_int32 value); +extern bool libcdsb_dict_update_cstring_int64 (vtype_dict* x, const char* key, vtype_int64 value); +extern bool libcdsb_dict_update_cstring_uint8 (vtype_dict* x, const char* key, vtype_uint8 value); +extern bool libcdsb_dict_update_cstring_uint16 (vtype_dict* x, const char* key, vtype_uint16 value); +extern bool libcdsb_dict_update_cstring_uint32 (vtype_dict* x, const char* key, vtype_uint32 value); +extern bool libcdsb_dict_update_cstring_uint64 (vtype_dict* x, const char* key, vtype_uint64 value); +extern bool libcdsb_dict_update_cstring_float (vtype_dict* x, const char* key, vtype_float value); +extern bool libcdsb_dict_update_cstring_double (vtype_dict* x, const char* key, vtype_double value); +extern bool libcdsb_dict_update_cstring_ldouble(vtype_dict* x, const char* key, vtype_ldouble value); + +extern bool libcdsb_dict_update_boolean_pointer(vtype_dict* x, vtype_bool key, const void* value); +extern bool libcdsb_dict_update_boolean_cstring(vtype_dict* x, vtype_bool key, const char* value); +extern bool libcdsb_dict_update_boolean_string (vtype_dict* x, vtype_bool key, const vtype_string* value); +extern bool libcdsb_dict_update_boolean_array (vtype_dict* x, vtype_bool key, const vtype_array* value); +extern bool libcdsb_dict_update_boolean_list (vtype_dict* x, vtype_bool key, const vtype_list* value); +extern bool libcdsb_dict_update_boolean_map (vtype_dict* x, vtype_bool key, const vtype_map* value); +extern bool libcdsb_dict_update_boolean_vset (vtype_dict* x, vtype_bool key, const vtype_set* value); +extern bool libcdsb_dict_update_boolean_dict (vtype_dict* x, vtype_bool key, const vtype_dict* value); +extern bool libcdsb_dict_update_boolean_boolean(vtype_dict* x, vtype_bool key, vtype_bool value); +extern bool libcdsb_dict_update_boolean_int8 (vtype_dict* x, vtype_bool key, vtype_int8 value); +extern bool libcdsb_dict_update_boolean_int16 (vtype_dict* x, vtype_bool key, vtype_int16 value); +extern bool libcdsb_dict_update_boolean_int32 (vtype_dict* x, vtype_bool key, vtype_int32 value); +extern bool libcdsb_dict_update_boolean_int64 (vtype_dict* x, vtype_bool key, vtype_int64 value); +extern bool libcdsb_dict_update_boolean_uint8 (vtype_dict* x, vtype_bool key, vtype_uint8 value); +extern bool libcdsb_dict_update_boolean_uint16 (vtype_dict* x, vtype_bool key, vtype_uint16 value); +extern bool libcdsb_dict_update_boolean_uint32 (vtype_dict* x, vtype_bool key, vtype_uint32 value); +extern bool libcdsb_dict_update_boolean_uint64 (vtype_dict* x, vtype_bool key, vtype_uint64 value); +extern bool libcdsb_dict_update_boolean_float (vtype_dict* x, vtype_bool key, vtype_float value); +extern bool libcdsb_dict_update_boolean_double (vtype_dict* x, vtype_bool key, vtype_double value); +extern bool libcdsb_dict_update_boolean_ldouble(vtype_dict* x, vtype_bool key, vtype_ldouble value); + +extern bool libcdsb_dict_update_uint8_pointer(vtype_dict* x, vtype_uint8 key, const void* value); +extern bool libcdsb_dict_update_uint8_cstring(vtype_dict* x, vtype_uint8 key, const char* value); +extern bool libcdsb_dict_update_uint8_string (vtype_dict* x, vtype_uint8 key, const vtype_string* value); +extern bool libcdsb_dict_update_uint8_array (vtype_dict* x, vtype_uint8 key, const vtype_array* value); +extern bool libcdsb_dict_update_uint8_list (vtype_dict* x, vtype_uint8 key, const vtype_list* value); +extern bool libcdsb_dict_update_uint8_map (vtype_dict* x, vtype_uint8 key, const vtype_map* value); +extern bool libcdsb_dict_update_uint8_vset (vtype_dict* x, vtype_uint8 key, const vtype_set* value); +extern bool libcdsb_dict_update_uint8_dict (vtype_dict* x, vtype_uint8 key, const vtype_dict* value); +extern bool libcdsb_dict_update_uint8_boolean(vtype_dict* x, vtype_uint8 key, vtype_bool value); +extern bool libcdsb_dict_update_uint8_int8 (vtype_dict* x, vtype_uint8 key, vtype_int8 value); +extern bool libcdsb_dict_update_uint8_int16 (vtype_dict* x, vtype_uint8 key, vtype_int16 value); +extern bool libcdsb_dict_update_uint8_int32 (vtype_dict* x, vtype_uint8 key, vtype_int32 value); +extern bool libcdsb_dict_update_uint8_int64 (vtype_dict* x, vtype_uint8 key, vtype_int64 value); +extern bool libcdsb_dict_update_uint8_uint8 (vtype_dict* x, vtype_uint8 key, vtype_uint8 value); +extern bool libcdsb_dict_update_uint8_uint16 (vtype_dict* x, vtype_uint8 key, vtype_uint16 value); +extern bool libcdsb_dict_update_uint8_uint32 (vtype_dict* x, vtype_uint8 key, vtype_uint32 value); +extern bool libcdsb_dict_update_uint8_uint64 (vtype_dict* x, vtype_uint8 key, vtype_uint64 value); +extern bool libcdsb_dict_update_uint8_float (vtype_dict* x, vtype_uint8 key, vtype_float value); +extern bool libcdsb_dict_update_uint8_double (vtype_dict* x, vtype_uint8 key, vtype_double value); +extern bool libcdsb_dict_update_uint8_ldouble(vtype_dict* x, vtype_uint8 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_uint16_pointer(vtype_dict* x, vtype_uint16 key, const void* value); +extern bool libcdsb_dict_update_uint16_cstring(vtype_dict* x, vtype_uint16 key, const char* value); +extern bool libcdsb_dict_update_uint16_string (vtype_dict* x, vtype_uint16 key, const vtype_string* value); +extern bool libcdsb_dict_update_uint16_array (vtype_dict* x, vtype_uint16 key, const vtype_array* value); +extern bool libcdsb_dict_update_uint16_list (vtype_dict* x, vtype_uint16 key, const vtype_list* value); +extern bool libcdsb_dict_update_uint16_map (vtype_dict* x, vtype_uint16 key, const vtype_map* value); +extern bool libcdsb_dict_update_uint16_vset (vtype_dict* x, vtype_uint16 key, const vtype_set* value); +extern bool libcdsb_dict_update_uint16_dict (vtype_dict* x, vtype_uint16 key, const vtype_dict* value); +extern bool libcdsb_dict_update_uint16_boolean(vtype_dict* x, vtype_uint16 key, vtype_bool value); +extern bool libcdsb_dict_update_uint16_int8 (vtype_dict* x, vtype_uint16 key, vtype_int8 value); +extern bool libcdsb_dict_update_uint16_int16 (vtype_dict* x, vtype_uint16 key, vtype_int16 value); +extern bool libcdsb_dict_update_uint16_int32 (vtype_dict* x, vtype_uint16 key, vtype_int32 value); +extern bool libcdsb_dict_update_uint16_int64 (vtype_dict* x, vtype_uint16 key, vtype_int64 value); +extern bool libcdsb_dict_update_uint16_uint8 (vtype_dict* x, vtype_uint16 key, vtype_uint8 value); +extern bool libcdsb_dict_update_uint16_uint16 (vtype_dict* x, vtype_uint16 key, vtype_uint16 value); +extern bool libcdsb_dict_update_uint16_uint32 (vtype_dict* x, vtype_uint16 key, vtype_uint32 value); +extern bool libcdsb_dict_update_uint16_uint64 (vtype_dict* x, vtype_uint16 key, vtype_uint64 value); +extern bool libcdsb_dict_update_uint16_float (vtype_dict* x, vtype_uint16 key, vtype_float value); +extern bool libcdsb_dict_update_uint16_double (vtype_dict* x, vtype_uint16 key, vtype_double value); +extern bool libcdsb_dict_update_uint16_ldouble(vtype_dict* x, vtype_uint16 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_uint32_pointer(vtype_dict* x, vtype_uint32 key, const void* value); +extern bool libcdsb_dict_update_uint32_cstring(vtype_dict* x, vtype_uint32 key, const char* value); +extern bool libcdsb_dict_update_uint32_string (vtype_dict* x, vtype_uint32 key, const vtype_string* value); +extern bool libcdsb_dict_update_uint32_array (vtype_dict* x, vtype_uint32 key, const vtype_array* value); +extern bool libcdsb_dict_update_uint32_list (vtype_dict* x, vtype_uint32 key, const vtype_list* value); +extern bool libcdsb_dict_update_uint32_map (vtype_dict* x, vtype_uint32 key, const vtype_map* value); +extern bool libcdsb_dict_update_uint32_vset (vtype_dict* x, vtype_uint32 key, const vtype_set* value); +extern bool libcdsb_dict_update_uint32_dict (vtype_dict* x, vtype_uint32 key, const vtype_dict* value); +extern bool libcdsb_dict_update_uint32_boolean(vtype_dict* x, vtype_uint32 key, vtype_bool value); +extern bool libcdsb_dict_update_uint32_int8 (vtype_dict* x, vtype_uint32 key, vtype_int8 value); +extern bool libcdsb_dict_update_uint32_int16 (vtype_dict* x, vtype_uint32 key, vtype_int16 value); +extern bool libcdsb_dict_update_uint32_int32 (vtype_dict* x, vtype_uint32 key, vtype_int32 value); +extern bool libcdsb_dict_update_uint32_int64 (vtype_dict* x, vtype_uint32 key, vtype_int64 value); +extern bool libcdsb_dict_update_uint32_uint8 (vtype_dict* x, vtype_uint32 key, vtype_uint8 value); +extern bool libcdsb_dict_update_uint32_uint16 (vtype_dict* x, vtype_uint32 key, vtype_uint16 value); +extern bool libcdsb_dict_update_uint32_uint32 (vtype_dict* x, vtype_uint32 key, vtype_uint32 value); +extern bool libcdsb_dict_update_uint32_uint64 (vtype_dict* x, vtype_uint32 key, vtype_uint64 value); +extern bool libcdsb_dict_update_uint32_float (vtype_dict* x, vtype_uint32 key, vtype_float value); +extern bool libcdsb_dict_update_uint32_double (vtype_dict* x, vtype_uint32 key, vtype_double value); +extern bool libcdsb_dict_update_uint32_ldouble(vtype_dict* x, vtype_uint32 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_uint64_pointer(vtype_dict* x, vtype_uint64 key, const void* value); +extern bool libcdsb_dict_update_uint64_cstring(vtype_dict* x, vtype_uint64 key, const char* value); +extern bool libcdsb_dict_update_uint64_string (vtype_dict* x, vtype_uint64 key, const vtype_string* value); +extern bool libcdsb_dict_update_uint64_array (vtype_dict* x, vtype_uint64 key, const vtype_array* value); +extern bool libcdsb_dict_update_uint64_list (vtype_dict* x, vtype_uint64 key, const vtype_list* value); +extern bool libcdsb_dict_update_uint64_map (vtype_dict* x, vtype_uint64 key, const vtype_map* value); +extern bool libcdsb_dict_update_uint64_vset (vtype_dict* x, vtype_uint64 key, const vtype_set* value); +extern bool libcdsb_dict_update_uint64_dict (vtype_dict* x, vtype_uint64 key, const vtype_dict* value); +extern bool libcdsb_dict_update_uint64_boolean(vtype_dict* x, vtype_uint64 key, vtype_bool value); +extern bool libcdsb_dict_update_uint64_int8 (vtype_dict* x, vtype_uint64 key, vtype_int8 value); +extern bool libcdsb_dict_update_uint64_int16 (vtype_dict* x, vtype_uint64 key, vtype_int16 value); +extern bool libcdsb_dict_update_uint64_int32 (vtype_dict* x, vtype_uint64 key, vtype_int32 value); +extern bool libcdsb_dict_update_uint64_int64 (vtype_dict* x, vtype_uint64 key, vtype_int64 value); +extern bool libcdsb_dict_update_uint64_uint8 (vtype_dict* x, vtype_uint64 key, vtype_uint8 value); +extern bool libcdsb_dict_update_uint64_uint16 (vtype_dict* x, vtype_uint64 key, vtype_uint16 value); +extern bool libcdsb_dict_update_uint64_uint32 (vtype_dict* x, vtype_uint64 key, vtype_uint32 value); +extern bool libcdsb_dict_update_uint64_uint64 (vtype_dict* x, vtype_uint64 key, vtype_uint64 value); +extern bool libcdsb_dict_update_uint64_float (vtype_dict* x, vtype_uint64 key, vtype_float value); +extern bool libcdsb_dict_update_uint64_double (vtype_dict* x, vtype_uint64 key, vtype_double value); +extern bool libcdsb_dict_update_uint64_ldouble(vtype_dict* x, vtype_uint64 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_int8_pointer(vtype_dict* x, vtype_int8 key, const void* value); +extern bool libcdsb_dict_update_int8_cstring(vtype_dict* x, vtype_int8 key, const char* value); +extern bool libcdsb_dict_update_int8_string (vtype_dict* x, vtype_int8 key, const vtype_string* value); +extern bool libcdsb_dict_update_int8_array (vtype_dict* x, vtype_int8 key, const vtype_array* value); +extern bool libcdsb_dict_update_int8_list (vtype_dict* x, vtype_int8 key, const vtype_list* value); +extern bool libcdsb_dict_update_int8_map (vtype_dict* x, vtype_int8 key, const vtype_map* value); +extern bool libcdsb_dict_update_int8_vset (vtype_dict* x, vtype_int8 key, const vtype_set* value); +extern bool libcdsb_dict_update_int8_dict (vtype_dict* x, vtype_int8 key, const vtype_dict* value); +extern bool libcdsb_dict_update_int8_boolean(vtype_dict* x, vtype_int8 key, vtype_bool value); +extern bool libcdsb_dict_update_int8_int8 (vtype_dict* x, vtype_int8 key, vtype_int8 value); +extern bool libcdsb_dict_update_int8_int16 (vtype_dict* x, vtype_int8 key, vtype_int16 value); +extern bool libcdsb_dict_update_int8_int32 (vtype_dict* x, vtype_int8 key, vtype_int32 value); +extern bool libcdsb_dict_update_int8_int64 (vtype_dict* x, vtype_int8 key, vtype_int64 value); +extern bool libcdsb_dict_update_int8_uint8 (vtype_dict* x, vtype_int8 key, vtype_uint8 value); +extern bool libcdsb_dict_update_int8_uint16 (vtype_dict* x, vtype_int8 key, vtype_uint16 value); +extern bool libcdsb_dict_update_int8_uint32 (vtype_dict* x, vtype_int8 key, vtype_uint32 value); +extern bool libcdsb_dict_update_int8_uint64 (vtype_dict* x, vtype_int8 key, vtype_uint64 value); +extern bool libcdsb_dict_update_int8_float (vtype_dict* x, vtype_int8 key, vtype_float value); +extern bool libcdsb_dict_update_int8_double (vtype_dict* x, vtype_int8 key, vtype_double value); +extern bool libcdsb_dict_update_int8_ldouble(vtype_dict* x, vtype_int8 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_int16_pointer(vtype_dict* x, vtype_int16 key, const void* value); +extern bool libcdsb_dict_update_int16_cstring(vtype_dict* x, vtype_int16 key, const char* value); +extern bool libcdsb_dict_update_int16_string (vtype_dict* x, vtype_int16 key, const vtype_string* value); +extern bool libcdsb_dict_update_int16_array (vtype_dict* x, vtype_int16 key, const vtype_array* value); +extern bool libcdsb_dict_update_int16_list (vtype_dict* x, vtype_int16 key, const vtype_list* value); +extern bool libcdsb_dict_update_int16_map (vtype_dict* x, vtype_int16 key, const vtype_map* value); +extern bool libcdsb_dict_update_int16_vset (vtype_dict* x, vtype_int16 key, const vtype_set* value); +extern bool libcdsb_dict_update_int16_dict (vtype_dict* x, vtype_int16 key, const vtype_dict* value); +extern bool libcdsb_dict_update_int16_boolean(vtype_dict* x, vtype_int16 key, vtype_bool value); +extern bool libcdsb_dict_update_int16_int8 (vtype_dict* x, vtype_int16 key, vtype_int8 value); +extern bool libcdsb_dict_update_int16_int16 (vtype_dict* x, vtype_int16 key, vtype_int16 value); +extern bool libcdsb_dict_update_int16_int32 (vtype_dict* x, vtype_int16 key, vtype_int32 value); +extern bool libcdsb_dict_update_int16_int64 (vtype_dict* x, vtype_int16 key, vtype_int64 value); +extern bool libcdsb_dict_update_int16_uint8 (vtype_dict* x, vtype_int16 key, vtype_uint8 value); +extern bool libcdsb_dict_update_int16_uint16 (vtype_dict* x, vtype_int16 key, vtype_uint16 value); +extern bool libcdsb_dict_update_int16_uint32 (vtype_dict* x, vtype_int16 key, vtype_uint32 value); +extern bool libcdsb_dict_update_int16_uint64 (vtype_dict* x, vtype_int16 key, vtype_uint64 value); +extern bool libcdsb_dict_update_int16_float (vtype_dict* x, vtype_int16 key, vtype_float value); +extern bool libcdsb_dict_update_int16_double (vtype_dict* x, vtype_int16 key, vtype_double value); +extern bool libcdsb_dict_update_int16_ldouble(vtype_dict* x, vtype_int16 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_int32_pointer(vtype_dict* x, vtype_int32 key, const void* value); +extern bool libcdsb_dict_update_int32_cstring(vtype_dict* x, vtype_int32 key, const char* value); +extern bool libcdsb_dict_update_int32_string (vtype_dict* x, vtype_int32 key, const vtype_string* value); +extern bool libcdsb_dict_update_int32_array (vtype_dict* x, vtype_int32 key, const vtype_array* value); +extern bool libcdsb_dict_update_int32_list (vtype_dict* x, vtype_int32 key, const vtype_list* value); +extern bool libcdsb_dict_update_int32_map (vtype_dict* x, vtype_int32 key, const vtype_map* value); +extern bool libcdsb_dict_update_int32_vset (vtype_dict* x, vtype_int32 key, const vtype_set* value); +extern bool libcdsb_dict_update_int32_dict (vtype_dict* x, vtype_int32 key, const vtype_dict* value); +extern bool libcdsb_dict_update_int32_boolean(vtype_dict* x, vtype_int32 key, vtype_bool value); +extern bool libcdsb_dict_update_int32_int8 (vtype_dict* x, vtype_int32 key, vtype_int8 value); +extern bool libcdsb_dict_update_int32_int16 (vtype_dict* x, vtype_int32 key, vtype_int16 value); +extern bool libcdsb_dict_update_int32_int32 (vtype_dict* x, vtype_int32 key, vtype_int32 value); +extern bool libcdsb_dict_update_int32_int64 (vtype_dict* x, vtype_int32 key, vtype_int64 value); +extern bool libcdsb_dict_update_int32_uint8 (vtype_dict* x, vtype_int32 key, vtype_uint8 value); +extern bool libcdsb_dict_update_int32_uint16 (vtype_dict* x, vtype_int32 key, vtype_uint16 value); +extern bool libcdsb_dict_update_int32_uint32 (vtype_dict* x, vtype_int32 key, vtype_uint32 value); +extern bool libcdsb_dict_update_int32_uint64 (vtype_dict* x, vtype_int32 key, vtype_uint64 value); +extern bool libcdsb_dict_update_int32_float (vtype_dict* x, vtype_int32 key, vtype_float value); +extern bool libcdsb_dict_update_int32_double (vtype_dict* x, vtype_int32 key, vtype_double value); +extern bool libcdsb_dict_update_int32_ldouble(vtype_dict* x, vtype_int32 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_int64_pointer(vtype_dict* x, vtype_int64 key, const void* value); +extern bool libcdsb_dict_update_int64_cstring(vtype_dict* x, vtype_int64 key, const char* value); +extern bool libcdsb_dict_update_int64_string (vtype_dict* x, vtype_int64 key, const vtype_string* value); +extern bool libcdsb_dict_update_int64_array (vtype_dict* x, vtype_int64 key, const vtype_array* value); +extern bool libcdsb_dict_update_int64_list (vtype_dict* x, vtype_int64 key, const vtype_list* value); +extern bool libcdsb_dict_update_int64_map (vtype_dict* x, vtype_int64 key, const vtype_map* value); +extern bool libcdsb_dict_update_int64_vset (vtype_dict* x, vtype_int64 key, const vtype_set* value); +extern bool libcdsb_dict_update_int64_dict (vtype_dict* x, vtype_int64 key, const vtype_dict* value); +extern bool libcdsb_dict_update_int64_boolean(vtype_dict* x, vtype_int64 key, vtype_bool value); +extern bool libcdsb_dict_update_int64_int8 (vtype_dict* x, vtype_int64 key, vtype_int8 value); +extern bool libcdsb_dict_update_int64_int16 (vtype_dict* x, vtype_int64 key, vtype_int16 value); +extern bool libcdsb_dict_update_int64_int32 (vtype_dict* x, vtype_int64 key, vtype_int32 value); +extern bool libcdsb_dict_update_int64_int64 (vtype_dict* x, vtype_int64 key, vtype_int64 value); +extern bool libcdsb_dict_update_int64_uint8 (vtype_dict* x, vtype_int64 key, vtype_uint8 value); +extern bool libcdsb_dict_update_int64_uint16 (vtype_dict* x, vtype_int64 key, vtype_uint16 value); +extern bool libcdsb_dict_update_int64_uint32 (vtype_dict* x, vtype_int64 key, vtype_uint32 value); +extern bool libcdsb_dict_update_int64_uint64 (vtype_dict* x, vtype_int64 key, vtype_uint64 value); +extern bool libcdsb_dict_update_int64_float (vtype_dict* x, vtype_int64 key, vtype_float value); +extern bool libcdsb_dict_update_int64_double (vtype_dict* x, vtype_int64 key, vtype_double value); +extern bool libcdsb_dict_update_int64_ldouble(vtype_dict* x, vtype_int64 key, vtype_ldouble value); + +extern bool libcdsb_dict_update_float_pointer(vtype_dict* x, vtype_float key, const void* value); +extern bool libcdsb_dict_update_float_cstring(vtype_dict* x, vtype_float key, const char* value); +extern bool libcdsb_dict_update_float_string (vtype_dict* x, vtype_float key, const vtype_string* value); +extern bool libcdsb_dict_update_float_array (vtype_dict* x, vtype_float key, const vtype_array* value); +extern bool libcdsb_dict_update_float_list (vtype_dict* x, vtype_float key, const vtype_list* value); +extern bool libcdsb_dict_update_float_map (vtype_dict* x, vtype_float key, const vtype_map* value); +extern bool libcdsb_dict_update_float_vset (vtype_dict* x, vtype_float key, const vtype_set* value); +extern bool libcdsb_dict_update_float_dict (vtype_dict* x, vtype_float key, const vtype_dict* value); +extern bool libcdsb_dict_update_float_boolean(vtype_dict* x, vtype_float key, vtype_bool value); +extern bool libcdsb_dict_update_float_int8 (vtype_dict* x, vtype_float key, vtype_int8 value); +extern bool libcdsb_dict_update_float_int16 (vtype_dict* x, vtype_float key, vtype_int16 value); +extern bool libcdsb_dict_update_float_int32 (vtype_dict* x, vtype_float key, vtype_int32 value); +extern bool libcdsb_dict_update_float_int64 (vtype_dict* x, vtype_float key, vtype_int64 value); +extern bool libcdsb_dict_update_float_uint8 (vtype_dict* x, vtype_float key, vtype_uint8 value); +extern bool libcdsb_dict_update_float_uint16 (vtype_dict* x, vtype_float key, vtype_uint16 value); +extern bool libcdsb_dict_update_float_uint32 (vtype_dict* x, vtype_float key, vtype_uint32 value); +extern bool libcdsb_dict_update_float_uint64 (vtype_dict* x, vtype_float key, vtype_uint64 value); +extern bool libcdsb_dict_update_float_float (vtype_dict* x, vtype_float key, vtype_float value); +extern bool libcdsb_dict_update_float_double (vtype_dict* x, vtype_float key, vtype_double value); +extern bool libcdsb_dict_update_float_ldouble(vtype_dict* x, vtype_float key, vtype_ldouble value); + +extern bool libcdsb_dict_update_double_pointer(vtype_dict* x, vtype_double key, const void* value); +extern bool libcdsb_dict_update_double_cstring(vtype_dict* x, vtype_double key, const char* value); +extern bool libcdsb_dict_update_double_string (vtype_dict* x, vtype_double key, const vtype_string* value); +extern bool libcdsb_dict_update_double_array (vtype_dict* x, vtype_double key, const vtype_array* value); +extern bool libcdsb_dict_update_double_list (vtype_dict* x, vtype_double key, const vtype_list* value); +extern bool libcdsb_dict_update_double_map (vtype_dict* x, vtype_double key, const vtype_map* value); +extern bool libcdsb_dict_update_double_vset (vtype_dict* x, vtype_double key, const vtype_set* value); +extern bool libcdsb_dict_update_double_dict (vtype_dict* x, vtype_double key, const vtype_dict* value); +extern bool libcdsb_dict_update_double_boolean(vtype_dict* x, vtype_double key, vtype_bool value); +extern bool libcdsb_dict_update_double_int8 (vtype_dict* x, vtype_double key, vtype_int8 value); +extern bool libcdsb_dict_update_double_int16 (vtype_dict* x, vtype_double key, vtype_int16 value); +extern bool libcdsb_dict_update_double_int32 (vtype_dict* x, vtype_double key, vtype_int32 value); +extern bool libcdsb_dict_update_double_int64 (vtype_dict* x, vtype_double key, vtype_int64 value); +extern bool libcdsb_dict_update_double_uint8 (vtype_dict* x, vtype_double key, vtype_uint8 value); +extern bool libcdsb_dict_update_double_uint16 (vtype_dict* x, vtype_double key, vtype_uint16 value); +extern bool libcdsb_dict_update_double_uint32 (vtype_dict* x, vtype_double key, vtype_uint32 value); +extern bool libcdsb_dict_update_double_uint64 (vtype_dict* x, vtype_double key, vtype_uint64 value); +extern bool libcdsb_dict_update_double_float (vtype_dict* x, vtype_double key, vtype_float value); +extern bool libcdsb_dict_update_double_double (vtype_dict* x, vtype_double key, vtype_double value); +extern bool libcdsb_dict_update_double_ldouble(vtype_dict* x, vtype_double key, vtype_ldouble value); + +extern bool libcdsb_dict_update_ldouble_pointer(vtype_dict* x, vtype_ldouble key, const void* value); +extern bool libcdsb_dict_update_ldouble_cstring(vtype_dict* x, vtype_ldouble key, const char* value); +extern bool libcdsb_dict_update_ldouble_string (vtype_dict* x, vtype_ldouble key, const vtype_string* value); +extern bool libcdsb_dict_update_ldouble_array (vtype_dict* x, vtype_ldouble key, const vtype_array* value); +extern bool libcdsb_dict_update_ldouble_list (vtype_dict* x, vtype_ldouble key, const vtype_list* value); +extern bool libcdsb_dict_update_ldouble_map (vtype_dict* x, vtype_ldouble key, const vtype_map* value); +extern bool libcdsb_dict_update_ldouble_vset (vtype_dict* x, vtype_ldouble key, const vtype_set* value); +extern bool libcdsb_dict_update_ldouble_dict (vtype_dict* x, vtype_ldouble key, const vtype_dict* value); +extern bool libcdsb_dict_update_ldouble_boolean(vtype_dict* x, vtype_ldouble key, vtype_bool value); +extern bool libcdsb_dict_update_ldouble_int8 (vtype_dict* x, vtype_ldouble key, vtype_int8 value); +extern bool libcdsb_dict_update_ldouble_int16 (vtype_dict* x, vtype_ldouble key, vtype_int16 value); +extern bool libcdsb_dict_update_ldouble_int32 (vtype_dict* x, vtype_ldouble key, vtype_int32 value); +extern bool libcdsb_dict_update_ldouble_int64 (vtype_dict* x, vtype_ldouble key, vtype_int64 value); +extern bool libcdsb_dict_update_ldouble_uint8 (vtype_dict* x, vtype_ldouble key, vtype_uint8 value); +extern bool libcdsb_dict_update_ldouble_uint16 (vtype_dict* x, vtype_ldouble key, vtype_uint16 value); +extern bool libcdsb_dict_update_ldouble_uint32 (vtype_dict* x, vtype_ldouble key, vtype_uint32 value); +extern bool libcdsb_dict_update_ldouble_uint64 (vtype_dict* x, vtype_ldouble key, vtype_uint64 value); +extern bool libcdsb_dict_update_ldouble_float (vtype_dict* x, vtype_ldouble key, vtype_float value); +extern bool libcdsb_dict_update_ldouble_double (vtype_dict* x, vtype_ldouble key, vtype_double value); +extern bool libcdsb_dict_update_ldouble_ldouble(vtype_dict* x, vtype_ldouble key, vtype_ldouble value); + +#endif /* LIBCDSB_DICT_H */ diff --git a/include/extra/dict.h b/include/extra/dict.h new file mode 100644 index 0000000..9c5853c --- /dev/null +++ b/include/extra/dict.h @@ -0,0 +1,18 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../dict.h" + +#ifndef LIBCDSB_EXTRA_DICT_H +#define LIBCDSB_EXTRA_DICT_H + +#define dict_foreach(x, data, callback) libcdsb_dict_foreach(x, data, callback, 0) + +extern bool libcdsb_dict_update(vtype_dict* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__; + +extern int libcdsb_dict_get (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_dict_foreach(vtype_dict* x, void* data, dict_access_callback, bool flush) LIBCDSB_nt__ LIBCDSB_nn13__; + +extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) LIBCDSB_nt__ LIBCDSB_nn1__; + +#endif /* LIBCDSB_EXTRA_DICT_H */ diff --git a/include/list.h b/include/list.h index f9adbed..6e35293 100644 --- a/include/list.h +++ b/include/list.h @@ -40,6 +40,7 @@ extern int libcdsb_list_find_array (vtype_list* x, const vtype_array* value, v 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_dict (vtype_list* x, const vtype_dict* 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); @@ -60,6 +61,7 @@ extern size_t libcdsb_list_count_array (const vtype_list* s, const vtype_array extern size_t libcdsb_list_count_list (const vtype_list* s, const vtype_list* value); extern size_t libcdsb_list_count_map (const vtype_list* s, const vtype_map* value); extern size_t libcdsb_list_count_vset (const vtype_list* s, const vtype_set* value); +extern size_t libcdsb_list_count_dict (const vtype_list* s, const vtype_dict* value); extern size_t libcdsb_list_count_boolean(const vtype_list* s, vtype_bool value); extern size_t libcdsb_list_count_int8 (const vtype_list* s, vtype_int8 value); extern size_t libcdsb_list_count_int16 (const vtype_list* s, vtype_int16 value); @@ -80,6 +82,7 @@ extern bool libcdsb_list_update_array (vtype_list* x, ssize_t index, const vty extern bool libcdsb_list_update_list (vtype_list* x, ssize_t index, const vtype_list* value, int ins_direction); extern bool libcdsb_list_update_map (vtype_list* x, ssize_t index, const vtype_map* value, int ins_direction); extern bool libcdsb_list_update_vset (vtype_list* x, ssize_t index, const vtype_set* value, int ins_direction); +extern bool libcdsb_list_update_dict (vtype_list* x, ssize_t index, const vtype_dict* value, int ins_direction); extern bool libcdsb_list_update_boolean(vtype_list* x, ssize_t index, vtype_bool value, int ins_direction); extern bool libcdsb_list_update_int8 (vtype_list* x, ssize_t index, vtype_int8 value, int ins_direction); extern bool libcdsb_list_update_int16 (vtype_list* x, ssize_t index, vtype_int16 value, int ins_direction); diff --git a/include/map.h b/include/map.h index 3551021..9898814 100644 --- a/include/map.h +++ b/include/map.h @@ -11,10 +11,10 @@ typedef int (*map_access_callback)(const void* key, vtype key_type, void* value, 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) -#define map_get(x, s, key) _LIBCDSB_Generic (libcdsb_map, find, key)(x, s, key, 0) -#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) +#define map_pop(x, key, data, callback) _LIBCDSB_Generic (libcdsb_map, find, key)(x, key, data, callback, 1) +#define map_get(x, key, data, callback) _LIBCDSB_Generic (libcdsb_map, find, key)(x, key, data, callback, 0) +#define map_update(x, key, value) _LIBCDSB_Generic2(libcdsb_map, update, key, value)(x, key, value) +#define map_remove(x, key) map_pop(x, key, 0, 0) 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); @@ -23,6 +23,7 @@ extern int libcdsb_map_find_array (vtype_map* x, const vtype_array* key, void* 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_dict (vtype_map* x, const vtype_dict* 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); @@ -43,6 +44,7 @@ extern bool libcdsb_map_update_pointer_array (vtype_map* x, const void* key, co extern bool libcdsb_map_update_pointer_list (vtype_map* x, const void* key, const vtype_list* value); extern bool libcdsb_map_update_pointer_map (vtype_map* x, const void* key, const vtype_map* value); extern bool libcdsb_map_update_pointer_vset (vtype_map* x, const void* key, const vtype_set* value); +extern bool libcdsb_map_update_pointer_dict (vtype_map* x, const void* key, const vtype_dict* value); extern bool libcdsb_map_update_pointer_boolean(vtype_map* x, const void* key, vtype_bool value); extern bool libcdsb_map_update_pointer_int8 (vtype_map* x, const void* key, vtype_int8 value); extern bool libcdsb_map_update_pointer_int16 (vtype_map* x, const void* key, vtype_int16 value); @@ -63,6 +65,7 @@ extern bool libcdsb_map_update_string_array (vtype_map* x, const vtype_string* extern bool libcdsb_map_update_string_list (vtype_map* x, const vtype_string* key, const vtype_list* value); extern bool libcdsb_map_update_string_map (vtype_map* x, const vtype_string* key, const vtype_map* value); extern bool libcdsb_map_update_string_vset (vtype_map* x, const vtype_string* key, const vtype_set* value); +extern bool libcdsb_map_update_string_dict (vtype_map* x, const vtype_string* key, const vtype_dict* value); extern bool libcdsb_map_update_string_boolean(vtype_map* x, const vtype_string* key, vtype_bool value); extern bool libcdsb_map_update_string_int8 (vtype_map* x, const vtype_string* key, vtype_int8 value); extern bool libcdsb_map_update_string_int16 (vtype_map* x, const vtype_string* key, vtype_int16 value); @@ -83,6 +86,7 @@ extern bool libcdsb_map_update_array_array (vtype_map* x, const vtype_array* ke extern bool libcdsb_map_update_array_list (vtype_map* x, const vtype_array* key, const vtype_list* value); extern bool libcdsb_map_update_array_map (vtype_map* x, const vtype_array* key, const vtype_map* value); extern bool libcdsb_map_update_array_vset (vtype_map* x, const vtype_array* key, const vtype_set* value); +extern bool libcdsb_map_update_array_dict (vtype_map* x, const vtype_array* key, const vtype_dict* value); extern bool libcdsb_map_update_array_boolean(vtype_map* x, const vtype_array* key, vtype_bool value); extern bool libcdsb_map_update_array_int8 (vtype_map* x, const vtype_array* key, vtype_int8 value); extern bool libcdsb_map_update_array_int16 (vtype_map* x, const vtype_array* key, vtype_int16 value); @@ -103,6 +107,7 @@ extern bool libcdsb_map_update_list_array (vtype_map* x, const vtype_list* key, extern bool libcdsb_map_update_list_list (vtype_map* x, const vtype_list* key, const vtype_list* value); extern bool libcdsb_map_update_list_map (vtype_map* x, const vtype_list* key, const vtype_map* value); extern bool libcdsb_map_update_list_vset (vtype_map* x, const vtype_list* key, const vtype_set* value); +extern bool libcdsb_map_update_list_dict (vtype_map* x, const vtype_list* key, const vtype_dict* value); extern bool libcdsb_map_update_list_boolean(vtype_map* x, const vtype_list* key, vtype_bool value); extern bool libcdsb_map_update_list_int8 (vtype_map* x, const vtype_list* key, vtype_int8 value); extern bool libcdsb_map_update_list_int16 (vtype_map* x, const vtype_list* key, vtype_int16 value); @@ -123,6 +128,7 @@ extern bool libcdsb_map_update_map_array (vtype_map* x, const vtype_map* key, c extern bool libcdsb_map_update_map_list (vtype_map* x, const vtype_map* key, const vtype_list* value); extern bool libcdsb_map_update_map_map (vtype_map* x, const vtype_map* key, const vtype_map* value); extern bool libcdsb_map_update_map_vset (vtype_map* x, const vtype_map* key, const vtype_set* value); +extern bool libcdsb_map_update_map_dict (vtype_map* x, const vtype_map* key, const vtype_dict* value); extern bool libcdsb_map_update_map_boolean(vtype_map* x, const vtype_map* key, vtype_bool value); extern bool libcdsb_map_update_map_int8 (vtype_map* x, const vtype_map* key, vtype_int8 value); extern bool libcdsb_map_update_map_int16 (vtype_map* x, const vtype_map* key, vtype_int16 value); @@ -143,6 +149,7 @@ extern bool libcdsb_map_update_vset_array (vtype_map* x, const vtype_set* key, extern bool libcdsb_map_update_vset_list (vtype_map* x, const vtype_set* key, const vtype_list* value); extern bool libcdsb_map_update_vset_map (vtype_map* x, const vtype_set* key, const vtype_map* value); extern bool libcdsb_map_update_vset_vset (vtype_map* x, const vtype_set* key, const vtype_set* value); +extern bool libcdsb_map_update_vset_dict (vtype_map* x, const vtype_set* key, const vtype_dict* value); extern bool libcdsb_map_update_vset_boolean(vtype_map* x, const vtype_set* key, vtype_bool value); extern bool libcdsb_map_update_vset_int8 (vtype_map* x, const vtype_set* key, vtype_int8 value); extern bool libcdsb_map_update_vset_int16 (vtype_map* x, const vtype_set* key, vtype_int16 value); @@ -156,6 +163,27 @@ extern bool libcdsb_map_update_vset_float (vtype_map* x, const vtype_set* key, extern bool libcdsb_map_update_vset_double (vtype_map* x, const vtype_set* key, vtype_double value); extern bool libcdsb_map_update_vset_ldouble(vtype_map* x, const vtype_set* key, vtype_ldouble value); +extern bool libcdsb_map_update_dict_pointer(vtype_map* x, const vtype_dict* key, const void* value); +extern bool libcdsb_map_update_dict_cstring(vtype_map* x, const vtype_dict* key, const char* value); +extern bool libcdsb_map_update_dict_string (vtype_map* x, const vtype_dict* key, const vtype_string* value); +extern bool libcdsb_map_update_dict_array (vtype_map* x, const vtype_dict* key, const vtype_array* value); +extern bool libcdsb_map_update_dict_list (vtype_map* x, const vtype_dict* key, const vtype_list* value); +extern bool libcdsb_map_update_dict_map (vtype_map* x, const vtype_dict* key, const vtype_map* value); +extern bool libcdsb_map_update_dict_vset (vtype_map* x, const vtype_dict* key, const vtype_set* value); +extern bool libcdsb_map_update_dict_dict (vtype_map* x, const vtype_dict* key, const vtype_dict* value); +extern bool libcdsb_map_update_dict_boolean(vtype_map* x, const vtype_dict* key, vtype_bool value); +extern bool libcdsb_map_update_dict_int8 (vtype_map* x, const vtype_dict* key, vtype_int8 value); +extern bool libcdsb_map_update_dict_int16 (vtype_map* x, const vtype_dict* key, vtype_int16 value); +extern bool libcdsb_map_update_dict_int32 (vtype_map* x, const vtype_dict* key, vtype_int32 value); +extern bool libcdsb_map_update_dict_int64 (vtype_map* x, const vtype_dict* key, vtype_int64 value); +extern bool libcdsb_map_update_dict_uint8 (vtype_map* x, const vtype_dict* key, vtype_uint8 value); +extern bool libcdsb_map_update_dict_uint16 (vtype_map* x, const vtype_dict* key, vtype_uint16 value); +extern bool libcdsb_map_update_dict_uint32 (vtype_map* x, const vtype_dict* key, vtype_uint32 value); +extern bool libcdsb_map_update_dict_uint64 (vtype_map* x, const vtype_dict* key, vtype_uint64 value); +extern bool libcdsb_map_update_dict_float (vtype_map* x, const vtype_dict* key, vtype_float value); +extern bool libcdsb_map_update_dict_double (vtype_map* x, const vtype_dict* key, vtype_double value); +extern bool libcdsb_map_update_dict_ldouble(vtype_map* x, const vtype_dict* key, vtype_ldouble value); + extern bool libcdsb_map_update_cstring_pointer(vtype_map* x, const char* key, const void* value); extern bool libcdsb_map_update_cstring_cstring(vtype_map* x, const char* key, const char* value); extern bool libcdsb_map_update_cstring_string (vtype_map* x, const char* key, const vtype_string* value); @@ -163,6 +191,7 @@ extern bool libcdsb_map_update_cstring_array (vtype_map* x, const char* key, co extern bool libcdsb_map_update_cstring_list (vtype_map* x, const char* key, const vtype_list* value); extern bool libcdsb_map_update_cstring_map (vtype_map* x, const char* key, const vtype_map* value); extern bool libcdsb_map_update_cstring_vset (vtype_map* x, const char* key, const vtype_set* value); +extern bool libcdsb_map_update_cstring_dict (vtype_map* x, const char* key, const vtype_dict* value); extern bool libcdsb_map_update_cstring_boolean(vtype_map* x, const char* key, vtype_bool value); extern bool libcdsb_map_update_cstring_int8 (vtype_map* x, const char* key, vtype_int8 value); extern bool libcdsb_map_update_cstring_int16 (vtype_map* x, const char* key, vtype_int16 value); @@ -183,6 +212,7 @@ extern bool libcdsb_map_update_boolean_array (vtype_map* x, vtype_bool key, con extern bool libcdsb_map_update_boolean_list (vtype_map* x, vtype_bool key, const vtype_list* value); extern bool libcdsb_map_update_boolean_map (vtype_map* x, vtype_bool key, const vtype_map* value); extern bool libcdsb_map_update_boolean_vset (vtype_map* x, vtype_bool key, const vtype_set* value); +extern bool libcdsb_map_update_boolean_dict (vtype_map* x, vtype_bool key, const vtype_dict* value); extern bool libcdsb_map_update_boolean_boolean(vtype_map* x, vtype_bool key, vtype_bool value); extern bool libcdsb_map_update_boolean_int8 (vtype_map* x, vtype_bool key, vtype_int8 value); extern bool libcdsb_map_update_boolean_int16 (vtype_map* x, vtype_bool key, vtype_int16 value); @@ -203,6 +233,7 @@ extern bool libcdsb_map_update_uint8_array (vtype_map* x, vtype_uint8 key, cons extern bool libcdsb_map_update_uint8_list (vtype_map* x, vtype_uint8 key, const vtype_list* value); extern bool libcdsb_map_update_uint8_map (vtype_map* x, vtype_uint8 key, const vtype_map* value); extern bool libcdsb_map_update_uint8_vset (vtype_map* x, vtype_uint8 key, const vtype_set* value); +extern bool libcdsb_map_update_uint8_dict (vtype_map* x, vtype_uint8 key, const vtype_dict* value); extern bool libcdsb_map_update_uint8_boolean(vtype_map* x, vtype_uint8 key, vtype_bool value); extern bool libcdsb_map_update_uint8_int8 (vtype_map* x, vtype_uint8 key, vtype_int8 value); extern bool libcdsb_map_update_uint8_int16 (vtype_map* x, vtype_uint8 key, vtype_int16 value); @@ -223,6 +254,7 @@ extern bool libcdsb_map_update_uint16_array (vtype_map* x, vtype_uint16 key, co extern bool libcdsb_map_update_uint16_list (vtype_map* x, vtype_uint16 key, const vtype_list* value); extern bool libcdsb_map_update_uint16_map (vtype_map* x, vtype_uint16 key, const vtype_map* value); extern bool libcdsb_map_update_uint16_vset (vtype_map* x, vtype_uint16 key, const vtype_set* value); +extern bool libcdsb_map_update_uint16_dict (vtype_map* x, vtype_uint16 key, const vtype_dict* value); extern bool libcdsb_map_update_uint16_boolean(vtype_map* x, vtype_uint16 key, vtype_bool value); extern bool libcdsb_map_update_uint16_int8 (vtype_map* x, vtype_uint16 key, vtype_int8 value); extern bool libcdsb_map_update_uint16_int16 (vtype_map* x, vtype_uint16 key, vtype_int16 value); @@ -243,6 +275,7 @@ extern bool libcdsb_map_update_uint32_array (vtype_map* x, vtype_uint32 key, co extern bool libcdsb_map_update_uint32_list (vtype_map* x, vtype_uint32 key, const vtype_list* value); extern bool libcdsb_map_update_uint32_map (vtype_map* x, vtype_uint32 key, const vtype_map* value); extern bool libcdsb_map_update_uint32_vset (vtype_map* x, vtype_uint32 key, const vtype_set* value); +extern bool libcdsb_map_update_uint32_dict (vtype_map* x, vtype_uint32 key, const vtype_dict* value); extern bool libcdsb_map_update_uint32_boolean(vtype_map* x, vtype_uint32 key, vtype_bool value); extern bool libcdsb_map_update_uint32_int8 (vtype_map* x, vtype_uint32 key, vtype_int8 value); extern bool libcdsb_map_update_uint32_int16 (vtype_map* x, vtype_uint32 key, vtype_int16 value); @@ -263,6 +296,7 @@ extern bool libcdsb_map_update_uint64_array (vtype_map* x, vtype_uint64 key, co extern bool libcdsb_map_update_uint64_list (vtype_map* x, vtype_uint64 key, const vtype_list* value); extern bool libcdsb_map_update_uint64_map (vtype_map* x, vtype_uint64 key, const vtype_map* value); extern bool libcdsb_map_update_uint64_vset (vtype_map* x, vtype_uint64 key, const vtype_set* value); +extern bool libcdsb_map_update_uint64_dict (vtype_map* x, vtype_uint64 key, const vtype_dict* value); extern bool libcdsb_map_update_uint64_boolean(vtype_map* x, vtype_uint64 key, vtype_bool value); extern bool libcdsb_map_update_uint64_int8 (vtype_map* x, vtype_uint64 key, vtype_int8 value); extern bool libcdsb_map_update_uint64_int16 (vtype_map* x, vtype_uint64 key, vtype_int16 value); @@ -283,6 +317,7 @@ extern bool libcdsb_map_update_int8_array (vtype_map* x, vtype_int8 key, const extern bool libcdsb_map_update_int8_list (vtype_map* x, vtype_int8 key, const vtype_list* value); extern bool libcdsb_map_update_int8_map (vtype_map* x, vtype_int8 key, const vtype_map* value); extern bool libcdsb_map_update_int8_vset (vtype_map* x, vtype_int8 key, const vtype_set* value); +extern bool libcdsb_map_update_int8_dict (vtype_map* x, vtype_int8 key, const vtype_dict* value); extern bool libcdsb_map_update_int8_boolean(vtype_map* x, vtype_int8 key, vtype_bool value); extern bool libcdsb_map_update_int8_int8 (vtype_map* x, vtype_int8 key, vtype_int8 value); extern bool libcdsb_map_update_int8_int16 (vtype_map* x, vtype_int8 key, vtype_int16 value); @@ -303,6 +338,7 @@ extern bool libcdsb_map_update_int16_array (vtype_map* x, vtype_int16 key, cons extern bool libcdsb_map_update_int16_list (vtype_map* x, vtype_int16 key, const vtype_list* value); extern bool libcdsb_map_update_int16_map (vtype_map* x, vtype_int16 key, const vtype_map* value); extern bool libcdsb_map_update_int16_vset (vtype_map* x, vtype_int16 key, const vtype_set* value); +extern bool libcdsb_map_update_int16_dict (vtype_map* x, vtype_int16 key, const vtype_dict* value); extern bool libcdsb_map_update_int16_boolean(vtype_map* x, vtype_int16 key, vtype_bool value); extern bool libcdsb_map_update_int16_int8 (vtype_map* x, vtype_int16 key, vtype_int8 value); extern bool libcdsb_map_update_int16_int16 (vtype_map* x, vtype_int16 key, vtype_int16 value); @@ -323,6 +359,7 @@ extern bool libcdsb_map_update_int32_array (vtype_map* x, vtype_int32 key, cons extern bool libcdsb_map_update_int32_list (vtype_map* x, vtype_int32 key, const vtype_list* value); extern bool libcdsb_map_update_int32_map (vtype_map* x, vtype_int32 key, const vtype_map* value); extern bool libcdsb_map_update_int32_vset (vtype_map* x, vtype_int32 key, const vtype_set* value); +extern bool libcdsb_map_update_int32_dict (vtype_map* x, vtype_int32 key, const vtype_dict* value); extern bool libcdsb_map_update_int32_boolean(vtype_map* x, vtype_int32 key, vtype_bool value); extern bool libcdsb_map_update_int32_int8 (vtype_map* x, vtype_int32 key, vtype_int8 value); extern bool libcdsb_map_update_int32_int16 (vtype_map* x, vtype_int32 key, vtype_int16 value); @@ -343,6 +380,7 @@ extern bool libcdsb_map_update_int64_array (vtype_map* x, vtype_int64 key, cons extern bool libcdsb_map_update_int64_list (vtype_map* x, vtype_int64 key, const vtype_list* value); extern bool libcdsb_map_update_int64_map (vtype_map* x, vtype_int64 key, const vtype_map* value); extern bool libcdsb_map_update_int64_vset (vtype_map* x, vtype_int64 key, const vtype_set* value); +extern bool libcdsb_map_update_int64_dict (vtype_map* x, vtype_int64 key, const vtype_dict* value); extern bool libcdsb_map_update_int64_boolean(vtype_map* x, vtype_int64 key, vtype_bool value); extern bool libcdsb_map_update_int64_int8 (vtype_map* x, vtype_int64 key, vtype_int8 value); extern bool libcdsb_map_update_int64_int16 (vtype_map* x, vtype_int64 key, vtype_int16 value); @@ -363,6 +401,7 @@ extern bool libcdsb_map_update_float_array (vtype_map* x, vtype_float key, cons extern bool libcdsb_map_update_float_list (vtype_map* x, vtype_float key, const vtype_list* value); extern bool libcdsb_map_update_float_map (vtype_map* x, vtype_float key, const vtype_map* value); extern bool libcdsb_map_update_float_vset (vtype_map* x, vtype_float key, const vtype_set* value); +extern bool libcdsb_map_update_float_dict (vtype_map* x, vtype_float key, const vtype_dict* value); extern bool libcdsb_map_update_float_boolean(vtype_map* x, vtype_float key, vtype_bool value); extern bool libcdsb_map_update_float_int8 (vtype_map* x, vtype_float key, vtype_int8 value); extern bool libcdsb_map_update_float_int16 (vtype_map* x, vtype_float key, vtype_int16 value); @@ -383,6 +422,7 @@ extern bool libcdsb_map_update_double_array (vtype_map* x, vtype_double key, co extern bool libcdsb_map_update_double_list (vtype_map* x, vtype_double key, const vtype_list* value); extern bool libcdsb_map_update_double_map (vtype_map* x, vtype_double key, const vtype_map* value); extern bool libcdsb_map_update_double_vset (vtype_map* x, vtype_double key, const vtype_set* value); +extern bool libcdsb_map_update_double_dict (vtype_map* x, vtype_double key, const vtype_dict* value); extern bool libcdsb_map_update_double_boolean(vtype_map* x, vtype_double key, vtype_bool value); extern bool libcdsb_map_update_double_int8 (vtype_map* x, vtype_double key, vtype_int8 value); extern bool libcdsb_map_update_double_int16 (vtype_map* x, vtype_double key, vtype_int16 value); @@ -403,6 +443,7 @@ extern bool libcdsb_map_update_ldouble_array (vtype_map* x, vtype_ldouble key, extern bool libcdsb_map_update_ldouble_list (vtype_map* x, vtype_ldouble key, const vtype_list* value); extern bool libcdsb_map_update_ldouble_map (vtype_map* x, vtype_ldouble key, const vtype_map* value); extern bool libcdsb_map_update_ldouble_vset (vtype_map* x, vtype_ldouble key, const vtype_set* value); +extern bool libcdsb_map_update_ldouble_dict (vtype_map* x, vtype_ldouble key, const vtype_dict* value); extern bool libcdsb_map_update_ldouble_boolean(vtype_map* x, vtype_ldouble key, vtype_bool value); extern bool libcdsb_map_update_ldouble_int8 (vtype_map* x, vtype_ldouble key, vtype_int8 value); extern bool libcdsb_map_update_ldouble_int16 (vtype_map* x, vtype_ldouble key, vtype_int16 value); diff --git a/include/set.h b/include/set.h index 775ecc8..a008e54 100644 --- a/include/set.h +++ b/include/set.h @@ -23,6 +23,7 @@ extern bool libcdsb_vset_push_array (vtype_set* x, const vtype_array* value); extern bool libcdsb_vset_push_list (vtype_set* x, const vtype_list* value); extern bool libcdsb_vset_push_map (vtype_set* x, const vtype_map* value); extern bool libcdsb_vset_push_vset (vtype_set* x, const vtype_set* value); +extern bool libcdsb_vset_push_dict (vtype_set* x, const vtype_dict* value); extern bool libcdsb_vset_push_boolean(vtype_set* x, vtype_bool value); extern bool libcdsb_vset_push_uint8 (vtype_set* x, vtype_uint8 value); extern bool libcdsb_vset_push_uint16 (vtype_set* x, vtype_uint16 value); @@ -43,6 +44,7 @@ extern int libcdsb_vset_find_array (vtype_set* x, const vtype_array* value, vo 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_dict (vtype_set* x, const vtype_dict* 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); diff --git a/include/vtype.h b/include/vtype.h index 0ea46fe..8aae269 100644 --- a/include/vtype.h +++ b/include/vtype.h @@ -30,6 +30,7 @@ typedef enum libcdsb_value_types { VTYPE_ARRAY = 15, VTYPE_LIST = 16, VTYPE_SET = 17, + VTYPE_DICT = 18, LIBCDSB_VTYPE_TERMINATION, /* It must be at the end of the enum. Never be used */ } vtype; @@ -42,6 +43,7 @@ struct libcdsb_map { struct libcdsb_map_node* root; vtype type; }; struct libcdsb_set { struct libcdsb_rbtree_node* root; vtype type; }; struct libcdsb_list { struct libcdsb_list_node* last; struct libcdsb_list_node* first; }; +struct libcdsb_dict { struct libcdsb_dict_node** nodes; size_t capacity; size_t size; }; typedef void* vtype_pointer; typedef bool vtype_bool; @@ -60,10 +62,13 @@ typedef float vtype_float; typedef double vtype_double; typedef long double vtype_ldouble; +typedef uint_least64_t vtype_hash; + 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_dict vtype_dict; typedef struct libcdsb_string vtype_string; @@ -81,6 +86,10 @@ extern size_t list_size(const vtype_list* x) LIBCDSB_pure__ LIBCDSB_nn1__; extern size_t map_size(const vtype_map* x) LIBCDSB_pure__ LIBCDSB_nn1__; /* Get count of the set elements */ extern size_t vset_size(const vtype_set* x) LIBCDSB_pure__ LIBCDSB_nn1__; +/* Get count of the dict elements */ +extern size_t dict_size(const vtype_dict* x) LIBCDSB_pure__ LIBCDSB_nn1__; +/* Get count of the available nodes */ +extern size_t dict_capacity(const vtype_dict* x) LIBCDSB_pure__ LIBCDSB_nn1__; /* Cpmpare 2 strings */ @@ -93,6 +102,8 @@ extern int list_compare(const vtype_list* s0, const vtype_list* s1) LIBCDS extern int map_compare(const vtype_map* s0, const vtype_map* s1) LIBCDSB_cmpattr__; /* Compare 2 sets */ extern int vset_compare(const vtype_set* s0, const vtype_set* s1) LIBCDSB_cmpattr__; +/* Compare 2 dicts */ +extern int dict_compare(const vtype_dict* s0, const vtype_dict* s1) LIBCDSB_cmpattr__; /* Copy string to another */ extern vtype_string string_copy(const vtype_string* s) LIBCDSB_cpyattr__; @@ -104,6 +115,8 @@ extern vtype_list list_copy(const vtype_list* s) LIBCDSB_cpyattr__; extern vtype_map map_copy(const vtype_map* s) LIBCDSB_cpyattr__; /* Copy set to another */ extern vtype_set vset_copy(const vtype_set* s) LIBCDSB_cpyattr__; +/* Copy set to another */ +extern vtype_dict dict_copy(const vtype_dict* s) LIBCDSB_cpyattr__; /* Duplicate string memory block */ extern vtype_string* string_duplicate(const vtype_string* s) LIBCDSB_dupattr__; @@ -115,6 +128,8 @@ extern vtype_list* list_duplicate(const vtype_list* s) LIBCDSB_dupattr__; extern vtype_map* map_duplicate(const vtype_map* s) LIBCDSB_dupattr__; /* Duplicate set memory block */ extern vtype_set* vset_duplicate(const vtype_set* s) LIBCDSB_dupattr__; +/* Duplicate dict memory block */ +extern vtype_dict* dict_duplicate(const vtype_dict* s) LIBCDSB_dupattr__; /* Copy string and store result to the memory block */ extern void string_copy_init(vtype_string* x, const vtype_string* s) LIBCDSB_nn12__; @@ -126,6 +141,8 @@ extern void list_copy_init(vtype_list* x, const vtype_list* s) LIBCDSB_nn1 extern void map_copy_init(vtype_map* x, const vtype_map* s) LIBCDSB_nn12__; /* Copy set and store result to the memory block */ extern void vset_copy_init(vtype_set* x, const vtype_set* s) LIBCDSB_nn12__; +/* Copy dict and store result to the memory block */ +extern void dict_copy_init(vtype_dict* x, const vtype_dict* s) LIBCDSB_nn12__; /* Free string resources */ extern void string_free(vtype_string* x); @@ -137,5 +154,21 @@ extern void list_free(vtype_list* x); extern void map_free(vtype_map* x); /* Free set resources */ extern void vset_free(vtype_set* x); +/* Free dict resources */ +extern void dict_free(vtype_dict* x); + +/* Get hash of the string */ +extern vtype_hash string_hash(const vtype_string* s) LIBCDSB_nn1__; +/* Get hash of the array */ +extern vtype_hash array_hash(const vtype_array* s) LIBCDSB_nn1__; +/* Get hash of the list */ +extern vtype_hash list_hash(const vtype_list* s) LIBCDSB_nn1__; +/* Get hash of the map */ +extern vtype_hash map_hash(const vtype_map* s) LIBCDSB_nn1__; +/* Get hash of the set */ +extern vtype_hash vset_hash(const vtype_set* s) LIBCDSB_nn1__; +/* Get hash of the dict */ +extern vtype_hash dict_hash(const vtype_dict* s) LIBCDSB_nn1__; + #endif /* LIBCDSB_VTYPE_H */ diff --git a/src/__internal/include.h b/src/__internal/include.h index 81f1303..9bed823 100644 --- a/src/__internal/include.h +++ b/src/__internal/include.h @@ -57,17 +57,24 @@ typedef vtype_array arr_t; typedef vtype_list list_t; typedef vtype_map map_t; typedef vtype_set set_t; +typedef vtype_dict dict_t; + +typedef vtype_hash hash_t; 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); +extern hash_t libcdsb_vtype_hash(void* value, vtype type); + #define vtype_stringify libcdsb_vtype_stringify #define vtype_name libcdsb_vtype_name #define vtype_compare libcdsb_vtype_compare_values #define vtype_compare_eq libcdsb_vtype_compare_values_eq +#define vtype_hash libcdsb_vtype_hash + #define vtype_size(type) (LIBCDSB_VTYPE_SIZES[type]) #define vtypeof(x) (vtype)(_Generic((x),\ @@ -78,6 +85,7 @@ extern int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype const list_t*: VTYPE_LIST, list_t*: VTYPE_LIST, list_t: VTYPE_LIST,\ const map_t*: VTYPE_MAP, map_t*: VTYPE_MAP, map_t: VTYPE_MAP,\ const set_t*: VTYPE_SET, set_t*: VTYPE_SET, set_t: VTYPE_SET,\ + const dict_t*: VTYPE_DICT, dict_t*: VTYPE_DICT, dict_t: VTYPE_DICT,\ const vtype_bool*: VTYPE_BOOLEAN, vtype_bool*: VTYPE_BOOLEAN, vtype_bool: VTYPE_BOOLEAN,\ const vtype_uint8*: VTYPE_UINT8, vtype_uint8*: VTYPE_UINT8, vtype_uint8: VTYPE_UINT8,\ const vtype_uint16*: VTYPE_UINT16, vtype_uint16*: VTYPE_UINT16, vtype_uint16: VTYPE_UINT16,\ diff --git a/src/__internal/vnode.h b/src/__internal/vnode.h index a119e62..3ff99c3 100644 --- a/src/__internal/vnode.h +++ b/src/__internal/vnode.h @@ -29,7 +29,9 @@ extern void* libcdsb_vnode_peek(const vnode_t* x, vtype type); #define vnode_peek libcdsb_vnode_peek #define vnode_free libcdsb_vnode_free +#define vnode_hash(vnode, type) vtype_hash(vnode_peek(vnode, type), type) #define vnode_compare(s0, t0, s1, t1) vtype_compare(vnode_peek(s0, t0), t0, vnode_peek(s1, t1), t1) +#define vnode_compare_eq(s0, s1, t) vtype_compare_eq(vnode_peek(s0, t), vnode_peek(s1, t), t) #define vnode_duplicate(vnode, type) libcdsb_vnode_create(vnode_peek(vnode, type), type) #define vnode_tduplicate(target_type, vnode, type) libcdsb_vnode_create_target(target_type, vnode_peek(vnode, type), type) diff --git a/src/array/generics.c b/src/array/generics.c index cdcf787..e34028a 100644 --- a/src/array/generics.c +++ b/src/array/generics.c @@ -4,12 +4,13 @@ #include "include.h" int libcdsb_array_find_pointer(arr_t* x, const void* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } -int libcdsb_array_find_string (arr_t* x, const char* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } -int libcdsb_array_find_array (arr_t* x, const str_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } -int libcdsb_array_find_list (arr_t* x, const arr_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } -int libcdsb_array_find_map (arr_t* x, const list_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } -int libcdsb_array_find_vset (arr_t* x, const map_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } -int libcdsb_array_find_cstring(arr_t* x, const set_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_cstring(arr_t* x, const char* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } +int libcdsb_array_find_string (arr_t* x, const str_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_array (arr_t* x, const arr_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_list (arr_t* x, const list_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_map (arr_t* x, const map_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_vset (arr_t* x, const set_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } +int libcdsb_array_find_dict (arr_t* x, const dict_t* v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, v, vtypeof( v), _, cb, r, cut); } int libcdsb_array_find_boolean(arr_t* x, bool v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } int libcdsb_array_find_int8 (arr_t* x, s8_t v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } int libcdsb_array_find_int16 (arr_t* x, s16_t v, void* _, array_access_callback cb, bool r, bool cut) { return libcdsb_array_find(x, &v, vtypeof(&v), _, cb, r, cut); } @@ -30,6 +31,7 @@ size_t libcdsb_array_count_array (const arr_t* x, const arr_t* v) { return lib size_t libcdsb_array_count_list (const arr_t* x, const list_t* v) { return libcdsb_array_count(x, v, vtypeof( v)); } size_t libcdsb_array_count_map (const arr_t* x, const map_t* v) { return libcdsb_array_count(x, v, vtypeof( v)); } size_t libcdsb_array_count_vset (const arr_t* x, const set_t* v) { return libcdsb_array_count(x, v, vtypeof( v)); } +size_t libcdsb_array_count_dict (const arr_t* x, const dict_t* v) { return libcdsb_array_count(x, v, vtypeof( v)); } size_t libcdsb_array_count_boolean(const arr_t* x, bool v) { return libcdsb_array_count(x, &v, vtypeof(&v)); } size_t libcdsb_array_count_int8 (const arr_t* x, s8_t v) { return libcdsb_array_count(x, &v, vtypeof(&v)); } size_t libcdsb_array_count_int16 (const arr_t* x, s16_t v) { return libcdsb_array_count(x, &v, vtypeof(&v)); } @@ -50,6 +52,7 @@ void libcdsb_array_push_array (arr_t* x, const arr_t* v) { libcdsb_array_push( void libcdsb_array_push_list (arr_t* x, const list_t* v) { libcdsb_array_push(x, v, vtypeof( v)); } void libcdsb_array_push_map (arr_t* x, const map_t* v) { libcdsb_array_push(x, v, vtypeof( v)); } void libcdsb_array_push_vset (arr_t* x, const set_t* v) { libcdsb_array_push(x, v, vtypeof( v)); } +void libcdsb_array_push_dict (arr_t* x, const dict_t* v) { libcdsb_array_push(x, v, vtypeof( v)); } void libcdsb_array_push_boolean(arr_t* x, bool v) { libcdsb_array_push(x, &v, vtypeof(&v)); } void libcdsb_array_push_int8 (arr_t* x, s8_t v) { libcdsb_array_push(x, &v, vtypeof(&v)); } void libcdsb_array_push_int16 (arr_t* x, s16_t v) { libcdsb_array_push(x, &v, vtypeof(&v)); } diff --git a/src/dict/generics.c b/src/dict/generics.c new file mode 100644 index 0000000..1c8ea7d --- /dev/null +++ b/src/dict/generics.c @@ -0,0 +1,445 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +int libcdsb_dict_get_by_pointer(dict_t* x, const void* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_cstring(dict_t* x, const char* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_string (dict_t* x, const str_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_array (dict_t* x, const arr_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_list (dict_t* x, const list_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_map (dict_t* x, const map_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_vset (dict_t* x, const set_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_dict (dict_t* x, const dict_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_get_by_boolean(dict_t* x, bool k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_int8 (dict_t* x, s8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_int16 (dict_t* x, s16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_int32 (dict_t* x, s32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_int64 (dict_t* x, s64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_uint8 (dict_t* x, u8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_uint16 (dict_t* x, u16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_uint32 (dict_t* x, u32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_uint64 (dict_t* x, u64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_float (dict_t* x, fl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_double (dict_t* x, dbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_get_by_ldouble(dict_t* x, ldbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } + +bool libcdsb_dict_update_pointer_pointer(dict_t* x, const void* k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_cstring(dict_t* x, const void* k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_string (dict_t* x, const void* k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_array (dict_t* x, const void* k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_list (dict_t* x, const void* k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_map (dict_t* x, const void* k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_vset (dict_t* x, const void* k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_dict (dict_t* x, const void* k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_pointer_boolean(dict_t* x, const void* k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_int8 (dict_t* x, const void* k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_int16 (dict_t* x, const void* k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_int32 (dict_t* x, const void* k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_int64 (dict_t* x, const void* k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_uint8 (dict_t* x, const void* k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_uint16 (dict_t* x, const void* k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_uint32 (dict_t* x, const void* k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_uint64 (dict_t* x, const void* k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_float (dict_t* x, const void* k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_double (dict_t* x, const void* k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_pointer_ldouble(dict_t* x, const void* k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_cstring_pointer(dict_t* x, const char* k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_cstring(dict_t* x, const char* k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_string (dict_t* x, const char* k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_array (dict_t* x, const char* k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_list (dict_t* x, const char* k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_map (dict_t* x, const char* k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_vset (dict_t* x, const char* k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_dict (dict_t* x, const char* k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_cstring_boolean(dict_t* x, const char* k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_int8 (dict_t* x, const char* k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_int16 (dict_t* x, const char* k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_int32 (dict_t* x, const char* k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_int64 (dict_t* x, const char* k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_uint8 (dict_t* x, const char* k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_uint16 (dict_t* x, const char* k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_uint32 (dict_t* x, const char* k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_uint64 (dict_t* x, const char* k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_float (dict_t* x, const char* k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_double (dict_t* x, const char* k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_cstring_ldouble(dict_t* x, const char* k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_string_pointer(dict_t* x, const str_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_cstring(dict_t* x, const str_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_string (dict_t* x, const str_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_array (dict_t* x, const str_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_list (dict_t* x, const str_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_map (dict_t* x, const str_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_vset (dict_t* x, const str_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_dict (dict_t* x, const str_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_string_boolean(dict_t* x, const str_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_int8 (dict_t* x, const str_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_int16 (dict_t* x, const str_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_int32 (dict_t* x, const str_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_int64 (dict_t* x, const str_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_uint8 (dict_t* x, const str_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_uint16 (dict_t* x, const str_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_uint32 (dict_t* x, const str_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_uint64 (dict_t* x, const str_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_float (dict_t* x, const str_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_double (dict_t* x, const str_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_string_ldouble(dict_t* x, const str_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_array_pointer(dict_t* x, const arr_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_cstring(dict_t* x, const arr_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_string (dict_t* x, const arr_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_array (dict_t* x, const arr_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_list (dict_t* x, const arr_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_map (dict_t* x, const arr_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_vset (dict_t* x, const arr_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_dict (dict_t* x, const arr_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_array_boolean(dict_t* x, const arr_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_int8 (dict_t* x, const arr_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_int16 (dict_t* x, const arr_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_int32 (dict_t* x, const arr_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_int64 (dict_t* x, const arr_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_uint8 (dict_t* x, const arr_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_uint16 (dict_t* x, const arr_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_uint32 (dict_t* x, const arr_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_uint64 (dict_t* x, const arr_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_float (dict_t* x, const arr_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_double (dict_t* x, const arr_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_array_ldouble(dict_t* x, const arr_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_list_pointer(dict_t* x, const list_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_cstring(dict_t* x, const list_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_string (dict_t* x, const list_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_array (dict_t* x, const list_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_list (dict_t* x, const list_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_map (dict_t* x, const list_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_vset (dict_t* x, const list_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_dict (dict_t* x, const list_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_list_boolean(dict_t* x, const list_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_int8 (dict_t* x, const list_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_int16 (dict_t* x, const list_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_int32 (dict_t* x, const list_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_int64 (dict_t* x, const list_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_uint8 (dict_t* x, const list_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_uint16 (dict_t* x, const list_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_uint32 (dict_t* x, const list_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_uint64 (dict_t* x, const list_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_float (dict_t* x, const list_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_double (dict_t* x, const list_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_list_ldouble(dict_t* x, const list_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_map_pointer(dict_t* x, const map_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_cstring(dict_t* x, const map_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_string (dict_t* x, const map_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_array (dict_t* x, const map_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_list (dict_t* x, const map_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_map (dict_t* x, const map_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_vset (dict_t* x, const map_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_dict (dict_t* x, const map_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_map_boolean(dict_t* x, const map_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_int8 (dict_t* x, const map_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_int16 (dict_t* x, const map_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_int32 (dict_t* x, const map_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_int64 (dict_t* x, const map_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_uint8 (dict_t* x, const map_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_uint16 (dict_t* x, const map_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_uint32 (dict_t* x, const map_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_uint64 (dict_t* x, const map_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_float (dict_t* x, const map_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_double (dict_t* x, const map_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_map_ldouble(dict_t* x, const map_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_vset_pointer(dict_t* x, const set_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_cstring(dict_t* x, const set_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_string (dict_t* x, const set_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_array (dict_t* x, const set_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_list (dict_t* x, const set_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_map (dict_t* x, const set_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_vset (dict_t* x, const set_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_dict (dict_t* x, const set_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_vset_boolean(dict_t* x, const set_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_int8 (dict_t* x, const set_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_int16 (dict_t* x, const set_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_int32 (dict_t* x, const set_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_int64 (dict_t* x, const set_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_uint8 (dict_t* x, const set_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_uint16 (dict_t* x, const set_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_uint32 (dict_t* x, const set_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_uint64 (dict_t* x, const set_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_float (dict_t* x, const set_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_double (dict_t* x, const set_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_vset_ldouble(dict_t* x, const set_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_dict_pointer(dict_t* x, const dict_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_cstring(dict_t* x, const dict_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_string (dict_t* x, const dict_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_array (dict_t* x, const dict_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_list (dict_t* x, const dict_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_map (dict_t* x, const dict_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_vset (dict_t* x, const dict_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_dict (dict_t* x, const dict_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_dict_update_dict_boolean(dict_t* x, const dict_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_int8 (dict_t* x, const dict_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_int16 (dict_t* x, const dict_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_int32 (dict_t* x, const dict_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_int64 (dict_t* x, const dict_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_uint8 (dict_t* x, const dict_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_uint16 (dict_t* x, const dict_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_uint32 (dict_t* x, const dict_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_uint64 (dict_t* x, const dict_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_float (dict_t* x, const dict_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_double (dict_t* x, const dict_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_dict_ldouble(dict_t* x, const dict_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_boolean_pointer(dict_t* x, bool k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_cstring(dict_t* x, bool k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_string (dict_t* x, bool k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_array (dict_t* x, bool k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_list (dict_t* x, bool k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_map (dict_t* x, bool k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_vset (dict_t* x, bool k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_dict (dict_t* x, bool k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_boolean_boolean(dict_t* x, bool k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_int8 (dict_t* x, bool k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_int16 (dict_t* x, bool k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_int32 (dict_t* x, bool k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_int64 (dict_t* x, bool k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_uint8 (dict_t* x, bool k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_uint16 (dict_t* x, bool k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_uint32 (dict_t* x, bool k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_uint64 (dict_t* x, bool k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_float (dict_t* x, bool k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_double (dict_t* x, bool k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_boolean_ldouble(dict_t* x, bool k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_uint8_pointer(dict_t* x, u8_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_cstring(dict_t* x, u8_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_string (dict_t* x, u8_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_array (dict_t* x, u8_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_list (dict_t* x, u8_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_map (dict_t* x, u8_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_vset (dict_t* x, u8_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_dict (dict_t* x, u8_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint8_boolean(dict_t* x, u8_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_int8 (dict_t* x, u8_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_int16 (dict_t* x, u8_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_int32 (dict_t* x, u8_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_int64 (dict_t* x, u8_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_uint8 (dict_t* x, u8_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_uint16 (dict_t* x, u8_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_uint32 (dict_t* x, u8_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_uint64 (dict_t* x, u8_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_float (dict_t* x, u8_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_double (dict_t* x, u8_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint8_ldouble(dict_t* x, u8_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_uint16_pointer(dict_t* x, u16_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_cstring(dict_t* x, u16_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_string (dict_t* x, u16_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_array (dict_t* x, u16_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_list (dict_t* x, u16_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_map (dict_t* x, u16_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_vset (dict_t* x, u16_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_dict (dict_t* x, u16_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint16_boolean(dict_t* x, u16_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_int8 (dict_t* x, u16_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_int16 (dict_t* x, u16_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_int32 (dict_t* x, u16_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_int64 (dict_t* x, u16_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_uint8 (dict_t* x, u16_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_uint16 (dict_t* x, u16_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_uint32 (dict_t* x, u16_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_uint64 (dict_t* x, u16_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_float (dict_t* x, u16_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_double (dict_t* x, u16_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint16_ldouble(dict_t* x, u16_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_uint32_pointer(dict_t* x, u32_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_cstring(dict_t* x, u32_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_string (dict_t* x, u32_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_array (dict_t* x, u32_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_list (dict_t* x, u32_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_map (dict_t* x, u32_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_vset (dict_t* x, u32_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_dict (dict_t* x, u32_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint32_boolean(dict_t* x, u32_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_int8 (dict_t* x, u32_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_int16 (dict_t* x, u32_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_int32 (dict_t* x, u32_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_int64 (dict_t* x, u32_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_uint8 (dict_t* x, u32_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_uint16 (dict_t* x, u32_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_uint32 (dict_t* x, u32_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_uint64 (dict_t* x, u32_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_float (dict_t* x, u32_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_double (dict_t* x, u32_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint32_ldouble(dict_t* x, u32_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_uint64_pointer(dict_t* x, u64_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_cstring(dict_t* x, u64_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_string (dict_t* x, u64_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_array (dict_t* x, u64_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_list (dict_t* x, u64_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_map (dict_t* x, u64_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_vset (dict_t* x, u64_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_dict (dict_t* x, u64_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_uint64_boolean(dict_t* x, u64_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_int8 (dict_t* x, u64_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_int16 (dict_t* x, u64_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_int32 (dict_t* x, u64_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_int64 (dict_t* x, u64_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_uint8 (dict_t* x, u64_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_uint16 (dict_t* x, u64_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_uint32 (dict_t* x, u64_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_uint64 (dict_t* x, u64_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_float (dict_t* x, u64_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_double (dict_t* x, u64_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_uint64_ldouble(dict_t* x, u64_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_int8_pointer(dict_t* x, s8_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_cstring(dict_t* x, s8_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_string (dict_t* x, s8_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_array (dict_t* x, s8_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_list (dict_t* x, s8_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_map (dict_t* x, s8_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_vset (dict_t* x, s8_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_dict (dict_t* x, s8_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int8_boolean(dict_t* x, s8_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_int8 (dict_t* x, s8_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_int16 (dict_t* x, s8_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_int32 (dict_t* x, s8_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_int64 (dict_t* x, s8_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_uint8 (dict_t* x, s8_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_uint16 (dict_t* x, s8_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_uint32 (dict_t* x, s8_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_uint64 (dict_t* x, s8_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_float (dict_t* x, s8_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_double (dict_t* x, s8_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int8_ldouble(dict_t* x, s8_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_int16_pointer(dict_t* x, s16_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_cstring(dict_t* x, s16_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_string (dict_t* x, s16_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_array (dict_t* x, s16_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_list (dict_t* x, s16_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_map (dict_t* x, s16_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_vset (dict_t* x, s16_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_dict (dict_t* x, s16_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int16_boolean(dict_t* x, s16_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_int8 (dict_t* x, s16_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_int16 (dict_t* x, s16_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_int32 (dict_t* x, s16_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_int64 (dict_t* x, s16_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_uint8 (dict_t* x, s16_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_uint16 (dict_t* x, s16_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_uint32 (dict_t* x, s16_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_uint64 (dict_t* x, s16_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_float (dict_t* x, s16_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_double (dict_t* x, s16_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int16_ldouble(dict_t* x, s16_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_int32_pointer(dict_t* x, s32_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_cstring(dict_t* x, s32_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_string (dict_t* x, s32_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_array (dict_t* x, s32_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_list (dict_t* x, s32_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_map (dict_t* x, s32_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_vset (dict_t* x, s32_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_dict (dict_t* x, s32_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int32_boolean(dict_t* x, s32_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_int8 (dict_t* x, s32_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_int16 (dict_t* x, s32_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_int32 (dict_t* x, s32_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_int64 (dict_t* x, s32_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_uint8 (dict_t* x, s32_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_uint16 (dict_t* x, s32_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_uint32 (dict_t* x, s32_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_uint64 (dict_t* x, s32_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_float (dict_t* x, s32_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_double (dict_t* x, s32_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int32_ldouble(dict_t* x, s32_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_int64_pointer(dict_t* x, s64_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_cstring(dict_t* x, s64_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_string (dict_t* x, s64_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_array (dict_t* x, s64_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_list (dict_t* x, s64_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_map (dict_t* x, s64_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_vset (dict_t* x, s64_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_dict (dict_t* x, s64_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_int64_boolean(dict_t* x, s64_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_int8 (dict_t* x, s64_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_int16 (dict_t* x, s64_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_int32 (dict_t* x, s64_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_int64 (dict_t* x, s64_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_uint8 (dict_t* x, s64_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_uint16 (dict_t* x, s64_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_uint32 (dict_t* x, s64_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_uint64 (dict_t* x, s64_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_float (dict_t* x, s64_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_double (dict_t* x, s64_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_int64_ldouble(dict_t* x, s64_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_float_pointer(dict_t* x, fl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_cstring(dict_t* x, fl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_string (dict_t* x, fl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_array (dict_t* x, fl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_list (dict_t* x, fl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_map (dict_t* x, fl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_vset (dict_t* x, fl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_dict (dict_t* x, fl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_float_boolean(dict_t* x, fl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_int8 (dict_t* x, fl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_int16 (dict_t* x, fl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_int32 (dict_t* x, fl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_int64 (dict_t* x, fl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_uint8 (dict_t* x, fl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_uint16 (dict_t* x, fl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_uint32 (dict_t* x, fl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_uint64 (dict_t* x, fl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_float (dict_t* x, fl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_double (dict_t* x, fl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_float_ldouble(dict_t* x, fl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_double_pointer(dict_t* x, dbl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_cstring(dict_t* x, dbl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_string (dict_t* x, dbl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_array (dict_t* x, dbl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_list (dict_t* x, dbl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_map (dict_t* x, dbl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_vset (dict_t* x, dbl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_dict (dict_t* x, dbl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_double_boolean(dict_t* x, dbl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_int8 (dict_t* x, dbl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_int16 (dict_t* x, dbl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_int32 (dict_t* x, dbl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_int64 (dict_t* x, dbl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_uint8 (dict_t* x, dbl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_uint16 (dict_t* x, dbl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_uint32 (dict_t* x, dbl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_uint64 (dict_t* x, dbl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_float (dict_t* x, dbl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_double (dict_t* x, dbl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_double_ldouble(dict_t* x, dbl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } + +bool libcdsb_dict_update_ldouble_pointer(dict_t* x, ldbl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_cstring(dict_t* x, ldbl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_string (dict_t* x, ldbl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_array (dict_t* x, ldbl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_list (dict_t* x, ldbl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_map (dict_t* x, ldbl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_vset (dict_t* x, ldbl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_dict (dict_t* x, ldbl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_dict_update_ldouble_boolean(dict_t* x, ldbl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_int8 (dict_t* x, ldbl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_int16 (dict_t* x, ldbl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_int32 (dict_t* x, ldbl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_int64 (dict_t* x, ldbl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_uint8 (dict_t* x, ldbl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_uint16 (dict_t* x, ldbl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_uint32 (dict_t* x, ldbl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_uint64 (dict_t* x, ldbl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_float (dict_t* x, ldbl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_double (dict_t* x, ldbl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_dict_update_ldouble_ldouble(dict_t* x, ldbl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } diff --git a/src/list/generics.c b/src/list/generics.c index 5e44da7..c2157e6 100644 --- a/src/list/generics.c +++ b/src/list/generics.c @@ -10,6 +10,7 @@ int libcdsb_list_find_array (list_t* x, const arr_t* v, void* _, list_access_c 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_dict (list_t* x, const dict_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); } @@ -30,6 +31,7 @@ size_t libcdsb_list_count_array (const list_t* s, const arr_t* v) { return lib size_t libcdsb_list_count_list (const list_t* s, const list_t* v) { return libcdsb_list_count((void*)s, v, vtypeof( v)); } size_t libcdsb_list_count_map (const list_t* s, const map_t* v) { return libcdsb_list_count((void*)s, v, vtypeof( v)); } size_t libcdsb_list_count_vset (const list_t* s, const set_t* v) { return libcdsb_list_count((void*)s, v, vtypeof( v)); } +size_t libcdsb_list_count_dict (const list_t* s, const dict_t* v) { return libcdsb_list_count((void*)s, v, vtypeof( v)); } size_t libcdsb_list_count_boolean(const list_t* s, bool v) { return libcdsb_list_count((void*)s, &v, vtypeof(&v)); } size_t libcdsb_list_count_int8 (const list_t* s, s8_t v) { return libcdsb_list_count((void*)s, &v, vtypeof(&v)); } size_t libcdsb_list_count_int16 (const list_t* s, s16_t v) { return libcdsb_list_count((void*)s, &v, vtypeof(&v)); } @@ -50,6 +52,7 @@ bool libcdsb_list_update_array (list_t* x, ssize_t i, const arr_t* v, int ins) bool libcdsb_list_update_list (list_t* x, ssize_t i, const list_t* v, int ins) { return libcdsb_list_update(x, i, v, vtypeof( v), ins); } bool libcdsb_list_update_map (list_t* x, ssize_t i, const map_t* v, int ins) { return libcdsb_list_update(x, i, v, vtypeof( v), ins); } bool libcdsb_list_update_vset (list_t* x, ssize_t i, const set_t* v, int ins) { return libcdsb_list_update(x, i, v, vtypeof( v), ins); } +bool libcdsb_list_update_dict (list_t* x, ssize_t i, const dict_t* v, int ins) { return libcdsb_list_update(x, i, v, vtypeof( v), ins); } bool libcdsb_list_update_boolean(list_t* x, ssize_t i, bool v, int ins) { return libcdsb_list_update(x, i, &v, vtypeof(&v), ins); } bool libcdsb_list_update_int8 (list_t* x, ssize_t i, s8_t v, int ins) { return libcdsb_list_update(x, i, &v, vtypeof(&v), ins); } bool libcdsb_list_update_int16 (list_t* x, ssize_t i, s16_t v, int ins) { return libcdsb_list_update(x, i, &v, vtypeof(&v), ins); } diff --git a/src/map/generics.c b/src/map/generics.c index a8e1642..649ed10 100644 --- a/src/map/generics.c +++ b/src/map/generics.c @@ -10,6 +10,7 @@ int libcdsb_map_find_array (map_t* x, const arr_t* k, void* _, map_access_call 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_dict (map_t* x, const dict_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); } @@ -23,13 +24,14 @@ int libcdsb_map_find_float (map_t* x, fl_t k, void* _, map_access_call 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)); } -bool libcdsb_map_update_pointer_string (map_t* x, const void* k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_pointer_array (map_t* x, const void* k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +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)); } +bool libcdsb_map_update_pointer_string (map_t* x, const void* k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_pointer_array (map_t* x, const void* k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_pointer_list (map_t* x, const void* k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_pointer_map (map_t* x, const void* k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_pointer_vset (map_t* x, const void* k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_pointer_map (map_t* x, const void* k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_pointer_vset (map_t* x, const void* k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_pointer_dict (map_t* x, const void* k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_pointer_boolean(map_t* x, const void* k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_pointer_int8 (map_t* x, const void* k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_pointer_int16 (map_t* x, const void* k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -43,13 +45,14 @@ bool libcdsb_map_update_pointer_float (map_t* x, const void* k, fl_t v bool libcdsb_map_update_pointer_double (map_t* x, const void* k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_pointer_ldouble(map_t* x, const void* k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_cstring_pointer(map_t* x, const char* k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_cstring_cstring(map_t* x, const char* k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_cstring_string (map_t* x, const char* k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_cstring_array (map_t* x, const char* k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_cstring_pointer(map_t* x, const char* k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_cstring_cstring(map_t* x, const char* k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_cstring_string (map_t* x, const char* k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_cstring_array (map_t* x, const char* k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_cstring_list (map_t* x, const char* k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_cstring_map (map_t* x, const char* k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_cstring_vset (map_t* x, const char* k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_cstring_map (map_t* x, const char* k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_cstring_vset (map_t* x, const char* k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_cstring_dict (map_t* x, const char* k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_cstring_boolean(map_t* x, const char* k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_cstring_int8 (map_t* x, const char* k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_cstring_int16 (map_t* x, const char* k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -63,13 +66,14 @@ bool libcdsb_map_update_cstring_float (map_t* x, const char* k, fl_t v bool libcdsb_map_update_cstring_double (map_t* x, const char* k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_cstring_ldouble(map_t* x, const char* k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_string_pointer(map_t* x, const str_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_string_cstring(map_t* x, const str_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_string_string (map_t* x, const str_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_string_array (map_t* x, const str_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_string_pointer(map_t* x, const str_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_string_cstring(map_t* x, const str_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_string_string (map_t* x, const str_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_string_array (map_t* x, const str_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_string_list (map_t* x, const str_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_string_map (map_t* x, const str_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_string_vset (map_t* x, const str_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_string_map (map_t* x, const str_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_string_vset (map_t* x, const str_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_string_dict (map_t* x, const str_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_string_boolean(map_t* x, const str_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_string_int8 (map_t* x, const str_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_string_int16 (map_t* x, const str_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } @@ -83,13 +87,14 @@ bool libcdsb_map_update_string_float (map_t* x, const str_t* k, fl_t v bool libcdsb_map_update_string_double (map_t* x, const str_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_string_ldouble(map_t* x, const str_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_array_pointer(map_t* x, const arr_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_array_cstring(map_t* x, const arr_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_array_string (map_t* x, const arr_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_array_array (map_t* x, const arr_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_array_pointer(map_t* x, const arr_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_array_cstring(map_t* x, const arr_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_array_string (map_t* x, const arr_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_array_array (map_t* x, const arr_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_array_list (map_t* x, const arr_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_array_map (map_t* x, const arr_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_array_vset (map_t* x, const arr_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_array_map (map_t* x, const arr_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_array_vset (map_t* x, const arr_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_array_dict (map_t* x, const arr_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_array_boolean(map_t* x, const arr_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_array_int8 (map_t* x, const arr_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_array_int16 (map_t* x, const arr_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } @@ -103,13 +108,14 @@ bool libcdsb_map_update_array_float (map_t* x, const arr_t* k, fl_t v) bool libcdsb_map_update_array_double (map_t* x, const arr_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_array_ldouble(map_t* x, const arr_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_list_pointer(map_t* x, const list_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_list_cstring(map_t* x, const list_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_list_string (map_t* x, const list_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_list_array (map_t* x, const list_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_list_pointer(map_t* x, const list_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_list_cstring(map_t* x, const list_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_list_string (map_t* x, const list_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_list_array (map_t* x, const list_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_list_list (map_t* x, const list_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_list_map (map_t* x, const list_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_list_vset (map_t* x, const list_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_list_map (map_t* x, const list_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_list_vset (map_t* x, const list_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_list_dict (map_t* x, const list_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_list_boolean(map_t* x, const list_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_list_int8 (map_t* x, const list_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_list_int16 (map_t* x, const list_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } @@ -123,13 +129,14 @@ bool libcdsb_map_update_list_float (map_t* x, const list_t* k, fl_t v) bool libcdsb_map_update_list_double (map_t* x, const list_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_list_ldouble(map_t* x, const list_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_map_pointer(map_t* x, const map_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_map_cstring(map_t* x, const map_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_map_string (map_t* x, const map_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_map_array (map_t* x, const map_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_map_pointer(map_t* x, const map_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_map_cstring(map_t* x, const map_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_map_string (map_t* x, const map_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_map_array (map_t* x, const map_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_map_list (map_t* x, const map_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_map_map (map_t* x, const map_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_map_vset (map_t* x, const map_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_map_map (map_t* x, const map_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_map_vset (map_t* x, const map_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_map_dict (map_t* x, const map_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_map_boolean(map_t* x, const map_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_map_int8 (map_t* x, const map_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_map_int16 (map_t* x, const map_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } @@ -143,13 +150,14 @@ bool libcdsb_map_update_map_float (map_t* x, const map_t* k, fl_t v) { bool libcdsb_map_update_map_double (map_t* x, const map_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_map_ldouble(map_t* x, const map_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_vset_pointer(map_t* x, const set_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_vset_cstring(map_t* x, const set_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_vset_string (map_t* x, const set_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_vset_array (map_t* x, const set_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_vset_pointer(map_t* x, const set_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_vset_cstring(map_t* x, const set_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_vset_string (map_t* x, const set_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_vset_array (map_t* x, const set_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_vset_list (map_t* x, const set_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_vset_map (map_t* x, const set_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_map_update_vset_vset (map_t* x, const set_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_vset_map (map_t* x, const set_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_vset_vset (map_t* x, const set_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_vset_dict (map_t* x, const set_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } bool libcdsb_map_update_vset_boolean(map_t* x, const set_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_vset_int8 (map_t* x, const set_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_vset_int16 (map_t* x, const set_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } @@ -163,13 +171,35 @@ bool libcdsb_map_update_vset_float (map_t* x, const set_t* k, fl_t v) bool libcdsb_map_update_vset_double (map_t* x, const set_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } bool libcdsb_map_update_vset_ldouble(map_t* x, const set_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_map_update_boolean_pointer(map_t* x, const bool k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_boolean_cstring(map_t* x, const bool k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_boolean_string (map_t* x, const bool k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_boolean_array (map_t* x, const bool k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_pointer(map_t* x, const dict_t* k, const void* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_cstring(map_t* x, const dict_t* k, const char* v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_string (map_t* x, const dict_t* k, const str_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_array (map_t* x, const dict_t* k, const arr_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_list (map_t* x, const dict_t* k, const list_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_map (map_t* x, const dict_t* k, const map_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_vset (map_t* x, const dict_t* k, const set_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_dict (map_t* x, const dict_t* k, const dict_t* v) { return libcdsb_map_update(x, k, vtypeof(k), v, vtypeof( v)); } +bool libcdsb_map_update_dict_boolean(map_t* x, const dict_t* k, bool v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_int8 (map_t* x, const dict_t* k, s8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_int16 (map_t* x, const dict_t* k, s16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_int32 (map_t* x, const dict_t* k, s32_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_int64 (map_t* x, const dict_t* k, s64_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_uint8 (map_t* x, const dict_t* k, u8_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_uint16 (map_t* x, const dict_t* k, u16_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_uint32 (map_t* x, const dict_t* k, u32_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_uint64 (map_t* x, const dict_t* k, u64_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_float (map_t* x, const dict_t* k, fl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_double (map_t* x, const dict_t* k, dbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } +bool libcdsb_map_update_dict_ldouble(map_t* x, const dict_t* k, ldbl_t v) { return libcdsb_map_update(x, k, vtypeof(k), &v, vtypeof(&v)); } + +bool libcdsb_map_update_boolean_pointer(map_t* x, const bool k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_boolean_cstring(map_t* x, const bool k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_boolean_string (map_t* x, const bool k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_boolean_array (map_t* x, const bool k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_boolean_list (map_t* x, const bool k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_boolean_map (map_t* x, const bool k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_boolean_vset (map_t* x, const bool k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_boolean_map (map_t* x, const bool k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_boolean_vset (map_t* x, const bool k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_boolean_dict (map_t* x, const bool k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_boolean_boolean(map_t* x, const bool k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_boolean_int8 (map_t* x, const bool k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_boolean_int16 (map_t* x, const bool k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -183,13 +213,14 @@ bool libcdsb_map_update_boolean_float (map_t* x, const bool k, fl_t v) bool libcdsb_map_update_boolean_double (map_t* x, const bool k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_boolean_ldouble(map_t* x, const bool k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int8_pointer(map_t* x, const s8_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int8_cstring(map_t* x, const s8_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int8_string (map_t* x, const s8_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int8_array (map_t* x, const s8_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int8_pointer(map_t* x, const s8_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int8_cstring(map_t* x, const s8_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int8_string (map_t* x, const s8_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int8_array (map_t* x, const s8_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int8_list (map_t* x, const s8_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int8_map (map_t* x, const s8_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int8_vset (map_t* x, const s8_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int8_map (map_t* x, const s8_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int8_vset (map_t* x, const s8_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int8_dict (map_t* x, const s8_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int8_boolean(map_t* x, const s8_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int8_int8 (map_t* x, const s8_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int8_int16 (map_t* x, const s8_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -203,13 +234,14 @@ bool libcdsb_map_update_int8_float (map_t* x, const s8_t k, fl_t v) { bool libcdsb_map_update_int8_double (map_t* x, const s8_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int8_ldouble(map_t* x, const s8_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int16_pointer(map_t* x, const s16_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int16_cstring(map_t* x, const s16_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int16_string (map_t* x, const s16_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int16_array (map_t* x, const s16_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int16_pointer(map_t* x, const s16_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int16_cstring(map_t* x, const s16_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int16_string (map_t* x, const s16_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int16_array (map_t* x, const s16_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int16_list (map_t* x, const s16_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int16_map (map_t* x, const s16_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int16_vset (map_t* x, const s16_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int16_map (map_t* x, const s16_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int16_vset (map_t* x, const s16_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int16_dict (map_t* x, const s16_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int16_boolean(map_t* x, const s16_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int16_int8 (map_t* x, const s16_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int16_int16 (map_t* x, const s16_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -223,13 +255,14 @@ bool libcdsb_map_update_int16_float (map_t* x, const s16_t k, fl_t v) bool libcdsb_map_update_int16_double (map_t* x, const s16_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int16_ldouble(map_t* x, const s16_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int32_pointer(map_t* x, const s32_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int32_cstring(map_t* x, const s32_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int32_string (map_t* x, const s32_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int32_array (map_t* x, const s32_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int32_pointer(map_t* x, const s32_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int32_cstring(map_t* x, const s32_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int32_string (map_t* x, const s32_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int32_array (map_t* x, const s32_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int32_list (map_t* x, const s32_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int32_map (map_t* x, const s32_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int32_vset (map_t* x, const s32_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int32_map (map_t* x, const s32_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int32_vset (map_t* x, const s32_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int32_dict (map_t* x, const s32_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int32_boolean(map_t* x, const s32_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int32_int8 (map_t* x, const s32_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int32_int16 (map_t* x, const s32_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -243,13 +276,14 @@ bool libcdsb_map_update_int32_float (map_t* x, const s32_t k, fl_t v) bool libcdsb_map_update_int32_double (map_t* x, const s32_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int32_ldouble(map_t* x, const s32_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int64_pointer(map_t* x, const s64_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int64_cstring(map_t* x, const s64_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_int64_string (map_t* x, const s64_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int64_array (map_t* x, const s64_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int64_pointer(map_t* x, const s64_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int64_cstring(map_t* x, const s64_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_int64_string (map_t* x, const s64_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int64_array (map_t* x, const s64_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int64_list (map_t* x, const s64_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int64_map (map_t* x, const s64_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_int64_vset (map_t* x, const s64_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int64_map (map_t* x, const s64_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int64_vset (map_t* x, const s64_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_int64_dict (map_t* x, const s64_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_int64_boolean(map_t* x, const s64_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int64_int8 (map_t* x, const s64_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int64_int16 (map_t* x, const s64_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -263,13 +297,14 @@ bool libcdsb_map_update_int64_float (map_t* x, const s64_t k, fl_t v) bool libcdsb_map_update_int64_double (map_t* x, const s64_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_int64_ldouble(map_t* x, const s64_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint8_pointer(map_t* x, const u8_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint8_cstring(map_t* x, const u8_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint8_string (map_t* x, const u8_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint8_array (map_t* x, const u8_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint8_pointer(map_t* x, const u8_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint8_cstring(map_t* x, const u8_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint8_string (map_t* x, const u8_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint8_array (map_t* x, const u8_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint8_list (map_t* x, const u8_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint8_map (map_t* x, const u8_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint8_vset (map_t* x, const u8_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint8_map (map_t* x, const u8_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint8_vset (map_t* x, const u8_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint8_dict (map_t* x, const u8_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint8_boolean(map_t* x, const u8_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint8_int8 (map_t* x, const u8_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint8_int16 (map_t* x, const u8_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -283,13 +318,14 @@ bool libcdsb_map_update_uint8_float (map_t* x, const u8_t k, fl_t v) { bool libcdsb_map_update_uint8_double (map_t* x, const u8_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint8_ldouble(map_t* x, const u8_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint16_pointer(map_t* x, const u16_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint16_cstring(map_t* x, const u16_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint16_string (map_t* x, const u16_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint16_array (map_t* x, const u16_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint16_pointer(map_t* x, const u16_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint16_cstring(map_t* x, const u16_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint16_string (map_t* x, const u16_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint16_array (map_t* x, const u16_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint16_list (map_t* x, const u16_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint16_map (map_t* x, const u16_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint16_vset (map_t* x, const u16_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint16_map (map_t* x, const u16_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint16_vset (map_t* x, const u16_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint16_dict (map_t* x, const u16_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint16_boolean(map_t* x, const u16_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint16_int8 (map_t* x, const u16_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint16_int16 (map_t* x, const u16_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -303,13 +339,14 @@ bool libcdsb_map_update_uint16_float (map_t* x, const u16_t k, fl_t v) bool libcdsb_map_update_uint16_double (map_t* x, const u16_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint16_ldouble(map_t* x, const u16_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint32_pointer(map_t* x, const u32_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint32_cstring(map_t* x, const u32_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint32_string (map_t* x, const u32_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint32_array (map_t* x, const u32_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint32_pointer(map_t* x, const u32_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint32_cstring(map_t* x, const u32_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint32_string (map_t* x, const u32_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint32_array (map_t* x, const u32_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint32_list (map_t* x, const u32_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint32_map (map_t* x, const u32_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint32_vset (map_t* x, const u32_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint32_map (map_t* x, const u32_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint32_vset (map_t* x, const u32_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint32_dict (map_t* x, const u32_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint32_boolean(map_t* x, const u32_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint32_int8 (map_t* x, const u32_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint32_int16 (map_t* x, const u32_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -323,13 +360,14 @@ bool libcdsb_map_update_uint32_float (map_t* x, const u32_t k, fl_t v) bool libcdsb_map_update_uint32_double (map_t* x, const u32_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint32_ldouble(map_t* x, const u32_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint64_pointer(map_t* x, const u64_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint64_cstring(map_t* x, const u64_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_uint64_string (map_t* x, const u64_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint64_array (map_t* x, const u64_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint64_pointer(map_t* x, const u64_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint64_cstring(map_t* x, const u64_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_uint64_string (map_t* x, const u64_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint64_array (map_t* x, const u64_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint64_list (map_t* x, const u64_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint64_map (map_t* x, const u64_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_uint64_vset (map_t* x, const u64_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint64_map (map_t* x, const u64_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint64_vset (map_t* x, const u64_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_uint64_dict (map_t* x, const u64_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_uint64_boolean(map_t* x, const u64_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint64_int8 (map_t* x, const u64_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint64_int16 (map_t* x, const u64_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -343,13 +381,14 @@ bool libcdsb_map_update_uint64_float (map_t* x, const u64_t k, fl_t v) bool libcdsb_map_update_uint64_double (map_t* x, const u64_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_uint64_ldouble(map_t* x, const u64_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_float_pointer(map_t* x, const fl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_float_cstring(map_t* x, const fl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_float_string (map_t* x, const fl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_float_array (map_t* x, const fl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_float_pointer(map_t* x, const fl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_float_cstring(map_t* x, const fl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_float_string (map_t* x, const fl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_float_array (map_t* x, const fl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_float_list (map_t* x, const fl_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_float_map (map_t* x, const fl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_float_vset (map_t* x, const fl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_float_map (map_t* x, const fl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_float_vset (map_t* x, const fl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_float_dict (map_t* x, const fl_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_float_boolean(map_t* x, const fl_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_float_int8 (map_t* x, const fl_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_float_int16 (map_t* x, const fl_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -363,13 +402,14 @@ bool libcdsb_map_update_float_float (map_t* x, const fl_t k, fl_t v) { bool libcdsb_map_update_float_double (map_t* x, const fl_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_float_ldouble(map_t* x, const fl_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_double_pointer(map_t* x, const dbl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_double_cstring(map_t* x, const dbl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_double_string (map_t* x, const dbl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_double_array (map_t* x, const dbl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_double_pointer(map_t* x, const dbl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_double_cstring(map_t* x, const dbl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_double_string (map_t* x, const dbl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_double_array (map_t* x, const dbl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_double_list (map_t* x, const dbl_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_double_map (map_t* x, const dbl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_double_vset (map_t* x, const dbl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_double_map (map_t* x, const dbl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_double_vset (map_t* x, const dbl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_double_dict (map_t* x, const dbl_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_double_boolean(map_t* x, const dbl_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_double_int8 (map_t* x, const dbl_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_double_int16 (map_t* x, const dbl_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } @@ -383,13 +423,14 @@ bool libcdsb_map_update_double_float (map_t* x, const dbl_t k, fl_t v) bool libcdsb_map_update_double_double (map_t* x, const dbl_t k, dbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_double_ldouble(map_t* x, const dbl_t k, ldbl_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_ldouble_pointer(map_t* x, const ldbl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_ldouble_cstring(map_t* x, const ldbl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_map_update_ldouble_string (map_t* x, const ldbl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_ldouble_array (map_t* x, const ldbl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_ldouble_pointer(map_t* x, const ldbl_t k, const void* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_ldouble_cstring(map_t* x, const ldbl_t k, const char* v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } +bool libcdsb_map_update_ldouble_string (map_t* x, const ldbl_t k, const str_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_ldouble_array (map_t* x, const ldbl_t k, const arr_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_ldouble_list (map_t* x, const ldbl_t k, const list_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_ldouble_map (map_t* x, const ldbl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_map_update_ldouble_vset (map_t* x, const ldbl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_ldouble_map (map_t* x, const ldbl_t k, const map_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_ldouble_vset (map_t* x, const ldbl_t k, const set_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } +bool libcdsb_map_update_ldouble_dict (map_t* x, const ldbl_t k, const dict_t* v) { return libcdsb_map_update(x, &k, vtypeof(&k), v, vtypeof( v)); } bool libcdsb_map_update_ldouble_boolean(map_t* x, const ldbl_t k, bool v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_ldouble_int8 (map_t* x, const ldbl_t k, s8_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_map_update_ldouble_int16 (map_t* x, const ldbl_t k, s16_t v) { return libcdsb_map_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } diff --git a/src/set/generics.c b/src/set/generics.c index 65be7a1..bd88199 100644 --- a/src/set/generics.c +++ b/src/set/generics.c @@ -4,13 +4,14 @@ #include "../../include/extra/set.h" #include "../__internal/include.h" -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_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_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_dict (set_t* x, const dict_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); } @@ -24,13 +25,14 @@ int libcdsb_vset_find_float (set_t* x, fl_t v, void* _, vset_access_ca 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)); } -bool libcdsb_vset_push_string (set_t* x, const str_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } -bool libcdsb_vset_push_array (set_t* x, const arr_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } +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)); } +bool libcdsb_vset_push_string (set_t* x, const str_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } +bool libcdsb_vset_push_array (set_t* x, const arr_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } bool libcdsb_vset_push_list (set_t* x, const list_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } -bool libcdsb_vset_push_map (set_t* x, const map_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } -bool libcdsb_vset_push_vset (set_t* x, const set_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } +bool libcdsb_vset_push_map (set_t* x, const map_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } +bool libcdsb_vset_push_vset (set_t* x, const set_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } +bool libcdsb_vset_push_dict (set_t* x, const dict_t* v) { return libcdsb_vset_insert(x, v, vtypeof( v)); } bool libcdsb_vset_push_boolean(set_t* x, bool v) { return libcdsb_vset_insert(x, &v, vtypeof(&v)); } bool libcdsb_vset_push_int8 (set_t* x, s8_t v) { return libcdsb_vset_insert(x, &v, vtypeof(&v)); } bool libcdsb_vset_push_int16 (set_t* x, s16_t v) { return libcdsb_vset_insert(x, &v, vtypeof(&v)); } From 511516b2186d221ae94c1c0963321d89a01e0d66 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 14 Aug 2022 18:24:16 +0300 Subject: [PATCH 38/63] Refactor rbtree types --- src/__internal/rbtree.h | 15 +++ src/map/base.c | 151 +++++++++++++---------------- src/map/copy.c | 120 ----------------------- src/map/extra.c | 14 +-- src/map/include.h | 3 + src/rbtree-extra.c | 206 ++++++++++++++++++++++++++++++++++++++++ src/set/base.c | 113 ++++++++-------------- src/set/copy.c | 103 -------------------- 8 files changed, 332 insertions(+), 393 deletions(-) delete mode 100644 src/map/copy.c create mode 100644 src/rbtree-extra.c delete mode 100644 src/set/copy.c diff --git a/src/__internal/rbtree.h b/src/__internal/rbtree.h index 79edf6b..0db10a0 100644 --- a/src/__internal/rbtree.h +++ b/src/__internal/rbtree.h @@ -29,4 +29,19 @@ extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node); #define rbnode_is_empty(n) ((n) == rbnode_empty) #define rbnode_is_root(n) rbnode_is_empty((n)->parent) + +extern void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info); +extern int libcdsb_rbtree_compare(const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info); + +extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info); +extern size_t libcdsb_rbtree_size(const void* s); +extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info); + +#define rbtree_duplicate libcdsb_rbtree_duplicate +#define rbtree_compare libcdsb_rbtree_compare +#define rbtree_hash libcdsb_rbtree_hash +#define rbtree_size libcdsb_rbtree_size +#define rbtree_free libcdsb_rbtree_free + + #endif /* LIBCDSB_SRC_INTERNAL_RBTREE_H */ diff --git a/src/map/base.c b/src/map/base.c index 7251cfe..de82733 100644 --- a/src/map/base.c +++ b/src/map/base.c @@ -3,106 +3,89 @@ #include "include.h" +#define mtree_duplicate(s, t) rbtree_duplicate((rbnode_t*)s, (void*)mnode_duplicate, t) +#define mtree_compare(s0, s1, t) rbtree_compare((void*)s0, (void*)s1, (void*)mnode_compare, (void*)t) + +static mnode_t* mnode_duplicate(const mnode_t* s, mnode_t* p, const vtype* t) { + mnode_t* x; + + x = mnode_create(vnode_duplicate(&s->key, *t), p, s->colored); + x->type = s->type; + x->value = vnode_duplicate(&s->value, s->type); + + return x; +} + +static int mnode_compare(const mnode_t* s0, const mnode_t* s1, vtype* t) { + int c = vnode_compare_eq(&s0->key, &s1->key, *t); + + return !c ? vnode_compare(&s0->value, s0->type, &s1->value, s1->type) : c; +} + +static hash_t mnode_hash(const mnode_t* s, vtype* tp) { + vtype t = (!is_null(tp)) ? *tp : VTYPE_POINTER; + return vnode_hash(s->key, t) + vnode_hash(s->value, s->type) + t; +} + +void libcdsb_mnode_free(mnode_t* x, vtype* t) { + vnode_free(&x->key, *t); + vnode_free(&x->value, x->type); +} + +/*#####################################################################################################################*/ + +hash_t map_hash(const map_t* s) { + return rbtree_hash(s->root, (void*)mnode_hash, (void*)&s->type) + VTYPE_MAP; +} + void map_init(map_t* x, vtype t) { x->root = mnode_empty; x->type = t; } - void map_free(map_t* x) { - mnode_t* t; - mnode_t* c; - - c = x->root; - - while (!mnode_is_empty(x->root)) { - if (!mnode_is_empty(c->left)) { - c = c->left; - } else if (!mnode_is_empty(c->right)) { - c = c->right; - } else if (!mnode_is_root(c)) { - vnode_free(&c->key, x->type); - vnode_free(&c->value, c->type); - - t = c; - c = c->parent; - - if (t == c->left) c->left = mnode_empty; - else c->right = mnode_empty; - - free(t); - } else { - vnode_free(&c->key, x->type); - vnode_free(&c->value, c->type); - x->root = mnode_empty; - } - } + rbtree_free(x->root, (void*)mnode_free, &x->type); + x->root = mnode_empty; x->type = 0; } +/*#####################################################################################################################*/ size_t map_size(const map_t* x) { - stack_t z = { .prev = 0, .value = x->root }; - size_t n = 0; - rbnode_t* c; - - if (!mnode_is_empty(x->root)) { - while ((c = stack_pop(&z))) { - ++n; - if (!rbnode_is_empty(c->left)) - stack_push(&z, c->left); - if (!rbnode_is_empty(c->right)) - stack_push(&z, c->right); - } - } - - return n; + return rbtree_size(x->root); } +/*#####################################################################################################################*/ int map_compare(const map_t* s0, const map_t* s1) { - - stack_t z = { .prev = 0, .value = 0 }; - vtype t = s0->type; - int c = 0; - - if (s0 == s1 || s0->root == s1->root) return 0; + if (s0 == s1) return 0; if (s0->type != s1->type) return s0->type - s1->type; - stack_push(&z, s1->root); - stack_push(&z, s0->root); - - for (mnode_t *c0, *c1;!is_null(z.value);) { - c0 = stack_pop(&z); - c1 = stack_pop(&z); - - if (mnode_is_empty(c0) || mnode_is_empty(c1)) { - if (c0 != c1) { - stack_flush(&z); - return mnode_is_empty(c0) ? -1 : 1; - } - } else if ((c = vnode_compare(c0->key, t, c1->key, t)) || (c = vnode_compare(c0->value, c0->type, c1->value, c1->type))) { - if (c0->left == c1->right) { - c = vnode_compare(c1->key, t, c0->right->key, t ); - if (!c) c = vnode_compare(c1->value, c1->type, c0->right->value, c0->type); - if (!c) c = vnode_compare(c1->left->key, t, c0->key, t ); - if (!c) c = vnode_compare(c1->left->value, c1->type, c0->value, c0->type); - } else if (c0->right == c1->left) { - c = vnode_compare(c0->key, t, c1->right->key, t ); - if (!c) c = vnode_compare(c0->value, c0->type, c1->right->value, c1->type); - if (!c) c = vnode_compare(c0->left->key, t, c1->key, t ); - if (!c) c = vnode_compare(c0->left->value, c0->type, c1->value, c1->type); - } - - if (c) { stack_flush(&z); return c; } - } else { - stack_push(&z, c1->right); - stack_push(&z, c0->right); - stack_push(&z, c1->left); - stack_push(&z, c0->left); - } - } - - return 0; + return mtree_compare(s0->root, s1->root, &s0->type); +} + +/*#####################################################################################################################*/ + +map_t map_copy(const map_t* s) { + map_t x; + + x.type = s->type; + x.root = mtree_duplicate(s->root, &x.type); + + return x; +} + +map_t* map_duplicate(const map_t* s) { + map_t *x = malloc(sizeof(*x)); + + x->type = s->type; + x->root = mtree_duplicate(s->root, &x->type); + + return x; +} + +void map_copy_init(map_t* x, const map_t* s) { + x->type = s->type; + x->root = mtree_duplicate(s->root, &x->type); } diff --git a/src/map/copy.c b/src/map/copy.c deleted file mode 100644 index ba5b31f..0000000 --- a/src/map/copy.c +++ /dev/null @@ -1,120 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "include.h" - -map_t map_copy(const map_t* s) { - - map_t x = { .type = s->type }; - stack_t z = { .prev = 0, .value = s->root }; - vtype t = s->type; - - if (!mnode_is_empty(s->root)) { - x.root = mnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x.root); - - do { - mnode_t *p0 = stack_pop(&z); - mnode_t *p1 = stack_pop(&z); - - if (!mnode_is_empty(p1->left)) { - p0->left = mnode_create(vnode_duplicate(&p1->left->key, t), p0, p1->left->colored); - p0->left->type = p1->left->type; - p0->left->value = vnode_duplicate(&p1->left->value, p1->left->type); - - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!mnode_is_empty(p1->right)) { - p0->right = mnode_create(vnode_duplicate(&p1->right->key, t), p0, p1->right->colored); - p0->right->type = p1->right->type; - p0->right->value = vnode_duplicate(&p1->right->value, p1->right->type); - - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x.root = mnode_empty; - - return x; -} - - -map_t* map_duplicate(const map_t* s) { - - map_t* x = malloc(sizeof(*x)); - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; - - if (!mnode_is_empty(s->root)) { - x->root = mnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x->root); - - do { - mnode_t *p0 = stack_pop(&z); - mnode_t *p1 = stack_pop(&z); - - if (!mnode_is_empty(p1->left)) { - p0->left = mnode_create(vnode_duplicate(&p1->left->key, t), p0, p1->left->colored); - p0->left->type = p1->left->type; - p0->left->value = vnode_duplicate(&p1->left->value, p1->left->type); - - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!mnode_is_empty(p1->right)) { - p0->right = mnode_create(vnode_duplicate(&p1->right->key, t), p0, p1->right->colored); - p0->right->type = p1->right->type; - p0->right->value = vnode_duplicate(&p1->right->value, p1->right->type); - - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x->root = mnode_empty; - - return x; -} - - -void map_copy_init(map_t* x, const map_t* s) { - - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; - - if (!mnode_is_empty(s->root)) { - x->root = mnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x->root); - - do { - mnode_t *p0 = stack_pop(&z); - mnode_t *p1 = stack_pop(&z); - - if (!mnode_is_empty(p1->left)) { - p0->left = mnode_create(vnode_duplicate(&p1->left->key, t), p0, p1->left->colored); - p0->left->type = p1->left->type; - p0->left->value = vnode_duplicate(&p1->left->value, p1->left->type); - - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!mnode_is_empty(p1->right)) { - p0->right = mnode_create(vnode_duplicate(&p1->right->key, t), p0, p1->right->colored); - p0->right->type = p1->right->type; - p0->right->value = vnode_duplicate(&p1->right->value, p1->right->type); - - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x->root = mnode_empty; -} diff --git a/src/map/extra.c b/src/map/extra.c index b657db3..5f28450 100644 --- a/src/map/extra.c +++ b/src/map/extra.c @@ -20,8 +20,7 @@ bool libcdsb_map_update(map_t* x, const void* k, vtype kt, const void* v, vtype cmp = vtype_compare(k, kt, vnode_peek(&n->key, kt), kt); if (cmp == 0) { - vnode_free(&n->key, kt); - vnode_free(&n->value, n->type); + mnode_free(n, &kt); n->key = kn; n->value = vnode_create(v, vt); @@ -66,8 +65,7 @@ int libcdsb_map_find(map_t* x, const void* k, vtype t, void* _, map_access_callb if (cut) { c = mnode_delete(&x->root, c); - vnode_free(&c->key, x->type); - vnode_free(&c->value, c->type); + mnode_free(c, &x->type); free(c); } @@ -76,7 +74,6 @@ int libcdsb_map_find(map_t* x, const void* k, vtype t, void* _, map_access_callb } return -1; - } @@ -91,13 +88,11 @@ int libcdsb_map_foreach(map_t* x, void* dt, map_access_callback callback, bool f if ((r = callback(vnode_peek(&c->key, x->type), x->type, vnode_peek(&c->value, c->type), c->type, dt))) break; - if (!mnode_is_empty(c->right)) stack_push(&z, c->right); if (!mnode_is_empty(c->left)) stack_push(&z, c->left); if (flush) { - vnode_free(&c->key, x->type); - vnode_free(&c->value, c->type); + mnode_free(c, &x->type); free(c); } } @@ -107,8 +102,7 @@ int libcdsb_map_foreach(map_t* x, void* dt, map_access_callback callback, bool f if (!mnode_is_empty(c->right)) stack_push(&z, c->right); if (!mnode_is_empty(c->left)) stack_push(&z, c->left); - vnode_free(&c->key, x->type); - vnode_free(&c->value, c->type); + mnode_free(c, &x->type); free(c); c = stack_pop(&z); diff --git a/src/map/include.h b/src/map/include.h index 29db5c4..59f1c5b 100644 --- a/src/map/include.h +++ b/src/map/include.h @@ -28,6 +28,7 @@ static_assert(offsetof(struct libcdsb_rbtree_node, value) == offsetof(struct lib static_assert(offsetof(struct libcdsb_set, root) == offsetof(struct libcdsb_map, root), "Implementation assert"); static_assert(offsetof(struct libcdsb_set, type) == offsetof(struct libcdsb_map, type), "Implementation assert"); +extern void libcdsb_mnode_free(mnode_t* x, vtype* t); #define mnode_empty ((mnode_t*)LIBCDSB_RBTREE_NODE_EMPTY) #define mnode_create(k, p, c) ((mnode_t*)libcdsb_rbtree_node_create(k, (rbnode_t*)p, c, sizeof(mnode_t))) @@ -37,4 +38,6 @@ static_assert(offsetof(struct libcdsb_set, type) == offsetof(struct libcdsb_map, #define mnode_is_empty(n) ((n) == mnode_empty) #define mnode_is_root(n) mnode_is_empty((n)->parent) +#define mnode_free libcdsb_mnode_free + #endif /* LIBCDSB_SRC_MAP_INCLUDE_H */ diff --git a/src/rbtree-extra.c b/src/rbtree-extra.c new file mode 100644 index 0000000..40b2821 --- /dev/null +++ b/src/rbtree-extra.c @@ -0,0 +1,206 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "__internal/rbtree.h" + +/*#####################################################################################################################*/ + +static rbnode_t* rbnode_duplicate(const rbnode_t* s, rbnode_t* p, const vtype* info) { + return rbnode_create(vnode_duplicate(&s->value, (info) ? *info : VTYPE_POINTER), p, s->colored); +} + +static int rbnode_compare(const rbnode_t* s0, const rbnode_t* s1, vtype* tp) { + vtype t = !is_null(tp) ? *tp : VTYPE_POINTER; + return vnode_compare(s0->value, t, s1->value, t); +} + +static hash_t rbnode_hash(const rbnode_t* s, vtype* tp) { + vtype t = (!is_null(tp)) ? *tp : VTYPE_POINTER; + return vnode_hash(s->value, t); +} + +static void rbnode_free(rbnode_t* x, vtype *t) { + if (!is_null(t)) vnode_free(&x->value, *t); +} + +/*#####################################################################################################################*/ + +hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) { + + rbnode_t *c0, *c1; + hash_t hash, v; + stack_t z; + + if (rbnode_is_empty(s)) return 0; + if (is_null(node_hash)) node_hash = (void*)rbnode_hash; + + z.prev = 0; + hash = 1; + c1 = (void*)s; + + if (!rbnode_is_empty(z.value = c1->left)) do { + c0 = stack_pop(&z); + ++hash; + if (!rbnode_is_empty(c0->left)) + stack_push(&z, c1 = c0->left); + if (!rbnode_is_empty(c0->right)) + stack_push(&z, c0->right); + } while (!is_null(z.value)); + + v = node_hash(c1, info); + c1 = (void*)s; + + if (!rbnode_is_empty(z.value = c1->right)) do { + c0 = stack_pop(&z); + ++hash; + if (!rbnode_is_empty(c0->left)) + stack_push(&z, c1 = c0->left); + if (!rbnode_is_empty(c0->right)) + stack_push(&z, c0->right); + } while (!is_null(z.value)); + + v += node_hash(c1, info); + + return hash ^ v; +} + +/*#####################################################################################################################*/ + +void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info) { + rbnode_t *p0, *p1, *x; + stack_t z; + + z.prev = 0; + z.value = (void*)s; + + if (is_null(node_duplicate)) { + node_duplicate = (void*)rbnode_duplicate; + } + + if (!rbnode_is_empty(s)) { + x = node_duplicate(z.value, rbnode_empty, info); + stack_push(&z, x); + + do { + p0 = stack_pop(&z); + p1 = stack_pop(&z); + + if (!rbnode_is_empty(p1->left)) { + p0->left = node_duplicate(p1->left, p0, info); + + stack_push(&z, p1->left); + stack_push(&z, p0->left); + } + + if (!rbnode_is_empty(p1->right)) { + p0->right = node_duplicate(p1->right, p0, info); + + stack_push(&z, p1->right); + stack_push(&z, p0->right); + } + + } while (!is_null(z.value)); + + } else x = rbnode_empty; + + return x; +} + +/*#####################################################################################################################*/ + +int libcdsb_rbtree_compare(const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info) { + + rbnode_t *c0, *c1; + stack_t z; + int c = 0; + + if (s0 == s1) return 0; + if (is_null(node_compare)) node_compare = (void*)rbnode_compare; + + z.prev = 0; + z.value = 0; + + stack_push(&z, (void*)s1); + stack_push(&z, (void*)s0); + + do { + c0 = stack_pop(&z); + c1 = stack_pop(&z); + + if (rbnode_is_empty(c0) || rbnode_is_empty(c1)) { + if (c0 != c1) { + stack_flush(&z); + return rbnode_is_empty(c0) ? -1 : 1; + } + } else if ((c = node_compare(c0, c1, info))) { + if (c0->left == c1->right) { // <-- rbnode_empty + c = node_compare(c0->right, c1, info); + if (!c) c = node_compare(c0, c1->left, info); + } else if (c0->right == c1->left) { // <-- rbnode_empty + c = node_compare(c0, c1->right, info); + if (!c) c = node_compare(c0->left, c1, info); + } + + if (c) { + stack_flush(&z); + return c; + } + } else { + stack_push(&z, c1->right); + stack_push(&z, c0->right); + stack_push(&z, c1->left); + stack_push(&z, c0->left); + } + + } while (!is_null(z.value)); + + return 0; +} + + +size_t libcdsb_rbtree_size(const void* s) { + stack_t z = { .prev = 0, .value = (void*)s }; + size_t n = 0; + rbnode_t* c; + + if (!rbnode_is_empty(s)) { + while ((c = stack_pop(&z))) { + ++n; + if (!rbnode_is_empty(c->left)) + stack_push(&z, c->left); + if (!rbnode_is_empty(c->right)) + stack_push(&z, c->right); + } + } + + return n; +} + + +void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) { + rbnode_t *t, *c; + + c = x; + if (is_null(node_free)) node_free = (void*)rbnode_free; + + while (!rbnode_is_empty(x)) { + if (!rbnode_is_empty(c->left)) { + c = c->left; + } else if (!rbnode_is_empty(c->right)) { + c = c->right; + } else if (!rbnode_is_root(c)) { + node_free(c, info); + + t = c; + c = c->parent; + + if (t == c->left) c->left = rbnode_empty; + else c->right = rbnode_empty; + + free(t); + } else { + node_free(c, info); + x = rbnode_empty; + } + } +} diff --git a/src/set/base.c b/src/set/base.c index 07752bb..17d5427 100644 --- a/src/set/base.c +++ b/src/set/base.c @@ -4,6 +4,11 @@ #include "../../include/set.h" #include "../__internal/rbtree.h" +/*#####################################################################################################################*/ + +hash_t vset_hash(const set_t* s) { + return rbtree_hash(s->root, nullptr, (void*)&s->type) + VTYPE_SET; +} void vset_init(set_t* x, vtype t) { x->root = rbnode_empty; @@ -12,92 +17,48 @@ void vset_init(set_t* x, vtype t) { void vset_free(set_t* x) { - rbnode_t* t; - rbnode_t* c; - - c = x->root; - - while (!rbnode_is_empty(x->root)) { - if (!rbnode_is_empty(c->left)) { - c = c->left; - } else if (!rbnode_is_empty(c->right)) { - c = c->right; - } else if (!rbnode_is_root(c)) { - vnode_free(&c->value, x->type); - - t = c; - c = c->parent; - - if (t == c->left) c->left = rbnode_empty; - else c->right = rbnode_empty; - - free(t); - } else { - vnode_free(&c->value, x->type); - x->root = rbnode_empty; - } - } + rbtree_free(x->root, nullptr, &x->type); + x->root = rbnode_empty; x->type = 0; } +/*#####################################################################################################################*/ size_t vset_size(const set_t* x) { - stack_t z = { .prev = 0, .value = x->root }; - size_t n = 0; - rbnode_t* c; - - if (!rbnode_is_empty(x->root)) { - while ((c = stack_pop(&z))) { - ++n; - if (!rbnode_is_empty(c->left)) - stack_push(&z, c->left); - if (!rbnode_is_empty(c->right)) - stack_push(&z, c->right); - } - } - - return n; + return rbtree_size(x->root); } +/*#####################################################################################################################*/ int vset_compare(const set_t* s0, const set_t* s1) { - stack_t z = { .prev = 0, .value = 0 }; - vtype t = s0->type; - int c = 0; - - if (s0 == s1 || s0->root == s1->root) return 0; + if (s0 == s1) return 0; if (s0->type != s1->type) return s0->type - s1->type; - stack_push(&z, s1->root); - stack_push(&z, s0->root); - - for (rbnode_t *c0, *c1;!is_null(z.value);) { - c0 = stack_pop(&z); - c1 = stack_pop(&z); - - if (rbnode_is_empty(c0) || rbnode_is_empty(c1)) { - if (c0 != c1) { - stack_flush(&z); - return rbnode_is_empty(c0) ? -1 : 1; - } - } else if ((c = vnode_compare(c0->value, t, c1->value, t))) { - if (c0->left == c1->right) { - c = vnode_compare(c1->value, t, c0->right->value, t); - if (!c) c = vnode_compare(c1->left->value, t, c0->value, t); - } else if (c0->right == c1->left) { - c = vnode_compare(c0->value, t, c1->right->value, t); - if (!c) c = vnode_compare(c0->left->value, t, c1->value, t); - } - - if (c) { stack_flush(&z); return c; } - } else { - stack_push(&z, c1->right); - stack_push(&z, c0->right); - stack_push(&z, c1->left); - stack_push(&z, c0->left); - } - } - - return 0; + return rbtree_compare(s0->root, s1->root, nullptr, (void*)&s0->type); +} + +/*#####################################################################################################################*/ + +set_t vset_copy(const set_t* s) { + set_t x; + + x.type = s->type; + x.root = rbtree_duplicate(s->root, nullptr, &x.type); + + return x; +} + +set_t* vset_duplicate(const set_t* s) { + set_t *x = malloc(sizeof(*x)); + + x->type = s->type; + x->root = rbtree_duplicate(s->root, nullptr, &x->type); + + return x; +} + +void vset_copy_init(set_t* x, const set_t* s) { + x->type = s->type; + x->root = rbtree_duplicate(s->root, nullptr, &x->type); } diff --git a/src/set/copy.c b/src/set/copy.c deleted file mode 100644 index 954d7d8..0000000 --- a/src/set/copy.c +++ /dev/null @@ -1,103 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "../../include/set.h" -#include "../__internal/rbtree.h" - -set_t vset_copy(const set_t* s) { - - set_t x = { .type = s->type }; - stack_t z = { .prev = 0, .value = s->root }; - vtype t = s->type; - - if (!rbnode_is_empty(s->root)) { - x.root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x.root); - - do { - rbnode_t *p0 = stack_pop(&z); - rbnode_t *p1 = stack_pop(&z); - - if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x.root = rbnode_empty; - - return x; -} - - -set_t* vset_duplicate(const set_t* s) { - - set_t* x = malloc(sizeof(*x)); - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; - - if (!rbnode_is_empty(s->root)) { - x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x->root); - - do { - rbnode_t *p0 = stack_pop(&z); - rbnode_t *p1 = stack_pop(&z); - - if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x->root = rbnode_empty; - - return x; -} - - -void vset_copy_init(set_t* x, const set_t* s) { - - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; - - if (!rbnode_is_empty(s->root)) { - x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); - stack_push(&z, x->root); - - do { - rbnode_t *p0 = stack_pop(&z); - rbnode_t *p1 = stack_pop(&z); - - if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x->root = rbnode_empty; -} From 4e6d83c4cfe4dcdba3eb101ad5c43fe9cbd44da7 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 14 Aug 2022 20:55:40 +0300 Subject: [PATCH 39/63] Update type generics --- src/vnode.c | 7 ++++++- src/vtype-extra.c | 1 + src/vtype.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/vnode.c b/src/vnode.c index ed834fe..b95d8a0 100644 --- a/src/vnode.c +++ b/src/vnode.c @@ -226,6 +226,7 @@ void* libcdsb_vnode_peek(const vnode_t* x, vtype t) { case VTYPE_ARRAY: case VTYPE_LIST: case VTYPE_SET: + case VTYPE_DICT: pt_: return *x; } } @@ -260,7 +261,8 @@ void libcdsb_vnode_free(vnode_t* x, vtype t) { case VTYPE_MAP: map_free(*x); goto pt_; case VTYPE_ARRAY: array_free(*x); goto pt_; case VTYPE_LIST: list_free(*x); goto pt_; - case VTYPE_SET: vset_free(*x); + case VTYPE_SET: vset_free(*x); goto pt_; + case VTYPE_DICT: dict_free(*x); pt_: free(*x); break; } @@ -304,6 +306,9 @@ vnode_t libcdsb_vnode_create_target(vtype xt, const void* v, vtype t) { case VTYPE_SET: _.ptr = vset_duplicate(v); break; + + case VTYPE_DICT: _.ptr = dict_duplicate(v); + break; } return _.ptr; diff --git a/src/vtype-extra.c b/src/vtype-extra.c index 7953b38..244f90b 100644 --- a/src/vtype-extra.c +++ b/src/vtype-extra.c @@ -59,6 +59,7 @@ const char* libcdsb_vtype_name(vtype t) { case VTYPE_ARRAY: return "VTYPE_ARRAY"; case VTYPE_LIST: return "VTYPE_LIST"; case VTYPE_SET: return "VTYPE_SET"; + case VTYPE_DICT: return "VTYPE_DICT"; } } diff --git a/src/vtype.c b/src/vtype.c index e3561db..a6108c4 100644 --- a/src/vtype.c +++ b/src/vtype.c @@ -30,6 +30,17 @@ static ldbl_t normalize_value(const void* v, vtype t) { } else return abs(*(ldbl_t*)v) <= LDBL_EPSILON ? 0 : *(ldbl_t*)v; } +static hash_t ldouble_hash(ldbl_t s) { + hash_t x, y; + ldbl_t m; + + m = modfl(s, &s); + x = llrintl(s); + y = floorl(m * 10000); + + return x ^ y; +} + /*#####################################################################################################################*/ int libcdsb_vtype_compare_values(const void* s0, vtype t0, const void* s1, vtype t1) { @@ -66,9 +77,9 @@ int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) { case VTYPE_UINT8: return compare( u8_t, s0, s1); case VTYPE_UINT16: return compare(u16_t, s0, s1); case VTYPE_UINT32: - u32_: return compare(u32_t, s0, s1); + x86_ptr: return compare(u32_t, s0, s1); - case VTYPE_POINTER: if (sizeof(void*) != 8) goto u32_; + case VTYPE_POINTER: if (!is_x64) goto x86_ptr; case VTYPE_UINT64: return compare(u64_t, s0, s1); case VTYPE_LDOUBLE: return (abs(*(ldbl_t*)s0 - *(ldbl_t*)s1) <= LDBL_EPSILON) ? 0 : (*(ldbl_t*)s0 < *(ldbl_t*)s1 ? -1 : 1); @@ -80,7 +91,42 @@ int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) { case VTYPE_LIST: return list_compare(s0, s1); case VTYPE_MAP: return map_compare(s0, s1); case VTYPE_SET: return vset_compare(s0, s1); + case VTYPE_DICT: return dict_compare(s0, s1); } #undef compare } + +/*#####################################################################################################################*/ + +hash_t libcdsb_vtype_hash(void* v, vtype t) { + + switch (t) { default: abort(); + + case VTYPE_BOOLEAN: + case VTYPE_INT8: + case VTYPE_UINT8: return (hash_t)(*(u8_t*)v); + + case VTYPE_INT16: + case VTYPE_UINT16: return (hash_t)(*(u16_t*)v); + + case VTYPE_INT32: + case VTYPE_UINT32: + x86_ptr: return (hash_t)(*(u32_t*)v); + + case VTYPE_POINTER: if (!is_x64) goto x86_ptr; + case VTYPE_INT64: + case VTYPE_UINT64: return (hash_t)(*(u64_t*)v); + + case VTYPE_STRING: return string_hash(v); + case VTYPE_ARRAY: return array_hash(v); + case VTYPE_LIST: return list_hash(v); + case VTYPE_MAP: return map_hash(v); + case VTYPE_SET: return vset_hash(v); + case VTYPE_DICT: return dict_hash(v); + + case VTYPE_FLOAT: return ldouble_hash(*(fl_t*)v); + case VTYPE_DOUBLE: return ldouble_hash(*(dbl_t*)v); + case VTYPE_LDOUBLE: return ldouble_hash(*(ldbl_t*)v); + } +} From 5c39f4970c32157c88553b6ac8844bad52380a1f Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 14 Aug 2022 21:05:33 +0300 Subject: [PATCH 40/63] Add containers hashing implementation --- src/array/base.c | 38 +++++++++++++++++++++++++++++--------- src/list/base.c | 16 ++++++++++++++++ src/string/base.c | 16 ++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/array/base.c b/src/array/base.c index 1133689..49ee49f 100644 --- a/src/array/base.c +++ b/src/array/base.c @@ -4,17 +4,20 @@ #include "include.h" #include "../__internal/assert.h" -size_t array_size (const arr_t* x) { - return x->size; -} +/*#####################################################################################################################*/ -size_t array_nmemb(const arr_t* x) { - return x->size*vtype_size(x->type); -} +hash_t array_hash(const arr_t* s) { + hash_t hash = 0; -void* array_at(const arr_t* x, ssize_t i) { - if (i < 0 && (i += x->size) < 0) i = 0; - return x->mem + i*vtype_size(x->type); + if (s->size > 0) + hash = vtype_hash(s->mem, s->type); + + if (s->size > 1) + hash += vtype_hash(array_internal_at(s, s->size - 1), s->type); + + hash ^= s->size; + + return hash + VTYPE_ARRAY; } void array_init(arr_t* x, vtype t) { @@ -52,6 +55,23 @@ void array_free(arr_t* x) { memset(x, 0, sizeof(*x)); } +/*#####################################################################################################################*/ + +size_t array_size (const arr_t* x) { + return x->size; +} + +size_t array_nmemb(const arr_t* x) { + return x->size*vtype_size(x->type); +} + +void* array_at(const arr_t* x, ssize_t i) { + if (i < 0 && (i += x->size) < 0) i = 0; + return x->mem + i*vtype_size(x->type); +} + +/*#####################################################################################################################*/ + int array_compare(const arr_t* s0, const arr_t* s1) { void *e; diff --git a/src/list/base.c b/src/list/base.c index 16260f1..57071fb 100644 --- a/src/list/base.c +++ b/src/list/base.c @@ -5,6 +5,22 @@ /*#####################################################################################################################*/ +hash_t list_hash(const list_t* s) { + + hash_t hash = 0; + + if (!is_null(s->first)) { + hash = vnode_hash(&s->first->node, s->first->type); + + if (s->first != s->last) { + hash += vnode_hash(&s->first->node, s->first->type); + hash ^= list_size(s); + } else hash ^= 1; + } + + return hash + VTYPE_LIST; +} + void list_init(list_t* x) { memset(x, 0, sizeof(*x)); } diff --git a/src/string/base.c b/src/string/base.c index a131640..805140d 100644 --- a/src/string/base.c +++ b/src/string/base.c @@ -3,6 +3,22 @@ #include "include.h" +hash_t string_hash(const str_t* s) { + hash_t hash = 0; + size_t nmemb = string_nmemb(s); + + if (nmemb > 0) + hash = s->buffer[0]; + + if (nmemb > 1) + hash += s->buffer[nmemb-1]; + + hash ^= nmemb; + + return hash + VTYPE_STRING; +} + + size_t string_nmemb(const str_t* s) { return (!is_null(s->buffer)) ? strlen(s->buffer) : 0; } From 2dcc673bb2d8f6ff5366e24deb4e5f931921f2d6 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Sun, 14 Aug 2022 21:06:38 +0300 Subject: [PATCH 41/63] Add dict implementation --- src/dict/base.c | 210 +++++++++++++++++++++++++++++++++++++++++++++ src/dict/extra.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ src/dict/include.h | 45 ++++++++++ 3 files changed, 464 insertions(+) create mode 100644 src/dict/base.c create mode 100644 src/dict/extra.c create mode 100644 src/dict/include.h diff --git a/src/dict/base.c b/src/dict/base.c new file mode 100644 index 0000000..29e4854 --- /dev/null +++ b/src/dict/base.c @@ -0,0 +1,210 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +#define dtree_duplicate(s) rbtree_duplicate((rbnode_t*)s, (void*)dnode_duplicate, nullptr) +#define dtree_compare(s0, s1) rbtree_compare((void*)s0, (void*)s1, (void*)dnode_compare, nullptr) + +static dnode_t* dnode_duplicate(const dnode_t* s, dnode_t* p, void* not_used) { + dnode_t* x; + + x = dnode_create(vnode_duplicate(&s->key, s->key_type), p, s->colored); + x->key_type = s->key_type; + x->val_type = s->val_type; + x->value = vnode_duplicate(&s->value, s->val_type); + + return x; +} + +static int dnode_compare(const dnode_t *s0, const dnode_t *s1, void* not_used) { + int c = vnode_compare(&s0->key, s1->key_type, &s1->key, s1->key_type); + + return (!c) ? vnode_compare(&s0->value, s1->val_type, &s1->value, s1->val_type) : c; +} + +static hash_t dnode_hash(const dnode_t* s, void* not_used) { + return vnode_hash(s->key, s->key_type) + vnode_hash(s->value, s->val_type) + s->key_type; +} + +/*#####################################################################################################################*/ + +static int dict_compare_equal_capacity(const dict_t* s0, const dict_t* s1) { + int c; + + for (size_t i = 0; i < s0->capacity; ++i) { + if ((c = dtree_compare(s0->nodes[i], s1->nodes[i]))) { + return c; + } + } + + return 0; +} + + +static int dict_compare_unequal_capacity(const dict_t* s0, const dict_t* s1) { + const dict_t *x, *y; + dnode_t *c0, *c1; + int cmp; + + stack_t z; + + if (s0->capacity <= s1->capacity) { + x = s0; + y = s1; + } else { + x = s1; + y = s0; + } + + z.prev = 0; + z.value = 0; + + for (size_t i = 0; i < x->capacity; ++i) { + if (!dnode_is_empty(x->nodes[i])) + stack_push(&z, x->nodes[i]); + } + + while ((c0 = stack_pop(&z))) { + + c1 = y->nodes[vnode_hash(c0->key, c0->key_type) / y->capacity]; + cmp = 1; + + while (!dnode_is_empty(c1)) { + + cmp = vnode_compare(c0->key, c0->key_type, c1->key, c1->key_type); + + if (cmp == 0) break; + + c1 = (cmp < 0) ? c1->left : c1->right; + } + + if (cmp) return x == s0 ? cmp : ~cmp + 1; + + if (!dnode_is_empty(c0->right)) stack_push(&z, c0->right); + if (!dnode_is_empty(c0->left)) stack_push(&z, c0->left); + } + + return 0; +} + +/*#####################################################################################################################*/ + +hash_t dict_hash(const dict_t* s) { + dnode_t *l, *r; + hash_t hash; + + if (!s->size) return 0; + + l = dnode_empty; + r = dnode_empty; + + for (size_t i = 0; i < s->capacity; ++i) { + if (!dnode_is_empty(s->nodes[i])) { + if (dnode_is_empty(l) || vnode_compare(s->nodes[i]->key, s->nodes[i]->key_type, l->key, l->key_type) < 0) { + l = s->nodes[i]; + } + + if (dnode_is_empty(r) || vnode_compare(s->nodes[i]->key, s->nodes[i]->key_type, r->key, r->key_type) > 0) { + r = s->nodes[i]; + } + } + } + + while (!dnode_is_empty(l->left)) + l = l->left; + + while (!dnode_is_empty(r->right)) + r = r->right; + + hash = vnode_hash(l->key, l->key_type) + vnode_hash(l->value, l->val_type); + + if (l != r) hash += vnode_hash(r->key, r->key_type) + vnode_hash(r->value, r->val_type); + + return (hash ^ s->size) + VTYPE_DICT; +} + +void dict_init(dict_t* x) { + memset(x, 0, sizeof(*x)); +} + + + +void dict_free(dict_t* x) { + for (size_t i = 0; i < x->capacity; ++i) + rbtree_free(x->nodes[i], (void*)dnode_free, nullptr); + + free(x->nodes); + memset(x, 0, sizeof(*x)); +} + +void libcdcb_dnode_free(dnode_t* x, void* not_used) { + vnode_free(&x->key, x->key_type); + vnode_free(&x->value, x->val_type); +} + +/*#####################################################################################################################*/ + +size_t dict_size(const dict_t* x) { + return x->size; +} + +size_t dict_capacity(const dict_t* x) { + return x->capacity; +} + +/*#####################################################################################################################*/ + +int dict_compare(const dict_t* s0, const dict_t* s1) { + + if (s0 == s1) + return 0; + + if (s0->size != s1->size) + return s0->size < s1->size ? -1 : 1; + + if (s0->capacity == s1->capacity) + return dict_compare_equal_capacity(s0, s1); + + return dict_compare_unequal_capacity(s0, s1); +} + +/*#####################################################################################################################*/ + +dict_t dict_copy(const dict_t* s) { + dict_t x; + + x.capacity = s->capacity; + x.size = s->size; + x.nodes = malloc(x.size * sizeof(*x.nodes)); + + for (size_t i = 0; i < x.capacity; ++i) { + x.nodes[i] = dtree_duplicate(s->nodes[i]); + } + + return x; +} + +dict_t* dict_duplicate(const dict_t* s) { + dict_t *x = malloc(sizeof(*x)); + + x->capacity = s->capacity; + x->size = s->size; + x->nodes = malloc(x->size * sizeof(*x->nodes)); + + for (size_t i = 0; i < x->capacity; ++i) { + x->nodes[i] = dtree_duplicate(s->nodes[i]); + } + + return x; +} + +void dict_copy_init(dict_t* x, const dict_t* s) { + x->capacity = s->capacity; + x->size = s->size; + x->nodes = malloc(x->size * sizeof(*x->nodes)); + + for (size_t i = 0; i < x->capacity; ++i) { + x->nodes[i] = dtree_duplicate(s->nodes[i]); + } +} diff --git a/src/dict/extra.c b/src/dict/extra.c new file mode 100644 index 0000000..66e2dd2 --- /dev/null +++ b/src/dict/extra.c @@ -0,0 +1,209 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +/*#####################################################################################################################*/ + +static void dict_rehash(dict_t* s, size_t capacity) { + stack_t z; + int cmp; + dnode_t *c, *p, *n, **r; + + dnode_t **nodes = malloc(capacity * sizeof(*nodes)); + + while (s->capacity--) { + if (!dnode_is_empty(s->nodes[s->capacity])) + stack_push(&z, s->nodes[s->capacity]); + } + + while ((c = stack_pop(&z))) { + + if (!dnode_is_empty(c->right)) { + stack_push(&z, c->right); + c->right = dnode_empty; + } + + if (!dnode_is_empty(c->left)) { + stack_push(&z, c->left); + c->left = dnode_empty; + } + + n = *(r = &nodes[vnode_hash(c->key, c->key_type) / capacity]); + + if (!dnode_is_empty(*r)) { + do { + p = n; + cmp = vnode_compare(&c->key, c->key_type, &n->key, n->key_type); + n = (cmp <= 0) ? n->left : n->right; + } while (!dnode_is_empty(n)); + + if (cmp < 0) p->left = c; + else p->right = c; + + c->parent = p; + c->colored = 1; + + if (!dnode_is_root(p)) + dnode_fixup(r, n); + + } else { + *r = c; + c->colored = 0; + c->parent = dnode_empty; + } + } + + free(s->nodes); + + s->capacity = capacity; + s->nodes = nodes; +} + +/*#####################################################################################################################*/ + +bool libcdsb_dict_shrink_to_fit(dict_t* s) { + + size_t capacity; + + capacity = (s->size / CAPACITY_BLOCK) + 1; + capacity *= CAPACITY_BLOCK; + + while (((double)s->size / capacity) > 0.65) + capacity += CAPACITY_BLOCK; + + if (capacity >= s->capacity) + return false; + + dict_rehash(s, capacity); + + return true; +} + + +bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { + + dnode_t **r, *n, *p; + vnode_t kn, vn; + int cmp; + + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) { + dict_rehash(x, x->capacity + CAPACITY_BLOCK); + } + + n = *(r = &x->nodes[vnode_hash(k, kt) / x->capacity]); + kn = vnode_create(k, kt); + vn = vnode_create(v, vt); + + if (!dnode_is_empty(n)) { + do { + p = n; + cmp = vtype_compare(k, kt, vnode_peek(&n->key, n->key_type), n->key_type); + + if (cmp == 0) { + dnode_free(n, nullptr); + + n->key = kn; + n->value = vn; + n->key_type = kt; + n->val_type = vt; + + return true; + } + + n = (cmp < 0) ? n->left : n->right; + } while (!dnode_is_empty(n)); + + n = dnode_create(kn, p, 1); + + if (cmp < 0) p->left = n; + else p->right = n; + + if (!dnode_is_root(p)) + dnode_fixup(r, n); + + } else n = *r = dnode_create(kn, dnode_empty, 0); + + n->value = vn; + n->key_type = kt; + n->val_type = vt; + + return false; +} + + +int libcdsb_dict_get(dict_t* x, const void* k, vtype t, void* _, dict_access_callback callback, bool cut) { + + dnode_t *c, **r; + void* key; + int cmp; + + if (x->capacity) { + c = *(r = &x->nodes[vnode_hash(k, t) / x->capacity]); + + while (!dnode_is_empty(c)) { + key = vnode_peek(&c->key, c->key_type); + cmp = vtype_compare(k, t, key, c->key_type); + + if (cmp == 0) { + cmp = (callback) ? callback(key, t, vnode_peek(&c->value, c->val_type), c->val_type, _) : 0; + + if (cut) { + c = dnode_delete(r, c); + dnode_free(c, nullptr); + free(c); + } + + return cmp; + } else c = (cmp < 0) ? c->left : c->right; + } + } + + return -1; +} + + +int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, bool flush) { + stack_t z; + int r; + dnode_t* c; + + r = 0; + z.prev = 0; + z.value = 0; + + for (size_t i = 0; i < x->capacity; ++i) { + if (!dnode_is_empty(x->nodes[i])) + stack_push(&z, x->nodes[i]); + } + + while ((c = stack_pop(&z))) { + if ((r = callback(vnode_peek(&c->key, c->key_type), c->key_type, vnode_peek(&c->value, c->val_type), c->val_type, dt))) + break; + + if (!dnode_is_empty(c->right)) stack_push(&z, c->right); + if (!dnode_is_empty(c->left)) stack_push(&z, c->left); + + if (flush) { + dnode_free(c, nullptr); + free(c); + } + } + + if (flush) { + while (c) { + if (!dnode_is_empty(c->right)) stack_push(&z, c->right); + if (!dnode_is_empty(c->left)) stack_push(&z, c->left); + + dnode_free(c, nullptr); + free(c); + + c = stack_pop(&z); + } + + free(x->nodes); + memset(x, 0, sizeof(*x)); + } else stack_flush(&z); + + return r; +} diff --git a/src/dict/include.h b/src/dict/include.h new file mode 100644 index 0000000..9a10f6f --- /dev/null +++ b/src/dict/include.h @@ -0,0 +1,45 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../include/extra/dict.h" +#include "../__internal/assert.h" +#include "../__internal/rbtree.h" + +#ifndef LIBCDSB_SRC_DICT_INCLUDE_H +#define LIBCDSB_SRC_DICT_INCLUDE_H + +#define CAPACITY_BLOCK 100 +#define REBUILD_POINT_MAX 0.65 +#define REBUILD_POINT_MIN 1 + +typedef struct libcdsb_dict_node { + struct libcdsb_dict_node* left; + struct libcdsb_dict_node* right; + struct libcdsb_dict_node* parent; + + vnode_t key; + short colored; + u8_t key_type; + u8_t val_type; + vnode_t value; +} dnode_t; + +static_assert(offsetof(struct libcdsb_rbtree_node, left) == offsetof(struct libcdsb_dict_node, left), "Implementation assert"); +static_assert(offsetof(struct libcdsb_rbtree_node, right) == offsetof(struct libcdsb_dict_node, right), "Implementation assert"); +static_assert(offsetof(struct libcdsb_rbtree_node, parent) == offsetof(struct libcdsb_dict_node, parent), "Implementation assert"); +static_assert(offsetof(struct libcdsb_rbtree_node, colored) == offsetof(struct libcdsb_dict_node, colored), "Implementation assert"); +static_assert(offsetof(struct libcdsb_rbtree_node, value) == offsetof(struct libcdsb_dict_node, key), "Implementation assert"); + +#define dnode_empty ((dnode_t*)LIBCDSB_RBTREE_NODE_EMPTY) +#define dnode_create(k, p, c) ((dnode_t*)libcdsb_rbtree_node_create(k, (rbnode_t*)p, c, sizeof(dnode_t))) +#define dnode_fixup(r, n) libcdsb_rbtree_node_fixup((rbnode_t**)(r), (rbnode_t*)(n)) +#define dnode_delete(r, n) (dnode_t*)libcdsb_rbtree_node_delete((rbnode_t**)(r), (rbnode_t*)(n)) + +#define dnode_is_empty(n) ((n) == dnode_empty) +#define dnode_is_root(n) dnode_is_empty((n)->parent) + +extern void libcdcb_dnode_free(dnode_t* x, void* not_used); + +#define dnode_free libcdcb_dnode_free + +#endif /* LIBCDSB_SRC_MAP_INCLUDE_H */ From 1f7ef918505cbb1c07bf5ed120bab6438d882903 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 15 Aug 2022 17:24:31 +0300 Subject: [PATCH 42/63] Add dict tests --- tests/Makefile | 10 ++++++- tests/src/array/src/plug.c | 18 ++++++++++--- tests/src/dict/main.c | 15 +++++++++++ tests/src/dict/plug.h | 17 ++++++++++++ tests/src/dict/src/io.c | 47 ++++++++++++++++++++++++++++++++ tests/src/dict/src/plug.c | 29 ++++++++++++++++++++ tests/src/dict/src/random.c | 53 +++++++++++++++++++++++++++++++++++++ tests/src/list/src/plug.c | 9 +++++++ tests/src/map/src/plug.c | 9 +++++++ tests/src/set/src/plug.c | 9 +++++++ tests/src/string/src/plug.c | 9 +++++++ 11 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 tests/src/dict/main.c create mode 100644 tests/src/dict/plug.h create mode 100644 tests/src/dict/src/io.c create mode 100644 tests/src/dict/src/plug.c create mode 100644 tests/src/dict/src/random.c diff --git a/tests/Makefile b/tests/Makefile index f9a6205..b1f7a65 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -27,6 +27,7 @@ OBJECTS_ARRAY := $(OBJECTS_BASE) $(call c_objects,../src/array/,array-) OBJECTS_LIST := $(OBJECTS_BASE) $(call c_objects,../src/list/,list-) OBJECTS_MAP := $(OBJECTS_BASE) $(call c_objects,../src/map/,map-) OBJECTS_SET := $(OBJECTS_BASE) $(call c_objects,../src/set/,set-) +OBJECTS_DICT := $(OBJECTS_BASE) $(call c_objects,../src/dict/,dict-) OBJECTS_BASE := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_BASE)) OBJECTS_STRING := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_STRING)) @@ -34,12 +35,14 @@ OBJECTS_ARRAY := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix . OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_LIST)) OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP)) OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET)) +OBJECTS_DICT := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_DICT)) OBJECTS_STRING := $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-)) OBJECTS_ARRAY := $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-)) OBJECTS_LIST := $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-)) OBJECTS_MAP := $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-)) OBJECTS_SET := $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-)) +OBJECTS_DICT := $(OBJECTS_DICT) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/dict/src/,dict-)) ######################################################################################################################## @@ -49,6 +52,7 @@ tests: $(addprefix $(BUILD_PATH)/string-,$(notdir $(basename $(wildcard ./src/st tests: $(addprefix $(BUILD_PATH)/list-,$(notdir $(basename $(wildcard ./src/list/*.c)))) tests: $(addprefix $(BUILD_PATH)/map-,$(notdir $(basename $(wildcard ./src/map/*.c)))) tests: $(addprefix $(BUILD_PATH)/set-,$(notdir $(basename $(wildcard ./src/set/*.c)))) +tests: $(addprefix $(BUILD_PATH)/dict-,$(notdir $(basename $(wildcard ./src/dict/*.c)))) ######################################################################################################################## @@ -66,6 +70,8 @@ $(BUILD_PATH)/obj/map-%.o: ./src/map/src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) $(BUILD_PATH)/obj/set-%.o: ./src/set/src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/dict-%.o: ./src/dict/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) $(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall @@ -77,6 +83,8 @@ $(BUILD_PATH)/map-%: ./src/map/%.c $(OBJECTS_MAP) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/set-%: ./src/set/%.c $(OBJECTS_SET) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall +$(BUILD_PATH)/dict-%: ./src/dict/%.c $(OBJECTS_DICT) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall ######################################################################################################################## @@ -97,4 +105,4 @@ FORCE: modules: ../bin/debug/libcdsb.a ../bin/debug/libcdsb.a: FORCE - cd ../ && $(MAKE) debug + cd ../ && CFLAGS=-DDICT_CAPACITY_BLOCK\=5 $(MAKE) debug diff --git a/tests/src/array/src/plug.c b/tests/src/array/src/plug.c index 364b6fc..0ed9a6b 100644 --- a/tests/src/array/src/plug.c +++ b/tests/src/array/src/plug.c @@ -9,18 +9,28 @@ vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_list* list_duplicate (const vtype_list* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +vtype_dict* dict_duplicate (const vtype_dict* x) { return 0; } void string_free(vtype_string* x) {} void list_free (vtype_list* x) {} void map_free (vtype_map* x) {} void vset_free (vtype_set* x) {} +void dict_free (vtype_dict* x) {} int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +int dict_compare (const vtype_dict* s0, const vtype_dict* s1) { return random_int8(); } -extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } -extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } -extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } -extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } +hash_t string_hash(const vtype_string* s) { return 0; } +hash_t list_hash (const vtype_list* s) { return 0; } +hash_t map_hash (const vtype_map* s) { return 0; } +hash_t vset_hash (const vtype_set* s) { return 0; } +hash_t dict_hash (const vtype_dict* s) { return 0; } + +void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } +void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } +void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } +void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } +void dict_copy_init (vtype_dict* x, const vtype_dict* s) { memset(x, 0, sizeof(*x)); } diff --git a/tests/src/dict/main.c b/tests/src/dict/main.c new file mode 100644 index 0000000..e1b73dc --- /dev/null +++ b/tests/src/dict/main.c @@ -0,0 +1,15 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); + + dict_t x; + + dict_init(&x); + + visual_push(&x, random_uint8()%17 + 16); + visual_remove(&x); +} diff --git a/tests/src/dict/plug.h b/tests/src/dict/plug.h new file mode 100644 index 0000000..57f84dc --- /dev/null +++ b/tests/src/dict/plug.h @@ -0,0 +1,17 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/extra/dict.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +void dict_push_random(dict_t* x, bool silent, unsigned int hpos); +void dict_remove_random(dict_t* x, bool silent, unsigned int hpos); + +void dict_print(dict_t* x, const char* prefix, unsigned int hpos); +void dict_info(const dict_t* x, unsigned int hpos); + +void visual_push(dict_t* x, size_t n); +void visual_remove(dict_t* x); diff --git a/tests/src/dict/src/io.c b/tests/src/dict/src/io.c new file mode 100644 index 0000000..d0c4336 --- /dev/null +++ b/tests/src/dict/src/io.c @@ -0,0 +1,47 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int node_print_callback(const void* k, vtype kt, void* v, vtype vt, void* _) { + print_container_value(0, k, kt, 0, *(unsigned int*)_); + return 0; +} + +void dict_print(dict_t* x, const char* prefix, unsigned int hpos) { + print_container_values_prefix("Dict", prefix, 0); + dict_foreach(x, &hpos, node_print_callback); + put_separator(0); +} + +void dict_info(const dict_t* x, unsigned int hpos) { + print_container_info("Dict", "nodes", 0, dict_size(x), -1, 0); + put_separator(0); +} + +void visual_push(dict_t* x, size_t n) { + while (n--) { + fputs("\e[s", stdout); + + dict_push_random(x, 0, 0); + + dict_info(x, 0); + dict_print(x, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} + +void visual_remove(dict_t* x) { + while (x->size) { + fputs("\e[s", stdout); + dict_remove_random(x, 0, 0); + + dict_info(x, 0); + dict_print(x, 0, 0); + + psleep(100000); + fputs("\e[u\e[J", stdout); + } +} diff --git a/tests/src/dict/src/plug.c b/tests/src/dict/src/plug.c new file mode 100644 index 0000000..bb5545a --- /dev/null +++ b/tests/src/dict/src/plug.c @@ -0,0 +1,29 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../../src/__internal/include.h" +#include "../../../include/random.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + +hash_t string_hash(const vtype_string* s) { return 0; } +hash_t array_hash (const vtype_array* s) { return 0; } +hash_t list_hash (const vtype_list* s) { return 0; } +hash_t map_hash (const vtype_map* s) { return 0; } +hash_t vset_hash (const vtype_set* s) { return 0; } diff --git a/tests/src/dict/src/random.c b/tests/src/dict/src/random.c new file mode 100644 index 0000000..0218398 --- /dev/null +++ b/tests/src/dict/src/random.c @@ -0,0 +1,53 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +static int remove_callback(const void* k, vtype kt, void* v, vtype vt, void* _) { + struct { size_t n; dict_t* x; unsigned int hp; } *d = _; + + if (!d->n--) { + print_container_value(0, k, kt, 0, d->hp); + + if (libcdsb_dict_get(d->x, k, kt, 0, 0, 1) == 0) { + printf("\e[%dG\e[32;1mSUCCESS\e[m\n", d->hp+1); + } else printf("\e[%dG\e[31;1mFAILURE\e[m\n", d->hp+1); + + return -2; + } + return 0; +} + +void dict_push_random(dict_t* x, _Bool silent, unsigned int hpos) { + + value_t k = random_value(); + value_t v = random_value(); + + if (!silent) { + printf("\e[%dG\e[36mUpdate value in dict with key:\e[m\n", hpos+1); + print_container_value(0, k.value, k.type, 1, hpos); + } + + if (libcdsb_dict_update(x, k.value, k.type, v.value, v.type)) { + if (!silent) printf("\e[%dG\e[33;1mCHANGE\e[m\n", hpos+1); + } else if (!silent) printf("\e[%dG\e[32;1mINSERT\e[m\n", hpos+1); + + if (!silent) put_separator(0); +} + + +void dict_remove_random(dict_t* x, _Bool silent, unsigned int hpos) { + struct { size_t n; dict_t* x; unsigned int hp; } d = { .n = dict_size(x), .x = x, .hp = hpos }; + + if (!silent) + printf("\e[%dG\e[36mTry to remove value from dict by key:\e[m\n", hpos+1); + + if (d.n) { + d.n = random_uint32()%d.n; + dict_foreach(x, &d, remove_callback); + } else if (!silent) { + printf("\e[%dG\e[32;1m\nFAILURE\e[m\n", hpos+1); + } + + if (!silent) put_separator(hpos); +} diff --git a/tests/src/list/src/plug.c b/tests/src/list/src/plug.c index eff34f8..7a32c0e 100644 --- a/tests/src/list/src/plug.c +++ b/tests/src/list/src/plug.c @@ -8,13 +8,22 @@ vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +vtype_dict* dict_duplicate (const vtype_dict* x) { return 0; } void string_free(vtype_string* x) {} void array_free (vtype_array* x) {} void map_free (vtype_map* x) {} void vset_free (vtype_set* x) {} +void dict_free (vtype_dict* x) {} int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +int dict_compare (const vtype_dict* s0, const vtype_dict* s1) { return random_int8(); } + +hash_t string_hash(const vtype_string* s) { return 0; } +hash_t array_hash (const vtype_array* s) { return 0; } +hash_t map_hash (const vtype_map* s) { return 0; } +hash_t vset_hash (const vtype_set* s) { return 0; } +hash_t dict_hash (const vtype_dict* s) { return 0; } diff --git a/tests/src/map/src/plug.c b/tests/src/map/src/plug.c index b2a8764..2462c64 100644 --- a/tests/src/map/src/plug.c +++ b/tests/src/map/src/plug.c @@ -8,13 +8,22 @@ vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_list* list_duplicate (const vtype_list* x) { return 0; } vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +vtype_dict* dict_duplicate (const vtype_dict* x) { return 0; } void string_free(vtype_string* x) {} void array_free (vtype_array* x) {} void list_free (vtype_list* x) {} void vset_free (vtype_set* x) {} +void dict_free (vtype_dict* x) {} int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +int dict_compare (const vtype_dict* s0, const vtype_dict* s1) { return random_int8(); } + +hash_t string_hash(const vtype_string* s) { return 0; } +hash_t array_hash (const vtype_array* s) { return 0; } +hash_t list_hash (const vtype_list* s) { return 0; } +hash_t vset_hash (const vtype_set* s) { return 0; } +hash_t dict_hash (const vtype_dict* s) { return 0; } diff --git a/tests/src/set/src/plug.c b/tests/src/set/src/plug.c index 00cf60d..6dc338a 100644 --- a/tests/src/set/src/plug.c +++ b/tests/src/set/src/plug.c @@ -8,13 +8,22 @@ vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_list* list_duplicate (const vtype_list* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_dict* dict_duplicate (const vtype_dict* x) { return 0; } void string_free(vtype_string* x) {} void array_free (vtype_array* x) {} void list_free (vtype_list* x) {} void map_free (vtype_map* x) {} +void dict_free (vtype_dict* x) {} int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int dict_compare (const vtype_dict* s0, const vtype_dict* s1) { return random_int8(); } + +hash_t string_hash(const vtype_string* s) { return 0; } +hash_t array_hash (const vtype_array* s) { return 0; } +hash_t list_hash (const vtype_list* s) { return 0; } +hash_t map_hash (const vtype_map* s) { return 0; } +hash_t dict_hash (const vtype_dict* s) { return 0; } diff --git a/tests/src/string/src/plug.c b/tests/src/string/src/plug.c index 6da62c4..02f7f0f 100644 --- a/tests/src/string/src/plug.c +++ b/tests/src/string/src/plug.c @@ -8,13 +8,22 @@ vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_list* list_duplicate (const vtype_list* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } vtype_set* vset_duplicate (const vtype_set* x) { return 0; } +vtype_dict* dict_duplicate (const vtype_dict* x) { return 0; } void array_free (vtype_array* x) {} void list_free (vtype_list* x) {} void map_free (vtype_map* x) {} void vset_free (vtype_set* x) {} +void dict_free (vtype_dict* x) {} int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +int dict_compare (const vtype_dict* s0, const vtype_dict* s1) { return random_int8(); } + +hash_t array_hash (const vtype_array* s) { return 0; } +hash_t list_hash (const vtype_list* s) { return 0; } +hash_t map_hash (const vtype_map* s) { return 0; } +hash_t vset_hash (const vtype_set* s) { return 0; } +hash_t dict_hash (const vtype_dict* s) { return 0; } From 21690b2c4e48d5f6a0560842fa9e89dbb2c6fd36 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 15 Aug 2022 17:27:51 +0300 Subject: [PATCH 43/63] Fix vnode's float & double containing cases --- src/vnode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vnode.c b/src/vnode.c index b95d8a0..5a30d6e 100644 --- a/src/vnode.c +++ b/src/vnode.c @@ -157,11 +157,11 @@ vnode_t libcdsb_vnode_create(const void* v, vtype t) { else _.ptr = memndup(v, sizeof(u64_t)); break; - case VTYPE_FLOAT: if (is_permissible(fl_t)) _.ld = *(fl_t*)v; + case VTYPE_FLOAT: if (is_permissible(fl_t)) _.f = *(fl_t*)v; else _.ptr = memndup(v, sizeof(fl_t)); break; - case VTYPE_DOUBLE: if (is_permissible(dbl_t)) _.ld = *(dbl_t*)v; + case VTYPE_DOUBLE: if (is_permissible(dbl_t)) _.d = *(dbl_t*)v; else _.ptr = memndup(v, sizeof(dbl_t)); break; From 4bd9a4556f3e9cd027dd7c471d3bbaf0c44910c6 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 15 Aug 2022 17:28:05 +0300 Subject: [PATCH 44/63] Update Makefile --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1f0d306..c797d09 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,8 @@ OBJECTS = $(call c_objects,./src/,)\ $(call c_objects,./src/array/,array-)\ $(call c_objects,./src/list/,list-)\ $(call c_objects,./src/map/,map-)\ - $(call c_objects,./src/set/,set-) + $(call c_objects,./src/set/,set-)\ + $(call c_objects,./src/dict/,dict-) ######################################################################################################################## @@ -53,6 +54,8 @@ $(DEBUG_PATH)/obj/map-%.o: ./src/map/%.c | $(DEBUG_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) $(DEBUG_PATH)/obj/set-%.o: ./src/set/%.c | $(DEBUG_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) +$(DEBUG_PATH)/obj/dict-%.o: ./src/dict/%.c | $(DEBUG_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) $(DEBUG_PATH)/obj/%.o: ./src/%.c | $(DEBUG_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) @@ -68,6 +71,8 @@ $(RELEASE_PATH)/obj/map-%.o: ./src/map/%.c | $(RELEASE_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) $(RELEASE_PATH)/obj/set-%.o: ./src/set/%.c | $(RELEASE_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) +$(RELEASE_PATH)/obj/dict-%.o: ./src/dict/%.c | $(RELEASE_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) $(RELEASE_PATH)/obj/%.o: ./src/%.c | $(RELEASE_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) From d42dcc4a07075b35410e123ef1980f0f2d4af081 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 15 Aug 2022 17:29:33 +0300 Subject: [PATCH 45/63] Change the float hashing --- src/__internal/include.h | 2 +- src/vtype.c | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/__internal/include.h b/src/__internal/include.h index 9bed823..562bde3 100644 --- a/src/__internal/include.h +++ b/src/__internal/include.h @@ -65,7 +65,7 @@ typedef vtype_hash hash_t; 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); -extern hash_t libcdsb_vtype_hash(void* value, vtype type); +extern hash_t libcdsb_vtype_hash(const void* value, vtype type); #define vtype_stringify libcdsb_vtype_stringify #define vtype_name libcdsb_vtype_name diff --git a/src/vtype.c b/src/vtype.c index a6108c4..45663d8 100644 --- a/src/vtype.c +++ b/src/vtype.c @@ -31,14 +31,32 @@ static ldbl_t normalize_value(const void* v, vtype t) { } static hash_t ldouble_hash(ldbl_t s) { - hash_t x, y; - ldbl_t m; + hash_t hash; - m = modfl(s, &s); - x = llrintl(s); - y = floorl(m * 10000); + if (sizeof(hash_t) == sizeof(u64_t)) { + if (is_little_endian) { + hash = *((u64_t*)&s); + hash ^= *((u16_t*)(((u64_t*)&s) + 1)); + } else { + memcpy(&hash, ((char*)&s) + sizeof(u16_t), sizeof(u64_t)); + hash ^= *((u16_t*)&s); + } + } else { + if (is_little_endian) { + hash = *((u32_t*)&s) ^ *((u32_t*)&s + 1); + hash ^= *((u16_t*)(((u32_t*)&s) + 2)); + } else { + u32_t x; - return x ^ y; + memcpy(&hash, ((char*)&s) + sizeof(u16_t), sizeof(u32_t)); + memcpy(&x, ((char*)&s) + sizeof(u16_t) + sizeof(u32_t), sizeof(u32_t)); + + hash ^= x; + hash ^= *((u16_t*)&s); + } + } + + return hash; } /*#####################################################################################################################*/ @@ -99,7 +117,7 @@ int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) { /*#####################################################################################################################*/ -hash_t libcdsb_vtype_hash(void* v, vtype t) { +hash_t libcdsb_vtype_hash(const void* v, vtype t) { switch (t) { default: abort(); @@ -116,7 +134,11 @@ hash_t libcdsb_vtype_hash(void* v, vtype t) { case VTYPE_POINTER: if (!is_x64) goto x86_ptr; case VTYPE_INT64: - case VTYPE_UINT64: return (hash_t)(*(u64_t*)v); + case VTYPE_UINT64: if (sizeof(hash_t) == sizeof(u64_t)) { + return (hash_t)(*(u64_t*)v); + } else { + return (hash_t)(*(u32_t*)v) ^ (*((u32_t*)v + 1)); + } case VTYPE_STRING: return string_hash(v); case VTYPE_ARRAY: return array_hash(v); From a1293af307dc9b1d0099c0408df4b8b1d2d696d7 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Mon, 15 Aug 2022 17:31:01 +0300 Subject: [PATCH 46/63] Fix dict extra --- src/dict/base.c | 4 --- src/dict/extra.c | 81 +++++++++++++++++++++++++++++----------------- src/dict/include.h | 5 ++- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/dict/base.c b/src/dict/base.c index 29e4854..35ec012 100644 --- a/src/dict/base.c +++ b/src/dict/base.c @@ -23,10 +23,6 @@ static int dnode_compare(const dnode_t *s0, const dnode_t *s1, void* not_used) { return (!c) ? vnode_compare(&s0->value, s1->val_type, &s1->value, s1->val_type) : c; } -static hash_t dnode_hash(const dnode_t* s, void* not_used) { - return vnode_hash(s->key, s->key_type) + vnode_hash(s->value, s->val_type) + s->key_type; -} - /*#####################################################################################################################*/ static int dict_compare_equal_capacity(const dict_t* s0, const dict_t* s1) { diff --git a/src/dict/extra.c b/src/dict/extra.c index 66e2dd2..8688703 100644 --- a/src/dict/extra.c +++ b/src/dict/extra.c @@ -6,15 +6,20 @@ /*#####################################################################################################################*/ static void dict_rehash(dict_t* s, size_t capacity) { - stack_t z; - int cmp; - dnode_t *c, *p, *n, **r; + stack_t z; + int cmp; + size_t index; + dnode_t *c, *p, *n; - dnode_t **nodes = malloc(capacity * sizeof(*nodes)); + dnode_t **nodes = calloc(capacity, sizeof(*nodes)); - while (s->capacity--) { - if (!dnode_is_empty(s->nodes[s->capacity])) - stack_push(&z, s->nodes[s->capacity]); + z.prev = 0; + z.value = 0; + index = s->capacity; + + while (index--) { + if (!dnode_is_empty(s->nodes[index])) + stack_push(&z, s->nodes[index]); } while ((c = stack_pop(&z))) { @@ -29,9 +34,10 @@ static void dict_rehash(dict_t* s, size_t capacity) { c->left = dnode_empty; } - n = *(r = &nodes[vnode_hash(c->key, c->key_type) / capacity]); + index = vnode_hash(&c->key, c->key_type) % capacity; + n = nodes[index]; - if (!dnode_is_empty(*r)) { + if (!is_null(nodes[index])) { do { p = n; cmp = vnode_compare(&c->key, c->key_type, &n->key, n->key_type); @@ -45,19 +51,27 @@ static void dict_rehash(dict_t* s, size_t capacity) { c->colored = 1; if (!dnode_is_root(p)) - dnode_fixup(r, n); + dnode_fixup(nodes + index, n); } else { - *r = c; - c->colored = 0; - c->parent = dnode_empty; + nodes[index] = c; + c->colored = 0; + c->parent = dnode_empty; } } free(s->nodes); - s->capacity = capacity; s->nodes = nodes; + + if (capacity > s->capacity) { + s->capacity = capacity; + while (capacity--) { + if (is_null(*nodes)) + *nodes = dnode_empty; + ++nodes; + } + } else s->capacity = capacity; } /*#####################################################################################################################*/ @@ -83,17 +97,18 @@ bool libcdsb_dict_shrink_to_fit(dict_t* s) { bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { - dnode_t **r, *n, *p; + dnode_t *n, *p; vnode_t kn, vn; - int cmp; + int cmp; + size_t index; - if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) { + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) dict_rehash(x, x->capacity + CAPACITY_BLOCK); - } - n = *(r = &x->nodes[vnode_hash(k, kt) / x->capacity]); - kn = vnode_create(k, kt); - vn = vnode_create(v, vt); + index = vtype_hash(k, kt) % x->capacity; + n = x->nodes[index]; + kn = vnode_create(k, kt); + vn = vnode_create(v, vt); if (!dnode_is_empty(n)) { do { @@ -120,26 +135,30 @@ bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtyp else p->right = n; if (!dnode_is_root(p)) - dnode_fixup(r, n); + dnode_fixup(x->nodes + index, n); - } else n = *r = dnode_create(kn, dnode_empty, 0); + } else x->nodes[index] = n = dnode_create(kn, dnode_empty, 0); n->value = vn; n->key_type = kt; n->val_type = vt; + ++x->size; + return false; } int libcdsb_dict_get(dict_t* x, const void* k, vtype t, void* _, dict_access_callback callback, bool cut) { - dnode_t *c, **r; - void* key; - int cmp; + dnode_t *c; + void* key; + int cmp; + size_t index; if (x->capacity) { - c = *(r = &x->nodes[vnode_hash(k, t) / x->capacity]); + index = vtype_hash(k, t) % x->capacity; + c = x->nodes[index]; while (!dnode_is_empty(c)) { key = vnode_peek(&c->key, c->key_type); @@ -149,9 +168,10 @@ int libcdsb_dict_get(dict_t* x, const void* k, vtype t, void* _, dict_access_cal cmp = (callback) ? callback(key, t, vnode_peek(&c->value, c->val_type), c->val_type, _) : 0; if (cut) { - c = dnode_delete(r, c); + c = dnode_delete(x->nodes + index, c); dnode_free(c, nullptr); free(c); + --x->size; } return cmp; @@ -178,7 +198,10 @@ int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, boo } while ((c = stack_pop(&z))) { - if ((r = callback(vnode_peek(&c->key, c->key_type), c->key_type, vnode_peek(&c->value, c->val_type), c->val_type, dt))) + void* k = vnode_peek(&c->key, c->key_type); + void* v = vnode_peek(&c->value, c->val_type); + + if ((r = callback(k, c->key_type, v, c->val_type, dt))) break; if (!dnode_is_empty(c->right)) stack_push(&z, c->right); diff --git a/src/dict/include.h b/src/dict/include.h index 9a10f6f..9926a72 100644 --- a/src/dict/include.h +++ b/src/dict/include.h @@ -8,9 +8,12 @@ #ifndef LIBCDSB_SRC_DICT_INCLUDE_H #define LIBCDSB_SRC_DICT_INCLUDE_H +#ifndef DICT_CAPACITY_BLOCK #define CAPACITY_BLOCK 100 +#else +#define CAPACITY_BLOCK DICT_CAPACITY_BLOCK +#endif #define REBUILD_POINT_MAX 0.65 -#define REBUILD_POINT_MIN 1 typedef struct libcdsb_dict_node { struct libcdsb_dict_node* left; From bc489e085e5a24641d35daadc23df6e20fb0981a Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 01:36:37 +0300 Subject: [PATCH 47/63] Refactor the attributes --- include/__attributes.h | 19 +- include/array.h | 131 +++--- include/dict.h | 842 +++++++++++++++++----------------- include/extra/array.h | 12 +- include/extra/cstring.h | 10 +- include/extra/dict.h | 10 +- include/extra/list.h | 11 +- include/extra/map.h | 7 +- include/extra/memory.h | 16 +- include/extra/set.h | 6 +- include/extra/string.h | 46 +- include/extra/vtype.h | 4 +- include/list.h | 132 +++--- include/map.h | 842 +++++++++++++++++----------------- include/set.h | 82 ++-- include/string.h | 44 +- include/vtype.h | 82 ++-- src/__internal/__attributes.h | 11 +- src/__internal/include.h | 7 +- src/__internal/rbtree.h | 18 +- src/__internal/vnode.h | 8 +- 21 files changed, 1157 insertions(+), 1183 deletions(-) diff --git a/include/__attributes.h b/include/__attributes.h index 9e29a9a..b1b5171 100644 --- a/include/__attributes.h +++ b/include/__attributes.h @@ -4,20 +4,9 @@ #ifndef LIBCDSB_CORE_ATTRIBUTES_H #define LIBCDSB_CORE_ATTRIBUTES_H -#define LIBCDSB_nt__ __attribute__ ((nothrow)) -#define LIBCDSB_nn1__ __attribute__ ((nonnull (1))) -#define LIBCDSB_nn2__ __attribute__ ((nonnull (2))) -#define LIBCDSB_nn12__ __attribute__ ((nonnull (1,2))) -#define LIBCDSB_nn123__ __attribute__ ((nonnull (1,2,3))) -#define LIBCDSB_nn124__ __attribute__ ((nonnull (1,2,4))) -#define LIBCDSB_nn13__ __attribute__ ((nonnull (1,3))) -#define LIBCDSB_nn23__ __attribute__ ((nonnull (2,3))) -#define LIBCDSB_nn23__ __attribute__ ((nonnull (2,3))) -#define LIBCDSB_pure__ LIBCDSB_nt__ __attribute__ ((pure)) -#define LIBCDSB_wur__ __attribute__ ((warn_unused_result)) - -#define LIBCDSB_cmpattr__ LIBCDSB_pure__ LIBCDSB_nn12__ -#define LIBCDSB_cpyattr__ LIBCDSB_pure__ LIBCDSB_wur__ LIBCDSB_nn1__ -#define LIBCDSB_dupattr__ LIBCDSB_wur__ LIBCDSB_nn1__ +#define Pure__ __attribute__ ((pure)) +#define Always_inline__ __attribute__ ((always_inline)) +#define Warn_unused_result__ __attribute__ ((warn_unused_result)) +#define Nonnull__(...) __attribute__ ((nonnull (__VA_ARGS__))) #endif /* LIBCDSB_CORE_ATTRIBUTES_H */ diff --git a/include/array.h b/include/array.h index 24b875d..9e7dee1 100644 --- a/include/array.h +++ b/include/array.h @@ -11,13 +11,12 @@ typedef int (*array_access_callback)(void* value, ssize_t index, vtype type, void* data); -extern void array_init(vtype_array* x, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__; +extern void array_init (vtype_array* x, vtype type) Nonnull__(1); +extern void* array_at (const vtype_array* s, ssize_t index) Nonnull__(1); +extern size_t array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, bool cut) Nonnull__(1); -extern void* array_at(const vtype_array* s, ssize_t index) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; - -extern void array_sort (vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; +extern void array_sort (vtype_array* x) Nonnull__(1); +extern void array_reverse(vtype_array* x) Nonnull__(1); #define array_pop(x, value, data, callback) _LIBCDSB_Generic(libcdsb_array, find, value)(x, value, data, callback, 0, 1) #define array_find(x, value, data, callback) _LIBCDSB_Generic(libcdsb_array, find, value)(x, value, data, callback, 0, 0) @@ -30,67 +29,67 @@ extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; /*#####################################################################################################################*/ -extern void libcdsb_array_push_pointer(vtype_array* x, const void* value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_cstring(vtype_array* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_string (vtype_array* x, const vtype_string* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_array (vtype_array* x, const vtype_array* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_list (vtype_array* x, const vtype_list* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_map (vtype_array* x, const vtype_map* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_vset (vtype_array* x, const vtype_set* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_dict (vtype_array* x, const vtype_dict* value) LIBCDSB_nt__ LIBCDSB_nn12__; -extern void libcdsb_array_push_boolean(vtype_array* x, vtype_bool value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_uint8 (vtype_array* x, vtype_uint8 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_uint16 (vtype_array* x, vtype_uint16 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_uint32 (vtype_array* x, vtype_uint32 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_uint64 (vtype_array* x, vtype_uint64 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_int8 (vtype_array* x, vtype_int8 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_int16 (vtype_array* x, vtype_int16 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_int32 (vtype_array* x, vtype_int32 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_int64 (vtype_array* x, vtype_int64 value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_float (vtype_array* x, vtype_float value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_double (vtype_array* x, vtype_double value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_array_push_ldouble(vtype_array* x, vtype_ldouble value) LIBCDSB_nt__ LIBCDSB_nn1__; +extern void libcdsb_array_push_pointer(vtype_array* x, const void* value) Nonnull__(1); +extern void libcdsb_array_push_cstring(vtype_array* x, const char* value) Nonnull__(1,2); +extern void libcdsb_array_push_string (vtype_array* x, const vtype_string* value) Nonnull__(1,2); +extern void libcdsb_array_push_array (vtype_array* x, const vtype_array* value) Nonnull__(1,2); +extern void libcdsb_array_push_list (vtype_array* x, const vtype_list* value) Nonnull__(1,2); +extern void libcdsb_array_push_map (vtype_array* x, const vtype_map* value) Nonnull__(1,2); +extern void libcdsb_array_push_vset (vtype_array* x, const vtype_set* value) Nonnull__(1,2); +extern void libcdsb_array_push_dict (vtype_array* x, const vtype_dict* value) Nonnull__(1,2); +extern void libcdsb_array_push_boolean(vtype_array* x, vtype_bool value) Nonnull__(1); +extern void libcdsb_array_push_uint8 (vtype_array* x, vtype_uint8 value) Nonnull__(1); +extern void libcdsb_array_push_uint16 (vtype_array* x, vtype_uint16 value) Nonnull__(1); +extern void libcdsb_array_push_uint32 (vtype_array* x, vtype_uint32 value) Nonnull__(1); +extern void libcdsb_array_push_uint64 (vtype_array* x, vtype_uint64 value) Nonnull__(1); +extern void libcdsb_array_push_int8 (vtype_array* x, vtype_int8 value) Nonnull__(1); +extern void libcdsb_array_push_int16 (vtype_array* x, vtype_int16 value) Nonnull__(1); +extern void libcdsb_array_push_int32 (vtype_array* x, vtype_int32 value) Nonnull__(1); +extern void libcdsb_array_push_int64 (vtype_array* x, vtype_int64 value) Nonnull__(1); +extern void libcdsb_array_push_float (vtype_array* x, vtype_float value) Nonnull__(1); +extern void libcdsb_array_push_double (vtype_array* x, vtype_double value) Nonnull__(1); +extern void libcdsb_array_push_ldouble(vtype_array* x, vtype_ldouble value) Nonnull__(1); -extern size_t libcdsb_array_count_pointer(const vtype_array* s, const void* value); -extern size_t libcdsb_array_count_cstring(const vtype_array* s, const char* value); -extern size_t libcdsb_array_count_string (const vtype_array* s, const vtype_string* value); -extern size_t libcdsb_array_count_array (const vtype_array* s, const vtype_array* value); -extern size_t libcdsb_array_count_list (const vtype_array* s, const vtype_list* value); -extern size_t libcdsb_array_count_map (const vtype_array* s, const vtype_map* value); -extern size_t libcdsb_array_count_vset (const vtype_array* s, const vtype_set* value); -extern size_t libcdsb_array_count_dict (const vtype_array* s, const vtype_dict* value); -extern size_t libcdsb_array_count_boolean(const vtype_array* s, vtype_bool value); -extern size_t libcdsb_array_count_int8 (const vtype_array* s, vtype_int8 value); -extern size_t libcdsb_array_count_int16 (const vtype_array* s, vtype_int16 value); -extern size_t libcdsb_array_count_int32 (const vtype_array* s, vtype_int32 value); -extern size_t libcdsb_array_count_int64 (const vtype_array* s, vtype_int64 value); -extern size_t libcdsb_array_count_uint8 (const vtype_array* s, vtype_uint8 value); -extern size_t libcdsb_array_count_uint16 (const vtype_array* s, vtype_uint16 value); -extern size_t libcdsb_array_count_uint32 (const vtype_array* s, vtype_uint32 value); -extern size_t libcdsb_array_count_uint64 (const vtype_array* s, vtype_uint64 value); -extern size_t libcdsb_array_count_float (const vtype_array* s, vtype_float value); -extern size_t libcdsb_array_count_double (const vtype_array* s, vtype_double value); -extern size_t libcdsb_array_count_ldouble(const vtype_array* s, vtype_ldouble value); +extern size_t libcdsb_array_count_pointer(const vtype_array* s, const void* value) Nonnull__(1); +extern size_t libcdsb_array_count_cstring(const vtype_array* s, const char* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_string (const vtype_array* s, const vtype_string* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_array (const vtype_array* s, const vtype_array* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_list (const vtype_array* s, const vtype_list* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_map (const vtype_array* s, const vtype_map* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_vset (const vtype_array* s, const vtype_set* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_dict (const vtype_array* s, const vtype_dict* value) Nonnull__(1,2); +extern size_t libcdsb_array_count_boolean(const vtype_array* s, vtype_bool value) Nonnull__(1); +extern size_t libcdsb_array_count_int8 (const vtype_array* s, vtype_int8 value) Nonnull__(1); +extern size_t libcdsb_array_count_int16 (const vtype_array* s, vtype_int16 value) Nonnull__(1); +extern size_t libcdsb_array_count_int32 (const vtype_array* s, vtype_int32 value) Nonnull__(1); +extern size_t libcdsb_array_count_int64 (const vtype_array* s, vtype_int64 value) Nonnull__(1); +extern size_t libcdsb_array_count_uint8 (const vtype_array* s, vtype_uint8 value) Nonnull__(1); +extern size_t libcdsb_array_count_uint16 (const vtype_array* s, vtype_uint16 value) Nonnull__(1); +extern size_t libcdsb_array_count_uint32 (const vtype_array* s, vtype_uint32 value) Nonnull__(1); +extern size_t libcdsb_array_count_uint64 (const vtype_array* s, vtype_uint64 value) Nonnull__(1); +extern size_t libcdsb_array_count_float (const vtype_array* s, vtype_float value) Nonnull__(1); +extern size_t libcdsb_array_count_double (const vtype_array* s, vtype_double value) Nonnull__(1); +extern size_t libcdsb_array_count_ldouble(const vtype_array* s, vtype_ldouble value) Nonnull__(1); -extern int libcdsb_array_find_pointer(vtype_array* x, const void* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_cstring(vtype_array* x, const char* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_string (vtype_array* x, const vtype_string* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_array (vtype_array* x, const vtype_array* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_list (vtype_array* x, const vtype_list* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_map (vtype_array* x, const vtype_map* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_vset (vtype_array* x, const vtype_set* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; -extern int libcdsb_array_find_dict (vtype_array* x, const vtype_dict* value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_boolean(vtype_array* x, vtype_bool value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint8 (vtype_array* x, vtype_uint8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint16 (vtype_array* x, vtype_uint16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint32 (vtype_array* x, vtype_uint32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_uint64 (vtype_array* x, vtype_uint64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int8 (vtype_array* x, vtype_int8 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int16 (vtype_array* x, vtype_int16 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int32 (vtype_array* x, vtype_int32 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_int64 (vtype_array* x, vtype_int64 value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_float (vtype_array* x, vtype_float value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_double (vtype_array* x, vtype_double value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_find_ldouble(vtype_array* x, vtype_ldouble value, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; +extern int libcdsb_array_find_pointer(vtype_array* x, const void* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_cstring(vtype_array* x, const char* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_string (vtype_array* x, const vtype_string* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_array (vtype_array* x, const vtype_array* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_list (vtype_array* x, const vtype_list* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_map (vtype_array* x, const vtype_map* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_vset (vtype_array* x, const vtype_set* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_dict (vtype_array* x, const vtype_dict* value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_array_find_boolean(vtype_array* x, vtype_bool value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_uint8 (vtype_array* x, vtype_uint8 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_uint16 (vtype_array* x, vtype_uint16 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_uint32 (vtype_array* x, vtype_uint32 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_uint64 (vtype_array* x, vtype_uint64 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_int8 (vtype_array* x, vtype_int8 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_int16 (vtype_array* x, vtype_int16 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_int32 (vtype_array* x, vtype_int32 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_int64 (vtype_array* x, vtype_int64 value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_float (vtype_array* x, vtype_float value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_double (vtype_array* x, vtype_double value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_find_ldouble(vtype_array* x, vtype_ldouble value, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); #endif /* LIBCDSB_ARRAY_H */ diff --git a/include/dict.h b/include/dict.h index a434ad4..8ff850c 100644 --- a/include/dict.h +++ b/include/dict.h @@ -9,452 +9,452 @@ typedef int (*dict_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data); -extern void dict_init(vtype_dict* x); +extern void dict_init(vtype_dict* x) Nonnull__(1); #define dict_pop(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 1) #define dict_get(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 0) #define dict_update(x, key, value) _LIBCDSB_Generic2(libcdsb_dict, update, key, value)(x, key, value) #define dict_remove(x, key) dict_pop(x, key, 0, 0) -extern int libcdsb_dict_get_by_pointer(vtype_dict* x, const void* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_cstring(vtype_dict* x, const char* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_string (vtype_dict* x, const vtype_string* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_array (vtype_dict* x, const vtype_array* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_list (vtype_dict* x, const vtype_list* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_map (vtype_dict* x, const vtype_map* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_vset (vtype_dict* x, const vtype_set* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_dict (vtype_dict* x, const vtype_dict* key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_boolean(vtype_dict* x, vtype_bool key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_int8 (vtype_dict* x, vtype_int8 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_int16 (vtype_dict* x, vtype_int16 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_int32 (vtype_dict* x, vtype_int32 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_int64 (vtype_dict* x, vtype_int64 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_uint8 (vtype_dict* x, vtype_uint8 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_uint16 (vtype_dict* x, vtype_uint16 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_uint32 (vtype_dict* x, vtype_uint32 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_uint64 (vtype_dict* x, vtype_uint64 key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_float (vtype_dict* x, vtype_float key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_double (vtype_dict* x, vtype_double key, void* data, dict_access_callback, bool cut); -extern int libcdsb_dict_get_by_ldouble(vtype_dict* x, vtype_ldouble key, void* data, dict_access_callback, bool cut); +extern int libcdsb_dict_get_by_pointer(vtype_dict* x, const void* key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_cstring(vtype_dict* x, const char* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_string (vtype_dict* x, const vtype_string* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_array (vtype_dict* x, const vtype_array* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_list (vtype_dict* x, const vtype_list* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_map (vtype_dict* x, const vtype_map* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_vset (vtype_dict* x, const vtype_set* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_dict (vtype_dict* x, const vtype_dict* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_dict_get_by_boolean(vtype_dict* x, vtype_bool key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_int8 (vtype_dict* x, vtype_int8 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_int16 (vtype_dict* x, vtype_int16 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_int32 (vtype_dict* x, vtype_int32 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_int64 (vtype_dict* x, vtype_int64 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_uint8 (vtype_dict* x, vtype_uint8 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_uint16 (vtype_dict* x, vtype_uint16 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_uint32 (vtype_dict* x, vtype_uint32 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_uint64 (vtype_dict* x, vtype_uint64 key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_float (vtype_dict* x, vtype_float key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_double (vtype_dict* x, vtype_double key, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_get_by_ldouble(vtype_dict* x, vtype_ldouble key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_pointer(vtype_dict* x, const void* key, const void* value); -extern bool libcdsb_dict_update_pointer_cstring(vtype_dict* x, const void* key, const char* value); -extern bool libcdsb_dict_update_pointer_string (vtype_dict* x, const void* key, const vtype_string* value); -extern bool libcdsb_dict_update_pointer_array (vtype_dict* x, const void* key, const vtype_array* value); -extern bool libcdsb_dict_update_pointer_list (vtype_dict* x, const void* key, const vtype_list* value); -extern bool libcdsb_dict_update_pointer_map (vtype_dict* x, const void* key, const vtype_map* value); -extern bool libcdsb_dict_update_pointer_vset (vtype_dict* x, const void* key, const vtype_set* value); -extern bool libcdsb_dict_update_pointer_dict (vtype_dict* x, const void* key, const vtype_dict* value); -extern bool libcdsb_dict_update_pointer_boolean(vtype_dict* x, const void* key, vtype_bool value); -extern bool libcdsb_dict_update_pointer_int8 (vtype_dict* x, const void* key, vtype_int8 value); -extern bool libcdsb_dict_update_pointer_int16 (vtype_dict* x, const void* key, vtype_int16 value); -extern bool libcdsb_dict_update_pointer_int32 (vtype_dict* x, const void* key, vtype_int32 value); -extern bool libcdsb_dict_update_pointer_int64 (vtype_dict* x, const void* key, vtype_int64 value); -extern bool libcdsb_dict_update_pointer_uint8 (vtype_dict* x, const void* key, vtype_uint8 value); -extern bool libcdsb_dict_update_pointer_uint16 (vtype_dict* x, const void* key, vtype_uint16 value); -extern bool libcdsb_dict_update_pointer_uint32 (vtype_dict* x, const void* key, vtype_uint32 value); -extern bool libcdsb_dict_update_pointer_uint64 (vtype_dict* x, const void* key, vtype_uint64 value); -extern bool libcdsb_dict_update_pointer_float (vtype_dict* x, const void* key, vtype_float value); -extern bool libcdsb_dict_update_pointer_double (vtype_dict* x, const void* key, vtype_double value); -extern bool libcdsb_dict_update_pointer_ldouble(vtype_dict* x, const void* key, vtype_ldouble value); +extern bool libcdsb_dict_update_pointer_pointer(vtype_dict* x, const void* key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_cstring(vtype_dict* x, const void* key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_string (vtype_dict* x, const void* key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_array (vtype_dict* x, const void* key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_list (vtype_dict* x, const void* key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_map (vtype_dict* x, const void* key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_vset (vtype_dict* x, const void* key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_dict (vtype_dict* x, const void* key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_pointer_boolean(vtype_dict* x, const void* key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_int8 (vtype_dict* x, const void* key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_int16 (vtype_dict* x, const void* key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_int32 (vtype_dict* x, const void* key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_int64 (vtype_dict* x, const void* key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_uint8 (vtype_dict* x, const void* key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_uint16 (vtype_dict* x, const void* key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_uint32 (vtype_dict* x, const void* key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_uint64 (vtype_dict* x, const void* key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_float (vtype_dict* x, const void* key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_double (vtype_dict* x, const void* key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_pointer_ldouble(vtype_dict* x, const void* key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_string_pointer(vtype_dict* x, const vtype_string* key, const void* value); -extern bool libcdsb_dict_update_string_cstring(vtype_dict* x, const vtype_string* key, const char* value); -extern bool libcdsb_dict_update_string_string (vtype_dict* x, const vtype_string* key, const vtype_string* value); -extern bool libcdsb_dict_update_string_array (vtype_dict* x, const vtype_string* key, const vtype_array* value); -extern bool libcdsb_dict_update_string_list (vtype_dict* x, const vtype_string* key, const vtype_list* value); -extern bool libcdsb_dict_update_string_map (vtype_dict* x, const vtype_string* key, const vtype_map* value); -extern bool libcdsb_dict_update_string_vset (vtype_dict* x, const vtype_string* key, const vtype_set* value); -extern bool libcdsb_dict_update_string_dict (vtype_dict* x, const vtype_string* key, const vtype_dict* value); -extern bool libcdsb_dict_update_string_boolean(vtype_dict* x, const vtype_string* key, vtype_bool value); -extern bool libcdsb_dict_update_string_int8 (vtype_dict* x, const vtype_string* key, vtype_int8 value); -extern bool libcdsb_dict_update_string_int16 (vtype_dict* x, const vtype_string* key, vtype_int16 value); -extern bool libcdsb_dict_update_string_int32 (vtype_dict* x, const vtype_string* key, vtype_int32 value); -extern bool libcdsb_dict_update_string_int64 (vtype_dict* x, const vtype_string* key, vtype_int64 value); -extern bool libcdsb_dict_update_string_uint8 (vtype_dict* x, const vtype_string* key, vtype_uint8 value); -extern bool libcdsb_dict_update_string_uint16 (vtype_dict* x, const vtype_string* key, vtype_uint16 value); -extern bool libcdsb_dict_update_string_uint32 (vtype_dict* x, const vtype_string* key, vtype_uint32 value); -extern bool libcdsb_dict_update_string_uint64 (vtype_dict* x, const vtype_string* key, vtype_uint64 value); -extern bool libcdsb_dict_update_string_float (vtype_dict* x, const vtype_string* key, vtype_float value); -extern bool libcdsb_dict_update_string_double (vtype_dict* x, const vtype_string* key, vtype_double value); -extern bool libcdsb_dict_update_string_ldouble(vtype_dict* x, const vtype_string* key, vtype_ldouble value); +extern bool libcdsb_dict_update_cstring_pointer(vtype_dict* x, const char* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_cstring(vtype_dict* x, const char* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_string (vtype_dict* x, const char* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_array (vtype_dict* x, const char* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_list (vtype_dict* x, const char* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_map (vtype_dict* x, const char* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_vset (vtype_dict* x, const char* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_dict (vtype_dict* x, const char* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_cstring_boolean(vtype_dict* x, const char* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_int8 (vtype_dict* x, const char* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_int16 (vtype_dict* x, const char* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_int32 (vtype_dict* x, const char* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_int64 (vtype_dict* x, const char* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_uint8 (vtype_dict* x, const char* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_uint16 (vtype_dict* x, const char* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_uint32 (vtype_dict* x, const char* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_uint64 (vtype_dict* x, const char* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_float (vtype_dict* x, const char* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_double (vtype_dict* x, const char* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_cstring_ldouble(vtype_dict* x, const char* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_pointer(vtype_dict* x, const vtype_array* key, const void* value); -extern bool libcdsb_dict_update_array_cstring(vtype_dict* x, const vtype_array* key, const char* value); -extern bool libcdsb_dict_update_array_string (vtype_dict* x, const vtype_array* key, const vtype_string* value); -extern bool libcdsb_dict_update_array_array (vtype_dict* x, const vtype_array* key, const vtype_array* value); -extern bool libcdsb_dict_update_array_list (vtype_dict* x, const vtype_array* key, const vtype_list* value); -extern bool libcdsb_dict_update_array_map (vtype_dict* x, const vtype_array* key, const vtype_map* value); -extern bool libcdsb_dict_update_array_vset (vtype_dict* x, const vtype_array* key, const vtype_set* value); -extern bool libcdsb_dict_update_array_dict (vtype_dict* x, const vtype_array* key, const vtype_dict* value); -extern bool libcdsb_dict_update_array_boolean(vtype_dict* x, const vtype_array* key, vtype_bool value); -extern bool libcdsb_dict_update_array_int8 (vtype_dict* x, const vtype_array* key, vtype_int8 value); -extern bool libcdsb_dict_update_array_int16 (vtype_dict* x, const vtype_array* key, vtype_int16 value); -extern bool libcdsb_dict_update_array_int32 (vtype_dict* x, const vtype_array* key, vtype_int32 value); -extern bool libcdsb_dict_update_array_int64 (vtype_dict* x, const vtype_array* key, vtype_int64 value); -extern bool libcdsb_dict_update_array_uint8 (vtype_dict* x, const vtype_array* key, vtype_uint8 value); -extern bool libcdsb_dict_update_array_uint16 (vtype_dict* x, const vtype_array* key, vtype_uint16 value); -extern bool libcdsb_dict_update_array_uint32 (vtype_dict* x, const vtype_array* key, vtype_uint32 value); -extern bool libcdsb_dict_update_array_uint64 (vtype_dict* x, const vtype_array* key, vtype_uint64 value); -extern bool libcdsb_dict_update_array_float (vtype_dict* x, const vtype_array* key, vtype_float value); -extern bool libcdsb_dict_update_array_double (vtype_dict* x, const vtype_array* key, vtype_double value); -extern bool libcdsb_dict_update_array_ldouble(vtype_dict* x, const vtype_array* key, vtype_ldouble value); +extern bool libcdsb_dict_update_string_pointer(vtype_dict* x, const vtype_string* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_cstring(vtype_dict* x, const vtype_string* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_string (vtype_dict* x, const vtype_string* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_array (vtype_dict* x, const vtype_string* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_list (vtype_dict* x, const vtype_string* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_map (vtype_dict* x, const vtype_string* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_vset (vtype_dict* x, const vtype_string* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_dict (vtype_dict* x, const vtype_string* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_string_boolean(vtype_dict* x, const vtype_string* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_int8 (vtype_dict* x, const vtype_string* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_int16 (vtype_dict* x, const vtype_string* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_int32 (vtype_dict* x, const vtype_string* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_int64 (vtype_dict* x, const vtype_string* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_uint8 (vtype_dict* x, const vtype_string* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_uint16 (vtype_dict* x, const vtype_string* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_uint32 (vtype_dict* x, const vtype_string* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_uint64 (vtype_dict* x, const vtype_string* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_float (vtype_dict* x, const vtype_string* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_double (vtype_dict* x, const vtype_string* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_string_ldouble(vtype_dict* x, const vtype_string* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_pointer(vtype_dict* x, const vtype_list* key, const void* value); -extern bool libcdsb_dict_update_list_cstring(vtype_dict* x, const vtype_list* key, const char* value); -extern bool libcdsb_dict_update_list_string (vtype_dict* x, const vtype_list* key, const vtype_string* value); -extern bool libcdsb_dict_update_list_array (vtype_dict* x, const vtype_list* key, const vtype_array* value); -extern bool libcdsb_dict_update_list_list (vtype_dict* x, const vtype_list* key, const vtype_list* value); -extern bool libcdsb_dict_update_list_map (vtype_dict* x, const vtype_list* key, const vtype_map* value); -extern bool libcdsb_dict_update_list_vset (vtype_dict* x, const vtype_list* key, const vtype_set* value); -extern bool libcdsb_dict_update_list_dict (vtype_dict* x, const vtype_list* key, const vtype_dict* value); -extern bool libcdsb_dict_update_list_boolean(vtype_dict* x, const vtype_list* key, vtype_bool value); -extern bool libcdsb_dict_update_list_int8 (vtype_dict* x, const vtype_list* key, vtype_int8 value); -extern bool libcdsb_dict_update_list_int16 (vtype_dict* x, const vtype_list* key, vtype_int16 value); -extern bool libcdsb_dict_update_list_int32 (vtype_dict* x, const vtype_list* key, vtype_int32 value); -extern bool libcdsb_dict_update_list_int64 (vtype_dict* x, const vtype_list* key, vtype_int64 value); -extern bool libcdsb_dict_update_list_uint8 (vtype_dict* x, const vtype_list* key, vtype_uint8 value); -extern bool libcdsb_dict_update_list_uint16 (vtype_dict* x, const vtype_list* key, vtype_uint16 value); -extern bool libcdsb_dict_update_list_uint32 (vtype_dict* x, const vtype_list* key, vtype_uint32 value); -extern bool libcdsb_dict_update_list_uint64 (vtype_dict* x, const vtype_list* key, vtype_uint64 value); -extern bool libcdsb_dict_update_list_float (vtype_dict* x, const vtype_list* key, vtype_float value); -extern bool libcdsb_dict_update_list_double (vtype_dict* x, const vtype_list* key, vtype_double value); -extern bool libcdsb_dict_update_list_ldouble(vtype_dict* x, const vtype_list* key, vtype_ldouble value); +extern bool libcdsb_dict_update_array_pointer(vtype_dict* x, const vtype_array* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_cstring(vtype_dict* x, const vtype_array* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_string (vtype_dict* x, const vtype_array* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_array (vtype_dict* x, const vtype_array* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_list (vtype_dict* x, const vtype_array* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_map (vtype_dict* x, const vtype_array* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_vset (vtype_dict* x, const vtype_array* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_dict (vtype_dict* x, const vtype_array* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_array_boolean(vtype_dict* x, const vtype_array* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_int8 (vtype_dict* x, const vtype_array* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_int16 (vtype_dict* x, const vtype_array* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_int32 (vtype_dict* x, const vtype_array* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_int64 (vtype_dict* x, const vtype_array* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_uint8 (vtype_dict* x, const vtype_array* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_uint16 (vtype_dict* x, const vtype_array* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_uint32 (vtype_dict* x, const vtype_array* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_uint64 (vtype_dict* x, const vtype_array* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_float (vtype_dict* x, const vtype_array* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_double (vtype_dict* x, const vtype_array* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_array_ldouble(vtype_dict* x, const vtype_array* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_pointer(vtype_dict* x, const vtype_map* key, const void* value); -extern bool libcdsb_dict_update_map_cstring(vtype_dict* x, const vtype_map* key, const char* value); -extern bool libcdsb_dict_update_map_string (vtype_dict* x, const vtype_map* key, const vtype_string* value); -extern bool libcdsb_dict_update_map_array (vtype_dict* x, const vtype_map* key, const vtype_array* value); -extern bool libcdsb_dict_update_map_list (vtype_dict* x, const vtype_map* key, const vtype_list* value); -extern bool libcdsb_dict_update_map_map (vtype_dict* x, const vtype_map* key, const vtype_map* value); -extern bool libcdsb_dict_update_map_vset (vtype_dict* x, const vtype_map* key, const vtype_set* value); -extern bool libcdsb_dict_update_map_dict (vtype_dict* x, const vtype_map* key, const vtype_dict* value); -extern bool libcdsb_dict_update_map_boolean(vtype_dict* x, const vtype_map* key, vtype_bool value); -extern bool libcdsb_dict_update_map_int8 (vtype_dict* x, const vtype_map* key, vtype_int8 value); -extern bool libcdsb_dict_update_map_int16 (vtype_dict* x, const vtype_map* key, vtype_int16 value); -extern bool libcdsb_dict_update_map_int32 (vtype_dict* x, const vtype_map* key, vtype_int32 value); -extern bool libcdsb_dict_update_map_int64 (vtype_dict* x, const vtype_map* key, vtype_int64 value); -extern bool libcdsb_dict_update_map_uint8 (vtype_dict* x, const vtype_map* key, vtype_uint8 value); -extern bool libcdsb_dict_update_map_uint16 (vtype_dict* x, const vtype_map* key, vtype_uint16 value); -extern bool libcdsb_dict_update_map_uint32 (vtype_dict* x, const vtype_map* key, vtype_uint32 value); -extern bool libcdsb_dict_update_map_uint64 (vtype_dict* x, const vtype_map* key, vtype_uint64 value); -extern bool libcdsb_dict_update_map_float (vtype_dict* x, const vtype_map* key, vtype_float value); -extern bool libcdsb_dict_update_map_double (vtype_dict* x, const vtype_map* key, vtype_double value); -extern bool libcdsb_dict_update_map_ldouble(vtype_dict* x, const vtype_map* key, vtype_ldouble value); +extern bool libcdsb_dict_update_list_pointer(vtype_dict* x, const vtype_list* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_cstring(vtype_dict* x, const vtype_list* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_string (vtype_dict* x, const vtype_list* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_array (vtype_dict* x, const vtype_list* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_list (vtype_dict* x, const vtype_list* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_map (vtype_dict* x, const vtype_list* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_vset (vtype_dict* x, const vtype_list* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_dict (vtype_dict* x, const vtype_list* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_list_boolean(vtype_dict* x, const vtype_list* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_int8 (vtype_dict* x, const vtype_list* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_int16 (vtype_dict* x, const vtype_list* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_int32 (vtype_dict* x, const vtype_list* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_int64 (vtype_dict* x, const vtype_list* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_uint8 (vtype_dict* x, const vtype_list* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_uint16 (vtype_dict* x, const vtype_list* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_uint32 (vtype_dict* x, const vtype_list* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_uint64 (vtype_dict* x, const vtype_list* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_float (vtype_dict* x, const vtype_list* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_double (vtype_dict* x, const vtype_list* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_list_ldouble(vtype_dict* x, const vtype_list* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_pointer(vtype_dict* x, const vtype_set* key, const void* value); -extern bool libcdsb_dict_update_vset_cstring(vtype_dict* x, const vtype_set* key, const char* value); -extern bool libcdsb_dict_update_vset_string (vtype_dict* x, const vtype_set* key, const vtype_string* value); -extern bool libcdsb_dict_update_vset_array (vtype_dict* x, const vtype_set* key, const vtype_array* value); -extern bool libcdsb_dict_update_vset_list (vtype_dict* x, const vtype_set* key, const vtype_list* value); -extern bool libcdsb_dict_update_vset_map (vtype_dict* x, const vtype_set* key, const vtype_map* value); -extern bool libcdsb_dict_update_vset_vset (vtype_dict* x, const vtype_set* key, const vtype_set* value); -extern bool libcdsb_dict_update_vset_dict (vtype_dict* x, const vtype_set* key, const vtype_dict* value); -extern bool libcdsb_dict_update_vset_boolean(vtype_dict* x, const vtype_set* key, vtype_bool value); -extern bool libcdsb_dict_update_vset_int8 (vtype_dict* x, const vtype_set* key, vtype_int8 value); -extern bool libcdsb_dict_update_vset_int16 (vtype_dict* x, const vtype_set* key, vtype_int16 value); -extern bool libcdsb_dict_update_vset_int32 (vtype_dict* x, const vtype_set* key, vtype_int32 value); -extern bool libcdsb_dict_update_vset_int64 (vtype_dict* x, const vtype_set* key, vtype_int64 value); -extern bool libcdsb_dict_update_vset_uint8 (vtype_dict* x, const vtype_set* key, vtype_uint8 value); -extern bool libcdsb_dict_update_vset_uint16 (vtype_dict* x, const vtype_set* key, vtype_uint16 value); -extern bool libcdsb_dict_update_vset_uint32 (vtype_dict* x, const vtype_set* key, vtype_uint32 value); -extern bool libcdsb_dict_update_vset_uint64 (vtype_dict* x, const vtype_set* key, vtype_uint64 value); -extern bool libcdsb_dict_update_vset_float (vtype_dict* x, const vtype_set* key, vtype_float value); -extern bool libcdsb_dict_update_vset_double (vtype_dict* x, const vtype_set* key, vtype_double value); -extern bool libcdsb_dict_update_vset_ldouble(vtype_dict* x, const vtype_set* key, vtype_ldouble value); +extern bool libcdsb_dict_update_map_pointer(vtype_dict* x, const vtype_map* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_cstring(vtype_dict* x, const vtype_map* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_string (vtype_dict* x, const vtype_map* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_array (vtype_dict* x, const vtype_map* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_list (vtype_dict* x, const vtype_map* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_map (vtype_dict* x, const vtype_map* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_vset (vtype_dict* x, const vtype_map* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_dict (vtype_dict* x, const vtype_map* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_map_boolean(vtype_dict* x, const vtype_map* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_int8 (vtype_dict* x, const vtype_map* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_int16 (vtype_dict* x, const vtype_map* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_int32 (vtype_dict* x, const vtype_map* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_int64 (vtype_dict* x, const vtype_map* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_uint8 (vtype_dict* x, const vtype_map* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_uint16 (vtype_dict* x, const vtype_map* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_uint32 (vtype_dict* x, const vtype_map* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_uint64 (vtype_dict* x, const vtype_map* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_float (vtype_dict* x, const vtype_map* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_double (vtype_dict* x, const vtype_map* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_map_ldouble(vtype_dict* x, const vtype_map* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_pointer(vtype_dict* x, const vtype_dict* key, const void* value); -extern bool libcdsb_dict_update_dict_cstring(vtype_dict* x, const vtype_dict* key, const char* value); -extern bool libcdsb_dict_update_dict_string (vtype_dict* x, const vtype_dict* key, const vtype_string* value); -extern bool libcdsb_dict_update_dict_array (vtype_dict* x, const vtype_dict* key, const vtype_array* value); -extern bool libcdsb_dict_update_dict_list (vtype_dict* x, const vtype_dict* key, const vtype_list* value); -extern bool libcdsb_dict_update_dict_map (vtype_dict* x, const vtype_dict* key, const vtype_map* value); -extern bool libcdsb_dict_update_dict_vset (vtype_dict* x, const vtype_dict* key, const vtype_set* value); -extern bool libcdsb_dict_update_dict_dict (vtype_dict* x, const vtype_dict* key, const vtype_dict* value); -extern bool libcdsb_dict_update_dict_boolean(vtype_dict* x, const vtype_dict* key, vtype_bool value); -extern bool libcdsb_dict_update_dict_int8 (vtype_dict* x, const vtype_dict* key, vtype_int8 value); -extern bool libcdsb_dict_update_dict_int16 (vtype_dict* x, const vtype_dict* key, vtype_int16 value); -extern bool libcdsb_dict_update_dict_int32 (vtype_dict* x, const vtype_dict* key, vtype_int32 value); -extern bool libcdsb_dict_update_dict_int64 (vtype_dict* x, const vtype_dict* key, vtype_int64 value); -extern bool libcdsb_dict_update_dict_uint8 (vtype_dict* x, const vtype_dict* key, vtype_uint8 value); -extern bool libcdsb_dict_update_dict_uint16 (vtype_dict* x, const vtype_dict* key, vtype_uint16 value); -extern bool libcdsb_dict_update_dict_uint32 (vtype_dict* x, const vtype_dict* key, vtype_uint32 value); -extern bool libcdsb_dict_update_dict_uint64 (vtype_dict* x, const vtype_dict* key, vtype_uint64 value); -extern bool libcdsb_dict_update_dict_float (vtype_dict* x, const vtype_dict* key, vtype_float value); -extern bool libcdsb_dict_update_dict_double (vtype_dict* x, const vtype_dict* key, vtype_double value); -extern bool libcdsb_dict_update_dict_ldouble(vtype_dict* x, const vtype_dict* key, vtype_ldouble value); +extern bool libcdsb_dict_update_vset_pointer(vtype_dict* x, const vtype_set* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_cstring(vtype_dict* x, const vtype_set* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_string (vtype_dict* x, const vtype_set* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_array (vtype_dict* x, const vtype_set* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_list (vtype_dict* x, const vtype_set* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_map (vtype_dict* x, const vtype_set* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_vset (vtype_dict* x, const vtype_set* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_dict (vtype_dict* x, const vtype_set* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_vset_boolean(vtype_dict* x, const vtype_set* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_int8 (vtype_dict* x, const vtype_set* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_int16 (vtype_dict* x, const vtype_set* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_int32 (vtype_dict* x, const vtype_set* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_int64 (vtype_dict* x, const vtype_set* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_uint8 (vtype_dict* x, const vtype_set* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_uint16 (vtype_dict* x, const vtype_set* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_uint32 (vtype_dict* x, const vtype_set* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_uint64 (vtype_dict* x, const vtype_set* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_float (vtype_dict* x, const vtype_set* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_double (vtype_dict* x, const vtype_set* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_vset_ldouble(vtype_dict* x, const vtype_set* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_pointer(vtype_dict* x, const char* key, const void* value); -extern bool libcdsb_dict_update_cstring_cstring(vtype_dict* x, const char* key, const char* value); -extern bool libcdsb_dict_update_cstring_string (vtype_dict* x, const char* key, const vtype_string* value); -extern bool libcdsb_dict_update_cstring_array (vtype_dict* x, const char* key, const vtype_array* value); -extern bool libcdsb_dict_update_cstring_list (vtype_dict* x, const char* key, const vtype_list* value); -extern bool libcdsb_dict_update_cstring_map (vtype_dict* x, const char* key, const vtype_map* value); -extern bool libcdsb_dict_update_cstring_vset (vtype_dict* x, const char* key, const vtype_set* value); -extern bool libcdsb_dict_update_cstring_dict (vtype_dict* x, const char* key, const vtype_dict* value); -extern bool libcdsb_dict_update_cstring_boolean(vtype_dict* x, const char* key, vtype_bool value); -extern bool libcdsb_dict_update_cstring_int8 (vtype_dict* x, const char* key, vtype_int8 value); -extern bool libcdsb_dict_update_cstring_int16 (vtype_dict* x, const char* key, vtype_int16 value); -extern bool libcdsb_dict_update_cstring_int32 (vtype_dict* x, const char* key, vtype_int32 value); -extern bool libcdsb_dict_update_cstring_int64 (vtype_dict* x, const char* key, vtype_int64 value); -extern bool libcdsb_dict_update_cstring_uint8 (vtype_dict* x, const char* key, vtype_uint8 value); -extern bool libcdsb_dict_update_cstring_uint16 (vtype_dict* x, const char* key, vtype_uint16 value); -extern bool libcdsb_dict_update_cstring_uint32 (vtype_dict* x, const char* key, vtype_uint32 value); -extern bool libcdsb_dict_update_cstring_uint64 (vtype_dict* x, const char* key, vtype_uint64 value); -extern bool libcdsb_dict_update_cstring_float (vtype_dict* x, const char* key, vtype_float value); -extern bool libcdsb_dict_update_cstring_double (vtype_dict* x, const char* key, vtype_double value); -extern bool libcdsb_dict_update_cstring_ldouble(vtype_dict* x, const char* key, vtype_ldouble value); +extern bool libcdsb_dict_update_dict_pointer(vtype_dict* x, const vtype_dict* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_cstring(vtype_dict* x, const vtype_dict* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_string (vtype_dict* x, const vtype_dict* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_array (vtype_dict* x, const vtype_dict* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_list (vtype_dict* x, const vtype_dict* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_map (vtype_dict* x, const vtype_dict* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_vset (vtype_dict* x, const vtype_dict* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_dict (vtype_dict* x, const vtype_dict* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_dict_update_dict_boolean(vtype_dict* x, const vtype_dict* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_int8 (vtype_dict* x, const vtype_dict* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_int16 (vtype_dict* x, const vtype_dict* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_int32 (vtype_dict* x, const vtype_dict* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_int64 (vtype_dict* x, const vtype_dict* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_uint8 (vtype_dict* x, const vtype_dict* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_uint16 (vtype_dict* x, const vtype_dict* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_uint32 (vtype_dict* x, const vtype_dict* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_uint64 (vtype_dict* x, const vtype_dict* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_float (vtype_dict* x, const vtype_dict* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_double (vtype_dict* x, const vtype_dict* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_dict_update_dict_ldouble(vtype_dict* x, const vtype_dict* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_dict_update_boolean_pointer(vtype_dict* x, vtype_bool key, const void* value); -extern bool libcdsb_dict_update_boolean_cstring(vtype_dict* x, vtype_bool key, const char* value); -extern bool libcdsb_dict_update_boolean_string (vtype_dict* x, vtype_bool key, const vtype_string* value); -extern bool libcdsb_dict_update_boolean_array (vtype_dict* x, vtype_bool key, const vtype_array* value); -extern bool libcdsb_dict_update_boolean_list (vtype_dict* x, vtype_bool key, const vtype_list* value); -extern bool libcdsb_dict_update_boolean_map (vtype_dict* x, vtype_bool key, const vtype_map* value); -extern bool libcdsb_dict_update_boolean_vset (vtype_dict* x, vtype_bool key, const vtype_set* value); -extern bool libcdsb_dict_update_boolean_dict (vtype_dict* x, vtype_bool key, const vtype_dict* value); -extern bool libcdsb_dict_update_boolean_boolean(vtype_dict* x, vtype_bool key, vtype_bool value); -extern bool libcdsb_dict_update_boolean_int8 (vtype_dict* x, vtype_bool key, vtype_int8 value); -extern bool libcdsb_dict_update_boolean_int16 (vtype_dict* x, vtype_bool key, vtype_int16 value); -extern bool libcdsb_dict_update_boolean_int32 (vtype_dict* x, vtype_bool key, vtype_int32 value); -extern bool libcdsb_dict_update_boolean_int64 (vtype_dict* x, vtype_bool key, vtype_int64 value); -extern bool libcdsb_dict_update_boolean_uint8 (vtype_dict* x, vtype_bool key, vtype_uint8 value); -extern bool libcdsb_dict_update_boolean_uint16 (vtype_dict* x, vtype_bool key, vtype_uint16 value); -extern bool libcdsb_dict_update_boolean_uint32 (vtype_dict* x, vtype_bool key, vtype_uint32 value); -extern bool libcdsb_dict_update_boolean_uint64 (vtype_dict* x, vtype_bool key, vtype_uint64 value); -extern bool libcdsb_dict_update_boolean_float (vtype_dict* x, vtype_bool key, vtype_float value); -extern bool libcdsb_dict_update_boolean_double (vtype_dict* x, vtype_bool key, vtype_double value); -extern bool libcdsb_dict_update_boolean_ldouble(vtype_dict* x, vtype_bool key, vtype_ldouble value); +extern bool libcdsb_dict_update_boolean_pointer(vtype_dict* x, vtype_bool key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_cstring(vtype_dict* x, vtype_bool key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_string (vtype_dict* x, vtype_bool key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_array (vtype_dict* x, vtype_bool key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_list (vtype_dict* x, vtype_bool key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_map (vtype_dict* x, vtype_bool key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_vset (vtype_dict* x, vtype_bool key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_dict (vtype_dict* x, vtype_bool key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_boolean_boolean(vtype_dict* x, vtype_bool key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_int8 (vtype_dict* x, vtype_bool key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_int16 (vtype_dict* x, vtype_bool key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_int32 (vtype_dict* x, vtype_bool key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_int64 (vtype_dict* x, vtype_bool key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_uint8 (vtype_dict* x, vtype_bool key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_uint16 (vtype_dict* x, vtype_bool key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_uint32 (vtype_dict* x, vtype_bool key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_uint64 (vtype_dict* x, vtype_bool key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_float (vtype_dict* x, vtype_bool key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_double (vtype_dict* x, vtype_bool key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_boolean_ldouble(vtype_dict* x, vtype_bool key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_pointer(vtype_dict* x, vtype_uint8 key, const void* value); -extern bool libcdsb_dict_update_uint8_cstring(vtype_dict* x, vtype_uint8 key, const char* value); -extern bool libcdsb_dict_update_uint8_string (vtype_dict* x, vtype_uint8 key, const vtype_string* value); -extern bool libcdsb_dict_update_uint8_array (vtype_dict* x, vtype_uint8 key, const vtype_array* value); -extern bool libcdsb_dict_update_uint8_list (vtype_dict* x, vtype_uint8 key, const vtype_list* value); -extern bool libcdsb_dict_update_uint8_map (vtype_dict* x, vtype_uint8 key, const vtype_map* value); -extern bool libcdsb_dict_update_uint8_vset (vtype_dict* x, vtype_uint8 key, const vtype_set* value); -extern bool libcdsb_dict_update_uint8_dict (vtype_dict* x, vtype_uint8 key, const vtype_dict* value); -extern bool libcdsb_dict_update_uint8_boolean(vtype_dict* x, vtype_uint8 key, vtype_bool value); -extern bool libcdsb_dict_update_uint8_int8 (vtype_dict* x, vtype_uint8 key, vtype_int8 value); -extern bool libcdsb_dict_update_uint8_int16 (vtype_dict* x, vtype_uint8 key, vtype_int16 value); -extern bool libcdsb_dict_update_uint8_int32 (vtype_dict* x, vtype_uint8 key, vtype_int32 value); -extern bool libcdsb_dict_update_uint8_int64 (vtype_dict* x, vtype_uint8 key, vtype_int64 value); -extern bool libcdsb_dict_update_uint8_uint8 (vtype_dict* x, vtype_uint8 key, vtype_uint8 value); -extern bool libcdsb_dict_update_uint8_uint16 (vtype_dict* x, vtype_uint8 key, vtype_uint16 value); -extern bool libcdsb_dict_update_uint8_uint32 (vtype_dict* x, vtype_uint8 key, vtype_uint32 value); -extern bool libcdsb_dict_update_uint8_uint64 (vtype_dict* x, vtype_uint8 key, vtype_uint64 value); -extern bool libcdsb_dict_update_uint8_float (vtype_dict* x, vtype_uint8 key, vtype_float value); -extern bool libcdsb_dict_update_uint8_double (vtype_dict* x, vtype_uint8 key, vtype_double value); -extern bool libcdsb_dict_update_uint8_ldouble(vtype_dict* x, vtype_uint8 key, vtype_ldouble value); +extern bool libcdsb_dict_update_uint8_pointer(vtype_dict* x, vtype_uint8 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_cstring(vtype_dict* x, vtype_uint8 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_string (vtype_dict* x, vtype_uint8 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_array (vtype_dict* x, vtype_uint8 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_list (vtype_dict* x, vtype_uint8 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_map (vtype_dict* x, vtype_uint8 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_vset (vtype_dict* x, vtype_uint8 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_dict (vtype_dict* x, vtype_uint8 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint8_boolean(vtype_dict* x, vtype_uint8 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_int8 (vtype_dict* x, vtype_uint8 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_int16 (vtype_dict* x, vtype_uint8 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_int32 (vtype_dict* x, vtype_uint8 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_int64 (vtype_dict* x, vtype_uint8 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_uint8 (vtype_dict* x, vtype_uint8 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_uint16 (vtype_dict* x, vtype_uint8 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_uint32 (vtype_dict* x, vtype_uint8 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_uint64 (vtype_dict* x, vtype_uint8 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_float (vtype_dict* x, vtype_uint8 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_double (vtype_dict* x, vtype_uint8 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_uint8_ldouble(vtype_dict* x, vtype_uint8 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_pointer(vtype_dict* x, vtype_uint16 key, const void* value); -extern bool libcdsb_dict_update_uint16_cstring(vtype_dict* x, vtype_uint16 key, const char* value); -extern bool libcdsb_dict_update_uint16_string (vtype_dict* x, vtype_uint16 key, const vtype_string* value); -extern bool libcdsb_dict_update_uint16_array (vtype_dict* x, vtype_uint16 key, const vtype_array* value); -extern bool libcdsb_dict_update_uint16_list (vtype_dict* x, vtype_uint16 key, const vtype_list* value); -extern bool libcdsb_dict_update_uint16_map (vtype_dict* x, vtype_uint16 key, const vtype_map* value); -extern bool libcdsb_dict_update_uint16_vset (vtype_dict* x, vtype_uint16 key, const vtype_set* value); -extern bool libcdsb_dict_update_uint16_dict (vtype_dict* x, vtype_uint16 key, const vtype_dict* value); -extern bool libcdsb_dict_update_uint16_boolean(vtype_dict* x, vtype_uint16 key, vtype_bool value); -extern bool libcdsb_dict_update_uint16_int8 (vtype_dict* x, vtype_uint16 key, vtype_int8 value); -extern bool libcdsb_dict_update_uint16_int16 (vtype_dict* x, vtype_uint16 key, vtype_int16 value); -extern bool libcdsb_dict_update_uint16_int32 (vtype_dict* x, vtype_uint16 key, vtype_int32 value); -extern bool libcdsb_dict_update_uint16_int64 (vtype_dict* x, vtype_uint16 key, vtype_int64 value); -extern bool libcdsb_dict_update_uint16_uint8 (vtype_dict* x, vtype_uint16 key, vtype_uint8 value); -extern bool libcdsb_dict_update_uint16_uint16 (vtype_dict* x, vtype_uint16 key, vtype_uint16 value); -extern bool libcdsb_dict_update_uint16_uint32 (vtype_dict* x, vtype_uint16 key, vtype_uint32 value); -extern bool libcdsb_dict_update_uint16_uint64 (vtype_dict* x, vtype_uint16 key, vtype_uint64 value); -extern bool libcdsb_dict_update_uint16_float (vtype_dict* x, vtype_uint16 key, vtype_float value); -extern bool libcdsb_dict_update_uint16_double (vtype_dict* x, vtype_uint16 key, vtype_double value); -extern bool libcdsb_dict_update_uint16_ldouble(vtype_dict* x, vtype_uint16 key, vtype_ldouble value); +extern bool libcdsb_dict_update_uint16_pointer(vtype_dict* x, vtype_uint16 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_cstring(vtype_dict* x, vtype_uint16 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_string (vtype_dict* x, vtype_uint16 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_array (vtype_dict* x, vtype_uint16 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_list (vtype_dict* x, vtype_uint16 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_map (vtype_dict* x, vtype_uint16 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_vset (vtype_dict* x, vtype_uint16 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_dict (vtype_dict* x, vtype_uint16 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint16_boolean(vtype_dict* x, vtype_uint16 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_int8 (vtype_dict* x, vtype_uint16 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_int16 (vtype_dict* x, vtype_uint16 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_int32 (vtype_dict* x, vtype_uint16 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_int64 (vtype_dict* x, vtype_uint16 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_uint8 (vtype_dict* x, vtype_uint16 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_uint16 (vtype_dict* x, vtype_uint16 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_uint32 (vtype_dict* x, vtype_uint16 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_uint64 (vtype_dict* x, vtype_uint16 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_float (vtype_dict* x, vtype_uint16 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_double (vtype_dict* x, vtype_uint16 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_uint16_ldouble(vtype_dict* x, vtype_uint16 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_pointer(vtype_dict* x, vtype_uint32 key, const void* value); -extern bool libcdsb_dict_update_uint32_cstring(vtype_dict* x, vtype_uint32 key, const char* value); -extern bool libcdsb_dict_update_uint32_string (vtype_dict* x, vtype_uint32 key, const vtype_string* value); -extern bool libcdsb_dict_update_uint32_array (vtype_dict* x, vtype_uint32 key, const vtype_array* value); -extern bool libcdsb_dict_update_uint32_list (vtype_dict* x, vtype_uint32 key, const vtype_list* value); -extern bool libcdsb_dict_update_uint32_map (vtype_dict* x, vtype_uint32 key, const vtype_map* value); -extern bool libcdsb_dict_update_uint32_vset (vtype_dict* x, vtype_uint32 key, const vtype_set* value); -extern bool libcdsb_dict_update_uint32_dict (vtype_dict* x, vtype_uint32 key, const vtype_dict* value); -extern bool libcdsb_dict_update_uint32_boolean(vtype_dict* x, vtype_uint32 key, vtype_bool value); -extern bool libcdsb_dict_update_uint32_int8 (vtype_dict* x, vtype_uint32 key, vtype_int8 value); -extern bool libcdsb_dict_update_uint32_int16 (vtype_dict* x, vtype_uint32 key, vtype_int16 value); -extern bool libcdsb_dict_update_uint32_int32 (vtype_dict* x, vtype_uint32 key, vtype_int32 value); -extern bool libcdsb_dict_update_uint32_int64 (vtype_dict* x, vtype_uint32 key, vtype_int64 value); -extern bool libcdsb_dict_update_uint32_uint8 (vtype_dict* x, vtype_uint32 key, vtype_uint8 value); -extern bool libcdsb_dict_update_uint32_uint16 (vtype_dict* x, vtype_uint32 key, vtype_uint16 value); -extern bool libcdsb_dict_update_uint32_uint32 (vtype_dict* x, vtype_uint32 key, vtype_uint32 value); -extern bool libcdsb_dict_update_uint32_uint64 (vtype_dict* x, vtype_uint32 key, vtype_uint64 value); -extern bool libcdsb_dict_update_uint32_float (vtype_dict* x, vtype_uint32 key, vtype_float value); -extern bool libcdsb_dict_update_uint32_double (vtype_dict* x, vtype_uint32 key, vtype_double value); -extern bool libcdsb_dict_update_uint32_ldouble(vtype_dict* x, vtype_uint32 key, vtype_ldouble value); +extern bool libcdsb_dict_update_uint32_pointer(vtype_dict* x, vtype_uint32 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_cstring(vtype_dict* x, vtype_uint32 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_string (vtype_dict* x, vtype_uint32 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_array (vtype_dict* x, vtype_uint32 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_list (vtype_dict* x, vtype_uint32 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_map (vtype_dict* x, vtype_uint32 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_vset (vtype_dict* x, vtype_uint32 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_dict (vtype_dict* x, vtype_uint32 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint32_boolean(vtype_dict* x, vtype_uint32 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_int8 (vtype_dict* x, vtype_uint32 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_int16 (vtype_dict* x, vtype_uint32 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_int32 (vtype_dict* x, vtype_uint32 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_int64 (vtype_dict* x, vtype_uint32 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_uint8 (vtype_dict* x, vtype_uint32 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_uint16 (vtype_dict* x, vtype_uint32 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_uint32 (vtype_dict* x, vtype_uint32 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_uint64 (vtype_dict* x, vtype_uint32 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_float (vtype_dict* x, vtype_uint32 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_double (vtype_dict* x, vtype_uint32 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_uint32_ldouble(vtype_dict* x, vtype_uint32 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_pointer(vtype_dict* x, vtype_uint64 key, const void* value); -extern bool libcdsb_dict_update_uint64_cstring(vtype_dict* x, vtype_uint64 key, const char* value); -extern bool libcdsb_dict_update_uint64_string (vtype_dict* x, vtype_uint64 key, const vtype_string* value); -extern bool libcdsb_dict_update_uint64_array (vtype_dict* x, vtype_uint64 key, const vtype_array* value); -extern bool libcdsb_dict_update_uint64_list (vtype_dict* x, vtype_uint64 key, const vtype_list* value); -extern bool libcdsb_dict_update_uint64_map (vtype_dict* x, vtype_uint64 key, const vtype_map* value); -extern bool libcdsb_dict_update_uint64_vset (vtype_dict* x, vtype_uint64 key, const vtype_set* value); -extern bool libcdsb_dict_update_uint64_dict (vtype_dict* x, vtype_uint64 key, const vtype_dict* value); -extern bool libcdsb_dict_update_uint64_boolean(vtype_dict* x, vtype_uint64 key, vtype_bool value); -extern bool libcdsb_dict_update_uint64_int8 (vtype_dict* x, vtype_uint64 key, vtype_int8 value); -extern bool libcdsb_dict_update_uint64_int16 (vtype_dict* x, vtype_uint64 key, vtype_int16 value); -extern bool libcdsb_dict_update_uint64_int32 (vtype_dict* x, vtype_uint64 key, vtype_int32 value); -extern bool libcdsb_dict_update_uint64_int64 (vtype_dict* x, vtype_uint64 key, vtype_int64 value); -extern bool libcdsb_dict_update_uint64_uint8 (vtype_dict* x, vtype_uint64 key, vtype_uint8 value); -extern bool libcdsb_dict_update_uint64_uint16 (vtype_dict* x, vtype_uint64 key, vtype_uint16 value); -extern bool libcdsb_dict_update_uint64_uint32 (vtype_dict* x, vtype_uint64 key, vtype_uint32 value); -extern bool libcdsb_dict_update_uint64_uint64 (vtype_dict* x, vtype_uint64 key, vtype_uint64 value); -extern bool libcdsb_dict_update_uint64_float (vtype_dict* x, vtype_uint64 key, vtype_float value); -extern bool libcdsb_dict_update_uint64_double (vtype_dict* x, vtype_uint64 key, vtype_double value); -extern bool libcdsb_dict_update_uint64_ldouble(vtype_dict* x, vtype_uint64 key, vtype_ldouble value); +extern bool libcdsb_dict_update_uint64_pointer(vtype_dict* x, vtype_uint64 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_cstring(vtype_dict* x, vtype_uint64 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_string (vtype_dict* x, vtype_uint64 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_array (vtype_dict* x, vtype_uint64 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_list (vtype_dict* x, vtype_uint64 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_map (vtype_dict* x, vtype_uint64 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_vset (vtype_dict* x, vtype_uint64 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_dict (vtype_dict* x, vtype_uint64 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_uint64_boolean(vtype_dict* x, vtype_uint64 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_int8 (vtype_dict* x, vtype_uint64 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_int16 (vtype_dict* x, vtype_uint64 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_int32 (vtype_dict* x, vtype_uint64 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_int64 (vtype_dict* x, vtype_uint64 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_uint8 (vtype_dict* x, vtype_uint64 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_uint16 (vtype_dict* x, vtype_uint64 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_uint32 (vtype_dict* x, vtype_uint64 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_uint64 (vtype_dict* x, vtype_uint64 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_float (vtype_dict* x, vtype_uint64 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_double (vtype_dict* x, vtype_uint64 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_uint64_ldouble(vtype_dict* x, vtype_uint64 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_pointer(vtype_dict* x, vtype_int8 key, const void* value); -extern bool libcdsb_dict_update_int8_cstring(vtype_dict* x, vtype_int8 key, const char* value); -extern bool libcdsb_dict_update_int8_string (vtype_dict* x, vtype_int8 key, const vtype_string* value); -extern bool libcdsb_dict_update_int8_array (vtype_dict* x, vtype_int8 key, const vtype_array* value); -extern bool libcdsb_dict_update_int8_list (vtype_dict* x, vtype_int8 key, const vtype_list* value); -extern bool libcdsb_dict_update_int8_map (vtype_dict* x, vtype_int8 key, const vtype_map* value); -extern bool libcdsb_dict_update_int8_vset (vtype_dict* x, vtype_int8 key, const vtype_set* value); -extern bool libcdsb_dict_update_int8_dict (vtype_dict* x, vtype_int8 key, const vtype_dict* value); -extern bool libcdsb_dict_update_int8_boolean(vtype_dict* x, vtype_int8 key, vtype_bool value); -extern bool libcdsb_dict_update_int8_int8 (vtype_dict* x, vtype_int8 key, vtype_int8 value); -extern bool libcdsb_dict_update_int8_int16 (vtype_dict* x, vtype_int8 key, vtype_int16 value); -extern bool libcdsb_dict_update_int8_int32 (vtype_dict* x, vtype_int8 key, vtype_int32 value); -extern bool libcdsb_dict_update_int8_int64 (vtype_dict* x, vtype_int8 key, vtype_int64 value); -extern bool libcdsb_dict_update_int8_uint8 (vtype_dict* x, vtype_int8 key, vtype_uint8 value); -extern bool libcdsb_dict_update_int8_uint16 (vtype_dict* x, vtype_int8 key, vtype_uint16 value); -extern bool libcdsb_dict_update_int8_uint32 (vtype_dict* x, vtype_int8 key, vtype_uint32 value); -extern bool libcdsb_dict_update_int8_uint64 (vtype_dict* x, vtype_int8 key, vtype_uint64 value); -extern bool libcdsb_dict_update_int8_float (vtype_dict* x, vtype_int8 key, vtype_float value); -extern bool libcdsb_dict_update_int8_double (vtype_dict* x, vtype_int8 key, vtype_double value); -extern bool libcdsb_dict_update_int8_ldouble(vtype_dict* x, vtype_int8 key, vtype_ldouble value); +extern bool libcdsb_dict_update_int8_pointer(vtype_dict* x, vtype_int8 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_cstring(vtype_dict* x, vtype_int8 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_string (vtype_dict* x, vtype_int8 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_array (vtype_dict* x, vtype_int8 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_list (vtype_dict* x, vtype_int8 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_map (vtype_dict* x, vtype_int8 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_vset (vtype_dict* x, vtype_int8 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_dict (vtype_dict* x, vtype_int8 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int8_boolean(vtype_dict* x, vtype_int8 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_int8 (vtype_dict* x, vtype_int8 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_int16 (vtype_dict* x, vtype_int8 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_int32 (vtype_dict* x, vtype_int8 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_int64 (vtype_dict* x, vtype_int8 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_uint8 (vtype_dict* x, vtype_int8 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_uint16 (vtype_dict* x, vtype_int8 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_uint32 (vtype_dict* x, vtype_int8 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_uint64 (vtype_dict* x, vtype_int8 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_float (vtype_dict* x, vtype_int8 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_double (vtype_dict* x, vtype_int8 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_int8_ldouble(vtype_dict* x, vtype_int8 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_pointer(vtype_dict* x, vtype_int16 key, const void* value); -extern bool libcdsb_dict_update_int16_cstring(vtype_dict* x, vtype_int16 key, const char* value); -extern bool libcdsb_dict_update_int16_string (vtype_dict* x, vtype_int16 key, const vtype_string* value); -extern bool libcdsb_dict_update_int16_array (vtype_dict* x, vtype_int16 key, const vtype_array* value); -extern bool libcdsb_dict_update_int16_list (vtype_dict* x, vtype_int16 key, const vtype_list* value); -extern bool libcdsb_dict_update_int16_map (vtype_dict* x, vtype_int16 key, const vtype_map* value); -extern bool libcdsb_dict_update_int16_vset (vtype_dict* x, vtype_int16 key, const vtype_set* value); -extern bool libcdsb_dict_update_int16_dict (vtype_dict* x, vtype_int16 key, const vtype_dict* value); -extern bool libcdsb_dict_update_int16_boolean(vtype_dict* x, vtype_int16 key, vtype_bool value); -extern bool libcdsb_dict_update_int16_int8 (vtype_dict* x, vtype_int16 key, vtype_int8 value); -extern bool libcdsb_dict_update_int16_int16 (vtype_dict* x, vtype_int16 key, vtype_int16 value); -extern bool libcdsb_dict_update_int16_int32 (vtype_dict* x, vtype_int16 key, vtype_int32 value); -extern bool libcdsb_dict_update_int16_int64 (vtype_dict* x, vtype_int16 key, vtype_int64 value); -extern bool libcdsb_dict_update_int16_uint8 (vtype_dict* x, vtype_int16 key, vtype_uint8 value); -extern bool libcdsb_dict_update_int16_uint16 (vtype_dict* x, vtype_int16 key, vtype_uint16 value); -extern bool libcdsb_dict_update_int16_uint32 (vtype_dict* x, vtype_int16 key, vtype_uint32 value); -extern bool libcdsb_dict_update_int16_uint64 (vtype_dict* x, vtype_int16 key, vtype_uint64 value); -extern bool libcdsb_dict_update_int16_float (vtype_dict* x, vtype_int16 key, vtype_float value); -extern bool libcdsb_dict_update_int16_double (vtype_dict* x, vtype_int16 key, vtype_double value); -extern bool libcdsb_dict_update_int16_ldouble(vtype_dict* x, vtype_int16 key, vtype_ldouble value); +extern bool libcdsb_dict_update_int16_pointer(vtype_dict* x, vtype_int16 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_cstring(vtype_dict* x, vtype_int16 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_string (vtype_dict* x, vtype_int16 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_array (vtype_dict* x, vtype_int16 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_list (vtype_dict* x, vtype_int16 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_map (vtype_dict* x, vtype_int16 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_vset (vtype_dict* x, vtype_int16 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_dict (vtype_dict* x, vtype_int16 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int16_boolean(vtype_dict* x, vtype_int16 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_int8 (vtype_dict* x, vtype_int16 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_int16 (vtype_dict* x, vtype_int16 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_int32 (vtype_dict* x, vtype_int16 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_int64 (vtype_dict* x, vtype_int16 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_uint8 (vtype_dict* x, vtype_int16 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_uint16 (vtype_dict* x, vtype_int16 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_uint32 (vtype_dict* x, vtype_int16 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_uint64 (vtype_dict* x, vtype_int16 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_float (vtype_dict* x, vtype_int16 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_double (vtype_dict* x, vtype_int16 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_int16_ldouble(vtype_dict* x, vtype_int16 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_pointer(vtype_dict* x, vtype_int32 key, const void* value); -extern bool libcdsb_dict_update_int32_cstring(vtype_dict* x, vtype_int32 key, const char* value); -extern bool libcdsb_dict_update_int32_string (vtype_dict* x, vtype_int32 key, const vtype_string* value); -extern bool libcdsb_dict_update_int32_array (vtype_dict* x, vtype_int32 key, const vtype_array* value); -extern bool libcdsb_dict_update_int32_list (vtype_dict* x, vtype_int32 key, const vtype_list* value); -extern bool libcdsb_dict_update_int32_map (vtype_dict* x, vtype_int32 key, const vtype_map* value); -extern bool libcdsb_dict_update_int32_vset (vtype_dict* x, vtype_int32 key, const vtype_set* value); -extern bool libcdsb_dict_update_int32_dict (vtype_dict* x, vtype_int32 key, const vtype_dict* value); -extern bool libcdsb_dict_update_int32_boolean(vtype_dict* x, vtype_int32 key, vtype_bool value); -extern bool libcdsb_dict_update_int32_int8 (vtype_dict* x, vtype_int32 key, vtype_int8 value); -extern bool libcdsb_dict_update_int32_int16 (vtype_dict* x, vtype_int32 key, vtype_int16 value); -extern bool libcdsb_dict_update_int32_int32 (vtype_dict* x, vtype_int32 key, vtype_int32 value); -extern bool libcdsb_dict_update_int32_int64 (vtype_dict* x, vtype_int32 key, vtype_int64 value); -extern bool libcdsb_dict_update_int32_uint8 (vtype_dict* x, vtype_int32 key, vtype_uint8 value); -extern bool libcdsb_dict_update_int32_uint16 (vtype_dict* x, vtype_int32 key, vtype_uint16 value); -extern bool libcdsb_dict_update_int32_uint32 (vtype_dict* x, vtype_int32 key, vtype_uint32 value); -extern bool libcdsb_dict_update_int32_uint64 (vtype_dict* x, vtype_int32 key, vtype_uint64 value); -extern bool libcdsb_dict_update_int32_float (vtype_dict* x, vtype_int32 key, vtype_float value); -extern bool libcdsb_dict_update_int32_double (vtype_dict* x, vtype_int32 key, vtype_double value); -extern bool libcdsb_dict_update_int32_ldouble(vtype_dict* x, vtype_int32 key, vtype_ldouble value); +extern bool libcdsb_dict_update_int32_pointer(vtype_dict* x, vtype_int32 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_cstring(vtype_dict* x, vtype_int32 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_string (vtype_dict* x, vtype_int32 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_array (vtype_dict* x, vtype_int32 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_list (vtype_dict* x, vtype_int32 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_map (vtype_dict* x, vtype_int32 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_vset (vtype_dict* x, vtype_int32 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_dict (vtype_dict* x, vtype_int32 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int32_boolean(vtype_dict* x, vtype_int32 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_int8 (vtype_dict* x, vtype_int32 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_int16 (vtype_dict* x, vtype_int32 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_int32 (vtype_dict* x, vtype_int32 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_int64 (vtype_dict* x, vtype_int32 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_uint8 (vtype_dict* x, vtype_int32 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_uint16 (vtype_dict* x, vtype_int32 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_uint32 (vtype_dict* x, vtype_int32 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_uint64 (vtype_dict* x, vtype_int32 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_float (vtype_dict* x, vtype_int32 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_double (vtype_dict* x, vtype_int32 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_int32_ldouble(vtype_dict* x, vtype_int32 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_pointer(vtype_dict* x, vtype_int64 key, const void* value); -extern bool libcdsb_dict_update_int64_cstring(vtype_dict* x, vtype_int64 key, const char* value); -extern bool libcdsb_dict_update_int64_string (vtype_dict* x, vtype_int64 key, const vtype_string* value); -extern bool libcdsb_dict_update_int64_array (vtype_dict* x, vtype_int64 key, const vtype_array* value); -extern bool libcdsb_dict_update_int64_list (vtype_dict* x, vtype_int64 key, const vtype_list* value); -extern bool libcdsb_dict_update_int64_map (vtype_dict* x, vtype_int64 key, const vtype_map* value); -extern bool libcdsb_dict_update_int64_vset (vtype_dict* x, vtype_int64 key, const vtype_set* value); -extern bool libcdsb_dict_update_int64_dict (vtype_dict* x, vtype_int64 key, const vtype_dict* value); -extern bool libcdsb_dict_update_int64_boolean(vtype_dict* x, vtype_int64 key, vtype_bool value); -extern bool libcdsb_dict_update_int64_int8 (vtype_dict* x, vtype_int64 key, vtype_int8 value); -extern bool libcdsb_dict_update_int64_int16 (vtype_dict* x, vtype_int64 key, vtype_int16 value); -extern bool libcdsb_dict_update_int64_int32 (vtype_dict* x, vtype_int64 key, vtype_int32 value); -extern bool libcdsb_dict_update_int64_int64 (vtype_dict* x, vtype_int64 key, vtype_int64 value); -extern bool libcdsb_dict_update_int64_uint8 (vtype_dict* x, vtype_int64 key, vtype_uint8 value); -extern bool libcdsb_dict_update_int64_uint16 (vtype_dict* x, vtype_int64 key, vtype_uint16 value); -extern bool libcdsb_dict_update_int64_uint32 (vtype_dict* x, vtype_int64 key, vtype_uint32 value); -extern bool libcdsb_dict_update_int64_uint64 (vtype_dict* x, vtype_int64 key, vtype_uint64 value); -extern bool libcdsb_dict_update_int64_float (vtype_dict* x, vtype_int64 key, vtype_float value); -extern bool libcdsb_dict_update_int64_double (vtype_dict* x, vtype_int64 key, vtype_double value); -extern bool libcdsb_dict_update_int64_ldouble(vtype_dict* x, vtype_int64 key, vtype_ldouble value); +extern bool libcdsb_dict_update_int64_pointer(vtype_dict* x, vtype_int64 key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_cstring(vtype_dict* x, vtype_int64 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_string (vtype_dict* x, vtype_int64 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_array (vtype_dict* x, vtype_int64 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_list (vtype_dict* x, vtype_int64 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_map (vtype_dict* x, vtype_int64 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_vset (vtype_dict* x, vtype_int64 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_dict (vtype_dict* x, vtype_int64 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_int64_boolean(vtype_dict* x, vtype_int64 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_int8 (vtype_dict* x, vtype_int64 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_int16 (vtype_dict* x, vtype_int64 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_int32 (vtype_dict* x, vtype_int64 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_int64 (vtype_dict* x, vtype_int64 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_uint8 (vtype_dict* x, vtype_int64 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_uint16 (vtype_dict* x, vtype_int64 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_uint32 (vtype_dict* x, vtype_int64 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_uint64 (vtype_dict* x, vtype_int64 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_float (vtype_dict* x, vtype_int64 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_double (vtype_dict* x, vtype_int64 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_int64_ldouble(vtype_dict* x, vtype_int64 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_float_pointer(vtype_dict* x, vtype_float key, const void* value); -extern bool libcdsb_dict_update_float_cstring(vtype_dict* x, vtype_float key, const char* value); -extern bool libcdsb_dict_update_float_string (vtype_dict* x, vtype_float key, const vtype_string* value); -extern bool libcdsb_dict_update_float_array (vtype_dict* x, vtype_float key, const vtype_array* value); -extern bool libcdsb_dict_update_float_list (vtype_dict* x, vtype_float key, const vtype_list* value); -extern bool libcdsb_dict_update_float_map (vtype_dict* x, vtype_float key, const vtype_map* value); -extern bool libcdsb_dict_update_float_vset (vtype_dict* x, vtype_float key, const vtype_set* value); -extern bool libcdsb_dict_update_float_dict (vtype_dict* x, vtype_float key, const vtype_dict* value); -extern bool libcdsb_dict_update_float_boolean(vtype_dict* x, vtype_float key, vtype_bool value); -extern bool libcdsb_dict_update_float_int8 (vtype_dict* x, vtype_float key, vtype_int8 value); -extern bool libcdsb_dict_update_float_int16 (vtype_dict* x, vtype_float key, vtype_int16 value); -extern bool libcdsb_dict_update_float_int32 (vtype_dict* x, vtype_float key, vtype_int32 value); -extern bool libcdsb_dict_update_float_int64 (vtype_dict* x, vtype_float key, vtype_int64 value); -extern bool libcdsb_dict_update_float_uint8 (vtype_dict* x, vtype_float key, vtype_uint8 value); -extern bool libcdsb_dict_update_float_uint16 (vtype_dict* x, vtype_float key, vtype_uint16 value); -extern bool libcdsb_dict_update_float_uint32 (vtype_dict* x, vtype_float key, vtype_uint32 value); -extern bool libcdsb_dict_update_float_uint64 (vtype_dict* x, vtype_float key, vtype_uint64 value); -extern bool libcdsb_dict_update_float_float (vtype_dict* x, vtype_float key, vtype_float value); -extern bool libcdsb_dict_update_float_double (vtype_dict* x, vtype_float key, vtype_double value); -extern bool libcdsb_dict_update_float_ldouble(vtype_dict* x, vtype_float key, vtype_ldouble value); +extern bool libcdsb_dict_update_float_pointer(vtype_dict* x, vtype_float key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_float_cstring(vtype_dict* x, vtype_float key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_string (vtype_dict* x, vtype_float key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_array (vtype_dict* x, vtype_float key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_list (vtype_dict* x, vtype_float key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_map (vtype_dict* x, vtype_float key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_vset (vtype_dict* x, vtype_float key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_dict (vtype_dict* x, vtype_float key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_float_boolean(vtype_dict* x, vtype_float key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_float_int8 (vtype_dict* x, vtype_float key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_int16 (vtype_dict* x, vtype_float key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_int32 (vtype_dict* x, vtype_float key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_int64 (vtype_dict* x, vtype_float key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_uint8 (vtype_dict* x, vtype_float key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_uint16 (vtype_dict* x, vtype_float key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_uint32 (vtype_dict* x, vtype_float key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_uint64 (vtype_dict* x, vtype_float key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_float_float (vtype_dict* x, vtype_float key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_float_double (vtype_dict* x, vtype_float key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_float_ldouble(vtype_dict* x, vtype_float key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_double_pointer(vtype_dict* x, vtype_double key, const void* value); -extern bool libcdsb_dict_update_double_cstring(vtype_dict* x, vtype_double key, const char* value); -extern bool libcdsb_dict_update_double_string (vtype_dict* x, vtype_double key, const vtype_string* value); -extern bool libcdsb_dict_update_double_array (vtype_dict* x, vtype_double key, const vtype_array* value); -extern bool libcdsb_dict_update_double_list (vtype_dict* x, vtype_double key, const vtype_list* value); -extern bool libcdsb_dict_update_double_map (vtype_dict* x, vtype_double key, const vtype_map* value); -extern bool libcdsb_dict_update_double_vset (vtype_dict* x, vtype_double key, const vtype_set* value); -extern bool libcdsb_dict_update_double_dict (vtype_dict* x, vtype_double key, const vtype_dict* value); -extern bool libcdsb_dict_update_double_boolean(vtype_dict* x, vtype_double key, vtype_bool value); -extern bool libcdsb_dict_update_double_int8 (vtype_dict* x, vtype_double key, vtype_int8 value); -extern bool libcdsb_dict_update_double_int16 (vtype_dict* x, vtype_double key, vtype_int16 value); -extern bool libcdsb_dict_update_double_int32 (vtype_dict* x, vtype_double key, vtype_int32 value); -extern bool libcdsb_dict_update_double_int64 (vtype_dict* x, vtype_double key, vtype_int64 value); -extern bool libcdsb_dict_update_double_uint8 (vtype_dict* x, vtype_double key, vtype_uint8 value); -extern bool libcdsb_dict_update_double_uint16 (vtype_dict* x, vtype_double key, vtype_uint16 value); -extern bool libcdsb_dict_update_double_uint32 (vtype_dict* x, vtype_double key, vtype_uint32 value); -extern bool libcdsb_dict_update_double_uint64 (vtype_dict* x, vtype_double key, vtype_uint64 value); -extern bool libcdsb_dict_update_double_float (vtype_dict* x, vtype_double key, vtype_float value); -extern bool libcdsb_dict_update_double_double (vtype_dict* x, vtype_double key, vtype_double value); -extern bool libcdsb_dict_update_double_ldouble(vtype_dict* x, vtype_double key, vtype_ldouble value); +extern bool libcdsb_dict_update_double_pointer(vtype_dict* x, vtype_double key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_double_cstring(vtype_dict* x, vtype_double key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_string (vtype_dict* x, vtype_double key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_array (vtype_dict* x, vtype_double key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_list (vtype_dict* x, vtype_double key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_map (vtype_dict* x, vtype_double key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_vset (vtype_dict* x, vtype_double key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_dict (vtype_dict* x, vtype_double key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_double_boolean(vtype_dict* x, vtype_double key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_double_int8 (vtype_dict* x, vtype_double key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_int16 (vtype_dict* x, vtype_double key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_int32 (vtype_dict* x, vtype_double key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_int64 (vtype_dict* x, vtype_double key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_uint8 (vtype_dict* x, vtype_double key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_uint16 (vtype_dict* x, vtype_double key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_uint32 (vtype_dict* x, vtype_double key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_uint64 (vtype_dict* x, vtype_double key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_double_float (vtype_dict* x, vtype_double key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_double_double (vtype_dict* x, vtype_double key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_double_ldouble(vtype_dict* x, vtype_double key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_pointer(vtype_dict* x, vtype_ldouble key, const void* value); -extern bool libcdsb_dict_update_ldouble_cstring(vtype_dict* x, vtype_ldouble key, const char* value); -extern bool libcdsb_dict_update_ldouble_string (vtype_dict* x, vtype_ldouble key, const vtype_string* value); -extern bool libcdsb_dict_update_ldouble_array (vtype_dict* x, vtype_ldouble key, const vtype_array* value); -extern bool libcdsb_dict_update_ldouble_list (vtype_dict* x, vtype_ldouble key, const vtype_list* value); -extern bool libcdsb_dict_update_ldouble_map (vtype_dict* x, vtype_ldouble key, const vtype_map* value); -extern bool libcdsb_dict_update_ldouble_vset (vtype_dict* x, vtype_ldouble key, const vtype_set* value); -extern bool libcdsb_dict_update_ldouble_dict (vtype_dict* x, vtype_ldouble key, const vtype_dict* value); -extern bool libcdsb_dict_update_ldouble_boolean(vtype_dict* x, vtype_ldouble key, vtype_bool value); -extern bool libcdsb_dict_update_ldouble_int8 (vtype_dict* x, vtype_ldouble key, vtype_int8 value); -extern bool libcdsb_dict_update_ldouble_int16 (vtype_dict* x, vtype_ldouble key, vtype_int16 value); -extern bool libcdsb_dict_update_ldouble_int32 (vtype_dict* x, vtype_ldouble key, vtype_int32 value); -extern bool libcdsb_dict_update_ldouble_int64 (vtype_dict* x, vtype_ldouble key, vtype_int64 value); -extern bool libcdsb_dict_update_ldouble_uint8 (vtype_dict* x, vtype_ldouble key, vtype_uint8 value); -extern bool libcdsb_dict_update_ldouble_uint16 (vtype_dict* x, vtype_ldouble key, vtype_uint16 value); -extern bool libcdsb_dict_update_ldouble_uint32 (vtype_dict* x, vtype_ldouble key, vtype_uint32 value); -extern bool libcdsb_dict_update_ldouble_uint64 (vtype_dict* x, vtype_ldouble key, vtype_uint64 value); -extern bool libcdsb_dict_update_ldouble_float (vtype_dict* x, vtype_ldouble key, vtype_float value); -extern bool libcdsb_dict_update_ldouble_double (vtype_dict* x, vtype_ldouble key, vtype_double value); -extern bool libcdsb_dict_update_ldouble_ldouble(vtype_dict* x, vtype_ldouble key, vtype_ldouble value); +extern bool libcdsb_dict_update_ldouble_pointer(vtype_dict* x, vtype_ldouble key, const void* value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_cstring(vtype_dict* x, vtype_ldouble key, const char* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_string (vtype_dict* x, vtype_ldouble key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_array (vtype_dict* x, vtype_ldouble key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_list (vtype_dict* x, vtype_ldouble key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_map (vtype_dict* x, vtype_ldouble key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_vset (vtype_dict* x, vtype_ldouble key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_dict (vtype_dict* x, vtype_ldouble key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_dict_update_ldouble_boolean(vtype_dict* x, vtype_ldouble key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_int8 (vtype_dict* x, vtype_ldouble key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_int16 (vtype_dict* x, vtype_ldouble key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_int32 (vtype_dict* x, vtype_ldouble key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_int64 (vtype_dict* x, vtype_ldouble key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_uint8 (vtype_dict* x, vtype_ldouble key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_uint16 (vtype_dict* x, vtype_ldouble key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_uint32 (vtype_dict* x, vtype_ldouble key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_uint64 (vtype_dict* x, vtype_ldouble key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_float (vtype_dict* x, vtype_ldouble key, vtype_float value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_double (vtype_dict* x, vtype_ldouble key, vtype_double value) Nonnull__(1); +extern bool libcdsb_dict_update_ldouble_ldouble(vtype_dict* x, vtype_ldouble key, vtype_ldouble value) Nonnull__(1); #endif /* LIBCDSB_DICT_H */ diff --git a/include/extra/array.h b/include/extra/array.h index d9d9ab8..3728d2f 100644 --- a/include/extra/array.h +++ b/include/extra/array.h @@ -12,12 +12,10 @@ #define array_foreach(x, data, callback) libcdsb_array_foreach(x, data, callback, 0) -extern ssize_t libcdsb_array_push(vtype_array* x, const void* value, vtype value_type) LIBCDSB_nt__ LIBCDSB_nn1__; - -extern size_t libcdsb_array_count(const vtype_array* s, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__; - -extern int libcdsb_array_find (vtype_array* x, const void* value, vtype type, void* data, array_access_callback, bool reverse, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_get (vtype_array* x, ssize_t index, void* data, array_access_callback, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_array_foreach(vtype_array* x, void* data, array_access_callback, bool flush) LIBCDSB_nt__ LIBCDSB_nn13__; +extern ssize_t libcdsb_array_push (vtype_array* x, const void* value, vtype value_type) Nonnull__(1); +extern size_t libcdsb_array_count (const vtype_array* s, const void* value, vtype type) Pure__ Warn_unused_result__ Nonnull__(1); +extern int libcdsb_array_find (vtype_array* x, const void* value, vtype type, void* data, array_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_array_get (vtype_array* x, ssize_t index, void* data, array_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_array_foreach(vtype_array* x, void* data, array_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_EXTRA_ARRAY_H */ diff --git a/include/extra/cstring.h b/include/extra/cstring.h index f60436b..9a4e9cb 100644 --- a/include/extra/cstring.h +++ b/include/extra/cstring.h @@ -7,12 +7,12 @@ #ifndef LIBCDSB_EXTRA_CSTRING_H #define LIBCDSB_EXTRA_CSTRING_H -extern size_t libcdsb_strlen (const char* s) LIBCDSB_pure__ LIBCDSB_nn1__; -extern size_t libcdsb_strasciilen(const char* s) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t libcdsb_strlen (const char* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern size_t libcdsb_strasciilen(const char* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern char* libcdsb_strdup (const char* s) LIBCDSB_nt__ LIBCDSB_wur__ LIBCDSB_nn1__; -extern char* libcdsb_strndup(const char* s, size_t n) LIBCDSB_nt__ LIBCDSB_wur__ LIBCDSB_nn1__; -extern void* libcdsb_memndup(const void* m, size_t n) LIBCDSB_nt__ LIBCDSB_wur__ LIBCDSB_nn1__; +extern char* libcdsb_strdup (const char* s) Warn_unused_result__ Nonnull__(1); +extern char* libcdsb_strndup(const char* s, size_t n) Warn_unused_result__ Nonnull__(1); +extern void* libcdsb_memndup(const void* m, size_t n) Warn_unused_result__ Nonnull__(1); #define strlen libcdsb_strlen #define strasciilen libcdsb_strasciilen diff --git a/include/extra/dict.h b/include/extra/dict.h index 9c5853c..47bc976 100644 --- a/include/extra/dict.h +++ b/include/extra/dict.h @@ -8,11 +8,9 @@ #define dict_foreach(x, data, callback) libcdsb_dict_foreach(x, data, callback, 0) -extern bool libcdsb_dict_update(vtype_dict* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__; - -extern int libcdsb_dict_get (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; -extern int libcdsb_dict_foreach(vtype_dict* x, void* data, dict_access_callback, bool flush) LIBCDSB_nt__ LIBCDSB_nn13__; - -extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) LIBCDSB_nt__ LIBCDSB_nn1__; +extern bool libcdsb_dict_update (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern int libcdsb_dict_get (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_foreach (vtype_dict* x, void* data, dict_access_callback, bool flush) Nonnull__(1,3); +extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) Nonnull__(1); #endif /* LIBCDSB_EXTRA_DICT_H */ diff --git a/include/extra/list.h b/include/extra/list.h index 89c5804..f83343d 100644 --- a/include/extra/list.h +++ b/include/extra/list.h @@ -12,12 +12,11 @@ #define list_foreach(x, data, callback) libcdsb_list_foreach(x, data, callback, 0) -extern bool libcdsb_list_update(vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction) LIBCDSB_nt__ LIBCDSB_nn1__; +extern bool libcdsb_list_update(vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction) Nonnull__(1); +extern size_t libcdsb_list_count(const vtype_list* s, const void* value, vtype type) Pure__ Warn_unused_result__ Nonnull__(1); -extern size_t libcdsb_list_count(const vtype_list* s, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__; - -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__; +extern int libcdsb_list_find (vtype_list* x, const void* value, vtype type, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_get (vtype_list* x, ssize_t index, void* data, list_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_list_foreach(vtype_list* x, void* data, list_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_EXTRA_LIST_H */ diff --git a/include/extra/map.h b/include/extra/map.h index e4ac897..a8f2f78 100644 --- a/include/extra/map.h +++ b/include/extra/map.h @@ -8,10 +8,9 @@ #define map_foreach(x, data, callback) libcdsb_map_foreach(x, data, callback, 0) -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_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__; +extern bool libcdsb_map_update (vtype_map* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern int libcdsb_map_find (vtype_map* x, const void* key, vtype key_type, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_foreach(vtype_map* x, void* data, map_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_EXTRA_MAP_H */ diff --git a/include/extra/memory.h b/include/extra/memory.h index fb3ca3a..b21b43e 100644 --- a/include/extra/memory.h +++ b/include/extra/memory.h @@ -12,15 +12,15 @@ typedef struct libcdsb_stack_node { void* value; } stack_t; -extern void libcdsb_stack_init (stack_t* stack); -extern void libcdsb_stack_push (stack_t* stack, void* value); -extern void* libcdsb_stack_pop (stack_t* stack); -extern void libcdsb_stack_flush(stack_t* stack); +extern void libcdsb_stack_init (stack_t* stack) Nonnull__(1); +extern void libcdsb_stack_push (stack_t* stack, void* value) Nonnull__(1); +extern void* libcdsb_stack_pop (stack_t* stack) Nonnull__(1); +extern void libcdsb_stack_flush(stack_t* stack) Nonnull__(1); -extern void* libcdsb_aalloc (size_t a, size_t n) LIBCDSB_nt__ LIBCDSB_wur__; -extern void* libcdsb_malloc (size_t n) LIBCDSB_nt__ LIBCDSB_wur__; -extern void* libcdsb_calloc (size_t n, size_t c) LIBCDSB_nt__ LIBCDSB_wur__; -extern void* libcdsb_realloc(void *p, size_t n) LIBCDSB_nt__ LIBCDSB_wur__; +extern void* libcdsb_aalloc (size_t a, size_t n) Warn_unused_result__; +extern void* libcdsb_malloc (size_t n) Warn_unused_result__; +extern void* libcdsb_calloc (size_t n, size_t c) Warn_unused_result__; +extern void* libcdsb_realloc(void *p, size_t n) Warn_unused_result__; #define aligned_alloc libcdsb_aalloc #define malloc libcdsb_malloc diff --git a/include/extra/set.h b/include/extra/set.h index a6d097d..0b25cdb 100644 --- a/include/extra/set.h +++ b/include/extra/set.h @@ -8,9 +8,9 @@ #define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, 0) -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_nn12__; -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__; +extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) LIBCDSB_nn13__; #endif /* LIBCDSB_EXTRA_SET_H */ diff --git a/include/extra/string.h b/include/extra/string.h index b96933c..64490ef 100644 --- a/include/extra/string.h +++ b/include/extra/string.h @@ -17,38 +17,38 @@ #define string_ltrim(x, arg) _LIBCDSB_GenericS(libcdsb_string, trim, arg)(x, arg, -1) #define string_rtrim(x, arg) _LIBCDSB_GenericS(libcdsb_string, trim, arg)(x, arg, 1) -extern size_t string_to_lower (vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t string_to_upper (vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t string_capitalize(vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t string_to_lower (vtype_string* x) Nonnull__(1); +extern size_t string_to_upper (vtype_string* x) Nonnull__(1); +extern size_t string_capitalize(vtype_string* x) Nonnull__(1); -extern size_t string_reverse (vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t string_reverse (vtype_string* x) Nonnull__(1); -extern size_t string_align_center(vtype_string* x, size_t padsize, int padchr) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t string_align_right (vtype_string* x, size_t padsize, int padchr) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t string_align_left (vtype_string* x, size_t padsize, int padchr) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t string_align_center(vtype_string* x, size_t padsize, int padchr) Nonnull__(1); +extern size_t string_align_right (vtype_string* x, size_t padsize, int padchr) Nonnull__(1); +extern size_t string_align_left (vtype_string* x, size_t padsize, int padchr) Nonnull__(1); -extern int string_compare_case_insensitive(const vtype_string* s0, const vtype_string* s1) LIBCDSB_cmpattr__; +extern int string_compare_case_insensitive(const vtype_string* s0, const vtype_string* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); -extern void libcdsb_string_replace(vtype_string* x, char* dest, size_t dest_nmemb, const char* src, size_t nmemb); +extern void libcdsb_string_replace(vtype_string* x, char* dest, size_t dest_nmemb, const char* src, size_t nmemb) Nonnull__(1,2); /*#####################################################################################################################*/ -inline vtype_array libcdsb_string_split_string (const vtype_string* x, const vtype_string* sep, size_t maxn) __attribute__((always_inline)); -extern vtype_array libcdsb_string_split_cstring(const vtype_string* string, const char* sep, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern vtype_array libcdsb_string_split_char (const vtype_string* string, int chr, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline vtype_array libcdsb_string_split_string (const vtype_string* x, const vtype_string* sep, size_t maxn) Nonnull__(1) Always_inline__; +extern vtype_array libcdsb_string_split_cstring(const vtype_string* string, const char* sep, size_t maxn) Nonnull__(1); +extern vtype_array libcdsb_string_split_char (const vtype_string* string, int chr, size_t maxn) Nonnull__(1); -inline void libcdsb_string_trim_string (vtype_string* x, const vtype_string* s, int direction) __attribute__((always_inline)); -extern void libcdsb_string_trim_cstring(vtype_string* x, const char* s, int direction) LIBCDSB_nt__ LIBCDSB_nn1__; -extern void libcdsb_string_trim_char (vtype_string* x, int sc, int direction) LIBCDSB_nt__ LIBCDSB_nn1__; +inline void libcdsb_string_trim_string (vtype_string* x, const vtype_string* s, int direction) Nonnull__(1) Always_inline__; +extern void libcdsb_string_trim_cstring(vtype_string* x, const char* s, int direction) Nonnull__(1); +extern void libcdsb_string_trim_char (vtype_string* x, int sc, int direction) Nonnull__(1); -inline size_t libcdsb_string_replace_r_string_string (vtype_string*restrict x, const vtype_string*restrict src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_r_string_cstring (vtype_string*restrict x, const vtype_string*restrict src, const char*restrict dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_r_string_char (vtype_string*restrict x, const vtype_string*restrict src, int dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_r_cstring_string (vtype_string*restrict x, const char*restrict src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_r_cstring_cstring(vtype_string*restrict x, const char*restrict src, const char*restrict dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t libcdsb_string_replace_r_cstring_char (vtype_string*restrict x, const char*restrict src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -inline size_t libcdsb_string_replace_r_char_string (vtype_string*restrict x, int src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_r_char_cstring (vtype_string*restrict x, int src, const char*restrict dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_r_string_string (vtype_string*restrict x, const vtype_string*restrict src, const vtype_string*restrict dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_r_string_cstring (vtype_string*restrict x, const vtype_string*restrict src, const char*restrict dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_r_string_char (vtype_string*restrict x, const vtype_string*restrict src, int dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_r_cstring_string (vtype_string*restrict x, const char*restrict src, const vtype_string*restrict dest, size_t maxn) Nonnull__(1) Always_inline__; +extern size_t libcdsb_string_replace_r_cstring_cstring(vtype_string*restrict x, const char*restrict src, const char*restrict dest, size_t maxn) Nonnull__(1); +extern size_t libcdsb_string_replace_r_cstring_char (vtype_string*restrict x, const char*restrict src, int dest, size_t maxn) Nonnull__(1); +inline size_t libcdsb_string_replace_r_char_string (vtype_string*restrict x, int src, const vtype_string*restrict dest, size_t maxn) Nonnull__(1) Always_inline__; +extern size_t libcdsb_string_replace_r_char_cstring (vtype_string*restrict x, int src, const char*restrict dest, size_t maxn) Nonnull__(1); #define libcdsb_string_replace_r_char_char libcdsb_string_replace_char_char /*#####################################################################################################################*/ diff --git a/include/extra/vtype.h b/include/extra/vtype.h index 7f614a5..7c5aec9 100644 --- a/include/extra/vtype.h +++ b/include/extra/vtype.h @@ -8,7 +8,7 @@ extern const size_t LIBCDSB_VTYPE_SIZES[18]; -extern const char* libcdsb_vtype_name(vtype t); -extern const char* libcdsb_vtype_stringify(const void* value, vtype t); +extern const char* libcdsb_vtype_name(vtype t) Warn_unused_result__; +extern const char* libcdsb_vtype_stringify(const void* value, vtype t) Warn_unused_result__; #endif /* LIBCDSB_EXTRA_VTYPE_H */ diff --git a/include/list.h b/include/list.h index 6e35293..219e04e 100644 --- a/include/list.h +++ b/include/list.h @@ -11,13 +11,11 @@ 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 size_t list_slice(vtype_list* x, vtype_list* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; - -extern void list_sort(vtype_list* x); -extern void list_reverse(vtype_list* x); +extern void list_init (vtype_list* x) Nonnull__(1); +extern void list_extend(vtype_list* x, const vtype_list* s) Nonnull__(1,2); +extern size_t list_slice (vtype_list* x, vtype_list* src, ssize_t index, size_t count, bool cut) Nonnull__(1,2); +extern void list_sort (vtype_list* x) Nonnull__(1); +extern void list_reverse(vtype_list* x) Nonnull__(1); #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) @@ -33,67 +31,67 @@ extern void list_reverse(vtype_list* x); /*#####################################################################################################################*/ -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_dict (vtype_list* x, const vtype_dict* 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 int libcdsb_list_find_pointer(vtype_list* x, const void* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_cstring(vtype_list* x, const char* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_string (vtype_list* x, const vtype_string* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_array (vtype_list* x, const vtype_array* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_list (vtype_list* x, const vtype_list* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_map (vtype_list* x, const vtype_map* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_vset (vtype_list* x, const vtype_set* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_dict (vtype_list* x, const vtype_dict* value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1,2); +extern int libcdsb_list_find_boolean(vtype_list* x, vtype_bool value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_int8 (vtype_list* x, vtype_int8 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_int16 (vtype_list* x, vtype_int16 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_int32 (vtype_list* x, vtype_int32 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_int64 (vtype_list* x, vtype_int64 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_uint8 (vtype_list* x, vtype_uint8 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_uint16 (vtype_list* x, vtype_uint16 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_uint32 (vtype_list* x, vtype_uint32 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_uint64 (vtype_list* x, vtype_uint64 value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_float (vtype_list* x, vtype_float value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_double (vtype_list* x, vtype_double value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); +extern int libcdsb_list_find_ldouble(vtype_list* x, vtype_ldouble value, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1); -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); -extern size_t libcdsb_list_count_string (const vtype_list* s, const vtype_string* value); -extern size_t libcdsb_list_count_array (const vtype_list* s, const vtype_array* value); -extern size_t libcdsb_list_count_list (const vtype_list* s, const vtype_list* value); -extern size_t libcdsb_list_count_map (const vtype_list* s, const vtype_map* value); -extern size_t libcdsb_list_count_vset (const vtype_list* s, const vtype_set* value); -extern size_t libcdsb_list_count_dict (const vtype_list* s, const vtype_dict* value); -extern size_t libcdsb_list_count_boolean(const vtype_list* s, vtype_bool value); -extern size_t libcdsb_list_count_int8 (const vtype_list* s, vtype_int8 value); -extern size_t libcdsb_list_count_int16 (const vtype_list* s, vtype_int16 value); -extern size_t libcdsb_list_count_int32 (const vtype_list* s, vtype_int32 value); -extern size_t libcdsb_list_count_int64 (const vtype_list* s, vtype_int64 value); -extern size_t libcdsb_list_count_uint8 (const vtype_list* s, vtype_uint8 value); -extern size_t libcdsb_list_count_uint16 (const vtype_list* s, vtype_uint16 value); -extern size_t libcdsb_list_count_uint32 (const vtype_list* s, vtype_uint32 value); -extern size_t libcdsb_list_count_uint64 (const vtype_list* s, vtype_uint64 value); -extern size_t libcdsb_list_count_float (const vtype_list* s, vtype_float value); -extern size_t libcdsb_list_count_double (const vtype_list* s, vtype_double value); -extern size_t libcdsb_list_count_ldouble(const vtype_list* s, vtype_ldouble value); +extern size_t libcdsb_list_count_pointer(const vtype_list* s, const void* value) Nonnull__(1); +extern size_t libcdsb_list_count_cstring(const vtype_list* s, const char* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_string (const vtype_list* s, const vtype_string* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_array (const vtype_list* s, const vtype_array* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_list (const vtype_list* s, const vtype_list* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_map (const vtype_list* s, const vtype_map* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_vset (const vtype_list* s, const vtype_set* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_dict (const vtype_list* s, const vtype_dict* value) Nonnull__(1,2); +extern size_t libcdsb_list_count_boolean(const vtype_list* s, vtype_bool value) Nonnull__(1); +extern size_t libcdsb_list_count_int8 (const vtype_list* s, vtype_int8 value) Nonnull__(1); +extern size_t libcdsb_list_count_int16 (const vtype_list* s, vtype_int16 value) Nonnull__(1); +extern size_t libcdsb_list_count_int32 (const vtype_list* s, vtype_int32 value) Nonnull__(1); +extern size_t libcdsb_list_count_int64 (const vtype_list* s, vtype_int64 value) Nonnull__(1); +extern size_t libcdsb_list_count_uint8 (const vtype_list* s, vtype_uint8 value) Nonnull__(1); +extern size_t libcdsb_list_count_uint16 (const vtype_list* s, vtype_uint16 value) Nonnull__(1); +extern size_t libcdsb_list_count_uint32 (const vtype_list* s, vtype_uint32 value) Nonnull__(1); +extern size_t libcdsb_list_count_uint64 (const vtype_list* s, vtype_uint64 value) Nonnull__(1); +extern size_t libcdsb_list_count_float (const vtype_list* s, vtype_float value) Nonnull__(1); +extern size_t libcdsb_list_count_double (const vtype_list* s, vtype_double value) Nonnull__(1); +extern size_t libcdsb_list_count_ldouble(const vtype_list* s, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_list_update_pointer(vtype_list* x, ssize_t index, const void* value, int ins_direction); -extern bool libcdsb_list_update_cstring(vtype_list* x, ssize_t index, const char* value, int ins_direction); -extern bool libcdsb_list_update_string (vtype_list* x, ssize_t index, const vtype_string* value, int ins_direction); -extern bool libcdsb_list_update_array (vtype_list* x, ssize_t index, const vtype_array* value, int ins_direction); -extern bool libcdsb_list_update_list (vtype_list* x, ssize_t index, const vtype_list* value, int ins_direction); -extern bool libcdsb_list_update_map (vtype_list* x, ssize_t index, const vtype_map* value, int ins_direction); -extern bool libcdsb_list_update_vset (vtype_list* x, ssize_t index, const vtype_set* value, int ins_direction); -extern bool libcdsb_list_update_dict (vtype_list* x, ssize_t index, const vtype_dict* value, int ins_direction); -extern bool libcdsb_list_update_boolean(vtype_list* x, ssize_t index, vtype_bool value, int ins_direction); -extern bool libcdsb_list_update_int8 (vtype_list* x, ssize_t index, vtype_int8 value, int ins_direction); -extern bool libcdsb_list_update_int16 (vtype_list* x, ssize_t index, vtype_int16 value, int ins_direction); -extern bool libcdsb_list_update_int32 (vtype_list* x, ssize_t index, vtype_int32 value, int ins_direction); -extern bool libcdsb_list_update_int64 (vtype_list* x, ssize_t index, vtype_int64 value, int ins_direction); -extern bool libcdsb_list_update_uint8 (vtype_list* x, ssize_t index, vtype_uint8 value, int ins_direction); -extern bool libcdsb_list_update_uint16 (vtype_list* x, ssize_t index, vtype_uint16 value, int ins_direction); -extern bool libcdsb_list_update_uint32 (vtype_list* x, ssize_t index, vtype_uint32 value, int ins_direction); -extern bool libcdsb_list_update_uint64 (vtype_list* x, ssize_t index, vtype_uint64 value, int ins_direction); -extern bool libcdsb_list_update_float (vtype_list* x, ssize_t index, vtype_float value, int ins_direction); -extern bool libcdsb_list_update_double (vtype_list* x, ssize_t index, vtype_double value, int ins_direction); -extern bool libcdsb_list_update_ldouble(vtype_list* x, ssize_t index, vtype_ldouble value, int ins_direction); +extern bool libcdsb_list_update_pointer(vtype_list* x, ssize_t index, const void* value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_cstring(vtype_list* x, ssize_t index, const char* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_string (vtype_list* x, ssize_t index, const vtype_string* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_array (vtype_list* x, ssize_t index, const vtype_array* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_list (vtype_list* x, ssize_t index, const vtype_list* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_map (vtype_list* x, ssize_t index, const vtype_map* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_vset (vtype_list* x, ssize_t index, const vtype_set* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_dict (vtype_list* x, ssize_t index, const vtype_dict* value, int ins_direction) Nonnull__(1,3); +extern bool libcdsb_list_update_boolean(vtype_list* x, ssize_t index, vtype_bool value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_int8 (vtype_list* x, ssize_t index, vtype_int8 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_int16 (vtype_list* x, ssize_t index, vtype_int16 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_int32 (vtype_list* x, ssize_t index, vtype_int32 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_int64 (vtype_list* x, ssize_t index, vtype_int64 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_uint8 (vtype_list* x, ssize_t index, vtype_uint8 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_uint16 (vtype_list* x, ssize_t index, vtype_uint16 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_uint32 (vtype_list* x, ssize_t index, vtype_uint32 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_uint64 (vtype_list* x, ssize_t index, vtype_uint64 value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_float (vtype_list* x, ssize_t index, vtype_float value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_double (vtype_list* x, ssize_t index, vtype_double value, int ins_direction) Nonnull__(1); +extern bool libcdsb_list_update_ldouble(vtype_list* x, ssize_t index, vtype_ldouble value, int ins_direction) Nonnull__(1); #endif /* LIBCDSB_LIST_H */ diff --git a/include/map.h b/include/map.h index 9898814..4248050 100644 --- a/include/map.h +++ b/include/map.h @@ -9,452 +9,452 @@ 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); +extern void map_init(vtype_map* x, vtype key_type) Nonnull__(1); #define map_pop(x, key, data, callback) _LIBCDSB_Generic (libcdsb_map, find, key)(x, key, data, callback, 1) #define map_get(x, key, data, callback) _LIBCDSB_Generic (libcdsb_map, find, key)(x, key, data, callback, 0) #define map_update(x, key, value) _LIBCDSB_Generic2(libcdsb_map, update, key, value)(x, key, value) #define map_remove(x, key) map_pop(x, key, 0, 0) -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_dict (vtype_map* x, const vtype_dict* 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 int libcdsb_map_find_pointer(vtype_map* x, const void* key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_cstring(vtype_map* x, const char* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_string (vtype_map* x, const vtype_string* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_array (vtype_map* x, const vtype_array* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_list (vtype_map* x, const vtype_list* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_map (vtype_map* x, const vtype_map* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_vset (vtype_map* x, const vtype_set* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_dict (vtype_map* x, const vtype_dict* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_map_find_boolean(vtype_map* x, vtype_bool key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_int8 (vtype_map* x, vtype_int8 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_int16 (vtype_map* x, vtype_int16 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_int32 (vtype_map* x, vtype_int32 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_int64 (vtype_map* x, vtype_int64 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_uint8 (vtype_map* x, vtype_uint8 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_uint16 (vtype_map* x, vtype_uint16 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_uint32 (vtype_map* x, vtype_uint32 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_uint64 (vtype_map* x, vtype_uint64 key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_float (vtype_map* x, vtype_float key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_double (vtype_map* x, vtype_double key, void* data, map_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_map_find_ldouble(vtype_map* x, vtype_ldouble key, void* data, map_access_callback, bool cut) Nonnull__(1); -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); -extern bool libcdsb_map_update_pointer_string (vtype_map* x, const void* key, const vtype_string* value); -extern bool libcdsb_map_update_pointer_array (vtype_map* x, const void* key, const vtype_array* value); -extern bool libcdsb_map_update_pointer_list (vtype_map* x, const void* key, const vtype_list* value); -extern bool libcdsb_map_update_pointer_map (vtype_map* x, const void* key, const vtype_map* value); -extern bool libcdsb_map_update_pointer_vset (vtype_map* x, const void* key, const vtype_set* value); -extern bool libcdsb_map_update_pointer_dict (vtype_map* x, const void* key, const vtype_dict* value); -extern bool libcdsb_map_update_pointer_boolean(vtype_map* x, const void* key, vtype_bool value); -extern bool libcdsb_map_update_pointer_int8 (vtype_map* x, const void* key, vtype_int8 value); -extern bool libcdsb_map_update_pointer_int16 (vtype_map* x, const void* key, vtype_int16 value); -extern bool libcdsb_map_update_pointer_int32 (vtype_map* x, const void* key, vtype_int32 value); -extern bool libcdsb_map_update_pointer_int64 (vtype_map* x, const void* key, vtype_int64 value); -extern bool libcdsb_map_update_pointer_uint8 (vtype_map* x, const void* key, vtype_uint8 value); -extern bool libcdsb_map_update_pointer_uint16 (vtype_map* x, const void* key, vtype_uint16 value); -extern bool libcdsb_map_update_pointer_uint32 (vtype_map* x, const void* key, vtype_uint32 value); -extern bool libcdsb_map_update_pointer_uint64 (vtype_map* x, const void* key, vtype_uint64 value); -extern bool libcdsb_map_update_pointer_float (vtype_map* x, const void* key, vtype_float value); -extern bool libcdsb_map_update_pointer_double (vtype_map* x, const void* key, vtype_double value); -extern bool libcdsb_map_update_pointer_ldouble(vtype_map* x, const void* key, vtype_ldouble value); +extern bool libcdsb_map_update_pointer_pointer(vtype_map* x, const void* key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_cstring(vtype_map* x, const void* key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_string (vtype_map* x, const void* key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_array (vtype_map* x, const void* key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_list (vtype_map* x, const void* key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_map (vtype_map* x, const void* key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_vset (vtype_map* x, const void* key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_dict (vtype_map* x, const void* key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_pointer_boolean(vtype_map* x, const void* key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_int8 (vtype_map* x, const void* key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_int16 (vtype_map* x, const void* key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_int32 (vtype_map* x, const void* key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_int64 (vtype_map* x, const void* key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_uint8 (vtype_map* x, const void* key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_uint16 (vtype_map* x, const void* key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_uint32 (vtype_map* x, const void* key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_uint64 (vtype_map* x, const void* key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_float (vtype_map* x, const void* key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_double (vtype_map* x, const void* key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_pointer_ldouble(vtype_map* x, const void* key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_string_pointer(vtype_map* x, const vtype_string* key, const void* value); -extern bool libcdsb_map_update_string_cstring(vtype_map* x, const vtype_string* key, const char* value); -extern bool libcdsb_map_update_string_string (vtype_map* x, const vtype_string* key, const vtype_string* value); -extern bool libcdsb_map_update_string_array (vtype_map* x, const vtype_string* key, const vtype_array* value); -extern bool libcdsb_map_update_string_list (vtype_map* x, const vtype_string* key, const vtype_list* value); -extern bool libcdsb_map_update_string_map (vtype_map* x, const vtype_string* key, const vtype_map* value); -extern bool libcdsb_map_update_string_vset (vtype_map* x, const vtype_string* key, const vtype_set* value); -extern bool libcdsb_map_update_string_dict (vtype_map* x, const vtype_string* key, const vtype_dict* value); -extern bool libcdsb_map_update_string_boolean(vtype_map* x, const vtype_string* key, vtype_bool value); -extern bool libcdsb_map_update_string_int8 (vtype_map* x, const vtype_string* key, vtype_int8 value); -extern bool libcdsb_map_update_string_int16 (vtype_map* x, const vtype_string* key, vtype_int16 value); -extern bool libcdsb_map_update_string_int32 (vtype_map* x, const vtype_string* key, vtype_int32 value); -extern bool libcdsb_map_update_string_int64 (vtype_map* x, const vtype_string* key, vtype_int64 value); -extern bool libcdsb_map_update_string_uint8 (vtype_map* x, const vtype_string* key, vtype_uint8 value); -extern bool libcdsb_map_update_string_uint16 (vtype_map* x, const vtype_string* key, vtype_uint16 value); -extern bool libcdsb_map_update_string_uint32 (vtype_map* x, const vtype_string* key, vtype_uint32 value); -extern bool libcdsb_map_update_string_uint64 (vtype_map* x, const vtype_string* key, vtype_uint64 value); -extern bool libcdsb_map_update_string_float (vtype_map* x, const vtype_string* key, vtype_float value); -extern bool libcdsb_map_update_string_double (vtype_map* x, const vtype_string* key, vtype_double value); -extern bool libcdsb_map_update_string_ldouble(vtype_map* x, const vtype_string* key, vtype_ldouble value); +extern bool libcdsb_map_update_cstring_pointer(vtype_map* x, const char* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_cstring(vtype_map* x, const char* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_string (vtype_map* x, const char* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_array (vtype_map* x, const char* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_list (vtype_map* x, const char* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_map (vtype_map* x, const char* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_vset (vtype_map* x, const char* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_dict (vtype_map* x, const char* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_cstring_boolean(vtype_map* x, const char* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_int8 (vtype_map* x, const char* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_int16 (vtype_map* x, const char* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_int32 (vtype_map* x, const char* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_int64 (vtype_map* x, const char* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_uint8 (vtype_map* x, const char* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_uint16 (vtype_map* x, const char* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_uint32 (vtype_map* x, const char* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_uint64 (vtype_map* x, const char* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_float (vtype_map* x, const char* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_double (vtype_map* x, const char* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_cstring_ldouble(vtype_map* x, const char* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_array_pointer(vtype_map* x, const vtype_array* key, const void* value); -extern bool libcdsb_map_update_array_cstring(vtype_map* x, const vtype_array* key, const char* value); -extern bool libcdsb_map_update_array_string (vtype_map* x, const vtype_array* key, const vtype_string* value); -extern bool libcdsb_map_update_array_array (vtype_map* x, const vtype_array* key, const vtype_array* value); -extern bool libcdsb_map_update_array_list (vtype_map* x, const vtype_array* key, const vtype_list* value); -extern bool libcdsb_map_update_array_map (vtype_map* x, const vtype_array* key, const vtype_map* value); -extern bool libcdsb_map_update_array_vset (vtype_map* x, const vtype_array* key, const vtype_set* value); -extern bool libcdsb_map_update_array_dict (vtype_map* x, const vtype_array* key, const vtype_dict* value); -extern bool libcdsb_map_update_array_boolean(vtype_map* x, const vtype_array* key, vtype_bool value); -extern bool libcdsb_map_update_array_int8 (vtype_map* x, const vtype_array* key, vtype_int8 value); -extern bool libcdsb_map_update_array_int16 (vtype_map* x, const vtype_array* key, vtype_int16 value); -extern bool libcdsb_map_update_array_int32 (vtype_map* x, const vtype_array* key, vtype_int32 value); -extern bool libcdsb_map_update_array_int64 (vtype_map* x, const vtype_array* key, vtype_int64 value); -extern bool libcdsb_map_update_array_uint8 (vtype_map* x, const vtype_array* key, vtype_uint8 value); -extern bool libcdsb_map_update_array_uint16 (vtype_map* x, const vtype_array* key, vtype_uint16 value); -extern bool libcdsb_map_update_array_uint32 (vtype_map* x, const vtype_array* key, vtype_uint32 value); -extern bool libcdsb_map_update_array_uint64 (vtype_map* x, const vtype_array* key, vtype_uint64 value); -extern bool libcdsb_map_update_array_float (vtype_map* x, const vtype_array* key, vtype_float value); -extern bool libcdsb_map_update_array_double (vtype_map* x, const vtype_array* key, vtype_double value); -extern bool libcdsb_map_update_array_ldouble(vtype_map* x, const vtype_array* key, vtype_ldouble value); +extern bool libcdsb_map_update_string_pointer(vtype_map* x, const vtype_string* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_cstring(vtype_map* x, const vtype_string* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_string (vtype_map* x, const vtype_string* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_array (vtype_map* x, const vtype_string* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_list (vtype_map* x, const vtype_string* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_map (vtype_map* x, const vtype_string* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_vset (vtype_map* x, const vtype_string* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_dict (vtype_map* x, const vtype_string* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_string_boolean(vtype_map* x, const vtype_string* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_int8 (vtype_map* x, const vtype_string* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_int16 (vtype_map* x, const vtype_string* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_int32 (vtype_map* x, const vtype_string* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_int64 (vtype_map* x, const vtype_string* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_uint8 (vtype_map* x, const vtype_string* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_uint16 (vtype_map* x, const vtype_string* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_uint32 (vtype_map* x, const vtype_string* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_uint64 (vtype_map* x, const vtype_string* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_float (vtype_map* x, const vtype_string* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_double (vtype_map* x, const vtype_string* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_string_ldouble(vtype_map* x, const vtype_string* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_list_pointer(vtype_map* x, const vtype_list* key, const void* value); -extern bool libcdsb_map_update_list_cstring(vtype_map* x, const vtype_list* key, const char* value); -extern bool libcdsb_map_update_list_string (vtype_map* x, const vtype_list* key, const vtype_string* value); -extern bool libcdsb_map_update_list_array (vtype_map* x, const vtype_list* key, const vtype_array* value); -extern bool libcdsb_map_update_list_list (vtype_map* x, const vtype_list* key, const vtype_list* value); -extern bool libcdsb_map_update_list_map (vtype_map* x, const vtype_list* key, const vtype_map* value); -extern bool libcdsb_map_update_list_vset (vtype_map* x, const vtype_list* key, const vtype_set* value); -extern bool libcdsb_map_update_list_dict (vtype_map* x, const vtype_list* key, const vtype_dict* value); -extern bool libcdsb_map_update_list_boolean(vtype_map* x, const vtype_list* key, vtype_bool value); -extern bool libcdsb_map_update_list_int8 (vtype_map* x, const vtype_list* key, vtype_int8 value); -extern bool libcdsb_map_update_list_int16 (vtype_map* x, const vtype_list* key, vtype_int16 value); -extern bool libcdsb_map_update_list_int32 (vtype_map* x, const vtype_list* key, vtype_int32 value); -extern bool libcdsb_map_update_list_int64 (vtype_map* x, const vtype_list* key, vtype_int64 value); -extern bool libcdsb_map_update_list_uint8 (vtype_map* x, const vtype_list* key, vtype_uint8 value); -extern bool libcdsb_map_update_list_uint16 (vtype_map* x, const vtype_list* key, vtype_uint16 value); -extern bool libcdsb_map_update_list_uint32 (vtype_map* x, const vtype_list* key, vtype_uint32 value); -extern bool libcdsb_map_update_list_uint64 (vtype_map* x, const vtype_list* key, vtype_uint64 value); -extern bool libcdsb_map_update_list_float (vtype_map* x, const vtype_list* key, vtype_float value); -extern bool libcdsb_map_update_list_double (vtype_map* x, const vtype_list* key, vtype_double value); -extern bool libcdsb_map_update_list_ldouble(vtype_map* x, const vtype_list* key, vtype_ldouble value); +extern bool libcdsb_map_update_array_pointer(vtype_map* x, const vtype_array* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_cstring(vtype_map* x, const vtype_array* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_string (vtype_map* x, const vtype_array* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_array (vtype_map* x, const vtype_array* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_list (vtype_map* x, const vtype_array* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_map (vtype_map* x, const vtype_array* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_vset (vtype_map* x, const vtype_array* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_dict (vtype_map* x, const vtype_array* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_array_boolean(vtype_map* x, const vtype_array* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_int8 (vtype_map* x, const vtype_array* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_int16 (vtype_map* x, const vtype_array* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_int32 (vtype_map* x, const vtype_array* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_int64 (vtype_map* x, const vtype_array* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_uint8 (vtype_map* x, const vtype_array* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_uint16 (vtype_map* x, const vtype_array* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_uint32 (vtype_map* x, const vtype_array* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_uint64 (vtype_map* x, const vtype_array* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_float (vtype_map* x, const vtype_array* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_double (vtype_map* x, const vtype_array* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_array_ldouble(vtype_map* x, const vtype_array* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_map_pointer(vtype_map* x, const vtype_map* key, const void* value); -extern bool libcdsb_map_update_map_cstring(vtype_map* x, const vtype_map* key, const char* value); -extern bool libcdsb_map_update_map_string (vtype_map* x, const vtype_map* key, const vtype_string* value); -extern bool libcdsb_map_update_map_array (vtype_map* x, const vtype_map* key, const vtype_array* value); -extern bool libcdsb_map_update_map_list (vtype_map* x, const vtype_map* key, const vtype_list* value); -extern bool libcdsb_map_update_map_map (vtype_map* x, const vtype_map* key, const vtype_map* value); -extern bool libcdsb_map_update_map_vset (vtype_map* x, const vtype_map* key, const vtype_set* value); -extern bool libcdsb_map_update_map_dict (vtype_map* x, const vtype_map* key, const vtype_dict* value); -extern bool libcdsb_map_update_map_boolean(vtype_map* x, const vtype_map* key, vtype_bool value); -extern bool libcdsb_map_update_map_int8 (vtype_map* x, const vtype_map* key, vtype_int8 value); -extern bool libcdsb_map_update_map_int16 (vtype_map* x, const vtype_map* key, vtype_int16 value); -extern bool libcdsb_map_update_map_int32 (vtype_map* x, const vtype_map* key, vtype_int32 value); -extern bool libcdsb_map_update_map_int64 (vtype_map* x, const vtype_map* key, vtype_int64 value); -extern bool libcdsb_map_update_map_uint8 (vtype_map* x, const vtype_map* key, vtype_uint8 value); -extern bool libcdsb_map_update_map_uint16 (vtype_map* x, const vtype_map* key, vtype_uint16 value); -extern bool libcdsb_map_update_map_uint32 (vtype_map* x, const vtype_map* key, vtype_uint32 value); -extern bool libcdsb_map_update_map_uint64 (vtype_map* x, const vtype_map* key, vtype_uint64 value); -extern bool libcdsb_map_update_map_float (vtype_map* x, const vtype_map* key, vtype_float value); -extern bool libcdsb_map_update_map_double (vtype_map* x, const vtype_map* key, vtype_double value); -extern bool libcdsb_map_update_map_ldouble(vtype_map* x, const vtype_map* key, vtype_ldouble value); +extern bool libcdsb_map_update_list_pointer(vtype_map* x, const vtype_list* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_cstring(vtype_map* x, const vtype_list* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_string (vtype_map* x, const vtype_list* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_array (vtype_map* x, const vtype_list* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_list (vtype_map* x, const vtype_list* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_map (vtype_map* x, const vtype_list* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_vset (vtype_map* x, const vtype_list* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_dict (vtype_map* x, const vtype_list* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_list_boolean(vtype_map* x, const vtype_list* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_int8 (vtype_map* x, const vtype_list* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_int16 (vtype_map* x, const vtype_list* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_int32 (vtype_map* x, const vtype_list* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_int64 (vtype_map* x, const vtype_list* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_uint8 (vtype_map* x, const vtype_list* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_uint16 (vtype_map* x, const vtype_list* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_uint32 (vtype_map* x, const vtype_list* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_uint64 (vtype_map* x, const vtype_list* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_float (vtype_map* x, const vtype_list* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_double (vtype_map* x, const vtype_list* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_list_ldouble(vtype_map* x, const vtype_list* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_vset_pointer(vtype_map* x, const vtype_set* key, const void* value); -extern bool libcdsb_map_update_vset_cstring(vtype_map* x, const vtype_set* key, const char* value); -extern bool libcdsb_map_update_vset_string (vtype_map* x, const vtype_set* key, const vtype_string* value); -extern bool libcdsb_map_update_vset_array (vtype_map* x, const vtype_set* key, const vtype_array* value); -extern bool libcdsb_map_update_vset_list (vtype_map* x, const vtype_set* key, const vtype_list* value); -extern bool libcdsb_map_update_vset_map (vtype_map* x, const vtype_set* key, const vtype_map* value); -extern bool libcdsb_map_update_vset_vset (vtype_map* x, const vtype_set* key, const vtype_set* value); -extern bool libcdsb_map_update_vset_dict (vtype_map* x, const vtype_set* key, const vtype_dict* value); -extern bool libcdsb_map_update_vset_boolean(vtype_map* x, const vtype_set* key, vtype_bool value); -extern bool libcdsb_map_update_vset_int8 (vtype_map* x, const vtype_set* key, vtype_int8 value); -extern bool libcdsb_map_update_vset_int16 (vtype_map* x, const vtype_set* key, vtype_int16 value); -extern bool libcdsb_map_update_vset_int32 (vtype_map* x, const vtype_set* key, vtype_int32 value); -extern bool libcdsb_map_update_vset_int64 (vtype_map* x, const vtype_set* key, vtype_int64 value); -extern bool libcdsb_map_update_vset_uint8 (vtype_map* x, const vtype_set* key, vtype_uint8 value); -extern bool libcdsb_map_update_vset_uint16 (vtype_map* x, const vtype_set* key, vtype_uint16 value); -extern bool libcdsb_map_update_vset_uint32 (vtype_map* x, const vtype_set* key, vtype_uint32 value); -extern bool libcdsb_map_update_vset_uint64 (vtype_map* x, const vtype_set* key, vtype_uint64 value); -extern bool libcdsb_map_update_vset_float (vtype_map* x, const vtype_set* key, vtype_float value); -extern bool libcdsb_map_update_vset_double (vtype_map* x, const vtype_set* key, vtype_double value); -extern bool libcdsb_map_update_vset_ldouble(vtype_map* x, const vtype_set* key, vtype_ldouble value); +extern bool libcdsb_map_update_map_pointer(vtype_map* x, const vtype_map* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_cstring(vtype_map* x, const vtype_map* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_string (vtype_map* x, const vtype_map* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_array (vtype_map* x, const vtype_map* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_list (vtype_map* x, const vtype_map* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_map (vtype_map* x, const vtype_map* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_vset (vtype_map* x, const vtype_map* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_dict (vtype_map* x, const vtype_map* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_map_boolean(vtype_map* x, const vtype_map* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_int8 (vtype_map* x, const vtype_map* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_int16 (vtype_map* x, const vtype_map* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_int32 (vtype_map* x, const vtype_map* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_int64 (vtype_map* x, const vtype_map* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_uint8 (vtype_map* x, const vtype_map* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_uint16 (vtype_map* x, const vtype_map* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_uint32 (vtype_map* x, const vtype_map* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_uint64 (vtype_map* x, const vtype_map* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_float (vtype_map* x, const vtype_map* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_double (vtype_map* x, const vtype_map* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_map_ldouble(vtype_map* x, const vtype_map* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_dict_pointer(vtype_map* x, const vtype_dict* key, const void* value); -extern bool libcdsb_map_update_dict_cstring(vtype_map* x, const vtype_dict* key, const char* value); -extern bool libcdsb_map_update_dict_string (vtype_map* x, const vtype_dict* key, const vtype_string* value); -extern bool libcdsb_map_update_dict_array (vtype_map* x, const vtype_dict* key, const vtype_array* value); -extern bool libcdsb_map_update_dict_list (vtype_map* x, const vtype_dict* key, const vtype_list* value); -extern bool libcdsb_map_update_dict_map (vtype_map* x, const vtype_dict* key, const vtype_map* value); -extern bool libcdsb_map_update_dict_vset (vtype_map* x, const vtype_dict* key, const vtype_set* value); -extern bool libcdsb_map_update_dict_dict (vtype_map* x, const vtype_dict* key, const vtype_dict* value); -extern bool libcdsb_map_update_dict_boolean(vtype_map* x, const vtype_dict* key, vtype_bool value); -extern bool libcdsb_map_update_dict_int8 (vtype_map* x, const vtype_dict* key, vtype_int8 value); -extern bool libcdsb_map_update_dict_int16 (vtype_map* x, const vtype_dict* key, vtype_int16 value); -extern bool libcdsb_map_update_dict_int32 (vtype_map* x, const vtype_dict* key, vtype_int32 value); -extern bool libcdsb_map_update_dict_int64 (vtype_map* x, const vtype_dict* key, vtype_int64 value); -extern bool libcdsb_map_update_dict_uint8 (vtype_map* x, const vtype_dict* key, vtype_uint8 value); -extern bool libcdsb_map_update_dict_uint16 (vtype_map* x, const vtype_dict* key, vtype_uint16 value); -extern bool libcdsb_map_update_dict_uint32 (vtype_map* x, const vtype_dict* key, vtype_uint32 value); -extern bool libcdsb_map_update_dict_uint64 (vtype_map* x, const vtype_dict* key, vtype_uint64 value); -extern bool libcdsb_map_update_dict_float (vtype_map* x, const vtype_dict* key, vtype_float value); -extern bool libcdsb_map_update_dict_double (vtype_map* x, const vtype_dict* key, vtype_double value); -extern bool libcdsb_map_update_dict_ldouble(vtype_map* x, const vtype_dict* key, vtype_ldouble value); +extern bool libcdsb_map_update_vset_pointer(vtype_map* x, const vtype_set* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_cstring(vtype_map* x, const vtype_set* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_string (vtype_map* x, const vtype_set* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_array (vtype_map* x, const vtype_set* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_list (vtype_map* x, const vtype_set* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_map (vtype_map* x, const vtype_set* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_vset (vtype_map* x, const vtype_set* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_dict (vtype_map* x, const vtype_set* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_vset_boolean(vtype_map* x, const vtype_set* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_int8 (vtype_map* x, const vtype_set* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_int16 (vtype_map* x, const vtype_set* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_int32 (vtype_map* x, const vtype_set* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_int64 (vtype_map* x, const vtype_set* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_uint8 (vtype_map* x, const vtype_set* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_uint16 (vtype_map* x, const vtype_set* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_uint32 (vtype_map* x, const vtype_set* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_uint64 (vtype_map* x, const vtype_set* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_float (vtype_map* x, const vtype_set* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_double (vtype_map* x, const vtype_set* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_vset_ldouble(vtype_map* x, const vtype_set* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_cstring_pointer(vtype_map* x, const char* key, const void* value); -extern bool libcdsb_map_update_cstring_cstring(vtype_map* x, const char* key, const char* value); -extern bool libcdsb_map_update_cstring_string (vtype_map* x, const char* key, const vtype_string* value); -extern bool libcdsb_map_update_cstring_array (vtype_map* x, const char* key, const vtype_array* value); -extern bool libcdsb_map_update_cstring_list (vtype_map* x, const char* key, const vtype_list* value); -extern bool libcdsb_map_update_cstring_map (vtype_map* x, const char* key, const vtype_map* value); -extern bool libcdsb_map_update_cstring_vset (vtype_map* x, const char* key, const vtype_set* value); -extern bool libcdsb_map_update_cstring_dict (vtype_map* x, const char* key, const vtype_dict* value); -extern bool libcdsb_map_update_cstring_boolean(vtype_map* x, const char* key, vtype_bool value); -extern bool libcdsb_map_update_cstring_int8 (vtype_map* x, const char* key, vtype_int8 value); -extern bool libcdsb_map_update_cstring_int16 (vtype_map* x, const char* key, vtype_int16 value); -extern bool libcdsb_map_update_cstring_int32 (vtype_map* x, const char* key, vtype_int32 value); -extern bool libcdsb_map_update_cstring_int64 (vtype_map* x, const char* key, vtype_int64 value); -extern bool libcdsb_map_update_cstring_uint8 (vtype_map* x, const char* key, vtype_uint8 value); -extern bool libcdsb_map_update_cstring_uint16 (vtype_map* x, const char* key, vtype_uint16 value); -extern bool libcdsb_map_update_cstring_uint32 (vtype_map* x, const char* key, vtype_uint32 value); -extern bool libcdsb_map_update_cstring_uint64 (vtype_map* x, const char* key, vtype_uint64 value); -extern bool libcdsb_map_update_cstring_float (vtype_map* x, const char* key, vtype_float value); -extern bool libcdsb_map_update_cstring_double (vtype_map* x, const char* key, vtype_double value); -extern bool libcdsb_map_update_cstring_ldouble(vtype_map* x, const char* key, vtype_ldouble value); +extern bool libcdsb_map_update_dict_pointer(vtype_map* x, const vtype_dict* key, const void* value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_cstring(vtype_map* x, const vtype_dict* key, const char* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_string (vtype_map* x, const vtype_dict* key, const vtype_string* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_array (vtype_map* x, const vtype_dict* key, const vtype_array* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_list (vtype_map* x, const vtype_dict* key, const vtype_list* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_map (vtype_map* x, const vtype_dict* key, const vtype_map* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_vset (vtype_map* x, const vtype_dict* key, const vtype_set* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_dict (vtype_map* x, const vtype_dict* key, const vtype_dict* value) Nonnull__(1,2,3); +extern bool libcdsb_map_update_dict_boolean(vtype_map* x, const vtype_dict* key, vtype_bool value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_int8 (vtype_map* x, const vtype_dict* key, vtype_int8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_int16 (vtype_map* x, const vtype_dict* key, vtype_int16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_int32 (vtype_map* x, const vtype_dict* key, vtype_int32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_int64 (vtype_map* x, const vtype_dict* key, vtype_int64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_uint8 (vtype_map* x, const vtype_dict* key, vtype_uint8 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_uint16 (vtype_map* x, const vtype_dict* key, vtype_uint16 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_uint32 (vtype_map* x, const vtype_dict* key, vtype_uint32 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_uint64 (vtype_map* x, const vtype_dict* key, vtype_uint64 value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_float (vtype_map* x, const vtype_dict* key, vtype_float value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_double (vtype_map* x, const vtype_dict* key, vtype_double value) Nonnull__(1,2); +extern bool libcdsb_map_update_dict_ldouble(vtype_map* x, const vtype_dict* key, vtype_ldouble value) Nonnull__(1,2); -extern bool libcdsb_map_update_boolean_pointer(vtype_map* x, vtype_bool key, const void* value); -extern bool libcdsb_map_update_boolean_cstring(vtype_map* x, vtype_bool key, const char* value); -extern bool libcdsb_map_update_boolean_string (vtype_map* x, vtype_bool key, const vtype_string* value); -extern bool libcdsb_map_update_boolean_array (vtype_map* x, vtype_bool key, const vtype_array* value); -extern bool libcdsb_map_update_boolean_list (vtype_map* x, vtype_bool key, const vtype_list* value); -extern bool libcdsb_map_update_boolean_map (vtype_map* x, vtype_bool key, const vtype_map* value); -extern bool libcdsb_map_update_boolean_vset (vtype_map* x, vtype_bool key, const vtype_set* value); -extern bool libcdsb_map_update_boolean_dict (vtype_map* x, vtype_bool key, const vtype_dict* value); -extern bool libcdsb_map_update_boolean_boolean(vtype_map* x, vtype_bool key, vtype_bool value); -extern bool libcdsb_map_update_boolean_int8 (vtype_map* x, vtype_bool key, vtype_int8 value); -extern bool libcdsb_map_update_boolean_int16 (vtype_map* x, vtype_bool key, vtype_int16 value); -extern bool libcdsb_map_update_boolean_int32 (vtype_map* x, vtype_bool key, vtype_int32 value); -extern bool libcdsb_map_update_boolean_int64 (vtype_map* x, vtype_bool key, vtype_int64 value); -extern bool libcdsb_map_update_boolean_uint8 (vtype_map* x, vtype_bool key, vtype_uint8 value); -extern bool libcdsb_map_update_boolean_uint16 (vtype_map* x, vtype_bool key, vtype_uint16 value); -extern bool libcdsb_map_update_boolean_uint32 (vtype_map* x, vtype_bool key, vtype_uint32 value); -extern bool libcdsb_map_update_boolean_uint64 (vtype_map* x, vtype_bool key, vtype_uint64 value); -extern bool libcdsb_map_update_boolean_float (vtype_map* x, vtype_bool key, vtype_float value); -extern bool libcdsb_map_update_boolean_double (vtype_map* x, vtype_bool key, vtype_double value); -extern bool libcdsb_map_update_boolean_ldouble(vtype_map* x, vtype_bool key, vtype_ldouble value); +extern bool libcdsb_map_update_boolean_pointer(vtype_map* x, vtype_bool key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_cstring(vtype_map* x, vtype_bool key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_string (vtype_map* x, vtype_bool key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_array (vtype_map* x, vtype_bool key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_list (vtype_map* x, vtype_bool key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_map (vtype_map* x, vtype_bool key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_vset (vtype_map* x, vtype_bool key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_dict (vtype_map* x, vtype_bool key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_boolean_boolean(vtype_map* x, vtype_bool key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_int8 (vtype_map* x, vtype_bool key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_int16 (vtype_map* x, vtype_bool key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_int32 (vtype_map* x, vtype_bool key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_int64 (vtype_map* x, vtype_bool key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_uint8 (vtype_map* x, vtype_bool key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_uint16 (vtype_map* x, vtype_bool key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_uint32 (vtype_map* x, vtype_bool key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_uint64 (vtype_map* x, vtype_bool key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_float (vtype_map* x, vtype_bool key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_double (vtype_map* x, vtype_bool key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_boolean_ldouble(vtype_map* x, vtype_bool key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_uint8_pointer(vtype_map* x, vtype_uint8 key, const void* value); -extern bool libcdsb_map_update_uint8_cstring(vtype_map* x, vtype_uint8 key, const char* value); -extern bool libcdsb_map_update_uint8_string (vtype_map* x, vtype_uint8 key, const vtype_string* value); -extern bool libcdsb_map_update_uint8_array (vtype_map* x, vtype_uint8 key, const vtype_array* value); -extern bool libcdsb_map_update_uint8_list (vtype_map* x, vtype_uint8 key, const vtype_list* value); -extern bool libcdsb_map_update_uint8_map (vtype_map* x, vtype_uint8 key, const vtype_map* value); -extern bool libcdsb_map_update_uint8_vset (vtype_map* x, vtype_uint8 key, const vtype_set* value); -extern bool libcdsb_map_update_uint8_dict (vtype_map* x, vtype_uint8 key, const vtype_dict* value); -extern bool libcdsb_map_update_uint8_boolean(vtype_map* x, vtype_uint8 key, vtype_bool value); -extern bool libcdsb_map_update_uint8_int8 (vtype_map* x, vtype_uint8 key, vtype_int8 value); -extern bool libcdsb_map_update_uint8_int16 (vtype_map* x, vtype_uint8 key, vtype_int16 value); -extern bool libcdsb_map_update_uint8_int32 (vtype_map* x, vtype_uint8 key, vtype_int32 value); -extern bool libcdsb_map_update_uint8_int64 (vtype_map* x, vtype_uint8 key, vtype_int64 value); -extern bool libcdsb_map_update_uint8_uint8 (vtype_map* x, vtype_uint8 key, vtype_uint8 value); -extern bool libcdsb_map_update_uint8_uint16 (vtype_map* x, vtype_uint8 key, vtype_uint16 value); -extern bool libcdsb_map_update_uint8_uint32 (vtype_map* x, vtype_uint8 key, vtype_uint32 value); -extern bool libcdsb_map_update_uint8_uint64 (vtype_map* x, vtype_uint8 key, vtype_uint64 value); -extern bool libcdsb_map_update_uint8_float (vtype_map* x, vtype_uint8 key, vtype_float value); -extern bool libcdsb_map_update_uint8_double (vtype_map* x, vtype_uint8 key, vtype_double value); -extern bool libcdsb_map_update_uint8_ldouble(vtype_map* x, vtype_uint8 key, vtype_ldouble value); +extern bool libcdsb_map_update_uint8_pointer(vtype_map* x, vtype_uint8 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_cstring(vtype_map* x, vtype_uint8 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_string (vtype_map* x, vtype_uint8 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_array (vtype_map* x, vtype_uint8 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_list (vtype_map* x, vtype_uint8 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_map (vtype_map* x, vtype_uint8 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_vset (vtype_map* x, vtype_uint8 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_dict (vtype_map* x, vtype_uint8 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint8_boolean(vtype_map* x, vtype_uint8 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_int8 (vtype_map* x, vtype_uint8 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_int16 (vtype_map* x, vtype_uint8 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_int32 (vtype_map* x, vtype_uint8 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_int64 (vtype_map* x, vtype_uint8 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_uint8 (vtype_map* x, vtype_uint8 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_uint16 (vtype_map* x, vtype_uint8 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_uint32 (vtype_map* x, vtype_uint8 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_uint64 (vtype_map* x, vtype_uint8 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_float (vtype_map* x, vtype_uint8 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_double (vtype_map* x, vtype_uint8 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_uint8_ldouble(vtype_map* x, vtype_uint8 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_uint16_pointer(vtype_map* x, vtype_uint16 key, const void* value); -extern bool libcdsb_map_update_uint16_cstring(vtype_map* x, vtype_uint16 key, const char* value); -extern bool libcdsb_map_update_uint16_string (vtype_map* x, vtype_uint16 key, const vtype_string* value); -extern bool libcdsb_map_update_uint16_array (vtype_map* x, vtype_uint16 key, const vtype_array* value); -extern bool libcdsb_map_update_uint16_list (vtype_map* x, vtype_uint16 key, const vtype_list* value); -extern bool libcdsb_map_update_uint16_map (vtype_map* x, vtype_uint16 key, const vtype_map* value); -extern bool libcdsb_map_update_uint16_vset (vtype_map* x, vtype_uint16 key, const vtype_set* value); -extern bool libcdsb_map_update_uint16_dict (vtype_map* x, vtype_uint16 key, const vtype_dict* value); -extern bool libcdsb_map_update_uint16_boolean(vtype_map* x, vtype_uint16 key, vtype_bool value); -extern bool libcdsb_map_update_uint16_int8 (vtype_map* x, vtype_uint16 key, vtype_int8 value); -extern bool libcdsb_map_update_uint16_int16 (vtype_map* x, vtype_uint16 key, vtype_int16 value); -extern bool libcdsb_map_update_uint16_int32 (vtype_map* x, vtype_uint16 key, vtype_int32 value); -extern bool libcdsb_map_update_uint16_int64 (vtype_map* x, vtype_uint16 key, vtype_int64 value); -extern bool libcdsb_map_update_uint16_uint8 (vtype_map* x, vtype_uint16 key, vtype_uint8 value); -extern bool libcdsb_map_update_uint16_uint16 (vtype_map* x, vtype_uint16 key, vtype_uint16 value); -extern bool libcdsb_map_update_uint16_uint32 (vtype_map* x, vtype_uint16 key, vtype_uint32 value); -extern bool libcdsb_map_update_uint16_uint64 (vtype_map* x, vtype_uint16 key, vtype_uint64 value); -extern bool libcdsb_map_update_uint16_float (vtype_map* x, vtype_uint16 key, vtype_float value); -extern bool libcdsb_map_update_uint16_double (vtype_map* x, vtype_uint16 key, vtype_double value); -extern bool libcdsb_map_update_uint16_ldouble(vtype_map* x, vtype_uint16 key, vtype_ldouble value); +extern bool libcdsb_map_update_uint16_pointer(vtype_map* x, vtype_uint16 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_cstring(vtype_map* x, vtype_uint16 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_string (vtype_map* x, vtype_uint16 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_array (vtype_map* x, vtype_uint16 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_list (vtype_map* x, vtype_uint16 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_map (vtype_map* x, vtype_uint16 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_vset (vtype_map* x, vtype_uint16 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_dict (vtype_map* x, vtype_uint16 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint16_boolean(vtype_map* x, vtype_uint16 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_int8 (vtype_map* x, vtype_uint16 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_int16 (vtype_map* x, vtype_uint16 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_int32 (vtype_map* x, vtype_uint16 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_int64 (vtype_map* x, vtype_uint16 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_uint8 (vtype_map* x, vtype_uint16 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_uint16 (vtype_map* x, vtype_uint16 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_uint32 (vtype_map* x, vtype_uint16 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_uint64 (vtype_map* x, vtype_uint16 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_float (vtype_map* x, vtype_uint16 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_double (vtype_map* x, vtype_uint16 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_uint16_ldouble(vtype_map* x, vtype_uint16 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_uint32_pointer(vtype_map* x, vtype_uint32 key, const void* value); -extern bool libcdsb_map_update_uint32_cstring(vtype_map* x, vtype_uint32 key, const char* value); -extern bool libcdsb_map_update_uint32_string (vtype_map* x, vtype_uint32 key, const vtype_string* value); -extern bool libcdsb_map_update_uint32_array (vtype_map* x, vtype_uint32 key, const vtype_array* value); -extern bool libcdsb_map_update_uint32_list (vtype_map* x, vtype_uint32 key, const vtype_list* value); -extern bool libcdsb_map_update_uint32_map (vtype_map* x, vtype_uint32 key, const vtype_map* value); -extern bool libcdsb_map_update_uint32_vset (vtype_map* x, vtype_uint32 key, const vtype_set* value); -extern bool libcdsb_map_update_uint32_dict (vtype_map* x, vtype_uint32 key, const vtype_dict* value); -extern bool libcdsb_map_update_uint32_boolean(vtype_map* x, vtype_uint32 key, vtype_bool value); -extern bool libcdsb_map_update_uint32_int8 (vtype_map* x, vtype_uint32 key, vtype_int8 value); -extern bool libcdsb_map_update_uint32_int16 (vtype_map* x, vtype_uint32 key, vtype_int16 value); -extern bool libcdsb_map_update_uint32_int32 (vtype_map* x, vtype_uint32 key, vtype_int32 value); -extern bool libcdsb_map_update_uint32_int64 (vtype_map* x, vtype_uint32 key, vtype_int64 value); -extern bool libcdsb_map_update_uint32_uint8 (vtype_map* x, vtype_uint32 key, vtype_uint8 value); -extern bool libcdsb_map_update_uint32_uint16 (vtype_map* x, vtype_uint32 key, vtype_uint16 value); -extern bool libcdsb_map_update_uint32_uint32 (vtype_map* x, vtype_uint32 key, vtype_uint32 value); -extern bool libcdsb_map_update_uint32_uint64 (vtype_map* x, vtype_uint32 key, vtype_uint64 value); -extern bool libcdsb_map_update_uint32_float (vtype_map* x, vtype_uint32 key, vtype_float value); -extern bool libcdsb_map_update_uint32_double (vtype_map* x, vtype_uint32 key, vtype_double value); -extern bool libcdsb_map_update_uint32_ldouble(vtype_map* x, vtype_uint32 key, vtype_ldouble value); +extern bool libcdsb_map_update_uint32_pointer(vtype_map* x, vtype_uint32 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_cstring(vtype_map* x, vtype_uint32 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_string (vtype_map* x, vtype_uint32 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_array (vtype_map* x, vtype_uint32 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_list (vtype_map* x, vtype_uint32 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_map (vtype_map* x, vtype_uint32 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_vset (vtype_map* x, vtype_uint32 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_dict (vtype_map* x, vtype_uint32 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint32_boolean(vtype_map* x, vtype_uint32 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_int8 (vtype_map* x, vtype_uint32 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_int16 (vtype_map* x, vtype_uint32 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_int32 (vtype_map* x, vtype_uint32 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_int64 (vtype_map* x, vtype_uint32 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_uint8 (vtype_map* x, vtype_uint32 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_uint16 (vtype_map* x, vtype_uint32 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_uint32 (vtype_map* x, vtype_uint32 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_uint64 (vtype_map* x, vtype_uint32 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_float (vtype_map* x, vtype_uint32 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_double (vtype_map* x, vtype_uint32 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_uint32_ldouble(vtype_map* x, vtype_uint32 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_uint64_pointer(vtype_map* x, vtype_uint64 key, const void* value); -extern bool libcdsb_map_update_uint64_cstring(vtype_map* x, vtype_uint64 key, const char* value); -extern bool libcdsb_map_update_uint64_string (vtype_map* x, vtype_uint64 key, const vtype_string* value); -extern bool libcdsb_map_update_uint64_array (vtype_map* x, vtype_uint64 key, const vtype_array* value); -extern bool libcdsb_map_update_uint64_list (vtype_map* x, vtype_uint64 key, const vtype_list* value); -extern bool libcdsb_map_update_uint64_map (vtype_map* x, vtype_uint64 key, const vtype_map* value); -extern bool libcdsb_map_update_uint64_vset (vtype_map* x, vtype_uint64 key, const vtype_set* value); -extern bool libcdsb_map_update_uint64_dict (vtype_map* x, vtype_uint64 key, const vtype_dict* value); -extern bool libcdsb_map_update_uint64_boolean(vtype_map* x, vtype_uint64 key, vtype_bool value); -extern bool libcdsb_map_update_uint64_int8 (vtype_map* x, vtype_uint64 key, vtype_int8 value); -extern bool libcdsb_map_update_uint64_int16 (vtype_map* x, vtype_uint64 key, vtype_int16 value); -extern bool libcdsb_map_update_uint64_int32 (vtype_map* x, vtype_uint64 key, vtype_int32 value); -extern bool libcdsb_map_update_uint64_int64 (vtype_map* x, vtype_uint64 key, vtype_int64 value); -extern bool libcdsb_map_update_uint64_uint8 (vtype_map* x, vtype_uint64 key, vtype_uint8 value); -extern bool libcdsb_map_update_uint64_uint16 (vtype_map* x, vtype_uint64 key, vtype_uint16 value); -extern bool libcdsb_map_update_uint64_uint32 (vtype_map* x, vtype_uint64 key, vtype_uint32 value); -extern bool libcdsb_map_update_uint64_uint64 (vtype_map* x, vtype_uint64 key, vtype_uint64 value); -extern bool libcdsb_map_update_uint64_float (vtype_map* x, vtype_uint64 key, vtype_float value); -extern bool libcdsb_map_update_uint64_double (vtype_map* x, vtype_uint64 key, vtype_double value); -extern bool libcdsb_map_update_uint64_ldouble(vtype_map* x, vtype_uint64 key, vtype_ldouble value); +extern bool libcdsb_map_update_uint64_pointer(vtype_map* x, vtype_uint64 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_cstring(vtype_map* x, vtype_uint64 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_string (vtype_map* x, vtype_uint64 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_array (vtype_map* x, vtype_uint64 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_list (vtype_map* x, vtype_uint64 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_map (vtype_map* x, vtype_uint64 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_vset (vtype_map* x, vtype_uint64 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_dict (vtype_map* x, vtype_uint64 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_uint64_boolean(vtype_map* x, vtype_uint64 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_int8 (vtype_map* x, vtype_uint64 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_int16 (vtype_map* x, vtype_uint64 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_int32 (vtype_map* x, vtype_uint64 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_int64 (vtype_map* x, vtype_uint64 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_uint8 (vtype_map* x, vtype_uint64 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_uint16 (vtype_map* x, vtype_uint64 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_uint32 (vtype_map* x, vtype_uint64 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_uint64 (vtype_map* x, vtype_uint64 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_float (vtype_map* x, vtype_uint64 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_double (vtype_map* x, vtype_uint64 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_uint64_ldouble(vtype_map* x, vtype_uint64 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_int8_pointer(vtype_map* x, vtype_int8 key, const void* value); -extern bool libcdsb_map_update_int8_cstring(vtype_map* x, vtype_int8 key, const char* value); -extern bool libcdsb_map_update_int8_string (vtype_map* x, vtype_int8 key, const vtype_string* value); -extern bool libcdsb_map_update_int8_array (vtype_map* x, vtype_int8 key, const vtype_array* value); -extern bool libcdsb_map_update_int8_list (vtype_map* x, vtype_int8 key, const vtype_list* value); -extern bool libcdsb_map_update_int8_map (vtype_map* x, vtype_int8 key, const vtype_map* value); -extern bool libcdsb_map_update_int8_vset (vtype_map* x, vtype_int8 key, const vtype_set* value); -extern bool libcdsb_map_update_int8_dict (vtype_map* x, vtype_int8 key, const vtype_dict* value); -extern bool libcdsb_map_update_int8_boolean(vtype_map* x, vtype_int8 key, vtype_bool value); -extern bool libcdsb_map_update_int8_int8 (vtype_map* x, vtype_int8 key, vtype_int8 value); -extern bool libcdsb_map_update_int8_int16 (vtype_map* x, vtype_int8 key, vtype_int16 value); -extern bool libcdsb_map_update_int8_int32 (vtype_map* x, vtype_int8 key, vtype_int32 value); -extern bool libcdsb_map_update_int8_int64 (vtype_map* x, vtype_int8 key, vtype_int64 value); -extern bool libcdsb_map_update_int8_uint8 (vtype_map* x, vtype_int8 key, vtype_uint8 value); -extern bool libcdsb_map_update_int8_uint16 (vtype_map* x, vtype_int8 key, vtype_uint16 value); -extern bool libcdsb_map_update_int8_uint32 (vtype_map* x, vtype_int8 key, vtype_uint32 value); -extern bool libcdsb_map_update_int8_uint64 (vtype_map* x, vtype_int8 key, vtype_uint64 value); -extern bool libcdsb_map_update_int8_float (vtype_map* x, vtype_int8 key, vtype_float value); -extern bool libcdsb_map_update_int8_double (vtype_map* x, vtype_int8 key, vtype_double value); -extern bool libcdsb_map_update_int8_ldouble(vtype_map* x, vtype_int8 key, vtype_ldouble value); +extern bool libcdsb_map_update_int8_pointer(vtype_map* x, vtype_int8 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_int8_cstring(vtype_map* x, vtype_int8 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_string (vtype_map* x, vtype_int8 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_array (vtype_map* x, vtype_int8 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_list (vtype_map* x, vtype_int8 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_map (vtype_map* x, vtype_int8 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_vset (vtype_map* x, vtype_int8 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_dict (vtype_map* x, vtype_int8 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int8_boolean(vtype_map* x, vtype_int8 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_int8_int8 (vtype_map* x, vtype_int8 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_int16 (vtype_map* x, vtype_int8 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_int32 (vtype_map* x, vtype_int8 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_int64 (vtype_map* x, vtype_int8 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_uint8 (vtype_map* x, vtype_int8 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_uint16 (vtype_map* x, vtype_int8 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_uint32 (vtype_map* x, vtype_int8 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_uint64 (vtype_map* x, vtype_int8 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_int8_float (vtype_map* x, vtype_int8 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_int8_double (vtype_map* x, vtype_int8 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_int8_ldouble(vtype_map* x, vtype_int8 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_int16_pointer(vtype_map* x, vtype_int16 key, const void* value); -extern bool libcdsb_map_update_int16_cstring(vtype_map* x, vtype_int16 key, const char* value); -extern bool libcdsb_map_update_int16_string (vtype_map* x, vtype_int16 key, const vtype_string* value); -extern bool libcdsb_map_update_int16_array (vtype_map* x, vtype_int16 key, const vtype_array* value); -extern bool libcdsb_map_update_int16_list (vtype_map* x, vtype_int16 key, const vtype_list* value); -extern bool libcdsb_map_update_int16_map (vtype_map* x, vtype_int16 key, const vtype_map* value); -extern bool libcdsb_map_update_int16_vset (vtype_map* x, vtype_int16 key, const vtype_set* value); -extern bool libcdsb_map_update_int16_dict (vtype_map* x, vtype_int16 key, const vtype_dict* value); -extern bool libcdsb_map_update_int16_boolean(vtype_map* x, vtype_int16 key, vtype_bool value); -extern bool libcdsb_map_update_int16_int8 (vtype_map* x, vtype_int16 key, vtype_int8 value); -extern bool libcdsb_map_update_int16_int16 (vtype_map* x, vtype_int16 key, vtype_int16 value); -extern bool libcdsb_map_update_int16_int32 (vtype_map* x, vtype_int16 key, vtype_int32 value); -extern bool libcdsb_map_update_int16_int64 (vtype_map* x, vtype_int16 key, vtype_int64 value); -extern bool libcdsb_map_update_int16_uint8 (vtype_map* x, vtype_int16 key, vtype_uint8 value); -extern bool libcdsb_map_update_int16_uint16 (vtype_map* x, vtype_int16 key, vtype_uint16 value); -extern bool libcdsb_map_update_int16_uint32 (vtype_map* x, vtype_int16 key, vtype_uint32 value); -extern bool libcdsb_map_update_int16_uint64 (vtype_map* x, vtype_int16 key, vtype_uint64 value); -extern bool libcdsb_map_update_int16_float (vtype_map* x, vtype_int16 key, vtype_float value); -extern bool libcdsb_map_update_int16_double (vtype_map* x, vtype_int16 key, vtype_double value); -extern bool libcdsb_map_update_int16_ldouble(vtype_map* x, vtype_int16 key, vtype_ldouble value); +extern bool libcdsb_map_update_int16_pointer(vtype_map* x, vtype_int16 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_int16_cstring(vtype_map* x, vtype_int16 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_string (vtype_map* x, vtype_int16 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_array (vtype_map* x, vtype_int16 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_list (vtype_map* x, vtype_int16 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_map (vtype_map* x, vtype_int16 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_vset (vtype_map* x, vtype_int16 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_dict (vtype_map* x, vtype_int16 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int16_boolean(vtype_map* x, vtype_int16 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_int16_int8 (vtype_map* x, vtype_int16 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_int16 (vtype_map* x, vtype_int16 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_int32 (vtype_map* x, vtype_int16 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_int64 (vtype_map* x, vtype_int16 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_uint8 (vtype_map* x, vtype_int16 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_uint16 (vtype_map* x, vtype_int16 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_uint32 (vtype_map* x, vtype_int16 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_uint64 (vtype_map* x, vtype_int16 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_int16_float (vtype_map* x, vtype_int16 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_int16_double (vtype_map* x, vtype_int16 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_int16_ldouble(vtype_map* x, vtype_int16 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_int32_pointer(vtype_map* x, vtype_int32 key, const void* value); -extern bool libcdsb_map_update_int32_cstring(vtype_map* x, vtype_int32 key, const char* value); -extern bool libcdsb_map_update_int32_string (vtype_map* x, vtype_int32 key, const vtype_string* value); -extern bool libcdsb_map_update_int32_array (vtype_map* x, vtype_int32 key, const vtype_array* value); -extern bool libcdsb_map_update_int32_list (vtype_map* x, vtype_int32 key, const vtype_list* value); -extern bool libcdsb_map_update_int32_map (vtype_map* x, vtype_int32 key, const vtype_map* value); -extern bool libcdsb_map_update_int32_vset (vtype_map* x, vtype_int32 key, const vtype_set* value); -extern bool libcdsb_map_update_int32_dict (vtype_map* x, vtype_int32 key, const vtype_dict* value); -extern bool libcdsb_map_update_int32_boolean(vtype_map* x, vtype_int32 key, vtype_bool value); -extern bool libcdsb_map_update_int32_int8 (vtype_map* x, vtype_int32 key, vtype_int8 value); -extern bool libcdsb_map_update_int32_int16 (vtype_map* x, vtype_int32 key, vtype_int16 value); -extern bool libcdsb_map_update_int32_int32 (vtype_map* x, vtype_int32 key, vtype_int32 value); -extern bool libcdsb_map_update_int32_int64 (vtype_map* x, vtype_int32 key, vtype_int64 value); -extern bool libcdsb_map_update_int32_uint8 (vtype_map* x, vtype_int32 key, vtype_uint8 value); -extern bool libcdsb_map_update_int32_uint16 (vtype_map* x, vtype_int32 key, vtype_uint16 value); -extern bool libcdsb_map_update_int32_uint32 (vtype_map* x, vtype_int32 key, vtype_uint32 value); -extern bool libcdsb_map_update_int32_uint64 (vtype_map* x, vtype_int32 key, vtype_uint64 value); -extern bool libcdsb_map_update_int32_float (vtype_map* x, vtype_int32 key, vtype_float value); -extern bool libcdsb_map_update_int32_double (vtype_map* x, vtype_int32 key, vtype_double value); -extern bool libcdsb_map_update_int32_ldouble(vtype_map* x, vtype_int32 key, vtype_ldouble value); +extern bool libcdsb_map_update_int32_pointer(vtype_map* x, vtype_int32 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_int32_cstring(vtype_map* x, vtype_int32 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_string (vtype_map* x, vtype_int32 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_array (vtype_map* x, vtype_int32 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_list (vtype_map* x, vtype_int32 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_map (vtype_map* x, vtype_int32 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_vset (vtype_map* x, vtype_int32 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_dict (vtype_map* x, vtype_int32 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int32_boolean(vtype_map* x, vtype_int32 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_int32_int8 (vtype_map* x, vtype_int32 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_int16 (vtype_map* x, vtype_int32 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_int32 (vtype_map* x, vtype_int32 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_int64 (vtype_map* x, vtype_int32 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_uint8 (vtype_map* x, vtype_int32 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_uint16 (vtype_map* x, vtype_int32 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_uint32 (vtype_map* x, vtype_int32 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_uint64 (vtype_map* x, vtype_int32 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_int32_float (vtype_map* x, vtype_int32 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_int32_double (vtype_map* x, vtype_int32 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_int32_ldouble(vtype_map* x, vtype_int32 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_int64_pointer(vtype_map* x, vtype_int64 key, const void* value); -extern bool libcdsb_map_update_int64_cstring(vtype_map* x, vtype_int64 key, const char* value); -extern bool libcdsb_map_update_int64_string (vtype_map* x, vtype_int64 key, const vtype_string* value); -extern bool libcdsb_map_update_int64_array (vtype_map* x, vtype_int64 key, const vtype_array* value); -extern bool libcdsb_map_update_int64_list (vtype_map* x, vtype_int64 key, const vtype_list* value); -extern bool libcdsb_map_update_int64_map (vtype_map* x, vtype_int64 key, const vtype_map* value); -extern bool libcdsb_map_update_int64_vset (vtype_map* x, vtype_int64 key, const vtype_set* value); -extern bool libcdsb_map_update_int64_dict (vtype_map* x, vtype_int64 key, const vtype_dict* value); -extern bool libcdsb_map_update_int64_boolean(vtype_map* x, vtype_int64 key, vtype_bool value); -extern bool libcdsb_map_update_int64_int8 (vtype_map* x, vtype_int64 key, vtype_int8 value); -extern bool libcdsb_map_update_int64_int16 (vtype_map* x, vtype_int64 key, vtype_int16 value); -extern bool libcdsb_map_update_int64_int32 (vtype_map* x, vtype_int64 key, vtype_int32 value); -extern bool libcdsb_map_update_int64_int64 (vtype_map* x, vtype_int64 key, vtype_int64 value); -extern bool libcdsb_map_update_int64_uint8 (vtype_map* x, vtype_int64 key, vtype_uint8 value); -extern bool libcdsb_map_update_int64_uint16 (vtype_map* x, vtype_int64 key, vtype_uint16 value); -extern bool libcdsb_map_update_int64_uint32 (vtype_map* x, vtype_int64 key, vtype_uint32 value); -extern bool libcdsb_map_update_int64_uint64 (vtype_map* x, vtype_int64 key, vtype_uint64 value); -extern bool libcdsb_map_update_int64_float (vtype_map* x, vtype_int64 key, vtype_float value); -extern bool libcdsb_map_update_int64_double (vtype_map* x, vtype_int64 key, vtype_double value); -extern bool libcdsb_map_update_int64_ldouble(vtype_map* x, vtype_int64 key, vtype_ldouble value); +extern bool libcdsb_map_update_int64_pointer(vtype_map* x, vtype_int64 key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_int64_cstring(vtype_map* x, vtype_int64 key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_string (vtype_map* x, vtype_int64 key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_array (vtype_map* x, vtype_int64 key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_list (vtype_map* x, vtype_int64 key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_map (vtype_map* x, vtype_int64 key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_vset (vtype_map* x, vtype_int64 key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_dict (vtype_map* x, vtype_int64 key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_int64_boolean(vtype_map* x, vtype_int64 key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_int64_int8 (vtype_map* x, vtype_int64 key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_int16 (vtype_map* x, vtype_int64 key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_int32 (vtype_map* x, vtype_int64 key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_int64 (vtype_map* x, vtype_int64 key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_uint8 (vtype_map* x, vtype_int64 key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_uint16 (vtype_map* x, vtype_int64 key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_uint32 (vtype_map* x, vtype_int64 key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_uint64 (vtype_map* x, vtype_int64 key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_int64_float (vtype_map* x, vtype_int64 key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_int64_double (vtype_map* x, vtype_int64 key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_int64_ldouble(vtype_map* x, vtype_int64 key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_float_pointer(vtype_map* x, vtype_float key, const void* value); -extern bool libcdsb_map_update_float_cstring(vtype_map* x, vtype_float key, const char* value); -extern bool libcdsb_map_update_float_string (vtype_map* x, vtype_float key, const vtype_string* value); -extern bool libcdsb_map_update_float_array (vtype_map* x, vtype_float key, const vtype_array* value); -extern bool libcdsb_map_update_float_list (vtype_map* x, vtype_float key, const vtype_list* value); -extern bool libcdsb_map_update_float_map (vtype_map* x, vtype_float key, const vtype_map* value); -extern bool libcdsb_map_update_float_vset (vtype_map* x, vtype_float key, const vtype_set* value); -extern bool libcdsb_map_update_float_dict (vtype_map* x, vtype_float key, const vtype_dict* value); -extern bool libcdsb_map_update_float_boolean(vtype_map* x, vtype_float key, vtype_bool value); -extern bool libcdsb_map_update_float_int8 (vtype_map* x, vtype_float key, vtype_int8 value); -extern bool libcdsb_map_update_float_int16 (vtype_map* x, vtype_float key, vtype_int16 value); -extern bool libcdsb_map_update_float_int32 (vtype_map* x, vtype_float key, vtype_int32 value); -extern bool libcdsb_map_update_float_int64 (vtype_map* x, vtype_float key, vtype_int64 value); -extern bool libcdsb_map_update_float_uint8 (vtype_map* x, vtype_float key, vtype_uint8 value); -extern bool libcdsb_map_update_float_uint16 (vtype_map* x, vtype_float key, vtype_uint16 value); -extern bool libcdsb_map_update_float_uint32 (vtype_map* x, vtype_float key, vtype_uint32 value); -extern bool libcdsb_map_update_float_uint64 (vtype_map* x, vtype_float key, vtype_uint64 value); -extern bool libcdsb_map_update_float_float (vtype_map* x, vtype_float key, vtype_float value); -extern bool libcdsb_map_update_float_double (vtype_map* x, vtype_float key, vtype_double value); -extern bool libcdsb_map_update_float_ldouble(vtype_map* x, vtype_float key, vtype_ldouble value); +extern bool libcdsb_map_update_float_pointer(vtype_map* x, vtype_float key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_float_cstring(vtype_map* x, vtype_float key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_string (vtype_map* x, vtype_float key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_array (vtype_map* x, vtype_float key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_list (vtype_map* x, vtype_float key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_map (vtype_map* x, vtype_float key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_vset (vtype_map* x, vtype_float key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_dict (vtype_map* x, vtype_float key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_float_boolean(vtype_map* x, vtype_float key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_float_int8 (vtype_map* x, vtype_float key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_float_int16 (vtype_map* x, vtype_float key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_float_int32 (vtype_map* x, vtype_float key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_float_int64 (vtype_map* x, vtype_float key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_float_uint8 (vtype_map* x, vtype_float key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_float_uint16 (vtype_map* x, vtype_float key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_float_uint32 (vtype_map* x, vtype_float key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_float_uint64 (vtype_map* x, vtype_float key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_float_float (vtype_map* x, vtype_float key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_float_double (vtype_map* x, vtype_float key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_float_ldouble(vtype_map* x, vtype_float key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_double_pointer(vtype_map* x, vtype_double key, const void* value); -extern bool libcdsb_map_update_double_cstring(vtype_map* x, vtype_double key, const char* value); -extern bool libcdsb_map_update_double_string (vtype_map* x, vtype_double key, const vtype_string* value); -extern bool libcdsb_map_update_double_array (vtype_map* x, vtype_double key, const vtype_array* value); -extern bool libcdsb_map_update_double_list (vtype_map* x, vtype_double key, const vtype_list* value); -extern bool libcdsb_map_update_double_map (vtype_map* x, vtype_double key, const vtype_map* value); -extern bool libcdsb_map_update_double_vset (vtype_map* x, vtype_double key, const vtype_set* value); -extern bool libcdsb_map_update_double_dict (vtype_map* x, vtype_double key, const vtype_dict* value); -extern bool libcdsb_map_update_double_boolean(vtype_map* x, vtype_double key, vtype_bool value); -extern bool libcdsb_map_update_double_int8 (vtype_map* x, vtype_double key, vtype_int8 value); -extern bool libcdsb_map_update_double_int16 (vtype_map* x, vtype_double key, vtype_int16 value); -extern bool libcdsb_map_update_double_int32 (vtype_map* x, vtype_double key, vtype_int32 value); -extern bool libcdsb_map_update_double_int64 (vtype_map* x, vtype_double key, vtype_int64 value); -extern bool libcdsb_map_update_double_uint8 (vtype_map* x, vtype_double key, vtype_uint8 value); -extern bool libcdsb_map_update_double_uint16 (vtype_map* x, vtype_double key, vtype_uint16 value); -extern bool libcdsb_map_update_double_uint32 (vtype_map* x, vtype_double key, vtype_uint32 value); -extern bool libcdsb_map_update_double_uint64 (vtype_map* x, vtype_double key, vtype_uint64 value); -extern bool libcdsb_map_update_double_float (vtype_map* x, vtype_double key, vtype_float value); -extern bool libcdsb_map_update_double_double (vtype_map* x, vtype_double key, vtype_double value); -extern bool libcdsb_map_update_double_ldouble(vtype_map* x, vtype_double key, vtype_ldouble value); +extern bool libcdsb_map_update_double_pointer(vtype_map* x, vtype_double key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_double_cstring(vtype_map* x, vtype_double key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_string (vtype_map* x, vtype_double key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_array (vtype_map* x, vtype_double key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_list (vtype_map* x, vtype_double key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_map (vtype_map* x, vtype_double key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_vset (vtype_map* x, vtype_double key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_dict (vtype_map* x, vtype_double key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_double_boolean(vtype_map* x, vtype_double key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_double_int8 (vtype_map* x, vtype_double key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_double_int16 (vtype_map* x, vtype_double key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_double_int32 (vtype_map* x, vtype_double key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_double_int64 (vtype_map* x, vtype_double key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_double_uint8 (vtype_map* x, vtype_double key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_double_uint16 (vtype_map* x, vtype_double key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_double_uint32 (vtype_map* x, vtype_double key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_double_uint64 (vtype_map* x, vtype_double key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_double_float (vtype_map* x, vtype_double key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_double_double (vtype_map* x, vtype_double key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_double_ldouble(vtype_map* x, vtype_double key, vtype_ldouble value) Nonnull__(1); -extern bool libcdsb_map_update_ldouble_pointer(vtype_map* x, vtype_ldouble key, const void* value); -extern bool libcdsb_map_update_ldouble_cstring(vtype_map* x, vtype_ldouble key, const char* value); -extern bool libcdsb_map_update_ldouble_string (vtype_map* x, vtype_ldouble key, const vtype_string* value); -extern bool libcdsb_map_update_ldouble_array (vtype_map* x, vtype_ldouble key, const vtype_array* value); -extern bool libcdsb_map_update_ldouble_list (vtype_map* x, vtype_ldouble key, const vtype_list* value); -extern bool libcdsb_map_update_ldouble_map (vtype_map* x, vtype_ldouble key, const vtype_map* value); -extern bool libcdsb_map_update_ldouble_vset (vtype_map* x, vtype_ldouble key, const vtype_set* value); -extern bool libcdsb_map_update_ldouble_dict (vtype_map* x, vtype_ldouble key, const vtype_dict* value); -extern bool libcdsb_map_update_ldouble_boolean(vtype_map* x, vtype_ldouble key, vtype_bool value); -extern bool libcdsb_map_update_ldouble_int8 (vtype_map* x, vtype_ldouble key, vtype_int8 value); -extern bool libcdsb_map_update_ldouble_int16 (vtype_map* x, vtype_ldouble key, vtype_int16 value); -extern bool libcdsb_map_update_ldouble_int32 (vtype_map* x, vtype_ldouble key, vtype_int32 value); -extern bool libcdsb_map_update_ldouble_int64 (vtype_map* x, vtype_ldouble key, vtype_int64 value); -extern bool libcdsb_map_update_ldouble_uint8 (vtype_map* x, vtype_ldouble key, vtype_uint8 value); -extern bool libcdsb_map_update_ldouble_uint16 (vtype_map* x, vtype_ldouble key, vtype_uint16 value); -extern bool libcdsb_map_update_ldouble_uint32 (vtype_map* x, vtype_ldouble key, vtype_uint32 value); -extern bool libcdsb_map_update_ldouble_uint64 (vtype_map* x, vtype_ldouble key, vtype_uint64 value); -extern bool libcdsb_map_update_ldouble_float (vtype_map* x, vtype_ldouble key, vtype_float value); -extern bool libcdsb_map_update_ldouble_double (vtype_map* x, vtype_ldouble key, vtype_double value); -extern bool libcdsb_map_update_ldouble_ldouble(vtype_map* x, vtype_ldouble key, vtype_ldouble value); +extern bool libcdsb_map_update_ldouble_pointer(vtype_map* x, vtype_ldouble key, const void* value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_cstring(vtype_map* x, vtype_ldouble key, const char* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_string (vtype_map* x, vtype_ldouble key, const vtype_string* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_array (vtype_map* x, vtype_ldouble key, const vtype_array* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_list (vtype_map* x, vtype_ldouble key, const vtype_list* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_map (vtype_map* x, vtype_ldouble key, const vtype_map* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_vset (vtype_map* x, vtype_ldouble key, const vtype_set* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_dict (vtype_map* x, vtype_ldouble key, const vtype_dict* value) Nonnull__(1,3); +extern bool libcdsb_map_update_ldouble_boolean(vtype_map* x, vtype_ldouble key, vtype_bool value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_int8 (vtype_map* x, vtype_ldouble key, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_int16 (vtype_map* x, vtype_ldouble key, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_int32 (vtype_map* x, vtype_ldouble key, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_int64 (vtype_map* x, vtype_ldouble key, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_uint8 (vtype_map* x, vtype_ldouble key, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_uint16 (vtype_map* x, vtype_ldouble key, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_uint32 (vtype_map* x, vtype_ldouble key, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_uint64 (vtype_map* x, vtype_ldouble key, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_float (vtype_map* x, vtype_ldouble key, vtype_float value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_double (vtype_map* x, vtype_ldouble key, vtype_double value) Nonnull__(1); +extern bool libcdsb_map_update_ldouble_ldouble(vtype_map* x, vtype_ldouble key, vtype_ldouble value) Nonnull__(1); #endif /* LIBCDSB_MAP_H */ diff --git a/include/set.h b/include/set.h index a008e54..2ea5c92 100644 --- a/include/set.h +++ b/include/set.h @@ -9,53 +9,53 @@ typedef int (*vset_access_callback)(const void* value, vtype type, void* data); -extern void vset_init(vtype_set* x, vtype type); +extern void vset_init(vtype_set* x, vtype type) Nonnull__(1); #define vset_remove(x, value) _LIBCDSB_Generic (libcdsb_vset, touch, value)(x, value, 1) #define vset_push(x, value) _LIBCDSB_Generic (libcdsb_vset, push, value)(x, value) #define in_vset(x, value) _LIBCDSB_Generic (libcdsb_vset, touch, value)(x, value, 0) -extern bool libcdsb_vset_push_pointer(vtype_set* x, const void* value); -extern bool libcdsb_vset_push_cstring(vtype_set* x, const char* value); -extern bool libcdsb_vset_push_string (vtype_set* x, const vtype_string* value); -extern bool libcdsb_vset_push_array (vtype_set* x, const vtype_array* value); -extern bool libcdsb_vset_push_list (vtype_set* x, const vtype_list* value); -extern bool libcdsb_vset_push_map (vtype_set* x, const vtype_map* value); -extern bool libcdsb_vset_push_vset (vtype_set* x, const vtype_set* value); -extern bool libcdsb_vset_push_dict (vtype_set* x, const vtype_dict* value); -extern bool libcdsb_vset_push_boolean(vtype_set* x, vtype_bool value); -extern bool libcdsb_vset_push_uint8 (vtype_set* x, vtype_uint8 value); -extern bool libcdsb_vset_push_uint16 (vtype_set* x, vtype_uint16 value); -extern bool libcdsb_vset_push_uint32 (vtype_set* x, vtype_uint32 value); -extern bool libcdsb_vset_push_uint64 (vtype_set* x, vtype_uint64 value); -extern bool libcdsb_vset_push_int8 (vtype_set* x, vtype_int8 value); -extern bool libcdsb_vset_push_int16 (vtype_set* x, vtype_int16 value); -extern bool libcdsb_vset_push_int32 (vtype_set* x, vtype_int32 value); -extern bool libcdsb_vset_push_int64 (vtype_set* x, vtype_int64 value); -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_push_pointer(vtype_set* x, const void* value) Nonnull__(1); +extern bool libcdsb_vset_push_cstring(vtype_set* x, const char* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_string (vtype_set* x, const vtype_string* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_array (vtype_set* x, const vtype_array* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_list (vtype_set* x, const vtype_list* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_map (vtype_set* x, const vtype_map* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_vset (vtype_set* x, const vtype_set* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_dict (vtype_set* x, const vtype_dict* value) Nonnull__(1,2); +extern bool libcdsb_vset_push_boolean(vtype_set* x, vtype_bool value) Nonnull__(1); +extern bool libcdsb_vset_push_uint8 (vtype_set* x, vtype_uint8 value) Nonnull__(1); +extern bool libcdsb_vset_push_uint16 (vtype_set* x, vtype_uint16 value) Nonnull__(1); +extern bool libcdsb_vset_push_uint32 (vtype_set* x, vtype_uint32 value) Nonnull__(1); +extern bool libcdsb_vset_push_uint64 (vtype_set* x, vtype_uint64 value) Nonnull__(1); +extern bool libcdsb_vset_push_int8 (vtype_set* x, vtype_int8 value) Nonnull__(1); +extern bool libcdsb_vset_push_int16 (vtype_set* x, vtype_int16 value) Nonnull__(1); +extern bool libcdsb_vset_push_int32 (vtype_set* x, vtype_int32 value) Nonnull__(1); +extern bool libcdsb_vset_push_int64 (vtype_set* x, vtype_int64 value) Nonnull__(1); +extern bool libcdsb_vset_push_float (vtype_set* x, vtype_float value) Nonnull__(1); +extern bool libcdsb_vset_push_double (vtype_set* x, vtype_double value) Nonnull__(1); +extern bool libcdsb_vset_push_ldouble(vtype_set* x, vtype_ldouble value) Nonnull__(1); -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_dict (vtype_set* x, const vtype_dict* 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); +extern int libcdsb_vset_find_pointer(vtype_set* x, const void* value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_cstring(vtype_set* x, const char* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_string (vtype_set* x, const vtype_string* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_array (vtype_set* x, const vtype_array* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_list (vtype_set* x, const vtype_list* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_map (vtype_set* x, const vtype_map* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_vset (vtype_set* x, const vtype_set* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_dict (vtype_set* x, const vtype_dict* value, void* data, vset_access_callback, bool cut) Nonnull__(1,2); +extern int libcdsb_vset_find_boolean(vtype_set* x, vtype_bool value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_uint8 (vtype_set* x, vtype_uint8 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_uint16 (vtype_set* x, vtype_uint16 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_uint32 (vtype_set* x, vtype_uint32 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_uint64 (vtype_set* x, vtype_uint64 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_int8 (vtype_set* x, vtype_int8 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_int16 (vtype_set* x, vtype_int16 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_int32 (vtype_set* x, vtype_int32 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_int64 (vtype_set* x, vtype_int64 value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_float (vtype_set* x, vtype_float value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_double (vtype_set* x, vtype_double value, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_find_ldouble(vtype_set* x, vtype_ldouble value, void* data, vset_access_callback, bool cut) Nonnull__(1); #endif /* LIBCDSB_SET_H */ diff --git a/include/string.h b/include/string.h index 6586852..aeb51fd 100644 --- a/include/string.h +++ b/include/string.h @@ -10,10 +10,10 @@ /*#####################################################################################################################*/ -extern void string_init(vtype_string* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__; +extern void string_init(vtype_string* x, const char* value) Nonnull__(1); -extern char* string_at(const vtype_string* s, ssize_t index) LIBCDSB_nt__ LIBCDSB_nn1__; -extern bool string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_t nchars, bool cut) LIBCDSB_nt__ LIBCDSB_nn12__; +extern char* string_at(const vtype_string* s, ssize_t index) Nonnull__(1); +extern bool string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_t nchars, bool cut) Nonnull__(1,2); #define string_indexof(s, arg) _LIBCDSB_GenericS(libcdsb_string, indexof, arg)(s, arg) #define string_count(s, arg) _LIBCDSB_GenericS(libcdsb_string, count, arg)(s, arg) @@ -27,29 +27,29 @@ extern bool string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_t /*#####################################################################################################################*/ -inline ssize_t libcdsb_string_indexof_string (const vtype_string* s, const vtype_string* arg) __attribute__((always_inline)); -extern ssize_t libcdsb_string_indexof_cstring(const vtype_string* s, const char* arg) LIBCDSB_pure__ LIBCDSB_nn1__; -extern ssize_t libcdsb_string_indexof_char (const vtype_string* s, int arg) LIBCDSB_pure__ LIBCDSB_nn1__; +inline ssize_t libcdsb_string_indexof_string (const vtype_string* s, const vtype_string* arg) Pure__ Warn_unused_result__ Nonnull__(1) Always_inline__; +extern ssize_t libcdsb_string_indexof_cstring(const vtype_string* s, const char* arg) Pure__ Warn_unused_result__ Nonnull__(1); +extern ssize_t libcdsb_string_indexof_char (const vtype_string* s, int arg) Pure__ Warn_unused_result__ Nonnull__(1); -inline size_t libcdsb_string_count_string (const vtype_string* s, const vtype_string* arg) __attribute__((always_inline)); -extern size_t libcdsb_string_count_cstring(const vtype_string* s, const char* arg) LIBCDSB_pure__ LIBCDSB_nn1__; -extern size_t libcdsb_string_count_char (const vtype_string* s, int arg) LIBCDSB_pure__ LIBCDSB_nn1__; +inline size_t libcdsb_string_count_string (const vtype_string* s, const vtype_string* arg) Pure__ Warn_unused_result__ Nonnull__(1) Always_inline__; +extern size_t libcdsb_string_count_cstring(const vtype_string* s, const char* arg) Pure__ Warn_unused_result__ Nonnull__(1); +extern size_t libcdsb_string_count_char (const vtype_string* s, int arg) Pure__ Warn_unused_result__ Nonnull__(1); -inline bool libcdsb_string_concat_string (vtype_string* x, const vtype_string* value) __attribute__((always_inline)); -extern bool libcdsb_string_concat_cstring(vtype_string* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__; -extern bool libcdsb_string_concat_char (vtype_string* x, int value) LIBCDSB_nt__ LIBCDSB_nn1__; +inline bool libcdsb_string_concat_string (vtype_string* x, const vtype_string* value) Nonnull__(1) Always_inline__; +extern bool libcdsb_string_concat_cstring(vtype_string* x, const char* value) Nonnull__(1); +extern bool libcdsb_string_concat_char (vtype_string* x, int value) Nonnull__(1); -extern void libcdsb_string_trim_spaces(vtype_string* x, int direction) LIBCDSB_nt__ LIBCDSB_nn1__; +extern void libcdsb_string_trim_spaces(vtype_string* x, int direction) Nonnull__(1); -inline size_t libcdsb_string_replace_string_string (vtype_string* x, const vtype_string* src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_string_cstring (vtype_string* x, const vtype_string* src, const char* dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_string_char (vtype_string* x, const vtype_string* src, int dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_cstring_string (vtype_string* x, const char* src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_cstring_cstring(vtype_string* x, const char* src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t libcdsb_string_replace_cstring_char (vtype_string* x, const char* src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -inline size_t libcdsb_string_replace_char_string (vtype_string* x, int src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_char_cstring (vtype_string* x, int src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t libcdsb_string_replace_char_char (vtype_string* x, int src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_string_string (vtype_string* x, const vtype_string* src, const vtype_string* dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_string_cstring (vtype_string* x, const vtype_string* src, const char* dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_string_char (vtype_string* x, const vtype_string* src, int dest, size_t maxn) Nonnull__(1) Always_inline__; +inline size_t libcdsb_string_replace_cstring_string (vtype_string* x, const char* src, const vtype_string* dest, size_t maxn) Nonnull__(1) Always_inline__; +extern size_t libcdsb_string_replace_cstring_cstring(vtype_string* x, const char* src, const char* dest, size_t maxn) Nonnull__(1); +extern size_t libcdsb_string_replace_cstring_char (vtype_string* x, const char* src, int dest, size_t maxn) Nonnull__(1); +inline size_t libcdsb_string_replace_char_string (vtype_string* x, int src, const vtype_string* dest, size_t maxn) Nonnull__(1) Always_inline__; +extern size_t libcdsb_string_replace_char_cstring (vtype_string* x, int src, const char* dest, size_t maxn) Nonnull__(1); +extern size_t libcdsb_string_replace_char_char (vtype_string* x, int src, int dest, size_t maxn) Nonnull__(1); /*#####################################################################################################################*/ diff --git a/include/vtype.h b/include/vtype.h index 8aae269..8238a19 100644 --- a/include/vtype.h +++ b/include/vtype.h @@ -62,7 +62,7 @@ typedef float vtype_float; typedef double vtype_double; typedef long double vtype_ldouble; -typedef uint_least64_t vtype_hash; +typedef size_t vtype_hash; typedef struct libcdsb_array vtype_array; typedef struct libcdsb_map vtype_map; @@ -73,76 +73,75 @@ typedef struct libcdsb_string vtype_string; /* Get utf8 chars count in string */ -extern size_t string_size(const vtype_string* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t string_size(const vtype_string* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get string size in bytes */ -extern size_t string_nmemb(const vtype_string* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t string_nmemb(const vtype_string* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the array elements */ -extern size_t array_size(const vtype_array* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t array_size(const vtype_array* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get array size in bytes */ -extern size_t array_nmemb(const vtype_array* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t array_nmemb(const vtype_array* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the list elements */ -extern size_t list_size(const vtype_list* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t list_size(const vtype_list* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the map elements */ -extern size_t map_size(const vtype_map* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t map_size(const vtype_map* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the set elements */ -extern size_t vset_size(const vtype_set* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t vset_size(const vtype_set* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the dict elements */ -extern size_t dict_size(const vtype_dict* x) LIBCDSB_pure__ LIBCDSB_nn1__; +extern size_t dict_size(const vtype_dict* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Get count of the available nodes */ -extern size_t dict_capacity(const vtype_dict* x) LIBCDSB_pure__ LIBCDSB_nn1__; - +extern size_t dict_capacity(const vtype_dict* x) Pure__ Warn_unused_result__ Nonnull__(1); /* Cpmpare 2 strings */ -extern int string_compare(const vtype_string* s0, const vtype_string* s1) LIBCDSB_cmpattr__; +extern int string_compare(const vtype_string* s0, const vtype_string* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Compare 2 arrays */ -extern int array_compare(const vtype_array* s0, const vtype_array* s1) LIBCDSB_cmpattr__; +extern int array_compare(const vtype_array* s0, const vtype_array* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Compare 2 lists */ -extern int list_compare(const vtype_list* s0, const vtype_list* s1) LIBCDSB_cmpattr__; +extern int list_compare(const vtype_list* s0, const vtype_list* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Compare 2 maps */ -extern int map_compare(const vtype_map* s0, const vtype_map* s1) LIBCDSB_cmpattr__; +extern int map_compare(const vtype_map* s0, const vtype_map* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Compare 2 sets */ -extern int vset_compare(const vtype_set* s0, const vtype_set* s1) LIBCDSB_cmpattr__; +extern int vset_compare(const vtype_set* s0, const vtype_set* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Compare 2 dicts */ -extern int dict_compare(const vtype_dict* s0, const vtype_dict* s1) LIBCDSB_cmpattr__; +extern int dict_compare(const vtype_dict* s0, const vtype_dict* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); /* Copy string to another */ -extern vtype_string string_copy(const vtype_string* s) LIBCDSB_cpyattr__; +extern vtype_string string_copy(const vtype_string* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Copy array to another */ -extern vtype_array array_copy(const vtype_array* s) LIBCDSB_cpyattr__; +extern vtype_array array_copy(const vtype_array* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Copy list to another */ -extern vtype_list list_copy(const vtype_list* s) LIBCDSB_cpyattr__; +extern vtype_list list_copy(const vtype_list* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Copy map to another */ -extern vtype_map map_copy(const vtype_map* s) LIBCDSB_cpyattr__; +extern vtype_map map_copy(const vtype_map* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Copy set to another */ -extern vtype_set vset_copy(const vtype_set* s) LIBCDSB_cpyattr__; +extern vtype_set vset_copy(const vtype_set* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Copy set to another */ -extern vtype_dict dict_copy(const vtype_dict* s) LIBCDSB_cpyattr__; +extern vtype_dict dict_copy(const vtype_dict* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Duplicate string memory block */ -extern vtype_string* string_duplicate(const vtype_string* s) LIBCDSB_dupattr__; +extern vtype_string* string_duplicate(const vtype_string* s) Warn_unused_result__ Nonnull__(1); /* Duplicate array memory block */ -extern vtype_array* array_duplicate(const vtype_array* s) LIBCDSB_dupattr__; +extern vtype_array* array_duplicate(const vtype_array* s) Warn_unused_result__ Nonnull__(1); /* Duplicate list memory block */ -extern vtype_list* list_duplicate(const vtype_list* s) LIBCDSB_dupattr__; +extern vtype_list* list_duplicate(const vtype_list* s) Warn_unused_result__ Nonnull__(1); /* Duplicate map memory block */ -extern vtype_map* map_duplicate(const vtype_map* s) LIBCDSB_dupattr__; +extern vtype_map* map_duplicate(const vtype_map* s) Warn_unused_result__ Nonnull__(1); /* Duplicate set memory block */ -extern vtype_set* vset_duplicate(const vtype_set* s) LIBCDSB_dupattr__; +extern vtype_set* vset_duplicate(const vtype_set* s) Warn_unused_result__ Nonnull__(1); /* Duplicate dict memory block */ -extern vtype_dict* dict_duplicate(const vtype_dict* s) LIBCDSB_dupattr__; +extern vtype_dict* dict_duplicate(const vtype_dict* s) Warn_unused_result__ Nonnull__(1); /* Copy string and store result to the memory block */ -extern void string_copy_init(vtype_string* x, const vtype_string* s) LIBCDSB_nn12__; +extern void string_copy_init(vtype_string* x, const vtype_string* s) Nonnull__(1,2); /* Copy array and store result to the memory block */ -extern void array_copy_init(vtype_array* x, const vtype_array* s) LIBCDSB_nn12__; +extern void array_copy_init(vtype_array* x, const vtype_array* s) Nonnull__(1,2); /* Copy list and store result to the memory block */ -extern void list_copy_init(vtype_list* x, const vtype_list* s) LIBCDSB_nn12__; +extern void list_copy_init(vtype_list* x, const vtype_list* s) Nonnull__(1,2); /* Copy map and store result to the memory block */ -extern void map_copy_init(vtype_map* x, const vtype_map* s) LIBCDSB_nn12__; +extern void map_copy_init(vtype_map* x, const vtype_map* s) Nonnull__(1,2); /* Copy set and store result to the memory block */ -extern void vset_copy_init(vtype_set* x, const vtype_set* s) LIBCDSB_nn12__; +extern void vset_copy_init(vtype_set* x, const vtype_set* s) Nonnull__(1,2); /* Copy dict and store result to the memory block */ -extern void dict_copy_init(vtype_dict* x, const vtype_dict* s) LIBCDSB_nn12__; +extern void dict_copy_init(vtype_dict* x, const vtype_dict* s) Nonnull__(1,2); /* Free string resources */ extern void string_free(vtype_string* x); @@ -158,17 +157,16 @@ extern void vset_free(vtype_set* x); extern void dict_free(vtype_dict* x); /* Get hash of the string */ -extern vtype_hash string_hash(const vtype_string* s) LIBCDSB_nn1__; +extern vtype_hash string_hash(const vtype_string* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Get hash of the array */ -extern vtype_hash array_hash(const vtype_array* s) LIBCDSB_nn1__; +extern vtype_hash array_hash(const vtype_array* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Get hash of the list */ -extern vtype_hash list_hash(const vtype_list* s) LIBCDSB_nn1__; +extern vtype_hash list_hash(const vtype_list* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Get hash of the map */ -extern vtype_hash map_hash(const vtype_map* s) LIBCDSB_nn1__; +extern vtype_hash map_hash(const vtype_map* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Get hash of the set */ -extern vtype_hash vset_hash(const vtype_set* s) LIBCDSB_nn1__; +extern vtype_hash vset_hash(const vtype_set* s) Pure__ Warn_unused_result__ Nonnull__(1); /* Get hash of the dict */ -extern vtype_hash dict_hash(const vtype_dict* s) LIBCDSB_nn1__; - +extern vtype_hash dict_hash(const vtype_dict* s) Pure__ Warn_unused_result__ Nonnull__(1); #endif /* LIBCDSB_VTYPE_H */ diff --git a/src/__internal/__attributes.h b/src/__internal/__attributes.h index 5892c90..85d74b0 100644 --- a/src/__internal/__attributes.h +++ b/src/__internal/__attributes.h @@ -3,11 +3,10 @@ #include "../../include/__attributes.h" -#define throw__ HHTTPC_nt__ -#define pure__ HHTTPC_pure__ -#define const__ __attribute__((const)) HHTTPC_nt__ -#define leaf__ __attribute__((leaf)) HHTTPC_nt__ -#define wur__ HHTTPC_wur__ -#define inline__ __attribute__((always_inline)) +#define pure__ Pure__ +#define const__ __attribute__((const)) +#define leaf__ __attribute__((leaf)) +#define wur__ Warn_unused_result__ +#define inline__ Always_inline__ #define ainline(...) inline __VA_ARGS__ inline__; inline __VA_ARGS__ diff --git a/src/__internal/include.h b/src/__internal/include.h index 562bde3..76f096d 100644 --- a/src/__internal/include.h +++ b/src/__internal/include.h @@ -62,10 +62,9 @@ typedef vtype_dict dict_t; typedef vtype_hash hash_t; -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); - -extern hash_t libcdsb_vtype_hash(const void* value, vtype type); +extern int libcdsb_vtype_compare_values (const void* s0, vtype t0, const void* s1, vtype t1) pure__ wur__; +extern int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) pure__ wur__; +extern hash_t libcdsb_vtype_hash (const void* value, vtype type) pure__ wur__; #define vtype_stringify libcdsb_vtype_stringify #define vtype_name libcdsb_vtype_name diff --git a/src/__internal/rbtree.h b/src/__internal/rbtree.h index 0db10a0..c9db416 100644 --- a/src/__internal/rbtree.h +++ b/src/__internal/rbtree.h @@ -17,9 +17,9 @@ typedef struct libcdsb_rbtree_node { extern rbnode_t LIBCDSB_RBTREE_NODE_EMPTY[1]; -extern void* libcdsb_rbtree_node_create(void* value, rbnode_t* parent, int colored, int size); -extern void libcdsb_rbtree_node_fixup (rbnode_t** root, rbnode_t* node); -extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node); +extern void* libcdsb_rbtree_node_create(void* value, rbnode_t* parent, int colored, int size) Nonnull__(1,2); +extern void libcdsb_rbtree_node_fixup (rbnode_t** root, rbnode_t* node) Nonnull__(1,2); +extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node) Nonnull__(1,2); #define rbnode_empty ((rbnode_t*)LIBCDSB_RBTREE_NODE_EMPTY) #define rbnode_create(v, p, c) ((rbnode_t*)libcdsb_rbtree_node_create(v, p, c, sizeof(rbnode_t))) @@ -29,13 +29,12 @@ extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node); #define rbnode_is_empty(n) ((n) == rbnode_empty) #define rbnode_is_root(n) rbnode_is_empty((n)->parent) +extern void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info) wur__ Nonnull__(1); +extern int libcdsb_rbtree_compare (const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info) pure__ wur__ Nonnull__(1,2); -extern void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info); -extern int libcdsb_rbtree_compare(const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info); - -extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info); -extern size_t libcdsb_rbtree_size(const void* s); -extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info); +extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) pure__ wur__ Nonnull__(1,2); +extern size_t libcdsb_rbtree_size(const void* s) pure__ wur__ Nonnull__(1); +extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) Nonnull__(1); #define rbtree_duplicate libcdsb_rbtree_duplicate #define rbtree_compare libcdsb_rbtree_compare @@ -43,5 +42,4 @@ extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info #define rbtree_size libcdsb_rbtree_size #define rbtree_free libcdsb_rbtree_free - #endif /* LIBCDSB_SRC_INTERNAL_RBTREE_H */ diff --git a/src/__internal/vnode.h b/src/__internal/vnode.h index 3ff99c3..c7a5d95 100644 --- a/src/__internal/vnode.h +++ b/src/__internal/vnode.h @@ -18,11 +18,11 @@ typedef union { typedef void* vnode_t; -extern vnode_t libcdsb_vnode_create(const void* value, vtype type); -extern vnode_t libcdsb_vnode_create_target(vtype target_type, const void* value, vtype type); +extern vnode_t libcdsb_vnode_create (const void* value, vtype type) wur__; +extern vnode_t libcdsb_vnode_create_target(vtype target_type, const void* value, vtype type) wur__; -extern void libcdsb_vnode_free(vnode_t* x, vtype type); -extern void* libcdsb_vnode_peek(const vnode_t* x, vtype type); +extern void libcdsb_vnode_free(vnode_t* x, vtype type) Nonnull__(1); +extern void* libcdsb_vnode_peek(const vnode_t* x, vtype type) pure__ wur__ Nonnull__(1); #define vnode_create libcdsb_vnode_create #define vnode_tcreate libcdsb_vnode_create_target From 4056544d49a80fa7ac8dc351f99548b4dbc88e99 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 18:36:50 +0300 Subject: [PATCH 48/63] Update tests headers --- tests/src/array/plug.h | 69 ----------------------------------------- tests/src/dict/plug.h | 12 +++---- tests/src/list/src/io.c | 1 - tests/src/map/plug.h | 14 ++++----- 4 files changed, 13 insertions(+), 83 deletions(-) diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h index 254611a..f852e45 100644 --- a/tests/src/array/plug.h +++ b/tests/src/array/plug.h @@ -9,7 +9,6 @@ #include "../../include/test.h" #include "../../include/time.h" - extern void array_print(arr_t* x, const char* prefix, unsigned int hpos); extern void array_info(arr_t* x, unsigned int hpos); @@ -23,71 +22,3 @@ extern void visual_slice(arr_t* x, arr_t* s); extern void array_push_random (arr_t* x, _Bool silent, unsigned int hpos); extern void array_remove_random(arr_t* x, _Bool silent, unsigned int hpos); - -/* -static void array_push_random(vtype_array* x) { - switch (random_uint8()%13) { - default: - case 0: array_push(x, random_boolean()); break; - case 1: array_push(x, random_uint8()); break; - case 2: array_push(x, random_uint16()); break; - case 3: array_push(x, random_uint32()); break; - case 4: array_push(x, random_uint64()); break; - case 5: array_push(x, random_int8()); break; - case 6: array_push(x, random_int16()); break; - case 7: array_push(x, random_int32()); break; - case 8: array_push(x, random_int64()); break; - case 9: array_push(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; - case 10: array_push(x, random_float()); break; - case 11: array_push(x, random_double()); break; - case 12: array_push(x, random_ldouble()); break; - } -} - -static void array_init_random(vtype_array* x) { - switch (random_uint8()%13) { - default: - case 0: array_init(x, VTYPE_BOOLEAN); break; - case 1: array_init(x, VTYPE_UINT8); break; - case 2: array_init(x, VTYPE_UINT16); break; - case 3: array_init(x, VTYPE_UINT32); break; - case 4: array_init(x, VTYPE_UINT64); break; - case 5: array_init(x, VTYPE_INT8); break; - case 6: array_init(x, VTYPE_INT16); break; - case 7: array_init(x, VTYPE_INT32); break; - case 8: array_init(x, VTYPE_INT64); break; - case 9: array_init(x, VTYPE_POINTER); break; - case 10: array_init(x, VTYPE_FLOAT); break; - case 11: array_init(x, VTYPE_DOUBLE); break; - case 12: array_init(x, VTYPE_LDOUBLE); break; - } -} - -static vtype_array array_random(unsigned int n) { - vtype_array x; - - array_init_random(&x); - - for (int i = 0; i < n; ++i) { - array_push_random(&x); - } - - return x; -} - -static int array_value_print(void* v, ssize_t i, vtype t, void* _) { - print_container_value(&i, v, t, false); - return 0; -} - -static void array_print(vtype_array* x, const char* prefix) { - print_container_values_prefix("Array", prefix); - array_foreach(x, 0, array_value_print); - put_separator(); -} - -static void array_info(const vtype_array* x) { - print_container_info("Array", 0, &x->type, array_size(x), array_nmemb(x)); - put_separator(); -} -*/ diff --git a/tests/src/dict/plug.h b/tests/src/dict/plug.h index 57f84dc..e6b73db 100644 --- a/tests/src/dict/plug.h +++ b/tests/src/dict/plug.h @@ -7,11 +7,11 @@ #include "../../include/test.h" #include "../../include/time.h" -void dict_push_random(dict_t* x, bool silent, unsigned int hpos); -void dict_remove_random(dict_t* x, bool silent, unsigned int hpos); +extern void dict_push_random(dict_t* x, bool silent, unsigned int hpos); +extern void dict_remove_random(dict_t* x, bool silent, unsigned int hpos); -void dict_print(dict_t* x, const char* prefix, unsigned int hpos); -void dict_info(const dict_t* x, unsigned int hpos); +extern void dict_info(const dict_t* x, unsigned int hpos); +extern void dict_print(dict_t* x, const char* prefix, unsigned int hpos); -void visual_push(dict_t* x, size_t n); -void visual_remove(dict_t* x); +extern void visual_push(dict_t* x, size_t n); +extern void visual_remove(dict_t* x); diff --git a/tests/src/list/src/io.c b/tests/src/list/src/io.c index 793ae33..fb61586 100644 --- a/tests/src/list/src/io.c +++ b/tests/src/list/src/io.c @@ -17,7 +17,6 @@ void list_info(list_t* x, unsigned int hpos) { print_container_info("List", "nodes", 0, list_size(x), -1, hpos); } - void visual_push(list_t* x, size_t n) { for (int i = 0; i < n; ++i) { fputs("\e[s", stdout); diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h index a2ae449..da2aeed 100644 --- a/tests/src/map/plug.h +++ b/tests/src/map/plug.h @@ -7,12 +7,12 @@ #include "../../include/test.h" #include "../../include/time.h" -void map_push_random(map_t* x, _Bool silent, unsigned int hpos); -void map_remove_random(map_t* x, _Bool silent, unsigned int hpos); +extern void map_push_random(map_t* x, _Bool silent, unsigned int hpos); +extern void map_remove_random(map_t* x, _Bool silent, unsigned int hpos); -void map_print(map_t* x, const char* prefix, unsigned int hpos); -void map_info(const map_t* x, unsigned int hpos); -void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos); +extern void map_info(const map_t* x, unsigned int hpos); +extern void map_print(map_t* x, const char* prefix, unsigned int hpos); +extern void map_rbtree_print(map_t *x, const char* prefix, unsigned int hpos); -void visual_push(map_t* x, size_t n); -void visual_remove(map_t* x); +extern void visual_push(map_t* x, size_t n); +extern void visual_remove(map_t* x); From 382bd0070100b8c38c8c1cc0e2154cca90acac19 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 18:38:35 +0300 Subject: [PATCH 49/63] Add global (communicative) test --- tests/Makefile | 42 +++--- tests/src/global/main.c | 34 +++++ tests/src/global/plug.h | 23 +++ tests/src/global/src/io.c | 33 +++++ tests/src/global/src/random.c | 265 ++++++++++++++++++++++++++++++++++ 5 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 tests/src/global/main.c create mode 100644 tests/src/global/plug.h create mode 100644 tests/src/global/src/io.c create mode 100644 tests/src/global/src/random.c diff --git a/tests/Makefile b/tests/Makefile index b1f7a65..bb8f5ee 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -17,32 +17,25 @@ $(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall ######################################################################################################################## - c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c))))) -OBJECTS_TESTS := $(call c_objects,./src/,) -OBJECTS_BASE := $(call c_objects,../src/,) -OBJECTS_STRING := $(OBJECTS_BASE) $(call c_objects,../src/string/,string-) -OBJECTS_ARRAY := $(OBJECTS_BASE) $(call c_objects,../src/array/,array-) -OBJECTS_LIST := $(OBJECTS_BASE) $(call c_objects,../src/list/,list-) -OBJECTS_MAP := $(OBJECTS_BASE) $(call c_objects,../src/map/,map-) -OBJECTS_SET := $(OBJECTS_BASE) $(call c_objects,../src/set/,set-) -OBJECTS_DICT := $(OBJECTS_BASE) $(call c_objects,../src/dict/,dict-) +OBJECTS_TESTS := $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/,)) +OBJECTS_BASE := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/,)) +OBJECTS_STRING := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/string/,string-)) +OBJECTS_ARRAY := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/array/,array-)) +OBJECTS_LIST := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/list/,list-)) +OBJECTS_MAP := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/map/,map-)) +OBJECTS_SET := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/set/,set-)) +OBJECTS_DICT := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/dict/,dict-)) -OBJECTS_BASE := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_BASE)) -OBJECTS_STRING := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_STRING)) -OBJECTS_ARRAY := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_ARRAY)) -OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_LIST)) -OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP)) -OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET)) -OBJECTS_DICT := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_DICT)) +OBJECTS_GLOBAL := $(OBJECTS_TESTS) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/global/src/,global-)) -OBJECTS_STRING := $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-)) -OBJECTS_ARRAY := $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-)) -OBJECTS_LIST := $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-)) -OBJECTS_MAP := $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-)) -OBJECTS_SET := $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-)) -OBJECTS_DICT := $(OBJECTS_DICT) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/dict/src/,dict-)) +OBJECTS_STRING := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-)) +OBJECTS_ARRAY := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-)) +OBJECTS_LIST := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-)) +OBJECTS_MAP := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-)) +OBJECTS_SET := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-)) +OBJECTS_DICT := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_DICT) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/dict/src/,dict-)) ######################################################################################################################## @@ -53,6 +46,7 @@ tests: $(addprefix $(BUILD_PATH)/list-,$(notdir $(basename $(wildcard ./src/list tests: $(addprefix $(BUILD_PATH)/map-,$(notdir $(basename $(wildcard ./src/map/*.c)))) tests: $(addprefix $(BUILD_PATH)/set-,$(notdir $(basename $(wildcard ./src/set/*.c)))) tests: $(addprefix $(BUILD_PATH)/dict-,$(notdir $(basename $(wildcard ./src/dict/*.c)))) +tests: $(addprefix $(BUILD_PATH)/global-,$(notdir $(basename $(wildcard ./src/global/*.c)))) ######################################################################################################################## @@ -72,6 +66,8 @@ $(BUILD_PATH)/obj/set-%.o: ./src/set/src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) $(BUILD_PATH)/obj/dict-%.o: ./src/dict/src/%.c | $(BUILD_PATH)/obj/ $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/obj/global-%.o: ./src/global/src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) $(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall @@ -85,6 +81,8 @@ $(BUILD_PATH)/set-%: ./src/set/%.c $(OBJECTS_SET) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall $(BUILD_PATH)/dict-%: ./src/dict/%.c $(OBJECTS_DICT) | $(BUILD_PATH)/ $(CC) $^ -o $@ $(CFLAGS) -g3 -Wall +$(BUILD_PATH)/global-%: ./src/global/%.c $(OBJECTS_GLOBAL) | $(BUILD_PATH)/ + $(CC) $^ ../bin/debug/libcdsb.a ../modules/libunic/bin/libunic.a -o $@ $(CFLAGS) -g3 -Wall ######################################################################################################################## diff --git a/tests/src/global/main.c b/tests/src/global/main.c new file mode 100644 index 0000000..6717c31 --- /dev/null +++ b/tests/src/global/main.c @@ -0,0 +1,34 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); + + value_t x = random_container(0); + + switch (x.type) { + default: abort(); + case VTYPE_ARRAY: + array_info((void*)x.value, 0); + array_free((void*)x.value); + return 0; + case VTYPE_MAP: + map_info((void*)x.value, 0); + map_free((void*)x.value); + return 0; + case VTYPE_LIST: + list_info((void*)x.value, 0); + list_free((void*)x.value); + return 0; + case VTYPE_SET: + vset_info((void*)x.value, 0); + vset_free((void*)x.value); + return 0; + case VTYPE_DICT: + dict_info((void*)x.value, 0); + dict_free((void*)x.value); + return 0; + } +} diff --git a/tests/src/global/plug.h b/tests/src/global/plug.h new file mode 100644 index 0000000..6b280eb --- /dev/null +++ b/tests/src/global/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/extra/string.h" +#include "../../../include/extra/array.h" +#include "../../../include/extra/list.h" +#include "../../../include/extra/set.h" +#include "../../../include/extra/map.h" +#include "../../../include/extra/dict.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +extern value_t random_container(bool embd); +extern value_t real_random_value(bool embd); + +extern void array_info(arr_t* x, unsigned int hpos); +extern void list_info (list_t* x, unsigned int hpos); +extern void dict_info(const dict_t* x, unsigned int hpos); +extern void map_info(const map_t* x, unsigned int hpos); +extern void vset_info(const set_t* x, unsigned int hpos); +extern void string_info(str_t* x); diff --git a/tests/src/global/src/io.c b/tests/src/global/src/io.c new file mode 100644 index 0000000..d7a5900 --- /dev/null +++ b/tests/src/global/src/io.c @@ -0,0 +1,33 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +void map_info(const map_t* x, unsigned int hpos) { + print_container_info("Map", "nodes", &x->type, map_size(x), -1, 0); + put_separator(0); +} + +void array_info(arr_t* x, unsigned int hpos) { + print_container_info("Array", "nodes", 0, array_size(x), -1, hpos); +} + + +void dict_info(const dict_t* x, unsigned int hpos) { + print_container_info("Dict", "nodes", 0, dict_size(x), -1, 0); + put_separator(0); +} + +void list_info(list_t* x, unsigned int hpos) { + print_container_info("List", "nodes", 0, list_size(x), -1, hpos); +} + +void vset_info(const set_t* x, unsigned int hpos) { + print_container_info("Set", "nodes", &x->type, vset_size(x), -1, 0); + put_separator(0); +} + +void string_info(str_t* x) { + print_container_info("String", "utf8 chars", 0, string_size(x), string_nmemb(x), 0); + put_separator(0); +} diff --git a/tests/src/global/src/random.c b/tests/src/global/src/random.c new file mode 100644 index 0000000..df0de0f --- /dev/null +++ b/tests/src/global/src/random.c @@ -0,0 +1,265 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../plug.h" + +#define MAX_ELEMENTS 2000 + +static arr_t random_array(bool embd); +static list_t random_list (bool embd); +static set_t random_set (bool embd); +static map_t random_map (bool embd); +static dict_t random_dict (bool embd); + +static str_t random_string() { + str_t x; + size_t n = random_uint16()%MAX_ELEMENTS; + + string_init(&x, 0); + + while (n--) { + string_concat(&x, random_unicode_symbol()); + } + + return x; +} + +static value_t random_value2() { + value_t v; + switch (random_uint8()%14) { + default: + case 0: v.value[0].b = random_boolean(); v.type = VTYPE_BOOLEAN; break; + case 1: v.value[0].u8 = random_uint8 (); v.type = VTYPE_UINT8; break; + case 2: v.value[0].u16 = random_uint16 (); v.type = VTYPE_UINT16; break; + case 3: v.value[0].u32 = random_uint32 (); v.type = VTYPE_UINT32; break; + case 4: v.value[0].u64 = random_uint64 (); v.type = VTYPE_UINT64; break; + case 5: v.value[0].u8 = random_int8 (); v.type = VTYPE_INT8; break; + case 6: v.value[0].u16 = random_uint16 (); v.type = VTYPE_INT16; break; + case 7: v.value[0].u32 = random_int32 (); v.type = VTYPE_INT32; break; + case 8: v.value[0].u64 = random_int64 (); v.type = VTYPE_INT64; break; + case 9: v.value[0].f = random_float (); v.type = VTYPE_FLOAT; break; + case 10: v.value[0].d = random_double (); v.type = VTYPE_DOUBLE; break; + case 11: v.value[0].ld = random_ldouble(); v.type = VTYPE_LDOUBLE; break; + case 12: v.value[0].ptr = (void*)(uintptr_t)random_uint64(); v.type = VTYPE_POINTER; break; + case 13: v.value[0].s = random_string(); v.type = VTYPE_STRING; break; + } + + return v; +} + +static value_t random_value_by_type(vtype type, bool embd) { + value_t v; + switch ((v.type = type)) { + default: + case VTYPE_BOOLEAN: v.value[0].b = random_boolean(); break; + case VTYPE_UINT8: v.value[0].u8 = random_uint8 (); break; + case VTYPE_UINT16: v.value[0].u16 = random_uint16 (); break; + case VTYPE_UINT32: v.value[0].u32 = random_uint32 (); break; + case VTYPE_UINT64: v.value[0].u64 = random_uint64 (); break; + case VTYPE_INT8: v.value[0].u8 = random_int8 (); break; + case VTYPE_INT16: v.value[0].u16 = random_uint16 (); break; + case VTYPE_INT32: v.value[0].u32 = random_int32 (); break; + case VTYPE_INT64: v.value[0].u64 = random_int64 (); break; + case VTYPE_FLOAT: v.value[0].f = random_float (); break; + case VTYPE_DOUBLE: v.value[0].d = random_double (); break; + case VTYPE_LDOUBLE: v.value[0].ld = random_ldouble(); break; + case VTYPE_STRING: v.value[0].s = random_string(); break; + case VTYPE_ARRAY: v.value[0].a = random_array(embd); break; + case VTYPE_MAP: v.value[0].m = random_map (embd); break; + case VTYPE_DICT: v.value[0].vd = random_dict (embd); break; + case VTYPE_LIST: v.value[0].l = random_list (embd); break; + case VTYPE_SET: v.value[0].vs = random_set (embd); break; + case VTYPE_POINTER: v.value[0].ptr = (void*)(uintptr_t)random_uint64(); break; + } + + return v; +} + +static arr_t random_array(bool embd) { + arr_t x; + size_t n = random_uint16()%((!embd)?MAX_ELEMENTS:100); + value_t v = (!embd) ? random_value2() : real_random_value(1); + + void (*callback)(void*); + + switch (v.type) { + default: callback = nullptr; break; + case VTYPE_STRING: callback = (void*)string_free; break; + case VTYPE_ARRAY: callback = (void*)array_free; break; + case VTYPE_LIST: callback = (void*)list_free; break; + case VTYPE_MAP: callback = (void*)map_free; break; + case VTYPE_SET: callback = (void*)vset_free; break; + case VTYPE_DICT: callback = (void*)dict_free; break; + } + + array_init(&x, v.type); + + while(n--) { + + libcdsb_array_push(&x, v.value, v.type); + + if (callback) callback(v.value); + + v = random_value_by_type(v.type, 1); + } + + if (callback) callback(v.value); + + return x; +} + +static set_t random_set(bool embd) { + set_t x; + size_t n = random_uint16()%((!embd)?MAX_ELEMENTS:100); + value_t v = (!embd) ? random_value2() : real_random_value(1); + + void (*callback)(void*); + + switch (v.type) { + default: callback = nullptr; break; + case VTYPE_STRING: callback = (void*)string_free; break; + case VTYPE_ARRAY: callback = (void*)array_free; break; + case VTYPE_LIST: callback = (void*)list_free; break; + case VTYPE_MAP: callback = (void*)map_free; break; + case VTYPE_SET: callback = (void*)vset_free; break; + case VTYPE_DICT: callback = (void*)dict_free; break; + } + + vset_init(&x, v.type); + + while(n--) { + + libcdsb_vset_insert(&x, v.value, v.type); + + if (callback) callback(v.value); + + v = random_value_by_type(v.type, 1); + } + + if (callback) callback(v.value); + return x; +} + +static list_t random_list(bool embd) { + list_t x; + value_t v; + size_t n = random_uint16()%((!embd)?MAX_ELEMENTS:100); + + list_init(&x); + + while(n--) { + v = (!embd) ? random_value2() : real_random_value(1); + libcdsb_list_update(&x, -1, v.value, v.type, 1); + + switch (v.type) { + default: break; + case VTYPE_STRING: string_free((void*)v.value); break; + case VTYPE_ARRAY: array_free ((void*)v.value); break; + case VTYPE_LIST: list_free ((void*)v.value); break; + case VTYPE_MAP: map_free ((void*)v.value); break; + case VTYPE_SET: vset_free ((void*)v.value); break; + case VTYPE_DICT: dict_free ((void*)v.value); break; + } + } + + return x; +} + +static map_t random_map(bool embd) { + map_t x; + size_t n = random_uint16()%((!embd)?MAX_ELEMENTS:100); + value_t k = (!embd) ? random_value2() : real_random_value(1); + + void (*callback)(void*); + + switch (k.type) { + default: callback = nullptr; break; + case VTYPE_STRING: callback = (void*)string_free; break; + case VTYPE_ARRAY: callback = (void*)array_free; break; + case VTYPE_LIST: callback = (void*)list_free; break; + case VTYPE_MAP: callback = (void*)map_free; break; + case VTYPE_SET: callback = (void*)vset_free; break; + case VTYPE_DICT: callback = (void*)dict_free; break; + } + + map_init(&x, k.type); + + while(n--) { + value_t v = (!embd) ? random_value2() : real_random_value(1); + + libcdsb_map_update(&x, k.value, k.type, v.value, v.type); + + if (callback) callback(k.value); + + switch (v.type) { + default: break; + case VTYPE_STRING: string_free((void*)v.value); break; + case VTYPE_ARRAY: array_free ((void*)v.value); break; + case VTYPE_LIST: list_free ((void*)v.value); break; + case VTYPE_MAP: map_free ((void*)v.value); break; + case VTYPE_SET: vset_free ((void*)v.value); break; + case VTYPE_DICT: dict_free ((void*)v.value); break; + } + + k = random_value_by_type(k.type, 1); + } + + if (callback) callback(k.value); + return x; + +} + +static dict_t random_dict(bool embd) { + dict_t x; + value_t k, v; + size_t n = random_uint16()%((!embd)?MAX_ELEMENTS:100); + + dict_init(&x); + + while(n--) { + k = (!embd) ? random_value2() : real_random_value(1); + v = (!embd) ? random_value2() : real_random_value(1); + libcdsb_dict_update(&x, k.value, k.type, v.value, v.type); + + switch (v.type) { + default: break; + case VTYPE_STRING: string_free((void*)v.value); break; + case VTYPE_ARRAY: array_free ((void*)v.value); break; + case VTYPE_LIST: list_free ((void*)v.value); break; + case VTYPE_MAP: map_free ((void*)v.value); break; + case VTYPE_SET: vset_free ((void*)v.value); break; + case VTYPE_DICT: dict_free ((void*)v.value); break; + } + + switch (k.type) { + default: break; + case VTYPE_STRING: string_free((void*)k.value); break; + case VTYPE_ARRAY: array_free ((void*)k.value); break; + case VTYPE_LIST: list_free ((void*)k.value); break; + case VTYPE_MAP: map_free ((void*)k.value); break; + case VTYPE_SET: vset_free ((void*)k.value); break; + case VTYPE_DICT: dict_free ((void*)k.value); break; + } + } + + return x; +} + +value_t random_container(bool embd) { + value_t v; + + switch (random_uint8()%5) { + default: + case 0: v.value[0].a = random_array(embd); v.type = VTYPE_ARRAY; break; + case 1: v.value[0].m = random_map (embd); v.type = VTYPE_MAP; break; + case 2: v.value[0].vd = random_dict (embd); v.type = VTYPE_DICT; break; + case 3: v.value[0].l = random_list (embd); v.type = VTYPE_LIST; break; + case 4: v.value[0].vs = random_set (embd); v.type = VTYPE_SET; break; + } + + return v; +} + +value_t real_random_value(bool embd) { + return random_boolean() ? random_value2() : random_container(embd); +} From 80ba7082d4c045af8e9809a3117bc73be5f5570e Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 18:39:55 +0300 Subject: [PATCH 50/63] Minor fixes --- include/array.h | 2 +- include/extra/set.h | 5 ++--- src/__internal/rbtree.h | 6 +++--- src/__internal/vnode.h | 2 +- src/extra-memory.c | 3 +++ 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/array.h b/include/array.h index 9e7dee1..5b6d177 100644 --- a/include/array.h +++ b/include/array.h @@ -21,7 +21,7 @@ extern void array_reverse(vtype_array* x) Nonnull__(1); #define array_pop(x, value, data, callback) _LIBCDSB_Generic(libcdsb_array, find, value)(x, value, data, callback, 0, 1) #define array_find(x, value, data, callback) _LIBCDSB_Generic(libcdsb_array, find, value)(x, value, data, callback, 0, 0) #define array_rfind(x, value, data, callback) _LIBCDSB_Generic(libcdsb_array, find, value)(x, value, data, callback, 1, 0) -#define list_countof(x, value) _LIBCDSB_Generic(libcdsb_array, count, value)(x, value) +#define array_countof(x, value) _LIBCDSB_Generic(libcdsb_array, count, value)(x, value) #define array_remove(x, value) array_pop(x, value, 0, 0) #define in_array(x, value) (array_find(x, value, 0, 0) == 0) diff --git a/include/extra/set.h b/include/extra/set.h index 0b25cdb..a34113b 100644 --- a/include/extra/set.h +++ b/include/extra/set.h @@ -8,9 +8,8 @@ #define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, 0) -extern bool libcdsb_vset_insert(vtype_set* x, const void* value, vtype type) LIBCDSB_nn12__; - +extern bool libcdsb_vset_insert(vtype_set* x, const void* value, vtype type) Nonnull__(1); extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) LIBCDSB_nn13__; +extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_EXTRA_SET_H */ diff --git a/src/__internal/rbtree.h b/src/__internal/rbtree.h index c9db416..8564bc1 100644 --- a/src/__internal/rbtree.h +++ b/src/__internal/rbtree.h @@ -32,9 +32,9 @@ extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node) extern void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info) wur__ Nonnull__(1); extern int libcdsb_rbtree_compare (const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info) pure__ wur__ Nonnull__(1,2); -extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) pure__ wur__ Nonnull__(1,2); -extern size_t libcdsb_rbtree_size(const void* s) pure__ wur__ Nonnull__(1); -extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) Nonnull__(1); +extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) pure__ wur__ Nonnull__(1); +extern size_t libcdsb_rbtree_size(const void* s) pure__ wur__ Nonnull__(1); +extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) Nonnull__(1); #define rbtree_duplicate libcdsb_rbtree_duplicate #define rbtree_compare libcdsb_rbtree_compare diff --git a/src/__internal/vnode.h b/src/__internal/vnode.h index c7a5d95..ad9a393 100644 --- a/src/__internal/vnode.h +++ b/src/__internal/vnode.h @@ -11,7 +11,7 @@ typedef union { void* ptr; bool b; str_t s; arr_t a; list_t l; - map_t m; set_t vs; + map_t m; set_t vs; dict_t vd; u8_t u8; u16_t u16; u32_t u32; u64_t u64; fl_t f; dbl_t d; ldbl_t ld; } var_t; diff --git a/src/extra-memory.c b/src/extra-memory.c index 72fdaab..0ff5783 100644 --- a/src/extra-memory.c +++ b/src/extra-memory.c @@ -55,6 +55,9 @@ char* libcdsb_strdup(const char* s) { void* x; size_t n; + if (is_null(s)) + return nullptr; + if ((x = malloc(n = strlen(s) + 1))) return memcpy(x, s, n); abort(); From 125153076d5496637807f1b3a179101d2420174a Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 21:10:54 +0300 Subject: [PATCH 51/63] Minor fixes --- include/extra/set.h | 6 +++--- include/set.h | 7 ++++--- src/dict/extra.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/extra/set.h b/include/extra/set.h index a34113b..42be364 100644 --- a/include/extra/set.h +++ b/include/extra/set.h @@ -8,8 +8,8 @@ #define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, 0) -extern bool libcdsb_vset_insert(vtype_set* x, const void* value, vtype type) Nonnull__(1); -extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) Nonnull__(1,3); +extern bool libcdsb_vset_insert (vtype_set* x, const void* value, vtype type) Nonnull__(1); +extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_EXTRA_SET_H */ diff --git a/include/set.h b/include/set.h index 2ea5c92..238c910 100644 --- a/include/set.h +++ b/include/set.h @@ -11,10 +11,11 @@ typedef int (*vset_access_callback)(const void* value, vtype type, void* data); extern void vset_init(vtype_set* x, vtype type) Nonnull__(1); -#define vset_remove(x, value) _LIBCDSB_Generic (libcdsb_vset, touch, value)(x, value, 1) -#define vset_push(x, value) _LIBCDSB_Generic (libcdsb_vset, push, value)(x, value) +#define vset_pop(x, value, data, callback) _LIBCDSB_Generic (libcdsb_vset, find, value)(x, value, data, callback, 1) +#define vset_get(x, value, data, callback) _LIBCDSB_Generic (libcdsb_vset, find, value)(x, value, data, callback, 0) +#define vset_push(x, value) _LIBCDSB_Generic (libcdsb_vset, push, value)(x, value) -#define in_vset(x, value) _LIBCDSB_Generic (libcdsb_vset, touch, value)(x, value, 0) +#define in_vset(x, value) (vset_get(&x, value, 0, 0, 0) == 0) extern bool libcdsb_vset_push_pointer(vtype_set* x, const void* value) Nonnull__(1); extern bool libcdsb_vset_push_cstring(vtype_set* x, const char* value) Nonnull__(1,2); diff --git a/src/dict/extra.c b/src/dict/extra.c index 8688703..5b4aba5 100644 --- a/src/dict/extra.c +++ b/src/dict/extra.c @@ -165,7 +165,7 @@ int libcdsb_dict_get(dict_t* x, const void* k, vtype t, void* _, dict_access_cal cmp = vtype_compare(k, t, key, c->key_type); if (cmp == 0) { - cmp = (callback) ? callback(key, t, vnode_peek(&c->value, c->val_type), c->val_type, _) : 0; + cmp = (callback) ? callback(key, c->key_type, vnode_peek(&c->value, c->val_type), c->val_type, _) : 0; if (cut) { c = dnode_delete(x->nodes + index, c); From 86928b4b221b16704c57a3482ab4e1e584673a05 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 16 Aug 2022 21:11:07 +0300 Subject: [PATCH 52/63] Add examples --- examples/Makefile | 40 +++++++++++++++++++++++++++++++ examples/array.c | 37 ++++++++++++++++++++++++++++ examples/dict.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ examples/list.c | 51 +++++++++++++++++++++++++++++++++++++++ examples/map.c | 55 ++++++++++++++++++++++++++++++++++++++++++ examples/set.c | 38 +++++++++++++++++++++++++++++ examples/string.c | 42 ++++++++++++++++++++++++++++++++ 7 files changed, 324 insertions(+) create mode 100644 examples/Makefile create mode 100644 examples/array.c create mode 100644 examples/dict.c create mode 100644 examples/list.c create mode 100644 examples/map.c create mode 100644 examples/set.c create mode 100644 examples/string.c diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..2d99f6b --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,40 @@ +# This software is licensed by the MIT License, see LICENSE file +# Copyright © 2022 Gregory Lirent + +######################################################################################################################## + +BUILD_PATH ?= ./bin + +######################################################################################################################## + +CC = clang +MKDIR = mkdir -p +RMRF = rm -rf +AR = ar crs +CP = cp + +######################################################################################################################## + +examples: modules +examples: $(addprefix $(BUILD_PATH)/,$(notdir $(basename $(wildcard ./*.c)))) + +$(BUILD_PATH)/%: ./%.c | $(BUILD_PATH)/ + $(CC) $^ ../bin/release/libcdsb.a ../modules/libunic/bin/libunic.a -o $@ $(CFLAGS) -O2 -Wall + + +$(BUILD_PATH)/: + $(MKDIR) $@ +$(BUILD_PATH)/obj/: | $(BUILD_PATH)/ + $(MKDIR) $@ + +clean: + $(RMRF) ./bin/ + cd ../ && $(MAKE) clean + +######################################################################################################################## + +FORCE: +modules: ../bin/release/libcdsb.a + +../bin/release/libcdsb.a: FORCE + cd ../ && $(MAKE) release diff --git a/examples/array.c b/examples/array.c new file mode 100644 index 0000000..29108c4 --- /dev/null +++ b/examples/array.c @@ -0,0 +1,37 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#include "../include/extra/array.h" + +typedef vtype_array arr_t; + +int print_value(void* value, ssize_t index, vtype type, void* data) { + const char *n = data; + vtype_int32 *v = value; + + assert(type == VTYPE_INT32); + + printf("%s %d (index: %ld)\n", n, *v, index); + + return 0; +} + +int main(int argc, char** argv) { + + arr_t arr; + + array_init(&arr, VTYPE_INT32); + + for (size_t i = 0; i < 28; ++i) { + array_push_back(&arr, i); + } + + array_get_by_index(&arr, 13, "Get value:", print_value); + array_pop_by_index(&arr, 18, "Pop value:", print_value); + + array_foreach(&arr, "Foreach loop:", print_value); + + array_free(&arr); +} diff --git a/examples/dict.c b/examples/dict.c new file mode 100644 index 0000000..1e548a4 --- /dev/null +++ b/examples/dict.c @@ -0,0 +1,61 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#include +#include "../include/extra/dict.h" + +typedef vtype_dict dict_t; + +int print_value(const void* key, vtype key_type, void* value, vtype value_type, void* data) { + const char *n = data; + + switch (key_type) { + default: abort(); + + case VTYPE_INT32: + printf("%s %d: ", n, *(vtype_int32*)key); + break; + case VTYPE_FLOAT: + printf("%s %f: ", n, *(vtype_float*)key); + break; + } + + switch (value_type) { + default: abort(); + + case VTYPE_INT32: + printf("%d\n", *(vtype_int32*)value); + break; + case VTYPE_FLOAT: + printf("%f\n", *(vtype_float*)value); + break; + } + + return 0; +} + +int main(int argc, char** argv) { + + dict_t dict; + vtype_float fl = 0.0; + + dict_init(&dict); + + for (size_t i = 0; i < 28; ++i) { + if (i%2) { + dict_update(&dict, (vtype_float)fl, (vtype_int32)i); + } else { + dict_update(&dict, (vtype_int32)i, (vtype_float)fl); + } + fl += 0.05; + } + + dict_get(&dict, 14, "Get value:", print_value); + dict_pop(&dict, 0.25, "Pop value:", print_value); + + dict_foreach(&dict, "Foreach loop:", print_value); + + dict_free(&dict); +} diff --git a/examples/list.c b/examples/list.c new file mode 100644 index 0000000..449ba2d --- /dev/null +++ b/examples/list.c @@ -0,0 +1,51 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#include "../include/extra/list.h" + +typedef vtype_list list_t; + + +int print_value(void* value, ssize_t index, vtype type, void* data) { + const char *n = data; + + switch (type) { + default: abort(); + + case VTYPE_INT32: + printf("%s %d (index: %ld)\n", n, *(vtype_int32*)value, index); + break; + case VTYPE_FLOAT: + printf("%s %f (index: %ld)\n", n, *(vtype_float*)value, index); + break; + } + + return 0; +} + + +int main(int argc, char** argv) { + + list_t list; + vtype_float fl = 0.0; + + list_init(&list); + + for (size_t i = 0; i < 28; ++i) { + if (i%2) { + list_push_back(&list, (vtype_int32)i); + } else { + list_push_back(&list, (vtype_float)fl); + fl += 0.05; + } + } + + list_get_by_index(&list, 13, "Get value:", print_value); + list_pop_by_index(&list, 18, "Pop value:", print_value); + + list_foreach(&list, "Foreach loop:", print_value); + + list_free(&list); +} diff --git a/examples/map.c b/examples/map.c new file mode 100644 index 0000000..115dc2e --- /dev/null +++ b/examples/map.c @@ -0,0 +1,55 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#include +#include "../include/extra/map.h" + +typedef vtype_map map_t; + +int print_value(const void* key, vtype key_type, void* value, vtype value_type, void* data) { + const char *n = data; + vtype_int32 *k = (void*)key; + + assert(key_type == VTYPE_INT32); + + printf("%s %d: ", n, *k); + + switch (value_type) { + default: abort(); + + case VTYPE_INT32: + printf("%d\n", *(vtype_int32*)value); + break; + case VTYPE_FLOAT: + printf("%f\n", *(vtype_float*)value); + break; + } + + return 0; +} + +int main(int argc, char** argv) { + + map_t map; + vtype_float fl = 0.0; + + map_init(&map, VTYPE_INT32); + + for (size_t i = 0; i < 28; ++i) { + if (i%2) { + map_update(&map, i, (vtype_int32)i); + } else { + map_update(&map, i, (vtype_float)fl); + fl += 0.05; + } + } + + map_get(&map, 13, "Get value:", print_value); + map_pop(&map, 18, "Pop value:", print_value); + + map_foreach(&map, "Foreach loop:", print_value); + + map_free(&map); +} diff --git a/examples/set.c b/examples/set.c new file mode 100644 index 0000000..9b9b4d1 --- /dev/null +++ b/examples/set.c @@ -0,0 +1,38 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include +#include "../include/extra/set.h" + +typedef vtype_set vset_t; + +int print_value(const void* value, vtype type, void* data) { + const char *n = data; + vtype_int32 *v = (void*)value; + + assert(type == VTYPE_INT32); + + printf("%s %d\n", n, *v); + + return 0; +} + + +int main(int argc, char** argv) { + + vset_t set; + + vset_init(&set, VTYPE_INT32); + + for (size_t i = 0; i < 28; ++i) { + vset_push(&set, i); + } + + vset_get(&set, 13, "Get value:", print_value); + vset_pop(&set, 18, "Pop value:", print_value); + + vset_foreach(&set, "Foreach loop:", print_value); + + vset_free(&set); +} diff --git a/examples/string.c b/examples/string.c new file mode 100644 index 0000000..4072af5 --- /dev/null +++ b/examples/string.c @@ -0,0 +1,42 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include "../include/extra/string.h" +#include "../include/extra/array.h" + +typedef vtype_string str_t; +typedef vtype_array arr_t; + +int main(int argc, char** argv) { + + str_t str; + + string_init(&str, "sed ut perspiciatis"); + + string_concat(&str, ", Unde omnis iste natus error sit voluptatem accusantium doloremque laudantium"); + string_concat(&str, ", Totam rem aperiam eaque ipsa"); + string_concat(&str, ", Quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt"); + string_concat(&str, ", Explicabo."); + + string_capitalize(&str); + + string_reverse(&str); + + printf("%s\n", str.buffer); + + arr_t parts = string_split(&str, ',', -1); + + printf("%lu\n", array_size(&parts)); + + for (size_t i = 0; i < array_size(&parts); ++i) { + str_t* value = array_at(&parts, i); + + string_trim_spaces(value); + + printf("%s (%lu)\n", value->buffer, string_nmemb(value)); + } + + array_free(&parts); + string_free(&str); +} From 9f83f595029d67794952d29b1faa10db09918b90 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:20:04 +0300 Subject: [PATCH 53/63] Update headers --- include/dict.h | 6 ++++++ include/extra/dict.h | 2 +- include/extra/memory.h | 3 +++ include/extra/string.h | 12 ++++++------ include/extra/vtype.h | 2 -- include/list.h | 4 ++-- include/map.h | 6 ++++++ include/set.h | 7 ++++++- include/string.h | 4 ++-- include/vtype.h | 2 -- src/__internal/include.h | 2 ++ 11 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/dict.h b/include/dict.h index 8ff850c..d6f9963 100644 --- a/include/dict.h +++ b/include/dict.h @@ -7,6 +7,8 @@ #ifndef LIBCDSB_DICT_H #define LIBCDSB_DICT_H +/*#####################################################################################################################*/ + typedef int (*dict_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data); extern void dict_init(vtype_dict* x) Nonnull__(1); @@ -16,6 +18,10 @@ extern void dict_init(vtype_dict* x) Nonnull__(1); #define dict_update(x, key, value) _LIBCDSB_Generic2(libcdsb_dict, update, key, value)(x, key, value) #define dict_remove(x, key) dict_pop(x, key, 0, 0) +#define in_dict(x, key) (dict_get(&x, key, 0, 0) == 0) + +/*#####################################################################################################################*/ + extern int libcdsb_dict_get_by_pointer(vtype_dict* x, const void* key, void* data, dict_access_callback, bool cut) Nonnull__(1); extern int libcdsb_dict_get_by_cstring(vtype_dict* x, const char* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); extern int libcdsb_dict_get_by_string (vtype_dict* x, const vtype_string* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); diff --git a/include/extra/dict.h b/include/extra/dict.h index 47bc976..972b77b 100644 --- a/include/extra/dict.h +++ b/include/extra/dict.h @@ -9,7 +9,7 @@ #define dict_foreach(x, data, callback) libcdsb_dict_foreach(x, data, callback, 0) extern bool libcdsb_dict_update (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); -extern int libcdsb_dict_get (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_find (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) Nonnull__(1); extern int libcdsb_dict_foreach (vtype_dict* x, void* data, dict_access_callback, bool flush) Nonnull__(1,3); extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) Nonnull__(1); diff --git a/include/extra/memory.h b/include/extra/memory.h index b21b43e..e27f73b 100644 --- a/include/extra/memory.h +++ b/include/extra/memory.h @@ -22,10 +22,13 @@ extern void* libcdsb_malloc (size_t n) Warn_unused_result__; extern void* libcdsb_calloc (size_t n, size_t c) Warn_unused_result__; extern void* libcdsb_realloc(void *p, size_t n) Warn_unused_result__; +extern void libcdsb_free(void* s); + #define aligned_alloc libcdsb_aalloc #define malloc libcdsb_malloc #define calloc libcdsb_calloc #define realloc libcdsb_realloc +#define free libcdsb_free #define stack_init libcdsb_stack_init #define stack_push libcdsb_stack_push diff --git a/include/extra/string.h b/include/extra/string.h index 64490ef..283df4b 100644 --- a/include/extra/string.h +++ b/include/extra/string.h @@ -8,7 +8,7 @@ /*#####################################################################################################################*/ -#define string_split(x, sep, maxn) _LIBCDSB_GenericS(libcdsb_string, split, sep)(x, sep, maxn) +#define string_split(s, sep, maxn) _LIBCDSB_GenericS(libcdsb_string, split, sep)(s, sep, maxn) #define string_case_compare string_compare_case_insensitive #define string_replace_r(x, src, dest, maxn) _LIBCDSB_GenericS2(libcdsb_string, replace_r, src, dest)(x, src, dest, maxn) @@ -27,15 +27,15 @@ extern size_t string_align_center(vtype_string* x, size_t padsize, int padchr) N extern size_t string_align_right (vtype_string* x, size_t padsize, int padchr) Nonnull__(1); extern size_t string_align_left (vtype_string* x, size_t padsize, int padchr) Nonnull__(1); -extern int string_compare_case_insensitive(const vtype_string* s0, const vtype_string* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); - extern void libcdsb_string_replace(vtype_string* x, char* dest, size_t dest_nmemb, const char* src, size_t nmemb) Nonnull__(1,2); /*#####################################################################################################################*/ -inline vtype_array libcdsb_string_split_string (const vtype_string* x, const vtype_string* sep, size_t maxn) Nonnull__(1) Always_inline__; -extern vtype_array libcdsb_string_split_cstring(const vtype_string* string, const char* sep, size_t maxn) Nonnull__(1); -extern vtype_array libcdsb_string_split_char (const vtype_string* string, int chr, size_t maxn) Nonnull__(1); +extern int string_compare_case_insensitive(const vtype_string* s0, const vtype_string* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); + +inline vtype_array libcdsb_string_split_string (const vtype_string* s, const vtype_string* sep, size_t maxn) Nonnull__(1) Always_inline__; +extern vtype_array libcdsb_string_split_cstring(const vtype_string* s, const char* sep, size_t maxn) Nonnull__(1); +extern vtype_array libcdsb_string_split_char (const vtype_string* s, int chr, size_t maxn) Nonnull__(1); inline void libcdsb_string_trim_string (vtype_string* x, const vtype_string* s, int direction) Nonnull__(1) Always_inline__; extern void libcdsb_string_trim_cstring(vtype_string* x, const char* s, int direction) Nonnull__(1); diff --git a/include/extra/vtype.h b/include/extra/vtype.h index 7c5aec9..af4307d 100644 --- a/include/extra/vtype.h +++ b/include/extra/vtype.h @@ -6,8 +6,6 @@ #ifndef LIBCDSB_EXTRA_VTYPE_H #define LIBCDSB_EXTRA_VTYPE_H -extern const size_t LIBCDSB_VTYPE_SIZES[18]; - extern const char* libcdsb_vtype_name(vtype t) Warn_unused_result__; extern const char* libcdsb_vtype_stringify(const void* value, vtype t) Warn_unused_result__; diff --git a/include/list.h b/include/list.h index 219e04e..2cde5b4 100644 --- a/include/list.h +++ b/include/list.h @@ -11,8 +11,8 @@ typedef int (*list_access_callback)(void* value, ssize_t index, vtype type, void* data); -extern void list_init (vtype_list* x) Nonnull__(1); -extern void list_extend(vtype_list* x, const vtype_list* s) Nonnull__(1,2); +extern void list_init (vtype_list* x) Nonnull__(1); +extern void list_extend (vtype_list* x, const vtype_list* s) Nonnull__(1,2); extern size_t list_slice (vtype_list* x, vtype_list* src, ssize_t index, size_t count, bool cut) Nonnull__(1,2); extern void list_sort (vtype_list* x) Nonnull__(1); extern void list_reverse(vtype_list* x) Nonnull__(1); diff --git a/include/map.h b/include/map.h index 4248050..85755bf 100644 --- a/include/map.h +++ b/include/map.h @@ -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) Nonnull__(1); @@ -16,6 +18,10 @@ extern void map_init(vtype_map* x, vtype key_type) Nonnull__(1); #define map_update(x, key, value) _LIBCDSB_Generic2(libcdsb_map, update, key, value)(x, key, value) #define map_remove(x, key) map_pop(x, key, 0, 0) +#define in_map(x, key) (map_get(&x, key, 0, 0) == 0) + +/*#####################################################################################################################*/ + extern int libcdsb_map_find_pointer(vtype_map* x, const void* key, void* data, map_access_callback, bool cut) Nonnull__(1); extern int libcdsb_map_find_cstring(vtype_map* x, const char* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); extern int libcdsb_map_find_string (vtype_map* x, const vtype_string* key, void* data, map_access_callback, bool cut) Nonnull__(1,2); diff --git a/include/set.h b/include/set.h index 238c910..d679c98 100644 --- a/include/set.h +++ b/include/set.h @@ -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) Nonnull__(1); @@ -14,8 +16,11 @@ extern void vset_init(vtype_set* x, vtype type) Nonnull__(1); #define vset_pop(x, value, data, callback) _LIBCDSB_Generic (libcdsb_vset, find, value)(x, value, data, callback, 1) #define vset_get(x, value, data, callback) _LIBCDSB_Generic (libcdsb_vset, find, value)(x, value, data, callback, 0) #define vset_push(x, value) _LIBCDSB_Generic (libcdsb_vset, push, value)(x, value) +#define vset_remove(x, value) vset_pop(x, value, 0, 0) -#define in_vset(x, value) (vset_get(&x, value, 0, 0, 0) == 0) +#define in_vset(x, value) (vset_get(&x, value, 0, 0) == 0) + +/*#####################################################################################################################*/ extern bool libcdsb_vset_push_pointer(vtype_set* x, const void* value) Nonnull__(1); extern bool libcdsb_vset_push_cstring(vtype_set* x, const char* value) Nonnull__(1,2); diff --git a/include/string.h b/include/string.h index aeb51fd..b8e8474 100644 --- a/include/string.h +++ b/include/string.h @@ -13,11 +13,11 @@ extern void string_init(vtype_string* x, const char* value) Nonnull__(1); extern char* string_at(const vtype_string* s, ssize_t index) Nonnull__(1); -extern bool string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_t nchars, bool cut) Nonnull__(1,2); +extern size_t string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_t nchars, bool cut) Nonnull__(1,2); #define string_indexof(s, arg) _LIBCDSB_GenericS(libcdsb_string, indexof, arg)(s, arg) #define string_count(s, arg) _LIBCDSB_GenericS(libcdsb_string, count, arg)(s, arg) -#define string_concat(s, value) _LIBCDSB_GenericS(libcdsb_string, concat, value)(s, value) +#define string_concat(x, value) _LIBCDSB_GenericS(libcdsb_string, concat, value)(x, value) #define string_trim_spaces(x) libcdsb_string_trim_spaces(x, 0) #define string_ltrim_spaces(x) libcdsb_string_trim_spaces(x, -1) diff --git a/include/vtype.h b/include/vtype.h index 8238a19..4ec686c 100644 --- a/include/vtype.h +++ b/include/vtype.h @@ -31,8 +31,6 @@ typedef enum libcdsb_value_types { VTYPE_LIST = 16, VTYPE_SET = 17, VTYPE_DICT = 18, - - LIBCDSB_VTYPE_TERMINATION, /* It must be at the end of the enum. Never be used */ } vtype; diff --git a/src/__internal/include.h b/src/__internal/include.h index 76f096d..dbefa85 100644 --- a/src/__internal/include.h +++ b/src/__internal/include.h @@ -14,6 +14,8 @@ #ifndef LIBCDSB_SRC_INTERNAL_INCLUDE #define LIBCDSB_SRC_INTERNAL_INCLUDE +extern const size_t LIBCDSB_VTYPE_SIZES[19]; + #define is_x64 (sizeof(void*) == sizeof(vtype_uint64)) #define is_big_endian (*((unsigned int*)"\0\0\0\1") < (unsigned int)0xffff) #define is_little_endian (!is_big_endian) From 1b815613a42f57e0ea117968e2d954914864faf4 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:20:40 +0300 Subject: [PATCH 54/63] Refactor array base --- src/array/base.c | 31 ++++++++++++++--------- src/array/copy.c | 66 ++++++++++++++++++++---------------------------- 2 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/array/base.c b/src/array/base.c index 49ee49f..f674b0c 100644 --- a/src/array/base.c +++ b/src/array/base.c @@ -4,6 +4,23 @@ #include "include.h" #include "../__internal/assert.h" +typedef void (*type_free)(void*); + +static inline type_free get_type_free(vtype type) { + switch (type) { + default: + #ifndef NDEBUG + abort(); + #endif + case VTYPE_STRING: return (void*)string_free; + case VTYPE_ARRAY: return (void*) array_free; + case VTYPE_LIST: return (void*) list_free; + case VTYPE_MAP: return (void*) map_free; + case VTYPE_SET: return (void*) vset_free; + case VTYPE_DICT: return (void*) dict_free; + } +} + /*#####################################################################################################################*/ hash_t array_hash(const arr_t* s) { @@ -29,21 +46,11 @@ void array_init(arr_t* x, vtype t) { void array_free(arr_t* x) { if (x->size && x->type >= VTYPE_STRING) { void* p = x->mem; - void (*free_)(void*); + type_free free_; assert(!is_null(p)); - switch (x->type) { - default: - #ifndef NDEBUG - abort(); - #endif - case VTYPE_STRING: free_ = (void*)string_free; break; - case VTYPE_ARRAY: free_ = (void*) array_free; break; - case VTYPE_LIST: free_ = (void*) list_free; break; - case VTYPE_MAP: free_ = (void*) map_free; break; - case VTYPE_SET: free_ = (void*) vset_free; break; - } + free_ = get_type_free(x->type); do { free_(p); diff --git a/src/array/copy.c b/src/array/copy.c index 967e74e..0100ce7 100644 --- a/src/array/copy.c +++ b/src/array/copy.c @@ -4,6 +4,22 @@ #include "include.h" #include "../__internal/assert.h" +typedef void (*type_initializer)(void*, const void*); + +static inline type_initializer get_type_initializer(vtype type) { + switch (type) { + default: + #ifndef NDEBUG + abort(); + #endif + case VTYPE_STRING: return (void*)string_copy_init; + case VTYPE_ARRAY: return (void*) array_copy_init; + case VTYPE_LIST: return (void*) list_copy_init; + case VTYPE_MAP: return (void*) map_copy_init; + case VTYPE_SET: return (void*) vset_copy_init; + case VTYPE_DICT: return (void*) dict_copy_init; + } +} arr_t array_copy(const arr_t* s) { arr_t x = { .mem = 0, .size = 0, .type = 0 }; @@ -14,19 +30,12 @@ arr_t array_copy(const arr_t* s) { if (s->type >= VTYPE_STRING) { void *p, *v, *e; - void (*init)(void*, const void*); + type_initializer init; x.mem = p = malloc(x.size*vtype_size(x.type)); v = s->mem; e = array_end(&x); - - switch (s->type) { default: abort(); - case VTYPE_STRING: init = (void*)string_copy_init; break; - case VTYPE_ARRAY: init = (void*) array_copy_init; break; - case VTYPE_LIST: init = (void*) list_copy_init; break; - case VTYPE_MAP: init = (void*) map_copy_init; break; - case VTYPE_SET: init = (void*) vset_copy_init; break; - } + init = get_type_initializer(s->type); do { init(p, v); @@ -50,19 +59,12 @@ arr_t* array_duplicate(const arr_t* s) { if (s->type >= VTYPE_STRING) { void *p, *v, *e; - void (*init)(void*, const void*); + type_initializer init; x->mem = p = malloc(x->size*vtype_size(x->type)); v = s->mem; e = array_end(x); - - switch (s->type) { default: abort(); - case VTYPE_STRING: init = (void*)string_copy_init; break; - case VTYPE_ARRAY: init = (void*) array_copy_init; break; - case VTYPE_LIST: init = (void*) list_copy_init; break; - case VTYPE_MAP: init = (void*) map_copy_init; break; - case VTYPE_SET: init = (void*) vset_copy_init; break; - } + init = get_type_initializer(s->type); do { init(p, v); @@ -84,19 +86,12 @@ void array_copy_init(arr_t* x, const arr_t* s) { if (s->type >= VTYPE_STRING) { void *p, *v, *e; - void (*init)(void*, const void*); + type_initializer init; x->mem = p = malloc(x->size*vtype_size(x->type)); v = s->mem; e = array_end(x); - - switch (s->type) { default: abort(); - case VTYPE_STRING: init = (void*)string_copy_init; break; - case VTYPE_ARRAY: init = (void*) array_copy_init; break; - case VTYPE_LIST: init = (void*) list_copy_init; break; - case VTYPE_MAP: init = (void*) map_copy_init; break; - case VTYPE_SET: init = (void*) vset_copy_init; break; - } + init = get_type_initializer(s->type); do { init(p, v); @@ -125,19 +120,12 @@ size_t array_slice(arr_t* x, arr_t* s, ssize_t i, size_t n, _Bool cut) { if (!cut && s->type >= VTYPE_STRING) { void *p, *v, *e; - void (*init)(void*, const void*); + type_initializer init; - p = x->mem; - v = array_internal_at(s, i); - e = array_internal_at(x, n); - - switch (s->type) { default: abort(); - case VTYPE_STRING: init = (void*)string_copy_init; break; - case VTYPE_ARRAY: init = (void*) array_copy_init; break; - case VTYPE_LIST: init = (void*) list_copy_init; break; - case VTYPE_MAP: init = (void*) map_copy_init; break; - case VTYPE_SET: init = (void*) vset_copy_init; break; - } + p = x->mem; + v = array_internal_at(s, i); + e = array_internal_at(x, n); + init = get_type_initializer(s->type); do { init(p, v); From ee987964a1223b5066dbd3b1ff66b9daf67ed2e9 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:21:01 +0300 Subject: [PATCH 55/63] Update dict symbols --- src/dict/extra.c | 2 +- src/dict/generics.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/dict/extra.c b/src/dict/extra.c index 5b4aba5..49b914a 100644 --- a/src/dict/extra.c +++ b/src/dict/extra.c @@ -149,7 +149,7 @@ bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtyp } -int libcdsb_dict_get(dict_t* x, const void* k, vtype t, void* _, dict_access_callback callback, bool cut) { +int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* _, dict_access_callback callback, bool cut) { dnode_t *c; void* key; diff --git a/src/dict/generics.c b/src/dict/generics.c index 1c8ea7d..41ab6b0 100644 --- a/src/dict/generics.c +++ b/src/dict/generics.c @@ -3,26 +3,26 @@ #include "include.h" -int libcdsb_dict_get_by_pointer(dict_t* x, const void* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_cstring(dict_t* x, const char* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_string (dict_t* x, const str_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_array (dict_t* x, const arr_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_list (dict_t* x, const list_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_map (dict_t* x, const map_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_vset (dict_t* x, const set_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_dict (dict_t* x, const dict_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_get_by_boolean(dict_t* x, bool k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_int8 (dict_t* x, s8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_int16 (dict_t* x, s16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_int32 (dict_t* x, s32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_int64 (dict_t* x, s64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_uint8 (dict_t* x, u8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_uint16 (dict_t* x, u16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_uint32 (dict_t* x, u32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_uint64 (dict_t* x, u64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_float (dict_t* x, fl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_double (dict_t* x, dbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_get_by_ldouble(dict_t* x, ldbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_get(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_pointer(dict_t* x, const void* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_cstring(dict_t* x, const char* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_string (dict_t* x, const str_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_array (dict_t* x, const arr_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_list (dict_t* x, const list_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_map (dict_t* x, const map_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_vset (dict_t* x, const set_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_dict (dict_t* x, const dict_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } +int libcdsb_dict_find_by_boolean(dict_t* x, bool k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_int8 (dict_t* x, s8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_int16 (dict_t* x, s16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_int32 (dict_t* x, s32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_int64 (dict_t* x, s64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_uint8 (dict_t* x, u8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_uint16 (dict_t* x, u16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_uint32 (dict_t* x, u32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_uint64 (dict_t* x, u64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_float (dict_t* x, fl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_double (dict_t* x, dbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } +int libcdsb_dict_find_by_ldouble(dict_t* x, ldbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } bool libcdsb_dict_update_pointer_pointer(dict_t* x, const void* k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } bool libcdsb_dict_update_pointer_cstring(dict_t* x, const void* k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } From 21e5c0fd8c8ed2177dc7f1ab5b716c668c9eee05 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:21:35 +0300 Subject: [PATCH 56/63] Fix string methods --- src/string/extra.c | 2 ++ src/string/get.c | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/string/extra.c b/src/string/extra.c index 50600f2..6a8d0f0 100644 --- a/src/string/extra.c +++ b/src/string/extra.c @@ -200,6 +200,8 @@ size_t string_reverse(str_t* x) { p = memcpy(p - cs, v, cs); v += cs; } else *(--p) = *(v++); + + ++n; } free(x->buffer); diff --git a/src/string/get.c b/src/string/get.c index 5493471..4f2cac5 100644 --- a/src/string/get.c +++ b/src/string/get.c @@ -32,31 +32,34 @@ char* string_at(const str_t* s, ssize_t i) { } -bool string_slice(str_t* x, str_t* s, ssize_t i, size_t c, bool cut) { +size_t string_slice(str_t* x, str_t* s, ssize_t i, size_t c, bool cut) { char *e, *p, *v; + size_t n = 0; memset(x, 0, sizeof(*x)); - if (!c) return true; + if (!c) return n; p = string_at(s, i); - if (is_null(p) || (e = p + strlen(p)) > p + c) - return false; + if (is_null(p)) + return n; + e = p + strlen(p); v = p; - do { v = next_char(v); } while (--c && v < e); + while (c-- && v < e) { + v = next_char(v); + ++n; + } - if (!c) { - x->buffer = strndup(p, v - p); + x->buffer = strndup(p, v - p); - if (cut) { - memmove(p, v, strlen(v) + 1); - } + if (cut) { + memmove(p, v, strlen(v) + 1); + } - return true; - } else return false; + return n; } From 209745f525d32b9e479ca3390111593b3055deb4 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:21:56 +0300 Subject: [PATCH 57/63] Update tests --- tests/src/dict/src/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/dict/src/random.c b/tests/src/dict/src/random.c index 0218398..1149260 100644 --- a/tests/src/dict/src/random.c +++ b/tests/src/dict/src/random.c @@ -9,7 +9,7 @@ static int remove_callback(const void* k, vtype kt, void* v, vtype vt, void* _) if (!d->n--) { print_container_value(0, k, kt, 0, d->hp); - if (libcdsb_dict_get(d->x, k, kt, 0, 0, 1) == 0) { + if (libcdsb_dict_find(d->x, k, kt, 0, 0, 1) == 0) { printf("\e[%dG\e[32;1mSUCCESS\e[m\n", d->hp+1); } else printf("\e[%dG\e[31;1mFAILURE\e[m\n", d->hp+1); From 862e85145c8e7b61b0125a2afe078c4c33a09fcc Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 17 Aug 2022 22:22:30 +0300 Subject: [PATCH 58/63] Minor project core fixes --- src/extra-memory.c | 5 +++++ src/extra-stack.c | 1 + src/vtype-extra.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/extra-memory.c b/src/extra-memory.c index 0ff5783..afeeb49 100644 --- a/src/extra-memory.c +++ b/src/extra-memory.c @@ -8,6 +8,7 @@ #undef malloc #undef realloc #undef calloc +#undef free void* libcdsb_aalloc(size_t a, size_t n) { void* x; @@ -73,3 +74,7 @@ char* libcdsb_strndup(const char* s, size_t n) { } abort(); } + +void libcdsb_free(void* s) { + free(s); +} diff --git a/src/extra-stack.c b/src/extra-stack.c index 3a32bdf..f78fdb0 100644 --- a/src/extra-stack.c +++ b/src/extra-stack.c @@ -4,6 +4,7 @@ #include #include "__internal/include.h" #undef malloc +#undef free void libcdsb_stack_init(stack_t* x) { memset(x, 0, sizeof(*x)); diff --git a/src/vtype-extra.c b/src/vtype-extra.c index 244f90b..80f1bfc 100644 --- a/src/vtype-extra.c +++ b/src/vtype-extra.c @@ -26,13 +26,13 @@ static _Thread_local char STRINGIFY_BUFFER[64]; /*#####################################################################################################################*/ -const size_t LIBCDSB_VTYPE_SIZES[18] = { +const size_t LIBCDSB_VTYPE_SIZES[19] = { sizeof(void*), sizeof(bool), sizeof(u8_t), sizeof(u16_t), sizeof(u32_t), sizeof(u64_t), sizeof(s8_t), sizeof(s16_t), sizeof(s32_t), sizeof(s64_t), sizeof(fl_t), sizeof(dbl_t), sizeof(ldbl_t), sizeof(str_t), sizeof(map_t), sizeof(arr_t), - sizeof(list_t), sizeof(set_t) + sizeof(list_t), sizeof(set_t), sizeof(dict_t) }; From 3cbf7a6fdff8f9a6e46f42e5edf8e3562ef459da Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 18 Aug 2022 00:08:10 +0300 Subject: [PATCH 59/63] Add stack_push_many method --- include/extra/memory.h | 18 ++++++++++-------- src/extra-stack.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/include/extra/memory.h b/include/extra/memory.h index e27f73b..e5a595e 100644 --- a/include/extra/memory.h +++ b/include/extra/memory.h @@ -12,10 +12,11 @@ typedef struct libcdsb_stack_node { void* value; } stack_t; -extern void libcdsb_stack_init (stack_t* stack) Nonnull__(1); -extern void libcdsb_stack_push (stack_t* stack, void* value) Nonnull__(1); -extern void* libcdsb_stack_pop (stack_t* stack) Nonnull__(1); -extern void libcdsb_stack_flush(stack_t* stack) Nonnull__(1); +extern void libcdsb_stack_init (stack_t* stack) Nonnull__(1); +extern void libcdsb_stack_push (stack_t* stack, void* value) Nonnull__(1); +extern void libcdsb_stack_push_many(stack_t* stack, size_t n, ...) Nonnull__(1); +extern void* libcdsb_stack_pop (stack_t* stack) Nonnull__(1); +extern void libcdsb_stack_flush (stack_t* stack) Nonnull__(1); extern void* libcdsb_aalloc (size_t a, size_t n) Warn_unused_result__; extern void* libcdsb_malloc (size_t n) Warn_unused_result__; @@ -30,9 +31,10 @@ extern void libcdsb_free(void* s); #define realloc libcdsb_realloc #define free libcdsb_free -#define stack_init libcdsb_stack_init -#define stack_push libcdsb_stack_push -#define stack_pop libcdsb_stack_pop -#define stack_flush libcdsb_stack_flush +#define stack_init libcdsb_stack_init +#define stack_push libcdsb_stack_push +#define stack_push_many libcdsb_stack_push_many +#define stack_pop libcdsb_stack_pop +#define stack_flush libcdsb_stack_flush #endif /* LIBCDSB_EXTRA_MEMORY_H */ diff --git a/src/extra-stack.c b/src/extra-stack.c index f78fdb0..563a177 100644 --- a/src/extra-stack.c +++ b/src/extra-stack.c @@ -1,6 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include #include #include "__internal/include.h" #undef malloc @@ -26,6 +27,31 @@ void libcdsb_stack_push(stack_t* x, void* value) { x->value = value; } +void libcdsb_stack_push_many(stack_t* x, size_t c, ...) { + + va_list args; + stack_t* n; + va_start(args, c); + + if (c) { + if (!x->value) { + x->value = va_arg(args, void*); + --c; + } + + while (c--) { + if (!(n = malloc(sizeof(*n)))) + abort(); + + n->prev = x->prev; + n->value = x->value; + x->prev = n; + } + } + + va_end(args); +} + void* libcdsb_stack_pop(stack_t* x) { stack_t* n; From 72770c35612b91a99687a800b241c922d643197e Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 18 Aug 2022 00:15:54 +0300 Subject: [PATCH 60/63] Rollback excess abstractions for rbtree's types --- src/__internal/rbtree.h | 13 --- src/map/base.c | 177 +++++++++++++++++++++++----------- src/map/copy.c | 113 ++++++++++++++++++++++ src/map/extra.c | 12 ++- src/map/include.h | 4 - src/rbtree-extra.c | 206 ---------------------------------------- src/set/base.c | 160 ++++++++++++++++++++++++------- src/set/copy.c | 97 +++++++++++++++++++ 8 files changed, 468 insertions(+), 314 deletions(-) create mode 100644 src/map/copy.c delete mode 100644 src/rbtree-extra.c create mode 100644 src/set/copy.c diff --git a/src/__internal/rbtree.h b/src/__internal/rbtree.h index 8564bc1..01a5c10 100644 --- a/src/__internal/rbtree.h +++ b/src/__internal/rbtree.h @@ -29,17 +29,4 @@ extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node) #define rbnode_is_empty(n) ((n) == rbnode_empty) #define rbnode_is_root(n) rbnode_is_empty((n)->parent) -extern void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info) wur__ Nonnull__(1); -extern int libcdsb_rbtree_compare (const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info) pure__ wur__ Nonnull__(1,2); - -extern hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) pure__ wur__ Nonnull__(1); -extern size_t libcdsb_rbtree_size(const void* s) pure__ wur__ Nonnull__(1); -extern void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) Nonnull__(1); - -#define rbtree_duplicate libcdsb_rbtree_duplicate -#define rbtree_compare libcdsb_rbtree_compare -#define rbtree_hash libcdsb_rbtree_hash -#define rbtree_size libcdsb_rbtree_size -#define rbtree_free libcdsb_rbtree_free - #endif /* LIBCDSB_SRC_INTERNAL_RBTREE_H */ diff --git a/src/map/base.c b/src/map/base.c index de82733..026f180 100644 --- a/src/map/base.c +++ b/src/map/base.c @@ -3,89 +3,158 @@ #include "include.h" -#define mtree_duplicate(s, t) rbtree_duplicate((rbnode_t*)s, (void*)mnode_duplicate, t) -#define mtree_compare(s0, s1, t) rbtree_compare((void*)s0, (void*)s1, (void*)mnode_compare, (void*)t) +/*#####################################################################################################################*/ -static mnode_t* mnode_duplicate(const mnode_t* s, mnode_t* p, const vtype* t) { - mnode_t* x; - - x = mnode_create(vnode_duplicate(&s->key, *t), p, s->colored); - x->type = s->type; - x->value = vnode_duplicate(&s->value, s->type); - - return x; -} - -static int mnode_compare(const mnode_t* s0, const mnode_t* s1, vtype* t) { - int c = vnode_compare_eq(&s0->key, &s1->key, *t); +static inline int mnode_compare(const mnode_t* s0, const mnode_t* s1, vtype t) { + int c = vnode_compare_eq(&s0->key, &s1->key, t); return !c ? vnode_compare(&s0->value, s0->type, &s1->value, s1->type) : c; } -static hash_t mnode_hash(const mnode_t* s, vtype* tp) { - vtype t = (!is_null(tp)) ? *tp : VTYPE_POINTER; - return vnode_hash(s->key, t) + vnode_hash(s->value, s->type) + t; -} - -void libcdsb_mnode_free(mnode_t* x, vtype* t) { - vnode_free(&x->key, *t); - vnode_free(&x->value, x->type); +static inline hash_t mnode_hash(const mnode_t* s, vtype t) { + return vnode_hash(&s->key, t) + vnode_hash(&s->value, s->type) + t; } /*#####################################################################################################################*/ hash_t map_hash(const map_t* s) { - return rbtree_hash(s->root, (void*)mnode_hash, (void*)&s->type) + VTYPE_MAP; + + mnode_t *c0, *c1; + hash_t hash, v; + stack_t z; + + if (mnode_is_empty(s->root)) return 0; + + z.prev = 0; + hash = 1; + c1 = s->root; + + if (!rbnode_is_empty(z.value = c1->left)) { + do { + c0 = stack_pop(&z); + ++hash; + + if (!mnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!mnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); + } while (!is_null(z.value)); + } + + v = mnode_hash(c1, s->type); + c1 = s->root; + + if (!rbnode_is_empty(z.value = c1->right)) { + do { + c0 = stack_pop(&z); + ++hash; + + if (!mnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!mnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); + } while (!is_null(z.value)); + } + + v += mnode_hash(c1, s->type); + + return (hash ^ v) + VTYPE_MAP; } +/*#####################################################################################################################*/ + void map_init(map_t* x, vtype t) { x->root = mnode_empty; x->type = t; } void map_free(map_t* x) { - rbtree_free(x->root, (void*)mnode_free, &x->type); + mnode_t *t, *c; + + c = x->root; + + while (!mnode_is_empty(x->root)) { + if (!mnode_is_empty(c->left)) { + c = c->left; + } else if (!mnode_is_empty(c->right)) { + c = c->right; + } else if (!mnode_is_root(c)) { + vnode_free(&c->key, x->type); + vnode_free(&c->value, c->type); + + t = c; + c = c->parent; + + if (t == c->left) c->left = mnode_empty; + else c->right = mnode_empty; + + free(t); + } else { + vnode_free(&c->key, x->type); + vnode_free(&c->value, c->type); + x->root = mnode_empty; + } + } - x->root = mnode_empty; x->type = 0; } /*#####################################################################################################################*/ size_t map_size(const map_t* x) { - return rbtree_size(x->root); + stack_t z = { .prev = 0, .value = x->root }; + size_t n = 0; + rbnode_t* c; + + if (!mnode_is_empty(x->root)) { + while ((c = stack_pop(&z))) { + ++n; + if (!rbnode_is_empty(c->right)) stack_push(&z, c->right); + if (!rbnode_is_empty(c->left)) stack_push(&z, c->left); + } + } + + return n; } /*#####################################################################################################################*/ int map_compare(const map_t* s0, const map_t* s1) { - if (s0 == s1) return 0; - if (s0->type != s1->type) return s0->type - s1->type; + mnode_t *c0, *c1; + stack_t z; + int c = 0; - return mtree_compare(s0->root, s1->root, &s0->type); -} - -/*#####################################################################################################################*/ - -map_t map_copy(const map_t* s) { - map_t x; - - x.type = s->type; - x.root = mtree_duplicate(s->root, &x.type); - - return x; -} - -map_t* map_duplicate(const map_t* s) { - map_t *x = malloc(sizeof(*x)); - - x->type = s->type; - x->root = mtree_duplicate(s->root, &x->type); - - return x; -} - -void map_copy_init(map_t* x, const map_t* s) { - x->type = s->type; - x->root = mtree_duplicate(s->root, &x->type); + if (s0 == s1 || s0->root == s1->root) + return 0; + if (s0->type != s1->type) + return s0->type - s1->type; + + z.prev = 0; + z.value = 0; + + stack_push_many(&z, 2, (void*)s1, (void*)s0); + + do { + c0 = stack_pop(&z); + c1 = stack_pop(&z); + + if (mnode_is_empty(c0) || mnode_is_empty(c1)) { + if (c0 != c1) { + stack_flush(&z); + return mnode_is_empty(c0) ? -1 : 1; + } + } else if ((c = mnode_compare(c0, c1, s0->type))) { + if (c0->left == c1->right) { // == mnode_empty + c = mnode_compare(c0->right, c1, s0->type); + if (!c) c = mnode_compare(c0, c1->left, s0->type); + } else if (c0->right == c1->left) { // == mnode_empty + c = mnode_compare(c0, c1->right, s0->type); + if (!c) c = mnode_compare(c0->left, c1, s0->type); + } + + if (c) { + stack_flush(&z); + return c; + } + } else stack_push_many(&z, 4, c1->right, c0->right, c1->left, c0->left); + + } while (!is_null(z.value)); + + return 0; } diff --git a/src/map/copy.c b/src/map/copy.c new file mode 100644 index 0000000..7a3948f --- /dev/null +++ b/src/map/copy.c @@ -0,0 +1,113 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +/*#####################################################################################################################*/ + +static inline mnode_t* mnode_duplicate(const mnode_t* s, mnode_t* p, const vtype t) { + mnode_t* x; + + x = mnode_create(vnode_duplicate(&s->key, t), p, s->colored); + x->type = s->type; + x->value = vnode_duplicate(&s->value, s->type); + + return x; +} + +/*#####################################################################################################################*/ + +map_t map_copy(const map_t* s) { + + map_t x; + stack_t z = { .prev = 0, .value = s->root }; + + x.type = s->type; + + if (!mnode_is_empty(s->root)) { + x.root = mnode_duplicate(s->root, mnode_empty, s->type); + stack_push(&z, x.root); + + do { + mnode_t *p0 = stack_pop(&z); + mnode_t *p1 = stack_pop(&z); + + if (!mnode_is_empty(p1->left)) { + p0->left = mnode_duplicate(p1->left, p0, s->type); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!mnode_is_empty(p1->right)) { + p0->right = mnode_duplicate(p1->right, p0, s->type); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x.root = mnode_empty; + + return x; +} + + +map_t* map_duplicate(const map_t* s) { + + map_t* x = malloc(sizeof(*x)); + stack_t z = { .prev = 0, .value = s->root }; + + x->type = s->type; + + if (!mnode_is_empty(s->root)) { + x->root = mnode_duplicate(s->root, mnode_empty, s->type); + stack_push(&z, x->root); + + do { + mnode_t *p0 = stack_pop(&z); + mnode_t *p1 = stack_pop(&z); + + if (!mnode_is_empty(p1->left)) { + p0->left = mnode_duplicate(p1->left, p0, s->type); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!mnode_is_empty(p1->right)) { + p0->right = mnode_duplicate(p1->right, p0, s->type); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x->root = mnode_empty; + + return x; +} + + +void map_copy_init(map_t* x, const map_t* s) { + + stack_t z = { .prev = 0, .value = s->root }; + + x->type = s->type; + + if (!mnode_is_empty(s->root)) { + x->root = mnode_duplicate(s->root, mnode_empty, s->type); + stack_push(&z, x->root); + + do { + mnode_t *p0 = stack_pop(&z); + mnode_t *p1 = stack_pop(&z); + + if (!mnode_is_empty(p1->left)) { + p0->left = mnode_duplicate(p1->left, p0, s->type); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!mnode_is_empty(p1->right)) { + p0->right = mnode_duplicate(p1->right, p0, s->type); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x->root = mnode_empty; +} diff --git a/src/map/extra.c b/src/map/extra.c index 5f28450..b587b17 100644 --- a/src/map/extra.c +++ b/src/map/extra.c @@ -20,7 +20,8 @@ bool libcdsb_map_update(map_t* x, const void* k, vtype kt, const void* v, vtype cmp = vtype_compare(k, kt, vnode_peek(&n->key, kt), kt); if (cmp == 0) { - mnode_free(n, &kt); + vnode_free(&n->key, x->type); + vnode_free(&n->value, n->type); n->key = kn; n->value = vnode_create(v, vt); @@ -65,7 +66,8 @@ int libcdsb_map_find(map_t* x, const void* k, vtype t, void* _, map_access_callb if (cut) { c = mnode_delete(&x->root, c); - mnode_free(c, &x->type); + vnode_free(&c->key, x->type); + vnode_free(&c->value, c->type); free(c); } @@ -92,7 +94,8 @@ int libcdsb_map_foreach(map_t* x, void* dt, map_access_callback callback, bool f if (!mnode_is_empty(c->left)) stack_push(&z, c->left); if (flush) { - mnode_free(c, &x->type); + vnode_free(&c->key, x->type); + vnode_free(&c->value, c->type); free(c); } } @@ -102,7 +105,8 @@ int libcdsb_map_foreach(map_t* x, void* dt, map_access_callback callback, bool f if (!mnode_is_empty(c->right)) stack_push(&z, c->right); if (!mnode_is_empty(c->left)) stack_push(&z, c->left); - mnode_free(c, &x->type); + vnode_free(&c->key, x->type); + vnode_free(&c->value, c->type); free(c); c = stack_pop(&z); diff --git a/src/map/include.h b/src/map/include.h index 59f1c5b..fe07b6b 100644 --- a/src/map/include.h +++ b/src/map/include.h @@ -28,8 +28,6 @@ static_assert(offsetof(struct libcdsb_rbtree_node, value) == offsetof(struct lib static_assert(offsetof(struct libcdsb_set, root) == offsetof(struct libcdsb_map, root), "Implementation assert"); static_assert(offsetof(struct libcdsb_set, type) == offsetof(struct libcdsb_map, type), "Implementation assert"); -extern void libcdsb_mnode_free(mnode_t* x, vtype* t); - #define mnode_empty ((mnode_t*)LIBCDSB_RBTREE_NODE_EMPTY) #define mnode_create(k, p, c) ((mnode_t*)libcdsb_rbtree_node_create(k, (rbnode_t*)p, c, sizeof(mnode_t))) #define mnode_fixup(r, n) libcdsb_rbtree_node_fixup((rbnode_t**)(r), (rbnode_t*)(n)) @@ -38,6 +36,4 @@ extern void libcdsb_mnode_free(mnode_t* x, vtype* t); #define mnode_is_empty(n) ((n) == mnode_empty) #define mnode_is_root(n) mnode_is_empty((n)->parent) -#define mnode_free libcdsb_mnode_free - #endif /* LIBCDSB_SRC_MAP_INCLUDE_H */ diff --git a/src/rbtree-extra.c b/src/rbtree-extra.c deleted file mode 100644 index 40b2821..0000000 --- a/src/rbtree-extra.c +++ /dev/null @@ -1,206 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "__internal/rbtree.h" - -/*#####################################################################################################################*/ - -static rbnode_t* rbnode_duplicate(const rbnode_t* s, rbnode_t* p, const vtype* info) { - return rbnode_create(vnode_duplicate(&s->value, (info) ? *info : VTYPE_POINTER), p, s->colored); -} - -static int rbnode_compare(const rbnode_t* s0, const rbnode_t* s1, vtype* tp) { - vtype t = !is_null(tp) ? *tp : VTYPE_POINTER; - return vnode_compare(s0->value, t, s1->value, t); -} - -static hash_t rbnode_hash(const rbnode_t* s, vtype* tp) { - vtype t = (!is_null(tp)) ? *tp : VTYPE_POINTER; - return vnode_hash(s->value, t); -} - -static void rbnode_free(rbnode_t* x, vtype *t) { - if (!is_null(t)) vnode_free(&x->value, *t); -} - -/*#####################################################################################################################*/ - -hash_t libcdsb_rbtree_hash(const void* s, hash_t (*node_hash)(const void* s, void* info), void* info) { - - rbnode_t *c0, *c1; - hash_t hash, v; - stack_t z; - - if (rbnode_is_empty(s)) return 0; - if (is_null(node_hash)) node_hash = (void*)rbnode_hash; - - z.prev = 0; - hash = 1; - c1 = (void*)s; - - if (!rbnode_is_empty(z.value = c1->left)) do { - c0 = stack_pop(&z); - ++hash; - if (!rbnode_is_empty(c0->left)) - stack_push(&z, c1 = c0->left); - if (!rbnode_is_empty(c0->right)) - stack_push(&z, c0->right); - } while (!is_null(z.value)); - - v = node_hash(c1, info); - c1 = (void*)s; - - if (!rbnode_is_empty(z.value = c1->right)) do { - c0 = stack_pop(&z); - ++hash; - if (!rbnode_is_empty(c0->left)) - stack_push(&z, c1 = c0->left); - if (!rbnode_is_empty(c0->right)) - stack_push(&z, c0->right); - } while (!is_null(z.value)); - - v += node_hash(c1, info); - - return hash ^ v; -} - -/*#####################################################################################################################*/ - -void* libcdsb_rbtree_duplicate(const rbnode_t* s, void* (*node_duplicate)(void* src, void* parent, void* info), void* info) { - rbnode_t *p0, *p1, *x; - stack_t z; - - z.prev = 0; - z.value = (void*)s; - - if (is_null(node_duplicate)) { - node_duplicate = (void*)rbnode_duplicate; - } - - if (!rbnode_is_empty(s)) { - x = node_duplicate(z.value, rbnode_empty, info); - stack_push(&z, x); - - do { - p0 = stack_pop(&z); - p1 = stack_pop(&z); - - if (!rbnode_is_empty(p1->left)) { - p0->left = node_duplicate(p1->left, p0, info); - - stack_push(&z, p1->left); - stack_push(&z, p0->left); - } - - if (!rbnode_is_empty(p1->right)) { - p0->right = node_duplicate(p1->right, p0, info); - - stack_push(&z, p1->right); - stack_push(&z, p0->right); - } - - } while (!is_null(z.value)); - - } else x = rbnode_empty; - - return x; -} - -/*#####################################################################################################################*/ - -int libcdsb_rbtree_compare(const rbnode_t* s0, const rbnode_t* s1, int (*node_compare)(const rbnode_t* s0, const rbnode_t* s1, void* info), void* info) { - - rbnode_t *c0, *c1; - stack_t z; - int c = 0; - - if (s0 == s1) return 0; - if (is_null(node_compare)) node_compare = (void*)rbnode_compare; - - z.prev = 0; - z.value = 0; - - stack_push(&z, (void*)s1); - stack_push(&z, (void*)s0); - - do { - c0 = stack_pop(&z); - c1 = stack_pop(&z); - - if (rbnode_is_empty(c0) || rbnode_is_empty(c1)) { - if (c0 != c1) { - stack_flush(&z); - return rbnode_is_empty(c0) ? -1 : 1; - } - } else if ((c = node_compare(c0, c1, info))) { - if (c0->left == c1->right) { // <-- rbnode_empty - c = node_compare(c0->right, c1, info); - if (!c) c = node_compare(c0, c1->left, info); - } else if (c0->right == c1->left) { // <-- rbnode_empty - c = node_compare(c0, c1->right, info); - if (!c) c = node_compare(c0->left, c1, info); - } - - if (c) { - stack_flush(&z); - return c; - } - } else { - stack_push(&z, c1->right); - stack_push(&z, c0->right); - stack_push(&z, c1->left); - stack_push(&z, c0->left); - } - - } while (!is_null(z.value)); - - return 0; -} - - -size_t libcdsb_rbtree_size(const void* s) { - stack_t z = { .prev = 0, .value = (void*)s }; - size_t n = 0; - rbnode_t* c; - - if (!rbnode_is_empty(s)) { - while ((c = stack_pop(&z))) { - ++n; - if (!rbnode_is_empty(c->left)) - stack_push(&z, c->left); - if (!rbnode_is_empty(c->right)) - stack_push(&z, c->right); - } - } - - return n; -} - - -void libcdsb_rbtree_free(void* x, void (*node_free)(void* x, void* info), void* info) { - rbnode_t *t, *c; - - c = x; - if (is_null(node_free)) node_free = (void*)rbnode_free; - - while (!rbnode_is_empty(x)) { - if (!rbnode_is_empty(c->left)) { - c = c->left; - } else if (!rbnode_is_empty(c->right)) { - c = c->right; - } else if (!rbnode_is_root(c)) { - node_free(c, info); - - t = c; - c = c->parent; - - if (t == c->left) c->left = rbnode_empty; - else c->right = rbnode_empty; - - free(t); - } else { - node_free(c, info); - x = rbnode_empty; - } - } -} diff --git a/src/set/base.c b/src/set/base.c index 17d5427..f10f02b 100644 --- a/src/set/base.c +++ b/src/set/base.c @@ -6,10 +6,58 @@ /*#####################################################################################################################*/ -hash_t vset_hash(const set_t* s) { - return rbtree_hash(s->root, nullptr, (void*)&s->type) + VTYPE_SET; +static inline int rbnode_compare(const rbnode_t* s0, const rbnode_t* s1, vtype t) { + return vnode_compare(s0->value, t, s1->value, t); } +static inline hash_t rbnode_hash(const rbnode_t* s, vtype t) { + return vnode_hash(&s->value, t); +} + +/*#####################################################################################################################*/ + +hash_t vset_hash(const set_t* s) { + + rbnode_t *c0, *c1; + hash_t hash, v; + stack_t z; + + if (rbnode_is_empty(s->root)) return 0; + + z.prev = 0; + hash = 1; + c1 = s->root; + + if (!rbnode_is_empty(z.value = c1->left)) { + do { + c0 = stack_pop(&z); + ++hash; + + if (!rbnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!rbnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); + } while (!is_null(z.value)); + } + + v = rbnode_hash(c1, s->type); + c1 = s->root; + + if (!rbnode_is_empty(z.value = c1->right)) { + do { + c0 = stack_pop(&z); + ++hash; + + if (!rbnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!rbnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); + } while (!is_null(z.value)); + } + + v += rbnode_hash(c1, s->type); + + return (hash ^ v) + VTYPE_SET; +} + +/*#####################################################################################################################*/ + void vset_init(set_t* x, vtype t) { x->root = rbnode_empty; x->type = t; @@ -17,48 +65,94 @@ void vset_init(set_t* x, vtype t) { void vset_free(set_t* x) { - rbtree_free(x->root, nullptr, &x->type); + rbnode_t *t, *c; + + c = x->root; + + while (!rbnode_is_empty(x->root)) { + if (!rbnode_is_empty(c->left)) { + c = c->left; + } else if (!rbnode_is_empty(c->right)) { + c = c->right; + } else if (!rbnode_is_root(c)) { + vnode_free(&c->value, x->type); + + t = c; + c = c->parent; + + if (t == c->left) c->left = rbnode_empty; + else c->right = rbnode_empty; + + free(t); + } else { + vnode_free(&c->value, x->type); + x->root = rbnode_empty; + } + } - x->root = rbnode_empty; x->type = 0; } /*#####################################################################################################################*/ size_t vset_size(const set_t* x) { - return rbtree_size(x->root); + stack_t z = { .prev = 0, .value = x->root }; + size_t n = 0; + rbnode_t* c; + + if (!rbnode_is_empty(x->root)) { + while ((c = stack_pop(&z))) { + ++n; + if (!rbnode_is_empty(c->right)) stack_push(&z, c->right); + if (!rbnode_is_empty(c->left)) stack_push(&z, c->left); + } + } + + return n; } /*#####################################################################################################################*/ int vset_compare(const set_t* s0, const set_t* s1) { - if (s0 == s1) return 0; - if (s0->type != s1->type) return s0->type - s1->type; + rbnode_t *c0, *c1; + stack_t z; + int c = 0; - return rbtree_compare(s0->root, s1->root, nullptr, (void*)&s0->type); -} - -/*#####################################################################################################################*/ - -set_t vset_copy(const set_t* s) { - set_t x; - - x.type = s->type; - x.root = rbtree_duplicate(s->root, nullptr, &x.type); - - return x; -} - -set_t* vset_duplicate(const set_t* s) { - set_t *x = malloc(sizeof(*x)); - - x->type = s->type; - x->root = rbtree_duplicate(s->root, nullptr, &x->type); - - return x; -} - -void vset_copy_init(set_t* x, const set_t* s) { - x->type = s->type; - x->root = rbtree_duplicate(s->root, nullptr, &x->type); + if (s0 == s1 || s0->root == s1->root) + return 0; + if (s0->type != s1->type) + return s0->type - s1->type; + + z.prev = 0; + z.value = 0; + + stack_push_many(&z, 2, (void*)s1, (void*)s0); + + do { + c0 = stack_pop(&z); + c1 = stack_pop(&z); + + if (rbnode_is_empty(c0) || rbnode_is_empty(c1)) { + if (c0 != c1) { + stack_flush(&z); + return rbnode_is_empty(c0) ? -1 : 1; + } + } else if ((c = rbnode_compare(c0, c1, s0->type))) { + if (c0->left == c1->right) { // == rbnode_empty + c = rbnode_compare(c0->right, c1, s0->type); + if (!c) c = rbnode_compare(c0, c1->left, s0->type); + } else if (c0->right == c1->left) { // == rbnode_empty + c = rbnode_compare(c0, c1->right, s0->type); + if (!c) c = rbnode_compare(c0->left, c1, s0->type); + } + + if (c) { + stack_flush(&z); + return c; + } + } else stack_push_many(&z, 4, c1->right, c0->right, c1->left, c0->left); + + } while (!is_null(z.value)); + + return 0; } diff --git a/src/set/copy.c b/src/set/copy.c new file mode 100644 index 0000000..a074b0b --- /dev/null +++ b/src/set/copy.c @@ -0,0 +1,97 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../include/set.h" +#include "../__internal/rbtree.h" + +set_t vset_copy(const set_t* s) { + + set_t x = { .type = s->type }; + stack_t z = { .prev = 0, .value = s->root }; + vtype t = s->type; + + if (!rbnode_is_empty(s->root)) { + x.root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + stack_push(&z, x.root); + + do { + rbnode_t *p0 = stack_pop(&z); + rbnode_t *p1 = stack_pop(&z); + + if (!rbnode_is_empty(p1->left)) { + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!rbnode_is_empty(p1->right)) { + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x.root = rbnode_empty; + + return x; +} + + +set_t* vset_duplicate(const set_t* s) { + + set_t* x = malloc(sizeof(*x)); + stack_t z = { .prev = 0, .value = s->root }; + vtype t = x->type = s->type; + + if (!rbnode_is_empty(s->root)) { + x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + stack_push(&z, x->root); + + do { + rbnode_t *p0 = stack_pop(&z); + rbnode_t *p1 = stack_pop(&z); + + if (!rbnode_is_empty(p1->left)) { + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!rbnode_is_empty(p1->right)) { + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x->root = rbnode_empty; + + return x; +} + + +void vset_copy_init(set_t* x, const set_t* s) { + + stack_t z = { .prev = 0, .value = s->root }; + vtype t = x->type = s->type; + + if (!rbnode_is_empty(s->root)) { + x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + stack_push(&z, x->root); + + do { + rbnode_t *p0 = stack_pop(&z); + rbnode_t *p1 = stack_pop(&z); + + if (!rbnode_is_empty(p1->left)) { + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + stack_push_many(&z, 2, p1->left, p0->left); + } + + if (!rbnode_is_empty(p1->right)) { + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + stack_push_many(&z, 2, p1->right, p0->right); + } + + } while (!is_null(z.value)); + + } else x->root = rbnode_empty; +} From b2fa470bce98f4aa7106029cc623c63e35e0e195 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 18 Aug 2022 02:27:26 +0300 Subject: [PATCH 61/63] Simplify dnode_t excess logic --- src/dict/base.c | 199 +++++++++++------------------------------- src/dict/copy.c | 82 +++++++++++++++++ src/dict/extra.c | 213 ++++++++++++++++----------------------------- src/dict/include.h | 30 ++----- 4 files changed, 215 insertions(+), 309 deletions(-) create mode 100644 src/dict/copy.c diff --git a/src/dict/base.c b/src/dict/base.c index 35ec012..76f7632 100644 --- a/src/dict/base.c +++ b/src/dict/base.c @@ -3,142 +3,61 @@ #include "include.h" -#define dtree_duplicate(s) rbtree_duplicate((rbnode_t*)s, (void*)dnode_duplicate, nullptr) -#define dtree_compare(s0, s1) rbtree_compare((void*)s0, (void*)s1, (void*)dnode_compare, nullptr) - -static dnode_t* dnode_duplicate(const dnode_t* s, dnode_t* p, void* not_used) { - dnode_t* x; - - x = dnode_create(vnode_duplicate(&s->key, s->key_type), p, s->colored); - x->key_type = s->key_type; - x->val_type = s->val_type; - x->value = vnode_duplicate(&s->value, s->val_type); - - return x; -} - -static int dnode_compare(const dnode_t *s0, const dnode_t *s1, void* not_used) { - int c = vnode_compare(&s0->key, s1->key_type, &s1->key, s1->key_type); - - return (!c) ? vnode_compare(&s0->value, s1->val_type, &s1->value, s1->val_type) : c; -} - -/*#####################################################################################################################*/ - -static int dict_compare_equal_capacity(const dict_t* s0, const dict_t* s1) { - int c; - - for (size_t i = 0; i < s0->capacity; ++i) { - if ((c = dtree_compare(s0->nodes[i], s1->nodes[i]))) { - return c; - } - } - - return 0; -} - - -static int dict_compare_unequal_capacity(const dict_t* s0, const dict_t* s1) { - const dict_t *x, *y; - dnode_t *c0, *c1; - int cmp; - - stack_t z; - - if (s0->capacity <= s1->capacity) { - x = s0; - y = s1; - } else { - x = s1; - y = s0; - } - - z.prev = 0; - z.value = 0; - - for (size_t i = 0; i < x->capacity; ++i) { - if (!dnode_is_empty(x->nodes[i])) - stack_push(&z, x->nodes[i]); - } - - while ((c0 = stack_pop(&z))) { - - c1 = y->nodes[vnode_hash(c0->key, c0->key_type) / y->capacity]; - cmp = 1; - - while (!dnode_is_empty(c1)) { - - cmp = vnode_compare(c0->key, c0->key_type, c1->key, c1->key_type); - - if (cmp == 0) break; - - c1 = (cmp < 0) ? c1->left : c1->right; - } - - if (cmp) return x == s0 ? cmp : ~cmp + 1; - - if (!dnode_is_empty(c0->right)) stack_push(&z, c0->right); - if (!dnode_is_empty(c0->left)) stack_push(&z, c0->left); - } - - return 0; -} - /*#####################################################################################################################*/ hash_t dict_hash(const dict_t* s) { - dnode_t *l, *r; - hash_t hash; + dnode_t *min, *max; + size_t i; + dnode_t *c; + hash_t hash; - if (!s->size) return 0; + if (!s->size) + return 0; - l = dnode_empty; - r = dnode_empty; + min = max = nullptr; + i = s->capacity; - for (size_t i = 0; i < s->capacity; ++i) { - if (!dnode_is_empty(s->nodes[i])) { - if (dnode_is_empty(l) || vnode_compare(s->nodes[i]->key, s->nodes[i]->key_type, l->key, l->key_type) < 0) { - l = s->nodes[i]; - } + while (i--) { + c = s->nodes[i]; - if (dnode_is_empty(r) || vnode_compare(s->nodes[i]->key, s->nodes[i]->key_type, r->key, r->key_type) > 0) { - r = s->nodes[i]; - } + while (!is_null(c)) { + if (is_null(min) || vnode_compare(&c->key, c->key_type, &min->key, min->key_type) < 0) min = c; + if (is_null(max) || vnode_compare(&c->key, c->key_type, &max->key, max->key_type) > 0) max = c; + + c = c->prev; } } - while (!dnode_is_empty(l->left)) - l = l->left; + hash = vnode_hash(&min->key, min->key_type); - while (!dnode_is_empty(r->right)) - r = r->right; - - hash = vnode_hash(l->key, l->key_type) + vnode_hash(l->value, l->val_type); - - if (l != r) hash += vnode_hash(r->key, r->key_type) + vnode_hash(r->value, r->val_type); + if (s->size > 0) + hash += vnode_hash(&max->key, max->key_type); return (hash ^ s->size) + VTYPE_DICT; } + void dict_init(dict_t* x) { memset(x, 0, sizeof(*x)); } - +/*#####################################################################################################################*/ void dict_free(dict_t* x) { - for (size_t i = 0; i < x->capacity; ++i) - rbtree_free(x->nodes[i], (void*)dnode_free, nullptr); + + while (x->capacity--) { + while (!is_null(x->nodes[x->capacity])) { + vnode_free(&x->nodes[x->capacity]->key, x->nodes[x->capacity]->key_type); + vnode_free(&x->nodes[x->capacity]->value, x->nodes[x->capacity]->value_type); + + x->nodes[x->capacity] = x->nodes[x->capacity]->prev; + } + } free(x->nodes); memset(x, 0, sizeof(*x)); } -void libcdcb_dnode_free(dnode_t* x, void* not_used) { - vnode_free(&x->key, x->key_type); - vnode_free(&x->value, x->val_type); -} - /*#####################################################################################################################*/ size_t dict_size(const dict_t* x) { @@ -152,6 +71,9 @@ size_t dict_capacity(const dict_t* x) { /*#####################################################################################################################*/ int dict_compare(const dict_t* s0, const dict_t* s1) { + dnode_t *c0, *c1; + size_t i; + int cmp; if (s0 == s1) return 0; @@ -159,48 +81,31 @@ int dict_compare(const dict_t* s0, const dict_t* s1) { if (s0->size != s1->size) return s0->size < s1->size ? -1 : 1; - if (s0->capacity == s1->capacity) - return dict_compare_equal_capacity(s0, s1); + i = s0->capacity; - return dict_compare_unequal_capacity(s0, s1); -} + while (i--) { + c0 = s0->nodes[i]; -/*#####################################################################################################################*/ + while (!is_null(c0)) { -dict_t dict_copy(const dict_t* s) { - dict_t x; + c1 = s1->nodes[vnode_hash(&c0->key, c0->key_type) % s1->capacity]; + cmp = -1; - x.capacity = s->capacity; - x.size = s->size; - x.nodes = malloc(x.size * sizeof(*x.nodes)); + while (!is_null(c1)) { + if ((cmp = vnode_compare(&c0->key, c0->key_type, &c1->key, c1->key_type) == 0)) { - for (size_t i = 0; i < x.capacity; ++i) { - x.nodes[i] = dtree_duplicate(s->nodes[i]); + cmp = vnode_compare(&c0->value, c0->value_type, &c1->value, c1->value_type); + break; + } + + c1 = c1->prev; + } + + if (cmp) return cmp; + + c0 = c0->prev; + } } - return x; -} - -dict_t* dict_duplicate(const dict_t* s) { - dict_t *x = malloc(sizeof(*x)); - - x->capacity = s->capacity; - x->size = s->size; - x->nodes = malloc(x->size * sizeof(*x->nodes)); - - for (size_t i = 0; i < x->capacity; ++i) { - x->nodes[i] = dtree_duplicate(s->nodes[i]); - } - - return x; -} - -void dict_copy_init(dict_t* x, const dict_t* s) { - x->capacity = s->capacity; - x->size = s->size; - x->nodes = malloc(x->size * sizeof(*x->nodes)); - - for (size_t i = 0; i < x->capacity; ++i) { - x->nodes[i] = dtree_duplicate(s->nodes[i]); - } + return 0; } diff --git a/src/dict/copy.c b/src/dict/copy.c new file mode 100644 index 0000000..35931a7 --- /dev/null +++ b/src/dict/copy.c @@ -0,0 +1,82 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +/*#####################################################################################################################*/ + +static inline dnode_t* dnode_duplicate(const dnode_t* s, dnode_t* p) { + dnode_t* x = malloc(sizeof(*x)); + + x->prev = p; + x->key = vnode_duplicate(&s->key, s->key_type); + x->value = vnode_duplicate(&s->value, s->value_type); + x->key_type = s->key_type; + x->value_type = s->value_type; + + return x; +} + +/*#####################################################################################################################*/ + +dict_t dict_copy(const dict_t* s) { + dict_t x; + size_t i; + dnode_t *n; + + x.capacity = i = s->capacity; + x.size = s->size; + x.nodes = calloc(x.capacity, sizeof(*x.nodes)); + + while (i--) { + n = s->nodes[i]; + + while (!is_null(n)) { + x.nodes[i] = dnode_duplicate(n, x.nodes[i]); + n = n->prev; + } + } + + return x; +} + + +dict_t* dict_duplicate(const dict_t* s) { + dict_t *x = malloc(sizeof(*x)); + size_t i; + dnode_t *n; + + x->capacity = i = s->capacity; + x->size = s->size; + x->nodes = calloc(x->capacity, sizeof(*x->nodes)); + + while (i--) { + n = s->nodes[i]; + + while (!is_null(n)) { + x->nodes[i] = dnode_duplicate(n, x->nodes[i]); + n = n->prev; + } + } + + return x; +} + + +void dict_copy_init(dict_t* x, const dict_t* s) { + size_t i; + dnode_t *n; + + x->capacity = i = s->capacity; + x->size = s->size; + x->nodes = calloc(x->capacity, sizeof(*x->nodes)); + + while (i--) { + n = s->nodes[i]; + + while (!is_null(n)) { + x->nodes[i] = dnode_duplicate(n, x->nodes[i]); + n = n->prev; + } + } +} diff --git a/src/dict/extra.c b/src/dict/extra.c index 49b914a..81d645c 100644 --- a/src/dict/extra.c +++ b/src/dict/extra.c @@ -6,72 +6,28 @@ /*#####################################################################################################################*/ static void dict_rehash(dict_t* s, size_t capacity) { - stack_t z; - int cmp; - size_t index; - dnode_t *c, *p, *n; + dnode_t **nodes, *c, *n, **p; + size_t i; - dnode_t **nodes = calloc(capacity, sizeof(*nodes)); + i = s->capacity; + nodes = calloc(sizeof(*nodes), capacity); - z.prev = 0; - z.value = 0; - index = s->capacity; + while (i--) { + c = s->nodes[i]; - while (index--) { - if (!dnode_is_empty(s->nodes[index])) - stack_push(&z, s->nodes[index]); - } + while (!is_null(c)) { + p = nodes + (vnode_hash(&c->key, c->key_type) % capacity); + n = c->prev; + c->prev = *p; - while ((c = stack_pop(&z))) { - - if (!dnode_is_empty(c->right)) { - stack_push(&z, c->right); - c->right = dnode_empty; - } - - if (!dnode_is_empty(c->left)) { - stack_push(&z, c->left); - c->left = dnode_empty; - } - - index = vnode_hash(&c->key, c->key_type) % capacity; - n = nodes[index]; - - if (!is_null(nodes[index])) { - do { - p = n; - cmp = vnode_compare(&c->key, c->key_type, &n->key, n->key_type); - n = (cmp <= 0) ? n->left : n->right; - } while (!dnode_is_empty(n)); - - if (cmp < 0) p->left = c; - else p->right = c; - - c->parent = p; - c->colored = 1; - - if (!dnode_is_root(p)) - dnode_fixup(nodes + index, n); - - } else { - nodes[index] = c; - c->colored = 0; - c->parent = dnode_empty; + *p = c; + c = n; } } free(s->nodes); - s->nodes = nodes; - - if (capacity > s->capacity) { - s->capacity = capacity; - while (capacity--) { - if (is_null(*nodes)) - *nodes = dnode_empty; - ++nodes; - } - } else s->capacity = capacity; + s->capacity = capacity; } /*#####################################################################################################################*/ @@ -96,86 +52,62 @@ bool libcdsb_dict_shrink_to_fit(dict_t* s) { bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { - - dnode_t *n, *p; - vnode_t kn, vn; - int cmp; - size_t index; + dnode_t *c, **p; if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) dict_rehash(x, x->capacity + CAPACITY_BLOCK); - index = vtype_hash(k, kt) % x->capacity; - n = x->nodes[index]; - kn = vnode_create(k, kt); - vn = vnode_create(v, vt); + c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); - if (!dnode_is_empty(n)) { - do { - p = n; - cmp = vtype_compare(k, kt, vnode_peek(&n->key, n->key_type), n->key_type); + while (!is_null(c)) { + if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { + vnode_free(&c->value, c->value_type); - if (cmp == 0) { - dnode_free(n, nullptr); + c->value = vnode_create(v, vt); + c->value_type = vt; - n->key = kn; - n->value = vn; - n->key_type = kt; - n->val_type = vt; + return true; + } else c = c->prev; + } - return true; - } + c = malloc(sizeof(*c)); - n = (cmp < 0) ? n->left : n->right; - } while (!dnode_is_empty(n)); - - n = dnode_create(kn, p, 1); - - if (cmp < 0) p->left = n; - else p->right = n; - - if (!dnode_is_root(p)) - dnode_fixup(x->nodes + index, n); - - } else x->nodes[index] = n = dnode_create(kn, dnode_empty, 0); - - n->value = vn; - n->key_type = kt; - n->val_type = vt; + c->prev = *p; + c->key = vnode_create(k, kt); + c->value = vnode_create(v, vt); + c->key_type = kt; + c->value_type = vt; + *p = c; ++x->size; return false; } -int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* _, dict_access_callback callback, bool cut) { - - dnode_t *c; - void* key; - int cmp; - size_t index; +int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* dt, dict_access_callback callback, bool cut) { + dnode_t *c, **p; + int r; + void* key; if (x->capacity) { - index = vtype_hash(k, t) % x->capacity; - c = x->nodes[index]; + c = *(p = x->nodes + (vtype_hash(k, t) % x->capacity)); - while (!dnode_is_empty(c)) { + while (!is_null(c)) { key = vnode_peek(&c->key, c->key_type); - cmp = vtype_compare(k, t, key, c->key_type); - - if (cmp == 0) { - cmp = (callback) ? callback(key, c->key_type, vnode_peek(&c->value, c->val_type), c->val_type, _) : 0; + if (vtype_compare(k, t, key, c->key_type) == 0) { + r = (callback) ? callback(key, c->key_type, vnode_peek(&c->value, c->value_type), c->value_type, dt) : 0; if (cut) { - c = dnode_delete(x->nodes + index, c); - dnode_free(c, nullptr); + *p = c->prev; + vnode_free(&c->key, c->key_type); + vnode_free(&c->value, c->value_type); free(c); --x->size; } - return cmp; - } else c = (cmp < 0) ? c->left : c->right; + return r; + } else c = *(p = &c->prev); } } @@ -184,49 +116,54 @@ int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* _, dict_access_ca int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, bool flush) { - stack_t z; - int r; - dnode_t* c; + dnode_t *c; + ssize_t i; + int r; - r = 0; - z.prev = 0; - z.value = 0; + r = 0; + i = x->capacity; - for (size_t i = 0; i < x->capacity; ++i) { - if (!dnode_is_empty(x->nodes[i])) - stack_push(&z, x->nodes[i]); - } + while (i) { + c = x->nodes[--i]; - while ((c = stack_pop(&z))) { - void* k = vnode_peek(&c->key, c->key_type); - void* v = vnode_peek(&c->value, c->val_type); + while (!is_null(c)) { + r = callback(vnode_peek(&c->key, c->key_type), c->key_type, + vnode_peek(&c->value, c->value_type), c->value_type, dt); - if ((r = callback(k, c->key_type, v, c->val_type, dt))) - break; + c = c->prev; - if (!dnode_is_empty(c->right)) stack_push(&z, c->right); - if (!dnode_is_empty(c->left)) stack_push(&z, c->left); + if (r) { + if (!flush) goto end_; + else goto flush_loop_; + } else if (flush) { + vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); + vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); + free(x->nodes[i]); - if (flush) { - dnode_free(c, nullptr); - free(c); + x->nodes[i] = c; + } } } if (flush) { - while (c) { - if (!dnode_is_empty(c->right)) stack_push(&z, c->right); - if (!dnode_is_empty(c->left)) stack_push(&z, c->left); + while (i) { + --i; - dnode_free(c, nullptr); - free(c); + while (!is_null(x->nodes[i])) { flush_loop_: + vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); + vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); - c = stack_pop(&z); + c = x->nodes[i]->prev; + free(x->nodes[i]); + + x->nodes[i] = c; + } } free(x->nodes); memset(x, 0, sizeof(*x)); - } else stack_flush(&z); + } + end_: return r; } diff --git a/src/dict/include.h b/src/dict/include.h index 9926a72..dc726d1 100644 --- a/src/dict/include.h +++ b/src/dict/include.h @@ -15,34 +15,16 @@ #endif #define REBUILD_POINT_MAX 0.65 + typedef struct libcdsb_dict_node { - struct libcdsb_dict_node* left; - struct libcdsb_dict_node* right; - struct libcdsb_dict_node* parent; + struct libcdsb_dict_node* prev; vnode_t key; - short colored; - u8_t key_type; - u8_t val_type; vnode_t value; + + u16_t key_type; + u16_t value_type; } dnode_t; -static_assert(offsetof(struct libcdsb_rbtree_node, left) == offsetof(struct libcdsb_dict_node, left), "Implementation assert"); -static_assert(offsetof(struct libcdsb_rbtree_node, right) == offsetof(struct libcdsb_dict_node, right), "Implementation assert"); -static_assert(offsetof(struct libcdsb_rbtree_node, parent) == offsetof(struct libcdsb_dict_node, parent), "Implementation assert"); -static_assert(offsetof(struct libcdsb_rbtree_node, colored) == offsetof(struct libcdsb_dict_node, colored), "Implementation assert"); -static_assert(offsetof(struct libcdsb_rbtree_node, value) == offsetof(struct libcdsb_dict_node, key), "Implementation assert"); -#define dnode_empty ((dnode_t*)LIBCDSB_RBTREE_NODE_EMPTY) -#define dnode_create(k, p, c) ((dnode_t*)libcdsb_rbtree_node_create(k, (rbnode_t*)p, c, sizeof(dnode_t))) -#define dnode_fixup(r, n) libcdsb_rbtree_node_fixup((rbnode_t**)(r), (rbnode_t*)(n)) -#define dnode_delete(r, n) (dnode_t*)libcdsb_rbtree_node_delete((rbnode_t**)(r), (rbnode_t*)(n)) - -#define dnode_is_empty(n) ((n) == dnode_empty) -#define dnode_is_root(n) dnode_is_empty((n)->parent) - -extern void libcdcb_dnode_free(dnode_t* x, void* not_used); - -#define dnode_free libcdcb_dnode_free - -#endif /* LIBCDSB_SRC_MAP_INCLUDE_H */ +#endif /* LIBCDSB_SRC_DICT_INCLUDE_H */ From e8d3b55ec98ad75766399b8a4cbf679a8435f6ff Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 18 Aug 2022 02:43:56 +0300 Subject: [PATCH 62/63] Add dict keys copy methods --- include/extra/dict.h | 13 +++++++++ src/dict/extra.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/include/extra/dict.h b/include/extra/dict.h index 972b77b..1f8edc5 100644 --- a/include/extra/dict.h +++ b/include/extra/dict.h @@ -14,3 +14,16 @@ extern int libcdsb_dict_foreach (vtype_dict* x, void* data, dict_access_ca extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) Nonnull__(1); #endif /* LIBCDSB_EXTRA_DICT_H */ + +#if defined(LIBCDSB_LIST_H) && !defined(LIBCDSB_EXTRA_DICT_H_EXT) +#define LIBCDSB_EXTRA_DICT_H_EXT + +#define dict_copy_keys libcdsb_dict_copy_keys +#define dict_duplicate_keys libcdsb_dict_duplicate_keys +#define dict_init_keys libcdsb_dict_init_keys + +extern vtype_list libcdsb_dict_copy_keys (const vtype_dict* s) Nonnull__(1); +extern vtype_list* libcdsb_dict_duplicate_keys(const vtype_dict* s) Nonnull__(1); +extern void libcdsb_dict_init_keys (vtype_list* x, const vtype_dict* s) Nonnull__(1,2); + +#endif /* LIBCDSB_EXTRA_DICT_H_EXT */ diff --git a/src/dict/extra.c b/src/dict/extra.c index 81d645c..5732977 100644 --- a/src/dict/extra.c +++ b/src/dict/extra.c @@ -1,6 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include "../../include/extra/list.h" #include "include.h" /*#####################################################################################################################*/ @@ -167,3 +168,69 @@ int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, boo end_: return r; } + +/*#####################################################################################################################*/ + +vtype_list libcdsb_dict_copy_keys(const vtype_dict* s) { + vtype_list x; + dnode_t *c; + size_t i; + + i = s->capacity; + + list_init(&x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_update(&x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } + + return x; +} + + +vtype_list* libcdsb_dict_duplicate_keys(const vtype_dict* s) { + vtype_list* x; + dnode_t *c; + size_t i; + + x = malloc(sizeof(*x)); + i = s->capacity; + + list_init(x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_update(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } + + return x; +} + + +void libcdsb_dict_init_keys(vtype_list* x, const vtype_dict* s) { + dnode_t *c; + size_t i; + + x = malloc(sizeof(*x)); + i = s->capacity; + + list_init(x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_update(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } +} From c9ec0d110f955df0fa9295cf8515b0d55fc2fafe Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 18 Aug 2022 03:15:57 +0300 Subject: [PATCH 63/63] Refactor usage of the stack_t initialization --- src/list/sort.c | 5 ++-- src/map/base.c | 65 ++++++++++++++++++++++++++----------------------- src/map/copy.c | 18 +++++++++++--- src/map/extra.c | 12 ++++++--- src/set/base.c | 65 ++++++++++++++++++++++++++----------------------- src/set/copy.c | 47 ++++++++++++++++++++++------------- src/set/extra.c | 12 ++++++--- 7 files changed, 133 insertions(+), 91 deletions(-) diff --git a/src/list/sort.c b/src/list/sort.c index 8b927b4..1542072 100644 --- a/src/list/sort.c +++ b/src/list/sort.c @@ -18,11 +18,12 @@ static inline void lnode_swap(lnode_t* s0, lnode_t* s1) { void list_sort(list_t* x) { - stack_t z = { .prev = 0, .value = x->last}; + stack_t z; lnode_t *l; lnode_t *r; - stack_push(&z, x->first); + stack_init(&z); + stack_push_many(&z, 2, x->last, x->first); while (z.value) { diff --git a/src/map/base.c b/src/map/base.c index 026f180..d2fc45d 100644 --- a/src/map/base.c +++ b/src/map/base.c @@ -19,37 +19,35 @@ static inline hash_t mnode_hash(const mnode_t* s, vtype t) { hash_t map_hash(const map_t* s) { + stack_t z; mnode_t *c0, *c1; - hash_t hash, v; - stack_t z; + hash_t hash, v; - if (mnode_is_empty(s->root)) return 0; + if (mnode_is_empty(s->root)) + return 0; - z.prev = 0; - hash = 1; - c1 = s->root; + stack_init(&z); + stack_push(&z, s->root->left); - if (!rbnode_is_empty(z.value = c1->left)) { + hash = 1; + + if (!mnode_is_empty(c0 = stack_pop(&z))) { do { - c0 = stack_pop(&z); ++hash; - - if (!mnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!mnode_is_empty(c0->right)) stack_push(&z, c0->right); if (!mnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); - } while (!is_null(z.value)); + } while (!is_null(c0 = stack_pop(&z))); } v = mnode_hash(c1, s->type); - c1 = s->root; + stack_push(&z, s->root->right); - if (!rbnode_is_empty(z.value = c1->right)) { + if (!mnode_is_empty(c0 = stack_pop(&z))) { do { - c0 = stack_pop(&z); ++hash; - if (!mnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); - if (!mnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); - } while (!is_null(z.value)); + if (!mnode_is_empty(c0->left)) stack_push(&z, c0->left); + } while (!is_null(c0 = stack_pop(&z))); } v += mnode_hash(c1, s->type); @@ -98,10 +96,15 @@ void map_free(map_t* x) { /*#####################################################################################################################*/ size_t map_size(const map_t* x) { - stack_t z = { .prev = 0, .value = x->root }; - size_t n = 0; + stack_t z; + size_t n; rbnode_t* c; + stack_init(&z); + stack_push(&z, x->root); + + n = 0; + if (!mnode_is_empty(x->root)) { while ((c = stack_pop(&z))) { ++n; @@ -116,20 +119,20 @@ size_t map_size(const map_t* x) { /*#####################################################################################################################*/ int map_compare(const map_t* s0, const map_t* s1) { + stack_t z; mnode_t *c0, *c1; - stack_t z; - int c = 0; + int cmp; if (s0 == s1 || s0->root == s1->root) return 0; if (s0->type != s1->type) return s0->type - s1->type; - z.prev = 0; - z.value = 0; - + stack_init(&z); stack_push_many(&z, 2, (void*)s1, (void*)s0); + cmp = 0; + do { c0 = stack_pop(&z); c1 = stack_pop(&z); @@ -139,18 +142,18 @@ int map_compare(const map_t* s0, const map_t* s1) { stack_flush(&z); return mnode_is_empty(c0) ? -1 : 1; } - } else if ((c = mnode_compare(c0, c1, s0->type))) { + } else if ((cmp = mnode_compare(c0, c1, s0->type))) { if (c0->left == c1->right) { // == mnode_empty - c = mnode_compare(c0->right, c1, s0->type); - if (!c) c = mnode_compare(c0, c1->left, s0->type); + cmp = mnode_compare(c0->right, c1, s0->type); + if (!cmp) cmp = mnode_compare(c0, c1->left, s0->type); } else if (c0->right == c1->left) { // == mnode_empty - c = mnode_compare(c0, c1->right, s0->type); - if (!c) c = mnode_compare(c0->left, c1, s0->type); + cmp = mnode_compare(c0, c1->right, s0->type); + if (!cmp) cmp = mnode_compare(c0->left, c1, s0->type); } - if (c) { + if (cmp) { stack_flush(&z); - return c; + return cmp; } } else stack_push_many(&z, 4, c1->right, c0->right, c1->left, c0->left); diff --git a/src/map/copy.c b/src/map/copy.c index 7a3948f..abe107f 100644 --- a/src/map/copy.c +++ b/src/map/copy.c @@ -20,7 +20,10 @@ static inline mnode_t* mnode_duplicate(const mnode_t* s, mnode_t* p, const vtype map_t map_copy(const map_t* s) { map_t x; - stack_t z = { .prev = 0, .value = s->root }; + stack_t z; + + stack_init(&z); + stack_push(&z, s->root); x.type = s->type; @@ -52,9 +55,13 @@ map_t map_copy(const map_t* s) { map_t* map_duplicate(const map_t* s) { - map_t* x = malloc(sizeof(*x)); - stack_t z = { .prev = 0, .value = s->root }; + map_t* x; + stack_t z; + stack_init(&z); + stack_push(&z, s->root); + + x = malloc(sizeof(*x)); x->type = s->type; if (!mnode_is_empty(s->root)) { @@ -85,7 +92,10 @@ map_t* map_duplicate(const map_t* s) { void map_copy_init(map_t* x, const map_t* s) { - stack_t z = { .prev = 0, .value = s->root }; + stack_t z; + + stack_init(&z); + stack_push(&z, s->root); x->type = s->type; diff --git a/src/map/extra.c b/src/map/extra.c index b587b17..0364e24 100644 --- a/src/map/extra.c +++ b/src/map/extra.c @@ -80,11 +80,17 @@ int libcdsb_map_find(map_t* x, const void* k, vtype t, void* _, map_access_callb 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; + stack_t z; + int r; mnode_t* c; - if (mnode_is_empty(x->root)) return 0; + stack_init(&z); + stack_push(&z, x->root); + + r = 0; + + if (mnode_is_empty(x->root)) + return 0; while ((c = stack_pop(&z))) { if ((r = callback(vnode_peek(&c->key, x->type), x->type, vnode_peek(&c->value, c->type), c->type, dt))) diff --git a/src/set/base.c b/src/set/base.c index f10f02b..7a85537 100644 --- a/src/set/base.c +++ b/src/set/base.c @@ -18,37 +18,35 @@ static inline hash_t rbnode_hash(const rbnode_t* s, vtype t) { hash_t vset_hash(const set_t* s) { + stack_t z; rbnode_t *c0, *c1; - hash_t hash, v; - stack_t z; + hash_t hash, v; - if (rbnode_is_empty(s->root)) return 0; + if (rbnode_is_empty(s->root)) + return 0; - z.prev = 0; - hash = 1; - c1 = s->root; + stack_init(&z); + stack_push(&z, s->root->left); - if (!rbnode_is_empty(z.value = c1->left)) { + hash = 1; + + if (!rbnode_is_empty(c0 = stack_pop(&z))) { do { - c0 = stack_pop(&z); ++hash; - - if (!rbnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); + if (!rbnode_is_empty(c0->right)) stack_push(&z, c0->right); if (!rbnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); - } while (!is_null(z.value)); + } while (!is_null(c0 = stack_pop(&z))); } v = rbnode_hash(c1, s->type); - c1 = s->root; + stack_push(&z, s->root->right); - if (!rbnode_is_empty(z.value = c1->right)) { + if (!rbnode_is_empty(c0 = stack_pop(&z))) { do { - c0 = stack_pop(&z); ++hash; - if (!rbnode_is_empty(c0->right)) stack_push(&z, c1 = c0->right); - if (!rbnode_is_empty(c0->left)) stack_push(&z, c1 = c0->left); - } while (!is_null(z.value)); + if (!rbnode_is_empty(c0->left)) stack_push(&z, c0->left); + } while (!is_null(c0 = stack_pop(&z))); } v += rbnode_hash(c1, s->type); @@ -96,10 +94,15 @@ void vset_free(set_t* x) { /*#####################################################################################################################*/ size_t vset_size(const set_t* x) { - stack_t z = { .prev = 0, .value = x->root }; - size_t n = 0; + stack_t z; + size_t n; rbnode_t* c; + stack_init(&z); + stack_push(&z, x->root); + + n = 0; + if (!rbnode_is_empty(x->root)) { while ((c = stack_pop(&z))) { ++n; @@ -114,20 +117,20 @@ size_t vset_size(const set_t* x) { /*#####################################################################################################################*/ int vset_compare(const set_t* s0, const set_t* s1) { + stack_t z; rbnode_t *c0, *c1; - stack_t z; - int c = 0; + int cmp; if (s0 == s1 || s0->root == s1->root) return 0; if (s0->type != s1->type) return s0->type - s1->type; - z.prev = 0; - z.value = 0; - + stack_init(&z); stack_push_many(&z, 2, (void*)s1, (void*)s0); + cmp = 0; + do { c0 = stack_pop(&z); c1 = stack_pop(&z); @@ -137,18 +140,18 @@ int vset_compare(const set_t* s0, const set_t* s1) { stack_flush(&z); return rbnode_is_empty(c0) ? -1 : 1; } - } else if ((c = rbnode_compare(c0, c1, s0->type))) { + } else if ((cmp = rbnode_compare(c0, c1, s0->type))) { if (c0->left == c1->right) { // == rbnode_empty - c = rbnode_compare(c0->right, c1, s0->type); - if (!c) c = rbnode_compare(c0, c1->left, s0->type); + cmp = rbnode_compare(c0->right, c1, s0->type); + if (!cmp) cmp = rbnode_compare(c0, c1->left, s0->type); } else if (c0->right == c1->left) { // == rbnode_empty - c = rbnode_compare(c0, c1->right, s0->type); - if (!c) c = rbnode_compare(c0->left, c1, s0->type); + cmp = rbnode_compare(c0, c1->right, s0->type); + if (!cmp) cmp = rbnode_compare(c0->left, c1, s0->type); } - if (c) { + if (cmp) { stack_flush(&z); - return c; + return cmp; } } else stack_push_many(&z, 4, c1->right, c0->right, c1->left, c0->left); diff --git a/src/set/copy.c b/src/set/copy.c index a074b0b..899cb93 100644 --- a/src/set/copy.c +++ b/src/set/copy.c @@ -6,12 +6,16 @@ set_t vset_copy(const set_t* s) { - set_t x = { .type = s->type }; - stack_t z = { .prev = 0, .value = s->root }; - vtype t = s->type; + set_t x; + stack_t z; + + stack_init(&z); + stack_push(&z, s->root); + + x.type = s->type; if (!rbnode_is_empty(s->root)) { - x.root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + x.root = rbnode_create(vnode_duplicate(&s->root->value, s->type), rbnode_empty, 0); stack_push(&z, x.root); do { @@ -19,12 +23,12 @@ set_t vset_copy(const set_t* s) { rbnode_t *p1 = stack_pop(&z); if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, s->type), p0, p1->left->colored); stack_push_many(&z, 2, p1->left, p0->left); } if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, s->type), p0, p1->right->colored); stack_push_many(&z, 2, p1->right, p0->right); } @@ -38,12 +42,17 @@ set_t vset_copy(const set_t* s) { set_t* vset_duplicate(const set_t* s) { - set_t* x = malloc(sizeof(*x)); - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; + set_t* x; + stack_t z; + + stack_init(&z); + stack_push(&z, s->root); + + x = malloc(sizeof(*x)); + x->type = s->type; if (!rbnode_is_empty(s->root)) { - x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + x->root = rbnode_create(vnode_duplicate(&s->root->value, s->type), rbnode_empty, 0); stack_push(&z, x->root); do { @@ -51,12 +60,12 @@ set_t* vset_duplicate(const set_t* s) { rbnode_t *p1 = stack_pop(&z); if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, s->type), p0, p1->left->colored); stack_push_many(&z, 2, p1->left, p0->left); } if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, s->type), p0, p1->right->colored); stack_push_many(&z, 2, p1->right, p0->right); } @@ -70,11 +79,15 @@ set_t* vset_duplicate(const set_t* s) { void vset_copy_init(set_t* x, const set_t* s) { - stack_t z = { .prev = 0, .value = s->root }; - vtype t = x->type = s->type; + stack_t z; + + stack_init(&z); + stack_push(&z, s->root); + + x->type = s->type; if (!rbnode_is_empty(s->root)) { - x->root = rbnode_create(vnode_duplicate(&s->root->value, t), rbnode_empty, 0); + x->root = rbnode_create(vnode_duplicate(&s->root->value, s->type), rbnode_empty, 0); stack_push(&z, x->root); do { @@ -82,12 +95,12 @@ void vset_copy_init(set_t* x, const set_t* s) { rbnode_t *p1 = stack_pop(&z); if (!rbnode_is_empty(p1->left)) { - p0->left = rbnode_create(vnode_duplicate(&p1->left->value, t), p0, p1->left->colored); + p0->left = rbnode_create(vnode_duplicate(&p1->left->value, s->type), p0, p1->left->colored); stack_push_many(&z, 2, p1->left, p0->left); } if (!rbnode_is_empty(p1->right)) { - p0->right = rbnode_create(vnode_duplicate(&p1->right->value, t), p0, p1->right->colored); + p0->right = rbnode_create(vnode_duplicate(&p1->right->value, s->type), p0, p1->right->colored); stack_push_many(&z, 2, p1->right, p0->right); } diff --git a/src/set/extra.c b/src/set/extra.c index 44bce68..b18926b 100644 --- a/src/set/extra.c +++ b/src/set/extra.c @@ -71,11 +71,17 @@ int libcdsb_vset_find(vtype_set* x, const void* v, vtype t, void* _, vset_access 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; + stack_t z; + int r; rbnode_t* c; - if (rbnode_is_empty(x->root)) return 0; + stack_init(&z); + stack_push(&z, x->root); + + r = 0; + + if (rbnode_is_empty(x->root)) + return 0; while ((c = stack_pop(&z))) { if ((r = callback(vnode_peek(&c->value, x->type), x->type, data)))