summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-09-29 21:38:51 +0200
committerTyge Løvset <[email protected]>2021-09-29 21:38:51 +0200
commit3624d34fabaa388e018f907a42ecfd014d96b704 (patch)
tree1fae6ec692a32c645e0dda59a6e80d5228ab8abc
parent23c177bbe65f83353aa5fd716d75cb4121acdba6 (diff)
downloadSTC-modified-3624d34fabaa388e018f907a42ecfd014d96b704.tar.gz
STC-modified-3624d34fabaa388e018f907a42ecfd014d96b704.zip
Changed forward declaration to support user defined container names with i_cnt.
-rw-r--r--README.md7
-rw-r--r--examples/new_deq.c4
-rw-r--r--examples/new_list.c4
-rw-r--r--examples/new_map.c2
-rw-r--r--examples/new_pque.c2
-rw-r--r--examples/new_queue.c2
-rw-r--r--examples/new_smap.c2
-rw-r--r--examples/new_sptr.c2
-rw-r--r--examples/new_vec.c4
-rw-r--r--examples/sptr_ex.c2
-rw-r--r--include/stc/cvec.h2
-rw-r--r--include/stc/forward.h26
12 files changed, 30 insertions, 29 deletions
diff --git a/README.md b/README.md
index 49edc853..9eb6b01a 100644
--- a/README.md
+++ b/README.md
@@ -317,8 +317,8 @@ 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(pnt, struct Point); // declare cstack_pnt and cstack_pnt_value_t, cstack_pnt_iter_t;
- // the element may be forward declared type as well
+forward_cstack(cstack_pnt, struct Point); // declare cstack_pnt and cstack_pnt_value_t, cstack_pnt_iter_t;
+ // the element may be forward declared type as well
typedef struct Dataset {
cstack_pnt vertices;
cstack_pnt colors;
@@ -326,8 +326,9 @@ typedef struct Dataset {
...
// Implementation
-#define F_tag pnt // define F_tag or an empty i_fwd if the container was forward declared.
+#define i_fwd // flag that the container was forward declared.
#define i_val struct Point
+#define i_tag pnt
#include <stc/cstack.h>
```
diff --git a/examples/new_deq.c b/examples/new_deq.c
index d1a5c2a6..93853ce3 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(i32, int);
-forward_cdeq(pnt, struct Point);
+forward_cdeq(cdeq_i32, int);
+forward_cdeq(cdeq_pnt, struct Point);
struct MyStruct {
cdeq_i32 intvec;
diff --git a/examples/new_list.c b/examples/new_list.c
index a38936b0..66c97c3b 100644
--- a/examples/new_list.c
+++ b/examples/new_list.c
@@ -1,8 +1,8 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_clist(i32, int);
-forward_clist(pnt, struct Point);
+forward_clist(clist_i32, int);
+forward_clist(clist_pnt, struct Point);
struct MyStruct {
clist_i32 intlst;
diff --git a/examples/new_map.c b/examples/new_map.c
index 2c4ee3bb..f09fe801 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(pnt, struct Point, int);
+forward_cmap(cmap_pnt, struct Point, int);
struct MyStruct {
cmap_pnt pntmap;
diff --git a/examples/new_pque.c b/examples/new_pque.c
index 1fb90123..7047a622 100644
--- a/examples/new_pque.c
+++ b/examples/new_pque.c
@@ -1,6 +1,6 @@
#include <stc/forward.h>
-forward_cpque(pnt, struct Point);
+forward_cpque(cpque_pnt, struct Point);
struct MyStruct {
cpque_pnt priority_queue;
diff --git a/examples/new_queue.c b/examples/new_queue.c
index a7fdb723..6e62abe6 100644
--- a/examples/new_queue.c
+++ b/examples/new_queue.c
@@ -2,7 +2,7 @@
#include <stc/forward.h>
#include <stdio.h>
-forward_cqueue(pnt, struct Point);
+forward_cqueue(cqueue_pnt, struct Point);
struct Point { int x, y; } typedef Point;
int point_compare(const Point* a, const Point* b) {
diff --git a/examples/new_smap.c b/examples/new_smap.c
index c05d90b9..bbaa3dd1 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(pnt, struct Point, int);
+forward_csmap(csmap_pnt, struct Point, int);
struct MyStruct {
csmap_pnt pntmap;
diff --git a/examples/new_sptr.c b/examples/new_sptr.c
index aad6192a..678ac85e 100644
--- a/examples/new_sptr.c
+++ b/examples/new_sptr.c
@@ -1,7 +1,7 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_csptr(person, struct Person);
+forward_csptr(csptr_person, struct Person);
struct Person { cstr name, last; } typedef Person;
diff --git a/examples/new_vec.c b/examples/new_vec.c
index ae1fd155..fb4181bd 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(i32, int);
-forward_cvec(pnt, struct Point);
+forward_cvec(cvec_i32, int);
+forward_cvec(cvec_pnt, struct Point);
struct MyStruct {
cvec_i32 intvec;
diff --git a/examples/sptr_ex.c b/examples/sptr_ex.c
index 184acd05..cd84c668 100644
--- a/examples/sptr_ex.c
+++ b/examples/sptr_ex.c
@@ -5,7 +5,7 @@
#include <stc/cstr.h>
#include <stc/forward.h>
-forward_csptr(song, struct Song);
+forward_csptr(csptr_song, struct Song);
struct Test {
csptr_song song1;
csptr_song song2;
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index d7f74fe9..04618fb2 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(i32, int);
+forward_cvec(cvec_i32, int);
struct MyStruct {
cvec_i32 int_vec;
diff --git a/include/stc/forward.h b/include/stc/forward.h
index 70c21440..2d22b9ca 100644
--- a/include/stc/forward.h
+++ b/include/stc/forward.h
@@ -25,19 +25,19 @@
#include <stddef.h>
-#define forward_carr2(TAG, VAL) _c_carr2_types(carr2_##TAG, VAL)
-#define forward_carr3(TAG, VAL) _c_carr3_types(carr3_##TAG, VAL)
-#define forward_cdeq(TAG, VAL) _c_cdeq_types(cdeq_##TAG, VAL)
-#define forward_clist(TAG, VAL) _c_clist_types(clist_##TAG, VAL)
-#define forward_cmap(TAG, KEY, VAL) _c_chash_types(cmap_##TAG, KEY, VAL, c_true, c_false)
-#define forward_csmap(TAG, KEY, VAL) _c_aatree_types(csmap_##TAG, KEY, VAL, c_true, c_false)
-#define forward_cset(TAG, KEY) _c_chash_types(cset_##TAG, cset, KEY, KEY, c_false, c_true)
-#define forward_csset(TAG, KEY) _c_aatree_types(csset_##TAG, KEY, KEY, c_false, c_true)
-#define forward_csptr(TAG, VAL) _c_csptr_types(csptr_##TAG, VAL)
-#define forward_cpque(TAG, VAL) _c_cpque_types(cpque_##TAG, VAL)
-#define forward_cstack(TAG, VAL) _c_cstack_types(cstack_##TAG, VAL)
-#define forward_cqueue(TAG, VAL) _c_cdeq_types(cqueue_##TAG, VAL)
-#define forward_cvec(TAG, VAL) _c_cvec_types(cvec_##TAG, VAL)
+#define forward_carr2(CX, VAL) _c_carr2_types(CX, VAL)
+#define forward_carr3(CX, VAL) _c_carr3_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, c_true, c_false)
+#define forward_csmap(CX, KEY, VAL) _c_aatree_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_csset(CX, KEY) _c_aatree_types(CX, KEY, KEY, c_false, c_true)
+#define forward_csptr(CX, VAL) _c_csptr_types(CX, VAL)
+#define forward_cpque(CX, VAL) _c_cpque_types(CX, VAL)
+#define forward_cstack(CX, VAL) _c_cstack_types(CX, VAL)
+#define forward_cqueue(CX, VAL) _c_cdeq_types(CX, VAL)
+#define forward_cvec(CX, VAL) _c_cvec_types(CX, VAL)
#ifndef MAP_SIZE_T
#define MAP_SIZE_T uint32_t