summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-23 23:55:10 +0100
committerTyge Løvset <[email protected]>2022-12-23 23:55:10 +0100
commitd623c6c85071b9af5d607bb5d9aceceaea05220a (patch)
treef20fc3714f86e1553d1103bed6dc8efefcbd9d6b /include
parent5f57d597cd27aef55adbcb3b452973b0c6e33667 (diff)
downloadSTC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.tar.gz
STC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.zip
Experimental uppercase macros.
Diffstat (limited to 'include')
-rw-r--r--include/stc/ccommon.h1
-rw-r--r--include/stc/priv/allcaps.h56
-rw-r--r--include/stc/views.h8
3 files changed, 61 insertions, 4 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index af6b52a5..95c35915 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -29,6 +29,7 @@
#include <stdbool.h>
#include <string.h>
#include <assert.h>
+#include "priv/allcaps.h"
#if SIZE_MAX == UINT32_MAX
#define c_ZU PRIu32
diff --git a/include/stc/priv/allcaps.h b/include/stc/priv/allcaps.h
new file mode 100644
index 00000000..1e2460b5
--- /dev/null
+++ b/include/stc/priv/allcaps.h
@@ -0,0 +1,56 @@
+/* MIT License
+ *
+ * Copyright (c) 2022 Tyge Løvset, NORCE, www.norceresearch.no
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define c_ALLOC c_alloc
+#define c_ALLOC_N c_alloc_n
+#define c_NEW c_new
+#define c_MALLOC c_malloc
+#define c_CALLOC c_calloc
+#define c_REALLOC c_realloc
+#define c_FREE c_free
+#define c_DELETE c_delete
+#define c_SWAP c_swap
+#define c_CONTAINER_OF c_container_of
+#define c_STATIC_ASSERT c_static_assert
+#define c_ARRAYLEN c_arraylen
+#define c_OPTION c_option
+#define c_FORLIST c_forlist
+#define c_FORRANGE c_forrange
+#define c_FOREACH c_foreach
+#define c_FORWHILE c_forwhile
+#define c_FORPAIR c_forpair
+#define c_FORFILTER c_forfilter
+#define c_FORMATCH c_formatch
+#define c_FORTOKEN c_fortoken
+#define c_FORTOKEN_SV c_fortoken_sv
+#define c_AUTO c_auto
+#define c_AUTODROP c_autodrop
+#define c_WITH c_with
+#define c_SCOPE c_scope
+#define c_DEFER c_defer
+#define c_DROP c_drop
+#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
diff --git a/include/stc/views.h b/include/stc/views.h
index 8f7a0d78..ea5f4536 100644
--- a/include/stc/views.h
+++ b/include/stc/views.h
@@ -63,8 +63,8 @@ int main()
#include <stc/ccommon.h>
-#ifndef c_FLT_STACK
- #define c_FLT_STACK 14 /* 22, 30, .. */
+#ifndef c_NFILTERS
+ #define c_NFILTERS 14 /* 22, 30, .. */
#endif
#define c_flt_take(i, n) (++(i).s1[(i).s1top++] <= (n))
#define c_flt_skip(i, n) (++(i).s1[(i).s1top++] > (n))
@@ -78,8 +78,8 @@ int main()
c_forfilter_s(i, C, C##_begin(&cnt), filter) if (!(cond)) break; else
#define c_forfilter_s(i, C, start, filter) \
for (struct {C##_iter it; C##_value *ref; \
- uint32_t s1[c_FLT_STACK], index, count; \
- bool s2[c_FLT_STACK]; uint8_t s1top, s2top;} \
+ uint32_t s1[c_NFILTERS], index, count; \
+ bool s2[c_NFILTERS]; uint8_t s1top, s2top;} \
i = {.it=start, .ref=i.it.ref}; i.it.ref \
; C##_next(&i.it), i.ref = i.it.ref, ++i.index, i.s1top=0, i.s2top=0) \
if (!((filter) && ++i.count)) ; else