improved Hawk::Value::setIndexedStr() functions

This commit is contained in:
hyung-hwan 2020-01-09 07:24:35 +00:00
parent ba8cb99231
commit f1c5626b1b
2 changed files with 74 additions and 21 deletions

View File

@ -961,23 +961,20 @@ int Hawk::Value::setIndexedFlt (Run* r, const Index& idx, hawk_flt_t v)
return n; return n;
} }
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric) ///////////////////////////////////////////////////////////////////
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_uch_t* str, hawk_oow_t len, bool numeric)
{ {
if (run == HAWK_NULL) return -1; if (this->run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedStr(run, idx, str, len, numeric); return this->setIndexedStr(this->run, idx, str, len, numeric);
} }
int Hawk::Value::setIndexedStr ( int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_uch_t* str, hawk_oow_t len, bool numeric)
Run* r, const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
{ {
hawk_val_t* tmp; hawk_val_t* tmp;
hawk_oocs_t oocs; tmp = numeric? hawk_rtx_makenstrvalwithuchars(r->rtx, str, len):
oocs.ptr = (hawk_ooch_t*)str; hawk_rtx_makestrvalwithuchars(r->rtx, str, len);
oocs.len = len;
tmp = numeric? hawk_rtx_makenstrvalwithoocs(r->rtx, &oocs):
hawk_rtx_makestrvalwithoocs(r->rtx, &oocs);
if (tmp == HAWK_NULL) if (tmp == HAWK_NULL)
{ {
r->awk->retrieveError (r); r->awk->retrieveError (r);
@ -991,13 +988,13 @@ int Hawk::Value::setIndexedStr (
return n; return n;
} }
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_ooch_t* str, bool numeric) int Hawk::Value::setIndexedStr (const Index& idx, const hawk_uch_t* str, bool numeric)
{ {
if (run == HAWK_NULL) return -1; if (run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedStr(run, idx, str, numeric); return this->setIndexedStr(run, idx, str, numeric);
} }
int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str, bool numeric) int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_uch_t* str, bool numeric)
{ {
hawk_val_t* tmp; hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str): tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str):
@ -1015,10 +1012,61 @@ int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str
return n; return n;
} }
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_bch_t* str, hawk_oow_t len, bool numeric)
{
if (this->run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedStr(this->run, idx, str, len, numeric);
}
int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len, bool numeric)
{
hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithbchars(r->rtx, str, len):
hawk_rtx_makestrvalwithbchars(r->rtx, str, len);
if (tmp == HAWK_NULL)
{
r->awk->retrieveError (r);
return -1;
}
hawk_rtx_refupval (r->rtx, tmp);
int n = this->setIndexedVal(r, idx, tmp);
hawk_rtx_refdownval (r->rtx, tmp);
return n;
}
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_bch_t* str, bool numeric)
{
if (run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedStr(run, idx, str, numeric);
}
int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_bch_t* str, bool numeric)
{
hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithbcstr(r->rtx, str):
hawk_rtx_makestrvalwithbcstr(r->rtx, str);
if (tmp == HAWK_NULL)
{
r->awk->retrieveError (r);
return -1;
}
hawk_rtx_refupval (r->rtx, tmp);
int n = this->setIndexedVal(r, idx, tmp);
hawk_rtx_refdownval (r->rtx, tmp);
return n;
}
///////////////////////////////////////////////////////////////////
int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str, hawk_oow_t len) int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str, hawk_oow_t len)
{ {
if (run == HAWK_NULL) return -1; if (run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedMbs(run, idx, str, len); return this->setIndexedMbs(this->run, idx, str, len);
} }
int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len) int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len)
@ -1045,7 +1093,7 @@ int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str,
int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str) int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str)
{ {
if (run == HAWK_NULL) return -1; if (run == HAWK_NULL) return -1; // NOTE: this->run isn't available. neither is this->run->awk. unable to set an error code
return this->setIndexedMbs(run, idx, str); return this->setIndexedMbs(run, idx, str);
} }

View File

@ -1079,10 +1079,15 @@ public:
int setIndexedFlt (const Index& idx, hawk_flt_t v); int setIndexedFlt (const Index& idx, hawk_flt_t v);
int setIndexedFlt (Run* r, const Index& idx, hawk_flt_t v); int setIndexedFlt (Run* r, const Index& idx, hawk_flt_t v);
int setIndexedStr (const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false); int setIndexedStr (const Index& idx, const hawk_uch_t* str, hawk_oow_t len, bool numeric = false);
int setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false); int setIndexedStr (Run* r, const Index& idx, const hawk_uch_t* str, hawk_oow_t len, bool numeric = false);
int setIndexedStr (const Index& idx, const hawk_ooch_t* str, bool numeric = false); int setIndexedStr (const Index& idx, const hawk_uch_t* str, bool numeric = false);
int setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str, bool numeric = false); int setIndexedStr (Run* r, const Index& idx, const hawk_uch_t* str, bool numeric = false);
int setIndexedStr (const Index& idx, const hawk_bch_t* str, hawk_oow_t len, bool numeric = false);
int setIndexedStr (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len, bool numeric = false);
int setIndexedStr (const Index& idx, const hawk_bch_t* str, bool numeric = false);
int setIndexedStr (Run* r, const Index& idx, const hawk_bch_t* str, bool numeric = false);
int setIndexedMbs (const Index& idx, const hawk_bch_t* str, hawk_oow_t len); int setIndexedMbs (const Index& idx, const hawk_bch_t* str, hawk_oow_t len);
int setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len); int setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len);