diff options
Diffstat (limited to 'misc/examples')
| -rw-r--r-- | misc/examples/box.c | 2 | ||||
| -rw-r--r-- | misc/examples/city.c | 2 | ||||
| -rw-r--r-- | misc/examples/forfilter.c | 20 | ||||
| -rw-r--r-- | misc/examples/forloops.c | 10 | ||||
| -rw-r--r-- | misc/examples/functor.c | 2 | ||||
| -rw-r--r-- | misc/examples/music_arc.c | 2 | ||||
| -rw-r--r-- | misc/examples/new_sptr.c | 2 | ||||
| -rw-r--r-- | misc/examples/person_arc.c | 2 | ||||
| -rw-r--r-- | misc/examples/prime.c | 2 | ||||
| -rw-r--r-- | misc/examples/sso_substr.c | 2 | ||||
| -rw-r--r-- | misc/examples/vikings.c | 4 |
11 files changed, 25 insertions, 25 deletions
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: |
