summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-06-06 15:38:59 +0200
committerTyge Løvset <[email protected]>2021-06-06 21:33:23 +0200
commit4569cf7843c510615542afe8bce237be53d79a9f (patch)
tree27b612467288637d8edefc45d2f85dab731b7341 /include
parent6d3a2ad8aeb2f4633e1ed707c5bd15bd974a06bf (diff)
downloadSTC-modified-4569cf7843c510615542afe8bce237be53d79a9f.tar.gz
STC-modified-4569cf7843c510615542afe8bce237be53d79a9f.zip
Added support for forward_cmap() and forward_cset(). Added support for forward_csmap() and forward_csset(). Not yet documented.
Diffstat (limited to 'include')
-rw-r--r--include/stc/cmap.h54
-rw-r--r--include/stc/cset.h15
-rw-r--r--include/stc/csmap.h52
-rw-r--r--include/stc/csset.h14
-rw-r--r--include/stc/csview.h28
5 files changed, 81 insertions, 82 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index ccdc0d11..e66bd526 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -62,37 +62,35 @@ int main(void) {
using_cmap_7(X, Key, Mapped, keyEquals, keyHash, \
mappedDel, c_no_clone)
#define using_cmap_7(X, Key, Mapped, keyEquals, keyHash, mappedDel, mappedClone) \
- using_cmap_9(X, Key, Mapped, keyEquals, keyHash, \
- mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_cmap_9(X, Key, Mapped, keyEquals, keyHash, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
- using_cmap_13(X, Key, Mapped, keyEquals, keyHash, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ using_cmap_10(X, Key, Mapped, keyEquals, keyHash, \
+ mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_cmap_10(X, Key, Mapped, keyEquals, keyHash, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
+ using_cmap_14(X, Key, Mapped, keyEquals, keyHash, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
c_default_del, c_default_fromraw, c_default_toraw, Key)
-
-#define using_cmap_13(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+#define using_cmap_14(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey) \
_c_using_chash(cmap_##X, cmap_, Key, Mapped, keyEqualsRaw, keyHashRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define using_cmap_keydef(...) c_MACRO_OVERLOAD(using_cmap_keydef, __VA_ARGS__)
#define using_cmap_keydef_7(X, Key, Mapped, keyEquals, keyHash, keyDel, keyClone) \
- using_cmap_keydef_9(X, Key, Mapped, keyEquals, keyHash, \
- keyDel, keyClone, c_default_toraw, Key)
-
-#define using_cmap_keydef_9(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \
- keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_cmap_keydef_10(X, Key, Mapped, keyEquals, keyHash, \
+ keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_cmap_keydef_10(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \
+ keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_chash(cmap_##X, cmap_, Key, Mapped, keyEqualsRaw, keyHashRaw, \
- c_default_del, c_default_fromraw, c_default_toraw, Mapped, \
+ c_default_del, c_default_fromraw, c_default_toraw, Mapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define using_cmap_str() \
_c_using_chash(cmap_str, cmap_, cstr, cstr, c_rawstr_equals, c_rawstr_hash, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
+ cstr_del, cstr_from, cstr_toraw, const char*, c_true, \
cstr_del, cstr_from, cstr_toraw, const char*)
@@ -103,13 +101,12 @@ int main(void) {
#define using_cmap_strkey_3(X, Mapped, mappedDel) \
using_cmap_strkey_4(X, Mapped, mappedDel, c_no_clone)
#define using_cmap_strkey_4(X, Mapped, mappedDel, mappedClone) \
- _c_using_chash_strkey(X, cmap_, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_cmap_strkey_6(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
- _c_using_chash_strkey(X, cmap_, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped)
-
-#define _c_using_chash_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
+ using_cmap_strkey_7(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_cmap_strkey_7(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
+ _c_using_chash_strkey(X, cmap_, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes)
+#define _c_using_chash_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_chash(C##X, C, cstr, Mapped, c_rawstr_equals, c_rawstr_hash, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
cstr_del, cstr_from, cstr_toraw, const char*)
@@ -122,11 +119,10 @@ int main(void) {
#define using_cmap_strval_5(X, Key, keyEquals, keyHash, keyDel) \
using_cmap_strval_6(X, Key, keyEquals, keyHash, keyDel, c_no_clone)
#define using_cmap_strval_6(X, Key, keyEquals, keyHash, keyDel, keyClone) \
- using_cmap_strval_8(X, Key, keyEquals, keyHash, keyDel, keyClone, c_default_toraw, Key)
-
-#define using_cmap_strval_8(X, Key, keyEqualsRaw, keyHashRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_cmap_strval_9(X, Key, keyEquals, keyHash, keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_cmap_strval_9(X, Key, keyEqualsRaw, keyHashRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_chash(cmap_##X, cmap_, Key, cstr, keyEqualsRaw, keyHashRaw, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
+ cstr_del, cstr_from, cstr_toraw, const char*, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define SET_ONLY_cmap_(...)
@@ -173,9 +169,9 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored)
} CX
#define _c_using_chash(CX, C, Key, Mapped, keyEqualsRaw, keyHashRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey) \
- _c_chash_types(CX, C, Key, Mapped); \
+ defTypes( _c_chash_types(CX, C, Key, Mapped); ) \
\
MAP_ONLY_##C( struct CX##_value_t { \
CX##_key_t first; \
diff --git a/include/stc/cset.h b/include/stc/cset.h
index 81ccf6c7..071a7cbc 100644
--- a/include/stc/cset.h
+++ b/include/stc/cset.h
@@ -43,9 +43,9 @@ int main(void) {
#include "cmap.h"
-/* cset: */
-#define using_cset(...) \
- c_MACRO_OVERLOAD(using_cset, __VA_ARGS__)
+#define forward_cset(X, Key) _c_chash_types(cset_##X, cset_, Key, Key)
+
+#define using_cset(...) c_MACRO_OVERLOAD(using_cset, __VA_ARGS__)
#define using_cset_2(X, Key) \
using_cset_4(X, Key, c_default_equals, c_default_hash)
@@ -54,15 +54,14 @@ int main(void) {
#define using_cset_5(X, Key, keyEquals, keyHash, keyDel) \
using_cset_6(X, Key, keyEquals, keyHash, keyDel, c_no_clone)
#define using_cset_6(X, Key, keyEquals, keyHash, keyDel, keyClone) \
- using_cset_8(X, Key, keyEquals, keyHash, keyDel, keyClone, c_default_toraw, Key)
-
-#define using_cset_8(X, Key, keyEqualsRaw, keyHashRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_cset_9(X, Key, keyEquals, keyHash, keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_cset_9(X, Key, keyEqualsRaw, keyHashRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_chash(cset_##X, cset_, Key, Key, keyEqualsRaw, keyHashRaw, \
- @@, @@, @@, void, keyDel, keyFromRaw, keyToRaw, RawKey)
+ @@, @@, @@, void, defTypes, keyDel, keyFromRaw, keyToRaw, RawKey)
/* cset_str: */
#define using_cset_str() \
- _c_using_chash_strkey(str, cset_, cstr, @@, @@, @@, void)
+ _c_using_chash_strkey(str, cset_, cstr, @@, @@, @@, void, c_true)
#define SET_ONLY_cset_(...) __VA_ARGS__
#define MAP_ONLY_cset_(...)
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index 05c21b61..d00ebd84 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -50,6 +50,8 @@ int main(void) {
#include <stdlib.h>
#include <string.h>
+#define forward_csmap(X, Key, Mapped) _c_aatree_types(csmap_##X, csmap_, Key, Mapped)
+
#define using_csmap(...) c_MACRO_OVERLOAD(using_csmap, __VA_ARGS__)
#define using_csmap_3(X, Key, Mapped) \
@@ -59,35 +61,33 @@ int main(void) {
#define using_csmap_5(X, Key, Mapped, keyCompare, mappedDel) \
using_csmap_6(X, Key, Mapped, keyCompare, mappedDel, c_no_clone)
#define using_csmap_6(X, Key, Mapped, keyCompare, mappedDel, mappedClone) \
- using_csmap_8(X, Key, Mapped, keyCompare, mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_csmap_8(X, Key, Mapped, keyCompare, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
- using_csmap_12(X, Key, Mapped, keyCompare, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ using_csmap_9(X, Key, Mapped, keyCompare, mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_csmap_9(X, Key, Mapped, keyCompare, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
+ using_csmap_13(X, Key, Mapped, keyCompare, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
c_default_del, c_default_fromraw, c_default_toraw, Key)
-
-#define using_csmap_12(X, Key, Mapped, keyCompareRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+#define using_csmap_13(X, Key, Mapped, keyCompareRaw, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey) \
_c_using_aatree(csmap_##X, csmap_, Key, Mapped, keyCompareRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define using_csmap_keydef(...) c_MACRO_OVERLOAD(using_csmap_keydef, __VA_ARGS__)
#define using_csmap_keydef_6(X, Key, Mapped, keyCompare, keyDel, keyClone) \
- using_csmap_keydef_8(X, Key, Mapped, keyCompare, \
- keyDel, keyClone, c_default_toraw, Key)
-
-#define using_csmap_keydef_8(X, Key, Mapped, keyCompareRaw, \
- keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_csmap_keydef_9(X, Key, Mapped, keyCompare, \
+ keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_csmap_keydef_9(X, Key, Mapped, keyCompareRaw, \
+ keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_aatree(csmap_##X, csmap_, Key, Mapped, keyCompareRaw, \
- c_default_del, c_default_fromraw, c_default_toraw, Mapped, \
+ c_default_del, c_default_fromraw, c_default_toraw, Mapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define using_csmap_str() \
_c_using_aatree(csmap_str, csmap_, cstr, cstr, c_rawstr_compare, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
+ cstr_del, cstr_from, cstr_toraw, const char*, c_true, \
cstr_del, cstr_from, cstr_toraw, const char*)
@@ -98,13 +98,12 @@ int main(void) {
#define using_csmap_strkey_3(X, Mapped, mappedDel) \
using_csmap_strkey_4(X, Mapped, mappedDel, c_no_clone)
#define using_csmap_strkey_4(X, Mapped, mappedDel, mappedClone) \
- _c_using_aatree_strkey(X, csmap_, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_csmap_strkey_6(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
- _c_using_aatree_strkey(X, csmap_, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped)
-
-#define _c_using_aatree_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
+ using_csmap_strkey_7(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_csmap_strkey_7(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
+ _c_using_aatree_strkey(X, csmap_, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes)
+#define _c_using_aatree_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_aatree(C##X, C, cstr, Mapped, c_rawstr_compare, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
cstr_del, cstr_from, cstr_toraw, const char*)
@@ -117,11 +116,10 @@ int main(void) {
#define using_csmap_strval_4(X, Key, keyCompare, keyDel) \
using_csmap_strval_5(X, Key, keyCompare, keyDel, c_no_clone)
#define using_csmap_strval_5(X, Key, keyCompare, keyDel, keyClone) \
- using_csmap_strval_7(X, Key, keyCompare, keyDel, keyClone, c_default_toraw, Key)
-
-#define using_csmap_strval_7(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_csmap_strval_8(X, Key, keyCompare, keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_csmap_strval_8(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_aatree(csmap_##X, csmap_, Key, cstr, keyCompareRaw, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
+ cstr_del, cstr_from, cstr_toraw, const char*, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define SET_ONLY_csmap_(...)
@@ -161,9 +159,9 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
} CX
#define _c_using_aatree(CX, C, Key, Mapped, keyCompareRaw, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey) \
- _c_aatree_types(CX, C, Key, Mapped); \
+ defTypes( _c_aatree_types(CX, C, Key, Mapped); ) \
\
MAP_ONLY_##C( struct CX##_value_t { \
CX##_key_t first; \
diff --git a/include/stc/csset.h b/include/stc/csset.h
index 1218fb42..2056009b 100644
--- a/include/stc/csset.h
+++ b/include/stc/csset.h
@@ -45,8 +45,9 @@ int main(void) {
#include "csmap.h"
-#define using_csset(...) \
- c_MACRO_OVERLOAD(using_csset, __VA_ARGS__)
+#define forward_csset(X, Key) _c_aatree_types(csset_##X, csset_, Key, Key)
+
+#define using_csset(...) c_MACRO_OVERLOAD(using_csset, __VA_ARGS__)
#define using_csset_2(X, Key) \
using_csset_3(X, Key, c_default_compare)
@@ -55,14 +56,13 @@ int main(void) {
#define using_csset_4(X, Key, keyCompare, keyDel) \
using_csset_5(X, Key, keyCompare, keyDel, c_no_clone)
#define using_csset_5(X, Key, keyCompare, keyDel, keyClone) \
- using_csset_7(X, Key, keyCompare, keyDel, keyClone, c_default_toraw, Key)
-
-#define using_csset_7(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
+ using_csset_8(X, Key, keyCompare, keyDel, keyClone, c_default_toraw, Key, c_true)
+#define using_csset_8(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_aatree(csset_##X, csset_, Key, Key, keyCompareRaw, \
- @@, @@, @@, void, keyDel, keyFromRaw, keyToRaw, RawKey)
+ @@, @@, @@, void, defTypes, keyDel, keyFromRaw, keyToRaw, RawKey)
#define using_csset_str() \
- _c_using_aatree_strkey(str, csset_, cstr, @@, @@, @@, void)
+ _c_using_aatree_strkey(str, csset_, cstr, @@, @@, @@, void, c_true)
#define SET_ONLY_csset_(...) __VA_ARGS__
#define MAP_ONLY_csset_(...)
diff --git a/include/stc/csview.h b/include/stc/csview.h
index 34f8f15c..f9bc11ca 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -146,16 +146,19 @@ STC_INLINE bool csview_equals_ref(const csview* a, const csview* b)
#define using_csmap_strvkey_3(X, Mapped, mappedDel) \
using_csmap_strvkey_4(X, Mapped, mappedDel, c_no_clone)
#define using_csmap_strvkey_4(X, Mapped, mappedDel, mappedClone) \
- using_csmap_strvkey_6(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_csmap_strvkey_6(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
+ using_csmap_strvkey_7(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_csmap_strvkey_7(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_aatree(csmap_##X, csmap_, cstr, Mapped, csview_compare_ref, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
cstr_del, cstr_from_v, cstr_to_v, csview)
+
#define using_csmap_strv() \
- using_csmap_strvkey_6(strv, cstr, cstr_del, cstr_from_v, cstr_to_v, csview)
+ _c_using_aatree(csmap_strv, csmap_, cstr, cstr, csview_equals_ref, csview_hash_ref, \
+ cstr_del, cstr_from_v, cstr_to_v, csview, c_true, \
+ cstr_del, cstr_from_v, cstr_to_v, csview)
#define using_csset_strv() \
_c_using_aatree(csset_strv, csset_, cstr, cstr, csview_compare_ref, \
- @@, @@, @@, void, cstr_del, cstr_from_v, cstr_to_v, csview)
+ @@, @@, @@, void, c_true, cstr_del, cstr_from_v, cstr_to_v, csview)
#define using_cmap_strvkey(...) c_MACRO_OVERLOAD(using_cmap_strvkey, __VA_ARGS__)
@@ -165,15 +168,18 @@ STC_INLINE bool csview_equals_ref(const csview* a, const csview* b)
#define using_cmap_strvkey_3(X, Mapped, mappedDel) \
using_cmap_strvkey_4(X, Mapped, mappedDel, c_no_clone)
#define using_cmap_strvkey_4(X, Mapped, mappedDel, mappedClone) \
- using_cmap_strvkey_6(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped)
-#define using_cmap_strvkey_6(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
+ using_cmap_strvkey_7(X, Mapped, mappedDel, mappedClone, c_default_toraw, Mapped, c_true)
+#define using_cmap_strvkey_7(X, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_chash(cmap_##X, cmap_, cstr, Mapped, csview_equals_ref, csview_hash_ref, \
- mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
- cstr_del, cstr_from_v, cstr_to_v, csview)
+ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
+ cstr_del, cstr_from_v, cstr_to_v, csview)
+
#define using_cmap_strv() \
- using_cmap_strvkey_6(strv, cstr, cstr_del, cstr_from_v, cstr_to_v, csview)
+ _c_using_chash(cmap_strv, cmap_, cstr, cstr, csview_equals_ref, csview_hash_ref, \
+ cstr_del, cstr_from_v, cstr_to_v, csview, c_true, \
+ cstr_del, cstr_from_v, cstr_to_v, csview)
#define using_cset_strv() \
_c_using_chash(cset_strv, cset_, cstr, cstr, csview_equals_ref, csview_hash_ref, \
- @@, @@, @@, void, cstr_del, cstr_from_v, cstr_to_v, csview)
+ @@, @@, @@, void, c_true, cstr_del, cstr_from_v, cstr_to_v, csview)
#endif \ No newline at end of file