diff options
| author | Tyge Løvset <[email protected]> | 2023-01-25 08:37:23 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-25 08:37:23 +0100 |
| commit | af4c2d6d2f3353364632701ef8208a9dcbe18623 (patch) | |
| tree | b79be8e7953e5a8219aa7db55ebc6358145dcbbc /include | |
| parent | 782ab14cac327134614188676a196fcfcb9d0ba1 (diff) | |
| download | STC-modified-af4c2d6d2f3353364632701ef8208a9dcbe18623.tar.gz STC-modified-af4c2d6d2f3353364632701ef8208a9dcbe18623.zip | |
Reverted cspan_subdim*() to cspan_at*(). Added cspan_flatten() constructor.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cspan.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/stc/cspan.h b/include/stc/cspan.h index 5ba408a8..2b600a2a 100644 --- a/include/stc/cspan.h +++ b/include/stc/cspan.h @@ -94,6 +94,9 @@ int demo2() { #define cspan_init(SpanType, ...) \ {.data=(SpanType##_value[])__VA_ARGS__, .dim={sizeof((SpanType##_value[])__VA_ARGS__)/sizeof(SpanType##_value)}} +#define cspan_flatten(span) \ + {.data=(span)->data, .dim={(uint32_t)cspan_size(span)}} + /* create a cspan from a cvec, cstack, cdeq, cqueue, or cpque (heap) */ #define cspan_from(container) \ {.data=(container)->data, .dim={(uint32_t)(container)->_len}} @@ -124,19 +127,19 @@ int demo2() { #define cspan_subspan4(self, offset, count) \ {.data=cspan_at(self, offset, 0, 0, 0), .dim={count, (self)->dim[1], (self)->dim[2], (self)->dim[3]}} -#define cspan_subdim4(...) c_MACRO_OVERLOAD(cspan_subdim4, __VA_ARGS__) -#define cspan_subdim3(...) c_MACRO_OVERLOAD(cspan_subdim3, __VA_ARGS__) -#define cspan_subdim2(self, x) \ +#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) \ {.data=cspan_at(self, x, 0), .dim={(self)->dim[1]}} -#define cspan_subdim3_2(self, x) \ +#define cspan_at3_2(self, x) \ {.data=cspan_at(self, x, 0, 0), .dim={(self)->dim[1], (self)->dim[2]}} -#define cspan_subdim3_3(self, x, y) \ +#define cspan_at3_3(self, x, y) \ {.data=cspan_at(self, x, y, 0), .dim={(self)->dim[2]}} -#define cspan_subdim4_2(self, x) \ +#define cspan_at4_2(self, x) \ {.data=cspan_at(self, x, 0, 0, 0), .dim={(self)->dim[1], (self)->dim[2], (self)->dim[3]}} -#define cspan_subdim4_3(self, x, y) \ +#define cspan_at4_3(self, x, y) \ {.data=cspan_at(self, x, y, 0, 0), .dim={(self)->dim[2], (self)->dim[3]}} -#define cspan_subdim4_4(self, x, y, z) \ +#define cspan_at4_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) |
