summaryrefslogtreecommitdiffhomepage
path: root/include/stc/forward.h
diff options
context:
space:
mode:
author_Tradam <[email protected]>2023-09-08 01:29:47 +0000
committerGitHub <[email protected]>2023-09-08 01:29:47 +0000
commit3c76c7f3d5db3f9586a90d03f8fbb02d79de9acd (patch)
treeafbe4b540967223911f7c5de36559b82154f02f3 /include/stc/forward.h
parent0841165881871ee01b782129be681209aeed2423 (diff)
parent1a72205fe05c2375cfd380dd8381a8460d9ed8d1 (diff)
downloadSTC-modified-modified.tar.gz
STC-modified-modified.zip
Merge branch 'stclib:master' into modifiedHEADmodified
Diffstat (limited to 'include/stc/forward.h')
-rw-r--r--include/stc/forward.h79
1 files changed, 50 insertions, 29 deletions
diff --git a/include/stc/forward.h b/include/stc/forward.h
index 31e67e7d..2fbff034 100644
--- a/include/stc/forward.h
+++ b/include/stc/forward.h
@@ -24,35 +24,50 @@
#define STC_FORWARD_H_INCLUDED
#include <stdint.h>
+#include <stddef.h>
#define forward_carc(CX, VAL) _c_carc_types(CX, VAL)
#define forward_cbox(CX, VAL) _c_cbox_types(CX, VAL)
#define forward_cdeq(CX, VAL) _c_cdeq_types(CX, VAL)
#define forward_clist(CX, VAL) _c_clist_types(CX, VAL)
-#define forward_cmap(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, int32_t, c_true, c_false)
-#define forward_cmap64(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, int64_t, c_true, c_false)
-#define forward_cset(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, int32_t, c_false, c_true)
-#define forward_cset64(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, int64_t, c_false, c_true)
-#define forward_csmap(CX, KEY, VAL) _c_aatree_types(CX, KEY, VAL, int32_t, c_true, c_false)
-#define forward_csset(CX, KEY) _c_aatree_types(CX, KEY, KEY, int32_t, c_false, c_true)
+#define forward_cmap(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, c_true, c_false)
+#define forward_cset(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, c_false, c_true)
+#define forward_csmap(CX, KEY, VAL) _c_aatree_types(CX, KEY, VAL, c_true, c_false)
+#define forward_csset(CX, KEY) _c_aatree_types(CX, KEY, KEY, c_false, c_true)
#define forward_cstack(CX, VAL) _c_cstack_types(CX, VAL)
#define forward_cpque(CX, VAL) _c_cpque_types(CX, VAL)
#define forward_cqueue(CX, VAL) _c_cdeq_types(CX, VAL)
#define forward_cvec(CX, VAL) _c_cvec_types(CX, VAL)
-// csview
+// csview : non-null terminated string view
typedef const char csview_value;
-typedef struct csview {
- csview_value* str;
+typedef struct csview {
+ csview_value* buf;
intptr_t size;
} csview;
-typedef union {
- csview_value* ref;
+typedef union {
+ csview_value* ref;
+ csview chr;
struct { csview chr; csview_value* end; } u8;
} csview_iter;
-// cstr
+
+// crawstr : null-terminated string view
+typedef csview_value crawstr_value;
+typedef struct crawstr {
+ crawstr_value* str;
+ intptr_t size;
+} crawstr;
+
+typedef union {
+ crawstr_value* ref;
+ csview chr;
+ struct { csview chr; } u8; // [deprecated]
+} crawstr_iter;
+
+
+// cstr : null-terminated string (short string optimized - sso)
typedef char cstr_value;
typedef struct { cstr_value* data; intptr_t size, cap; } cstr_buf;
typedef union cstr {
@@ -60,11 +75,13 @@ typedef union cstr {
struct { cstr_value* data; size_t size, ncap; } lon;
} cstr;
-typedef union {
- cstr_value* ref;
- struct { csview chr; } u8;
+typedef union {
+ cstr_value* ref;
+ csview chr;
+ struct { csview chr; } u8; // [deprecated]
} cstr_iter;
+
#define c_true(...) __VA_ARGS__
#define c_false(...)
@@ -83,12 +100,17 @@ typedef union {
#define _c_cdeq_types(SELF, VAL) \
typedef VAL SELF##_value; \
- typedef struct { SELF##_value *ref, *end; } SELF##_iter; \
\
typedef struct SELF { \
- SELF##_value *_base, *data; \
- intptr_t _len, _cap; \
- } SELF
+ SELF##_value *data; \
+ intptr_t start, end, capmask; \
+ } SELF; \
+\
+ typedef struct { \
+ SELF##_value *ref; \
+ intptr_t pos; \
+ const SELF* _s; \
+ } SELF##_iter
#define _c_clist_types(SELF, VAL) \
typedef VAL SELF##_value; \
@@ -103,10 +125,9 @@ typedef union {
SELF##_node *last; \
} SELF
-#define _c_chash_types(SELF, KEY, VAL, SZ, MAP_ONLY, SET_ONLY) \
+#define _c_chash_types(SELF, KEY, VAL, MAP_ONLY, SET_ONLY) \
typedef KEY SELF##_key; \
typedef VAL SELF##_mapped; \
- typedef SZ SELF##_ssize; \
\
typedef SET_ONLY( SELF##_key ) \
MAP_ONLY( struct SELF##_value ) \
@@ -115,23 +136,23 @@ typedef union {
typedef struct { \
SELF##_value *ref; \
bool inserted; \
+ uint8_t hashx; \
} SELF##_result; \
\
typedef struct { \
SELF##_value *ref, *_end; \
- uint8_t* _hx; \
+ struct chash_slot* sref; \
} SELF##_iter; \
\
typedef struct SELF { \
- SELF##_value* table; \
- uint8_t* _hashx; \
- SELF##_ssize size, bucket_count; \
+ SELF##_value* data; \
+ struct chash_slot* slot; \
+ intptr_t size, bucket_count; \
} SELF
-#define _c_aatree_types(SELF, KEY, VAL, SZ, MAP_ONLY, SET_ONLY) \
+#define _c_aatree_types(SELF, KEY, VAL, MAP_ONLY, SET_ONLY) \
typedef KEY SELF##_key; \
typedef VAL SELF##_mapped; \
- typedef SZ SELF##_ssize; \
typedef struct SELF##_node SELF##_node; \
\
typedef SET_ONLY( SELF##_key ) \
@@ -147,12 +168,12 @@ typedef union {
SELF##_value *ref; \
SELF##_node *_d; \
int _top; \
- SELF##_ssize _tn, _st[36]; \
+ int32_t _tn, _st[36]; \
} SELF##_iter; \
\
typedef struct SELF { \
SELF##_node *nodes; \
- SELF##_ssize root, disp, head, size, cap; \
+ int32_t root, disp, head, size, cap; \
} SELF
#define _c_cstack_fixed(SELF, VAL, CAP) \