diff options
| author | Tyge Løvset <[email protected]> | 2023-01-23 17:15:20 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-23 17:15:20 +0100 |
| commit | c2d862f377f9bf2f276db7ba41ea835117603881 (patch) | |
| tree | df957689e114b7b80df69a2f67a9eca3e866915e /include/stc | |
| parent | d23fb483c4fc98a68eb9cdb0d544002c26accb0a (diff) | |
| download | STC-modified-c2d862f377f9bf2f276db7ba41ea835117603881.tar.gz STC-modified-c2d862f377f9bf2f276db7ba41ea835117603881.zip | |
Changed c_OVERLOADMACRO() internally.
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/algo/crange.h | 6 | ||||
| -rw-r--r-- | include/stc/algo/filter.h | 4 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 42 | ||||
| -rw-r--r-- | include/stc/cspan.h | 10 | ||||
| -rw-r--r-- | include/stc/csview.h | 6 |
5 files changed, 34 insertions, 34 deletions
diff --git a/include/stc/algo/crange.h b/include/stc/algo/crange.h index 5e1610d9..39236ae0 100644 --- a/include/stc/algo/crange.h +++ b/include/stc/algo/crange.h @@ -54,10 +54,10 @@ typedef struct { crange_value start, end, step, value; } crange; typedef struct { crange_value *ref, end, step; } crange_iter; #define crange_make(...) c_MACRO_OVERLOAD(crange_make, __VA_ARGS__) -#define crange_make1(stop) crange_make3(0, stop, 1) -#define crange_make2(start, stop) crange_make3(start, stop, 1) +#define crange_make_1(stop) crange_make_3(0, stop, 1) +#define crange_make_2(start, stop) crange_make_3(start, stop, 1) -STC_INLINE crange crange_make3(crange_value start, crange_value stop, crange_value step) +STC_INLINE crange crange_make_3(crange_value start, crange_value stop, crange_value step) { crange r = {start, stop - (step > 0), step}; return r; } STC_INLINE crange_iter crange_begin(crange* self) diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h index 0f850f41..9037c984 100644 --- a/include/stc/algo/filter.h +++ b/include/stc/algo/filter.h @@ -61,10 +61,10 @@ int main() #define c_FORFILTER(...) c_MACRO_OVERLOAD(c_FORFILTER, __VA_ARGS__) -#define c_FORFILTER4(i, C, cnt, filter) \ +#define c_FORFILTER_4(i, C, cnt, filter) \ c_FORFILTER_B(i, C, C##_begin(&cnt), filter) -#define c_FORFILTER5(i, C, cnt, filter, cond) \ +#define c_FORFILTER_5(i, C, cnt, filter, cond) \ c_FORFILTER_B(i, C, C##_begin(&cnt), filter) if (!(cond)) break; else #define c_FORFILTER_B(i, C, start, filter) \ diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 286450ec..9315dd99 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -56,7 +56,7 @@ /* Macro overloading feature support based on: https://rextester.com/ONP80107 */ #define c_MACRO_OVERLOAD(name, ...) \ - c_PASTE(name, c_NUMARGS(__VA_ARGS__))(__VA_ARGS__) + c_PASTE(c_CONCAT(name, _), c_NUMARGS(__VA_ARGS__))(__VA_ARGS__) #define c_CONCAT(a, b) a ## b #define c_PASTE(a, b) c_CONCAT(a, b) #define c_EXPAND(...) __VA_ARGS__ @@ -124,8 +124,8 @@ typedef const char* crawstr; #define c_ARRAYLEN(a) (sizeof(a)/sizeof 0[a]) #define c_SV(...) c_MACRO_OVERLOAD(c_SV, __VA_ARGS__) -#define c_SV1(lit) c_SV2(lit, crawstr_len(lit)) -#define c_SV2(str, n) (c_COMPOUND(csview){str, n}) +#define c_SV_1(lit) c_SV_2(lit, crawstr_len(lit)) +#define c_SV_2(str, n) (c_COMPOUND(csview){str, n}) #define c_ARGSV(sv) (int)(sv).size, (sv).str /* use with "%.*s" */ #define c_PAIR(ref) (ref)->first, (ref)->second @@ -168,9 +168,9 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle, /* Control block macros */ #define c_FOREACH(...) c_MACRO_OVERLOAD(c_FOREACH, __VA_ARGS__) -#define c_FOREACH3(it, C, cnt) \ +#define c_FOREACH_3(it, C, cnt) \ for (C##_iter it = C##_begin(&cnt); it.ref; C##_next(&it)) -#define c_FOREACH4(it, C, start, finish) \ +#define c_FOREACH_4(it, C, start, finish) \ for (C##_iter it = start, *_endref = (C##_iter*)(finish).ref \ ; it.ref != (C##_value*)_endref; C##_next(&it)) @@ -185,11 +185,11 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle, ; C##_next(&_.it)) #define c_FORRANGE(...) c_MACRO_OVERLOAD(c_FORRANGE, __VA_ARGS__) -#define c_FORRANGE1(stop) c_FORRANGE3(_c_i, 0, stop) -#define c_FORRANGE2(i, stop) c_FORRANGE3(i, 0, stop) -#define c_FORRANGE3(i, start, stop) \ +#define c_FORRANGE_1(stop) c_FORRANGE_3(_c_i, 0, stop) +#define c_FORRANGE_2(i, stop) c_FORRANGE_3(i, 0, stop) +#define c_FORRANGE_3(i, start, stop) \ for (long long i=start, _end=(long long)(stop); i < _end; ++i) -#define c_FORRANGE4(i, start, stop, step) \ +#define c_FORRANGE_4(i, start, stop, step) \ for (long long i=start, _inc=step, _end=(long long)(stop) - (_inc > 0) \ ; (_inc > 0) ^ (i > _end); i += _inc) #ifndef __cplusplus @@ -205,34 +205,34 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle, ; it.index < it.size; ++it.ref, ++it.index) #endif #define c_WITH(...) c_MACRO_OVERLOAD(c_WITH, __VA_ARGS__) -#define c_WITH2(declvar, drop) for (declvar, **_c_i = NULL; !_c_i; ++_c_i, drop) -#define c_WITH3(declvar, pred, drop) for (declvar, **_c_i = NULL; !_c_i && (pred); ++_c_i, drop) +#define c_WITH_2(declvar, drop) for (declvar, **_c_i = NULL; !_c_i; ++_c_i, drop) +#define c_WITH_3(declvar, pred, drop) for (declvar, **_c_i = NULL; !_c_i && (pred); ++_c_i, drop) #define c_SCOPE(init, drop) for (int _c_i = (init, 1); _c_i; --_c_i, drop) #define c_DEFER(...) for (int _c_i = 1; _c_i; --_c_i, __VA_ARGS__) #define c_AUTO(...) c_MACRO_OVERLOAD(c_AUTO, __VA_ARGS__) -#define c_AUTO2(C, a) \ - c_WITH2(C a = C##_init(), C##_drop(&a)) -#define c_AUTO3(C, a, b) \ - c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init()), \ +#define c_AUTO_2(C, a) \ + c_WITH_2(C a = C##_init(), C##_drop(&a)) +#define c_AUTO_3(C, a, b) \ + c_WITH_2(c_EXPAND(C a = C##_init(), b = C##_init()), \ (C##_drop(&b), C##_drop(&a))) -#define c_AUTO4(C, a, b, c) \ - c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init()), \ +#define c_AUTO_4(C, a, b, c) \ + c_WITH_2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init()), \ (C##_drop(&c), C##_drop(&b), C##_drop(&a))) -#define c_AUTO5(C, a, b, c, d) \ - c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init(), d = C##_init()), \ +#define c_AUTO_5(C, a, b, c, d) \ + c_WITH_2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init(), d = C##_init()), \ (C##_drop(&d), C##_drop(&c), C##_drop(&b), C##_drop(&a))) /* Generic functions */ #define c_drop(C, ...) do { c_FORLIST (_i, C*, {__VA_ARGS__}) C##_drop(*_i.ref); } while(0) #define c_find_if(...) c_MACRO_OVERLOAD(c_find_if, __VA_ARGS__) -#define c_find_if4(it, C, cnt, pred) do { \ +#define c_find_if_4(it, C, cnt, pred) do { \ size_t index = 0; \ for (it = C##_begin(&cnt); it.ref && !(pred); C##_next(&it)) \ ++index; \ } while (0) -#define c_find_if5(it, C, start, end, pred) do { \ +#define c_find_if_5(it, C, start, end, pred) do { \ size_t index = 0; \ const C##_value* _endref = (end).ref; \ for (it = start; it.ref != _endref && !(pred); C##_next(&it)) \ diff --git a/include/stc/cspan.h b/include/stc/cspan.h index 502f1b71..5ba408a8 100644 --- a/include/stc/cspan.h +++ b/include/stc/cspan.h @@ -128,15 +128,15 @@ int demo2() { #define cspan_subdim3(...) c_MACRO_OVERLOAD(cspan_subdim3, __VA_ARGS__) #define cspan_subdim2(self, x) \ {.data=cspan_at(self, x, 0), .dim={(self)->dim[1]}} -#define cspan_subdim32(self, x) \ +#define cspan_subdim3_2(self, x) \ {.data=cspan_at(self, x, 0, 0), .dim={(self)->dim[1], (self)->dim[2]}} -#define cspan_subdim33(self, x, y) \ +#define cspan_subdim3_3(self, x, y) \ {.data=cspan_at(self, x, y, 0), .dim={(self)->dim[2]}} -#define cspan_subdim42(self, x) \ +#define cspan_subdim4_2(self, x) \ {.data=cspan_at(self, x, 0, 0, 0), .dim={(self)->dim[1], (self)->dim[2], (self)->dim[3]}} -#define cspan_subdim43(self, x, y) \ +#define cspan_subdim4_3(self, x, y) \ {.data=cspan_at(self, x, y, 0, 0), .dim={(self)->dim[2], (self)->dim[3]}} -#define cspan_subdim44(self, x, y, z) \ +#define cspan_subdim4_4(self, x, y, z) \ {.data=cspan_at(self, x, y, z, 0), .dim={(self)->dim[3]}} STC_INLINE size_t _cspan_i1(const uint32_t dim[1], uint32_t x) diff --git a/include/stc/csview.h b/include/stc/csview.h index fb860a66..c53cd1c0 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -27,12 +27,12 @@ #include "forward.h" #include "utf8.h" -#define csview_NULL c_SV1("") +#define csview_NULL c_SV_1("") #define csview_init() csview_NULL #define csview_drop(p) c_default_drop(p) #define csview_clone(sv) c_default_clone(sv) -#define csview_lit(literal) c_SV1(literal) -#define csview_from_n(str, n) c_SV2(str, n) +#define csview_lit(literal) c_SV_1(literal) +#define csview_from_n(str, n) c_SV_2(str, n) STC_API size_t csview_find_sv(csview sv, csview search); |
