summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-11-03 12:44:44 +0100
committerTyge Løvset <[email protected]>2022-11-03 12:44:44 +0100
commita913e030b5db2e0d0a49234a86fa39930b4ed6e9 (patch)
tree3cf10eb3bdc2bc0f958d32b3dcf44888d16ea75b
parent0a9ab178aad191dc3a394e5fa8aca860da9ee9b0 (diff)
downloadSTC-modified-a913e030b5db2e0d0a49234a86fa39930b4ed6e9.tar.gz
STC-modified-a913e030b5db2e0d0a49234a86fa39930b4ed6e9.zip
Renamed forward_CONTAINER(...) => declare_CONTAINER(...),
and c_is_fwd => c_declared, for the i_opt option define.
-rw-r--r--README.md8
-rw-r--r--examples/new_deq.c8
-rw-r--r--examples/new_list.c8
-rw-r--r--examples/new_map.c4
-rw-r--r--examples/new_queue.c4
-rw-r--r--examples/new_smap.c4
-rw-r--r--examples/new_vec.c8
-rw-r--r--include/stc/alt/csmap.h2
-rw-r--r--include/stc/carc.h2
-rw-r--r--include/stc/carr2.h2
-rw-r--r--include/stc/carr3.h2
-rw-r--r--include/stc/cbox.h2
-rw-r--r--include/stc/ccommon.h2
-rw-r--r--include/stc/cdeq.h2
-rw-r--r--include/stc/clist.h2
-rw-r--r--include/stc/cmap.h2
-rw-r--r--include/stc/cpque.h2
-rw-r--r--include/stc/csmap.h2
-rw-r--r--include/stc/cstack.h2
-rw-r--r--include/stc/cvec.h6
-rw-r--r--include/stc/forward.h32
21 files changed, 53 insertions, 53 deletions
diff --git a/README.md b/README.md
index 4548ea55..f4fd275d 100644
--- a/README.md
+++ b/README.md
@@ -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_is_fwd*, *c_static*, *c_header* with the *|* separator.
+- `i_opt` - Boolean properties: may combine *c_no_cmp*, *c_no_clone*, *c_no_atomic*, *c_declared*, *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
-forward_cstack(cstack_pnt, struct Point); // declare cstack_pnt and cstack_pnt_value, cstack_pnt_iter;
+declare_cstack(cstack_pnt, struct Point); // declare cstack_pnt and cstack_pnt_value, cstack_pnt_iter;
// the element may be forward declared type as well
typedef struct Dataset {
cstack_pnt vertices;
@@ -434,7 +434,7 @@ typedef struct Dataset {
...
// Implementation
-#define c_opt c_is_fwd // flag that the container was forward declared.
+#define c_opt c_declared // 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_is_fwd`; may be combined with `|`
+- Added: `i_opt` template parameter: compile-time options: `c_no_cmp`, `c_no_clone`, `c_no_atomic`, `c_declared`; 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/new_deq.c b/examples/new_deq.c
index dd6f04c0..9da5c90d 100644
--- a/examples/new_deq.c
+++ b/examples/new_deq.c
@@ -1,8 +1,8 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_cdeq(cdeq_i32, int);
-forward_cdeq(cdeq_pnt, struct Point);
+declare_cdeq(cdeq_i32, int);
+declare_cdeq(cdeq_pnt, struct Point);
struct MyStruct {
cdeq_i32 intvec;
@@ -11,7 +11,7 @@ struct MyStruct {
#define i_val int
-#define i_opt c_is_fwd
+#define i_opt c_declared
#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_is_fwd
+#define i_opt c_declared
#define i_tag pnt
#include <stc/cdeq.h>
diff --git a/examples/new_list.c b/examples/new_list.c
index 87260931..816e7271 100644
--- a/examples/new_list.c
+++ b/examples/new_list.c
@@ -1,7 +1,7 @@
#include <stc/cstr.h>
-forward_clist(clist_i32, int);
-forward_clist(clist_pnt, struct Point);
+declare_clist(clist_i32, int);
+declare_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_is_fwd
+#define i_opt c_declared
#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_is_fwd
+#define i_opt c_declared
#define i_tag pnt
#include <stc/clist.h>
diff --git a/examples/new_map.c b/examples/new_map.c
index 24909a7c..214df821 100644
--- a/examples/new_map.c
+++ b/examples/new_map.c
@@ -1,7 +1,7 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_cmap(cmap_pnt, struct Point, int);
+declare_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_is_fwd
+#define i_opt c_declared
#define i_tag pnt
#include <stc/cmap.h>
diff --git a/examples/new_queue.c b/examples/new_queue.c
index 46ae836e..d7b6d0aa 100644
--- a/examples/new_queue.c
+++ b/examples/new_queue.c
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <time.h>
-forward_cqueue(cqueue_pnt, struct Point);
+declare_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_is_fwd
+#define i_opt c_declared
#define i_tag pnt
#include <stc/cqueue.h>
diff --git a/examples/new_smap.c b/examples/new_smap.c
index 35c56b7c..ca136a0f 100644
--- a/examples/new_smap.c
+++ b/examples/new_smap.c
@@ -1,7 +1,7 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_csmap(PMap, struct Point, int);
+declare_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_is_fwd
+#define i_opt c_declared
#include <stc/csmap.h>
// cstr => cstr map
diff --git a/examples/new_vec.c b/examples/new_vec.c
index 6e6be95a..9be8cbdb 100644
--- a/examples/new_vec.c
+++ b/examples/new_vec.c
@@ -1,8 +1,8 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_cvec(cvec_i32, int);
-forward_cvec(cvec_pnt, struct Point);
+declare_cvec(cvec_i32, int);
+declare_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_is_fwd
+#define i_opt c_declared
#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_is_fwd
+#define i_opt c_declared
#define i_tag pnt
#include <stc/cvec.h>
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h
index 888c6b8c..85ecc8c7 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_is_fwd)
+#if !c_option(c_declared)
_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 03f91be7..9b52b0c4 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_is_fwd)
+#if !c_option(c_declared)
_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 598a0e86..01e4752c 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_is_fwd)
+#if !c_option(c_declared)
_cx_deftypes(_c_carr2_types, _cx_self, i_key);
#endif
diff --git a/include/stc/carr3.h b/include/stc/carr3.h
index a4b8e44b..7287da68 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_is_fwd)
+#if !c_option(c_declared)
_cx_deftypes(_c_carr3_types, _cx_self, i_key);
#endif
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index c690bec7..7b0e6742 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_is_fwd)
+#if !c_option(c_declared)
_cx_deftypes(_c_cbox_types, _cx_self, i_key);
#endif
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 14f4978b..d3b48caa 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -103,7 +103,7 @@
#define c_derived_valclone(v) i_valfrom((i_valto((&(v)))))
#define c_option(flag) ((i_opt) & (flag))
-#define c_is_fwd (1<<0)
+#define c_declared (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 302351ac..bd1a9a0f 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_is_fwd)
+#if !c_option(c_declared)
_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 82adcdf8..b23a25ca 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_is_fwd)
+#if !c_option(c_declared)
_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 2cea2f54..908466d2 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -72,7 +72,7 @@ typedef struct { size_t idx; uint8_t hx; } chash_bucket_t;
#endif
#define _i_ishash
#include "template.h"
-#if !c_option(c_is_fwd)
+#if !c_option(c_declared)
_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 19b01c15..af64d553 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -33,7 +33,7 @@
#include "template.h"
-#if !c_option(c_is_fwd)
+#if !c_option(c_declared)
_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 68e96726..5afa6c1b 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -77,7 +77,7 @@ struct csmap_rep { size_t root, disp, head, size, cap; unsigned nodes[1]; };
#endif
#include "template.h"
-#if !c_option(c_is_fwd)
+#if !c_option(c_declared)
_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 2b5528e9..011a7884 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -33,7 +33,7 @@
#endif
#include "template.h"
-#if !c_option(c_is_fwd)
+#if !c_option(c_declared)
#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 f0ad0a80..30965df3 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -25,7 +25,7 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_cvec(cvec_i32, int);
+declare_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_is_fwd // forward declared
+#define i_opt c_declared // 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_is_fwd)
+#if !c_option(c_declared)
_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 2e0b3445..e1202588 100644
--- a/include/stc/forward.h
+++ b/include/stc/forward.h
@@ -25,22 +25,22 @@
#include <stddef.h>
-#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)
+#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)
typedef const char csview_value;
typedef struct { csview_value* str; size_t size; } csview;