added Hawk::getErrorMessageU(), Hawk::getErrorMessageB(), Hawk::getErrorLocationFileU(), Hawk::getErrorLocationFileB()
This commit is contained in:
parent
8740a081f7
commit
0c65ae7eec
@ -127,10 +127,10 @@ struct rxtn_t
|
|||||||
Hawk::NoSource Hawk::Source::NONE;
|
Hawk::NoSource Hawk::Source::NONE;
|
||||||
|
|
||||||
#if defined(HAWK_HAVE_INLINE)
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
static HAWK_INLINE xtn_t* GET_XTN(hawk_t* awk) { return (xtn_t*)((hawk_uint8_t*)hawk_getxtn(awk) - HAWK_SIZEOF(xtn_t)); }
|
static HAWK_INLINE xtn_t* GET_XTN(hawk_t* hawk) { return (xtn_t*)((hawk_uint8_t*)hawk_getxtn(hawk) - HAWK_SIZEOF(xtn_t)); }
|
||||||
static HAWK_INLINE rxtn_t* GET_RXTN(hawk_rtx_t* rtx) { return (rxtn_t*)((hawk_uint8_t*)hawk_rtx_getxtn(rtx) - HAWK_SIZEOF(rxtn_t)); }
|
static HAWK_INLINE rxtn_t* GET_RXTN(hawk_rtx_t* rtx) { return (rxtn_t*)((hawk_uint8_t*)hawk_rtx_getxtn(rtx) - HAWK_SIZEOF(rxtn_t)); }
|
||||||
#else
|
#else
|
||||||
#define GET_XTN(awk) ((xtn_t*)((hawk_uint8_t*)hawk_getxtn(awk) - HAWK_SIZEOF(xtn_t)))
|
#define GET_XTN(hawk) ((xtn_t*)((hawk_uint8_t*)hawk_getxtn(hawk) - HAWK_SIZEOF(xtn_t)))
|
||||||
#define GET_RXTN(rtx) ((rxtn_t*)((hawk_uint8_t*)hawk_rtx_getxtn(rtx) - HAWK_SIZEOF(rxtn_t)))
|
#define GET_RXTN(rtx) ((rxtn_t*)((hawk_uint8_t*)hawk_rtx_getxtn(rtx) - HAWK_SIZEOF(rxtn_t)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1175,13 +1175,25 @@ hawk_errnum_t Hawk::Run::getErrorNumber () const
|
|||||||
hawk_loc_t Hawk::Run::getErrorLocation () const
|
hawk_loc_t Hawk::Run::getErrorLocation () const
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||||
return *hawk_rtx_geterrloc (this->rtx);
|
return *hawk_rtx_geterrloc(this->rtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hawk_ooch_t* Hawk::Run::getErrorMessage () const
|
const hawk_ooch_t* Hawk::Run::getErrorMessage () const
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||||
return hawk_rtx_geterrmsg (this->rtx);
|
return hawk_rtx_geterrmsg(this->rtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hawk_uch_t* Hawk::Run::getErrorMessageU () const
|
||||||
|
{
|
||||||
|
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||||
|
return hawk_rtx_geterrumsg(this->rtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hawk_bch_t* Hawk::Run::getErrorMessageB () const
|
||||||
|
{
|
||||||
|
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||||
|
return hawk_rtx_geterrbmsg(this->rtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hawk::Run::setError (hawk_errnum_t code, const hawk_loc_t* loc)
|
void Hawk::Run::setError (hawk_errnum_t code, const hawk_loc_t* loc)
|
||||||
@ -1264,7 +1276,7 @@ int Hawk::Run::getGlobal (int id, Value& g) const
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Hawk::Hawk (Mmgr* mmgr):
|
Hawk::Hawk (Mmgr* mmgr):
|
||||||
Mmged (mmgr), awk (HAWK_NULL),
|
Mmged (mmgr), hawk (HAWK_NULL),
|
||||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||||
functionMap (HAWK_NULL),
|
functionMap (HAWK_NULL),
|
||||||
#else
|
#else
|
||||||
@ -1283,7 +1295,7 @@ const hawk_ooch_t* Hawk::getErrorString (hawk_errnum_t num) const
|
|||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
HAWK_ASSERT (this->dflerrstr != HAWK_NULL);
|
HAWK_ASSERT (this->dflerrstr != HAWK_NULL);
|
||||||
return this->dflerrstr(awk, num);
|
return this->dflerrstr(this->hawk, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hawk_ooch_t* Hawk::xerrstr (hawk_t* a, hawk_errnum_t num)
|
const hawk_ooch_t* Hawk::xerrstr (hawk_t* a, hawk_errnum_t num)
|
||||||
@ -1302,16 +1314,71 @@ hawk_loc_t Hawk::getErrorLocation () const
|
|||||||
return this->errinf.loc;
|
return this->errinf.loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hawk_ooch_t* Hawk::getErrorLocationFile () const
|
||||||
|
{
|
||||||
|
return this->errinf.loc.file;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hawk_uch_t* Hawk::getErrorLocationFileU () const
|
||||||
|
{
|
||||||
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
|
return this->errinf.loc.file;
|
||||||
|
#else
|
||||||
|
if (!this->errinf.loc.file) return HAWK_NULL;
|
||||||
|
hawk_oow_t wcslen, mbslen;
|
||||||
|
wcslen = HAWK_COUNTOF(this->xerrlocfile);
|
||||||
|
hawk_conv_bcstr_to_ucstr_with_cmgr (this->errinf.loc.file, &mbslen, hawk->xerrlocfile, &wcslen, hawk_getcmgr(this->hawk), 1);
|
||||||
|
return hawk->xerrlocfile;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const hawk_bch_t* Hawk::getErrorLocationFileB () const
|
||||||
|
{
|
||||||
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
|
if (!this->errinf.loc.file) return HAWK_NULL;
|
||||||
|
hawk_oow_t wcslen, mbslen;
|
||||||
|
mbslen = HAWK_COUNTOF(this->xerrlocfile);
|
||||||
|
hawk_conv_ucstr_to_bcstr_with_cmgr (this->errinf.loc.file, &wcslen, this->xerrlocfile, &mbslen, hawk_getcmgr(this->hawk));
|
||||||
|
return this->xerrlocfile;
|
||||||
|
#else
|
||||||
|
return this->errinf.loc.file;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const hawk_ooch_t* Hawk::getErrorMessage () const
|
const hawk_ooch_t* Hawk::getErrorMessage () const
|
||||||
{
|
{
|
||||||
return this->errinf.msg;
|
return this->errinf.msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hawk_uch_t* Hawk::getErrorMessageU () const
|
||||||
|
{
|
||||||
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
|
return this->errinf.msg;
|
||||||
|
#else
|
||||||
|
hawk_oow_t wcslen, mbslen;
|
||||||
|
wcslen = HAWK_COUNTOF(this->xerrmsg);
|
||||||
|
hawk_conv_bcstr_to_ucstr_with_cmgr (this->errinf.msg, &mbslen, this->xerrmsg, &wcslen, hawk_getcmgr(this->hawk), 1);
|
||||||
|
return this->xerrmsg;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const hawk_bch_t* Hawk::getErrorMessageB () const
|
||||||
|
{
|
||||||
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
|
hawk_oow_t wcslen, mbslen;
|
||||||
|
mbslen = HAWK_COUNTOF(this->xerrmsg);
|
||||||
|
hawk_conv_ucstr_to_bcstr_with_cmgr (this->errinf.msg, &wcslen, this->xerrmsg, &mbslen, hawk_getcmgr(this->hawk));
|
||||||
|
return this->xerrmsg;
|
||||||
|
#else
|
||||||
|
return this->errinf.msg;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Hawk::setError (hawk_errnum_t code, const hawk_loc_t* loc)
|
void Hawk::setError (hawk_errnum_t code, const hawk_loc_t* loc)
|
||||||
{
|
{
|
||||||
if (this->awk)
|
if (this->hawk)
|
||||||
{
|
{
|
||||||
hawk_seterrnum (this->awk, loc, code);
|
hawk_seterrnum (this->hawk, loc, code);
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1325,11 +1392,11 @@ void Hawk::setError (hawk_errnum_t code, const hawk_loc_t* loc)
|
|||||||
|
|
||||||
void Hawk::formatError (hawk_errnum_t code, const hawk_loc_t* loc, const hawk_bch_t* fmt, ...)
|
void Hawk::formatError (hawk_errnum_t code, const hawk_loc_t* loc, const hawk_bch_t* fmt, ...)
|
||||||
{
|
{
|
||||||
if (this->awk)
|
if (this->hawk)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
hawk_seterrbvfmt (this->awk, loc, code, fmt, ap);
|
hawk_seterrbvfmt (this->hawk, loc, code, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
}
|
}
|
||||||
@ -1344,11 +1411,11 @@ void Hawk::formatError (hawk_errnum_t code, const hawk_loc_t* loc, const hawk_bc
|
|||||||
|
|
||||||
void Hawk::formatError (hawk_errnum_t code, const hawk_loc_t* loc, const hawk_uch_t* fmt, ...)
|
void Hawk::formatError (hawk_errnum_t code, const hawk_loc_t* loc, const hawk_uch_t* fmt, ...)
|
||||||
{
|
{
|
||||||
if (this->awk)
|
if (this->hawk)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
hawk_seterruvfmt (this->awk, loc, code, fmt, ap);
|
hawk_seterruvfmt (this->hawk, loc, code, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
}
|
}
|
||||||
@ -1369,13 +1436,13 @@ void Hawk::clearError ()
|
|||||||
|
|
||||||
void Hawk::retrieveError ()
|
void Hawk::retrieveError ()
|
||||||
{
|
{
|
||||||
if (this->awk == HAWK_NULL)
|
if (this->hawk == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->clearError ();
|
this->clearError ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hawk_geterrinf (this->awk, &errinf);
|
hawk_geterrinf (this->hawk, &errinf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,7 +1467,7 @@ static void clear_xtn (hawk_t* awk)
|
|||||||
|
|
||||||
int Hawk::open ()
|
int Hawk::open ()
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->awk == HAWK_NULL);
|
HAWK_ASSERT (this->hawk == HAWK_NULL);
|
||||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||||
HAWK_ASSERT (this->functionMap == HAWK_NULL);
|
HAWK_ASSERT (this->functionMap == HAWK_NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -1415,34 +1482,34 @@ int Hawk::open ()
|
|||||||
prm.modgetsym = Hawk::modgetsym;
|
prm.modgetsym = Hawk::modgetsym;
|
||||||
|
|
||||||
hawk_errnum_t errnum;
|
hawk_errnum_t errnum;
|
||||||
this->awk = hawk_open(this->getMmgr(), HAWK_SIZEOF(xtn_t), hawk_get_cmgr_by_id(HAWK_CMGR_UTF8), &prm, &errnum);
|
this->hawk = hawk_open(this->getMmgr(), HAWK_SIZEOF(xtn_t), hawk_get_cmgr_by_id(HAWK_CMGR_UTF8), &prm, &errnum);
|
||||||
if (!this->awk)
|
if (!this->hawk)
|
||||||
{
|
{
|
||||||
this->setError (errnum);
|
this->setError (errnum);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->awk->_instsize += HAWK_SIZEOF(xtn_t);
|
this->hawk->_instsize += HAWK_SIZEOF(xtn_t);
|
||||||
|
|
||||||
// associate this Hawk object with the underlying awk object
|
// associate this Hawk object with the underlying awk object
|
||||||
xtn_t* xtn = (xtn_t*)GET_XTN(this->awk);
|
xtn_t* xtn = (xtn_t*)GET_XTN(this->hawk);
|
||||||
xtn->hawk = this;
|
xtn->hawk = this;
|
||||||
xtn->ecb.close = fini_xtn;
|
xtn->ecb.close = fini_xtn;
|
||||||
xtn->ecb.clear = clear_xtn;
|
xtn->ecb.clear = clear_xtn;
|
||||||
|
|
||||||
this->dflerrstr = hawk_geterrstr(this->awk);
|
this->dflerrstr = hawk_geterrstr(this->hawk);
|
||||||
// TODO: revive this too when hawk_seterrstr is revived()
|
// TODO: revive this too when hawk_seterrstr is revived()
|
||||||
// hawk_seterrstr (this->awk, Hawk::xerrstr);
|
// hawk_seterrstr (this->hawk, Hawk::xerrstr);
|
||||||
|
|
||||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||||
this->functionMap = hawk_htb_open(
|
this->functionMap = hawk_htb_open(
|
||||||
hawk_getgem(this->awk), HAWK_SIZEOF(this), 512, 70,
|
hawk_getgem(this->hawk), HAWK_SIZEOF(this), 512, 70,
|
||||||
HAWK_SIZEOF(hawk_ooch_t), 1
|
HAWK_SIZEOF(hawk_ooch_t), 1
|
||||||
);
|
);
|
||||||
if (this->functionMap == HAWK_NULL)
|
if (this->functionMap == HAWK_NULL)
|
||||||
{
|
{
|
||||||
hawk_close (this->awk);
|
hawk_close (this->hawk);
|
||||||
this->awk = HAWK_NULL;
|
this->hawk = HAWK_NULL;
|
||||||
|
|
||||||
this->setError (HAWK_ENOMEM);
|
this->setError (HAWK_ENOMEM);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1470,7 +1537,7 @@ int Hawk::open ()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// push the call back after everything else is ok.
|
// push the call back after everything else is ok.
|
||||||
hawk_pushecb (this->awk, &xtn->ecb);
|
hawk_pushecb (this->hawk, &xtn->ecb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,10 +1556,10 @@ void Hawk::close ()
|
|||||||
this->functionMap.clear ();
|
this->functionMap.clear ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (this->awk)
|
if (this->hawk)
|
||||||
{
|
{
|
||||||
hawk_close (this->awk);
|
hawk_close (this->hawk);
|
||||||
this->awk = HAWK_NULL;
|
this->hawk = HAWK_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->clearError ();
|
this->clearError ();
|
||||||
@ -1500,8 +1567,8 @@ void Hawk::close ()
|
|||||||
|
|
||||||
hawk_cmgr_t* Hawk::getCmgr () const
|
hawk_cmgr_t* Hawk::getCmgr () const
|
||||||
{
|
{
|
||||||
if (!this->awk) return HAWK_NULL;
|
if (!this->hawk) return HAWK_NULL;
|
||||||
return hawk_getcmgr(this->awk);
|
return hawk_getcmgr(this->hawk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hawk::uponClosing ()
|
void Hawk::uponClosing ()
|
||||||
@ -1533,7 +1600,7 @@ Hawk::Run* Hawk::parse (Source& in, Source& out)
|
|||||||
sio.in = readSource;
|
sio.in = readSource;
|
||||||
sio.out = (source_writer == HAWK_NULL)? HAWK_NULL: writeSource;
|
sio.out = (source_writer == HAWK_NULL)? HAWK_NULL: writeSource;
|
||||||
|
|
||||||
int n = hawk_parse(awk, &sio);
|
int n = hawk_parse(this->hawk, &sio);
|
||||||
if (n <= -1)
|
if (n <= -1)
|
||||||
{
|
{
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
@ -1557,7 +1624,7 @@ Hawk::Run* Hawk::resetRunContext ()
|
|||||||
|
|
||||||
int Hawk::loop (Value* ret)
|
int Hawk::loop (Value* ret)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
||||||
|
|
||||||
hawk_val_t* rv = hawk_rtx_loop (this->runctx.rtx);
|
hawk_val_t* rv = hawk_rtx_loop (this->runctx.rtx);
|
||||||
@ -1575,7 +1642,7 @@ int Hawk::loop (Value* ret)
|
|||||||
|
|
||||||
int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, hawk_oow_t nargs)
|
int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, hawk_oow_t nargs)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
||||||
|
|
||||||
hawk_val_t* buf[16];
|
hawk_val_t* buf[16];
|
||||||
@ -1586,7 +1653,7 @@ int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
if (nargs <= HAWK_COUNTOF(buf)) ptr = buf;
|
if (nargs <= HAWK_COUNTOF(buf)) ptr = buf;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr = (hawk_val_t**)hawk_allocmem(awk, HAWK_SIZEOF(hawk_val_t*) * nargs);
|
ptr = (hawk_val_t**)hawk_allocmem(this->hawk, HAWK_SIZEOF(hawk_val_t*) * nargs);
|
||||||
if (ptr == HAWK_NULL)
|
if (ptr == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->runctx.setError (HAWK_ENOMEM);
|
this->runctx.setError (HAWK_ENOMEM);
|
||||||
@ -1600,7 +1667,7 @@ int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
|
|
||||||
hawk_val_t* rv = hawk_rtx_callwithbcstr(this->runctx.rtx, name, ptr, nargs);
|
hawk_val_t* rv = hawk_rtx_callwithbcstr(this->runctx.rtx, name, ptr, nargs);
|
||||||
|
|
||||||
if (ptr != HAWK_NULL && ptr != buf) hawk_freemem (awk, ptr);
|
if (ptr != HAWK_NULL && ptr != buf) hawk_freemem (this->hawk, ptr);
|
||||||
|
|
||||||
if (rv == HAWK_NULL)
|
if (rv == HAWK_NULL)
|
||||||
{
|
{
|
||||||
@ -1616,7 +1683,7 @@ int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
|
|
||||||
int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_t nargs)
|
int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_t nargs)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (this->awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
HAWK_ASSERT (this->runctx.rtx != HAWK_NULL);
|
||||||
|
|
||||||
hawk_val_t* buf[16];
|
hawk_val_t* buf[16];
|
||||||
@ -1627,7 +1694,7 @@ int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
if (nargs <= HAWK_COUNTOF(buf)) ptr = buf;
|
if (nargs <= HAWK_COUNTOF(buf)) ptr = buf;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr = (hawk_val_t**)hawk_allocmem(awk, HAWK_SIZEOF(hawk_val_t*) * nargs);
|
ptr = (hawk_val_t**)hawk_allocmem(this->hawk, HAWK_SIZEOF(hawk_val_t*) * nargs);
|
||||||
if (ptr == HAWK_NULL)
|
if (ptr == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->runctx.setError (HAWK_ENOMEM);
|
this->runctx.setError (HAWK_ENOMEM);
|
||||||
@ -1641,7 +1708,7 @@ int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
|
|
||||||
hawk_val_t* rv = hawk_rtx_callwithucstr(this->runctx.rtx, name, ptr, nargs);
|
hawk_val_t* rv = hawk_rtx_callwithucstr(this->runctx.rtx, name, ptr, nargs);
|
||||||
|
|
||||||
if (ptr != HAWK_NULL && ptr != buf) hawk_freemem (awk, ptr);
|
if (ptr != HAWK_NULL && ptr != buf) hawk_freemem (this->hawk, ptr);
|
||||||
|
|
||||||
if (rv == HAWK_NULL)
|
if (rv == HAWK_NULL)
|
||||||
{
|
{
|
||||||
@ -1658,7 +1725,7 @@ int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_
|
|||||||
void Hawk::halt ()
|
void Hawk::halt ()
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
hawk_haltall (awk);
|
hawk_haltall (this->hawk);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hawk::init_runctx ()
|
int Hawk::init_runctx ()
|
||||||
@ -1671,7 +1738,7 @@ int Hawk::init_runctx ()
|
|||||||
rio.file = fileHandler;
|
rio.file = fileHandler;
|
||||||
rio.console = consoleHandler;
|
rio.console = consoleHandler;
|
||||||
|
|
||||||
hawk_rtx_t* rtx = hawk_rtx_open(awk, HAWK_SIZEOF(rxtn_t), &rio);
|
hawk_rtx_t* rtx = hawk_rtx_open(this->hawk, HAWK_SIZEOF(rxtn_t), &rio);
|
||||||
if (rtx == HAWK_NULL)
|
if (rtx == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->retrieveError();
|
this->retrieveError();
|
||||||
@ -1698,31 +1765,31 @@ void Hawk::fini_runctx ()
|
|||||||
|
|
||||||
int Hawk::getTrait () const
|
int Hawk::getTrait () const
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
int val;
|
int val;
|
||||||
hawk_getopt (awk, HAWK_TRAIT, &val);
|
hawk_getopt (this->hawk, HAWK_TRAIT, &val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hawk::setTrait (int trait)
|
void Hawk::setTrait (int trait)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
hawk_setopt (awk, HAWK_TRAIT, &trait);
|
hawk_setopt (this->hawk, HAWK_TRAIT, &trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
hawk_oow_t Hawk::getMaxDepth (depth_t id) const
|
hawk_oow_t Hawk::getMaxDepth (depth_t id) const
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
|
|
||||||
hawk_oow_t depth;
|
hawk_oow_t depth;
|
||||||
hawk_getopt (awk, (hawk_opt_t)id, &depth);
|
hawk_getopt (this->hawk, (hawk_opt_t)id, &depth);
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hawk::setMaxDepth (depth_t id, hawk_oow_t depth)
|
void Hawk::setMaxDepth (depth_t id, hawk_oow_t depth)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
hawk_setopt (awk, (hawk_opt_t)id, &depth);
|
hawk_setopt (this->hawk, (hawk_opt_t)id, &depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hawk::dispatch_function (Run* run, const hawk_fnc_info_t* fi)
|
int Hawk::dispatch_function (Run* run, const hawk_fnc_info_t* fi)
|
||||||
@ -1977,20 +2044,20 @@ void Hawk::xstrs_t::clear (hawk_t* awk)
|
|||||||
int Hawk::addArgument (const hawk_uch_t* arg, hawk_oow_t len)
|
int Hawk::addArgument (const hawk_uch_t* arg, hawk_oow_t len)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = this->runarg.add(awk, arg, len);
|
int n = this->runarg.add(this->hawk, arg, len);
|
||||||
if (n <= -1) this->setError (HAWK_ENOMEM);
|
if (n <= -1) this->setError (HAWK_ENOMEM);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hawk::addArgument (const hawk_uch_t* arg)
|
int Hawk::addArgument (const hawk_uch_t* arg)
|
||||||
{
|
{
|
||||||
return addArgument(arg, hawk_count_ucstr(arg));
|
return this->addArgument(arg, hawk_count_ucstr(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hawk::addArgument (const hawk_bch_t* arg, hawk_oow_t len)
|
int Hawk::addArgument (const hawk_bch_t* arg, hawk_oow_t len)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
int n = this->runarg.add(awk, arg, len);
|
int n = this->runarg.add(this->hawk, arg, len);
|
||||||
if (n <= -1) this->setError (HAWK_ENOMEM);
|
if (n <= -1) this->setError (HAWK_ENOMEM);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2000,16 +2067,15 @@ int Hawk::addArgument (const hawk_bch_t* arg)
|
|||||||
return this->addArgument(arg, hawk_count_bcstr(arg));
|
return this->addArgument(arg, hawk_count_bcstr(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hawk::clearArguments ()
|
void Hawk::clearArguments ()
|
||||||
{
|
{
|
||||||
runarg.clear (awk);
|
this->runarg.clear (this->hawk);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hawk::addGlobal(const hawk_bch_t* name)
|
int Hawk::addGlobal(const hawk_bch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_addgblwithbcstr(awk, name);
|
int n = hawk_addgblwithbcstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2017,7 +2083,7 @@ int Hawk::addGlobal(const hawk_bch_t* name)
|
|||||||
int Hawk::addGlobal(const hawk_uch_t* name)
|
int Hawk::addGlobal(const hawk_uch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_addgblwithucstr(awk, name);
|
int n = hawk_addgblwithucstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2025,7 +2091,7 @@ int Hawk::addGlobal(const hawk_uch_t* name)
|
|||||||
int Hawk::deleteGlobal (const hawk_bch_t* name)
|
int Hawk::deleteGlobal (const hawk_bch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_delgblwithbcstr(awk, name);
|
int n = hawk_delgblwithbcstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2033,7 +2099,7 @@ int Hawk::deleteGlobal (const hawk_bch_t* name)
|
|||||||
int Hawk::deleteGlobal (const hawk_uch_t* name)
|
int Hawk::deleteGlobal (const hawk_uch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_delgblwithucstr(awk, name);
|
int n = hawk_delgblwithucstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2042,7 +2108,7 @@ int Hawk::deleteGlobal (const hawk_uch_t* name)
|
|||||||
int Hawk::findGlobal (const hawk_bch_t* name)
|
int Hawk::findGlobal (const hawk_bch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_findgblwithbcstr(awk, name);
|
int n = hawk_findgblwithbcstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2050,7 +2116,7 @@ int Hawk::findGlobal (const hawk_bch_t* name)
|
|||||||
int Hawk::findGlobal (const hawk_uch_t* name)
|
int Hawk::findGlobal (const hawk_uch_t* name)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = hawk_findgblwithucstr(awk, name);
|
int n = hawk_findgblwithucstr(this->hawk, name);
|
||||||
if (n <= -1) this->retrieveError ();
|
if (n <= -1) this->retrieveError ();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2096,7 +2162,7 @@ int Hawk::addFunction (
|
|||||||
spec.impl = this->functionHandler;
|
spec.impl = this->functionHandler;
|
||||||
spec.trait = validOpts;
|
spec.trait = validOpts;
|
||||||
|
|
||||||
hawk_fnc_t* fnc = hawk_addfncwithbcstr(awk, name, &spec);
|
hawk_fnc_t* fnc = hawk_addfncwithbcstr(this->hawk, name, &spec);
|
||||||
if (fnc == HAWK_NULL)
|
if (fnc == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
@ -2111,18 +2177,23 @@ int Hawk::addFunction (
|
|||||||
// the function name exists in the underlying function table.
|
// the function name exists in the underlying function table.
|
||||||
// use the pointer to the name to maintain the hash table.
|
// use the pointer to the name to maintain the hash table.
|
||||||
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (hawk_ooch_t*)fnc->name.ptr, fnc->name.len, &handler, HAWK_SIZEOF(handler));
|
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (hawk_ooch_t*)fnc->name.ptr, fnc->name.len, &handler, HAWK_SIZEOF(handler));
|
||||||
|
if (!pair)
|
||||||
|
{
|
||||||
|
hawk_delfncwithbcstr (this->hawk, name);
|
||||||
|
this->retrieveError ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
FunctionMap::Pair* pair;
|
FunctionMap::Pair* pair;
|
||||||
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
||||||
catch (...) { pair = HAWK_NULL; }
|
catch (...) { pair = HAWK_NULL; }
|
||||||
#endif
|
if (!pair)
|
||||||
|
|
||||||
if (pair == HAWK_NULL)
|
|
||||||
{
|
{
|
||||||
hawk_delfncwithbcstr (awk, name);
|
hawk_delfncwithbcstr (this->hawk, name);
|
||||||
this->setError (HAWK_ENOMEM);
|
this->setError (HAWK_ENOMEM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2142,7 +2213,7 @@ int Hawk::addFunction (
|
|||||||
spec.impl = this->functionHandler;
|
spec.impl = this->functionHandler;
|
||||||
spec.trait = validOpts;
|
spec.trait = validOpts;
|
||||||
|
|
||||||
hawk_fnc_t* fnc = hawk_addfncwithucstr(awk, name, &spec);
|
hawk_fnc_t* fnc = hawk_addfncwithucstr(this->hawk, name, &spec);
|
||||||
if (fnc == HAWK_NULL)
|
if (fnc == HAWK_NULL)
|
||||||
{
|
{
|
||||||
this->retrieveError ();
|
this->retrieveError ();
|
||||||
@ -2157,18 +2228,23 @@ int Hawk::addFunction (
|
|||||||
// the function name exists in the underlying function table.
|
// the function name exists in the underlying function table.
|
||||||
// use the pointer to the name to maintain the hash table.
|
// use the pointer to the name to maintain the hash table.
|
||||||
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (hawk_ooch_t*)fnc->name.ptr, fnc->name.len, &handler, HAWK_SIZEOF(handler));
|
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (hawk_ooch_t*)fnc->name.ptr, fnc->name.len, &handler, HAWK_SIZEOF(handler));
|
||||||
|
if (!pair)
|
||||||
|
{
|
||||||
|
hawk_delfncwithucstr (this->hawk, name);
|
||||||
|
this->retrieveError ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
FunctionMap::Pair* pair;
|
FunctionMap::Pair* pair;
|
||||||
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
||||||
catch (...) { pair = HAWK_NULL; }
|
catch (...) { pair = HAWK_NULL; }
|
||||||
#endif
|
if (!pair)
|
||||||
|
|
||||||
if (pair == HAWK_NULL)
|
|
||||||
{
|
{
|
||||||
hawk_delfncwithucstr (awk, name);
|
hawk_delfncwithucstr (this->hawk, name);
|
||||||
this->setError (HAWK_ENOMEM);
|
this->setError (HAWK_ENOMEM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2177,7 +2253,7 @@ int Hawk::deleteFunction (const hawk_ooch_t* name)
|
|||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
|
|
||||||
int n = hawk_delfnc(awk, name);
|
int n = hawk_delfnc(this->hawk, name);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||||
|
@ -376,8 +376,6 @@ private:
|
|||||||
class HAWK_EXPORT Hawk: public Uncopyable, public Mmged
|
class HAWK_EXPORT Hawk: public Uncopyable, public Mmged
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef hawk_errstr_t errstr_t;
|
|
||||||
typedef hawk_errinf_t errinf_t;
|
|
||||||
|
|
||||||
enum depth_t
|
enum depth_t
|
||||||
{
|
{
|
||||||
@ -431,12 +429,17 @@ public:
|
|||||||
/// last error occurred.
|
/// last error occurred.
|
||||||
///
|
///
|
||||||
hawk_loc_t getErrorLocation () const;
|
hawk_loc_t getErrorLocation () const;
|
||||||
|
const hawk_ooch_t* getErrorLocationFile () const;
|
||||||
|
const hawk_uch_t* getErrorLocationFileU () const;
|
||||||
|
const hawk_bch_t* getErrorLocationFileB () const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The Hawk::getErrorMessage() function returns a message describing
|
/// The Hawk::getErrorMessage() function returns a message describing
|
||||||
/// the last error occurred.
|
/// the last error occurred.
|
||||||
///
|
///
|
||||||
const hawk_ooch_t* getErrorMessage () const;
|
const hawk_ooch_t* getErrorMessage () const;
|
||||||
|
const hawk_uch_t* getErrorMessageU () const;
|
||||||
|
const hawk_bch_t* getErrorMessageB () const;
|
||||||
|
|
||||||
void setError (
|
void setError (
|
||||||
hawk_errnum_t code, ///< error code
|
hawk_errnum_t code, ///< error code
|
||||||
@ -1178,6 +1181,8 @@ public:
|
|||||||
hawk_errnum_t getErrorNumber () const;
|
hawk_errnum_t getErrorNumber () const;
|
||||||
hawk_loc_t getErrorLocation () const;
|
hawk_loc_t getErrorLocation () const;
|
||||||
const hawk_ooch_t* getErrorMessage () const;
|
const hawk_ooch_t* getErrorMessage () const;
|
||||||
|
const hawk_uch_t* getErrorMessageU () const;
|
||||||
|
const hawk_bch_t* getErrorMessageB () const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The setError() function sets error information.
|
/// The setError() function sets error information.
|
||||||
@ -1250,12 +1255,12 @@ public:
|
|||||||
///
|
///
|
||||||
operator hawk_t* () const
|
operator hawk_t* () const
|
||||||
{
|
{
|
||||||
return this->awk;
|
return this->hawk;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator hawk_gem_t* () const
|
operator hawk_gem_t* () const
|
||||||
{
|
{
|
||||||
return this->awk? hawk_getgem(this->awk): HAWK_NULL;
|
return this->hawk? hawk_getgem(this->hawk): HAWK_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -1711,25 +1716,32 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// use this with care
|
// use this with care
|
||||||
hawk_t* getHandle() const { return this->awk; }
|
hawk_t* getHandle() const { return this->hawk; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
hawk_t* awk;
|
hawk_t* hawk;
|
||||||
|
|
||||||
errstr_t dflerrstr;
|
hawk_errstr_t dflerrstr;
|
||||||
errinf_t errinf;
|
hawk_errinf_t errinf;
|
||||||
|
#if defined(HAWK_OOCH_IS_BCH)
|
||||||
|
mutable hawk_uch_t xerrmsg[HAWK_ERRMSG_CAPA];
|
||||||
|
mutable hawk_uch_t xerrlocfile[128];
|
||||||
|
#else
|
||||||
|
mutable hawk_bch_t xerrmsg[HAWK_ERRMSG_CAPA * 2];
|
||||||
|
mutable hawk_bch_t xerrlocfile[256];
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||||
hawk_htb_t* functionMap;
|
hawk_htb_t* functionMap;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
class FunctionMap: public HashTable<Cstr,FunctionHandler>
|
class FunctionMap: public HashTable<Cstr,FunctionHandler>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FunctionMap (Hawk* awk): awk(awk) {}
|
FunctionMap (Hawk* awk): hawk(hawk) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Hawk* awk;
|
Hawk* hawk;
|
||||||
};
|
};
|
||||||
|
|
||||||
FunctionMap functionMap;
|
FunctionMap functionMap;
|
||||||
|
@ -151,10 +151,10 @@ int HawkStd::open ()
|
|||||||
if (!this->stdmod_up)
|
if (!this->stdmod_up)
|
||||||
{
|
{
|
||||||
#if defined(USE_DLFCN)
|
#if defined(USE_DLFCN)
|
||||||
if (hawk_setopt(awk, HAWK_MODPOSTFIX, HAWK_T(".so")) <= -1) goto oops;
|
if (hawk_setopt(this->hawk, HAWK_MODPOSTFIX, HAWK_T(".so")) <= -1) goto oops;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hawk_stdmodstartup(this->awk) <= -1) goto oops;
|
if (hawk_stdmodstartup(this->hawk) <= -1) goto oops;
|
||||||
this->stdmod_up = true;
|
this->stdmod_up = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ void HawkStd::close ()
|
|||||||
//
|
//
|
||||||
//if (this->stdmod_up)
|
//if (this->stdmod_up)
|
||||||
//{
|
//{
|
||||||
// hawk_stdmodshutdown (this->awk);
|
// hawk_stdmodshutdown (this->hawk);
|
||||||
// this->stdmod_up = false;
|
// this->stdmod_up = false;
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
@ -200,7 +200,7 @@ void HawkStd::uponClosing ()
|
|||||||
{
|
{
|
||||||
if (this->stdmod_up)
|
if (this->stdmod_up)
|
||||||
{
|
{
|
||||||
hawk_stdmodshutdown (this->awk);
|
hawk_stdmodshutdown (this->hawk);
|
||||||
this->stdmod_up = false;
|
this->stdmod_up = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,8 +791,8 @@ const hawk_cmgr_t* HawkStd::getConsoleCmgr () const
|
|||||||
|
|
||||||
int HawkStd::addConsoleOutput (const hawk_uch_t* arg, hawk_oow_t len)
|
int HawkStd::addConsoleOutput (const hawk_uch_t* arg, hawk_oow_t len)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (this->hawk != HAWK_NULL);
|
||||||
int n = this->ofile.add(awk, arg, len);
|
int n = this->ofile.add(this->hawk, arg, len);
|
||||||
if (n <= -1) this->setError (HAWK_ENOMEM);
|
if (n <= -1) this->setError (HAWK_ENOMEM);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ int HawkStd::addConsoleOutput (const hawk_uch_t* arg)
|
|||||||
int HawkStd::addConsoleOutput (const hawk_bch_t* arg, hawk_oow_t len)
|
int HawkStd::addConsoleOutput (const hawk_bch_t* arg, hawk_oow_t len)
|
||||||
{
|
{
|
||||||
HAWK_ASSERT (awk != HAWK_NULL);
|
HAWK_ASSERT (awk != HAWK_NULL);
|
||||||
int n = this->ofile.add(awk, arg, len);
|
int n = this->ofile.add(this->hawk, arg, len);
|
||||||
if (n <= -1) this->setError (HAWK_ENOMEM);
|
if (n <= -1) this->setError (HAWK_ENOMEM);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ int HawkStd::addConsoleOutput (const hawk_bch_t* arg)
|
|||||||
|
|
||||||
void HawkStd::clearConsoleOutputs ()
|
void HawkStd::clearConsoleOutputs ()
|
||||||
{
|
{
|
||||||
this->ofile.clear (awk);
|
this->ofile.clear (this->hawk);
|
||||||
}
|
}
|
||||||
|
|
||||||
int HawkStd::open_console_in (Console& io)
|
int HawkStd::open_console_in (Console& io)
|
||||||
@ -1144,31 +1144,31 @@ void HawkStd::freeMem (void* ptr)
|
|||||||
|
|
||||||
hawk_flt_t HawkStd::pow (hawk_flt_t x, hawk_flt_t y)
|
hawk_flt_t HawkStd::pow (hawk_flt_t x, hawk_flt_t y)
|
||||||
{
|
{
|
||||||
return hawk_stdmathpow (this->awk, x, y);
|
return hawk_stdmathpow (this->hawk, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
hawk_flt_t HawkStd::mod (hawk_flt_t x, hawk_flt_t y)
|
hawk_flt_t HawkStd::mod (hawk_flt_t x, hawk_flt_t y)
|
||||||
{
|
{
|
||||||
return hawk_stdmathmod (this->awk, x, y);
|
return hawk_stdmathmod (this->hawk, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* HawkStd::modopen (const hawk_mod_spec_t* spec)
|
void* HawkStd::modopen (const hawk_mod_spec_t* spec)
|
||||||
{
|
{
|
||||||
void* h;
|
void* h;
|
||||||
h = hawk_stdmodopen (this->awk, spec);
|
h = hawk_stdmodopen (this->hawk, spec);
|
||||||
if (!h) this->retrieveError ();
|
if (!h) this->retrieveError ();
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HawkStd::modclose (void* handle)
|
void HawkStd::modclose (void* handle)
|
||||||
{
|
{
|
||||||
hawk_stdmodclose (this->awk, handle);
|
hawk_stdmodclose (this->hawk, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* HawkStd::modgetsym (void* handle, const hawk_ooch_t* name)
|
void* HawkStd::modgetsym (void* handle, const hawk_ooch_t* name)
|
||||||
{
|
{
|
||||||
void* s;
|
void* s;
|
||||||
s = hawk_stdmodgetsym(this->awk, handle, name);
|
s = hawk_stdmodgetsym(this->hawk, handle, name);
|
||||||
if (!s) this->retrieveError ();
|
if (!s) this->retrieveError ();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -185,28 +185,13 @@ static void print_error (MyHawk& hawk)
|
|||||||
hawk_errnum_t code = hawk.getErrorNumber();
|
hawk_errnum_t code = hawk.getErrorNumber();
|
||||||
hawk_loc_t loc = hawk.getErrorLocation();
|
hawk_loc_t loc = hawk.getErrorLocation();
|
||||||
|
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
|
||||||
hawk_bch_t msg[256]; // don't care about truncation for now
|
|
||||||
hawk_oow_t ucslen, bcslen = HAWK_COUNTOF(msg);
|
|
||||||
hawk_conv_ucstr_to_bcstr_with_cmgr (hawk.getErrorMessage(), &ucslen, msg, &bcslen, hawk_getcmgr((hawk_t*)hawk));
|
|
||||||
#else
|
|
||||||
const hawk_bch_t* msg = hawk.getErrorMessage();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
if (loc.file)
|
if (loc.file)
|
||||||
{
|
{
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
print_error ("code %d line %lu at %s - %s\n", (int)code, (unsigned long int)loc.line, hawk.getErrorLocationFileB(), hawk.getErrorMessageB());
|
||||||
hawk_bch_t file[128]; // don't care about truncation for now
|
|
||||||
bcslen = HAWK_COUNTOF(file);
|
|
||||||
hawk_conv_ucstr_to_bcstr_with_cmgr (loc.file, &ucslen, file, &bcslen, hawk_getcmgr((hawk_t*)hawk));
|
|
||||||
#else
|
|
||||||
const hawk_bch_t* file = loc.file;
|
|
||||||
#endif
|
|
||||||
print_error ("code %d line %lu at %s - %s\n", (int)code, (unsigned long int)loc.line, file, msg);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_error ("code %d line %lu - %s\n", (int)code, (unsigned long int)loc.line, msg);
|
print_error ("code %d line %lu - %s\n", (int)code, (unsigned long int)loc.line, hawk.getErrorMessageB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user