added two more variants of Hawk::Run::setGlobal()

This commit is contained in:
hyung-hwan 2021-08-19 18:42:12 +00:00
parent 98e594190d
commit ebdb8cecce
2 changed files with 36 additions and 6 deletions

View File

@ -1323,6 +1323,34 @@ int Hawk::Run::setGlobal (int id, const hawk_bch_t* ptr, hawk_oow_t len, bool mb
return n;
}
int Hawk::Run::setGlobal (int id, const hawk_uch_t* ptr, bool mbs)
{
HAWK_ASSERT (this->rtx != HAWK_NULL);
hawk_val_t* tmp = mbs? hawk_rtx_makembsvalwithucstr(this->rtx, ptr):
hawk_rtx_makestrvalwithucstr(this->rtx, ptr);
if (HAWK_UNLIKELY(!tmp)) return -1;
hawk_rtx_refupval (this->rtx, tmp);
int n = hawk_rtx_setgbl(this->rtx, id, tmp);
hawk_rtx_refdownval (this->rtx, tmp);
return n;
}
int Hawk::Run::setGlobal (int id, const hawk_bch_t* ptr, bool mbs)
{
HAWK_ASSERT (this->rtx != HAWK_NULL);
hawk_val_t* tmp = mbs? hawk_rtx_makembsvalwithbcstr(this->rtx, ptr):
hawk_rtx_makestrvalwithbcstr(this->rtx, ptr);
if (HAWK_UNLIKELY(!tmp)) return -1;
hawk_rtx_refupval (this->rtx, tmp);
int n = hawk_rtx_setgbl(this->rtx, id, tmp);
hawk_rtx_refdownval (this->rtx, tmp);
return n;
}
int Hawk::Run::setGlobal (int id, const Value& gbl)
{
HAWK_ASSERT (this->rtx != HAWK_NULL);

View File

@ -1239,6 +1239,8 @@ public:
///
int setGlobal (int id, const hawk_uch_t* ptr, hawk_oow_t len, bool mbs = false);
int setGlobal (int id, const hawk_bch_t* ptr, hawk_oow_t len, bool mbs = false);
int setGlobal (int id, const hawk_uch_t* ptr, bool mbs = false);
int setGlobal (int id, const hawk_bch_t* ptr, bool mbs = false);
///
/// The setGlobal() function sets a global variable