From b0d60c33a073782fe0bb08c835ca9db0b94145d0 Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Mon, 18 Apr 2022 12:12:01 +0200 Subject: Removed i_drop and i_from template specifiers to reduce redundancies and add clarity (error given if used): use i_valdrop/i_valfrom and i_keydrop/i_keyfrom instead. Added missing at_mut() function to cdeq. --- examples/arc_containers.c | 2 +- examples/arc_demo.c | 2 +- examples/arcvec_erase.c | 2 +- examples/box2.c | 2 +- examples/complex.c | 4 ++-- examples/mapmap.c | 4 ++-- examples/music_arc.c | 2 +- examples/new_sptr.c | 2 +- examples/rawptr_elements.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/arc_containers.c b/examples/arc_containers.c index 53297270..cd049c4d 100644 --- a/examples/arc_containers.c +++ b/examples/arc_containers.c @@ -8,7 +8,7 @@ #define i_type Arc // (atomic) ref. counted type #define i_val Map -#define i_drop(p) (printf("drop Arc:\n"), Map_drop(p)) +#define i_valdrop(p) (printf("drop Arc:\n"), Map_drop(p)) // no need for atomic ref. count in single thread: // no compare function available for csmap: #define i_opt c_no_atomic|c_no_cmp diff --git a/examples/arc_demo.c b/examples/arc_demo.c index 036b7a00..12f81b8d 100644 --- a/examples/arc_demo.c +++ b/examples/arc_demo.c @@ -10,7 +10,7 @@ void int_drop(int* x) { #define i_type iref // set type name to be defined (instead of 'carc_int') #define i_val int -#define i_drop int_drop // optional, just to display the elements destroyed +#define i_valdrop int_drop // optional, just to display the elements destroyed #include // iref #define i_key_arcbox iref // note: use i_key_bind instead of i_key for carc/cbox elements diff --git a/examples/arcvec_erase.c b/examples/arcvec_erase.c index 12547f6c..10d8d4c0 100644 --- a/examples/arcvec_erase.c +++ b/examples/arcvec_erase.c @@ -4,7 +4,7 @@ void show_drop(int* x) { printf("drop: %d\n", *x); } #define i_type Arc #define i_val int -#define i_drop show_drop +#define i_valdrop show_drop // carc/cbox will use pointer address comparison of i_val // if 'i_opt c_no_cmp' is defined, otherwise i_cmp is used // to compare object values. See the two differences by diff --git a/examples/box2.c b/examples/box2.c index 68a9ccba..6d118e2c 100644 --- a/examples/box2.c +++ b/examples/box2.c @@ -27,7 +27,7 @@ struct { // Box in box: #define i_val_arcbox cbox_Point // NB: use i_val_arcbox when value is a cbox or carc! - // it will auto-set i_drop, i_from, i_cmp for you. + // it will auto-set i_valdrop, i_valfrom, i_cmp for you. #define i_opt c_no_cmp #define i_tag BoxPoint #include // cbox_BoxPoint diff --git a/examples/complex.c b/examples/complex.c index 9ccd2dae..ef7f711f 100644 --- a/examples/complex.c +++ b/examples/complex.c @@ -4,8 +4,8 @@ void check_drop(float* v) {printf("destroy %g\n", *v);} #define i_type FloatStack #define i_val float -#define i_drop check_drop -#define i_from c_default_from +#define i_valdrop check_drop +#define i_valfrom c_default_from #include #define i_type StackList diff --git a/examples/mapmap.c b/examples/mapmap.c index 7faaffd1..94b92a81 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -16,8 +16,8 @@ // Shorthand for: //#define i_val People_value //#define i_cmp People_value_cmp -//#define i_from People_value_clone -//#define i_drop People_value_drop +//#define i_valfrom People_value_clone +//#define i_valdrop People_value_drop #include void add(Departments* deps, const char* name, const char* email, const char* dep) diff --git a/examples/music_arc.c b/examples/music_arc.c index b8525022..e36477f2 100644 --- a/examples/music_arc.c +++ b/examples/music_arc.c @@ -19,7 +19,7 @@ void Song_drop(Song* s) { #define i_type SongPtr #define i_val Song -#define i_drop Song_drop +#define i_valdrop Song_drop #define i_opt c_no_cmp #include diff --git a/examples/new_sptr.c b/examples/new_sptr.c index 2fb058df..2c2c5d8a 100644 --- a/examples/new_sptr.c +++ b/examples/new_sptr.c @@ -22,7 +22,7 @@ void Person_drop(Person* p) { // ... #define i_type SPtr #define i_val int -#define i_drop(x) printf("drop: %d\n", *(x)) +#define i_valdrop(x) printf("drop: %d\n", *(x)) #include #define i_val_arcbox SPtr diff --git a/examples/rawptr_elements.c b/examples/rawptr_elements.c index 8f7dd4de..b0878941 100644 --- a/examples/rawptr_elements.c +++ b/examples/rawptr_elements.c @@ -16,8 +16,8 @@ struct { double x, y; } typedef Point; // Map of int64 pointers: For fun, define valraw as int64_t for easy emplace call! typedef int64_t inttype; #define i_key_str -#define i_valraw inttype #define i_val inttype* +#define i_valraw inttype #define i_valdrop(x) c_free(*(x)) #define i_valfrom(raw) c_new(inttype, raw) #define i_valto(x) **(x) -- cgit v1.2.3