diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 8eca9c8..3718bc1 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -2780,7 +2780,7 @@ static int add_string_literal (moo_t* moo, const moo_oocs_t* str, moo_oow_t* ind if (MOO_CLASSOF(moo, lit) == moo->_string && MOO_OBJ_GET_SIZE(lit) == str->len && - moo_equal_oochars(((moo_oop_char_t)lit)->slot, str->ptr, str->len)) + moo_equal_oochars(MOO_OBJ_GET_CHAR_SLOT(lit), str->ptr, str->len)) { *index = i; return 0; @@ -2958,7 +2958,7 @@ static moo_ooi_t find_class_level_variable (moo_t* moo, moo_oop_class_t self, co for (index = VAR_INSTANCE; index <= VAR_CLASS; index++) { v = vv[index]; - hs.ptr = v->slot; + hs.ptr = MOO_OBJ_GET_CHAR_SLOT(v); hs.len = MOO_OBJ_GET_SIZE(v); if (find_word_in_string(&hs, name, &pos) >= 0) @@ -3008,7 +3008,7 @@ static moo_ooi_t find_class_level_variable (moo_t* moo, moo_oop_class_t self, co for (index = VAR_INSTANCE; index <= VAR_CLASS; index++) { v = vv[index]; - hs.ptr = v->slot; + hs.ptr = MOO_OBJ_GET_CHAR_SLOT(v); hs.len = MOO_OBJ_GET_SIZE(v); if (find_word_in_string(&hs, name, &pos) >= 0) @@ -4850,10 +4850,9 @@ static int read_array_literal (moo_t* moo, int rdonly, moo_oop_t* xlit) for (i = saved_arlit_count, j = 0; i < moo->c->arlit.count; i++, j++) { - ((moo_oop_oop_t)a)->slot[j] = moo->c->arlit.ptr[i]; + MOO_STORE_OOP (moo, &((moo_oop_oop_t)a)->slot[j], moo->c->arlit.ptr[i]); } - if (rdonly) { MOO_ASSERT (moo, MOO_OOP_IS_POINTER(a)); @@ -6476,7 +6475,7 @@ static int add_compiled_method (moo_t* moo) for (i = 0; i < cc->mth.literals.count; i++) { /* let's do the variadic data initialization here */ - mth->slot[i] = cc->mth.literals.ptr[i]; + MOO_STORE_OOP (moo, &mth->slot[i], cc->mth.literals.ptr[i]); } moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++; @@ -7233,7 +7232,7 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type) * initv_count is 1 whereas total_count is 3. */ MOO_ASSERT (moo, initv_count <= cc->var[var_type].total_count); - tmp = moo_instantiate (moo, moo->_array, MOO_NULL, cc->var[var_type].total_count); + tmp = moo_instantiate(moo, moo->_array, MOO_NULL, cc->var[var_type].total_count); if (!tmp) return -1; if (super_initv_count > 0) @@ -7250,7 +7249,7 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type) MOO_ASSERT (moo, MOO_CLASSOF(moo, initv) == moo->_array); for (i = 0; i < super_initv_count; i++) { - if (initv->slot[i]) ((moo_oop_oop_t)tmp)->slot[j] = initv->slot[i]; + if (initv->slot[i]) MOO_STORE_OOP (moo, &((moo_oop_oop_t)tmp)->slot[j], initv->slot[i]); j++; } } @@ -7263,7 +7262,7 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type) for (i = 0; i < cc->var[var_type].initv_count; i++) { if (cc->var[var_type].initv[i].v) - ((moo_oop_oop_t)tmp)->slot[j] = cc->var[var_type].initv[i].v; + MOO_STORE_OOP (moo, &((moo_oop_oop_t)tmp)->slot[j], cc->var[var_type].initv[i].v); j++; } @@ -7408,7 +7407,7 @@ static int make_defined_class (moo_t* moo) for (i = 0; i < initv_count; i++) { - cc->self_oop->slot[i] = initv->slot[i]; + MOO_STORE_OOP (moo, &cc->self_oop->slot[i], initv->slot[i]); } } @@ -7426,7 +7425,7 @@ static int make_defined_class (moo_t* moo) MOO_ASSERT (moo, MOO_CLASS_NAMED_INSTVARS + j + initv_count <= MOO_OBJ_GET_SIZE(cc->self_oop)); for (i = 0; i < initv_count; i++) { - cc->self_oop->slot[j] = cc->var[VAR_CLASS].initv[i].v; + MOO_STORE_OOP (moo, &cc->self_oop->slot[j], cc->var[VAR_CLASS].initv[i].v); j++; } } @@ -8144,8 +8143,8 @@ static int __compile_class_definition (moo_t* moo, int class_type) MOO_ASSERT (moo, MOO_CLASSOF(moo, pds) == moo->_string); - ptr = pds->slot; - end = pds->slot + MOO_OBJ_GET_SIZE(pds); + ptr = MOO_OBJ_GET_CHAR_SLOT(pds); + end = ptr + MOO_OBJ_GET_SIZE(pds); /* this loop handles the pooldic string as if it's a pooldic import. * see compile_class_level_variables() for mostly identical code except token handling */ diff --git a/moo/lib/debug.c b/moo/lib/debug.c index f57ef92..3729a7a 100644 --- a/moo/lib/debug.c +++ b/moo/lib/debug.c @@ -37,7 +37,7 @@ void moo_dumpsymtab (moo_t* moo) for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++) { - symbol = (moo_oop_char_t)moo->symtab->bucket->slot[i]; + symbol = (moo_oop_char_t)MOO_OBJ_GET_OOP_VAL(moo->symtab->bucket, i); if ((moo_oop_t)symbol != moo->_nil) { MOO_DEBUG2 (moo, " %07zu %O\n", i, symbol); @@ -58,7 +58,7 @@ void moo_dumpdic (moo_t* moo, moo_oop_dic_t dic, const moo_bch_t* title) for (i = 0; i < MOO_OBJ_GET_SIZE(dic->bucket); i++) { - ass = (moo_oop_association_t)dic->bucket->slot[i]; + ass = (moo_oop_association_t)MOO_OBJ_GET_OOP_VAL(dic->bucket, i); if ((moo_oop_t)ass != moo->_nil) { MOO_DEBUG2 (moo, " %07zu %O\n", i, ass->key); diff --git a/moo/lib/decode.c b/moo/lib/decode.c index dacd45d..952f96c 100644 --- a/moo/lib/decode.c +++ b/moo/lib/decode.c @@ -604,9 +604,8 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn) /* print literal frame contents */ for (ip = 0; ip < MOO_OBJ_GET_SIZE(mth) - MOO_METHOD_NAMED_INSTVARS; ip++) { - MOO_LOG2(moo, DECODE_LOG_MASK, " @%-5zd %O\n", ip, mth->slot[ip]); + MOO_LOG2(moo, DECODE_LOG_MASK, " @%-5zd %O\n", ip, MOO_OBJ_GET_OOP_VAL(mth, ip)); } return 0; } - diff --git a/moo/lib/exec.c b/moo/lib/exec.c index fcfbeff..9ce6352 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -1914,7 +1914,7 @@ static void log_char_object (moo_t* moo, moo_bitmask_t mask, moo_oop_char_t msg) MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(msg) == MOO_OBJ_TYPE_CHAR); rem = MOO_OBJ_GET_SIZE(msg); - ptr = msg->slot; + ptr = MOO_OBJ_GET_CHAR_SLOT(msg); start_over: while (rem > 0) @@ -3458,7 +3458,7 @@ static moo_pfrc_t pf_system_log (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) for (i = 0; i < MOO_OBJ_GET_SIZE(msg); i++) { - inner = ((moo_oop_oop_t)msg)->slot[i]; + inner = MOO_OBJ_GET_OOP_VAL(msg, i); if (i > 0) moo_logbfmt (moo, mask, " "); if (MOO_OOP_IS_POINTER(inner) && diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 0a15bc4..684f3b8 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -500,28 +500,26 @@ struct moo_obj_word_t #define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot) #define MOO_OBJ_GET_LIWORD_SLOT(oop) (((moo_oop_liword_t)(oop))->slot) -#if 0 -#define MOO_OBJ_GET_OOP_SLOT_PTR(oop,idx) (&(((moo_oop_oop_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_CHAR_SLOT_PTR(oop,idx) (&(((moo_oop_char_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_BYTE_SLOT_PTR(oop,idx) (&(((moo_oop_byte_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_HALFWORD_SLOT_PTR(oop,idx) (&(((moo_oop_halfword_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_WORD_SLOT_PTR(oop,idx) (&(((moo_oop_word_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_LIWORD_SLOT_PTR(oop,idx) (&(((moo_oop_liword_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_OOP_PTR(oop,idx) (&(((moo_oop_oop_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_CHAR_PTR(oop,idx) (&(((moo_oop_char_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_BYTE_PTR(oop,idx) (&(((moo_oop_byte_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_HALFWORD_PTR(oop,idx) (&(((moo_oop_halfword_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_WORD_PTR(oop,idx) (&(((moo_oop_word_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_LIWORD_PTR(oop,idx) (&(((moo_oop_liword_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_OOP_SLOT_VAL(oop,idx) ((((moo_oop_oop_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_CHAR_SLOT_VAL(oop,idx) ((((moo_oop_char_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_BYTE_SLOT_VAL(oop,idx) ((((moo_oop_byte_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_HALFWORD_SLOT_VAL(oop,idx) ((((moo_oop_halfword_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_WORD_SLOT_VAL(oop,idx) ((((moo_oop_word_t)(oop))->slot)[idx]) -#define MOO_OBJ_GET_LIWORD_SLOT_VAL(oop,idx) ((((moo_oop_liword_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_OOP_VAL(oop,idx) ((((moo_oop_oop_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_CHAR_VAL(oop,idx) ((((moo_oop_char_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_BYTE_VAL(oop,idx) ((((moo_oop_byte_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_HALFWORD_VAL(oop,idx) ((((moo_oop_halfword_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_WORD_VAL(oop,idx) ((((moo_oop_word_t)(oop))->slot)[idx]) +#define MOO_OBJ_GET_LIWORD_VAL(oop,idx) ((((moo_oop_liword_t)(oop))->slot)[idx]) -/*#define MOO_OBJ_SET_OOP_SLOT_VAL(oop,idx,val) ((((moo_oop_oop_t)(oop))->slot)[idx] = (val)) - I must use MOO_STORE_OOP() instead.*/ -#define MOO_OBJ_SET_CHAR_SLOT_VAL(oop,idx,val) ((((moo_oop_char_t)(oop))->slot)[idx] = (val)) -#define MOO_OBJ_SET_BYTE_SLOT_VAL(oop,idx,val) ((((moo_oop_byte_t)(oop))->slot)[idx] = (val)) -#define MOO_OBJ_SET_HALFWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_halfword_t)(oop))->slot)[idx] = (val)) -#define MOO_OBJ_SET_WORD_SLOT_VAL(oop,idx,val) ((((moo_oop_word_t)(oop))->slot)[idx] = (val)) -#define MOO_OBJ_SET_LIWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_liword_t)(oop))->slot)[idx] = (val)) -#endif +/*#define MOO_OBJ_SET_OOP_VAL(oop,idx,val) ((((moo_oop_oop_t)(oop))->slot)[idx] = (val)) - I must use MOO_STORE_OOP() instead.*/ +#define MOO_OBJ_SET_CHAR_VAL(oop,idx,val) ((((moo_oop_char_t)(oop))->slot)[idx] = (val)) +#define MOO_OBJ_SET_BYTE_VAL(oop,idx,val) ((((moo_oop_byte_t)(oop))->slot)[idx] = (val)) +#define MOO_OBJ_SET_HALFWORD_VAL(oop,idx,val) ((((moo_oop_halfword_t)(oop))->slot)[idx] = (val)) +#define MOO_OBJ_SET_WORD_VAL(oop,idx,val) ((((moo_oop_word_t)(oop))->slot)[idx] = (val)) +#define MOO_OBJ_SET_LIWORD_VAL(oop,idx,val) ((((moo_oop_liword_t)(oop))->slot)[idx] = (val)) typedef struct moo_trailer_t moo_trailer_t; struct moo_trailer_t diff --git a/moo/lib/pf-basic.c b/moo/lib/pf-basic.c index aa5a738..86d2e0e 100644 --- a/moo/lib/pf-basic.c +++ b/moo/lib/pf-basic.c @@ -142,7 +142,7 @@ static int _equal_objects (moo_t* moo, moo_oop_t rcv, moo_oop_t arg) /* NOTE: even if the object implements the equality method, * this primitive method doesn't honor it. */ - n = _equal_objects(moo, ((moo_oop_oop_t)rcv)->slot[i], ((moo_oop_oop_t)arg)->slot[i]); + n = _equal_objects(moo, MOO_OBJ_GET_OOP_VAL(rcv, i), MOO_OBJ_GET_OOP_VAL(arg, i)); if (n <= 0) return n; } @@ -326,25 +326,25 @@ moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) switch (MOO_OBJ_GET_FLAGS_TYPE(rcv)) { case MOO_OBJ_TYPE_BYTE: - v = MOO_SMOOI_TO_OOP(((moo_oop_byte_t)rcv)->slot[idx]); + v = MOO_SMOOI_TO_OOP(MOO_OBJ_GET_BYTE_VAL(rcv, idx)); break; case MOO_OBJ_TYPE_CHAR: - v = MOO_CHAR_TO_OOP(((moo_oop_char_t)rcv)->slot[idx]); + v = MOO_CHAR_TO_OOP(MOO_OBJ_GET_CHAR_VAL(rcv, idx)); break; case MOO_OBJ_TYPE_HALFWORD: /* TODO: LargeInteger if the halfword is too large */ - v = MOO_SMOOI_TO_OOP(((moo_oop_halfword_t)rcv)->slot[idx]); + v = MOO_SMOOI_TO_OOP(MOO_OBJ_GET_HALFWORD_VAL(rcv, idx)); break; case MOO_OBJ_TYPE_WORD: - v = moo_oowtoint (moo, ((moo_oop_word_t)rcv)->slot[idx]); + v = moo_oowtoint(moo, MOO_OBJ_GET_WORD_VAL(rcv, idx)); if (!v) return MOO_PF_FAILURE; break; case MOO_OBJ_TYPE_OOP: - v = ((moo_oop_oop_t)rcv)->slot[idx]; + v = MOO_OBJ_GET_OOP_VAL(rcv, idx); break; default: @@ -402,7 +402,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) return MOO_PF_FAILURE; } /* TOOD: must I check the range of the value? */ - ((moo_oop_byte_t)rcv)->slot[idx] = MOO_OOP_TO_SMOOI(val); + MOO_OBJ_SET_BYTE_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val)); break; case MOO_OBJ_TYPE_CHAR: @@ -411,7 +411,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) moo_seterrbfmt (moo, MOO_EINVAL, "value not a character - %O", val); return MOO_PF_FAILURE; } - ((moo_oop_char_t)rcv)->slot[idx] = MOO_OOP_TO_CHAR(val); + MOO_OBJ_SET_CHAR_VAL (rcv, idx, MOO_OOP_TO_CHAR(val)); break; case MOO_OBJ_TYPE_HALFWORD: @@ -423,7 +423,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) } /* if the small integer is too large, it will get truncated */ - ((moo_oop_halfword_t)rcv)->slot[idx] = MOO_OOP_TO_SMOOI(val); + MOO_OBJ_SET_HALFWORD_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val)); break; case MOO_OBJ_TYPE_WORD: @@ -436,7 +436,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) moo_seterrbfmt (moo, MOO_EINVAL, "value not a word integer - %O", val); return MOO_PF_FAILURE; } - ((moo_oop_word_t)rcv)->slot[idx] = w; + MOO_OBJ_SET_WORD_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val)); break; } @@ -515,29 +515,29 @@ moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { case MOO_OBJ_TYPE_BYTE: if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value; - for (i = sidx; i < end; i++) ((moo_oop_byte_t)rcv)->slot[i] = MOO_OOP_TO_SMOOI(dval); + for (i = sidx; i < end; i++) MOO_OBJ_SET_BYTE_VAL (rcv, i, MOO_OOP_TO_SMOOI(dval)); break; case MOO_OBJ_TYPE_CHAR: if (!MOO_OOP_IS_CHAR(dval)) goto invalid_fill_value; - for (i = sidx; i < end; i++) ((moo_oop_char_t)rcv)->slot[i] = MOO_OOP_TO_CHAR(dval); + for (i = sidx; i < end; i++) MOO_OBJ_SET_CHAR_VAL (rcv, i, MOO_OOP_TO_CHAR(dval)); break; case MOO_OBJ_TYPE_HALFWORD: if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value; - for (i = sidx; i < end; i++) ((moo_oop_halfword_t)rcv)->slot[i] = MOO_OOP_TO_SMOOI(dval); + for (i = sidx; i < end; i++) MOO_OBJ_SET_HALFWORD_VAL (rcv, i, MOO_OOP_TO_SMOOI(dval)); break; case MOO_OBJ_TYPE_WORD: { moo_oow_t dw; if (moo_inttooow(moo, dval, &dw) <= 0) goto invalid_fill_value; - for (i = sidx; i < end; i++) ((moo_oop_word_t)rcv)->slot[i] = dw; + for (i = sidx; i < end; i++) MOO_OBJ_SET_WORD_VAL (rcv, i, dw); break; } case MOO_OBJ_TYPE_OOP: - for (i = sidx; i < end; i++) ((moo_oop_oop_t)rcv)->slot[i] = dval; + for (i = sidx; i < end; i++) MOO_STORE_OOP (moo, &((moo_oop_oop_t)rcv)->slot[i], dval); break; default: @@ -645,19 +645,19 @@ moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) switch (MOO_OBJ_GET_FLAGS_TYPE(rcv)) { case MOO_OBJ_TYPE_BYTE: - MOO_MEMMOVE (&((moo_oop_byte_t)rcv)->slot[didx], - &((moo_oop_byte_t)rcv)->slot[sidx], - ssz * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); + MOO_MEMMOVE (MOO_OBJ_GET_BYTE_PTR(rcv, didx), + MOO_OBJ_GET_BYTE_PTR(rcv, sidx), + ssz * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0))); if (didx > sidx) { - MOO_MEMSET (&((moo_oop_byte_t)rcv)->slot[sidx], 0, - (didx - sidx) * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_BYTE_PTR(rcv, sidx), 0, + (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0))); } else { - MOO_MEMSET (&((moo_oop_byte_t)rcv)->slot[didx + ssz - 1], 0, - (sidx - didx) * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_BYTE_PTR(rcv, didx + ssz - 1), 0, + (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0))); } break; diff --git a/moo/lib/pf-sys.c b/moo/lib/pf-sys.c index 8cde53c..a09eacd 100644 --- a/moo/lib/pf-sys.c +++ b/moo/lib/pf-sys.c @@ -622,7 +622,7 @@ moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (len_in_buffer > 0) { - MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer); + MOO_MEMCPY (MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), &rawptr[offset], len_in_buffer); } MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); @@ -685,7 +685,7 @@ moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (len_in_buffer > 0) { - MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer); + MOO_MEMCPY (&rawptr[offset], MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), len_in_buffer); } MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); @@ -941,7 +941,7 @@ moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (len_in_buffer > 0) { - MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer); + MOO_MEMCPY (MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), &rawptr[offset], len_in_buffer); } MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); @@ -999,7 +999,7 @@ moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (len_in_buffer > 0) { - MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer); + MOO_MEMCPY (&rawptr[offset], MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), len_in_buffer); } MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); diff --git a/moo/mod/ffi.c b/moo/mod/ffi.c index 6859ee8..cb53b67 100644 --- a/moo/mod/ffi.c +++ b/moo/mod/ffi.c @@ -203,7 +203,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) dcReset (ffi->dc); i = 0; - if (i < MOO_OBJ_GET_SIZE(sig) && MOO_OBJ_GET_CHAR_SLOT(sig)[i] == '|') + if (i < MOO_OBJ_GET_SIZE(sig) && MOO_OBJ_GET_CHAR_VAL(sig, i) == '|') { dcMode (ffi->dc, DC_CALL_C_ELLIPSIS); @@ -219,7 +219,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) moo_ooch_t fmtc; moo_oop_t arg; - fmtc = MOO_OBJ_GET_CHAR_SLOT(sig)[i]; + fmtc = MOO_OBJ_GET_CHAR_VAL(sig, i); if (fmtc == ')') { @@ -325,7 +325,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) /*ptr = moo_dupoochars (moo, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg)); if (!ptr) goto softfail; */ /* out of system memory or conversion error - soft failure */ #else - ptr = moo_dupootoucharswithheadroom (moo, MOO_SIZEOF_VOID_P, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg), MOO_NULL); + ptr = moo_dupootoucharswithheadroom(moo, MOO_SIZEOF_VOID_P, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg), MOO_NULL); if (!ptr) goto softfail; /* out of system memory or conversion error - soft failure */ link_ca (ffi, ptr); #endif @@ -343,7 +343,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (i >= MOO_OBJ_GET_SIZE(sig)) goto call_void; - switch (((moo_oop_char_t)sig)->slot[i]) + switch (MOO_OBJ_GET_CHAR_VAL(sig, i)) { /* TODO: support more types... */ /* TODO: proper return value conversion */ @@ -358,7 +358,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { moo_oop_t r; - r = moo_ooitoint (moo, dcCallInt (ffi->dc, f)); + r = moo_ooitoint (moo, dcCallInt(ffi->dc, f)); if (!r) goto hardfail; MOO_STACK_SETRET (moo, nargs, r); break; @@ -379,7 +379,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) #if (MOO_SIZEOF_LONG_LONG > 0) moo_oop_t r; # if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_OOI_T) - r = moo_ooitoint (moo, dcCallLongLong (ffi->dc, f)); + r = moo_ooitoint (moo, dcCallLongLong(ffi->dc, f)); # else # error UNSUPPORTED MOO_SIZEOF_LONG_LONG # endif diff --git a/moo/mod/sck.c b/moo/mod/sck.c index d3a346f..f60c8e2 100644 --- a/moo/mod/sck.c +++ b/moo/mod/sck.c @@ -481,7 +481,7 @@ static moo_pfrc_t pf_read_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (length > maxlen - offset) length = maxlen - offset; } - n = recv(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); + n = recv(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0); if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) { moo_seterrwithsyserr (moo, 0, errno); @@ -554,7 +554,7 @@ static moo_pfrc_t pf_write_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (length > maxlen - offset) length = maxlen - offset; } - n = send(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); + n = send(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0); if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) { moo_seterrwithsyserr (moo, 0, errno); diff --git a/moo/mod/stdio.c b/moo/mod/stdio.c index b96d973..257c7d3 100644 --- a/moo/mod/stdio.c +++ b/moo/mod/stdio.c @@ -61,17 +61,17 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) #if defined(MOO_OOCH_IS_UCH) ucslen = MOO_OBJ_GET_SIZE(name); bcslen = MOO_COUNTOF(namebuf) - 1; - if (moo_convootobchars (moo, name->slot, &ucslen, namebuf, &bcslen) <= -1) goto softfail; + if (moo_convootobchars(moo, MOO_OBJ_GET_CHAR_SLOT(name), &ucslen, namebuf, &bcslen) <= -1) goto softfail; namebuf[bcslen] = '\0'; ucslen = MOO_OBJ_GET_SIZE(mode); bcslen = MOO_COUNTOF(modebuf) - 1; - if (moo_convootobchars (moo, mode->slot, &ucslen, modebuf, &bcslen) <= -1) goto softfail; + if (moo_convootobchars(moo, MOO_OBJ_GET_CHAR_SLOT(mode), &ucslen, modebuf, &bcslen) <= -1) goto softfail; modebuf[bcslen] = '\0'; stdio->fp = fopen (namebuf, modebuf); #else - stdio->fp = fopen (name->slot, mode->slot); + stdio->fp = fopen (MOO_OBJ_GET_CHAR_SLOT(name), MOO_OBJ_GET_CHAR_SLOT(mode)); #endif if (!stdio->fp) { @@ -150,7 +150,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit) bcslen = MOO_COUNTOF(bcs); /* TODO: implement character conversion into stdio and use it instead of vm's conversion facility. */ - if ((n = moo_convootobchars (moo, &x->slot[ucspos], &ucslen, bcs, &bcslen)) <= -1) + if ((n = moo_convootobchars (moo, MOO_OBJ_GET_CHAR_PTR(x, ucspos), &ucslen, bcs, &bcslen)) <= -1) { if (n != -2 || ucslen <= 0) goto softfail; } @@ -167,7 +167,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit) } #else puts_string: - if (fwrite (x->slot, 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x)) + if (fwrite (MOO_OBJ_GET_CHAR_SLOT(x), 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x)) { moo_seterrwithsyserr (moo, 0, errno); goto softfail;