diff options
| author | Tyge Løvset <[email protected]> | 2022-11-13 11:25:25 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-11-13 11:25:25 +0100 |
| commit | 99fb2a81c771739e11091b84161f03d740eab084 (patch) | |
| tree | 11fcb6b1fe8497b0cfa524987ec300fdf269557e | |
| parent | e0fc0f2ec3846334496ab90b46ce1d69e9bbd230 (diff) | |
| download | STC-modified-99fb2a81c771739e11091b84161f03d740eab084.tar.gz STC-modified-99fb2a81c771739e11091b84161f03d740eab084.zip | |
Reverted forward declaration from c_declare_X back to c_forward_X, and the flag "i_opt c_declared" to "i_opt c_is_forward". Sorry about this, but hopefully not a widely used feature for most yet.
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | examples/cpque.c | 4 | ||||
| -rw-r--r-- | examples/new_deq.c | 8 | ||||
| -rw-r--r-- | examples/new_list.c | 8 | ||||
| -rw-r--r-- | examples/new_map.c | 4 | ||||
| -rw-r--r-- | examples/new_queue.c | 4 | ||||
| -rw-r--r-- | examples/new_smap.c | 4 | ||||
| -rw-r--r-- | examples/new_vec.c | 8 | ||||
| -rw-r--r-- | include/stc/alt/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/carc.h | 2 | ||||
| -rw-r--r-- | include/stc/carr2.h | 2 | ||||
| -rw-r--r-- | include/stc/carr3.h | 2 | ||||
| -rw-r--r-- | include/stc/cbox.h | 2 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 2 | ||||
| -rw-r--r-- | include/stc/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/cmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cpque.h | 2 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cstack.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 6 | ||||
| -rw-r--r-- | include/stc/forward.h | 32 |
22 files changed, 55 insertions, 55 deletions
@@ -310,7 +310,7 @@ The list of template parameters: Properties: - `i_tag` - Container type name tag. Defaults to *i_key* name. - `i_type` - Full container type name. Alternative to *i_tag*. -- `i_opt` - Boolean properties: may combine *c_no_cmp*, *c_no_clone*, *c_no_atomic*, *c_declared*, *c_static*, *c_header* with the *|* separator. +- `i_opt` - Boolean properties: may combine *c_no_cmp*, *c_no_clone*, *c_no_atomic*, *c_is_forward*, *c_static*, *c_header* with the *|* separator. Key: - `i_keydrop` - Destroy map/set key func - defaults to empty destructor. @@ -425,7 +425,7 @@ but still not expose or include the full implementation / API of the container. ```c // Header file #include <stc/forward.h> // only include data structures -declare_cstack(cstack_pnt, struct Point); // declare cstack_pnt (and cstack_pnt_value, cstack_pnt_iter); +forward_cstack(cstack_pnt, struct Point); // declare cstack_pnt (and cstack_pnt_value, cstack_pnt_iter); // struct Point may be an incomplete type. typedef struct Dataset { cstack_pnt vertices; @@ -434,7 +434,7 @@ typedef struct Dataset { ... // Implementation -#define c_opt c_declared // flag that the container was forward declared. +#define c_opt c_is_forward // flag that the container was forward declared. #define i_val struct Point #define i_tag pnt #include <stc/cstack.h> @@ -527,7 +527,7 @@ Memory efficiency - Replaced: *csview_first_token()* and *csview_next_token()* with one function: `csview_token()`. - Added: **checkauto** tool for checking that c-source files uses `c_auto*` macros correctly. - Added: general `i_keyclass` / `i_valclass` template parameters which auto-binds template functions. -- Added: `i_opt` template parameter: compile-time options: `c_no_cmp`, `c_no_clone`, `c_no_atomic`, `c_declared`; may be combined with `|` +- Added: `i_opt` template parameter: compile-time options: `c_no_cmp`, `c_no_clone`, `c_no_atomic`, `c_is_forward`; may be combined with `|` - Added: [**cbox**](docs/cbox_api.md) type: smart pointer, similar to [Rust Box](https://doc.rust-lang.org/rust-by-example/std/box.html) and [std::unique_ptr](https://en.cppreference.com/w/cpp/memory/unique_ptr). - Added: [**c_forpair**](docs/ccommon_api.md) macro: for-loop with "structured binding" diff --git a/examples/cpque.c b/examples/cpque.c index dba4552f..7254b0f7 100644 --- a/examples/cpque.c +++ b/examples/cpque.c @@ -12,7 +12,7 @@ #include <stc/cstr.h> // predeclare -declare_cpque(ipque, int); +forward_cpque(ipque, int); struct { ipque Q; @@ -23,7 +23,7 @@ struct { #define i_type ipque #define i_val int -#define i_opt c_declared // needed to avoid re-type-define container type +#define i_opt c_is_forward // needed to avoid re-type-define container type #define i_less_functor(self, x, y) c_container_of(self, IPQueue, Q)->less(x, y) // <== This. #include <stc/cpque.h> diff --git a/examples/new_deq.c b/examples/new_deq.c index 9da5c90d..39149140 100644 --- a/examples/new_deq.c +++ b/examples/new_deq.c @@ -1,8 +1,8 @@ #include <stc/cstr.h> #include <stc/forward.h> -declare_cdeq(cdeq_i32, int); -declare_cdeq(cdeq_pnt, struct Point); +forward_cdeq(cdeq_i32, int); +forward_cdeq(cdeq_pnt, struct Point); struct MyStruct { cdeq_i32 intvec; @@ -11,7 +11,7 @@ struct MyStruct { #define i_val int -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag i32 #include <stc/cdeq.h> @@ -23,7 +23,7 @@ int point_cmp(const Point* a, const Point* b) { #define i_val Point #define i_cmp point_cmp -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag pnt #include <stc/cdeq.h> diff --git a/examples/new_list.c b/examples/new_list.c index 816e7271..6dbe80b4 100644 --- a/examples/new_list.c +++ b/examples/new_list.c @@ -1,7 +1,7 @@ #include <stc/cstr.h> -declare_clist(clist_i32, int); -declare_clist(clist_pnt, struct Point); +forward_clist(clist_i32, int); +forward_clist(clist_pnt, struct Point); struct MyStruct { clist_i32 intlst; @@ -9,7 +9,7 @@ struct MyStruct { } typedef MyStruct; #define i_val int -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag i32 #define i_extern // define _clist_mergesort() #include <stc/clist.h> @@ -22,7 +22,7 @@ int point_cmp(const Point* a, const Point* b) { #define i_val Point #define i_cmp point_cmp -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag pnt #include <stc/clist.h> diff --git a/examples/new_map.c b/examples/new_map.c index 214df821..f43d4217 100644 --- a/examples/new_map.c +++ b/examples/new_map.c @@ -1,7 +1,7 @@ #include <stc/cstr.h> #include <stc/forward.h> -declare_cmap(cmap_pnt, struct Point, int); +forward_cmap(cmap_pnt, struct Point, int); struct MyStruct { cmap_pnt pntmap; @@ -26,7 +26,7 @@ int point_cmp(const Point* a, const Point* b) { #define i_val int #define i_cmp point_cmp #define i_hash c_default_hash -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag pnt #include <stc/cmap.h> diff --git a/examples/new_queue.c b/examples/new_queue.c index d7b6d0aa..bc7a95c9 100644 --- a/examples/new_queue.c +++ b/examples/new_queue.c @@ -3,7 +3,7 @@ #include <stdio.h> #include <time.h> -declare_cqueue(cqueue_pnt, struct Point); +forward_cqueue(cqueue_pnt, struct Point); struct Point { int x, y; } typedef Point; int point_cmp(const Point* a, const Point* b) { @@ -12,7 +12,7 @@ int point_cmp(const Point* a, const Point* b) { } #define i_val Point #define i_cmp point_cmp -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag pnt #include <stc/cqueue.h> diff --git a/examples/new_smap.c b/examples/new_smap.c index ca136a0f..c77aa185 100644 --- a/examples/new_smap.c +++ b/examples/new_smap.c @@ -1,7 +1,7 @@ #include <stc/cstr.h> #include <stc/forward.h> -declare_csmap(PMap, struct Point, int); +forward_csmap(PMap, struct Point, int); // Use forward declared PMap in struct struct MyStruct { @@ -25,7 +25,7 @@ int point_cmp(const Point* a, const Point* b) { #define i_key Point #define i_val int #define i_cmp point_cmp -#define i_opt c_declared +#define i_opt c_is_forward #include <stc/csmap.h> // cstr => cstr map diff --git a/examples/new_vec.c b/examples/new_vec.c index 9be8cbdb..84e4c7b2 100644 --- a/examples/new_vec.c +++ b/examples/new_vec.c @@ -1,8 +1,8 @@ #include <stc/cstr.h> #include <stc/forward.h> -declare_cvec(cvec_i32, int); -declare_cvec(cvec_pnt, struct Point); +forward_cvec(cvec_i32, int); +forward_cvec(cvec_pnt, struct Point); struct MyStruct { cvec_i32 intvec; @@ -10,7 +10,7 @@ struct MyStruct { } typedef MyStruct; #define i_val int -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag i32 #include <stc/cvec.h> @@ -23,7 +23,7 @@ int point_cmp(const Point* a, const Point* b) { #define i_val Point //#define i_cmp point_cmp #define i_less(a, b) a->x < b->x || (a->x == b->x && a->y < b->y) -#define i_opt c_declared +#define i_opt c_is_forward #define i_tag pnt #include <stc/cvec.h> diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h index 85ecc8c7..4cf7c2d7 100644 --- a/include/stc/alt/csmap.h +++ b/include/stc/alt/csmap.h @@ -72,7 +72,7 @@ int main(void) { #endif #include <stc/template.h> -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_aatree_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY); #endif diff --git a/include/stc/carc.h b/include/stc/carc.h index 9b52b0c4..69a5660e 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -94,7 +94,7 @@ typedef i_keyraw _cx_raw; #define _i_atomic_inc(v) (void)(++*(v)) #define _i_atomic_dec_and_test(v) !(--*(v)) #endif -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_carc_types, _cx_self, i_key); #endif _cx_carc_rep { catomic_long counter; i_key value; }; diff --git a/include/stc/carr2.h b/include/stc/carr2.h index fa46fd44..e96d3c6a 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -57,7 +57,7 @@ int main() { #define _i_prefix carr2_ #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_carr2_types, _cx_self, i_key); #endif diff --git a/include/stc/carr3.h b/include/stc/carr3.h index 7287da68..3fe9e8ae 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -59,7 +59,7 @@ int main() { #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_carr3_types, _cx_self, i_key); #endif diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 7b0e6742..cf9e1b5a 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -79,7 +79,7 @@ int main() { #include "template.h" typedef i_keyraw _cx_raw; -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_cbox_types, _cx_self, i_key); #endif diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index f9aff743..935d10d9 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -101,7 +101,7 @@ #define c_default_drop(vp) ((void) (vp)) #define c_option(flag) ((i_opt) & (flag)) -#define c_declared (1<<0) +#define c_is_forward (1<<0) #define c_no_atomic (1<<1) #define c_no_clone (1<<2) #define c_no_cmp (1<<3) diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index bd1a9a0f..d1102e32 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -38,7 +38,7 @@ struct cdeq_rep { size_t size, cap; unsigned base[1]; }; #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_cdeq_types, _cx_self, i_key); #endif typedef i_keyraw _cx_raw; diff --git a/include/stc/clist.h b/include/stc/clist.h index b23a25ca..b5f9c233 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -85,7 +85,7 @@ _c_clist_complete_types(clist_VOID, dummy); #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_clist_types, _cx_self, i_key); #endif _cx_deftypes(_c_clist_complete_types, _cx_self, dummy); diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 3683b357..45b1d81d 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -80,7 +80,7 @@ typedef struct { size_t idx; uint8_t hx; } chash_bucket_t; #ifndef i_eq_functor #define i_eq_functor(self, x, y) i_eq(x, y) #endif -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_chash_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY); #endif diff --git a/include/stc/cpque.h b/include/stc/cpque.h index fbeafcc3..ba83474b 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -35,7 +35,7 @@ #ifndef i_less_functor #define i_less_functor(self, x, y) i_less(x, y) #endif -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_cpque_types, _cx_self, i_key); #endif typedef i_keyraw _cx_raw; diff --git a/include/stc/csmap.h b/include/stc/csmap.h index aced3f2a..afab01e8 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -77,7 +77,7 @@ int main(void) { #ifndef i_cmp_functor #define i_cmp_functor(self, x, y) i_cmp(x, y) #endif -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_aatree_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY); #endif diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 011a7884..7e46da86 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -33,7 +33,7 @@ #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) #ifdef i_capacity #define _i_no_clone _cx_deftypes(_c_cstack_fixed, _cx_self, i_key, i_capacity); diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 30965df3..2f49ec34 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -25,7 +25,7 @@ #include <stc/cstr.h> #include <stc/forward.h> -declare_cvec(cvec_i32, int); +forward_cvec(cvec_i32, int); struct MyStruct { cvec_i32 int_vec; @@ -39,7 +39,7 @@ struct MyStruct { #include <stc/cvec.h> #define i_key int -#define i_opt c_declared // forward declared +#define i_opt c_is_forward // forward declared #define i_tag i32 #include <stc/cvec.h> @@ -75,7 +75,7 @@ struct cvec_rep { size_t size, cap; unsigned data[1]; }; #endif #include "template.h" -#if !c_option(c_declared) +#if !c_option(c_is_forward) _cx_deftypes(_c_cvec_types, _cx_self, i_key); #endif typedef i_keyraw _cx_raw; diff --git a/include/stc/forward.h b/include/stc/forward.h index ef287fe4..ffec50de 100644 --- a/include/stc/forward.h +++ b/include/stc/forward.h @@ -25,22 +25,22 @@ #include <stddef.h> -#define declare_carc(CX, VAL) _c_carc_types(CX, VAL) -#define declare_carr2(CX, VAL) _c_carr2_types(CX, VAL) -#define declare_carr3(CX, VAL) _c_carr3_types(CX, VAL) -#define declare_cbox(CX, VAL) _c_cbox_types(CX, VAL) -#define declare_cdeq(CX, VAL) _c_cdeq_types(CX, VAL) -#define declare_clist(CX, VAL) _c_clist_types(CX, VAL) -#define declare_cmap(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, uint32_t, c_true, c_false) -#define declare_cmap_huge(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, size_t, c_true, c_false) -#define declare_cset(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, uint32_t, c_false, c_true) -#define declare_cset_huge(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, size_t, c_false, c_true) -#define declare_csmap(CX, KEY, VAL) _c_aatree_types(CX, KEY, VAL, uint32_t, c_true, c_false) -#define declare_csset(CX, KEY) _c_aatree_types(CX, KEY, KEY, uint32_t, c_false, c_true) -#define declare_cstack(CX, VAL) _c_cstack_types(CX, VAL) -#define declare_cpque(CX, VAL) _c_cpque_types(CX, VAL) -#define declare_cqueue(CX, VAL) _c_cdeq_types(CX, VAL) -#define declare_cvec(CX, VAL) _c_cvec_types(CX, VAL) +#define forward_carc(CX, VAL) _c_carc_types(CX, VAL) +#define forward_carr2(CX, VAL) _c_carr2_types(CX, VAL) +#define forward_carr3(CX, VAL) _c_carr3_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, uint32_t, c_true, c_false) +#define forward_cmap_huge(CX, KEY, VAL) _c_chash_types(CX, KEY, VAL, size_t, c_true, c_false) +#define forward_cset(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, uint32_t, c_false, c_true) +#define forward_cset_huge(CX, KEY) _c_chash_types(CX, cset, KEY, KEY, size_t, c_false, c_true) +#define forward_csmap(CX, KEY, VAL) _c_aatree_types(CX, KEY, VAL, uint32_t, c_true, c_false) +#define forward_csset(CX, KEY) _c_aatree_types(CX, KEY, KEY, uint32_t, 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) typedef const char csview_value; typedef struct { csview_value* str; size_t size; } csview; |
