changed code to get rid of some type conversion warnings

This commit is contained in:
hyunghwan.chung 2018-02-26 15:30:38 +00:00
parent f9372e9d61
commit 18ca2b30a0
9 changed files with 138 additions and 106 deletions

View File

@ -70,7 +70,7 @@
#define IS_SIGN_DIFF(x,y) (((x) ^ (y)) < 0) #define IS_SIGN_DIFF(x,y) (((x) ^ (y)) < 0)
/* digit character array */ /* digit character array */
static char* _digitc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static char _digitc[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/* exponent table */ /* exponent table */
static moo_uint8_t _exp_tab[] = static moo_uint8_t _exp_tab[] =
@ -1166,12 +1166,12 @@ static MOO_INLINE moo_oow_t multiply_unsigned_array_karatsuba (moo_t* moo, const
tmplen[0] = ndigits_xh + ndigits_yh; tmplen[0] = ndigits_xh + ndigits_yh;
tmplen[1] = ndigits_yl + ndigits_yh + 1; tmplen[1] = ndigits_yl + ndigits_yh + 1;
if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0]; if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0];
tmp[1] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */ tmp[1] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */
if (!tmp[1]) goto oops; if (!tmp[1]) goto oops;
/* make a temporary for (a0 + a1) and (a0 * b0) */ /* make a temporary for (a0 + a1) and (a0 * b0) */
tmplen[0] = ndigits_xl + ndigits_yl + 1; tmplen[0] = ndigits_xl + ndigits_yl + 1;
tmp[0] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); tmp[0] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]);
if (!tmp[0]) goto oops; if (!tmp[0]) goto oops;
/* tmp[0] = a0 + a1 */ /* tmp[0] = a0 + a1 */
@ -1286,12 +1286,12 @@ oops:
tmplen[0] = ndigits_yl + ndigits_yh + 1; tmplen[0] = ndigits_yl + ndigits_yh + 1;
tmplen[1] = ndigits_xh + ndigits_yh; tmplen[1] = ndigits_xh + ndigits_yh;
if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0]; if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0];
tmp[1] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]); tmp[1] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]);
if (!tmp[1]) goto oops; if (!tmp[1]) goto oops;
/* make a temporary for (a0 + a1) and (a0 * b0) */ /* make a temporary for (a0 + a1) and (a0 * b0) */
tmplen[0] = ndigits_xl + ndigits_yl; tmplen[0] = ndigits_xl + ndigits_yl;
tmp[0] = moo_callocmem (moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]); tmp[0] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]);
if (!tmp[0]) goto oops; if (!tmp[0]) goto oops;
/* tmp[0] = a0 + a1 */ /* tmp[0] = a0 + a1 */

View File

@ -1036,7 +1036,7 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop)
total_bytes = MOO_SIZEOF(moo_obj_t) + get_payload_bytes(moo, oop); total_bytes = MOO_SIZEOF(moo_obj_t) + get_payload_bytes(moo, oop);
moo_pushtmp (moo, &oop); moo_pushtmp (moo, &oop);
z = moo_allocbytes (moo, total_bytes); z = (moo_oop_t)moo_allocbytes (moo, total_bytes);
moo_poptmp(moo); moo_poptmp(moo);
MOO_MEMCPY (z, oop, total_bytes); MOO_MEMCPY (z, oop, total_bytes);
@ -1059,7 +1059,7 @@ int moo_regfinalizable (moo_t* moo, moo_oop_t oop)
return -1; return -1;
} }
x = moo_allocmem (moo, MOO_SIZEOF(*x)); x = (moo_finalizable_t*)moo_allocmem(moo, MOO_SIZEOF(*x));
if (!x) return -1; if (!x) return -1;
MOO_OBJ_SET_FLAGS_GCFIN (oop, MOO_GCFIN_FINALIZABLE); MOO_OBJ_SET_FLAGS_GCFIN (oop, MOO_GCFIN_FINALIZABLE);

View File

@ -92,14 +92,15 @@
static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_list ap, outbfmt_t outbfmt) static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_list ap, outbfmt_t outbfmt)
{ {
const fmtchar_t* percent; const fmtchar_t* percent;
#if defined(FMTCHAR_IS_OOCH)
const fmtchar_t* checkpoint; const fmtchar_t* checkpoint;
#endif
moo_bch_t nbuf[MAXNBUF], bch; moo_bch_t nbuf[MAXNBUF], bch;
const moo_bch_t* nbufp; const moo_bch_t* nbufp;
int n, base, neg, sign; int n, base, neg, sign;
moo_ooi_t tmp, width, precision; moo_ooi_t tmp, width, precision;
moo_ooch_t ch, padc; moo_ooch_t ch, padc;
#if !defined(FMTCHAR_IS_OOCH)
fmtchar_t fch;
#endif
int lm_flag, lm_dflag, flagc, numlen; int lm_flag, lm_dflag, flagc, numlen;
moo_uintmax_t num = 0; moo_uintmax_t num = 0;
int stop = 0; int stop = 0;
@ -137,11 +138,38 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis
} }
PUT_OOCS (checkpoint, fmt - checkpoint - 1); PUT_OOCS (checkpoint, fmt - checkpoint - 1);
#else #else
while ((ch = *fmt++) != '%' || stop) #if defined(MOO_OOCH_IS_UCH)
/* fmtchar is bch. ooch is uch. convert bch to uch */
checkpoint = fmt;
while ((fch = *fmt++) != '%' || stop)
{ {
if (ch == '\0') goto done; if (fch == '\0') break;
}
while (checkpoint < fmt - 1)
{
moo_oow_t cvlen, bclen;
bclen = fmt - checkpoint - 1;
cvlen = moo->cmgr->bctouc(checkpoint, bclen, &ch);
if (cvlen == 0 || cvlen > bclen) goto oops;
checkpoint += cvlen;
PUT_OOCH (ch, 1); PUT_OOCH (ch, 1);
} }
if (fch == '\0') goto done;
#else
while ((fch = *fmt++) != '%' || stop)
{
moo_bch_t bcsbuf[MOO_MBLEN_MAX + 1];
moo_oow_t ucslen, bcslen;
if (fch == '\0') goto done;
/* fmtchar is uch. ooch is bch. convert uch to bch */
ucslen = 1;
bcslen = MOO_COUNTOF(bcsbuf);
if (moo_convutooochars(moo, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops;
PUT_OOCS (bcsbuf, bcslen);
}
#endif
#endif #endif
percent = fmt - 1; percent = fmt - 1;

View File

@ -322,66 +322,67 @@ struct moo_ioarg_t
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
}; };
enum moo_iotok_type_t
{
MOO_IOTOK_EOF,
MOO_IOTOK_CHARLIT,
MOO_IOTOK_STRLIT,
MOO_IOTOK_SYMLIT,
MOO_IOTOK_NUMLIT,
MOO_IOTOK_RADNUMLIT,
MOO_IOTOK_ERRLIT, /* error(NN) */
MOO_IOTOK_ERROR, /* error */
MOO_IOTOK_NIL,
MOO_IOTOK_SELF,
MOO_IOTOK_SUPER,
MOO_IOTOK_TRUE,
MOO_IOTOK_FALSE,
MOO_IOTOK_THIS_CONTEXT,
MOO_IOTOK_THIS_PROCESS,
MOO_IOTOK_SELFNS,
MOO_IOTOK_IF,
MOO_IOTOK_ELSE,
MOO_IOTOK_ELSIF,
MOO_IOTOK_WHILE,
MOO_IOTOK_UNTIL,
MOO_IOTOK_DO,
MOO_IOTOK_BREAK,
MOO_IOTOK_CONTINUE,
MOO_IOTOK_IDENT,
MOO_IOTOK_IDENT_DOTTED,
MOO_IOTOK_BINSEL,
MOO_IOTOK_KEYWORD,
MOO_IOTOK_ASSIGN, /* := */
MOO_IOTOK_COLON, /* : */
MOO_IOTOK_PERCENT, /* % */
MOO_IOTOK_RETURN, /* ^ */
MOO_IOTOK_LOCAL_RETURN, /* ^^ */
MOO_IOTOK_LBRACE,
MOO_IOTOK_RBRACE,
MOO_IOTOK_LBRACK,
MOO_IOTOK_RBRACK,
MOO_IOTOK_LPAREN,
MOO_IOTOK_RPAREN,
MOO_IOTOK_HASHPAREN, /* #( - array literal */
MOO_IOTOK_HASHBRACK, /* #[ - byte array literal */
MOO_IOTOK_PERCPAREN, /* %( - array expression */
MOO_IOTOK_PERCBRACE, /* %{ - dictionary expression */
MOO_IOTOK_PERIOD,
MOO_IOTOK_COMMA,
MOO_IOTOK_SEMICOLON
};
typedef enum moo_iotok_type_t moo_iotok_type_t;
struct moo_iotok_t struct moo_iotok_t
{ {
enum moo_iotok_type_t type;
{
MOO_IOTOK_EOF,
MOO_IOTOK_CHARLIT,
MOO_IOTOK_STRLIT,
MOO_IOTOK_SYMLIT,
MOO_IOTOK_NUMLIT,
MOO_IOTOK_RADNUMLIT,
MOO_IOTOK_ERRLIT, /* error(NN) */
MOO_IOTOK_ERROR, /* error */
MOO_IOTOK_NIL,
MOO_IOTOK_SELF,
MOO_IOTOK_SUPER,
MOO_IOTOK_TRUE,
MOO_IOTOK_FALSE,
MOO_IOTOK_THIS_CONTEXT,
MOO_IOTOK_THIS_PROCESS,
MOO_IOTOK_SELFNS,
MOO_IOTOK_IF,
MOO_IOTOK_ELSE,
MOO_IOTOK_ELSIF,
MOO_IOTOK_WHILE,
MOO_IOTOK_UNTIL,
MOO_IOTOK_DO,
MOO_IOTOK_BREAK,
MOO_IOTOK_CONTINUE,
MOO_IOTOK_IDENT,
MOO_IOTOK_IDENT_DOTTED,
MOO_IOTOK_BINSEL,
MOO_IOTOK_KEYWORD,
MOO_IOTOK_ASSIGN, /* := */
MOO_IOTOK_COLON, /* : */
MOO_IOTOK_PERCENT, /* % */
MOO_IOTOK_RETURN, /* ^ */
MOO_IOTOK_LOCAL_RETURN, /* ^^ */
MOO_IOTOK_LBRACE,
MOO_IOTOK_RBRACE,
MOO_IOTOK_LBRACK,
MOO_IOTOK_RBRACK,
MOO_IOTOK_LPAREN,
MOO_IOTOK_RPAREN,
MOO_IOTOK_HASHPAREN, /* #( - array literal */
MOO_IOTOK_HASHBRACK, /* #[ - byte array literal */
MOO_IOTOK_PERCPAREN, /* %( - array expression */
MOO_IOTOK_PERCBRACE, /* %{ - dictionary expression */
MOO_IOTOK_PERIOD,
MOO_IOTOK_COMMA,
MOO_IOTOK_SEMICOLON
} type;
moo_oocs_t name; moo_oocs_t name;
moo_oow_t name_capa; moo_oow_t name_capa;
moo_ioloc_t loc; moo_ioloc_t loc;
}; };
typedef struct moo_iotok_t moo_iotok_t; typedef struct moo_iotok_t moo_iotok_t;

View File

@ -167,6 +167,13 @@ typedef moo_rbt_pair_t* (*moo_rbt_cbserter_t) (
void* ctx /**< callback context */ void* ctx /**< callback context */
); );
enum moo_rbt_pair_color_t
{
MOO_RBT_RED,
MOO_RBT_BLACK
};
typedef enum moo_rbt_pair_color_t moo_rbt_pair_color_t;
/** /**
* The moo_rbt_pair_t type defines red-black tree pair. A pair is composed * The moo_rbt_pair_t type defines red-black tree pair. A pair is composed
* of a key and a value. It maintains pointers to the beginning of a key and * of a key and a value. It maintains pointers to the beginning of a key and
@ -188,11 +195,7 @@ struct moo_rbt_pair_t
} val; } val;
/* management information below */ /* management information below */
enum moo_rbt_pair_color_t color;
{
MOO_RBT_RED,
MOO_RBT_BLACK
} color;
moo_rbt_pair_t* parent; moo_rbt_pair_t* parent;
moo_rbt_pair_t* child[2]; /* left and right */ moo_rbt_pair_t* child[2]; /* left and right */
}; };

View File

@ -33,7 +33,7 @@ moo_t* moo_open (moo_mmgr_t* mmgr, moo_oow_t xtnsize, moo_oow_t heapsize, const
/* if this assertion fails, correct the type definition in moo.h */ /* if this assertion fails, correct the type definition in moo.h */
MOO_ASSERT (moo, MOO_SIZEOF(moo_oow_t) == MOO_SIZEOF(moo_oop_t)); MOO_ASSERT (moo, MOO_SIZEOF(moo_oow_t) == MOO_SIZEOF(moo_oop_t));
moo = MOO_MMGR_ALLOC (mmgr, MOO_SIZEOF(*moo) + xtnsize); moo = (moo_t*)MOO_MMGR_ALLOC(mmgr, MOO_SIZEOF(*moo) + xtnsize);
if (moo) if (moo)
{ {
if (moo_init(moo, mmgr, heapsize, vmprim) <= -1) if (moo_init(moo, mmgr, heapsize, vmprim) <= -1)
@ -369,7 +369,7 @@ moo_cb_t* moo_regcb (moo_t* moo, moo_cb_t* tmpl)
{ {
moo_cb_t* actual; moo_cb_t* actual;
actual = moo_allocmem (moo, MOO_SIZEOF(*actual)); actual = (moo_cb_t*)moo_allocmem(moo, MOO_SIZEOF(*actual));
if (!actual) return MOO_NULL; if (!actual) return MOO_NULL;
*actual = *tmpl; *actual = *tmpl;

View File

@ -1103,7 +1103,7 @@ typedef void (*moo_mod_gc_t) (
struct moo_mod_t struct moo_mod_t
{ {
/* input */ /* input */
const moo_ooch_t name[MOO_MOD_NAME_LEN_MAX + 1]; /*const*/ moo_ooch_t name[MOO_MOD_NAME_LEN_MAX + 1];
/*const*/ int hints; /* bitwised-ORed of moo_mod_hint_t enumerators */ /*const*/ int hints; /* bitwised-ORed of moo_mod_hint_t enumerators */
/* user-defined data */ /* user-defined data */
@ -1342,7 +1342,7 @@ struct moo_t
{ {
struct struct
{ {
moo_uch_t* ptr; moo_ooch_t* ptr;
moo_oow_t capa; moo_oow_t capa;
moo_oow_t len; moo_oow_t len;
} xbuf; } xbuf;

View File

@ -34,7 +34,7 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size)
if ((moo->option.trait & MOO_DEBUG_GC) && !(moo->option.trait & MOO_NOGC)) moo_gc (moo); if ((moo->option.trait & MOO_DEBUG_GC) && !(moo->option.trait & MOO_NOGC)) moo_gc (moo);
#endif #endif
ptr = moo_allocheapmem (moo, moo->curheap, size); ptr = (moo_uint8_t*)moo_allocheapmem(moo, moo->curheap, size);
if (!ptr && moo->errnum == MOO_EOOMEM && !(moo->option.trait & MOO_NOGC)) if (!ptr && moo->errnum == MOO_EOOMEM && !(moo->option.trait & MOO_NOGC))
{ {
moo_gc (moo); moo_gc (moo);
@ -44,7 +44,7 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size)
(moo_oow_t)(moo->curheap->limit - moo->curheap->base), (moo_oow_t)(moo->curheap->limit - moo->curheap->base),
(moo_oow_t)(moo->curheap->limit - moo->curheap->ptr) (moo_oow_t)(moo->curheap->limit - moo->curheap->ptr)
); );
ptr = moo_allocheapmem (moo, moo->curheap, size); ptr = (moo_uint8_t*)moo_allocheapmem(moo, moo->curheap, size);
/* TODO: grow heap if ptr is still null. */ /* TODO: grow heap if ptr is still null. */
} }
@ -66,7 +66,7 @@ moo_oop_t moo_allocoopobj (moo_t* moo, moo_oow_t size)
* MOO_SIZEOF(moo_oop_t) will guarantee the starting address * MOO_SIZEOF(moo_oop_t) will guarantee the starting address
* of the allocated space to be an even number. * of the allocated space to be an even number.
* see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */ * see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */
hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned);
if (!hdr) return MOO_NULL; if (!hdr) return MOO_NULL;
hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 0); hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 0);
@ -88,7 +88,7 @@ moo_oop_t moo_allocoopobjwithtrailer (moo_t* moo, moo_oow_t size, const moo_oob_
nbytes = (size + 1) * MOO_SIZEOF(moo_oop_t) + blen; nbytes = (size + 1) * MOO_SIZEOF(moo_oop_t) + blen;
nbytes_aligned = MOO_ALIGN(nbytes, MOO_SIZEOF(moo_oop_t)); nbytes_aligned = MOO_ALIGN(nbytes, MOO_SIZEOF(moo_oop_t));
hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned);
if (!hdr) return MOO_NULL; if (!hdr) return MOO_NULL;
hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 1); hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, 0, 0, 1);
@ -128,7 +128,7 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo
if (MOO_UNLIKELY(ngc)) if (MOO_UNLIKELY(ngc))
{ {
hdr = moo_callocmem (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); hdr = (moo_oop_t)moo_callocmem(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned);
if (!hdr) return MOO_NULL; if (!hdr) return MOO_NULL;
} }
else else
@ -137,7 +137,7 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo
* MOO_SIZEOF(moo_oop_t) will guarantee the starting address * MOO_SIZEOF(moo_oop_t) will guarantee the starting address
* of the allocated space to be an even number. * of the allocated space to be an even number.
* see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */ * see MOO_OOP_IS_NUMERIC() and MOO_OOP_IS_POINTER() */
hdr = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); hdr = (moo_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned);
if (!hdr) return MOO_NULL; if (!hdr) return MOO_NULL;
} }
@ -163,22 +163,22 @@ static MOO_INLINE moo_oop_t alloc_numeric_array (moo_t* moo, const void* ptr, mo
MOO_INLINE moo_oop_t moo_alloccharobj (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len) MOO_INLINE moo_oop_t moo_alloccharobj (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len)
{ {
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_CHAR, MOO_SIZEOF(moo_ooch_t), 1, 0); return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_CHAR, MOO_SIZEOF(moo_ooch_t), 1, 0);
} }
MOO_INLINE moo_oop_t moo_allocbyteobj (moo_t* moo, const moo_oob_t* ptr, moo_oow_t len) MOO_INLINE moo_oop_t moo_allocbyteobj (moo_t* moo, const moo_oob_t* ptr, moo_oow_t len)
{ {
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_BYTE, MOO_SIZEOF(moo_oob_t), 0, 0); return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_BYTE, MOO_SIZEOF(moo_oob_t), 0, 0);
} }
MOO_INLINE moo_oop_t moo_allochalfwordobj (moo_t* moo, const moo_oohw_t* ptr, moo_oow_t len) MOO_INLINE moo_oop_t moo_allochalfwordobj (moo_t* moo, const moo_oohw_t* ptr, moo_oow_t len)
{ {
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_HALFWORD, MOO_SIZEOF(moo_oohw_t), 0, 0); return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_HALFWORD, MOO_SIZEOF(moo_oohw_t), 0, 0);
} }
MOO_INLINE moo_oop_t moo_allocwordobj (moo_t* moo, const moo_oow_t* ptr, moo_oow_t len) MOO_INLINE moo_oop_t moo_allocwordobj (moo_t* moo, const moo_oow_t* ptr, moo_oow_t len)
{ {
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0, 0); return alloc_numeric_array(moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0, 0);
} }
static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t num_flexi_fields, moo_obj_type_t* type, moo_oow_t* outlen) static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t num_flexi_fields, moo_obj_type_t* type, moo_oow_t* outlen)
@ -251,7 +251,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
/* both the fixed part(named instance variables) and /* both the fixed part(named instance variables) and
* the variable part(indexed instance variables) are allowed. */ * the variable part(indexed instance variables) are allowed. */
oop = moo_allocoopobj (moo, alloclen); oop = moo_allocoopobj(moo, alloclen);
if (oop) if (oop)
{ {
/* initialize named instance variables with default values */ /* initialize named instance variables with default values */
@ -291,19 +291,19 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
oop = moo_alloccharobj (moo, vptr, alloclen); oop = moo_alloccharobj(moo, vptr, alloclen);
break; break;
case MOO_OBJ_TYPE_BYTE: case MOO_OBJ_TYPE_BYTE:
oop = moo_allocbyteobj (moo, vptr, alloclen); oop = moo_allocbyteobj(moo, vptr, alloclen);
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
oop = moo_allochalfwordobj (moo, vptr, alloclen); oop = moo_allochalfwordobj(moo, vptr, alloclen);
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
oop = moo_allocwordobj (moo, vptr, alloclen); oop = moo_allocwordobj(moo, vptr, alloclen);
break; break;
default: default:

View File

@ -369,7 +369,7 @@ int moo_concatoocstrtosbuf (moo_t* moo, const moo_ooch_t* str, int id)
newcapa = MOO_ALIGN(p->len + len, 512); /* TODO: adjust this capacity */ newcapa = MOO_ALIGN(p->len + len, 512); /* TODO: adjust this capacity */
/* +1 to handle line ending injection more easily */ /* +1 to handle line ending injection more easily */
tmp = moo_reallocmem (moo, p->ptr, (newcapa + 1) * MOO_SIZEOF(*tmp)); tmp = (moo_ooch_t*)moo_reallocmem(moo, p->ptr, (newcapa + 1) * MOO_SIZEOF(*tmp));
if (!tmp) return -1; if (!tmp) return -1;
p->ptr = tmp; p->ptr = tmp;
@ -731,7 +731,7 @@ int moo_convbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_
/* length bound */ /* length bound */
int n; int n;
n = bcsn_to_ucsn_with_cmgr (bcs, bcslen, ucs, ucslen, moo->cmgr, 0); n = bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0);
if (n <= -1) if (n <= -1)
{ {
@ -747,7 +747,7 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_
/* length bound */ /* length bound */
int n; int n;
n = ucsn_to_bcsn_with_cmgr (ucs, ucslen, bcs, bcslen, moo->cmgr); n = ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr);
if (n <= -1) if (n <= -1)
{ {
@ -762,7 +762,7 @@ int moo_convbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_u
/* null-terminated. */ /* null-terminated. */
int n; int n;
n = bcs_to_ucs_with_cmgr (bcs, bcslen, ucs, ucslen, moo->cmgr, 0); n = bcs_to_ucs_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0);
if (n <= -1) if (n <= -1)
{ {
@ -777,7 +777,7 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
/* null-terminated */ /* null-terminated */
int n; int n;
n = ucs_to_bcs_with_cmgr (ucs, ucslen, bcs, bcslen, moo->cmgr); n = ucs_to_bcs_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr);
if (n <= -1) if (n <= -1)
{ {
@ -795,13 +795,13 @@ MOO_INLINE moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headro
moo_uch_t* ptr; moo_uch_t* ptr;
inlen = bcslen; inlen = bcslen;
if (moo_convbtouchars (moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) if (moo_convbtouchars(moo, bcs, &inlen, MOO_NULL, &outlen) <= -1)
{ {
/* note it's also an error if no full conversion is made in this function */ /* note it's also an error if no full conversion is made in this function */
return MOO_NULL; return MOO_NULL;
} }
ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_uch_t))); ptr = (moo_uch_t*)moo_allocmem(moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_uch_t)));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
inlen = bcslen; inlen = bcslen;
@ -828,13 +828,13 @@ MOO_INLINE moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headro
moo_bch_t* ptr; moo_bch_t* ptr;
inlen = ucslen; inlen = ucslen;
if (moo_convutobchars (moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) if (moo_convutobchars(moo, ucs, &inlen, MOO_NULL, &outlen) <= -1)
{ {
/* note it's also an error if no full conversion is made in this function */ /* note it's also an error if no full conversion is made in this function */
return MOO_NULL; return MOO_NULL;
} }
ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_bch_t))); ptr = (moo_bch_t*)moo_allocmem(moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_bch_t)));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
inlen = ucslen; inlen = ucslen;
@ -859,14 +859,14 @@ MOO_INLINE moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroo
moo_oow_t inlen, outlen; moo_oow_t inlen, outlen;
moo_uch_t* ptr; moo_uch_t* ptr;
if (moo_convbtoucstr (moo, bcs, &inlen, MOO_NULL, &outlen) <= -1) if (moo_convbtoucstr(moo, bcs, &inlen, MOO_NULL, &outlen) <= -1)
{ {
/* note it's also an error if no full conversion is made in this function */ /* note it's also an error if no full conversion is made in this function */
return MOO_NULL; return MOO_NULL;
} }
outlen++; outlen++;
ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_uch_t))); ptr = (moo_uch_t*)moo_allocmem(moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_uch_t)));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
moo_convbtoucstr (moo, bcs, &inlen, ptr, &outlen); moo_convbtoucstr (moo, bcs, &inlen, ptr, &outlen);
@ -884,14 +884,14 @@ MOO_INLINE moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroo
moo_oow_t inlen, outlen; moo_oow_t inlen, outlen;
moo_bch_t* ptr; moo_bch_t* ptr;
if (moo_convutobcstr (moo, ucs, &inlen, MOO_NULL, &outlen) <= -1) if (moo_convutobcstr(moo, ucs, &inlen, MOO_NULL, &outlen) <= -1)
{ {
/* note it's also an error if no full conversion is made in this function */ /* note it's also an error if no full conversion is made in this function */
return MOO_NULL; return MOO_NULL;
} }
outlen++; outlen++;
ptr = moo_allocmem (moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_bch_t))); ptr = (moo_bch_t*)moo_allocmem(moo, headroom_bytes + (outlen * MOO_SIZEOF(moo_bch_t)));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
ptr = (moo_bch_t*)((moo_oob_t*)ptr + headroom_bytes); ptr = (moo_bch_t*)((moo_oob_t*)ptr + headroom_bytes);
@ -911,7 +911,7 @@ moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen)
{ {
moo_uch_t* ptr; moo_uch_t* ptr;
ptr = moo_allocmem (moo, (ucslen + 1) * MOO_SIZEOF(moo_uch_t)); ptr = (moo_uch_t*)moo_allocmem(moo, (ucslen + 1) * MOO_SIZEOF(moo_uch_t));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
moo_copyuchars (ptr, ucs, ucslen); moo_copyuchars (ptr, ucs, ucslen);
@ -923,7 +923,7 @@ moo_bch_t* moo_dupbchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen)
{ {
moo_bch_t* ptr; moo_bch_t* ptr;
ptr = moo_allocmem (moo, (bcslen + 1) * MOO_SIZEOF(moo_bch_t)); ptr = (moo_bch_t*)moo_allocmem(moo, (bcslen + 1) * MOO_SIZEOF(moo_bch_t));
if (!ptr) return MOO_NULL; if (!ptr) return MOO_NULL;
moo_copybchars (ptr, bcs, bcslen); moo_copybchars (ptr, bcs, bcslen);