added MOO_OBJ_GET_XXX_SLOT() macros
This commit is contained in:
parent
750f529201
commit
79198df35b
@ -413,6 +413,12 @@ struct moo_obj_word_t
|
|||||||
moo_oow_t slot[1];
|
moo_oow_t slot[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MOO_OBJ_GET_OOP_SLOT(oop) (((moo_oop_oop_t)(oop))->slot)
|
||||||
|
#define MOO_OBJ_GET_CHAR_SLOT(oop) (((moo_oop_char_t)(oop))->slot)
|
||||||
|
#define MOO_OBJ_GET_BYTE_SLOT(oop) (((moo_oop_byte_t)(oop))->slot)
|
||||||
|
#define MOO_OBJ_GET_HALFWORD_SLOT(oop) (((moo_oop_halfword_t)(oop))->slot)
|
||||||
|
#define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot)
|
||||||
|
|
||||||
typedef struct moo_trailer_t moo_trailer_t;
|
typedef struct moo_trailer_t moo_trailer_t;
|
||||||
struct moo_trailer_t
|
struct moo_trailer_t
|
||||||
{
|
{
|
||||||
@ -420,6 +426,7 @@ struct moo_trailer_t
|
|||||||
moo_oob_t slot[1];
|
moo_oob_t slot[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define MOO_SET_NAMED_INSTVARS 2
|
#define MOO_SET_NAMED_INSTVARS 2
|
||||||
typedef struct moo_set_t moo_set_t;
|
typedef struct moo_set_t moo_set_t;
|
||||||
typedef struct moo_set_t* moo_oop_set_t;
|
typedef struct moo_set_t* moo_oop_set_t;
|
||||||
|
@ -243,11 +243,12 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_ooi_t nargs)
|
|||||||
/* TOOD: check if arg is a string. */
|
/* TOOD: check if arg is a string. */
|
||||||
/* TODO: free all duplicated strings after call */
|
/* TODO: free all duplicated strings after call */
|
||||||
#if defined(MOO_OOCH_IS_UCH)
|
#if defined(MOO_OOCH_IS_UCH)
|
||||||
ptr = moo_dupootobchars (moo, ((moo_oop_char_t)arg)->slot, MOO_OBJ_GET_SIZE(arg), MOO_NULL);
|
ptr = moo_dupootobchars (moo, 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 */
|
|
||||||
#else
|
#else
|
||||||
ptr = moo_dupoochars (moo, ((moo_oop_char_t)arg)->slot, MOO_OBJ_GET_SIZE(arg));
|
ptr = MOO_OBJ_GET_CHAR_SLOT(arg);
|
||||||
|
/*ptr = moo_dupoochars (moo, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg));*/
|
||||||
#endif
|
#endif
|
||||||
|
if (!ptr) goto softfail; /* out of system memory or conversion error - soft failure */
|
||||||
|
|
||||||
dcArgPointer (dc, ptr);
|
dcArgPointer (dc, ptr);
|
||||||
j++;
|
j++;
|
||||||
@ -259,11 +260,12 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_ooi_t nargs)
|
|||||||
moo_uch_t* ptr;
|
moo_uch_t* ptr;
|
||||||
|
|
||||||
#if defined(MOO_OOCH_IS_UCH)
|
#if defined(MOO_OOCH_IS_UCH)
|
||||||
ptr = moo_dupoochars (moo, ((moo_oop_char_t)arg)->slot, MOO_OBJ_GET_SIZE(arg));
|
ptr = MOO_OBJ_GET_CHAR_SLOT(arg);
|
||||||
|
/*ptr = moo_dupoochars (moo, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg));*/
|
||||||
#else
|
#else
|
||||||
ptr = moo_dupootouchars (moo, ((moo_oop_char_t)arg)->slot, MOO_OBJ_GET_SIZE(arg), MOO_NULL);
|
ptr = moo_dupootouchars (moo, 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 */
|
|
||||||
#endif
|
#endif
|
||||||
|
if (!ptr) goto softfail; /* out of system memory or conversion error - soft failure */
|
||||||
|
|
||||||
dcArgPointer (dc, ptr);
|
dcArgPointer (dc, ptr);
|
||||||
j++;
|
j++;
|
||||||
|
@ -69,12 +69,12 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
|
|||||||
#if defined(MOO_OOCH_IS_UCH)
|
#if defined(MOO_OOCH_IS_UCH)
|
||||||
ucslen = MOO_OBJ_GET_SIZE(name);
|
ucslen = MOO_OBJ_GET_SIZE(name);
|
||||||
bcslen = MOO_COUNTOF(namebuf) - 1;
|
bcslen = MOO_COUNTOF(namebuf) - 1;
|
||||||
if (moo_convootobchars (moo, name->slot, &ucslen, namebuf, &bcslen) <= -1) goto reterr;
|
if (moo_convootobchars (moo, name->slot, &ucslen, namebuf, &bcslen) <= -1) goto softfail;
|
||||||
namebuf[bcslen] = '\0';
|
namebuf[bcslen] = '\0';
|
||||||
|
|
||||||
ucslen = MOO_OBJ_GET_SIZE(mode);
|
ucslen = MOO_OBJ_GET_SIZE(mode);
|
||||||
bcslen = MOO_COUNTOF(modebuf) - 1;
|
bcslen = MOO_COUNTOF(modebuf) - 1;
|
||||||
if (moo_convootobchars (moo, mode->slot, &ucslen, modebuf, &bcslen) <= -1) goto reterr;
|
if (moo_convootobchars (moo, mode->slot, &ucslen, modebuf, &bcslen) <= -1) goto softfail;
|
||||||
modebuf[bcslen] = '\0';
|
modebuf[bcslen] = '\0';
|
||||||
|
|
||||||
rcv->fp = fopen (namebuf, modebuf);
|
rcv->fp = fopen (namebuf, modebuf);
|
||||||
@ -84,13 +84,13 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
|
|||||||
if (!rcv->fp)
|
if (!rcv->fp)
|
||||||
{
|
{
|
||||||
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
|
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
|
||||||
goto reterr;
|
goto softfail;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOO_STACK_SETRETTORCV (moo, nargs);
|
MOO_STACK_SETRETTORCV (moo, nargs);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
|
|
||||||
reterr:
|
softfail:
|
||||||
MOO_STACK_SETRETTOERROR (moo, nargs);
|
MOO_STACK_SETRETTOERROR (moo, nargs);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -159,13 +159,13 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
|
|||||||
/* TODO: implement character conversion into stdio and use it instead of vm's conversion facility. */
|
/* 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, &x->slot[ucspos], &ucslen, bcs, &bcslen)) <= -1)
|
||||||
{
|
{
|
||||||
if (n != -2 || ucslen <= 0) goto reterr;
|
if (n != -2 || ucslen <= 0) goto softfail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite (bcs, 1, bcslen, rcv->fp) < bcslen)
|
if (fwrite (bcs, 1, bcslen, rcv->fp) < bcslen)
|
||||||
{
|
{
|
||||||
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
|
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
|
||||||
goto reterr;
|
goto softfail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: abort looping for async processing???? */
|
/* TODO: abort looping for async processing???? */
|
||||||
@ -176,14 +176,14 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
moo_seterrnum (moo, MOO_EINVAL);
|
moo_seterrnum (moo, MOO_EINVAL);
|
||||||
goto reterr;
|
goto softfail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MOO_STACK_SETRETTORCV (moo, nargs);
|
MOO_STACK_SETRETTORCV (moo, nargs);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
|
|
||||||
reterr:
|
softfail:
|
||||||
MOO_STACK_SETRETTOERROR (moo, nargs);
|
MOO_STACK_SETRETTOERROR (moo, nargs);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user