summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2021-09-20 10:36:25 +0200
committerTyge Lovset <[email protected]>2021-09-20 10:36:25 +0200
commit0861391b9b3b8ad37e24b0dba7da192f31e48a6b (patch)
treedf78821e47690e1793465d0fcf3d068ad33ccf44 /include
parent625a0fad0c1d187d56d3a9c9bb831987e9250e86 (diff)
downloadSTC-modified-0861391b9b3b8ad37e24b0dba7da192f31e48a6b.tar.gz
STC-modified-0861391b9b3b8ad37e24b0dba7da192f31e48a6b.zip
Renamed macros: breaking changes for Version 2.0!
c_forvar => c_autovar c_forscope => c_autoscope c_forauto => c_auto Removed: c_fordefer(x); use c_forscope(0, x) instead. Added: c_exitauto; // continue
Diffstat (limited to 'include')
-rw-r--r--include/stc/carr2.h2
-rw-r--r--include/stc/carr3.h2
-rw-r--r--include/stc/cbits.h2
-rw-r--r--include/stc/ccommon.h32
-rw-r--r--include/stc/clist.h2
-rw-r--r--include/stc/cmap.h2
-rw-r--r--include/stc/cqueue.h2
-rw-r--r--include/stc/csmap.h2
-rw-r--r--include/stc/cstr.h2
9 files changed, 24 insertions, 24 deletions
diff --git a/include/stc/carr2.h b/include/stc/carr2.h
index e390469e..93cabb6e 100644
--- a/include/stc/carr2.h
+++ b/include/stc/carr2.h
@@ -34,7 +34,7 @@
int main() {
int w = 7, h = 5;
- c_forvar (carr2_int image = carr2_int_init(w, h), carr2_int_del(&image))
+ c_autovar (carr2_int image = carr2_int_init(w, h), carr2_int_del(&image))
{
int *dat = carr2_int_data(&image);
for (int i = 0; i < carr2_int_size(image); ++i)
diff --git a/include/stc/carr3.h b/include/stc/carr3.h
index 8467739d..8ba67d43 100644
--- a/include/stc/carr3.h
+++ b/include/stc/carr3.h
@@ -34,7 +34,7 @@
int main() {
int w = 7, h = 5, d = 3;
- c_forvar (carr3_int image = carr3_int_init(w, h, d), carr3_int_del(&image))
+ c_autovar (carr3_int image = carr3_int_init(w, h, d), carr3_int_del(&image))
{
int *dat = carr3_int_data(&image);
for (int i = 0; i < carr3_int_size(image); ++i)
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index af767207..9bf28d44 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -30,7 +30,7 @@ Similar to boost::dynamic_bitset / std::bitset
#include "cbits.h"
int main() {
- c_forvar (cbits bset = cbits_with_size(23, true), cbits_del(&bset))
+ c_autovar (cbits bset = cbits_with_size(23, true), cbits_del(&bset))
{
cbits_reset(&bset, 9);
cbits_resize(&bset, 43, false);
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index d11f1b3f..a97828af 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -136,22 +136,22 @@ STC_API uint64_t c_default_hash(const void *key, size_t len);
for (type i=start, _c_inc=step, _c_end=(stop) - (0 < _c_inc) \
; (i <= _c_end) == (0 < _c_inc); i += _c_inc)
-#define c_forvar(declvar, ...) for (declvar, *_c_ii = NULL; !_c_ii; ++_c_ii, __VA_ARGS__)
-#define c_forscope(start, end) for (int _c_ii = (start, 0); !_c_ii; ++_c_ii, end)
-#define c_fordefer(...) for (int _c_ii = 0; !_c_ii; ++_c_ii, __VA_ARGS__)
-
-#define c_forauto(...) c_MACRO_OVERLOAD(c_forauto, __VA_ARGS__)
-#define c_forauto_2(CX, a) \
- c_forvar(CX a = CX##_init(), CX##_del(&a))
-#define c_forauto_3(CX, a, b) \
- c_forvar(c_EXPAND(CX a = CX##_init(), b = CX##_init()), \
- CX##_del(&b), CX##_del(&a))
-#define c_forauto_4(CX, a, b, c) \
- c_forvar(c_EXPAND(CX a = CX##_init(), b = CX##_init(), c = CX##_init()), \
- CX##_del(&c), CX##_del(&b), CX##_del(&a))
-
-#define c_forbuffer(b, type, n) c_forbuffer_N(b, type, n, 256)
-#define c_forbuffer_N(b, type, n, BYTES) \
+#define c_autoscope(init, ...) for (int _c_ii = (init, 0); !_c_ii; ++_c_ii, __VA_ARGS__)
+#define c_autovar(declvar, ...) for (declvar, *_c_ii = NULL; !_c_ii; ++_c_ii, __VA_ARGS__)
+#define c_exitauto continue
+
+#define c_auto(...) c_MACRO_OVERLOAD(c_auto, __VA_ARGS__)
+#define c_auto_2(CX, a) \
+ c_autovar(CX a = CX##_init(), CX##_del(&a))
+#define c_auto_3(CX, a, b) \
+ c_autovar(c_EXPAND(CX a = CX##_init(), b = CX##_init()), \
+ CX##_del(&b), CX##_del(&a))
+#define c_auto_4(CX, a, b, c) \
+ c_autovar(c_EXPAND(CX a = CX##_init(), b = CX##_init(), c = CX##_init()), \
+ CX##_del(&c), CX##_del(&b), CX##_del(&a))
+
+#define c_autobuf(b, type, n) c_autobuf_N(b, type, n, 256)
+#define c_autobuf_N(b, type, n, BYTES) \
for (type _c_b[((BYTES) - 1) / sizeof(type) + 1], \
*b = (n)*sizeof *b > (BYTES) ? c_new_n(type, n) : _c_b \
; b; b != _c_b ? c_free(b) : (void)0, b = NULL)
diff --git a/include/stc/clist.h b/include/stc/clist.h
index 83e08c24..0b5cd35c 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -35,7 +35,7 @@
#include <stc/clist.h>
int main() {
- c_forvar (clist_ix list = clist_ix_init(), clist_ix_del(&list))
+ c_autovar (clist_ix list = clist_ix_init(), clist_ix_del(&list))
{
stc64_t rng = stc64_init(12345);
int n;
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 989335c1..096a7045 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -31,7 +31,7 @@
#include <stc/cmap.h>
int main(void) {
- c_forvar (cmap_ichar m = cmap_ichar_init(), cmap_ichar_del(&m))
+ c_autovar (cmap_ichar m = cmap_ichar_init(), cmap_ichar_del(&m))
{
cmap_ichar_emplace(&m, 5, 'a');
cmap_ichar_emplace(&m, 8, 'b');
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index f1d173e2..45e3c2a6 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -33,7 +33,7 @@ int main() {
stc64_t rng = stc64_init(1234);
stc64_uniform_t dist = stc64_uniform_init(0, n);
- c_forauto (cqueue_int, Q)
+ c_auto (cqueue_int, Q)
{
// Push ten million random numbers onto the queue.
for (int i=0; i<n; ++i)
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index d52f70c4..cc7eeb49 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -32,7 +32,7 @@
#include <stc/csmap.h>
int main(void) {
- c_forvar (csmap_sx m = csmap_sx_init(), csmap_sx_del(&m))
+ c_autovar (csmap_sx m = csmap_sx_init(), csmap_sx_del(&m))
{
csmap_sx_emplace(&m, "Testing one", 1.234);
csmap_sx_emplace(&m, "Testing two", 12.34);
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index 681f38b1..23830d75 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -292,7 +292,7 @@ STC_DEF void
cstr_replace_n(cstr* self, size_t pos, size_t len, const char* str, size_t n) {
size_t sz = cstr_size(*self);
if (len > sz - pos) len = sz - pos;
- c_forbuffer (xstr, char, n) {
+ c_autobuf (xstr, char, n) {
memcpy(xstr, str, n);
_cstr_internal_move(self, pos + len, pos + n);
memcpy(&self->str[pos], xstr, n);