diff options
| -rw-r--r-- | docs/cmap_api.md | 7 | ||||
| -rwxr-xr-x[-rw-r--r--] | examples/make.sh | 0 | ||||
| -rw-r--r-- | examples/vikings.c | 17 | ||||
| -rw-r--r-- | include/stc/template.h | 16 |
4 files changed, 17 insertions, 23 deletions
diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 28e5529c..91c36def 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -379,17 +379,18 @@ static inline RViking Viking_toraw(const Viking* vp) { #define i_key_bind Viking #define i_keyraw RViking #define i_keyfrom Viking_from +#define i_opt c_no_clone // disable map cloning #define i_hash(rp) (c_strhash(rp->name) ^ c_strhash(rp->country)) #define i_val int +#include <stc/cmap.h> /* - i_key_bind makes these defines, unless they are already defined: + i_key_bind sets up these defines, unless they are already defined: #define i_cmp RViking_cmp //#define i_hash RViking_hash // already defined above. - #define i_keyclone c_derived_keyclone // because i_keyfrom is defined. + //#define i_keyclone Viking_clone // not used because c_no_clone #define i_keyto Viking_toraw // because i_keyraw type is defined #define i_keydrop Viking_drop */ -#include <stc/cmap.h> int main() { diff --git a/examples/make.sh b/examples/make.sh index e5efde07..e5efde07 100644..100755 --- a/examples/make.sh +++ b/examples/make.sh diff --git a/examples/vikings.c b/examples/vikings.c index b5b3417b..f291a601 100644 --- a/examples/vikings.c +++ b/examples/vikings.c @@ -35,17 +35,18 @@ static inline RViking Viking_toraw(const Viking* vp) { #define i_key_bind Viking // key type #define i_keyraw RViking // lookup type #define i_keyfrom Viking_from +#define i_opt c_no_clone #define i_hash(rp) c_strhash(rp->name) ^ c_strhash(rp->country) #define i_val int // mapped type - -// i_key_bind makes up these defines, unless they are already defined: -// i_cmp => RViking_cmp -// //i_hash => RViking_hash // already defined. -// i_keyclone => c_derived_keyclone // because i_keyfrom is defined -// i_keyto => Viking_toraw // because i_keyraw is defined -// i_keydrop => Viking_drop - #include <stc/cmap.h> +/* + i_key_bind set up these defines, unless they are already defined: + i_cmp => RViking_cmp + //i_hash => RViking_hash // already defined. + //i_keyclone => Viking_clone // not used, because of c_no_clone + i_keyto => Viking_toraw // because i_keyraw is defined + i_keydrop => Viking_drop +*/ int main() { diff --git a/include/stc/template.h b/include/stc/template.h index e77aa781..cb0c7ef2 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -95,7 +95,6 @@ #define i_key_bind cstr #define i_keyraw crawstr #define i_keyfrom cstr_from - #define i_keyclone cstr_clone #ifndef i_tag #define i_tag str #endif @@ -104,7 +103,6 @@ #define i_keyraw csview #define i_keyfrom cstr_from_sv #define i_keyto cstr_sv - #define i_keyclone cstr_clone #define i_eq csview_eq #ifndef i_tag #define i_tag ssv @@ -112,15 +110,13 @@ #elif defined i_key_arcbox #define i_key_bind i_key_arcbox #define i_keyraw c_paste(i_key_arcbox, _value) - #define i_keyto c_paste(i_key, _toval) + #define i_keyto c_paste(i_key_arcbox, _toval) #define i_eq c_paste(i_key_arcbox, _value_eq) #endif #ifdef i_key_bind #define i_key i_key_bind - #if !defined i_keyclone && defined i_keyfrom - #define i_keyclone c_derived_keyclone - #elif !defined i_keyclone + #ifndef i_keyclone #define i_keyclone c_paste(i_key, _clone) #endif #if !defined i_keyto && defined i_keyraw @@ -193,24 +189,20 @@ #define i_val_bind cstr #define i_valraw crawstr #define i_valfrom cstr_from - #define i_valclone cstr_clone #elif defined i_val_ssv #define i_val_bind cstr #define i_valraw csview #define i_valfrom cstr_from_sv #define i_valto cstr_sv - #define i_valclone cstr_clone #elif defined i_val_arcbox #define i_val_bind i_val_arcbox #define i_valraw c_paste(i_val_arcbox, _value) - #define i_valto c_paste(i_val, _toval) + #define i_valto c_paste(i_val_arcbox, _toval) #endif #ifdef i_val_bind #define i_val i_val_bind - #if !defined i_valclone && defined i_valfrom - #define i_valclone c_derived_valclone - #elif !defined i_valclone + #ifndef i_valclone #define i_valclone c_paste(i_val, _clone) #endif #if !defined i_valto && defined i_valraw |
