diff options
| author | Tyge Løvset <[email protected]> | 2020-07-24 13:07:33 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-07-24 13:07:33 +0200 |
| commit | 54e135b6453fed2cd210bd9b738eb69fdde93a88 (patch) | |
| tree | a9a30c72b5de09ce6cee644c712365446f439e58 /stc | |
| parent | eda4377e0bea66d23f584b7660a7617f8bea4bf0 (diff) | |
| download | STC-modified-54e135b6453fed2cd210bd9b738eb69fdde93a88.tar.gz STC-modified-54e135b6453fed2cd210bd9b738eb69fdde93a88.zip | |
Added <container>_<tag>_init variables; Fixed prime.c and list.c examples.
Diffstat (limited to 'stc')
| -rw-r--r-- | stc/cdefs.h | 4 | ||||
| -rw-r--r-- | stc/clist.h | 7 | ||||
| -rw-r--r-- | stc/cmap.h | 6 | ||||
| -rw-r--r-- | stc/cvec.h | 5 |
4 files changed, 16 insertions, 6 deletions
diff --git a/stc/cdefs.h b/stc/cdefs.h index 753e1b47..b33b9186 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -38,8 +38,12 @@ #if defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define STC_API extern
+#define STC_VARDECL extern
+#define STC_VARDEF
#else
#define STC_API STC_INLINE
+#define STC_VARDECL static
+#define STC_VARDEF static
#endif
/* Macro overloading feature support: https://rextester.com/ONP80107 */
diff --git a/stc/clist.h b/stc/clist.h index 41067286..85c2d9b9 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -91,10 +91,11 @@ \
declare_CListTypes(tag, Value); \
\
- STC_INLINE CList_##tag \
- clist_##tag##_init(void) {return clist_init;} \
+ STC_VARDECL CList_##tag clist_##tag##_init; \
STC_API void \
clist_##tag##_destroy(CList_##tag* self); \
+ STC_INLINE void \
+ clist_##tag##_clear(CList_##tag* self) {clist_##tag##_destroy(self);} \
STC_API void \
clist_##tag##_pushBack(CList_##tag* self, Value value); \
STC_API void \
@@ -149,6 +150,8 @@ #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define implement_CList_6(tag, Value, valueDestroy, RawValue, valueCompareRaw, valueGetRaw) \
\
+ STC_VARDEF CList_##tag clist_##tag##_init = clist_init; \
+ \
STC_API void \
clist_##tag##_destroy(CList_##tag* self) { \
while (self->last) \
@@ -158,8 +158,7 @@ typedef struct { \ uint8_t* _hx; \
} CType##Iter_##tag, ctype##_##tag##_iter_t; \
\
-STC_INLINE CType##_##tag \
-ctype##_##tag##_init(void) {return cmap_init;} \
+STC_VARDECL CType##_##tag ctype##_##tag##_init; \
STC_API CType##_##tag \
ctype##_##tag##_make(size_t initialSize); \
STC_API void \
@@ -201,6 +200,9 @@ typedef Value CType##Value_##tag, ctype##_##tag##_value_t #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define implement_CHASH(tag, CType, ctype, Key, Value, valueDestroy, keyEqualsRaw, keyHashRaw, \
keyDestroy, RawKey, keyGetRaw, keyInitRaw) \
+ \
+STC_VARDEF CType##_##tag ctype##_##tag##_init = cmap_init; \
+ \
STC_API CType##_##tag \
ctype##_##tag##_make(size_t initialSize) { \
CType##_##tag h = ctype##_init; \
@@ -49,8 +49,7 @@ typedef struct CVec_##tag { \ Value* data; \
} CVec_##tag; \
\
-STC_INLINE CVec_##tag \
-cvec_##tag##_init(void) {return cvec_init;} \
+STC_VARDECL CVec_##tag cvec_##tag##_init; \
STC_API CVec_##tag \
cvec_##tag##_make(size_t size, Value null); \
STC_API void \
@@ -112,6 +111,8 @@ typedef RawValue CVecRawValue_##tag #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define implement_CVec_6(tag, Value, valueDestroy, RawValue, valueCompareRaw, valueGetRaw) \
\
+STC_VARDEF CVec_##tag cvec_##tag##_init = cvec_init; \
+ \
STC_API CVec_##tag \
cvec_##tag##_make(size_t size, Value null) { \
CVec_##tag vec = cvec_init; \
|
