diff --git a/ase/include/ase/cmn/map.h b/ase/include/ase/cmn/map.h index 91cf787f..738db64b 100644 --- a/ase/include/ase/cmn/map.h +++ b/ase/include/ase/cmn/map.h @@ -1,5 +1,5 @@ /* - * $Id: map.h 376 2008-09-24 07:18:50Z baconevi $ + * $Id: map.h 380 2008-09-24 08:16:41Z baconevi $ * * {License} */ @@ -115,6 +115,17 @@ enum ase_map_walk_t #define ASE_MAP_SIZE(m) ((m)->size) #define ASE_MAP_CAPA(m) ((m)->capa) +#define ASE_MAP_MMGR(m) ((m)->mmgr) +#define ASE_MAP_KCOPIER(m) ((m)->copier[ASE_MAP_KEY]) +#define ASE_MAP_VCOPIER(m) ((m)->copier[ASE_MAP_VAL]) +#define ASE_MAP_KFREEER(m) ((m)->freeer[ASE_MAP_KEY]) +#define ASE_MAP_VFREEER(m) ((m)->freeer[ASE_MAP_VAL]) +#define ASE_MAP_HASHER(m) ((m)->hasher) +#define ASE_MAP_COMPER(m) ((m)->comper) +#define ASE_MAP_KEEPER(m) ((m)->keeper) +#define ASE_MAP_SIZER(m) ((m)->sizer) +#define ASE_MAP_EXTENSION(m) ((void*)(((ase_map_t*)m) + 1)) + #define ASE_MAP_KPTR(p) ((p)->kptr) #define ASE_MAP_KLEN(p) ((p)->klen) #define ASE_MAP_VPTR(p) ((p)->vptr) diff --git a/ase/include/ase/cmn/str.h b/ase/include/ase/cmn/str.h index 49f7c6dd..a2e08022 100644 --- a/ase/include/ase/cmn/str.h +++ b/ase/include/ase/cmn/str.h @@ -1,5 +1,5 @@ /* - * $Id: str.h 379 2008-09-24 08:06:56Z baconevi $ + * $Id: str.h 380 2008-09-24 08:16:41Z baconevi $ * * {License} */ @@ -10,10 +10,14 @@ #include #include -#define ASE_STR_LEN(x) ((x)->len) -#define ASE_STR_PTR(x) ((x)->ptr) -#define ASE_STR_CAPA(x) ((x)->capa) -#define ASE_STR_CHAR(x,idx) ((x)->ptr[idx]) +#define ASE_STR_LEN(s) ((s)->len) +#define ASE_STR_PTR(s) ((s)->ptr) +#define ASE_STR_CAPA(s) ((s)->capa) +#define ASE_STR_CHAR(s,idx) ((s)->ptr[idx]) + +#define ASE_STR_MMGR(s) ((s)->mmgr) +#define ASE_STR_SIZER(s) ((s)->sizer) +#define ASE_STR_EXTENSION(s) ((void*)(((ase_str_t*)s) + 1)) typedef struct ase_str_t ase_str_t; typedef ase_size_t (*ase_str_sizer_t) (ase_str_t* data, ase_size_t hint); diff --git a/ase/lib/awk/awk.c b/ase/lib/awk/awk.c index 8459522b..bf160a0e 100644 --- a/ase/lib/awk/awk.c +++ b/ase/lib/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c 379 2008-09-24 08:06:56Z baconevi $ + * $Id: awk.c 380 2008-09-24 08:16:41Z baconevi $ * * {License} */ @@ -23,7 +23,7 @@ static void free_afn (ase_map_t* map, void* vptr, ase_size_t vlen) { - ase_awk_t* awk = *(ase_awk_t**)ase_map_getextension(map); + ase_awk_t* awk = *(ase_awk_t**)ASE_MAP_EXTENSION(map); ase_awk_afn_t* f = (ase_awk_afn_t*)vptr; /* f->name doesn't have to be freed */ @@ -35,7 +35,7 @@ static void free_afn (ase_map_t* map, void* vptr, ase_size_t vlen) static void free_bfn (ase_map_t* map, void* vptr, ase_size_t vlen) { - ase_awk_t* awk = *(ase_awk_t**)ase_map_getextension(map); + ase_awk_t* awk = *(ase_awk_t**)ASE_MAP_EXTENSION(map); ase_awk_bfn_t* f = (ase_awk_bfn_t*)vptr; ASE_AWK_FREE (awk, f); @@ -74,7 +74,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->wtab) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->wtab) = awk; ase_map_setcopier (awk->wtab, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE); ase_map_setcopier (awk->wtab, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE); @@ -86,7 +86,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->rwtab) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->rwtab) = awk; ase_map_setcopier (awk->rwtab, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE); ase_map_setcopier (awk->rwtab, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE); @@ -101,7 +101,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->tree.afns) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->tree.afns) = awk; ase_map_setfreeer (awk->tree.afns, ASE_MAP_VAL, free_afn); /*awk->parse.afns = ase_map_open (awk, 256, 70, ASE_NULL, ASE_NULL, mmgr);*/ @@ -115,7 +115,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->parse.afns) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->parse.afns) = awk; /*awk->parse.named = ase_map_open (awk, 256, 70, ASE_NULL, ASE_NULL, mmgr);*/ awk->parse.named = ase_map_open (mmgr, ASE_SIZEOF(awk), 256, 70); @@ -129,7 +129,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->parse.named) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->parse.named) = awk; if (ase_awk_tab_open (&awk->parse.globals, awk) == ASE_NULL) { @@ -219,7 +219,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext) ASE_AWK_FREE (awk, awk); return ASE_NULL; } - *(ase_awk_t**)ase_map_getextension(awk->bfn.user) = awk; + *(ase_awk_t**)ASE_MAP_EXTENSION(awk->bfn.user) = awk; ase_map_setfreeer (awk->bfn.user, ASE_MAP_VAL, free_bfn); awk->parse.depth.cur.block = 0; diff --git a/ase/lib/awk/std.c b/ase/lib/awk/std.c index 5f53a85d..43f5c5ca 100644 --- a/ase/lib/awk/std.c +++ b/ase/lib/awk/std.c @@ -47,7 +47,7 @@ ase_awk_t* ase_awk_openstd (void) awk = ase_awk_open (ASE_NULL, ASE_SIZEOF(ext_t), ASE_NULL); ase_awk_setccls (awk, ASE_CCLS_GETDFL()); - ext = (ext_t*) ase_awk_getextension (awk); + ext = (ext_t*)ASE_AWK_EXTENSION(awk); ext->prmfns.pow = custom_awk_pow; ext->prmfns.sprintf = custom_awk_sprintf; ext->prmfns.dprintf = custom_awk_dprintf; diff --git a/ase/lib/awk/val.c b/ase/lib/awk/val.c index ae96566c..191de09f 100644 --- a/ase/lib/awk/val.c +++ b/ase/lib/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c 378 2008-09-24 08:00:50Z baconevi $ + * $Id: val.c 380 2008-09-24 08:16:41Z baconevi $ * * {License} */ @@ -430,7 +430,7 @@ static void same_mapval (void* run, void* v) */ static void free_mapval (ase_map_t* map, void* dptr, ase_size_t dlen) { - ase_awk_run_t* run = *(ase_awk_run_t**)ase_map_getextension(map); + ase_awk_run_t* run = *(ase_awk_run_t**)ASE_MAP_EXTENSION(map); #ifdef DEBUG_VAL ase_dprintf (ASE_T("refdown in map free...")); @@ -443,7 +443,7 @@ static void free_mapval (ase_map_t* map, void* dptr, ase_size_t dlen) static void same_mapval (ase_map_t* map, void* dptr, ase_size_t dlen) { - ase_awk_run_t* run = *(ase_awk_run_t**)ase_map_getextension(map); + ase_awk_run_t* run = *(ase_awk_run_t**)ASE_MAP_EXTENSION(map); #ifdef DEBUG_VAL ase_dprintf (ASE_T("refdown nofree in map free...")); ase_awk_dprintval (run, dptr); @@ -485,7 +485,7 @@ ase_awk_val_t* ase_awk_makemapval (ase_awk_run_t* run) ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); return ASE_NULL; } - *(ase_awk_run_t**)ase_map_getextension(val->map) = run; + *(ase_awk_run_t**)ASE_MAP_EXTENSION(val->map) = run; /* the key is copied inline into a pair and is freed when the pair * is destroyed */ @@ -1119,7 +1119,7 @@ static ase_map_walk_t print_pair ( { ase_awk_run_t* run = (ase_awk_run_t*)arg; - ASE_ASSERT (run == *(ase_awk_run_t**)ase_map_getextension(map)); + ASE_ASSERT (run == *(ase_awk_run_t**)ASE_MAP_EXTENSION(map)); DPRINTF (DCUSTOM, ASE_T(" %.*s=>"), (int)ASE_MAP_KCLEN(pair), ASE_MAP_KPTR(pair));