summaryrefslogtreecommitdiffhomepage
path: root/misc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-01-19 21:20:16 +0100
committerTyge Løvset <[email protected]>2023-01-19 21:20:16 +0100
commitf8accdbcee0b397ad6ba2f2c2c64575a003e71e5 (patch)
tree1ec8e47eb15fd69d53e394e143c36d7f3500643e /misc
parent5aa48d538569463ffeda976d21f79edc5f276be4 (diff)
downloadSTC-modified-f8accdbcee0b397ad6ba2f2c2c64575a003e71e5.tar.gz
STC-modified-f8accdbcee0b397ad6ba2f2c2c64575a003e71e5.zip
Finish last commit. Most safe function macros are now preferred lowercase, whereas flow control macros (c_FOREACH, ..) are preferred uppercase.
Diffstat (limited to 'misc')
-rw-r--r--misc/archived/csmap.h6
-rw-r--r--misc/archived/cstr.h4
-rw-r--r--misc/examples/box.c2
-rw-r--r--misc/examples/city.c2
-rw-r--r--misc/examples/forfilter.c20
-rw-r--r--misc/examples/forloops.c10
-rw-r--r--misc/examples/functor.c2
-rw-r--r--misc/examples/music_arc.c2
-rw-r--r--misc/examples/new_sptr.c2
-rw-r--r--misc/examples/person_arc.c2
-rw-r--r--misc/examples/prime.c2
-rw-r--r--misc/examples/sso_substr.c2
-rw-r--r--misc/examples/vikings.c4
13 files changed, 30 insertions, 30 deletions
diff --git a/misc/archived/csmap.h b/misc/archived/csmap.h
index 5c9fba6b..2daec3b9 100644
--- a/misc/archived/csmap.h
+++ b/misc/archived/csmap.h
@@ -129,8 +129,8 @@ _cx_memb(_clear)(_cx_self* self)
STC_INLINE _cx_raw
_cx_memb(_value_toraw)(_cx_value* val) {
return _i_SET_ONLY( i_keyto(val) )
- _i_MAP_ONLY( c_INIT(_cx_raw){i_keyto((&val->first)),
- i_valto((&val->second))} );
+ _i_MAP_ONLY( c_COMPOUND(_cx_raw){i_keyto((&val->first)),
+ i_valto((&val->second))} );
}
STC_INLINE int
@@ -470,7 +470,7 @@ _cx_memb(_clone_r_)(_cx_node *tn) {
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
- return c_INIT(_cx_self){_cx_memb(_clone_r_)(cx.root), cx.size};
+ return c_COMPOUND(_cx_self){_cx_memb(_clone_r_)(cx.root), cx.size};
}
#endif // !i_no_clone
diff --git a/misc/archived/cstr.h b/misc/archived/cstr.h
index e074b6e4..1a5b0da4 100644
--- a/misc/archived/cstr.h
+++ b/misc/archived/cstr.h
@@ -67,7 +67,7 @@ STC_INLINE cstr cstr_init() { return cstr_NULL; }
STC_INLINE const char* cstr_str(const cstr* self) { return self->str; }
#define cstr_toraw(self) (self)->str
STC_INLINE csview cstr_sv(const cstr* self)
- { return c_INIT(csview){self->str, _cstr_p(self)->size}; }
+ { return c_COMPOUND(csview){self->str, _cstr_p(self)->size}; }
#define cstr_lit(literal) \
cstr_from_n(literal, crawstr_len(literal))
STC_INLINE cstr cstr_from(const char* str)
@@ -118,7 +118,7 @@ STC_INLINE bool cstr_getline(cstr *self, FILE *stream)
STC_INLINE cstr_buf cstr_buffer(cstr* s) {
cstr_priv* p = _cstr_p(s);
- return c_INIT(cstr_buf){s->str, p->size, p->cap};
+ return c_COMPOUND(cstr_buf){s->str, p->size, p->cap};
}
STC_INLINE cstr cstr_with_capacity(const size_t cap) {
diff --git a/misc/examples/box.c b/misc/examples/box.c
index 446a7603..3a7a8139 100644
--- a/misc/examples/box.c
+++ b/misc/examples/box.c
@@ -24,7 +24,7 @@ Person Person_clone(Person p) {
void Person_drop(Person* p) {
printf("drop: %s %s\n", cstr_str(&p->name), cstr_str(&p->last));
- c_DROP(cstr, &p->name, &p->last);
+ c_drop(cstr, &p->name, &p->last);
}
#define i_type PBox
diff --git a/misc/examples/city.c b/misc/examples/city.c
index 7f355bdf..e24c90de 100644
--- a/misc/examples/city.c
+++ b/misc/examples/city.c
@@ -44,7 +44,7 @@ City City_clone(City c) {
void City_drop(City* c) {
printf("drop %s\n", cstr_str(&c->name));
- c_DROP(cstr, &c->name, &c->country);
+ c_drop(cstr, &c->name, &c->country);
}
diff --git a/misc/examples/forfilter.c b/misc/examples/forfilter.c
index 05d0bc28..e041fd68 100644
--- a/misc/examples/forfilter.c
+++ b/misc/examples/forfilter.c
@@ -33,12 +33,12 @@ void demo1(void)
int res, sum = 0;
c_FORFILTER (i, IVec, vec
- , c_FLT_SKIPWHILE(i, *i.ref != 80)
- && c_FLT_SKIP(i, 1)
- && c_FLT_SKIPWHILE(i, *i.ref != 80)
+ , c_flt_skipwhile(i, *i.ref != 80)
+ && c_flt_skip(i, 1)
+ && c_flt_skipwhile(i, *i.ref != 80)
&& flt_isEven(i)
&& flt_skipValue(i, 80)
- , c_FLT_TAKE(i, 5) // short-circuit
+ , c_flt_take(i, 5) // short-circuit
){
sum += res = flt_square(i);
printf(" %d", res);
@@ -66,9 +66,9 @@ void demo2(void)
puts("demo2:");
c_FORFILTER (x, crange, crange_literal(INT64_MAX)
- , c_FLT_SKIPWHILE(x, *x.ref != 11)
+ , c_flt_skipwhile(x, *x.ref != 11)
&& *x.ref % 2 != 0
- , c_FLT_TAKE(x, 5))
+ , c_flt_take(x, 5))
IVec_push(&vector, *x.ref * *x.ref);
c_FOREACH (x, IVec, vector)
printf(" %d", *x.ref);
@@ -128,11 +128,11 @@ void demo5(void)
puts("demo5:");
crange r1 = crange_make(1963, INT32_MAX);
c_FORFILTER (i, crange, r1
- , c_FLT_SKIP(i,15)
- && c_FLT_SKIPWHILE(i, flt_mid_decade(i))
- && c_FLT_SKIP(i,30)
+ , c_flt_skip(i,15)
+ && c_flt_skipwhile(i, flt_mid_decade(i))
+ && c_flt_skip(i,30)
&& flt_even(i)
- , c_FLT_TAKE(i,10))
+ , c_flt_take(i,10))
printf(" %lld", *i.ref);
puts("");
}
diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c
index 69c1c193..cd3c4d9e 100644
--- a/misc/examples/forloops.c
+++ b/misc/examples/forloops.c
@@ -68,12 +68,12 @@ int main()
puts("\n\nc_forfilter:");
c_FORFILTER (i, IVec, vec
- , c_FLT_SKIPWHILE(i, *i.ref != 65)
- && c_FLT_TAKEWHILE(i, *i.ref != 280)
- && c_FLT_SKIPWHILE(i, isOdd(i))
+ , c_flt_skipwhile(i, *i.ref != 65)
+ && c_flt_takewhile(i, *i.ref != 280)
+ && c_flt_skipwhile(i, isOdd(i))
&& isOdd(i)
- && c_FLT_SKIP(i, 2)
- , c_FLT_TAKE(i, 1))
+ && c_flt_skip(i, 2)
+ , c_flt_take(i, 1))
printf(" %d", *i.ref);
puts("");
// 189
diff --git a/misc/examples/functor.c b/misc/examples/functor.c
index 54e2702d..f1db3644 100644
--- a/misc/examples/functor.c
+++ b/misc/examples/functor.c
@@ -23,7 +23,7 @@ struct {
#define i_type ipque
#define i_val int
#define i_opt c_is_forward // needed to avoid re-type-define container type
-#define i_less_functor(self, x, y) c_CONTAINER_OF(self, IPQueue, Q)->less(x, y)
+#define i_less_functor(self, x, y) c_container_of(self, IPQueue, Q)->less(x, y)
#include <stc/cpque.h>
void print_queue(const char* name, IPQueue q) {
diff --git a/misc/examples/music_arc.c b/misc/examples/music_arc.c
index 9896c591..fad7ddcf 100644
--- a/misc/examples/music_arc.c
+++ b/misc/examples/music_arc.c
@@ -16,7 +16,7 @@ Song Song_make(const char* artist, const char* title)
void Song_drop(Song* s) {
printf("drop: %s\n", cstr_str(&s->title));
- c_DROP(cstr, &s->artist, &s->title);
+ c_drop(cstr, &s->artist, &s->title);
}
// Define the reference counted type
diff --git a/misc/examples/new_sptr.c b/misc/examples/new_sptr.c
index 5441ae01..116827a4 100644
--- a/misc/examples/new_sptr.c
+++ b/misc/examples/new_sptr.c
@@ -43,7 +43,7 @@ Person Person_clone(Person p) {
}
void Person_drop(Person* p) {
printf("drop: %s %s\n", cstr_str(&p->name), cstr_str(&p->last));
- c_DROP(cstr, &p->name, &p->last);
+ c_drop(cstr, &p->name, &p->last);
}
diff --git a/misc/examples/person_arc.c b/misc/examples/person_arc.c
index f782c9da..4d9c2a51 100644
--- a/misc/examples/person_arc.c
+++ b/misc/examples/person_arc.c
@@ -24,7 +24,7 @@ Person Person_clone(Person p) {
void Person_drop(Person* p) {
printf("drop: %s %s\n", cstr_str(&p->name), cstr_str(&p->last));
- c_DROP(cstr, &p->name, &p->last);
+ c_drop(cstr, &p->name, &p->last);
}
#define i_type PSPtr
diff --git a/misc/examples/prime.c b/misc/examples/prime.c
index 40ccc299..4a6b0f68 100644
--- a/misc/examples/prime.c
+++ b/misc/examples/prime.c
@@ -45,7 +45,7 @@ int main(void)
puts("Show the last 50 primes using a temporary crange generator:");
c_FORFILTER (i, crange, crange_literal(n - 1, 0, -2)
, cbits_test(&primes, *i.ref>>1)
- , c_FLT_TAKE(i, 50)) {
+ , c_flt_take(i, 50)) {
printf("%lld ", *i.ref);
if (i.count % 10 == 0) puts("");
}
diff --git a/misc/examples/sso_substr.c b/misc/examples/sso_substr.c
index 8e7450ba..be372a8d 100644
--- a/misc/examples/sso_substr.c
+++ b/misc/examples/sso_substr.c
@@ -16,5 +16,5 @@ int main ()
cstr s3 = cstr_from_sv(cstr_substr_ex(&str, 0, 6)); // "apples"
printf("%s %s: %d, %d\n", cstr_str(&s2), cstr_str(&s3),
cstr_is_long(&str), cstr_is_long(&s2));
- c_DROP (cstr, &str, &s2, &s3);
+ c_drop (cstr, &str, &s2, &s3);
}
diff --git a/misc/examples/vikings.c b/misc/examples/vikings.c
index c65a9caa..a050b324 100644
--- a/misc/examples/vikings.c
+++ b/misc/examples/vikings.c
@@ -23,11 +23,11 @@ static inline int RViking_cmp(const RViking* rx, const RViking* ry) {
}
static inline Viking Viking_from(RViking raw) { // note: parameter is by value
- return c_INIT(Viking){cstr_from(raw.name), cstr_from(raw.country)};
+ return c_COMPOUND(Viking){cstr_from(raw.name), cstr_from(raw.country)};
}
static inline RViking Viking_toraw(const Viking* vp) {
- return c_INIT(RViking){cstr_str(&vp->name), cstr_str(&vp->country)};
+ return c_COMPOUND(RViking){cstr_str(&vp->name), cstr_str(&vp->country)};
}
// With this in place, we define the Viking => int hash map type: