diff --git a/moo/lib/exec.c b/moo/lib/exec.c index c608349..b2143d1 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -1841,7 +1841,7 @@ static moo_pfrc_t pf_dump (moo_t* moo, moo_ooi_t nargs) return MOO_PF_SUCCESS; } -static void log_char_object (moo_t* moo, moo_log_masks_t mask, moo_oop_char_t msg) +static void log_char_object (moo_t* moo, moo_bitmask_t mask, moo_oop_char_t msg) { moo_ooi_t n; moo_oow_t rem; @@ -3354,7 +3354,7 @@ static moo_pfrc_t pf_strlen (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_log (moo_t* moo, moo_ooi_t nargs) { moo_oop_t msg, level; - moo_log_masks_t mask; + moo_bitmask_t mask; moo_ooi_t k; MOO_ASSERT (moo, nargs >= 2); diff --git a/moo/lib/logfmt.c b/moo/lib/logfmt.c index c441468..a207973 100644 --- a/moo/lib/logfmt.c +++ b/moo/lib/logfmt.c @@ -130,14 +130,14 @@ static moo_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' }; typedef int (*moo_fmtout_putch_t) ( moo_t* moo, - moo_log_masks_t mask, + moo_bitmask_t mask, moo_ooch_t c, moo_oow_t len ); typedef int (*moo_fmtout_putcs_t) ( moo_t* moo, - moo_log_masks_t mask, + moo_bitmask_t mask, const moo_ooch_t* ptr, moo_oow_t len ); @@ -146,7 +146,7 @@ typedef struct moo_fmtout_t moo_fmtout_t; struct moo_fmtout_t { moo_oow_t count; /* out */ - moo_log_masks_t mask; /* in */ + moo_bitmask_t mask; /* in */ moo_fmtout_putch_t putch; /* in */ moo_fmtout_putcs_t putcs; /* in */ }; @@ -184,7 +184,7 @@ static moo_bch_t* sprintn_upper (moo_bch_t* nbuf, moo_uintmax_t num, int base, m } /* ------------------------------------------------------------------------- */ -static int put_ooch (moo_t* moo, moo_log_masks_t mask, moo_ooch_t ch, moo_oow_t len) +static int put_ooch (moo_t* moo, moo_bitmask_t mask, moo_ooch_t ch, moo_oow_t len) { /* this is not equivalent to put_oocs(moo,mask,&ch, 1); * this function is to emit a single character multiple times */ @@ -281,7 +281,7 @@ redo: return 1; /* success */ } -static int put_oocs (moo_t* moo, moo_log_masks_t mask, const moo_ooch_t* ptr, moo_oow_t len) +static int put_oocs (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* ptr, moo_oow_t len) { moo_oow_t rem; @@ -374,9 +374,9 @@ redo: /* ------------------------------------------------------------------------- */ -typedef moo_ooi_t (*outbfmt_t) (moo_t* moo, moo_log_masks_t mask, const moo_bch_t* fmt, ...); +typedef moo_ooi_t (*outbfmt_t) (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...); -static int print_object (moo_t* moo, moo_log_masks_t mask, moo_oop_t oop, outbfmt_t outbfmt) +static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_t outbfmt) { if (oop == moo->_nil) { @@ -612,7 +612,7 @@ static int _logufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_l return __logufmtv (moo, fmt, data, ap, moo_logbfmt); } -moo_ooi_t moo_logbfmt (moo_t* moo, moo_log_masks_t mask, const moo_bch_t* fmt, ...) +moo_ooi_t moo_logbfmt (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...) { int x; va_list ap; @@ -645,7 +645,7 @@ moo_ooi_t moo_logbfmt (moo_t* moo, moo_log_masks_t mask, const moo_bch_t* fmt, . return (x <= -1)? -1: fo.count; } -moo_ooi_t moo_logufmt (moo_t* moo, moo_log_masks_t mask, const moo_uch_t* fmt, ...) +moo_ooi_t moo_logufmt (moo_t* moo, moo_bitmask_t mask, const moo_uch_t* fmt, ...) { int x; va_list ap; @@ -679,7 +679,7 @@ moo_ooi_t moo_logufmt (moo_t* moo, moo_log_masks_t mask, const moo_uch_t* fmt, . * ERROR MESSAGE FORMATTING * -------------------------------------------------------------------------- */ -static int put_errch (moo_t* moo, moo_log_masks_t mask, moo_ooch_t ch, moo_oow_t len) +static int put_errch (moo_t* moo, moo_bitmask_t mask, moo_ooch_t ch, moo_oow_t len) { moo_oow_t max; @@ -698,7 +698,7 @@ static int put_errch (moo_t* moo, moo_log_masks_t mask, moo_ooch_t ch, moo_oow_t return 1; /* success */ } -static int put_errcs (moo_t* moo, moo_log_masks_t mask, const moo_ooch_t* ptr, moo_oow_t len) +static int put_errcs (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* ptr, moo_oow_t len) { moo_oow_t max; @@ -715,7 +715,7 @@ static int put_errcs (moo_t* moo, moo_log_masks_t mask, const moo_ooch_t* ptr, m } -static moo_ooi_t __errbfmtv (moo_t* moo, moo_log_masks_t mask, const moo_bch_t* fmt, ...); +static moo_ooi_t __errbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...); static int _errbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_t* data, va_list ap) { @@ -727,7 +727,7 @@ static int _errufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_l return __logufmtv (moo, fmt, data, ap, __errbfmtv); } -static moo_ooi_t __errbfmtv (moo_t* moo, moo_log_masks_t mask, const moo_bch_t* fmt, ...) +static moo_ooi_t __errbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...) { va_list ap; moo_fmtout_t fo; diff --git a/moo/lib/main.c b/moo/lib/main.c index 7c91e60..daa7422 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -214,7 +214,7 @@ struct xtn_t int vm_running; int logfd; - moo_log_masks_t logmask; + moo_bitmask_t logmask; int logfd_istty; struct @@ -657,7 +657,7 @@ static void flush_log (moo_t* moo, int fd) } } -static void log_write (moo_t* moo, moo_log_masks_t mask, const moo_ooch_t* msg, moo_oow_t len) +static void log_write (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* msg, moo_oow_t len) { moo_bch_t buf[256]; moo_oow_t ucslen, bcslen, msgidx; @@ -2213,7 +2213,7 @@ static int handle_logopt (moo_t* moo, const moo_bch_t* str) xtn_t* xtn = moo_getxtn (moo); moo_bch_t* xstr = (moo_bch_t*)str; moo_bch_t* cm, * flt; - moo_log_masks_t logmask; + moo_bitmask_t logmask; cm = moo_find_bchar_in_bcstr (xstr, ','); if (cm) @@ -2299,7 +2299,7 @@ static int handle_dbgopt (moo_t* moo, const moo_bch_t* str) xtn_t* xtn = moo_getxtn (moo); const moo_bch_t* cm, * flt; moo_oow_t len; - moo_traits_t trait, dbgopt = 0; + moo_bitmask_t trait, dbgopt = 0; cm = str - 1; do @@ -2467,7 +2467,7 @@ int main (int argc, char* argv[]) } { - moo_traits_t trait = 0; + moo_bitmask_t trait = 0; /*trait |= MOO_NOGC;*/ trait |= MOO_AWAIT_PROCS; diff --git a/moo/lib/moo.c b/moo/lib/moo.c index 7e24b6b..9d9fd1e 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -291,14 +291,14 @@ int moo_setoption (moo_t* moo, moo_option_t id, const void* value) switch (id) { case MOO_TRAIT: - moo->option.trait = *(moo_traits_t*)value; + moo->option.trait = *(moo_bitmask_t*)value; #if defined(MOO_BUILD_DEBUG) moo->option.karatsuba_cutoff = ((moo->option.trait & MOO_DEBUG_BIGINT)? MOO_KARATSUBA_CUTOFF_DEBUG: MOO_KARATSUBA_CUTOFF); #endif return 0; case MOO_LOG_MASK: - moo->option.log_mask = *(moo_log_masks_t*)value; + moo->option.log_mask = *(moo_bitmask_t*)value; return 0; case MOO_LOG_MAXCAPA: @@ -353,11 +353,11 @@ int moo_getoption (moo_t* moo, moo_option_t id, void* value) switch (id) { case MOO_TRAIT: - *(moo_traits_t*)value = moo->option.trait; + *(moo_bitmask_t*)value = moo->option.trait; return 0; case MOO_LOG_MASK: - *(moo_log_masks_t*)value = moo->option.log_mask; + *(moo_bitmask_t*)value = moo->option.log_mask; return 0; case MOO_LOG_MAXCAPA: diff --git a/moo/lib/moo.h b/moo/lib/moo.h index c606474..b0a7eed 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -38,6 +38,9 @@ * object instead of putting in in a separate byte array. */ #define MOO_USE_METHOD_TRAILER + +typedef unsigned int moo_bitmask_t; + /* ========================================================================== */ /** @@ -128,8 +131,6 @@ enum moo_trait_t }; typedef enum moo_trait_t moo_trait_t; -typedef unsigned int moo_traits_t; - typedef struct moo_obj_t moo_obj_t; typedef struct moo_obj_t* moo_oop_t; @@ -949,8 +950,6 @@ enum moo_log_mask_t }; typedef enum moo_log_mask_t moo_log_mask_t; -typedef unsigned int moo_log_masks_t; - /* all bits must be set to get enabled */ #define MOO_LOG_ENABLED(moo,mask) (((moo)->option.log_mask & (mask)) == (mask)) @@ -1009,7 +1008,7 @@ typedef void (*moo_free_heap_t) ( typedef void (*moo_log_write_t) ( moo_t* moo, - moo_log_masks_t mask, + moo_bitmask_t mask, const moo_ooch_t* msg, moo_oow_t len ); @@ -1312,8 +1311,8 @@ struct moo_t struct { - moo_traits_t trait; - moo_log_masks_t log_mask; + moo_bitmask_t trait; + moo_bitmask_t log_mask; moo_oow_t log_maxcapa; moo_oow_t dfl_symtab_size; moo_oow_t dfl_sysdic_size; @@ -1337,8 +1336,8 @@ struct moo_t moo_ooch_t* ptr; moo_oow_t len; moo_oow_t capa; - moo_log_masks_t last_mask; - moo_log_masks_t default_type_mask; + moo_bitmask_t last_mask; + moo_bitmask_t default_type_mask; } log; /* ========================= */