diff options
| author | Tyge Løvset <[email protected]> | 2021-09-07 09:48:19 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-09-07 09:48:19 +0200 |
| commit | 5fabf7416364a3b15bc253d98e95a02a56cf409a (patch) | |
| tree | ac100569de21b3e9e411f00d591a7927cf748b54 /include | |
| parent | 007d8a204df58a2e051f9de3c417b3a0fbf3f515 (diff) | |
| download | STC-modified-5fabf7416364a3b15bc253d98e95a02a56cf409a.tar.gz STC-modified-5fabf7416364a3b15bc253d98e95a02a56cf409a.zip | |
Switched to lowercase input define symbols, e.g. i_KEY => i_key, etc.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/carray.h | 28 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 88 | ||||
| -rw-r--r-- | include/stc/clist.h | 80 | ||||
| -rw-r--r-- | include/stc/clist_v1.h | 76 | ||||
| -rw-r--r-- | include/stc/cmap.h | 98 | ||||
| -rw-r--r-- | include/stc/cpque.h | 18 | ||||
| -rw-r--r-- | include/stc/cset.h | 6 | ||||
| -rw-r--r-- | include/stc/csmap.h | 110 | ||||
| -rw-r--r-- | include/stc/csmap_v1.h | 96 | ||||
| -rw-r--r-- | include/stc/csptr.h | 10 | ||||
| -rw-r--r-- | include/stc/csset.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 94 | ||||
| -rw-r--r-- | include/stc/template.h | 170 | ||||
| -rw-r--r-- | include/stc/test_new_list.c | 14 | ||||
| -rw-r--r-- | include/stc/test_new_map.c | 18 | ||||
| -rw-r--r-- | include/stc/test_new_vec.c | 14 |
17 files changed, 462 insertions, 462 deletions
diff --git a/include/stc/carray.h b/include/stc/carray.h index 0d28ff62..e70a4b64 100644 --- a/include/stc/carray.h +++ b/include/stc/carray.h @@ -50,9 +50,9 @@ int main() { }
}
*/
- defTypes( _c_carray2_types(Self, i_VAL); )
+ defTypes( _c_carray2_types(Self, i_val); )
\
- STC_API Self cx_memb(_with_values)(size_t xdim, size_t ydim, i_VAL value); \
+ STC_API Self cx_memb(_with_values)(size_t xdim, size_t ydim, i_val value); \
STC_API Self cx_memb(_with_storage)(size_t xdim, size_t ydim, cx_value_t* storage); \
STC_API Self cx_memb(_clone)(Self src); \
\
@@ -76,15 +76,15 @@ int main() { } \
STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; } \
\
- _c_implement_carray2(Self, i_VAL, i_VALDEL, i_VALFROM) \
+ _c_implement_carray2(Self, i_val, i_valdel, i_valfrom) \
STC_API void cx_memb(_del)(Self* self)
// carray3:
- defTypes( _c_carray3_types(Self, i_VAL); )
+ defTypes( _c_carray3_types(Self, i_val); )
\
- STC_API Self cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, i_VAL value); \
+ STC_API Self cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, i_val value); \
STC_API Self cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, cx_value_t* storage); \
STC_API Self cx_memb(_clone)(Self src); \
\
@@ -111,14 +111,14 @@ int main() { } \
STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; } \
\
- _c_implement_carray3(Self, i_VAL, i_VALDEL, i_VALFROM) \
+ _c_implement_carray3(Self, i_val, i_valdel, i_valfrom) \
STC_API void cx_memb(_del)(Self* self)
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-#define _c_implement_carray2(Self, i_VAL, i_VALDEL, i_VALFROM) \
+#define _c_implement_carray2(Self, i_val, i_valdel, i_valfrom) \
\
STC_DEF Self cx_memb(_with_storage)(size_t xdim, size_t ydim, cx_value_t* block) { \
Self _arr = {c_new_n(cx_value_t*, xdim), xdim, ydim}; \
@@ -127,7 +127,7 @@ int main() { return _arr; \
} \
\
- STC_DEF Self cx_memb(_with_values)(size_t xdim, size_t ydim, i_VAL value) { \
+ STC_DEF Self cx_memb(_with_values)(size_t xdim, size_t ydim, i_val value) { \
Self _arr = cx_memb(_init)(xdim, ydim); \
for (cx_value_t* p = _arr.data[0], *e = p + xdim*ydim; p != e; ++p) \
*p = value; \
@@ -137,21 +137,21 @@ int main() { STC_DEF Self cx_memb(_clone)(Self src) { \
Self _arr = cx_memb(_init)(src.xdim, src.ydim); \
for (cx_value_t* p = _arr.data[0], *q = src.data[0], *e = p + cx_memb(_size)(src); p != e; ++p, ++q) \
- *p = i_VALFROM(*q); \
+ *p = i_valfrom(*q); \
return _arr; \
} \
\
STC_DEF void cx_memb(_del)(Self* self) { \
if (!self->data) return; \
for (cx_value_t* p = self->data[0], *e = p + cx_memb(_size)(*self); p != e; ++p) \
- i_VALDEL(p); \
+ i_valdel(p); \
c_free(self->data[0]); /* data */ \
c_free(self->data); /* pointers */ \
}
// carray3 impl.
-#define _c_implement_carray3(Self, i_VAL, i_VALDEL, i_VALFROM) \
+#define _c_implement_carray3(Self, i_val, i_valdel, i_valfrom) \
\
STC_DEF Self cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, cx_value_t* block) { \
Self _arr = {c_new_n(cx_value_t**, xdim*(ydim + 1)), xdim, ydim, zdim}; \
@@ -162,7 +162,7 @@ int main() { return _arr; \
} \
\
- STC_DEF Self cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, i_VAL value) { \
+ STC_DEF Self cx_memb(_with_values)(size_t xdim, size_t ydim, size_t zdim, i_val value) { \
Self _arr = cx_memb(_init)(xdim, ydim, zdim); \
for (cx_value_t* p = **_arr.data, *e = p + xdim*ydim*zdim; p != e; ++p) \
*p = value; \
@@ -172,14 +172,14 @@ int main() { STC_DEF Self cx_memb(_clone)(Self src) { \
Self _arr = cx_memb(_init)(src.xdim, src.ydim, src.zdim); \
for (cx_value_t* p = **_arr.data, *q = **src.data, *e = p + cx_memb(_size)(src); p != e; ++p, ++q) \
- *p = i_VALFROM(*q); \
+ *p = i_valfrom(*q); \
return _arr; \
} \
\
STC_DEF void cx_memb(_del)(Self* self) { \
if (!self->data) return; \
for (cx_value_t* p = **self->data, *e = p + cx_memb(_size)(*self); p != e; ++p) \
- i_VALDEL(p); \
+ i_valdel(p); \
c_free(self->data[0][0]); /* data */ \
c_free(self->data); /* pointers */ \
}
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index a2dd32a6..d1df91a3 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -39,7 +39,7 @@ #endif
#define STC_INLINE static inline
-#if defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_IMP)
+#if defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
# define STC_API extern
# define STC_DEF
# define STC_LIBRARY_ONLY(...) __VA_ARGS__
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 6eca970a..65e2cd0d 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -28,17 +28,17 @@ #include <string.h>
\
- defTypes( _c_cdeq_types(Self, i_VAL); ) \
- typedef i_VALRAW cx_rawvalue_t; \
+ defTypes( _c_cdeq_types(Self, i_val); ) \
+ typedef i_valraw cx_rawvalue_t; \
\
STC_API Self cx_memb(_init)(void); \
STC_API Self cx_memb(_clone)(Self cx); \
STC_API void cx_memb(_clear)(Self* self); \
STC_API void cx_memb(_del)(Self* self); \
- STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t p1, cx_iter_t p2, i_VALRAW raw); \
+ STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t p1, cx_iter_t p2, i_valraw raw); \
STC_API int cx_memb(_value_compare)(const cx_value_t* x, const cx_value_t* y); \
- STC_API void cx_memb(_push_back)(Self* self, i_VAL value); \
- STC_API void cx_memb(_push_front)(Self* self, i_VAL value); \
+ STC_API void cx_memb(_push_back)(Self* self, i_val value); \
+ STC_API void cx_memb(_push_front)(Self* self, i_val value); \
STC_API cx_iter_t cx_memb(_erase_range_p)(Self* self, cx_value_t* p1, cx_value_t* p2); \
STC_API cx_iter_t cx_memb(_insert_range_p)(Self* self, cx_value_t* pos, \
const cx_value_t* p1, const cx_value_t* p2, bool clone); \
@@ -50,18 +50,18 @@ STC_INLINE size_t cx_memb(_size)(Self cx) { return _cdeq_rep(&cx)->size; } \
STC_INLINE size_t cx_memb(_capacity)(Self cx) { return _cdeq_rep(&cx)->cap; } \
STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); } \
- STC_INLINE i_VAL cx_memb(_value_fromraw)(i_VALRAW raw) { return i_VALFROM(raw); } \
- STC_INLINE i_VALRAW cx_memb(_value_toraw)(cx_value_t* pval) { return i_VALTO(pval); } \
- STC_INLINE i_VAL cx_memb(_value_clone)(i_VAL val) \
- { return i_VALFROM(i_VALTO(&val)); } \
- STC_INLINE void cx_memb(_emplace_back)(Self* self, i_VALRAW raw) \
- { cx_memb(_push_back)(self, i_VALFROM(raw)); } \
- STC_INLINE void cx_memb(_emplace_front)(Self* self, i_VALRAW raw) \
- { cx_memb(_push_front)(self, i_VALFROM(raw)); } \
+ STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); } \
+ STC_INLINE i_valraw cx_memb(_value_toraw)(cx_value_t* pval) { return i_valto(pval); } \
+ STC_INLINE i_val cx_memb(_value_clone)(i_val val) \
+ { return i_valfrom(i_valto(&val)); } \
+ STC_INLINE void cx_memb(_emplace_back)(Self* self, i_valraw raw) \
+ { cx_memb(_push_back)(self, i_valfrom(raw)); } \
+ STC_INLINE void cx_memb(_emplace_front)(Self* self, i_valraw raw) \
+ { cx_memb(_push_front)(self, i_valfrom(raw)); } \
STC_INLINE void cx_memb(_pop_back)(Self* self) \
- {i_VALDEL(&self->data[--_cdeq_rep(self)->size]); } \
+ {i_valdel(&self->data[--_cdeq_rep(self)->size]); } \
STC_INLINE void cx_memb(_pop_front)(Self* self) \
- {i_VALDEL(self->data++); --_cdeq_rep(self)->size; } \
+ {i_valdel(self->data++); --_cdeq_rep(self)->size; } \
STC_INLINE cx_value_t* cx_memb(_front)(const Self* self) { return self->data; } \
STC_INLINE cx_value_t* cx_memb(_back)(const Self* self) \
{ return self->data + _cdeq_rep(self)->size - 1; } \
@@ -95,7 +95,7 @@ } \
\
STC_INLINE cx_iter_t \
- cx_memb(_insert)(Self* self, size_t idx, i_VAL value) { \
+ cx_memb(_insert)(Self* self, size_t idx, i_val value) { \
return cx_memb(_insert_range_p)(self, self->data + idx, &value, &value + 1, false); \
} \
STC_INLINE cx_iter_t \
@@ -103,12 +103,12 @@ return cx_memb(_insert_range_p)(self, self->data + idx, arr, arr + n, false); \
} \
STC_INLINE cx_iter_t \
- cx_memb(_insert_at)(Self* self, cx_iter_t it, i_VAL value) { \
+ cx_memb(_insert_at)(Self* self, cx_iter_t it, i_val value) { \
return cx_memb(_insert_range_p)(self, it.ref, &value, &value + 1, false); \
} \
\
STC_INLINE cx_iter_t \
- cx_memb(_emplace)(Self* self, size_t idx, i_VALRAW raw) { \
+ cx_memb(_emplace)(Self* self, size_t idx, i_valraw raw) { \
return cx_memb(_emplace_range_p)(self, self->data + idx, &raw, &raw + 1); \
} \
STC_INLINE cx_iter_t \
@@ -116,7 +116,7 @@ return cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n); \
} \
STC_INLINE cx_iter_t \
- cx_memb(_emplace_at)(Self* self, cx_iter_t it, i_VALRAW raw) { \
+ cx_memb(_emplace_at)(Self* self, cx_iter_t it, i_valraw raw) { \
return cx_memb(_emplace_range_p)(self, it.ref, &raw, &raw + 1); \
} \
STC_INLINE cx_iter_t \
@@ -146,12 +146,12 @@ } \
\
STC_INLINE cx_iter_t \
- cx_memb(_find)(const Self* self, i_VALRAW raw) { \
+ cx_memb(_find)(const Self* self, i_valraw raw) { \
return cx_memb(_find_in)(cx_memb(_begin)(self), cx_memb(_end)(self), raw); \
} \
\
STC_INLINE cx_value_t* \
- cx_memb(_get)(const Self* self, i_VALRAW raw) { \
+ cx_memb(_get)(const Self* self, i_valraw raw) { \
cx_iter_t end = cx_memb(_end)(self); \
cx_value_t* val = cx_memb(_find_in)(cx_memb(_begin)(self), end, raw).ref; \
return val == end.ref ? NULL : val; \
@@ -168,7 +168,7 @@ cx_memb(_sort_range)(cx_memb(_begin)(self), cx_memb(_end)(self), cx_memb(_value_compare)); \
} \
\
- _c_implement_cdeq(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW) \
+ _c_implement_cdeq(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
struct stc_trailing_semicolon
/* -------------------------- IMPLEMENTATION ------------------------- */
@@ -178,7 +178,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0};
#define _cdeq_nfront(self) ((self)->data - (self)->_base)
-#define _c_implement_cdeq(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW) \
+#define _c_implement_cdeq(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
\
STC_DEF Self \
cx_memb(_init)(void) { \
@@ -190,7 +190,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; cx_memb(_clear)(Self* self) { \
struct cdeq_rep* rep = _cdeq_rep(self); if (rep->cap) { \
for (cx_value_t *p = self->data, *q = p + rep->size; p != q; ++p) \
- i_VALDEL(p); \
+ i_valdel(p); \
rep->size = 0; \
} \
} \
@@ -208,7 +208,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; size_t sz = rep->size, cap = (size_t) (sz*1.7) + n + 7; \
size_t nfront = _cdeq_nfront(self); \
rep = (struct cdeq_rep*) c_realloc(rep->cap ? rep : NULL, \
- offsetof(struct cdeq_rep, base) + cap*sizeof(i_VAL)); \
+ offsetof(struct cdeq_rep, base) + cap*sizeof(i_val)); \
rep->size = sz, rep->cap = cap; \
self->_base = (cx_value_t *) rep->base; \
self->data = self->_base + nfront; \
@@ -221,13 +221,13 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; size_t sz = rep->size, cap = rep->cap; \
size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront; \
if (nfront >= n) { \
- self->data = (cx_value_t *) memmove(self->data - n, self->data, idx*sizeof(i_VAL)); \
+ self->data = (cx_value_t *) memmove(self->data - n, self->data, idx*sizeof(i_val)); \
} else { \
if (sz*1.3 + n > cap) cap = cx_memb(_realloc_)(self, n); \
size_t unused = cap - (sz + n); \
size_t pos = (nback*2 < unused) ? unused - nback : unused/2; \
- memmove(self->_base + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_VAL)); \
- self->data = (cx_value_t *) memmove(self->_base + pos, self->data, idx*sizeof(i_VAL)); \
+ memmove(self->_base + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val)); \
+ self->data = (cx_value_t *) memmove(self->_base + pos, self->data, idx*sizeof(i_val)); \
} \
} \
\
@@ -237,12 +237,12 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; size_t sz = rep->size, cap = rep->cap; \
size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront; \
if (nback >= n || sz*1.3 + n > cap && cx_memb(_realloc_)(self, n)) { \
- memmove(self->data + idx + n, self->data + idx, (sz - idx)*sizeof(i_VAL)); \
+ memmove(self->data + idx + n, self->data + idx, (sz - idx)*sizeof(i_val)); \
} else { \
size_t unused = cap - (sz + n); \
size_t pos = (nfront*2 < unused) ? nfront : unused/2; \
- memmove(self->_base + pos, self->data, idx*sizeof(i_VAL)); \
- memmove(self->data + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_VAL)); \
+ memmove(self->_base + pos, self->data, idx*sizeof(i_val)); \
+ memmove(self->data + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val)); \
self->data = ((cx_value_t *) self->_base) + pos; \
} \
} \
@@ -257,7 +257,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; } \
\
STC_DEF void \
- cx_memb(_push_front)(Self* self, i_VAL value) { \
+ cx_memb(_push_front)(Self* self, i_val value) { \
if (self->data == self->_base) \
cx_memb(_expand_left_)(self, 0, 1); \
else \
@@ -267,7 +267,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; } \
\
STC_DEF void \
- cx_memb(_push_back)(Self* self, i_VAL value) { \
+ cx_memb(_push_back)(Self* self, i_val value) { \
struct cdeq_rep* rep = _cdeq_rep(self); \
if (_cdeq_nfront(self) + rep->size == rep->cap) \
cx_memb(_expand_right_)(self, rep->size, 1); \
@@ -287,7 +287,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; const cx_value_t* p2, bool clone) { \
pos = cx_memb(_insert_space_)(self, pos, p2 - p1); \
cx_iter_t it = {pos}; \
- if (clone) while (p1 != p2) *pos++ = i_VALFROM(i_VALTO(p1++)); \
+ if (clone) while (p1 != p2) *pos++ = i_valfrom(i_valto(p1++)); \
else memcpy(pos, p1, (p2 - p1)*sizeof *p1); \
return it; \
} \
@@ -296,7 +296,7 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; cx_memb(_emplace_range_p)(Self* self, cx_value_t* pos, const cx_rawvalue_t* p1, const cx_rawvalue_t* p2) { \
pos = cx_memb(_insert_space_)(self, pos, p2 - p1); \
cx_iter_t it = {pos}; \
- while (p1 != p2) *pos++ = i_VALFROM(*p1++); \
+ while (p1 != p2) *pos++ = i_valfrom(*p1++); \
return it; \
} \
\
@@ -305,32 +305,32 @@ static struct cdeq_rep _cdeq_sentinel = {0, 0}; size_t n = p2 - p1; \
if (n > 0) { \
cx_value_t* p = p1, *end = self->data + _cdeq_rep(self)->size; \
- while (p != p2) i_VALDEL(p++); \
+ while (p != p2) i_valdel(p++); \
if (p1 == self->data) self->data += n; \
- else memmove(p1, p2, (end - p2) * sizeof(i_VAL)); \
+ else memmove(p1, p2, (end - p2) * sizeof(i_val)); \
_cdeq_rep(self)->size -= n; \
} \
return c_make(cx_iter_t){p1}; \
} \
\
STC_DEF cx_iter_t \
- cx_memb(_find_in)(cx_iter_t i1, cx_iter_t i2, i_VALRAW raw) { \
+ cx_memb(_find_in)(cx_iter_t i1, cx_iter_t i2, i_valraw raw) { \
for (; i1.ref != i2.ref; ++i1.ref) { \
- i_VALRAW r = i_VALTO(i1.ref); \
- if (i_CMP(&raw, &r) == 0) return i1; \
+ i_valraw r = i_valto(i1.ref); \
+ if (i_cmp(&raw, &r) == 0) return i1; \
} \
return i2; \
} \
\
STC_DEF int \
cx_memb(_value_compare)(const cx_value_t* x, const cx_value_t* y) { \
- i_VALRAW rx = i_VALTO(x); \
- i_VALRAW ry = i_VALTO(y); \
- return i_CMP(&rx, &ry); \
+ i_valraw rx = i_valto(x); \
+ i_valraw ry = i_valto(y); \
+ return i_cmp(&rx, &ry); \
}
#else
-#define _c_implement_cdeq(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW)
+#define _c_implement_cdeq(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw)
#endif
#endif
diff --git a/include/stc/clist.h b/include/stc/clist.h index 63633e55..43790aac 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -30,8 +30,8 @@ #include <stdio.h>
#include <stc/crandom.h>
- #define i_TAG ix
- #define i_VAL int64_t
+ #define i_tag ix
+ #define i_val int64_t
#include <stc/clist.h>
int main() {
@@ -72,14 +72,14 @@ _c_clist_types(clist_VOID, int); _c_clist_complete_types(clist_VOID, dummy);
#endif // CLIST_H_INCLUDED
-#define i_MODULE clist
+#define i_module clist
#include "template.h"
-#if !defined i_FWD
-cx_deftypes(_c_clist_types, Self, i_VAL);
+#if !defined i_fwd
+cx_deftypes(_c_clist_types, Self, i_val);
#endif
cx_deftypes(_c_clist_complete_types, Self);
-typedef i_VALRAW cx_rawvalue_t;
+typedef i_valraw cx_rawvalue_t;
#ifndef CLIST_H_INCLUDED
@@ -91,7 +91,7 @@ typedef i_VALRAW cx_rawvalue_t; entry->value = val
// +: set self->last based on node
-#if !defined(STC_HEADER) || defined(i_IMP) && (i_IMP == 2)
+#if !defined(STC_HEADER) || defined(i_imp) && (i_imp == 2)
// NON TEMPLATED CODE
STC_DEF size_t
@@ -157,17 +157,17 @@ _clist_mergesort(clist_VOID_node_t *list, int (*cmp)(const clist_VOID_node_t*, c STC_API Self cx_memb(_clone)(Self cx);
STC_API void cx_memb(_del)(Self* self);
-STC_API void cx_memb(_push_back)(Self* self, i_VAL value);
-STC_API void cx_memb(_push_front)(Self* self, i_VAL value);
-STC_API cx_iter_t cx_memb(_insert)(Self* self, cx_iter_t it, i_VAL value);
+STC_API void cx_memb(_push_back)(Self* self, i_val value);
+STC_API void cx_memb(_push_front)(Self* self, i_val value);
+STC_API cx_iter_t cx_memb(_insert)(Self* self, cx_iter_t it, i_val value);
STC_API void cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n);
STC_API cx_iter_t cx_memb(_erase_at)(Self* self, cx_iter_t it);
STC_API cx_iter_t cx_memb(_erase_range)(Self* self, cx_iter_t it1, cx_iter_t it2);
-STC_API size_t cx_memb(_remove)(Self* self, i_VALRAW val);
+STC_API size_t cx_memb(_remove)(Self* self, i_valraw val);
STC_API cx_iter_t cx_memb(_splice)(Self* self, cx_iter_t it, Self* other);
STC_API Self cx_memb(_split_off)(Self* self, cx_iter_t it1, cx_iter_t it2);
STC_API void cx_memb(_sort)(Self* self);
-STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW val);
+STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val);
STC_API cx_node_t* cx_memb(_erase_after_)(Self* self, cx_node_t* node);
STC_INLINE Self cx_memb(_init)(void) { return c_make(Self){NULL}; }
@@ -175,20 +175,20 @@ STC_INLINE bool cx_memb(_empty)(Self cx) { return cx.last == NULL; } STC_INLINE size_t cx_memb(_count)(Self cx)
{ return _clist_count((const clist_VOID*) &cx); }
STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); }
-STC_INLINE i_VAL cx_memb(_value_fromraw)(i_VALRAW raw) { return i_VALFROM(raw); }
-STC_INLINE i_VALRAW cx_memb(_value_toraw)(cx_value_t* pval) { return i_VALTO(pval); }
-STC_INLINE i_VAL cx_memb(_value_clone)(i_VAL val)
- { return i_VALFROM(i_VALTO(&val)); }
+STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); }
+STC_INLINE i_valraw cx_memb(_value_toraw)(cx_value_t* pval) { return i_valto(pval); }
+STC_INLINE i_val cx_memb(_value_clone)(i_val val)
+ { return i_valfrom(i_valto(&val)); }
STC_INLINE void cx_memb(_pop_front)(Self* self)
{ cx_memb(_erase_after_)(self, self->last); }
STC_INLINE cx_iter_t cx_memb(_erase)(Self* self, cx_iter_t it)
{ return cx_memb(_erase_at)(self, it); }
-STC_INLINE void cx_memb(_emplace_back)(Self* self, i_VALRAW raw)
- { cx_memb(_push_back)(self, i_VALFROM(raw)); }
-STC_INLINE void cx_memb(_emplace_front)(Self* self, i_VALRAW raw)
- { cx_memb(_push_front)(self, i_VALFROM(raw)); }
-STC_INLINE cx_iter_t cx_memb(_emplace)(Self* self, cx_iter_t it, i_VALRAW raw)
- { return cx_memb(_insert)(self, it, i_VALFROM(raw)); }
+STC_INLINE void cx_memb(_emplace_back)(Self* self, i_valraw raw)
+ { cx_memb(_push_back)(self, i_valfrom(raw)); }
+STC_INLINE void cx_memb(_emplace_front)(Self* self, i_valraw raw)
+ { cx_memb(_push_front)(self, i_valfrom(raw)); }
+STC_INLINE cx_iter_t cx_memb(_emplace)(Self* self, cx_iter_t it, i_valraw raw)
+ { return cx_memb(_insert)(self, it, i_valfrom(raw)); }
STC_INLINE cx_value_t* cx_memb(_front)(const Self* self) { return &self->last->next->value; }
STC_INLINE cx_value_t* cx_memb(_back)(const Self* self) { return &self->last->value; }
@@ -228,23 +228,23 @@ cx_memb(_splice_range)(Self* self, cx_iter_t it, }
STC_INLINE cx_iter_t
-cx_memb(_find)(const Self* self, i_VALRAW val) {
+cx_memb(_find)(const Self* self, i_valraw val) {
return cx_memb(_find_in)(cx_memb(_begin)(self), cx_memb(_end)(self), val);
}
STC_INLINE cx_value_t*
-cx_memb(_get)(const Self* self, i_VALRAW val) {
+cx_memb(_get)(const Self* self, i_valraw val) {
return cx_memb(_find_in)(cx_memb(_begin)(self), cx_memb(_end)(self), val).ref;
}
// -------------------------- IMPLEMENTATION -------------------------
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_IMP)
+#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
STC_DEF Self
cx_memb(_clone)(Self cx) {
Self out = cx_memb(_init)();
- c_foreach (it, Self, cx) cx_memb(_emplace_back)(&out, i_VALTO(it.ref));
+ c_foreach (it, Self, cx) cx_memb(_emplace_back)(&out, i_valto(it.ref));
return out;
}
@@ -254,24 +254,24 @@ cx_memb(_del)(Self* self) { }
STC_DEF void
-cx_memb(_push_back)(Self* self, i_VAL value) {
+cx_memb(_push_back)(Self* self, i_val value) {
_c_clist_insert_after(self, Self, self->last, value);
self->last = entry;
}
STC_DEF void
-cx_memb(_push_front)(Self* self, i_VAL value) {
+cx_memb(_push_front)(Self* self, i_val value) {
_c_clist_insert_after(self, Self, self->last, value);
if (!self->last) self->last = entry;
}
STC_DEF void
cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n) {
- for (size_t i=0; i<n; ++i) cx_memb(_push_back)(self, i_VALFROM(arr[i]));
+ for (size_t i=0; i<n; ++i) cx_memb(_push_back)(self, i_valfrom(arr[i]));
}
STC_DEF cx_iter_t
-cx_memb(_insert)(Self* self, cx_iter_t it, i_VAL value) {
+cx_memb(_insert)(Self* self, cx_iter_t it, i_val value) {
cx_node_t* node = it.ref ? it.prev : self->last;
_c_clist_insert_after(self, Self, node, value);
if (!self->last || !it.ref) {
@@ -300,10 +300,10 @@ cx_memb(_erase_range)(Self* self, cx_iter_t it1, cx_iter_t it2) { }
STC_DEF cx_iter_t
-cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW val) {
+cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val) {
c_foreach (it, Self, it1, it2) {
- i_VALRAW r = i_VALTO(it.ref);
- if (i_CMP(&r, &val) == 0) return it;
+ i_valraw r = i_valto(it.ref);
+ if (i_cmp(&r, &val) == 0) return it;
}
it2.ref = NULL; return it2;
}
@@ -314,18 +314,18 @@ cx_memb(_erase_after_)(Self* self, cx_node_t* node) { node->next = next;
if (del == next) self->last = node = NULL;
else if (self->last == del) self->last = node, node = NULL;
- i_VALDEL(&del->value); c_free(del);
+ i_valdel(&del->value); c_free(del);
return node;
}
STC_DEF size_t
-cx_memb(_remove)(Self* self, i_VALRAW val) {
+cx_memb(_remove)(Self* self, i_valraw val) {
size_t n = 0;
cx_node_t* prev = self->last, *node;
while (prev) {
node = prev->next;
- i_VALRAW r = i_VALTO(&node->value);
- if (i_CMP(&r, &val) == 0)
+ i_valraw r = i_valto(&node->value);
+ if (i_cmp(&r, &val) == 0)
prev = cx_memb(_erase_after_)(self, prev), ++n;
else
prev = (node == self->last ? NULL : node);
@@ -361,9 +361,9 @@ cx_memb(_split_off)(Self* self, cx_iter_t it1, cx_iter_t it2) { STC_DEF int
cx_memb(_sort_cmp_)(const clist_VOID_node_t* x, const clist_VOID_node_t* y) {
- i_VALRAW a = i_VALTO(&((const cx_node_t *) x)->value);
- i_VALRAW b = i_VALTO(&((const cx_node_t *) y)->value);
- return i_CMP(&a, &b);
+ i_valraw a = i_valto(&((const cx_node_t *) x)->value);
+ i_valraw b = i_valto(&((const cx_node_t *) y)->value);
+ return i_cmp(&a, &b);
}
STC_DEF void
diff --git a/include/stc/clist_v1.h b/include/stc/clist_v1.h index 8a3d6cb7..e19b2764 100644 --- a/include/stc/clist_v1.h +++ b/include/stc/clist_v1.h @@ -61,25 +61,25 @@ _c_clist_types(clist_VOID, int); STC_API size_t _clist_count(const clist_VOID* self);
#define _clist_node(Self, vp) c_container_of(vp, cx_node_t, value)
-#define _c_using_clist(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW, defTypes) \
+#define _c_using_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw, defTypes) \
\
- defTypes( _c_clist_types(Self, i_VAL); ) \
- typedef i_VALRAW cx_rawvalue_t; \
+ defTypes( _c_clist_types(Self, i_val); ) \
+ typedef i_valraw cx_rawvalue_t; \
\
STC_API Self cx_memb(_clone)(Self lst); \
STC_API void cx_memb(_del)(Self* self); \
- STC_API void cx_memb(_push_back)(Self* self, i_VAL value); \
- STC_API void cx_memb(_push_front)(Self* self, i_VAL value); \
+ STC_API void cx_memb(_push_back)(Self* self, i_val value); \
+ STC_API void cx_memb(_push_front)(Self* self, i_val value); \
STC_API void cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n); \
STC_API Self cx_memb(_split_after)(Self* self, cx_iter_t pos1, cx_iter_t pos2); \
STC_API void cx_memb(_splice_after)(Self* self, cx_iter_t pos, Self* other); \
STC_DEF void cx_memb(_splice_after_range)(Self* self, cx_iter_t pos, Self* other, cx_iter_t i1, cx_iter_t i2); \
- STC_API cx_iter_t cx_memb(_find)(const Self* self, i_VALRAW val); \
- STC_API cx_iter_t cx_memb(_find_before)(const Self* self, i_VALRAW val); \
- STC_API cx_iter_t cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW val); \
+ STC_API cx_iter_t cx_memb(_find)(const Self* self, i_valraw val); \
+ STC_API cx_iter_t cx_memb(_find_before)(const Self* self, i_valraw val); \
+ STC_API cx_iter_t cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val); \
STC_API void cx_memb(_sort)(Self* self); \
- STC_API size_t cx_memb(_remove)(Self* self, i_VALRAW val); \
- STC_API cx_iter_t cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_VAL value); \
+ STC_API size_t cx_memb(_remove)(Self* self, i_valraw val); \
+ STC_API cx_iter_t cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_val value); \
STC_API cx_iter_t cx_memb(_erase_after)(Self* self, cx_iter_t pos); \
STC_API cx_iter_t cx_memb(_erase_range_after)(Self* self, cx_iter_t pos, cx_iter_t it2); \
STC_API cx_node_t* cx_memb(_erase_after_)(Self* self, cx_node_t* node); \
@@ -87,13 +87,13 @@ STC_API size_t _clist_count(const clist_VOID* self); STC_INLINE Self cx_memb(_init)(void) {Self lst = {NULL}; return lst; } \
STC_INLINE bool cx_memb(_empty)(Self lst) { return lst.last == NULL; } \
STC_INLINE size_t cx_memb(_count)(Self lst) { return _clist_count((const clist_VOID*) &lst); } \
- STC_INLINE i_VAL cx_memb(_value_fromraw)(i_VALRAW raw) { return i_VALFROM(raw); } \
- STC_INLINE i_VAL cx_memb(_value_clone)(i_VAL val) { return i_VALFROM(i_VALTO(&val)); } \
+ STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); } \
+ STC_INLINE i_val cx_memb(_value_clone)(i_val val) { return i_valfrom(i_valto(&val)); } \
STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); } \
- STC_INLINE void cx_memb(_emplace_back)(Self* self, i_VALRAW raw) \
- { cx_memb(_push_back)(self, i_VALFROM(raw)); } \
- STC_INLINE void cx_memb(_emplace_front)(Self* self, i_VALRAW raw) \
- { cx_memb(_push_front)(self, i_VALFROM(raw)); } \
+ STC_INLINE void cx_memb(_emplace_back)(Self* self, i_valraw raw) \
+ { cx_memb(_push_back)(self, i_valfrom(raw)); } \
+ STC_INLINE void cx_memb(_emplace_front)(Self* self, i_valraw raw) \
+ { cx_memb(_push_front)(self, i_valfrom(raw)); } \
STC_INLINE cx_value_t* \
cx_memb(_front)(const Self* self) { return &self->last->next->value; } \
STC_INLINE cx_value_t* \
@@ -105,8 +105,8 @@ STC_API size_t _clist_count(const clist_VOID* self); { cx_memb(_splice_after)(self, cx_memb(_last)(self), other); } \
\
STC_INLINE cx_iter_t \
- cx_memb(_emplace_after)(Self* self, cx_iter_t pos, i_VALRAW raw) { \
- return cx_memb(_insert_after)(self, pos, i_VALFROM(raw)); \
+ cx_memb(_emplace_after)(Self* self, cx_iter_t pos, i_valraw raw) { \
+ return cx_memb(_insert_after)(self, pos, i_valfrom(raw)); \
} \
\
STC_INLINE cx_iter_t \
@@ -143,19 +143,19 @@ STC_API size_t _clist_count(const clist_VOID* self); while (n-- && it.ref) cx_memb(_next)(&it); return it; \
} \
\
- _c_implement_clist(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW) \
+ _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
struct stc_trailing_semicolon
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-#define _c_implement_clist(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW) \
+#define _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
\
STC_DEF Self \
cx_memb(_clone)(Self lst) { \
Self out = cx_memb(_init)(); \
c_foreach_3 (i, Self, lst) \
- cx_memb(_emplace_back)(&out, i_VALTO(i.ref)); \
+ cx_memb(_emplace_back)(&out, i_valto(i.ref)); \
return out; \
} \
\
@@ -165,23 +165,23 @@ STC_API size_t _clist_count(const clist_VOID* self); } \
\
STC_DEF void \
- cx_memb(_push_back)(Self* self, i_VAL value) { \
+ cx_memb(_push_back)(Self* self, i_val value) { \
_c_clist_insert_after(self, Self, self->last, value); \
self->last = entry; \
} \
STC_DEF void \
- cx_memb(_push_front)(Self* self, i_VAL value) { \
+ cx_memb(_push_front)(Self* self, i_val value) { \
_c_clist_insert_after(self, Self, self->last, value); \
if (!self->last) self->last = entry; \
} \
\
STC_DEF void \
cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n) { \
- for (size_t i=0; i<n; ++i) cx_memb(_push_back)(self, i_VALFROM(arr[i])); \
+ for (size_t i=0; i<n; ++i) cx_memb(_push_back)(self, i_valfrom(arr[i])); \
} \
\
STC_DEF cx_iter_t \
- cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_VAL value) { \
+ cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_val value) { \
cx_node_t* node = pos.ref ? _clist_node(Self, pos.ref) : NULL; \
_c_clist_insert_after(self, Self, node, value); \
if (!node || node == self->last && pos._state == 0) self->last = entry; \
@@ -203,24 +203,24 @@ STC_API size_t _clist_count(const clist_VOID* self); } \
\
STC_DEF cx_iter_t \
- cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW val) { \
+ cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val) { \
cx_iter_t i = it1; \
for (cx_memb(_next)(&i); i.ref != it2.ref; cx_memb(_next)(&i)) { \
- i_VALRAW r = i_VALTO(i.ref); \
- if (i_CMP(&r, &val) == 0) return it1; \
+ i_valraw r = i_valto(i.ref); \
+ if (i_cmp(&r, &val) == 0) return it1; \
it1 = i; \
} \
it1.ref = NULL; return it1; \
} \
\
STC_DEF cx_iter_t \
- cx_memb(_find_before)(const Self* self, i_VALRAW val) { \
+ cx_memb(_find_before)(const Self* self, i_valraw val) { \
cx_iter_t it = cx_memb(_find_before_in)(cx_memb(_before_begin)(self), cx_memb(_end)(self), val); \
return it; \
} \
\
STC_DEF cx_iter_t \
- cx_memb(_find)(const Self* self, i_VALRAW val) { \
+ cx_memb(_find)(const Self* self, i_valraw val) { \
cx_iter_t it = cx_memb(_find_before_in)(cx_memb(_before_begin)(self), cx_memb(_end)(self), val); \
if (it.ref != cx_memb(_end)(self).ref) cx_memb(_next)(&it); \
return it; \
@@ -232,18 +232,18 @@ STC_API size_t _clist_count(const clist_VOID* self); node->next = next; \
if (del == next) self->last = node = NULL; \
else if (self->last == del) self->last = node, node = NULL; \
- i_VALDEL(&del->value); c_free(del); \
+ i_valdel(&del->value); c_free(del); \
return node; \
} \
\
STC_DEF size_t \
- cx_memb(_remove)(Self* self, i_VALRAW val) { \
+ cx_memb(_remove)(Self* self, i_valraw val) { \
size_t n = 0; \
cx_node_t* prev = self->last, *node; \
while (prev) { \
node = prev->next; \
- i_VALRAW r = i_VALTO(&node->value); \
- if (i_CMP(&r, &val) == 0) \
+ i_valraw r = i_valto(&node->value); \
+ if (i_cmp(&r, &val) == 0) \
prev = cx_memb(_erase_after_)(self, prev), ++n; \
else \
prev = (node == self->last ? NULL : node); \
@@ -281,9 +281,9 @@ STC_API size_t _clist_count(const clist_VOID* self); \
STC_DEF int \
cx_memb(_sort_cmp_)(const void* x, const void* y) { \
- i_VALRAW a = i_VALTO(&((cx_node_t *) x)->value); \
- i_VALRAW b = i_VALTO(&((cx_node_t *) y)->value); \
- return i_CMP(&a, &b); \
+ i_valraw a = i_valto(&((cx_node_t *) x)->value); \
+ i_valraw b = i_valto(&((cx_node_t *) y)->value); \
+ return i_cmp(&a, &b); \
} \
\
STC_DEF void \
@@ -361,7 +361,7 @@ _clist_mergesort(clist_VOID_node_t *list, int (*cmp)(const void*, const void*)) }
#else
-#define _c_implement_clist(Self, i_VAL, i_CMP, i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW)
+#define _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw)
#endif
#endif
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index d6f480d0..474d43df 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -25,9 +25,9 @@ /*
#include <stdio.h>
-#define i_TAG mx
-#define i_KEY int
-#define i_VAL char // Map of int -> char
+#define i_tag mx
+#define i_key int
+#define i_val char // Map of int -> char
#include <stc/cmap.h>
int main(void) {
@@ -58,7 +58,7 @@ int main(void) { #define _cmap_inits {NULL, NULL, 0, 0, 0.85f}
typedef struct { size_t idx; uint_fast8_t hx; } chash_bucket_t;
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_IMP)
+#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
STC_INLINE uint64_t c_default_hash(const void *key, size_t len) {
const uint64_t m = 0xb5ad4eceda1ce2a9;
@@ -87,15 +87,15 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored) #endif
#endif // CMAP_H_INCLUDED
-#ifndef i_MODULE
-#define i_MODULE cmap
+#ifndef i_module
+#define i_module cmap
#define cx_MAP_ONLY c_true
#define cx_SET_ONLY c_false
#define cx_keyref(vp) (&(vp)->first)
#endif
#include "template.h"
-#ifndef i_FWD
-cx_deftypes(_c_chash_types, Self, i_KEY, i_VAL, cx_MAP_ONLY, cx_SET_ONLY);
+#ifndef i_fwd
+cx_deftypes(_c_chash_types, Self, i_key, i_val, cx_MAP_ONLY, cx_SET_ONLY);
#endif
cx_MAP_ONLY( struct cx_value_t {
@@ -103,11 +103,11 @@ cx_MAP_ONLY( struct cx_value_t { cx_mapped_t second;
}; )
-typedef i_KEYRAW cx_rawkey_t;
-typedef i_VALRAW cx_memb(_rawmapped_t);
-typedef cx_SET_ONLY( i_KEYRAW )
- cx_MAP_ONLY( struct { i_KEYRAW first;
- i_VALRAW second; } )
+typedef i_keyraw cx_rawkey_t;
+typedef i_valraw cx_memb(_rawmapped_t);
+typedef cx_SET_ONLY( i_keyraw )
+ cx_MAP_ONLY( struct { i_keyraw first;
+ i_valraw second; } )
cx_rawvalue_t;
STC_API Self cx_memb(_with_capacity)(size_t cap);
@@ -116,7 +116,7 @@ STC_API void cx_memb(_del)(Self* self); STC_API void cx_memb(_clear)(Self* self);
STC_API void cx_memb(_reserve)(Self* self, size_t capacity);
STC_API chash_bucket_t cx_memb(_bucket_)(const Self* self, const cx_rawkey_t* rkeyptr);
-STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey);
+STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_keyraw rkey);
STC_API void cx_memb(_erase_entry)(Self* self, cx_value_t* val);
STC_INLINE Self cx_memb(_init)(void) { return c_make(Self)_cmap_inits; }
@@ -128,20 +128,20 @@ STC_INLINE size_t cx_memb(_bucket_count)(Self map) { return map.bucket_cou STC_INLINE size_t cx_memb(_capacity)(Self map)
{ return (size_t) (map.bucket_count * map.max_load_factor); }
STC_INLINE void cx_memb(_swap)(Self *map1, Self *map2) {c_swap(Self, *map1, *map2); }
-STC_INLINE bool cx_memb(_contains)(const Self* self, i_KEYRAW rkey)
+STC_INLINE bool cx_memb(_contains)(const Self* self, i_keyraw rkey)
{ return self->size && self->_hashx[cx_memb(_bucket_)(self, &rkey).idx]; }
cx_MAP_ONLY(
- STC_API cx_result_t cx_memb(_insert_or_assign)(Self* self, i_KEY _key, i_VAL _mapped);
- STC_API cx_result_t cx_memb(_emplace_or_assign)(Self* self, i_KEYRAW rkey, i_VALRAW rmapped);
+ STC_API cx_result_t cx_memb(_insert_or_assign)(Self* self, i_key _key, i_val _mapped);
+ STC_API cx_result_t cx_memb(_emplace_or_assign)(Self* self, i_keyraw rkey, i_valraw rmapped);
STC_INLINE cx_result_t /* short-form, like operator[]: */
- cx_memb(_put)(Self* self, i_KEY key, i_VAL mapped) {
+ cx_memb(_put)(Self* self, i_key key, i_val mapped) {
return cx_memb(_insert_or_assign)(self, key, mapped);
}
STC_INLINE cx_mapped_t*
- cx_memb(_at)(const Self* self, i_KEYRAW rkey) {
+ cx_memb(_at)(const Self* self, i_keyraw rkey) {
chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
return &self->table[b.idx].second;
}
@@ -149,28 +149,28 @@ cx_MAP_ONLY( STC_INLINE void
cx_memb(_value_clone)(cx_value_t* _dst, cx_value_t* _val) {
- *cx_keyref(_dst) = i_KEYFROM(i_KEYTO(cx_keyref(_val)));
- cx_MAP_ONLY( _dst->second = i_VALFROM(i_VALTO(&_val->second)); )
+ *cx_keyref(_dst) = i_keyfrom(i_keyto(cx_keyref(_val)));
+ cx_MAP_ONLY( _dst->second = i_valfrom(i_valto(&_val->second)); )
}
STC_INLINE cx_rawvalue_t
cx_memb(_value_toraw)(cx_value_t* val) {
- return cx_SET_ONLY( i_KEYTO(val) )
- cx_MAP_ONLY( c_make(cx_rawvalue_t){i_KEYTO(&val->first), i_VALTO(&val->second)} );
+ return cx_SET_ONLY( i_keyto(val) )
+ cx_MAP_ONLY( c_make(cx_rawvalue_t){i_keyto(&val->first), i_valto(&val->second)} );
}
STC_INLINE void
cx_memb(_value_del)(cx_value_t* _val) {
- i_KEYDEL(cx_keyref(_val));
- cx_MAP_ONLY( i_VALDEL(&_val->second); )
+ i_keydel(cx_keyref(_val));
+ cx_MAP_ONLY( i_valdel(&_val->second); )
}
STC_INLINE cx_result_t
-cx_memb(_emplace)(Self* self, i_KEYRAW rkey cx_MAP_ONLY(, i_VALRAW rmapped)) {
+cx_memb(_emplace)(Self* self, i_keyraw rkey cx_MAP_ONLY(, i_valraw rmapped)) {
cx_result_t _res = cx_memb(_insert_entry_)(self, rkey);
if (_res.inserted) {
- *cx_keyref(_res.ref) = i_KEYFROM(rkey);
- cx_MAP_ONLY(_res.ref->second = i_VALFROM(rmapped);)
+ *cx_keyref(_res.ref) = i_keyfrom(rkey);
+ cx_MAP_ONLY(_res.ref->second = i_valfrom(rmapped);)
}
return _res;
}
@@ -182,15 +182,15 @@ cx_memb(_emplace_items)(Self* self, const cx_rawvalue_t arr[], size_t n) { }
STC_INLINE cx_result_t
-cx_memb(_insert)(Self* self, i_KEY _key cx_MAP_ONLY(, i_VAL _mapped)) {
- cx_result_t _res = cx_memb(_insert_entry_)(self, i_KEYTO(&_key));
+cx_memb(_insert)(Self* self, i_key _key cx_MAP_ONLY(, i_val _mapped)) {
+ cx_result_t _res = cx_memb(_insert_entry_)(self, i_keyto(&_key));
if (_res.inserted) { *cx_keyref(_res.ref) = _key; cx_MAP_ONLY( _res.ref->second = _mapped; )}
- else { i_KEYDEL(&_key); cx_MAP_ONLY( i_VALDEL(&_mapped); )}
+ else { i_keydel(&_key); cx_MAP_ONLY( i_valdel(&_mapped); )}
return _res;
}
STC_INLINE cx_iter_t
-cx_memb(_find)(const Self* self, i_KEYRAW rkey) {
+cx_memb(_find)(const Self* self, i_keyraw rkey) {
cx_iter_t it = {NULL};
if (self->size == 0) return it;
chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
@@ -199,7 +199,7 @@ cx_memb(_find)(const Self* self, i_KEYRAW rkey) { }
STC_INLINE cx_value_t*
-cx_memb(_get)(const Self* self, i_KEYRAW rkey)
+cx_memb(_get)(const Self* self, i_keyraw rkey)
{ return cx_memb(_find)(self, rkey).ref; }
STC_INLINE cx_iter_t
@@ -218,7 +218,7 @@ cx_memb(_next)(cx_iter_t* it) {while ((++it->ref, *++it->_hx == 0)) ; }
STC_INLINE size_t
-cx_memb(_erase)(Self* self, i_KEYRAW rkey) {
+cx_memb(_erase)(Self* self, i_keyraw rkey) {
if (self->size == 0) return 0;
chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
return self->_hashx[b.idx] ? cx_memb(_erase_entry)(self, self->table + b.idx), 1 : 0;
@@ -233,7 +233,7 @@ cx_memb(_erase_at)(Self* self, cx_iter_t it) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_IMP)
+#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
//STC_INLINE size_t fastrange_uint64_t(uint64_t x, uint64_t n)
// { uint64_t lo, hi; c_umul128(x, n, &lo, &hi); return hi; }
@@ -268,32 +268,32 @@ STC_DEF void cx_memb(_clear)(Self* self) { cx_MAP_ONLY(
STC_DEF cx_result_t
- cx_memb(_insert_or_assign)(Self* self, i_KEY _key, i_VAL _mapped) {
- cx_result_t _res = cx_memb(_insert_entry_)(self, i_KEYTO(&_key));
+ cx_memb(_insert_or_assign)(Self* self, i_key _key, i_val _mapped) {
+ cx_result_t _res = cx_memb(_insert_entry_)(self, i_keyto(&_key));
if (_res.inserted) _res.ref->first = _key;
- else { i_KEYDEL(&_key); i_VALDEL(&_res.ref->second); }
+ else { i_keydel(&_key); i_valdel(&_res.ref->second); }
_res.ref->second = _mapped; return _res;
}
STC_DEF cx_result_t
- cx_memb(_emplace_or_assign)(Self* self, i_KEYRAW rkey, i_VALRAW rmapped) {
+ cx_memb(_emplace_or_assign)(Self* self, i_keyraw rkey, i_valraw rmapped) {
cx_result_t _res = cx_memb(_insert_entry_)(self, rkey);
- if (_res.inserted) _res.ref->first = i_KEYFROM(rkey);
- else i_VALDEL(&_res.ref->second);
- _res.ref->second = i_VALFROM(rmapped); return _res;
+ if (_res.inserted) _res.ref->first = i_keyfrom(rkey);
+ else i_valdel(&_res.ref->second);
+ _res.ref->second = i_valfrom(rmapped); return _res;
}
)
STC_DEF chash_bucket_t
cx_memb(_bucket_)(const Self* self, const cx_rawkey_t* rkeyptr) {
- const uint64_t _hash = i_HASH(rkeyptr, sizeof *rkeyptr);
+ const uint64_t _hash = i_hash(rkeyptr, sizeof *rkeyptr);
uint_fast8_t _hx; size_t _cap = self->bucket_count;
chash_bucket_t b = {c_PASTE(fastrange_,MAP_SIZE_T)(_hash, _cap), (uint_fast8_t)(_hash | 0x80)};
const uint8_t* _hashx = self->_hashx;
while ((_hx = _hashx[b.idx])) {
if (_hx == b.hx) {
- cx_rawkey_t _raw = i_KEYTO(cx_keyref(self->table + b.idx));
- if (i_EQU(&_raw, rkeyptr)) break;
+ cx_rawkey_t _raw = i_keyto(cx_keyref(self->table + b.idx));
+ if (i_equ(&_raw, rkeyptr)) break;
}
if (++b.idx == _cap) b.idx = 0;
}
@@ -301,7 +301,7 @@ cx_memb(_bucket_)(const Self* self, const cx_rawkey_t* rkeyptr) { }
STC_DEF cx_result_t
-cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey) {
+cx_memb(_insert_entry_)(Self* self, i_keyraw rkey) {
if (self->size + 1 >= (cx_memb(_size_t)) (self->bucket_count * self->max_load_factor))
cx_memb(_reserve)(self, 8 + (self->size*13ull >> 3));
chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
@@ -344,7 +344,7 @@ cx_memb(_reserve)(Self* self, size_t _newcap) { uint8_t* _hashx = self->_hashx;
for (size_t i = 0; i < _oldcap; ++i, ++e)
if (_tmp._hashx[i]) {
- cx_rawkey_t _raw = i_KEYTO(cx_keyref(e));
+ cx_rawkey_t _raw = i_keyto(cx_keyref(e));
chash_bucket_t b = cx_memb(_bucket_)(self, &_raw);
_slot[b.idx] = *e;
_hashx[b.idx] = (uint8_t) b.hx;
@@ -363,8 +363,8 @@ cx_memb(_erase_entry)(Self* self, cx_value_t* _val) { if (++j == _cap) j = 0;
if (! _hashx[j])
break;
- cx_rawkey_t _raw = i_KEYTO(cx_keyref(_slot+j));
- k = c_PASTE(fastrange_,MAP_SIZE_T)(i_HASH(&_raw, sizeof _raw), _cap);
+ cx_rawkey_t _raw = i_keyto(cx_keyref(_slot+j));
+ k = c_PASTE(fastrange_,MAP_SIZE_T)(i_hash(&_raw, sizeof _raw), _cap);
if ((j < i) ^ (k <= i) ^ (k > j)) /* is k outside (i, j]? */
_slot[i] = _slot[j], _hashx[i] = _hashx[j], i = j;
}
diff --git a/include/stc/cpque.h b/include/stc/cpque.h index 102cf0aa..a9bc6b56 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -55,10 +55,10 @@ #define using_cpque_2(X, ctype) \
_c_using_cpque(cpque_##X, ctype, ctype##_value_compare)
-#define using_cpque_3(X, ctype, i_CMP) \
- _c_using_cpque(cpque_##X, ctype, i_CMP)
+#define using_cpque_3(X, ctype, i_cmp) \
+ _c_using_cpque(cpque_##X, ctype, i_cmp)
-#define _c_using_cpque(Self, ctype, i_CMP) \
+#define _c_using_cpque(Self, ctype, i_cmp) \
typedef ctype Self; \
typedef ctype##_value_t cx_value_t; \
typedef ctype##_rawvalue_t cx_rawvalue_t; \
@@ -84,7 +84,7 @@ { cx_memb(_push)(self, ctype##_value_fromraw(raw)); } \
STC_API void cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n); \
\
- _c_implement_cpque(Self, ctype, i_CMP) \
+ _c_implement_cpque(Self, ctype, i_cmp) \
struct stc_trailing_semicolon
@@ -92,14 +92,14 @@ #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-#define _c_implement_cpque(Self, ctype, i_CMP) \
+#define _c_implement_cpque(Self, ctype, i_cmp) \
\
STC_INLINE void \
cx_memb(_sift_down_)(cx_value_t* arr, size_t i, size_t n) { \
size_t r = i, c = i << 1; \
while (c <= n) { \
- c += (c < n && i_CMP(&arr[c], &arr[c + 1]) < 0); \
- if (i_CMP(&arr[r], &arr[c]) < 0) { \
+ c += (c < n && i_cmp(&arr[c], &arr[c + 1]) < 0); \
+ if (i_cmp(&arr[r], &arr[c]) < 0) { \
cx_value_t tmp = arr[r]; arr[r] = arr[c]; arr[r = c] = tmp; \
} else \
return; \
@@ -128,7 +128,7 @@ ctype##_push_back(self, value); /* sift-up the value */ \
size_t n = cx_memb(_size)(*self), c = n; \
cx_value_t *arr = self->data - 1; \
- for (; c > 1 && i_CMP(&arr[c >> 1], &value) < 0; c >>= 1) \
+ for (; c > 1 && i_cmp(&arr[c >> 1], &value) < 0; c >>= 1) \
arr[c] = arr[c >> 1]; \
if (c != n) arr[c] = value; \
} \
@@ -140,7 +140,7 @@ } \
#else
-#define _c_implement_cpque(Self, ctype, i_CMP)
+#define _c_implement_cpque(Self, ctype, i_cmp)
#endif
#endif
diff --git a/include/stc/cset.h b/include/stc/cset.h index aaa42e46..ffdbca0d 100644 --- a/include/stc/cset.h +++ b/include/stc/cset.h @@ -23,8 +23,8 @@ // Unordered set - implemented as closed hashing with linear probing and no tombstones.
/*
-#define i_TAG sx
-#define i_KEY int
+#define i_tag sx
+#define i_key int
#include <stc/cset.h>
#include <stdio.h>
@@ -39,7 +39,7 @@ int main(void) { }
*/
-#define i_MODULE cset
+#define i_module cset
#define cx_MAP_ONLY c_false
#define cx_SET_ONLY c_true
#define cx_keyref(vp) (vp)
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index 2b0a9245..3ea30083 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -56,7 +56,7 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; #define _csmap_rep(self) c_container_of((self)->nodes, struct csmap_rep, nodes)
#if !defined cx_forwarded
- _c_aatree_types(Self, C, i_KEY, i_VAL);
+ _c_aatree_types(Self, C, i_key, i_val);
#endif
\
@@ -71,25 +71,25 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; cx_value_t value; \
}; \
\
- typedef i_KEYRAW cx_rawkey_t; \
- typedef i_VALRAW cx_memb(_rawmapped_t); \
- typedef cx_SET_ONLY( i_KEYRAW ) \
- cx_MAP_ONLY( struct { i_KEYRAW first; \
- i_VALRAW second; } ) \
+ typedef i_keyraw cx_rawkey_t; \
+ typedef i_valraw cx_memb(_rawmapped_t); \
+ typedef cx_SET_ONLY( i_keyraw ) \
+ cx_MAP_ONLY( struct { i_keyraw first; \
+ i_valraw second; } ) \
cx_rawvalue_t; \
\
STC_API Self cx_memb(_init)(void); \
STC_API Self cx_memb(_clone)(Self tree); \
STC_API void cx_memb(_del)(Self* self); \
STC_API void cx_memb(_reserve)(Self* self, size_t cap); \
- STC_API cx_value_t* cx_memb(_find_it)(const Self* self, i_KEYRAW rkey, cx_iter_t* out); \
- STC_API cx_iter_t cx_memb(_lower_bound)(const Self* self, i_KEYRAW rkey); \
+ STC_API cx_value_t* cx_memb(_find_it)(const Self* self, i_keyraw rkey, cx_iter_t* out); \
+ STC_API cx_iter_t cx_memb(_lower_bound)(const Self* self, i_keyraw rkey); \
STC_API cx_value_t* cx_memb(_front)(const Self* self); \
STC_API cx_value_t* cx_memb(_back)(const Self* self); \
- STC_API int cx_memb(_erase)(Self* self, i_KEYRAW rkey); \
+ STC_API int cx_memb(_erase)(Self* self, i_keyraw rkey); \
STC_API cx_iter_t cx_memb(_erase_at)(Self* self, cx_iter_t it); \
STC_API cx_iter_t cx_memb(_erase_range)(Self* self, cx_iter_t it1, cx_iter_t it2); \
- STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey); \
+ STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_keyraw rkey); \
STC_API void cx_memb(_next)(cx_iter_t* it); \
\
STC_INLINE bool cx_memb(_empty)(Self tree) { return _csmap_rep(&tree)->size == 0; } \
@@ -97,9 +97,9 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; STC_INLINE size_t cx_memb(_capacity)(Self tree) { return _csmap_rep(&tree)->cap; } \
STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); *self = cx_memb(_init)(); } \
STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); } \
- STC_INLINE bool cx_memb(_contains)(const Self* self, i_KEYRAW rkey) \
+ STC_INLINE bool cx_memb(_contains)(const Self* self, i_keyraw rkey) \
{cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it) != NULL; } \
- STC_INLINE cx_value_t* cx_memb(_get)(const Self* self, i_KEYRAW rkey) \
+ STC_INLINE cx_value_t* cx_memb(_get)(const Self* self, i_keyraw rkey) \
{cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it); } \
\
STC_INLINE Self \
@@ -111,33 +111,33 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; \
STC_INLINE cx_rawvalue_t \
cx_memb(_value_toraw)(cx_value_t* val) { \
- return cx_SET_ONLY( i_KEYTO(val) ) \
- cx_MAP_ONLY( c_make(cx_rawvalue_t){i_KEYTO(&val->first), i_VALTO(&val->second)} ); \
+ return cx_SET_ONLY( i_keyto(val) ) \
+ cx_MAP_ONLY( c_make(cx_rawvalue_t){i_keyto(&val->first), i_valto(&val->second)} ); \
} \
STC_INLINE void \
cx_memb(_value_del)(cx_value_t* val) { \
- i_KEYDEL(cx_keyref(val)); \
- cx_MAP_ONLY( i_VALDEL(&val->second); ) \
+ i_keydel(cx_keyref(val)); \
+ cx_MAP_ONLY( i_valdel(&val->second); ) \
} \
STC_INLINE void \
cx_memb(_value_clone)(cx_value_t* dst, cx_value_t* val) { \
- *cx_keyref(dst) = i_KEYFROM(i_KEYTO(cx_keyref(val))); \
- cx_MAP_ONLY( dst->second = i_VALFROM(i_VALTO(&val->second)); ) \
+ *cx_keyref(dst) = i_keyfrom(i_keyto(cx_keyref(val))); \
+ cx_MAP_ONLY( dst->second = i_valfrom(i_valto(&val->second)); ) \
} \
\
STC_INLINE cx_iter_t \
- cx_memb(_find)(const Self* self, i_KEYRAW rkey) { \
+ cx_memb(_find)(const Self* self, i_keyraw rkey) { \
cx_iter_t it; \
cx_memb(_find_it)(self, rkey, &it); \
return it; \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_emplace)(Self* self, i_KEYRAW rkey cx_MAP_ONLY(, i_VALRAW rmapped)) { \
+ cx_memb(_emplace)(Self* self, i_keyraw rkey cx_MAP_ONLY(, i_valraw rmapped)) { \
cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
if (res.inserted) { \
- *cx_keyref(res.ref) = i_KEYFROM(rkey); \
- cx_MAP_ONLY(res.ref->second = i_VALFROM(rmapped);) \
+ *cx_keyref(res.ref) = i_keyfrom(rkey); \
+ cx_MAP_ONLY(res.ref->second = i_valfrom(rmapped);) \
} \
return res; \
} \
@@ -149,37 +149,37 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; } \
\
STC_INLINE cx_result_t \
- cx_memb(_insert)(Self* self, i_KEY key cx_MAP_ONLY(, i_VAL mapped)) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_KEYTO(&key)); \
+ cx_memb(_insert)(Self* self, i_key key cx_MAP_ONLY(, i_val mapped)) { \
+ cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) {*cx_keyref(res.ref) = key; cx_MAP_ONLY( res.ref->second = mapped; )} \
- else {i_KEYDEL(&key); cx_MAP_ONLY( i_VALDEL(&mapped); )} \
+ else {i_keydel(&key); cx_MAP_ONLY( i_valdel(&mapped); )} \
return res; \
} \
\
cx_MAP_ONLY( \
STC_INLINE cx_result_t \
- cx_memb(_insert_or_assign)(Self* self, i_KEY key, i_VAL mapped) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_KEYTO(&key)); \
+ cx_memb(_insert_or_assign)(Self* self, i_key key, i_val mapped) { \
+ cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) res.ref->first = key; \
- else {i_KEYDEL(&key); i_VALDEL(&res.ref->second); } \
+ else {i_keydel(&key); i_valdel(&res.ref->second); } \
res.ref->second = mapped; return res; \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_put)(Self* self, i_KEY key, i_VAL mapped) { \
+ cx_memb(_put)(Self* self, i_key key, i_val mapped) { \
return cx_memb(_insert_or_assign)(self, key, mapped); \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_emplace_or_assign)(Self* self, i_KEYRAW rkey, i_VALRAW rmapped) { \
+ cx_memb(_emplace_or_assign)(Self* self, i_keyraw rkey, i_valraw rmapped) { \
cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
- if (res.inserted) res.ref->first = i_KEYFROM(rkey); \
- else i_VALDEL(&res.ref->second); \
- res.ref->second = i_VALFROM(rmapped); return res; \
+ if (res.inserted) res.ref->first = i_keyfrom(rkey); \
+ else i_valdel(&res.ref->second); \
+ res.ref->second = i_valfrom(rmapped); return res; \
} \
\
STC_INLINE cx_mapped_t* \
- cx_memb(_at)(const Self* self, i_KEYRAW rkey) { \
+ cx_memb(_at)(const Self* self, i_keyraw rkey) { \
cx_iter_t it; \
return &cx_memb(_find_it)(self, rkey, &it)->second; \
}) \
@@ -203,9 +203,9 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; return it; \
} \
\
- _c_implement_aatree(Self, C, i_KEY, i_VAL, i_CMP, \
- i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW, \
- i_KEYDEL, i_KEYFROM, i_KEYTO, i_KEYRAW) \
+ _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+ i_valdel, i_valfrom, i_valto, i_valraw, \
+ i_keydel, i_keyfrom, i_keyto, i_keyraw) \
struct stc_trailing_semicolon
/* -------------------------- IMPLEMENTATION ------------------------- */
@@ -213,9 +213,9 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0};
-#define _c_implement_aatree(Self, C, i_KEY, i_VAL, i_CMP, \
- i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW, \
- i_KEYDEL, i_KEYFROM, i_KEYTO, i_KEYRAW) \
+#define _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+ i_valdel, i_valfrom, i_valto, i_valraw, \
+ i_keydel, i_keyfrom, i_keyto, i_keyraw) \
STC_DEF Self \
cx_memb(_init)(void) { \
Self tree = {(cx_node_t *) _csmap_sentinel.nodes}; \
@@ -268,13 +268,13 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; } \
\
STC_DEF cx_value_t* \
- cx_memb(_find_it)(const Self* self, i_KEYRAW rkey, cx_iter_t* out) { \
+ cx_memb(_find_it)(const Self* self, i_keyraw rkey, cx_iter_t* out) { \
cx_memb(_size_t) tn = _csmap_rep(self)->root; \
cx_node_t *d = out->_d = self->nodes; \
out->_top = 0; \
while (tn) { \
- int c; cx_rawkey_t raw = i_KEYTO(cx_keyref(&d[tn].value)); \
- if ((c = i_CMP(&raw, &rkey)) < 0) \
+ int c; cx_rawkey_t raw = i_keyto(cx_keyref(&d[tn].value)); \
+ if ((c = i_cmp(&raw, &rkey)) < 0) \
tn = d[tn].link[1]; \
else if (c > 0) \
{ out->_st[out->_top++] = tn; tn = d[tn].link[0]; } \
@@ -285,7 +285,7 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; } \
\
STC_DEF cx_iter_t \
- cx_memb(_lower_bound)(const Self* self, i_KEYRAW rkey) { \
+ cx_memb(_lower_bound)(const Self* self, i_keyraw rkey) { \
cx_iter_t it; \
cx_memb(_find_it)(self, rkey, &it); \
if (!it.ref && it._top) { \
@@ -340,8 +340,8 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; int c, top = 0, dir = 0; \
while (tx) { \
up[top++] = tx; \
- i_KEYRAW raw = i_KEYTO(cx_keyref(&d[tx].value)); \
- if ((c = i_CMP(&raw, rkey)) == 0) {res->ref = &d[tx].value; return tn; } \
+ i_keyraw raw = i_keyto(cx_keyref(&d[tx].value)); \
+ if ((c = i_cmp(&raw, rkey)) == 0) {res->ref = &d[tx].value; return tn; } \
dir = (c < 0); \
tx = d[tx].link[dir]; \
} \
@@ -359,7 +359,7 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; } \
\
STC_DEF cx_result_t \
- cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey) { \
+ cx_memb(_insert_entry_)(Self* self, i_keyraw rkey) { \
cx_result_t res = {NULL, false}; \
cx_memb(_size_t) tn = cx_memb(_insert_entry_i_)(self, (cx_memb(_size_t)) _csmap_rep(self)->root, &rkey, &res); \
_csmap_rep(self)->root = tn; \
@@ -370,8 +370,8 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; STC_DEF cx_memb(_size_t) \
cx_memb(_erase_r_)(cx_node_t *d, cx_memb(_size_t) tn, const cx_rawkey_t* rkey, int *erased) { \
if (tn == 0) return 0; \
- i_KEYRAW raw = i_KEYTO(cx_keyref(&d[tn].value)); \
- cx_memb(_size_t) tx; int c = i_CMP(&raw, rkey); \
+ i_keyraw raw = i_keyto(cx_keyref(&d[tn].value)); \
+ cx_memb(_size_t) tx; int c = i_cmp(&raw, rkey); \
if (c != 0) \
d[tn].link[c < 0] = cx_memb(_erase_r_)(d, d[tn].link[c < 0], rkey, erased); \
else { \
@@ -381,7 +381,7 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; while (d[tx].link[1]) \
tx = d[tx].link[1]; \
d[tn].value = d[tx].value; /* move */ \
- raw = i_KEYTO(cx_keyref(&d[tn].value)); \
+ raw = i_keyto(cx_keyref(&d[tn].value)); \
d[tn].link[0] = cx_memb(_erase_r_)(d, d[tn].link[0], &raw, erased); \
} else { /* unlink node */ \
tx = tn; \
@@ -406,7 +406,7 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; } \
\
STC_DEF int \
- cx_memb(_erase)(Self* self, i_KEYRAW rkey) { \
+ cx_memb(_erase)(Self* self, i_keyraw rkey) { \
int erased = 0; \
cx_memb(_size_t) root = cx_memb(_erase_r_)(self->nodes, (cx_memb(_size_t)) _csmap_rep(self)->root, &rkey, &erased); \
return erased ? (_csmap_rep(self)->root = root, --_csmap_rep(self)->size, 1) : 0; \
@@ -414,9 +414,9 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; \
STC_DEF cx_iter_t \
cx_memb(_erase_at)(Self* self, cx_iter_t it) { \
- cx_rawkey_t raw = i_KEYTO(cx_keyref(it.ref)), nxt; \
+ cx_rawkey_t raw = i_keyto(cx_keyref(it.ref)), nxt; \
cx_memb(_next)(&it); \
- if (it.ref) nxt = i_KEYTO(cx_keyref(it.ref)); \
+ if (it.ref) nxt = i_keyto(cx_keyref(it.ref)); \
cx_memb(_erase)(self, raw); \
if (it.ref) cx_memb(_find_it)(self, nxt, &it); \
return it; \
@@ -427,12 +427,12 @@ static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0}; if (!it2.ref) { while (it1.ref) it1 = cx_memb(_erase_at)(self, it1); \
return it1; } \
cx_key_t k1 = *cx_keyref(it1.ref), k2 = *cx_keyref(it2.ref); \
- cx_rawkey_t r1 = i_KEYTO(&k1); \
+ cx_rawkey_t r1 = i_keyto(&k1); \
for (;;) { \
if (memcmp(&k1, &k2, sizeof k1) == 0) return it1; \
cx_memb(_next)(&it1); k1 = *cx_keyref(it1.ref); \
cx_memb(_erase)(self, r1); \
- cx_memb(_find_it)(self, (r1 = i_KEYTO(&k1)), &it1); \
+ cx_memb(_find_it)(self, (r1 = i_keyto(&k1)), &it1); \
} \
} \
\
diff --git a/include/stc/csmap_v1.h b/include/stc/csmap_v1.h index e5f35944..b9f443a8 100644 --- a/include/stc/csmap_v1.h +++ b/include/stc/csmap_v1.h @@ -64,21 +64,21 @@ int main(void) { }
#ifndef cx_forwarded
- _c_aatree_types(Self, C, i_KEY, i_VAL);
+ _c_aatree_types(Self, C, i_key, i_val);
#endif
_c_aatree_complete_types(Self, C); \
\
- typedef i_KEYRAW cx_rawkey_t; \
- typedef i_VALRAW cx_memb(_rawmapped_t); \
+ typedef i_keyraw cx_rawkey_t; \
+ typedef i_valraw cx_memb(_rawmapped_t); \
typedef cx_SET_ONLY( cx_rawkey_t ) \
cx_MAP_ONLY( struct { cx_rawkey_t first; \
cx_memb(_rawmapped_t) second; } ) \
cx_rawvalue_t; \
\
STC_API Self cx_memb(_init)(void); \
- STC_API cx_value_t* cx_memb(_find_it)(const Self* self, i_KEYRAW rkey, cx_iter_t* out); \
- STC_API cx_iter_t cx_memb(_lower_bound)(const Self* self, i_KEYRAW rkey); \
+ STC_API cx_value_t* cx_memb(_find_it)(const Self* self, i_keyraw rkey, cx_iter_t* out); \
+ STC_API cx_iter_t cx_memb(_lower_bound)(const Self* self, i_keyraw rkey); \
STC_API cx_value_t* cx_memb(_front)(const Self* self); \
STC_API cx_value_t* cx_memb(_back)(const Self* self); \
STC_API cx_iter_t cx_memb(_erase_at)(Self* self, cx_iter_t it); \
@@ -86,7 +86,7 @@ int main(void) { STC_API cx_node_t* cx_memb(_erase_r_)(cx_node_t *tn, const cx_rawkey_t* rkey, int *erased); \
STC_API void cx_memb(_del_r_)(cx_node_t* tn); \
STC_API cx_node_t* cx_memb(_clone_r_)(cx_node_t *tn); \
- STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey); \
+ STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_keyraw rkey); \
STC_API void cx_memb(_next)(cx_iter_t* it); \
\
STC_INLINE bool cx_memb(_empty)(Self cx) { return cx.size == 0; } \
@@ -95,31 +95,31 @@ int main(void) { STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); *self = cx_memb(_init)(); } \
STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); } \
STC_INLINE Self cx_memb(_clone)(Self cx) { return c_make(Self){ cx_memb(_clone_r_)(cx.root), cx.size}; } \
- STC_INLINE cx_iter_t cx_memb(_find)(const Self* self, i_KEYRAW rkey) \
+ STC_INLINE cx_iter_t cx_memb(_find)(const Self* self, i_keyraw rkey) \
{cx_iter_t it; cx_memb(_find_it)(self, rkey, &it); return it; } \
- STC_INLINE bool cx_memb(_contains)(const Self* self, i_KEYRAW rkey) \
+ STC_INLINE bool cx_memb(_contains)(const Self* self, i_keyraw rkey) \
{cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it) != NULL; } \
- STC_INLINE cx_value_t* cx_memb(_get)(const Self* self, i_KEYRAW rkey) \
+ STC_INLINE cx_value_t* cx_memb(_get)(const Self* self, i_keyraw rkey) \
{cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it); } \
\
STC_INLINE void \
cx_memb(_value_del)(cx_value_t* val) { \
- i_KEYDEL(cx_keyref(val)); \
- cx_MAP_ONLY( i_VALDEL(&val->second); ) \
+ i_keydel(cx_keyref(val)); \
+ cx_MAP_ONLY( i_valdel(&val->second); ) \
} \
\
STC_INLINE void \
cx_memb(_value_clone)(cx_value_t* dst, cx_value_t* val) { \
- *cx_keyref(dst) = i_KEYFROM(i_KEYTO(cx_keyref(val))); \
- cx_MAP_ONLY( dst->second = i_VALFROM(i_VALTO(&val->second)); ) \
+ *cx_keyref(dst) = i_keyfrom(i_keyto(cx_keyref(val))); \
+ cx_MAP_ONLY( dst->second = i_valfrom(i_valto(&val->second)); ) \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_emplace)(Self* self, i_KEYRAW rkey cx_MAP_ONLY(, i_VALRAW rmapped)) { \
+ cx_memb(_emplace)(Self* self, i_keyraw rkey cx_MAP_ONLY(, i_valraw rmapped)) { \
cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
if (res.inserted) { \
- *cx_keyref(res.ref) = i_KEYFROM(rkey); \
- cx_MAP_ONLY(res.ref->second = i_VALFROM(rmapped);) \
+ *cx_keyref(res.ref) = i_keyfrom(rkey); \
+ cx_MAP_ONLY(res.ref->second = i_valfrom(rmapped);) \
} \
return res; \
} \
@@ -131,37 +131,37 @@ int main(void) { } \
\
STC_INLINE cx_result_t \
- cx_memb(_insert)(Self* self, i_KEY key cx_MAP_ONLY(, i_VAL mapped)) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_KEYTO(&key)); \
+ cx_memb(_insert)(Self* self, i_key key cx_MAP_ONLY(, i_val mapped)) { \
+ cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) {*cx_keyref(res.ref) = key; cx_MAP_ONLY( res.ref->second = mapped; )} \
- else {i_KEYDEL(&key); cx_MAP_ONLY( i_VALDEL(&mapped); )} \
+ else {i_keydel(&key); cx_MAP_ONLY( i_valdel(&mapped); )} \
return res; \
} \
\
cx_MAP_ONLY( \
STC_INLINE cx_result_t \
- cx_memb(_insert_or_assign)(Self* self, i_KEY key, i_VAL mapped) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_KEYTO(&key)); \
+ cx_memb(_insert_or_assign)(Self* self, i_key key, i_val mapped) { \
+ cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) res.ref->first = key; \
- else {i_KEYDEL(&key); i_VALDEL(&res.ref->second); } \
+ else {i_keydel(&key); i_valdel(&res.ref->second); } \
res.ref->second = mapped; return res; \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_put)(Self* self, i_KEY key, i_VAL mapped) { \
+ cx_memb(_put)(Self* self, i_key key, i_val mapped) { \
return cx_memb(_insert_or_assign)(self, key, mapped); \
} \
\
STC_INLINE cx_result_t \
- cx_memb(_emplace_or_assign)(Self* self, i_KEYRAW rkey, i_VALRAW rmapped) { \
+ cx_memb(_emplace_or_assign)(Self* self, i_keyraw rkey, i_valraw rmapped) { \
cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
- if (res.inserted) res.ref->first = i_KEYFROM(rkey); \
- else i_VALDEL(&res.ref->second); \
- res.ref->second = i_VALFROM(rmapped); return res; \
+ if (res.inserted) res.ref->first = i_keyfrom(rkey); \
+ else i_valdel(&res.ref->second); \
+ res.ref->second = i_valfrom(rmapped); return res; \
} \
\
STC_INLINE cx_mapped_t* \
- cx_memb(_at)(const Self* self, i_KEYRAW rkey) { \
+ cx_memb(_at)(const Self* self, i_keyraw rkey) { \
cx_iter_t it; \
return &cx_memb(_find_it)(self, rkey, &it)->second; \
}) \
@@ -178,7 +178,7 @@ int main(void) { } \
\
STC_INLINE size_t \
- cx_memb(_erase)(Self* self, i_KEYRAW rkey) { \
+ cx_memb(_erase)(Self* self, i_keyraw rkey) { \
int erased = 0; \
self->root = cx_memb(_erase_r_)(self->root, &rkey, &erased); \
self->size -= erased; return erased; \
@@ -190,9 +190,9 @@ int main(void) { return it; \
} \
\
- _c_implement_aatree(Self, C, i_KEY, i_VAL, i_CMP, \
- i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW, \
- i_KEYDEL, i_KEYFROM, i_KEYTO, i_KEYRAW) \
+ _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+ i_valdel, i_valfrom, i_valto, i_valraw, \
+ i_keydel, i_keyfrom, i_keyto, i_keyraw) \
struct stc_trailing_semicolon
/* -------------------------- IMPLEMENTATION ------------------------- */
@@ -203,9 +203,9 @@ _c_aatree_types(csmap_SENTINEL, csmap_, int, int); _c_aatree_complete_types(csmap_SENTINEL, csmap_);
static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sentinel, 0};
-#define _c_implement_aatree(Self, C, i_KEY, i_VAL, i_CMP, \
- i_VALDEL, i_VALFROM, i_VALTO, i_VALRAW, \
- i_KEYDEL, i_KEYFROM, i_KEYTO, i_KEYRAW) \
+#define _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+ i_valdel, i_valfrom, i_valto, i_valraw, \
+ i_keydel, i_keyfrom, i_keyto, i_keyraw) \
STC_DEF Self \
cx_memb(_init)(void) { \
Self cx = {(cx_node_t *) &_aatree_sentinel, 0}; \
@@ -231,8 +231,8 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen cx_node_t *tn = self->root; \
out->_top = 0; \
while (tn->level) { \
- int c; cx_rawkey_t rx = i_KEYTO(cx_keyref(&tn->value)); \
- if ((c = i_CMP(&rx, &rkey)) < 0) tn = tn->link[1]; \
+ int c; cx_rawkey_t rx = i_keyto(cx_keyref(&tn->value)); \
+ if ((c = i_cmp(&rx, &rkey)) < 0) tn = tn->link[1]; \
else if (c > 0) {out->_st[out->_top++] = tn; tn = tn->link[0]; } \
else {out->_tn = tn->link[1]; return (out->ref = &tn->value); } \
} \
@@ -240,7 +240,7 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen } \
\
STC_DEF cx_iter_t \
- cx_memb(_lower_bound)(const Self* self, i_KEYRAW rkey) { \
+ cx_memb(_lower_bound)(const Self* self, i_keyraw rkey) { \
cx_iter_t it; \
cx_memb(_find_it)(self, rkey, &it); \
if (!it.ref && it._top) { \
@@ -295,8 +295,8 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen int c, top = 0, dir = 0; \
while (tx->level) { \
up[top++] = tx; \
- cx_rawkey_t r = i_KEYTO(cx_keyref(&tx->value)); \
- if (!(c = i_CMP(&r, rkey))) {res->ref = &tx->value; return tn; } \
+ cx_rawkey_t r = i_keyto(cx_keyref(&tx->value)); \
+ if (!(c = i_cmp(&r, rkey))) {res->ref = &tx->value; return tn; } \
tx = tx->link[(dir = (c < 0))]; \
} \
tn = c_new(cx_node_t); \
@@ -314,7 +314,7 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen } \
\
STC_DEF cx_result_t \
- cx_memb(_insert_entry_)(Self* self, i_KEYRAW rkey) { \
+ cx_memb(_insert_entry_)(Self* self, i_keyraw rkey) { \
cx_result_t res = {NULL, false}; \
self->root = cx_memb(_insert_entry_i_)(self->root, &rkey, &res); \
self->size += res.inserted; \
@@ -325,8 +325,8 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen cx_memb(_erase_r_)(cx_node_t *tn, const cx_rawkey_t* rkey, int *erased) { \
if (tn->level == 0) \
return tn; \
- cx_rawkey_t raw = i_KEYTO(cx_keyref(&tn->value)); \
- cx_node_t *tx; int c = i_CMP(&raw, rkey); \
+ cx_rawkey_t raw = i_keyto(cx_keyref(&tn->value)); \
+ cx_node_t *tx; int c = i_cmp(&raw, rkey); \
if (c != 0) \
tn->link[c < 0] = cx_memb(_erase_r_)(tn->link[c < 0], rkey, erased); \
else { \
@@ -336,7 +336,7 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen while (tx->link[1]->level) \
tx = tx->link[1]; \
tn->value = tx->value; \
- raw = i_KEYTO(cx_keyref(&tn->value)); \
+ raw = i_keyto(cx_keyref(&tn->value)); \
tn->link[0] = cx_memb(_erase_r_)(tn->link[0], &raw, erased); \
} else { \
tx = tn; \
@@ -357,9 +357,9 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen } \
STC_DEF cx_iter_t \
cx_memb(_erase_at)(Self* self, cx_iter_t it) { \
- cx_rawkey_t raw = i_KEYTO(cx_keyref(it.ref)), nxt; \
+ cx_rawkey_t raw = i_keyto(cx_keyref(it.ref)), nxt; \
cx_memb(_next)(&it); \
- if (it.ref) nxt = i_KEYTO(cx_keyref(it.ref)); \
+ if (it.ref) nxt = i_keyto(cx_keyref(it.ref)); \
cx_memb(_erase)(self, raw); \
if (it.ref) cx_memb(_find_it)(self, nxt, &it); \
return it; \
@@ -370,12 +370,12 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen if (!it2.ref) { while (it1.ref) it1 = cx_memb(_erase_at)(self, it1); \
return it1; } \
cx_key_t k1 = *cx_keyref(it1.ref), k2 = *cx_keyref(it2.ref); \
- cx_rawkey_t r1 = i_KEYTO(&k1); \
+ cx_rawkey_t r1 = i_keyto(&k1); \
for (;;) { \
if (memcmp(&k1, &k2, sizeof k1) == 0) return it1; \
cx_memb(_next)(&it1); k1 = *cx_keyref(it1.ref); \
cx_memb(_erase)(self, r1); \
- cx_memb(_find_it)(self, (r1 = i_KEYTO(&k1)), &it1); \
+ cx_memb(_find_it)(self, (r1 = i_keyto(&k1)), &it1); \
} \
} \
\
diff --git a/include/stc/csptr.h b/include/stc/csptr.h index 1729235e..e7dd2485 100644 --- a/include/stc/csptr.h +++ b/include/stc/csptr.h @@ -68,11 +68,11 @@ typedef long atomic_count_t; }
#endif
-#define forward_csptr(X, i_VAL) _csptr_types(csptr_##X, i_VAL)
+#define forward_csptr(X, i_val) _csptr_types(csptr_##X, i_val)
#define csptr_null {NULL, NULL}
- defTypes( _csptr_types(Self, i_VAL); ) \
+ defTypes( _csptr_types(Self, i_val); ) \
struct cx_memb(_rep_) {atomic_count_t cnt; cx_value_t val; }; \
\
STC_INLINE Self \
@@ -112,7 +112,7 @@ typedef long atomic_count_t; STC_INLINE void \
cx_memb(_del)(Self* self) { \
if (self->use_count && c_atomic_decrement(self->use_count) == 0) { \
- i_VALDEL(self->get); \
+ i_valdel(self->get); \
if (self->get != &((struct cx_memb(_rep_)*)self->use_count)->val) c_free(self->get); \
c_free(self->use_count); \
} \
@@ -148,12 +148,12 @@ typedef long atomic_count_t; \
STC_INLINE int \
cx_memb(_compare)(const Self* x, const Self* y) { \
- return i_CMP(x->get, y->get); \
+ return i_cmp(x->get, y->get); \
} \
\
STC_INLINE bool \
cx_memb(_equals)(const Self* x, const Self* y) { \
- return i_CMP(x->get, y->get) == 0; \
+ return i_cmp(x->get, y->get) == 0; \
} \
struct stc_trailing_semicolon
diff --git a/include/stc/csset.h b/include/stc/csset.h index a5e1499c..f275cbfd 100644 --- a/include/stc/csset.h +++ b/include/stc/csset.h @@ -43,7 +43,7 @@ int main(void) { }
*/
-#define i_CNT csset
+#define i_cnt csset
#define KEY_REF_csset(vp) (vp)
#include "csmap.h"
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index b79116cb..b79191f9 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -32,14 +32,14 @@ struct MyStruct { cstr name;
} typedef MyStruct;
-#define i_VAL float
+#define i_val float
#include <stc/cvec.h>
-#define i_VAL_str // special for cstr
+#define i_val_str // special for cstr
#include <stc/cvec.h>
-#define f_TAG i32 // f: forward declared above; shorthand for i_FWD
-#define i_VAL int
+#define f_tag i32 // f: forward declared above; shorthand for i_fwd
+#define i_val int
#include <stc/cvec.h>
int main() {
@@ -67,24 +67,24 @@ struct cvec_Rep_ { size_t size, cap; void* data[]; }; #define cvec_rep_(self) c_container_of((self)->data, struct cvec_Rep_, data)
#endif // CVEC_H_INCLUDED
-#define i_MODULE cvec
+#define i_module cvec
#include "template.h"
-#if !defined i_FWD
- cx_deftypes(_c_cvec_types, Self, i_VAL);
+#if !defined i_fwd
+ cx_deftypes(_c_cvec_types, Self, i_val);
#endif
-typedef i_VALRAW cx_rawvalue_t;
+typedef i_valraw cx_rawvalue_t;
STC_API Self cx_memb(_init)(void);
STC_API Self cx_memb(_clone)(Self cx);
STC_API void cx_memb(_del)(Self* self);
STC_API void cx_memb(_clear)(Self* self);
STC_API void cx_memb(_reserve)(Self* self, size_t cap);
-STC_API void cx_memb(_resize)(Self* self, size_t size, i_VAL fill_val);
+STC_API void cx_memb(_resize)(Self* self, size_t size, i_val fill_val);
STC_API int cx_memb(_value_compare)(const cx_value_t* x, const cx_value_t* y);
-STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW raw);
-STC_API cx_iter_t cx_memb(_bsearch_in)(cx_iter_t it1, cx_iter_t it2, i_VALRAW raw);
-STC_API void cx_memb(_push_back)(Self* self, i_VAL value);
+STC_API cx_iter_t cx_memb(_find_in)(cx_iter_t it1, cx_iter_t it2, i_valraw raw);
+STC_API cx_iter_t cx_memb(_bsearch_in)(cx_iter_t it1, cx_iter_t it2, i_valraw raw);
+STC_API void cx_memb(_push_back)(Self* self, i_val value);
STC_API cx_iter_t cx_memb(_erase_range_p)(Self* self, cx_value_t* p1, cx_value_t* p2);
STC_API cx_iter_t cx_memb(_insert_range_p)(Self* self, cx_value_t* pos,
const cx_value_t* p1, const cx_value_t* p2, bool clone);
@@ -94,18 +94,18 @@ STC_API cx_iter_t cx_memb(_emplace_range_p)(Self* self, cx_value_t* pos, STC_INLINE size_t cx_memb(_size)(Self cx) { return cvec_rep_(&cx)->size; }
STC_INLINE size_t cx_memb(_capacity)(Self cx) { return cvec_rep_(&cx)->cap; }
STC_INLINE bool cx_memb(_empty)(Self cx) { return !cvec_rep_(&cx)->size; }
-STC_INLINE i_VAL cx_memb(_value_fromraw)(i_VALRAW raw) { return i_VALFROM(raw); }
-STC_INLINE i_VALRAW cx_memb(_value_toraw)(cx_value_t* val) { return i_VALTO(val); }
-STC_INLINE i_VAL cx_memb(_value_clone)(cx_value_t val)
- { return i_VALFROM(i_VALTO(&val)); }
+STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); }
+STC_INLINE i_valraw cx_memb(_value_toraw)(cx_value_t* val) { return i_valto(val); }
+STC_INLINE i_val cx_memb(_value_clone)(cx_value_t val)
+ { return i_valfrom(i_valto(&val)); }
STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); }
STC_INLINE cx_value_t* cx_memb(_front)(const Self* self) { return self->data; }
STC_INLINE cx_value_t* cx_memb(_back)(const Self* self)
{ return self->data + cvec_rep_(self)->size - 1; }
-STC_INLINE void cx_memb(_emplace_back)(Self* self, i_VALRAW raw)
- { cx_memb(_push_back)(self, i_VALFROM(raw)); }
+STC_INLINE void cx_memb(_emplace_back)(Self* self, i_valraw raw)
+ { cx_memb(_push_back)(self, i_valfrom(raw)); }
STC_INLINE void cx_memb(_pop_back)(Self* self)
- { i_VALDEL(&self->data[--cvec_rep_(self)->size]); }
+ { i_valdel(&self->data[--cvec_rep_(self)->size]); }
STC_INLINE cx_iter_t cx_memb(_begin)(const Self* self)
{ return c_make(cx_iter_t){self->data}; }
STC_INLINE cx_iter_t cx_memb(_end)(const Self* self)
@@ -115,7 +115,7 @@ STC_INLINE cx_iter_t cx_memb(_adv)(cx_iter_t it, intptr_t offs) {it.ref += of STC_INLINE size_t cx_memb(_idx)(Self cx, cx_iter_t it) { return it.ref - cx.data; }
STC_INLINE Self
-cx_memb(_with_size)(size_t size, i_VAL null_val) {
+cx_memb(_with_size)(size_t size, i_val null_val) {
Self cx = cx_memb(_init)();
cx_memb(_resize)(&cx, size, null_val);
return cx;
@@ -135,7 +135,7 @@ cx_memb(_shrink_to_fit)(Self *self) { }
STC_INLINE cx_iter_t
-cx_memb(_insert)(Self* self, size_t idx, i_VAL value) {
+cx_memb(_insert)(Self* self, size_t idx, i_val value) {
return cx_memb(_insert_range_p)(self, self->data + idx, &value, &value + 1, false);
}
STC_INLINE cx_iter_t
@@ -143,12 +143,12 @@ cx_memb(_insert_n)(Self* self, size_t idx, const cx_value_t arr[], size_t n) { return cx_memb(_insert_range_p)(self, self->data + idx, arr, arr + n, false);
}
STC_INLINE cx_iter_t
-cx_memb(_insert_at)(Self* self, cx_iter_t it, i_VAL value) {
+cx_memb(_insert_at)(Self* self, cx_iter_t it, i_val value) {
return cx_memb(_insert_range_p)(self, it.ref, &value, &value + 1, false);
}
STC_INLINE cx_iter_t
-cx_memb(_emplace)(Self* self, size_t idx, i_VALRAW raw) {
+cx_memb(_emplace)(Self* self, size_t idx, i_valraw raw) {
return cx_memb(_emplace_range_p)(self, self->data + idx, &raw, &raw + 1);
}
STC_INLINE cx_iter_t
@@ -156,7 +156,7 @@ cx_memb(_emplace_n)(Self* self, size_t idx, const cx_rawvalue_t arr[], size_t n) return cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n);
}
STC_INLINE cx_iter_t
-cx_memb(_emplace_at)(Self* self, cx_iter_t it, i_VALRAW raw) {
+cx_memb(_emplace_at)(Self* self, cx_iter_t it, i_valraw raw) {
return cx_memb(_emplace_range_p)(self, it.ref, &raw, &raw + 1);
}
STC_INLINE cx_iter_t
@@ -192,19 +192,19 @@ cx_memb(_at)(const Self* self, size_t idx) { }
STC_INLINE cx_iter_t
-cx_memb(_find)(const Self* self, i_VALRAW raw) {
+cx_memb(_find)(const Self* self, i_valraw raw) {
return cx_memb(_find_in)(cx_memb(_begin)(self), cx_memb(_end)(self), raw);
}
STC_INLINE cx_value_t*
-cx_memb(_get)(const Self* self, i_VALRAW raw) {
+cx_memb(_get)(const Self* self, i_valraw raw) {
cx_iter_t end = cx_memb(_end)(self);
cx_value_t* val = cx_memb(_find_in)(cx_memb(_begin)(self), end, raw).ref;
return val == end.ref ? NULL : val;
}
STC_INLINE cx_iter_t
-cx_memb(_bsearch)(const Self* self, i_VALRAW raw) {
+cx_memb(_bsearch)(const Self* self, i_valraw raw) {
return cx_memb(_bsearch_in)(cx_memb(_begin)(self), cx_memb(_end)(self), raw);
}
STC_INLINE void
@@ -219,7 +219,7 @@ cx_memb(_sort)(Self* self) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_IMP)
+#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
#ifndef CVEC_H_INCLUDED
#define CVEC_H_INCLUDED
@@ -236,7 +236,7 @@ STC_DEF void cx_memb(_clear)(Self* self) {
struct cvec_Rep_* rep = cvec_rep_(self); if (rep->cap) {
for (cx_value_t *p = self->data, *q = p + rep->size; p != q; ++p)
- i_VALDEL(p);
+ i_valdel(p);
rep->size = 0;
}
}
@@ -254,7 +254,7 @@ cx_memb(_reserve)(Self* self, size_t cap) { size_t len = rep->size, oldcap = rep->cap;
if (cap > oldcap) {
rep = (struct cvec_Rep_*) c_realloc(oldcap ? rep : NULL,
- offsetof(struct cvec_Rep_, data) + cap*sizeof(i_VAL));
+ offsetof(struct cvec_Rep_, data) + cap*sizeof(i_val));
self->data = (cx_value_t*) rep->data;
rep->size = len;
rep->cap = cap;
@@ -262,17 +262,17 @@ cx_memb(_reserve)(Self* self, size_t cap) { }
STC_DEF void
-cx_memb(_resize)(Self* self, size_t len, i_VAL null_val) {
+cx_memb(_resize)(Self* self, size_t len, i_val null_val) {
cx_memb(_reserve)(self, len);
struct cvec_Rep_* rep = cvec_rep_(self);
size_t i, n = rep->size;
- for (i = len; i < n; ++i) i_VALDEL(self->data + i);
+ for (i = len; i < n; ++i) i_valdel(self->data + i);
for (i = n; i < len; ++i) self->data[i] = null_val;
if (rep->cap) rep->size = len;
}
STC_DEF void
-cx_memb(_push_back)(Self* self, i_VAL value) {
+cx_memb(_push_back)(Self* self, i_val value) {
size_t len = cvec_rep_(self)->size;
if (len == cx_memb(_capacity)(*self))
cx_memb(_reserve)(self, (len*13 >> 3) + 4);
@@ -295,7 +295,7 @@ cx_memb(_insert_space_)(Self* self, cx_value_t* pos, size_t len) { cx_memb(_reserve)(self, (size*13 >> 3) + len),
pos = self->data + idx;
cvec_rep_(self)->size += len;
- memmove(pos + len, pos, (size - idx) * sizeof(i_VAL));
+ memmove(pos + len, pos, (size - idx) * sizeof(i_val));
return pos;
}
@@ -304,7 +304,7 @@ cx_memb(_insert_range_p)(Self* self, cx_value_t* pos, const cx_value_t* p1, const cx_value_t* p2, bool clone) {
pos = cx_memb(_insert_space_)(self, pos, p2 - p1);
cx_iter_t it = {pos};
- if (clone) while (p1 != p2) *pos++ = i_VALFROM(i_VALTO(p1++));
+ if (clone) while (p1 != p2) *pos++ = i_valfrom(i_valto(p1++));
else memcpy(pos, p1, (p2 - p1)*sizeof *p1);
return it;
}
@@ -314,7 +314,7 @@ cx_memb(_emplace_range_p)(Self* self, cx_value_t* pos, const cx_rawvalue_t* p1, const cx_rawvalue_t* p2) {
pos = cx_memb(_insert_space_)(self, pos, p2 - p1);
cx_iter_t it = {pos};
- while (p1 != p2) *pos++ = i_VALFROM(*p1++);
+ while (p1 != p2) *pos++ = i_valfrom(*p1++);
return it;
}
@@ -323,29 +323,29 @@ cx_memb(_erase_range_p)(Self* self, cx_value_t* p1, cx_value_t* p2) { intptr_t len = p2 - p1;
if (len > 0) {
cx_value_t* p = p1, *end = self->data + cvec_rep_(self)->size;
- while (p != p2) i_VALDEL(p++);
- memmove(p1, p2, (end - p2) * sizeof(i_VAL));
+ while (p != p2) i_valdel(p++);
+ memmove(p1, p2, (end - p2) * sizeof(i_val));
cvec_rep_(self)->size -= len;
}
return c_make(cx_iter_t){.ref = p1};
}
STC_DEF cx_iter_t
-cx_memb(_find_in)(cx_iter_t i1, cx_iter_t i2, i_VALRAW raw) {
+cx_memb(_find_in)(cx_iter_t i1, cx_iter_t i2, i_valraw raw) {
for (; i1.ref != i2.ref; ++i1.ref) {
- i_VALRAW r = i_VALTO(i1.ref);
- if (i_CMP(&raw, &r) == 0) return i1;
+ i_valraw r = i_valto(i1.ref);
+ if (i_cmp(&raw, &r) == 0) return i1;
}
return i2;
}
STC_DEF cx_iter_t
-cx_memb(_bsearch_in)(cx_iter_t i1, cx_iter_t i2, i_VALRAW raw) {
+cx_memb(_bsearch_in)(cx_iter_t i1, cx_iter_t i2, i_valraw raw) {
cx_iter_t mid, last = i2;
while (i1.ref != i2.ref) {
mid.ref = i1.ref + ((i2.ref - i1.ref)>>1);
- int c; i_VALRAW m = i_VALTO(mid.ref);
- if ((c = i_CMP(&raw, &m)) == 0) return mid;
+ int c; i_valraw m = i_valto(mid.ref);
+ if ((c = i_cmp(&raw, &m)) == 0) return mid;
else if (c < 0) i2.ref = mid.ref;
else i1.ref = mid.ref + 1;
}
@@ -354,9 +354,9 @@ cx_memb(_bsearch_in)(cx_iter_t i1, cx_iter_t i2, i_VALRAW raw) { STC_DEF int
cx_memb(_value_compare)(const cx_value_t* x, const cx_value_t* y) {
- i_VALRAW rx = i_VALTO(x);
- i_VALRAW ry = i_VALTO(y);
- return i_CMP(&rx, &ry);
+ i_valraw rx = i_valto(x);
+ i_valraw ry = i_valto(y);
+ return i_cmp(&rx, &ry);
}
#endif
diff --git a/include/stc/template.h b/include/stc/template.h index 0aabed0b..cfa53a5c 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -20,13 +20,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef i_TEMPLATE
-#define i_TEMPLATE
+#ifndef i_template
+#define i_template
#ifndef STC_TEMPLATE_H_INCLUDED
#define STC_TEMPLATE_H_INCLUDED
#define cx_memb(name) c_PASTE(Self, name)
- #define Self c_PASTE3(i_MODULE, _, i_TAG)
+ #define Self c_PASTE3(i_module, _, i_tag)
// typedef container types defined in forward.h
#define cx_deftypes(macro, SELF, ...) macro(SELF, __VA_ARGS__)
@@ -41,112 +41,112 @@ #define cx_node_t cx_memb(_node_t)
#endif
-#if defined f_TAG
- #define i_TAG f_TAG
- #define i_FWD
+#if defined f_tag
+ #define i_tag f_tag
+ #define i_fwd
#endif
-#if defined i_KEY_str
- #define i_KEY cstr
- #define i_CMP c_rawstr_compare
- #define i_EQU c_rawstr_equals
- #define i_HASH c_rawstr_hash
- #define i_KEYDEL cstr_del
- #define i_KEYFROM cstr_from
- #define i_KEYTO cstr_str
- #define i_KEYRAW const char*
+#if defined i_key_str
+ #define i_key cstr
+ #define i_cmp c_rawstr_compare
+ #define i_equ c_rawstr_equals
+ #define i_hash c_rawstr_hash
+ #define i_keydel cstr_del
+ #define i_keyfrom cstr_from
+ #define i_keyto cstr_str
+ #define i_keyraw const char*
#endif
-#if defined i_VAL_str
- #define i_VAL cstr
- #ifndef i_KEY
- #define i_CMP c_rawstr_compare
+#if defined i_val_str
+ #define i_val cstr
+ #ifndef i_key
+ #define i_cmp c_rawstr_compare
#endif
- #define i_VALDEL cstr_del
- #define i_VALFROM cstr_from
- #define i_VALTO cstr_str
- #define i_VALRAW const char*
+ #define i_valdel cstr_del
+ #define i_valfrom cstr_from
+ #define i_valto cstr_str
+ #define i_valraw const char*
#endif
-#if defined i_KEY && !defined i_VAL
- #define i_VAL i_KEY
+#if defined i_key && !defined i_val
+ #define i_val i_key
#endif
-#if !defined i_TAG && defined i_KEY_str
- #define i_TAG str
-#elif !defined i_TAG && defined i_KEY
- #define i_TAG i_KEY
-#elif !defined i_TAG && defined i_VAL_str
- #define i_TAG str
-#elif !defined i_TAG && defined i_VAL
- #define i_TAG i_VAL
+#if !defined i_tag && defined i_key_str
+ #define i_tag str
+#elif !defined i_tag && defined i_key
+ #define i_tag i_key
+#elif !defined i_tag && defined i_val_str
+ #define i_tag str
+#elif !defined i_tag && defined i_val
+ #define i_tag i_val
#endif
-#if (defined i_VALTO ^ defined i_VALRAW) || (defined i_VALRAW && !defined i_VALFROM)
- #error if i_VALRAW defined, both i_VALFROM and i_VALTO must be defined
+#if (defined i_valto ^ defined i_valraw) || (defined i_valraw && !defined i_valfrom)
+ #error if i_valraw defined, both i_valfrom and i_valto must be defined
#endif
-#if (defined i_KEYTO ^ defined i_KEYRAW) || (defined i_KEYRAW && !defined i_KEYFROM)
- #error if i_KEYRAW defined, both i_KEYFROM and i_KEYTO must be defined
+#if (defined i_keyto ^ defined i_keyraw) || (defined i_keyraw && !defined i_keyfrom)
+ #error if i_keyraw defined, both i_keyfrom and i_keyto must be defined
#endif
-#if defined i_KEY
- #if !defined i_KEYFROM && defined i_KEYDEL
- #define i_KEYFROM c_no_clone
- #elif !defined i_KEYFROM
- #define i_KEYFROM c_default_fromraw
+#if defined i_key
+ #if !defined i_keyfrom && defined i_keydel
+ #define i_keyfrom c_no_clone
+ #elif !defined i_keyfrom
+ #define i_keyfrom c_default_fromraw
#endif
- #ifndef i_KEYRAW
- #define i_KEYRAW i_KEY
- #define i_KEYTO c_default_toraw
+ #ifndef i_keyraw
+ #define i_keyraw i_key
+ #define i_keyto c_default_toraw
#endif
- #if !defined i_EQU && defined i_CMP
- #define i_EQU !i_CMP
- #elif !defined i_EQU
- #define i_EQU c_default_equals
+ #if !defined i_equ && defined i_cmp
+ #define i_equ !i_cmp
+ #elif !defined i_equ
+ #define i_equ c_default_equals
#endif
- #ifndef i_HASH
- #define i_HASH c_default_hash
+ #ifndef i_hash
+ #define i_hash c_default_hash
#endif
#endif
-#if !defined i_VALFROM && defined i_VALDEL
- #define i_VALFROM c_no_clone
-#elif !defined i_VALFROM
- #define i_VALFROM c_default_fromraw
+#if !defined i_valfrom && defined i_valdel
+ #define i_valfrom c_no_clone
+#elif !defined i_valfrom
+ #define i_valfrom c_default_fromraw
#endif
-#ifndef i_VALRAW
- #define i_VALRAW i_VAL
- #define i_VALTO c_default_toraw
+#ifndef i_valraw
+ #define i_valraw i_val
+ #define i_valto c_default_toraw
#endif
-#ifndef i_KEYDEL
- #define i_KEYDEL c_default_del
+#ifndef i_keydel
+ #define i_keydel c_default_del
#endif
-#ifndef i_VALDEL
- #define i_VALDEL c_default_del
+#ifndef i_valdel
+ #define i_valdel c_default_del
#endif
-#ifndef i_CMP
- #define i_CMP c_default_compare
+#ifndef i_cmp
+ #define i_cmp c_default_compare
#endif
#else // -------------------------------------------------------
-#undef i_MODULE
-#undef i_TAG
-#undef f_TAG
-#undef i_IMP
-#undef i_FWD
-#undef i_CMP
-#undef i_EQU
-#undef i_HASH
-#undef i_VAL
-#undef i_VAL_str
-#undef i_VALDEL
-#undef i_VALFROM
-#undef i_VALTO
-#undef i_VALRAW
-#undef i_KEY
-#undef i_KEY_str
-#undef i_KEYDEL
-#undef i_KEYFROM
-#undef i_KEYTO
-#undef i_KEYRAW
+#undef i_module
+#undef i_tag
+#undef f_tag
+#undef i_imp
+#undef i_fwd
+#undef i_cmp
+#undef i_equ
+#undef i_hash
+#undef i_val
+#undef i_val_str
+#undef i_valdel
+#undef i_valfrom
+#undef i_valto
+#undef i_valraw
+#undef i_key
+#undef i_key_str
+#undef i_keydel
+#undef i_keyfrom
+#undef i_keyto
+#undef i_keyraw
-#undef i_TEMPLATE
+#undef i_template
#endif
diff --git a/include/stc/test_new_list.c b/include/stc/test_new_list.c index 83f6107c..764146b3 100644 --- a/include/stc/test_new_list.c +++ b/include/stc/test_new_list.c @@ -10,8 +10,8 @@ struct MyStruct { } typedef MyStruct; -#define f_TAG i32 -#define i_VAL int +#define f_tag i32 +#define i_val int #include "clist.h" struct Point { int x, y; } typedef Point; @@ -19,15 +19,15 @@ int point_compare(const Point* a, const Point* b) { int c = c_default_compare(&a->x, &b->x); return c ? c : c_default_compare(&a->y, &b->y); } -#define f_TAG pnt -#define i_VAL Point -#define i_CMP point_compare +#define f_tag pnt +#define i_val Point +#define i_cmp point_compare #include "clist.h" -#define i_VAL float +#define i_val float #include "clist.h" -#define i_VAL_str +#define i_val_str #include "clist.h" diff --git a/include/stc/test_new_map.c b/include/stc/test_new_map.c index 5dfca14e..b59bd145 100644 --- a/include/stc/test_new_map.c +++ b/include/stc/test_new_map.c @@ -9,8 +9,8 @@ struct MyStruct { } typedef MyStruct;
-#define i_KEY int
-#define i_VAL int
+#define i_key int
+#define i_val int
#include "cmap.h"
struct Point { int x, y; } typedef Point;
@@ -18,17 +18,17 @@ int point_compare(const Point* a, const Point* b) { int c = c_default_compare(&a->x, &b->x);
return c ? c : c_default_compare(&a->y, &b->y);
}
-#define f_TAG pnt // f=forward declared
-#define i_KEY Point
-#define i_VAL int
-#define i_CMP point_compare
+#define f_tag pnt // f=forward declared
+#define i_key Point
+#define i_val int
+#define i_cmp point_compare
#include "cmap.h"
-#define i_KEY_str
-#define i_VAL_str
+#define i_key_str
+#define i_val_str
#include "cmap.h"
-#define i_KEY_str
+#define i_key_str
#include "cset.h"
diff --git a/include/stc/test_new_vec.c b/include/stc/test_new_vec.c index c64f633c..3cc770da 100644 --- a/include/stc/test_new_vec.c +++ b/include/stc/test_new_vec.c @@ -10,8 +10,8 @@ struct MyStruct { } typedef MyStruct;
-#define f_TAG i32
-#define i_VAL int
+#define f_tag i32
+#define i_val int
#include "cvec.h"
struct Point { int x, y; } typedef Point;
@@ -19,15 +19,15 @@ int point_compare(const Point* a, const Point* b) { int c = c_default_compare(&a->x, &b->x);
return c ? c : c_default_compare(&a->y, &b->y);
}
-#define f_TAG pnt
-#define i_VAL Point
-#define i_CMP point_compare
+#define f_tag pnt
+#define i_val Point
+#define i_cmp point_compare
#include "cvec.h"
-#define i_VAL float
+#define i_val float
#include "cvec.h"
-#define i_VAL_str
+#define i_val_str
#include "cvec.h"
|
