diff options
| author | Tyge Løvset <[email protected]> | 2023-01-29 17:24:33 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-29 17:24:33 +0100 |
| commit | 209bf743e0c1253a4bc81d2ffb6897f657a84c8a (patch) | |
| tree | 9631a2a79e1890cb7c46515aae0ef105710ad59c /include | |
| parent | a344b43728ff40a2e1ee25f2f1b592f33432aee7 (diff) | |
| download | STC-modified-209bf743e0c1253a4bc81d2ffb6897f657a84c8a.tar.gz STC-modified-209bf743e0c1253a4bc81d2ffb6897f657a84c8a.zip | |
Some method renaming in cspan: cspan_multidim() ctor => cspan_md(). cspan_atN() => cspan_submdN().
cstr_replace_ex() merged as overload of cstr_replace().
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cspan.h | 24 | ||||
| -rw-r--r-- | include/stc/cstr.h | 6 | ||||
| -rw-r--r-- | include/stc/priv/altnames.h | 12 |
3 files changed, 15 insertions, 27 deletions
diff --git a/include/stc/cspan.h b/include/stc/cspan.h index 19dd74d4..7886c9f6 100644 --- a/include/stc/cspan.h +++ b/include/stc/cspan.h @@ -30,7 +30,7 @@ using_cspan(Intspan, int, 1); int demo1() { float raw[4*5]; - Span2f ms = cspan_multidim(raw, 4, 5); + Span2f ms = cspan_md(raw, 4, 5); for (size_t i=0; i<ms.dim[0]; i++) for (size_t j=0; j<ms.dim[1]; j++) @@ -94,7 +94,7 @@ typedef struct { uint32_t d[2]; } cspan_idx2; typedef struct { uint32_t d[3]; } cspan_idx3; typedef struct { uint32_t d[4]; } cspan_idx4; -#define cspan_multidim(array, ...) \ +#define cspan_md(array, ...) \ {.data=array, .dim={__VA_ARGS__}, .stride={.d={__VA_ARGS__}}} /* For static initialization, use cspan_make(). c_make() for non-static only. */ @@ -117,7 +117,7 @@ typedef struct { uint32_t d[4]; } cspan_idx4; #define cspan_front(self) ((self)->data) #define cspan_back(self) ((self)->data + cspan_size(self) - 1) -// cspan_subspan: +// cspan_subspanN: #define cspan_subspan(self, offset, count) \ {.data=cspan_at(self, offset), .dim={count}} @@ -130,24 +130,24 @@ typedef struct { uint32_t d[4]; } cspan_idx4; {.data=cspan_at(self, offset, 0, 0, 0), .dim={count, (self)->dim[1], (self)->dim[2], (self)->dim[3]}, \ .stride={(self)->stride}} -// cspan_atN: +// cspan_submdN: -#define cspan_at4(...) c_MACRO_OVERLOAD(cspan_at4, __VA_ARGS__) -#define cspan_at3(...) c_MACRO_OVERLOAD(cspan_at3, __VA_ARGS__) -#define cspan_at2(self, x) \ +#define cspan_submd4(...) c_MACRO_OVERLOAD(cspan_submd4, __VA_ARGS__) +#define cspan_submd3(...) c_MACRO_OVERLOAD(cspan_submd3, __VA_ARGS__) +#define cspan_submd2(self, x) \ {.data=cspan_at(self, x, 0), .dim={(self)->dim[1]}} -#define cspan_at3_2(self, x) \ +#define cspan_submd3_2(self, x) \ {.data=cspan_at(self, x, 0, 0), .dim={(self)->dim[1], (self)->dim[2]}, \ .stride={.d={0, (self)->stride.d[2]}}} -#define cspan_at3_3(self, x, y) \ +#define cspan_submd3_3(self, x, y) \ {.data=cspan_at(self, x, y, 0), .dim={(self)->dim[2]}} -#define cspan_at4_2(self, x) \ +#define cspan_submd4_2(self, x) \ {.data=cspan_at(self, x, 0, 0, 0), .dim={(self)->dim[1], (self)->dim[2], (self)->dim[3]}, \ .stride={.d={0, (self)->stride.d[2], (self)->stride.d[3]}}} -#define cspan_at4_3(self, x, y) \ +#define cspan_submd4_3(self, x, y) \ {.data=cspan_at(self, x, y, 0, 0), .dim={(self)->dim[2], (self)->dim[3]}, \ .stride={.d={0, (self)->stride.d[3]}}} -#define cspan_at4_4(self, x, y, z) \ +#define cspan_submd4_4(self, x, y, z) \ {.data=cspan_at(self, x, y, z, 0), .dim={(self)->dim[3]}} // cspan_slice: diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 04091968..071e40e8 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -373,12 +373,12 @@ STC_INLINE char* cstr_append_s(cstr* self, cstr s) { return cstr_append_n(self, sv.str, sv.size); } -STC_INLINE void cstr_replace_ex(cstr* self, const char* search, const char* repl, unsigned count) { +#define cstr_replace(...) c_MACRO_OVERLOAD(cstr_replace, __VA_ARGS__) +#define cstr_replace_3(self, search, repl) cstr_replace_4(self, search, repl, ~0U) +STC_INLINE void cstr_replace_4(cstr* self, const char* search, const char* repl, unsigned count) { cstr_take(self, cstr_replace_sv(cstr_sv(self), c_SV(search, strlen(search)), c_SV(repl, strlen(repl)), count)); } -STC_INLINE void cstr_replace(cstr* self, const char* search, const char* repl) - { cstr_replace_ex(self, search, repl, ~0U); } STC_INLINE void cstr_replace_at_sv(cstr* self, size_t pos, size_t len, const csview repl) { char* d = _cstr_internal_move(self, pos + len, pos + repl.size); diff --git a/include/stc/priv/altnames.h b/include/stc/priv/altnames.h index 7f58384c..695d3ebc 100644 --- a/include/stc/priv/altnames.h +++ b/include/stc/priv/altnames.h @@ -42,15 +42,3 @@ #define c_scope c_SCOPE #define c_defer c_DEFER #define c_sv c_SV - -#define c_DROP c_drop -#define c_DELETE c_delete -#define c_SWAP c_swap -#define c_FIND_IF c_find_if -#define c_ERASE_IF c_erase_if -#define c_FLT_TAKE c_flt_take -#define c_FLT_SKIP c_flt_skip -#define c_FLT_SKIPWHILE c_flt_skipwhile -#define c_FLT_TAKEWHILE c_flt_takewhile -#define c_CONTAINER_OF c_container_of -#define c_STATIC_ASSERT c_static_assert |
