working on mod-ffi
This commit is contained in:
parent
5b6347b0a9
commit
12e50d46d7
@ -48,7 +48,7 @@ void* hawk_gem_reallocmem (hawk_gem_t* gem, void* ptr, hawk_oow_t size)
|
||||
return nptr;
|
||||
}
|
||||
|
||||
void* hawk_gem_callocmem_noerr (hawk_gem_t* gem, hawk_oow_t size)
|
||||
void* hawk_gem_callocmem_noseterr (hawk_gem_t* gem, hawk_oow_t size)
|
||||
{
|
||||
void* ptr = HAWK_MMGR_ALLOC(gem->mmgr, size);
|
||||
if (ptr) HAWK_MEMSET (ptr, 0, size);
|
||||
|
@ -82,11 +82,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE void* hawk_gem_allocmem_noerr (hawk_gem_t* gem, hawk_oow_t size) { return HAWK_MMGR_ALLOC(gem->mmgr, size); }
|
||||
static HAWK_INLINE void* hawk_gem_reallocmem_noerr (hawk_gem_t* gem, void* ptr, hawk_oow_t size) { return HAWK_MMGR_REALLOC(gem->mmgr, ptr, size); }
|
||||
static HAWK_INLINE void* hawk_gem_allocmem_noseterr (hawk_gem_t* gem, hawk_oow_t size) { return HAWK_MMGR_ALLOC(gem->mmgr, size); }
|
||||
static HAWK_INLINE void* hawk_gem_reallocmem_noseterr (hawk_gem_t* gem, void* ptr, hawk_oow_t size) { return HAWK_MMGR_REALLOC(gem->mmgr, ptr, size); }
|
||||
#else
|
||||
#define hawk_gem_allocmem_noerr(gem, size) (HAWK_MMGR_ALLOC((gem)->mmgr, size))
|
||||
#define hawk_gem_reallocmem_noerr(gem, ptr, size) (HAWK_MMGR_REALLOC((gem)->mmgr, ptr, size))
|
||||
#define hawk_gem_allocmem_noseterr(gem, size) (HAWK_MMGR_ALLOC((gem)->mmgr, size))
|
||||
#define hawk_gem_reallocmem_noseterr(gem, ptr, size) (HAWK_MMGR_REALLOC((gem)->mmgr, ptr, size))
|
||||
#endif
|
||||
|
||||
HAWK_EXPORT void* hawk_gem_allocmem (
|
||||
@ -112,7 +112,7 @@ static HAWK_INLINE void hawk_gem_freemem (hawk_gem_t* gem, void* ptr) { HAWK_MMG
|
||||
#endif
|
||||
|
||||
|
||||
void* hawk_gem_callocmem_noerr (
|
||||
void* hawk_gem_callocmem_noseterr (
|
||||
hawk_gem_t* gem,
|
||||
hawk_oow_t size
|
||||
);
|
||||
|
@ -613,7 +613,7 @@ int hawk_buildrex (hawk_t* hawk, const hawk_ooch_t* ptn, hawk_oow_t len, hawk_tr
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int hawk_findmodsymfnc_noerr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
int hawk_findmodsymfnc_noseterr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -637,7 +637,7 @@ int hawk_findmodsymfnc_noerr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow
|
||||
}
|
||||
|
||||
|
||||
int hawk_findmodsymint_noerr (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
int hawk_findmodsymint_noseterr (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -660,7 +660,7 @@ int hawk_findmodsymint_noerr (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow
|
||||
return -1;
|
||||
}
|
||||
|
||||
int hawk_findmodsymflt_noerr (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
int hawk_findmodsymflt_noseterr (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -685,21 +685,21 @@ int hawk_findmodsymflt_noerr (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow
|
||||
|
||||
int hawk_findmodsymfnc (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n = hawk_findmodsymfnc_noerr(hawk, fnctab, count, name, sym);
|
||||
int n = hawk_findmodsymfnc_noseterr(hawk, fnctab, count, name, sym);
|
||||
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||
return n;
|
||||
}
|
||||
|
||||
int hawk_findmodsymint (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n = hawk_findmodsymint_noerr(hawk, inttab, count, name, sym);
|
||||
int n = hawk_findmodsymint_noseterr(hawk, inttab, count, name, sym);
|
||||
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||
return n;
|
||||
}
|
||||
|
||||
int hawk_findmodsymflt (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
int n = hawk_findmodsymflt_noerr(hawk, flttab, count, name, sym);
|
||||
int n = hawk_findmodsymflt_noseterr(hawk, flttab, count, name, sym);
|
||||
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||
return n;
|
||||
}
|
||||
|
@ -1928,7 +1928,7 @@ HAWK_EXPORT int hawk_isvalidident (
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
HAWK_EXPORT int hawk_findmodsymfnc_noerr (
|
||||
HAWK_EXPORT int hawk_findmodsymfnc_noseterr (
|
||||
hawk_t* hawk,
|
||||
hawk_mod_fnc_tab_t* fnctab,
|
||||
hawk_oow_t count,
|
||||
@ -1936,7 +1936,7 @@ HAWK_EXPORT int hawk_findmodsymfnc_noerr (
|
||||
hawk_mod_sym_t* sym
|
||||
);
|
||||
|
||||
HAWK_EXPORT int hawk_findmodsymint_noerr (
|
||||
HAWK_EXPORT int hawk_findmodsymint_noseterr (
|
||||
hawk_t* hawk,
|
||||
hawk_mod_int_tab_t* inttab,
|
||||
hawk_oow_t count,
|
||||
@ -1944,7 +1944,7 @@ HAWK_EXPORT int hawk_findmodsymint_noerr (
|
||||
hawk_mod_sym_t* sym
|
||||
);
|
||||
|
||||
HAWK_EXPORT int hawk_findmodsymflt_noerr (
|
||||
HAWK_EXPORT int hawk_findmodsymflt_noseterr (
|
||||
hawk_t* hawk,
|
||||
hawk_mod_flt_tab_t* flttab,
|
||||
hawk_oow_t count,
|
||||
|
@ -422,7 +422,7 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
|
||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
if (hawk_findmodsymfnc_noseterr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||
}
|
||||
|
||||
|
@ -797,7 +797,7 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
|
||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
if (hawk_findmodsymfnc_noseterr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||
}
|
||||
|
||||
|
@ -6208,7 +6208,7 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
|
||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
if (hawk_findmodsymfnc_noseterr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||
}
|
||||
|
||||
|
@ -218,13 +218,13 @@ typedef hawk_ooci_t tre_cint_t;
|
||||
|
||||
|
||||
|
||||
/* use the noerr version becuase various tre functions return
|
||||
/* use the noseterr version because various tre functions return
|
||||
* REG_ESPACE upon memory shortage and the wrapper functions
|
||||
* uses the returned code to set the error number on the
|
||||
* hawk_tre_t wrapper object */
|
||||
#define xmalloc(gem,size) hawk_gem_allocmem_noerr(gem,size)
|
||||
#define xrealloc(gem,ptr,new_size) hawk_gem_reallocmem_noerr(gem, ptr, new_size)
|
||||
#define xcalloc(gem,nmemb,size) hawk_gem_callocmem_noerr(gem, (nmemb) * (size))
|
||||
#define xmalloc(gem,size) hawk_gem_allocmem_noseterr(gem,size)
|
||||
#define xrealloc(gem,ptr,new_size) hawk_gem_reallocmem_noseterr(gem, ptr, new_size)
|
||||
#define xcalloc(gem,nmemb,size) hawk_gem_callocmem_noseterr(gem, (nmemb) * (size))
|
||||
#define xfree(gem,ptr) hawk_gem_freemem(gem,ptr)
|
||||
|
||||
/* tre-ast.h */
|
||||
|
@ -489,8 +489,7 @@ static int fnc_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static HAWK_INLINE int add_ffi_arg (hawk_t* hawk, ffi_t* ffi, hawk_ooch_t fmtc, int _unsigned, hawk_oop_t arg)
|
||||
static HAWK_INLINE int add_ffi_arg (hawk_rtx_t* rtx, ffi_t* ffi, hawk_ooch_t fmtc, int _unsigned, hawk_val_t* arg)
|
||||
{
|
||||
#if defined(USE_LIBFFI)
|
||||
if (ffi->arg_count >= ffi->arg_max)
|
||||
@ -502,11 +501,11 @@ static HAWK_INLINE int add_ffi_arg (hawk_t* hawk, ffi_t* ffi, hawk_ooch_t fmtc,
|
||||
hawk_oow_t newmax;
|
||||
|
||||
newmax = ffi->arg_max + 16; /* TODO: adjust this? */
|
||||
ttmp = hawk_reallocmem(hawk, ffi->arg_types, HAWK_SIZEOF(*ttmp) * newmax);
|
||||
ttmp = hawk_rtx_reallocmem(rtx, ffi->arg_types, HAWK_SIZEOF(*ttmp) * newmax);
|
||||
if (HAWK_UNLIKELY(!ttmp)) goto oops;
|
||||
vtmp = hawk_reallocmem(hawk, ffi->arg_values, HAWK_SIZEOF(*vtmp) * newmax);
|
||||
vtmp = hawk_rtx_reallocmem(rtx, ffi->arg_values, HAWK_SIZEOF(*vtmp) * newmax);
|
||||
if (HAWK_UNLIKELY(!vtmp)) goto oops;
|
||||
stmp = hawk_reallocmem(hawk, ffi->arg_svs, HAWK_SIZEOF(*stmp) * newmax);
|
||||
stmp = hawk_rtx_reallocmem(rtx, ffi->arg_svs, HAWK_SIZEOF(*stmp) * newmax);
|
||||
if (HAWK_UNLIKELY(!stmp)) goto oops;
|
||||
|
||||
ffi->arg_types = ttmp;
|
||||
@ -519,244 +518,203 @@ static HAWK_INLINE int add_ffi_arg (hawk_t* hawk, ffi_t* ffi, hawk_ooch_t fmtc,
|
||||
switch (fmtc)
|
||||
{
|
||||
case FMTC_INT8:
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt8 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (HAWK_OOP_IS_CHAR(arg)) v = HAWK_OOP_TO_CHAR(arg);
|
||||
else if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt8 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ui8;
|
||||
ffi->arg_svs[ffi->arg_count].ui8 = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (HAWK_OOP_IS_CHAR(arg)) v = HAWK_OOP_TO_CHAR(arg);
|
||||
else if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt8 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].i8;
|
||||
ffi->arg_svs[ffi->arg_count].i8 = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FMTC_INT16:
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt16 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt16 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ui16;
|
||||
ffi->arg_svs[ffi->arg_count].ui16 = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt16 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].i16;
|
||||
ffi->arg_svs[ffi->arg_count].i16 = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case FMTC_INT32:
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt32 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt32 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ui32;
|
||||
ffi->arg_svs[ffi->arg_count].ui32 = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt32 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].i32;
|
||||
ffi->arg_svs[ffi->arg_count].i32 = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FMTC_INT64:
|
||||
{
|
||||
#if (HAWK_SIZEOF_INT64_T > 0)
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt64 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt64 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ui64;
|
||||
ffi->arg_svs[ffi->arg_count].ui64 = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt64 (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].i64;
|
||||
ffi->arg_svs[ffi->arg_count].i64 = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#else
|
||||
goto inval_sig_ch;
|
||||
#endif
|
||||
}
|
||||
|
||||
case FMTC_CHAR: /* this is a byte */
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgChar (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (HAWK_OOP_IS_CHAR(arg)) v = HAWK_OOP_TO_CHAR(arg);
|
||||
else if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgChar (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].uc;
|
||||
ffi->arg_svs[ffi->arg_count].uc = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (HAWK_OOP_IS_CHAR(arg)) v = HAWK_OOP_TO_CHAR(arg);
|
||||
else if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgChar (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].c;
|
||||
ffi->arg_svs[ffi->arg_count].c = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FMTC_SHORT:
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgShort (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgShort (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].uh;
|
||||
ffi->arg_svs[ffi->arg_count].uh = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgShort (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].h;
|
||||
ffi->arg_svs[ffi->arg_count].h = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FMTC_INT:
|
||||
{
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgInt (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgInt (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ui;
|
||||
ffi->arg_svs[ffi->arg_count].ui = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgInt (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].i;
|
||||
ffi->arg_svs[ffi->arg_count].i = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FMTC_LONG:
|
||||
{
|
||||
hawk_int_t v;
|
||||
arg_as_long:
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_oow_t v;
|
||||
if (hawk_inttooow_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ul;
|
||||
ffi->arg_svs[ffi->arg_count].ul = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
hawk_ooi_t v;
|
||||
if (hawk_inttoooi_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].l;
|
||||
ffi->arg_svs[ffi->arg_count].l = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FMTC_LONGLONG:
|
||||
{
|
||||
#if (HAWK_SIZEOF_LONG_LONG <= HAWK_SIZEOF_LONG)
|
||||
goto arg_as_long;
|
||||
#else
|
||||
hawk_int_t v;
|
||||
if (hawk_rtx_valtoint(rtx, arg, &v) <= -1) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
__dcArgLongLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
if (_unsigned)
|
||||
{
|
||||
hawk_uintmax_t v;
|
||||
if (hawk_inttouintmax_noseterr(hawk, arg, &v) <= 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgLongLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ull;
|
||||
ffi->arg_svs[ffi->arg_count].ull = v;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_intmax_t v;
|
||||
if (hawk_inttointmax_noseterr(hawk, arg, &v) == 0) goto inval_arg_value;
|
||||
#if defined(USE_DYNCALL)
|
||||
dcArgLongLong (ffi->dc, v);
|
||||
#elif defined(USE_LIBFFI)
|
||||
ffi->arg_values[ffi->arg_count] = &ffi->arg_svs[ffi->arg_count].ll;
|
||||
ffi->arg_svs[ffi->arg_count].ll = v;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
case FMTC_BCS:
|
||||
{
|
||||
@ -844,7 +802,7 @@ static HAWK_INLINE int add_ffi_arg (hawk_t* hawk, ffi_t* ffi, hawk_ooch_t fmtc,
|
||||
default:
|
||||
inval_sig_ch:
|
||||
/* invalid argument signature specifier */
|
||||
hawk_seterrbfmt (hawk, HAWK_EINVAL, "invalid argument type signature - %jc", fmtc);
|
||||
hawk_rtx_seterrbfmt (rtx, HAWK_NULL, HAWK_EINVAL, "invalid argument type signature - %jc", fmtc);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -862,6 +820,7 @@ oops:
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static hawk_pfrc_t fnc_call (hawk_t* hawk, hawk_mod_t* mod, hawk_ooi_t nargs)
|
||||
{
|
||||
#if defined(USE_DYNCALL) || defined(USE_LIBFFI)
|
||||
|
@ -1831,7 +1831,7 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
|
||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
{
|
||||
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
if (hawk_findmodsymfnc_noseterr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user