updating Hawk and StdHawk classes for hawk
This commit is contained in:
parent
b610816366
commit
0e4cdc0f04
@ -64,7 +64,7 @@ Hawk::RIOBase::RIOBase (Run* run, rio_arg_t* riod): run (run), riod (riod)
|
||||
{
|
||||
}
|
||||
|
||||
const Hawk::char_t* Hawk::RIOBase::getName () const
|
||||
const hawk_ooch_t* Hawk::RIOBase::getName () const
|
||||
{
|
||||
return this->riod->name;
|
||||
}
|
||||
@ -163,17 +163,15 @@ Hawk::Console::~Console ()
|
||||
}
|
||||
}
|
||||
|
||||
int Hawk::Console::setFileName (const char_t* name)
|
||||
int Hawk::Console::setFileName (const hawk_ooch_t* name)
|
||||
{
|
||||
if (this->getMode() == READ)
|
||||
{
|
||||
return hawk_rtx_setfilename (
|
||||
this->run->rtx, name, hawk_strlen(name));
|
||||
return hawk_rtx_setfilename(this->run->rtx, name, hawk_count_oocstr(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
return hawk_rtx_setofilename (
|
||||
this->run->rtx, name, hawk_strlen(name));
|
||||
return hawk_rtx_setofilename(this->run->rtx, name, hawk_count_oocstr(name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,9 +201,9 @@ Hawk::Console::Mode Hawk::Console::getMode () const
|
||||
|
||||
Hawk::Value::IndexIterator Hawk::Value::IndexIterator::END;
|
||||
|
||||
const Hawk::char_t* Hawk::Value::getEmptyStr()
|
||||
const hawk_ooch_t* Hawk::Value::getEmptyStr()
|
||||
{
|
||||
static const Hawk::char_t* EMPTY_STRING = HAWK_T("");
|
||||
static const hawk_ooch_t* EMPTY_STRING = HAWK_T("");
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
const hawk_bch_t* Hawk::Value::getEmptyMbs()
|
||||
@ -259,7 +257,7 @@ Hawk::Value::IntIndex::IntIndex (int_t x)
|
||||
}
|
||||
|
||||
#if defined(HAWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW)
|
||||
void* Hawk::Value::operator new (size_t n, Run* run) throw ()
|
||||
void* Hawk::Value::operator new (hawk_oow_t n, Run* run) throw ()
|
||||
{
|
||||
void* ptr = hawk_rtx_allocmem (run->rtx, HAWK_SIZEOF(run) + n);
|
||||
if (ptr == HAWK_NULL) return HAWK_NULL;
|
||||
@ -268,7 +266,7 @@ void* Hawk::Value::operator new (size_t n, Run* run) throw ()
|
||||
return (char*)ptr + HAWK_SIZEOF(run);
|
||||
}
|
||||
|
||||
void* Hawk::Value::operator new[] (size_t n, Run* run) throw ()
|
||||
void* Hawk::Value::operator new[] (hawk_oow_t n, Run* run) throw ()
|
||||
{
|
||||
void* ptr = hawk_rtx_allocmem (run->rtx, HAWK_SIZEOF(run) + n);
|
||||
if (ptr == HAWK_NULL) return HAWK_NULL;
|
||||
@ -419,10 +417,10 @@ Hawk::Value::operator Hawk::flt_t () const
|
||||
return v;
|
||||
}
|
||||
|
||||
Hawk::Value::operator const Hawk::char_t* () const
|
||||
Hawk::Value::operator const hawk_ooch_t* () const
|
||||
{
|
||||
const Hawk::char_t* ptr;
|
||||
size_t len;
|
||||
const hawk_ooch_t* ptr;
|
||||
hawk_oow_t len;
|
||||
if (Hawk::Value::getStr(&ptr, &len) <= -1) ptr = getEmptyStr();
|
||||
return ptr;
|
||||
}
|
||||
@ -431,7 +429,7 @@ Hawk::Value::operator const Hawk::char_t* () const
|
||||
Hawk::Value::operator const hawk_bch_t* () const
|
||||
{
|
||||
const hawk_bch_t* ptr;
|
||||
size_t len;
|
||||
hawk_oow_t len;
|
||||
if (Hawk::Value::getMbs(&ptr, &len) <= -1) ptr = getEmptyMbs();
|
||||
return ptr;
|
||||
}
|
||||
@ -496,10 +494,10 @@ int Hawk::Value::getNum (int_t* lv, flt_t* fv) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::Value::getStr (const char_t** str, size_t* len) const
|
||||
int Hawk::Value::getStr (const hawk_ooch_t** str, hawk_oow_t* len) const
|
||||
{
|
||||
const char_t* p = getEmptyStr();
|
||||
size_t l = 0;
|
||||
const hawk_ooch_t* p = getEmptyStr();
|
||||
hawk_oow_t l = 0;
|
||||
|
||||
HAWK_ASSERT (this->val != HAWK_NULL);
|
||||
|
||||
@ -542,10 +540,10 @@ int Hawk::Value::getStr (const char_t** str, size_t* len) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::Value::getMbs (const hawk_bch_t** str, size_t* len) const
|
||||
int Hawk::Value::getMbs (const hawk_bch_t** str, hawk_oow_t* len) const
|
||||
{
|
||||
const hawk_bch_t* p = getEmptyMbs();
|
||||
size_t l = 0;
|
||||
hawk_oow_t l = 0;
|
||||
|
||||
HAWK_ASSERT (this->val != HAWK_NULL);
|
||||
|
||||
@ -676,7 +674,7 @@ int Hawk::Value::setFlt (Run* r, flt_t v)
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Value::setStr (const char_t* str, size_t len, bool numeric)
|
||||
int Hawk::Value::setStr (const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
|
||||
{
|
||||
if (this->run == HAWK_NULL)
|
||||
{
|
||||
@ -687,12 +685,12 @@ int Hawk::Value::setStr (const char_t* str, size_t len, bool numeric)
|
||||
return this->setStr(this->run, str, len, numeric);
|
||||
}
|
||||
|
||||
int Hawk::Value::setStr (Run* r, const char_t* str, size_t len, bool numeric)
|
||||
int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
|
||||
{
|
||||
val_t* tmp;
|
||||
|
||||
oocs_t oocs;
|
||||
oocs.ptr = (char_t*)str;
|
||||
hawk_oocs_t oocs;
|
||||
oocs.ptr = (hawk_ooch_t*)str;
|
||||
oocs.len = len;
|
||||
|
||||
tmp = numeric? hawk_rtx_makenstrvalwithoocs(r->rtx, &oocs):
|
||||
@ -708,13 +706,13 @@ int Hawk::Value::setStr (Run* r, const char_t* str, size_t len, bool numeric)
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Value::setStr (const char_t* str, bool numeric)
|
||||
int Hawk::Value::setStr (const hawk_ooch_t* str, bool numeric)
|
||||
{
|
||||
if (this->run == HAWK_NULL) return -1;
|
||||
return this->setStr(this->run, str, numeric);
|
||||
}
|
||||
|
||||
int Hawk::Value::setStr (Run* r, const char_t* str, bool numeric)
|
||||
int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, bool numeric)
|
||||
{
|
||||
val_t* tmp;
|
||||
tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str):
|
||||
@ -731,7 +729,7 @@ int Hawk::Value::setStr (Run* r, const char_t* str, bool numeric)
|
||||
}
|
||||
|
||||
|
||||
int Hawk::Value::setMbs (const hawk_bch_t* str, size_t len)
|
||||
int Hawk::Value::setMbs (const hawk_bch_t* str, hawk_oow_t len)
|
||||
{
|
||||
if (this->run == HAWK_NULL)
|
||||
{
|
||||
@ -742,7 +740,7 @@ int Hawk::Value::setMbs (const hawk_bch_t* str, size_t len)
|
||||
return this->setMbs(this->run, str, len);
|
||||
}
|
||||
|
||||
int Hawk::Value::setMbs (Run* r, const hawk_bch_t* str, size_t len)
|
||||
int Hawk::Value::setMbs (Run* r, const hawk_bch_t* str, hawk_oow_t len)
|
||||
{
|
||||
val_t* tmp;
|
||||
|
||||
@ -771,7 +769,7 @@ int Hawk::Value::setMbs (const hawk_bch_t* str)
|
||||
int Hawk::Value::setMbs (Run* r, const hawk_bch_t* str)
|
||||
{
|
||||
val_t* tmp;
|
||||
tmp = hawk_rtx_makembsval(r->rtx, str, hawk_mbslen(str));
|
||||
tmp = hawk_rtx_makembsval(r->rtx, str, hawk_count_bcstr(str));
|
||||
if (!tmp)
|
||||
{
|
||||
r->awk->retrieveError (r);
|
||||
@ -894,19 +892,19 @@ int Hawk::Value::setIndexedFlt (Run* r, const Index& idx, flt_t v)
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedStr (const Index& idx, const char_t* str, size_t len, bool numeric)
|
||||
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
|
||||
{
|
||||
if (run == HAWK_NULL) return -1;
|
||||
return this->setIndexedStr(run, idx, str, len, numeric);
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedStr (
|
||||
Run* r, const Index& idx, const char_t* str, size_t len, bool numeric)
|
||||
Run* r, const Index& idx, const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
|
||||
{
|
||||
val_t* tmp;
|
||||
|
||||
oocs_t oocs;
|
||||
oocs.ptr = (char_t*)str;
|
||||
hawk_oocs_t oocs;
|
||||
oocs.ptr = (hawk_ooch_t*)str;
|
||||
oocs.len = len;
|
||||
|
||||
tmp = numeric? hawk_rtx_makenstrvalwithoocs(r->rtx, &oocs):
|
||||
@ -924,13 +922,13 @@ int Hawk::Value::setIndexedStr (
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedStr (const Index& idx, const char_t* str, bool numeric)
|
||||
int Hawk::Value::setIndexedStr (const Index& idx, const hawk_ooch_t* str, bool numeric)
|
||||
{
|
||||
if (run == HAWK_NULL) return -1;
|
||||
return this->setIndexedStr(run, idx, str, numeric);
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const char_t* str, bool numeric)
|
||||
int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str, bool numeric)
|
||||
{
|
||||
val_t* tmp;
|
||||
tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str):
|
||||
@ -948,13 +946,13 @@ int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const char_t* str, boo
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str, size_t len)
|
||||
int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str, hawk_oow_t len)
|
||||
{
|
||||
if (run == HAWK_NULL) return -1;
|
||||
return this->setIndexedMbs(run, idx, str, len);
|
||||
}
|
||||
|
||||
int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, size_t len)
|
||||
int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, hawk_oow_t len)
|
||||
{
|
||||
val_t* tmp;
|
||||
|
||||
@ -985,7 +983,7 @@ int Hawk::Value::setIndexedMbs (const Index& idx, const hawk_bch_t* str)
|
||||
int Hawk::Value::setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str)
|
||||
{
|
||||
val_t* tmp;
|
||||
tmp = hawk_rtx_makembsval(r->rtx, str, hawk_mbslen(str));
|
||||
tmp = hawk_rtx_makembsval(r->rtx, str, hawk_count_bcstr(str));
|
||||
if (tmp == HAWK_NULL)
|
||||
{
|
||||
r->awk->retrieveError (r);
|
||||
@ -1018,7 +1016,7 @@ int Hawk::Value::getIndexed (const Index& idx, Value* v) const
|
||||
}
|
||||
|
||||
// get the value from the map.
|
||||
val_t* fv = hawk_rtx_getmapvalfld(this->run->rtx, val, (char_t*)idx.ptr, idx.len);
|
||||
val_t* fv = hawk_rtx_getmapvalfld(this->run->rtx, val, (hawk_ooch_t*)idx.ptr, idx.len);
|
||||
|
||||
// the key is not found. it is not an error. v is just nil
|
||||
if (fv == HAWK_NULL)
|
||||
@ -1121,20 +1119,20 @@ Hawk::loc_t Hawk::Run::getErrorLocation () const
|
||||
return *hawk_rtx_geterrloc (this->rtx);
|
||||
}
|
||||
|
||||
const Hawk::char_t* Hawk::Run::getErrorMessage () const
|
||||
const hawk_ooch_t* Hawk::Run::getErrorMessage () const
|
||||
{
|
||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||
return hawk_rtx_geterrmsg (this->rtx);
|
||||
}
|
||||
|
||||
void Hawk::Run::setError (errnum_t code, const oocs_t* args, const loc_t* loc)
|
||||
void Hawk::Run::setError (errnum_t code, const hawk_oocs_t* args, const loc_t* loc)
|
||||
{
|
||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||
hawk_rtx_seterror (this->rtx, code, args, loc);
|
||||
}
|
||||
|
||||
void Hawk::Run::setErrorWithMessage (
|
||||
errnum_t code, const char_t* msg, const loc_t* loc)
|
||||
errnum_t code, const hawk_ooch_t* msg, const loc_t* loc)
|
||||
{
|
||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||
|
||||
@ -1174,7 +1172,7 @@ int Hawk::Run::setGlobal (int id, flt_t v)
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::Run::setGlobal (int id, const char_t* ptr, size_t len)
|
||||
int Hawk::Run::setGlobal (int id, const hawk_ooch_t* ptr, hawk_oow_t len)
|
||||
{
|
||||
HAWK_ASSERT (this->rtx != HAWK_NULL);
|
||||
|
||||
@ -1224,14 +1222,14 @@ Hawk::operator Hawk::awk_t* () const
|
||||
return this->awk;
|
||||
}
|
||||
|
||||
const Hawk::char_t* Hawk::getErrorString (errnum_t num) const
|
||||
const hawk_ooch_t* Hawk::getErrorString (errnum_t num) const
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
HAWK_ASSERT (dflerrstr != HAWK_NULL);
|
||||
return dflerrstr (awk, num);
|
||||
}
|
||||
|
||||
const Hawk::char_t* Hawk::xerrstr (awk_t* a, errnum_t num)
|
||||
const hawk_ooch_t* Hawk::xerrstr (awk_t* a, errnum_t num)
|
||||
{
|
||||
Hawk* awk = *(Hawk**)GET_XTN(a);
|
||||
return awk->getErrorString (num);
|
||||
@ -1248,12 +1246,12 @@ Hawk::loc_t Hawk::getErrorLocation () const
|
||||
return this->errinf.loc;
|
||||
}
|
||||
|
||||
const Hawk::char_t* Hawk::getErrorMessage () const
|
||||
const hawk_ooch_t* Hawk::getErrorMessage () const
|
||||
{
|
||||
return this->errinf.msg;
|
||||
}
|
||||
|
||||
void Hawk::setError (errnum_t code, const oocs_t* args, const loc_t* loc)
|
||||
void Hawk::setError (errnum_t code, const hawk_oocs_t* args, const loc_t* loc)
|
||||
{
|
||||
if (awk != HAWK_NULL)
|
||||
{
|
||||
@ -1270,7 +1268,7 @@ void Hawk::setError (errnum_t code, const oocs_t* args, const loc_t* loc)
|
||||
}
|
||||
}
|
||||
|
||||
void Hawk::setErrorWithMessage (errnum_t code, const char_t* msg, const loc_t* loc)
|
||||
void Hawk::setErrorWithMessage (errnum_t code, const hawk_ooch_t* msg, const loc_t* loc)
|
||||
{
|
||||
HAWK_MEMSET (&errinf, 0, HAWK_SIZEOF(errinf));
|
||||
|
||||
@ -1328,11 +1326,11 @@ int Hawk::open ()
|
||||
hawk_prm_t prm;
|
||||
|
||||
HAWK_MEMSET (&prm, 0, HAWK_SIZEOF(prm));
|
||||
prm.math.pow = pow;
|
||||
prm.math.mod = mod;
|
||||
prm.modopen = modopen;
|
||||
prm.modclose = modclose;
|
||||
prm.modsym = modsym;
|
||||
prm.math.pow = pow;
|
||||
prm.math.mod = mod;
|
||||
prm.modopen = modopen;
|
||||
prm.modclose = modclose;
|
||||
prm.modgetsym = modgetsym;
|
||||
|
||||
hawk_errnum_t errnum;
|
||||
this->awk = hawk_open(this->getMmgr(), HAWK_SIZEOF(xtn_t), &prm, &errnum);
|
||||
@ -1492,7 +1490,7 @@ int Hawk::loop (Value* ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, size_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->runctx.rtx != HAWK_NULL);
|
||||
@ -1514,7 +1512,7 @@ int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, size_t na
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < nargs; i++) ptr[i] = (val_t*)args[i];
|
||||
for (hawk_oow_t i = 0; i < nargs; i++) ptr[i] = (val_t*)args[i];
|
||||
}
|
||||
|
||||
val_t* rv = hawk_rtx_callwithbcstr(this->runctx.rtx, name, ptr, nargs);
|
||||
@ -1533,7 +1531,7 @@ int Hawk::call (const hawk_bch_t* name, Value* ret, const Value* args, size_t na
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, size_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->runctx.rtx != HAWK_NULL);
|
||||
@ -1555,7 +1553,7 @@ int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, size_t na
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < nargs; i++) ptr[i] = (val_t*)args[i];
|
||||
for (hawk_oow_t i = 0; i < nargs; i++) ptr[i] = (val_t*)args[i];
|
||||
}
|
||||
|
||||
val_t* rv = hawk_rtx_callwithucstr(this->runctx.rtx, name, ptr, nargs);
|
||||
@ -1584,7 +1582,7 @@ int Hawk::init_runctx ()
|
||||
{
|
||||
if (this->runctx.rtx) return 0;
|
||||
|
||||
hawk_rio_t rio;
|
||||
hawk_rio_cbs_t rio;
|
||||
|
||||
rio.pipe = pipeHandler;
|
||||
rio.file = fileHandler;
|
||||
@ -1629,16 +1627,16 @@ void Hawk::setTrait (int trait)
|
||||
hawk_setopt (awk, HAWK_TRAIT, &trait);
|
||||
}
|
||||
|
||||
Hawk::size_t Hawk::getMaxDepth (depth_t id) const
|
||||
hawk_oow_t Hawk::getMaxDepth (depth_t id) const
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
|
||||
size_t depth;
|
||||
hawk_oow_t depth;
|
||||
hawk_getopt (awk, (hawk_opt_t)id, &depth);
|
||||
return depth;
|
||||
}
|
||||
|
||||
void Hawk::setMaxDepth (depth_t id, size_t depth)
|
||||
void Hawk::setMaxDepth (depth_t id, hawk_oow_t depth)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
hawk_setopt (awk, (hawk_opt_t)id, &depth);
|
||||
@ -1671,7 +1669,7 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
handler = pair->value;
|
||||
#endif
|
||||
|
||||
size_t i, nargs = hawk_rtx_getnargs(run->rtx);
|
||||
hawk_oow_t i, nargs = hawk_rtx_getnargs(run->rtx);
|
||||
|
||||
Value buf[16];
|
||||
Value* args;
|
||||
@ -1724,9 +1722,7 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
|
||||
if (idx == 0)
|
||||
{
|
||||
xx = args[i].setStr (run,
|
||||
HAWK_STR_PTR(&run->rtx->inrec.line),
|
||||
HAWK_STR_LEN(&run->rtx->inrec.line));
|
||||
xx = args[i].setStr(run, HAWK_OOECS_PTR(&run->rtx->inrec.line), HAWK_OOECS_LEN(&run->rtx->inrec.line));
|
||||
}
|
||||
else if (idx <= run->rtx->inrec.nflds)
|
||||
{
|
||||
@ -1736,7 +1732,7 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
}
|
||||
else
|
||||
{
|
||||
xx = args[i].setStr (run, HAWK_T(""), (size_t)0);
|
||||
xx = args[i].setStr (run, HAWK_T(""), (hawk_oow_t)0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1779,8 +1775,8 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
{
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
HAWK_ASSERTX (args[i].run == run,
|
||||
"Do NOT change the run field from function handler");
|
||||
// Do NOT change the run field from function handler
|
||||
HAWK_ASSERT (args[i].run == run);
|
||||
|
||||
val_t* v = hawk_rtx_getarg(run->rtx, i);
|
||||
if (HAWK_RTX_GETVALTYPE(run->rtx, v) == HAWK_VAL_REF)
|
||||
@ -1821,12 +1817,12 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
|
||||
int Hawk::xstrs_t::add (awk_t* awk, const hawk_ooch_t* arg, hawk_oow_t len)
|
||||
{
|
||||
if (this->len >= this->capa)
|
||||
{
|
||||
hawk_oocs_t* ptr;
|
||||
size_t capa = this->capa;
|
||||
hawk_oow_t capa = this->capa;
|
||||
|
||||
capa += 64;
|
||||
ptr = (hawk_oocs_t*)hawk_reallocmem(awk, this->ptr, HAWK_SIZEOF(hawk_oocs_t)*(capa+1));
|
||||
@ -1837,7 +1833,7 @@ int Hawk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
|
||||
}
|
||||
|
||||
this->ptr[this->len].len = len;
|
||||
this->ptr[this->len].ptr = hawk_strxdup(awk, arg, len);
|
||||
this->ptr[this->len].ptr = hawk_dupoochars(awk, arg, len);
|
||||
if (this->ptr[this->len].ptr == HAWK_NULL) return -1;
|
||||
|
||||
this->len++;
|
||||
@ -1860,7 +1856,7 @@ void Hawk::xstrs_t::clear (awk_t* awk)
|
||||
}
|
||||
}
|
||||
|
||||
int Hawk::addArgument (const char_t* arg, size_t len)
|
||||
int Hawk::addArgument (const hawk_ooch_t* arg, hawk_oow_t len)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
int n = runarg.add(awk, arg, len);
|
||||
@ -1868,9 +1864,9 @@ int Hawk::addArgument (const char_t* arg, size_t len)
|
||||
return n;
|
||||
}
|
||||
|
||||
int Hawk::addArgument (const char_t* arg)
|
||||
int Hawk::addArgument (const hawk_ooch_t* arg)
|
||||
{
|
||||
return addArgument(arg, hawk_strlen(arg));
|
||||
return addArgument(arg, hawk_count_oocstr(arg));
|
||||
}
|
||||
|
||||
void Hawk::clearArguments ()
|
||||
@ -1954,7 +1950,7 @@ int Hawk::getGlobal (int id, Value& v)
|
||||
}
|
||||
|
||||
int Hawk::addFunction (
|
||||
const hawk_bch_t* name, size_t minArgs, size_t maxArgs,
|
||||
const hawk_bch_t* name, hawk_oow_t minArgs, hawk_oow_t maxArgs,
|
||||
const hawk_bch_t* argSpec, FunctionHandler handler, int validOpts)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
@ -1982,7 +1978,7 @@ int Hawk::addFunction (
|
||||
//
|
||||
// the function name exists in the underlying function table.
|
||||
// use the pointer to the name to maintain the hash table.
|
||||
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (char_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));
|
||||
#else
|
||||
FunctionMap::Pair* pair;
|
||||
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
||||
@ -2000,7 +1996,7 @@ int Hawk::addFunction (
|
||||
}
|
||||
|
||||
int Hawk::addFunction (
|
||||
const hawk_uch_t* name, size_t minArgs, size_t maxArgs,
|
||||
const hawk_uch_t* name, hawk_oow_t minArgs, hawk_oow_t maxArgs,
|
||||
const hawk_uch_t* argSpec, FunctionHandler handler, int validOpts)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
@ -2028,7 +2024,7 @@ int Hawk::addFunction (
|
||||
//
|
||||
// the function name exists in the underlying function table.
|
||||
// use the pointer to the name to maintain the hash table.
|
||||
hawk_htb_pair_t* pair = hawk_htb_upsert(this->functionMap, (char_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));
|
||||
#else
|
||||
FunctionMap::Pair* pair;
|
||||
try { pair = this->functionMap.upsert(Cstr(fnc->name.ptr, fnc->name.len), handler); }
|
||||
@ -2045,7 +2041,7 @@ int Hawk::addFunction (
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hawk::deleteFunction (const char_t* name)
|
||||
int Hawk::deleteFunction (const hawk_ooch_t* name)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
|
||||
@ -2053,7 +2049,7 @@ int Hawk::deleteFunction (const char_t* name)
|
||||
if (n == 0)
|
||||
{
|
||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||
hawk_htb_delete (this->functionMap, name, hawk_strlen(name));
|
||||
hawk_htb_delete (this->functionMap, name, hawk_count_oocstr(name));
|
||||
#else
|
||||
this->functionMap.remove (Cstr(name));
|
||||
#endif
|
||||
@ -2063,9 +2059,9 @@ int Hawk::deleteFunction (const char_t* name)
|
||||
return n;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::readSource (
|
||||
hawk_ooi_t Hawk::readSource (
|
||||
awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg,
|
||||
char_t* data, size_t count)
|
||||
hawk_ooch_t* data, hawk_oow_t count)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(awk);
|
||||
Source::Data sdat (xtn->awk, Source::READ, arg);
|
||||
@ -2083,9 +2079,9 @@ Hawk::ssize_t Hawk::readSource (
|
||||
}
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writeSource (
|
||||
hawk_ooi_t Hawk::writeSource (
|
||||
awk_t* awk, hawk_sio_cmd_t cmd, sio_arg_t* arg,
|
||||
char_t* data, size_t count)
|
||||
hawk_ooch_t* data, hawk_oow_t count)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(awk);
|
||||
Source::Data sdat (xtn->awk, Source::WRITE, arg);
|
||||
@ -2103,7 +2099,7 @@ Hawk::ssize_t Hawk::writeSource (
|
||||
}
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||
hawk_ooi_t Hawk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, hawk_oow_t count)
|
||||
{
|
||||
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||
Hawk* awk = rxtn->run->awk;
|
||||
@ -2167,7 +2163,7 @@ Hawk::ssize_t Hawk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, voi
|
||||
}
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||
hawk_ooi_t Hawk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, hawk_oow_t count)
|
||||
{
|
||||
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||
Hawk* awk = rxtn->run->awk;
|
||||
@ -2231,7 +2227,7 @@ Hawk::ssize_t Hawk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, voi
|
||||
}
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::consoleHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||
hawk_ooi_t Hawk::consoleHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, hawk_oow_t count)
|
||||
{
|
||||
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||
Hawk* awk = rxtn->run->awk;
|
||||
@ -2311,19 +2307,19 @@ int Hawk::closePipe (Pipe& io)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::readPipe (Pipe& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writePipe (Pipe& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writePipeBytes (Pipe& io, const hawk_bch_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
@ -2347,19 +2343,19 @@ int Hawk::closeFile (File& io)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::readFile (File& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writeFile (File& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writeFileBytes (File& io, const hawk_bch_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
@ -2383,19 +2379,19 @@ int Hawk::closeConsole (Console& io)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::readConsole (Console& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::readConsole (Console& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writeConsole (Console& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writeConsole (Console& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Hawk::ssize_t Hawk::writeConsoleBytes (Console& io, const hawk_bch_t* buf, size_t len)
|
||||
hawk_ooi_t Hawk::writeConsoleBytes (Console& io, const hawk_bch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
((Run*)io)->setError (HAWK_ENOIMPL);
|
||||
return -1;
|
||||
@ -2443,10 +2439,10 @@ void Hawk::modclose (awk_t* awk, void* handle)
|
||||
xtn->awk->modclose (handle);
|
||||
}
|
||||
|
||||
void* Hawk::modsym (awk_t* awk, void* handle, const char_t* name)
|
||||
void* Hawk::modgetsym (awk_t* awk, void* handle, const hawk_ooch_t* name)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(awk);
|
||||
return xtn->awk->modsym (handle, name);
|
||||
return xtn->awk->modgetsym (handle, name);
|
||||
}
|
||||
/////////////////////////////////
|
||||
HAWK_END_NAMESPACE(HAWK)
|
||||
|
@ -30,10 +30,14 @@
|
||||
#include <hawk.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
//#define HAWK_AWK_USE_HTB_FOR_FUNCTION_MAP 1
|
||||
//#define HAWK_AWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW 1
|
||||
#define HAWK_USE_HTB_FOR_FUNCTION_MAP 1
|
||||
//#define HAWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW 1
|
||||
|
||||
#if defined(HAWK_AWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||
// TOOD: redefine these NAMESPACE stuffs or move them somewhere else
|
||||
#define HAWK_BEGIN_NAMESPACE(x) namespace x {
|
||||
#define HAWK_END_NAMESPACE(x) }
|
||||
|
||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||
# include <hawk-htb.h>
|
||||
#else
|
||||
# include <hawk/HashTable.hpp>
|
||||
@ -71,13 +75,13 @@ public:
|
||||
|
||||
enum depth_t
|
||||
{
|
||||
DEPTH_INCLUDE = HAWK_AWK_DEPTH_INCLUDE,
|
||||
DEPTH_BLOCK_PARSE = HAWK_AWK_DEPTH_BLOCK_PARSE,
|
||||
DEPTH_BLOCK_RUN = HAWK_AWK_DEPTH_BLOCK_RUN,
|
||||
DEPTH_EXPR_PARSE = HAWK_AWK_DEPTH_EXPR_PARSE,
|
||||
DEPTH_EXPR_RUN = HAWK_AWK_DEPTH_EXPR_RUN,
|
||||
DEPTH_REX_BUILD = HAWK_AWK_DEPTH_REX_BUILD,
|
||||
DEPTH_REX_MATCH = HAWK_AWK_DEPTH_REX_MATCH
|
||||
DEPTH_INCLUDE = HAWK_DEPTH_INCLUDE,
|
||||
DEPTH_BLOCK_PARSE = HAWK_DEPTH_BLOCK_PARSE,
|
||||
DEPTH_BLOCK_RUN = HAWK_DEPTH_BLOCK_RUN,
|
||||
DEPTH_EXPR_PARSE = HAWK_DEPTH_EXPR_PARSE,
|
||||
DEPTH_EXPR_RUN = HAWK_DEPTH_EXPR_RUN,
|
||||
DEPTH_REX_BUILD = HAWK_DEPTH_REX_BUILD,
|
||||
DEPTH_REX_MATCH = HAWK_DEPTH_REX_MATCH
|
||||
};
|
||||
|
||||
/// The gbl_id_t type redefines #hawk_gbl_id_t.
|
||||
@ -120,16 +124,16 @@ protected:
|
||||
/// to customize an error message. You must include the same numbers
|
||||
/// of ${X}'s as the orginal formatting string. Their order may be
|
||||
/// different. The example below changes the formatting string for
|
||||
/// #HAWK_AWK_ENOENT.
|
||||
/// #HAWK_ENOENT.
|
||||
/// \code
|
||||
/// const MyHawk::char_t* MyHawk::getErrorString (errnum_t num) const
|
||||
/// const hawk_ooch_t* MyHawk::getErrorString (hawk_errnum_t num) const
|
||||
/// {
|
||||
/// if (num == HAWK_AWK_ENOENT) return HAWK_T("cannot find '${0}'");
|
||||
/// if (num == HAWK_ENOENT) return HAWK_T("cannot find '${0}'");
|
||||
/// return Hawk::getErrorString (num);
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
virtual const char_t* getErrorString (
|
||||
virtual const hawk_ooch_t* getErrorString (
|
||||
errnum_t num
|
||||
) const;
|
||||
|
||||
@ -150,14 +154,14 @@ public:
|
||||
/// The Hawk::getErrorMessage() function returns a message describing
|
||||
/// the last error occurred.
|
||||
///
|
||||
const char_t* getErrorMessage () const;
|
||||
const hawk_ooch_t* getErrorMessage () const;
|
||||
|
||||
///
|
||||
/// The setError() function sets error information.
|
||||
///
|
||||
void setError (
|
||||
errnum_t code, ///< error code
|
||||
const oocs_t* args = HAWK_NULL, ///< message formatting
|
||||
const hawk_oocs_t* args = HAWK_NULL, ///< message formatting
|
||||
/// argument array
|
||||
const loc_t* loc = HAWK_NULL ///< error location
|
||||
);
|
||||
@ -168,7 +172,7 @@ public:
|
||||
///
|
||||
void setErrorWithMessage (
|
||||
errnum_t code, ///< error code
|
||||
const char_t* msg, ///< error message
|
||||
const hawk_ooch_t* msg, ///< error message
|
||||
const loc_t* loc ///< error location
|
||||
);
|
||||
|
||||
@ -229,19 +233,19 @@ public:
|
||||
return this->arg->prev == HAWK_NULL;
|
||||
}
|
||||
|
||||
const char_t* getName() const
|
||||
const hawk_ooch_t* getName() const
|
||||
{
|
||||
return this->arg->name;
|
||||
}
|
||||
|
||||
// since it doesn't copy the contents,
|
||||
// it should point to something that outlives this object.
|
||||
void setName (const char_t* name)
|
||||
void setName (const hawk_ooch_t* name)
|
||||
{
|
||||
this->arg->name = name;
|
||||
}
|
||||
|
||||
const char_t* getPrevName() const
|
||||
const hawk_ooch_t* getPrevName() const
|
||||
{
|
||||
return this->arg->prev->name;
|
||||
}
|
||||
@ -282,8 +286,8 @@ public:
|
||||
|
||||
virtual int open (Data& io) = 0;
|
||||
virtual int close (Data& io) = 0;
|
||||
virtual ssize_t read (Data& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t write (Data& io, const char_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t read (Data& io, hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
|
||||
///
|
||||
/// The NONE object indicates no source.
|
||||
@ -301,8 +305,8 @@ protected:
|
||||
public:
|
||||
int open (Data& io) { return -1; }
|
||||
int close (Data& io) { return 0; }
|
||||
ssize_t read (Data& io, char_t* buf, size_t len) { return 0; }
|
||||
ssize_t write (Data& io, const char_t* buf, size_t len) { return 0; }
|
||||
hawk_ooi_t read (Data& io, hawk_ooch_t* buf, hawk_oow_t len) { return 0; }
|
||||
hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len) { return 0; }
|
||||
};
|
||||
|
||||
public:
|
||||
@ -317,7 +321,7 @@ public:
|
||||
RIOBase (Run* run, rio_arg_t* riod);
|
||||
|
||||
public:
|
||||
const char_t* getName() const;
|
||||
const hawk_ooch_t* getName() const;
|
||||
|
||||
const void* getHandle () const;
|
||||
void setHandle (void* handle);
|
||||
@ -353,11 +357,11 @@ public:
|
||||
enum Mode
|
||||
{
|
||||
/// open for read-only access
|
||||
READ = HAWK_AWK_RIO_PIPE_READ,
|
||||
READ = HAWK_RIO_PIPE_READ,
|
||||
/// open for write-only access
|
||||
WRITE = HAWK_AWK_RIO_PIPE_WRITE,
|
||||
WRITE = HAWK_RIO_PIPE_WRITE,
|
||||
/// open for read and write
|
||||
RW = HAWK_AWK_RIO_PIPE_RW
|
||||
RW = HAWK_RIO_PIPE_RW
|
||||
};
|
||||
|
||||
/// The CloseMode type defines the closing mode for a pipe
|
||||
@ -365,11 +369,11 @@ public:
|
||||
enum CloseMode
|
||||
{
|
||||
/// close both read and write ends
|
||||
CLOSE_FULL = HAWK_AWK_RIO_CLOSE_FULL,
|
||||
CLOSE_FULL = HAWK_RIO_CMD_CLOSE_FULL,
|
||||
/// close the read end only
|
||||
CLOSE_READ = HAWK_AWK_RIO_CLOSE_READ,
|
||||
CLOSE_READ = HAWK_RIO_CMD_CLOSE_READ,
|
||||
/// close the write end only
|
||||
CLOSE_WRITE = HAWK_AWK_RIO_CLOSE_WRITE
|
||||
CLOSE_WRITE = HAWK_RIO_CMD_CLOSE_WRITE
|
||||
};
|
||||
|
||||
class HAWK_EXPORT Handler
|
||||
@ -379,9 +383,9 @@ public:
|
||||
|
||||
virtual int open (Pipe& io) = 0;
|
||||
virtual int close (Pipe& io) = 0;
|
||||
virtual ssize_t read (Pipe& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t write (Pipe& io, const char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeBytes (Pipe& io, const hawk_bch_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t read (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual hawk_ooi_t write (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual hawk_ooi_t writeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual int flush (Pipe& io) = 0;
|
||||
};
|
||||
|
||||
@ -412,9 +416,9 @@ public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ = HAWK_AWK_RIO_FILE_READ,
|
||||
WRITE = HAWK_AWK_RIO_FILE_WRITE,
|
||||
APPEND = HAWK_AWK_RIO_FILE_APPEND
|
||||
READ = HAWK_RIO_FILE_READ,
|
||||
WRITE = HAWK_RIO_FILE_WRITE,
|
||||
APPEND = HAWK_RIO_FILE_APPEND
|
||||
};
|
||||
|
||||
class HAWK_EXPORT Handler
|
||||
@ -424,9 +428,9 @@ public:
|
||||
|
||||
virtual int open (File& io) = 0;
|
||||
virtual int close (File& io) = 0;
|
||||
virtual ssize_t read (File& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t write (File& io, const char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeBytes (File& io, const hawk_bch_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t read (File& io, hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual hawk_ooi_t write (File& io, const hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual hawk_ooi_t writeBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len) = 0;
|
||||
virtual int flush (File& io) = 0;
|
||||
};
|
||||
|
||||
@ -449,8 +453,8 @@ public:
|
||||
/// Console mode enumerators
|
||||
enum Mode
|
||||
{
|
||||
READ = HAWK_AWK_RIO_CONSOLE_READ, ///< open for input
|
||||
WRITE = HAWK_AWK_RIO_CONSOLE_WRITE ///< open for output
|
||||
READ = HAWK_RIO_CONSOLE_READ, ///< open for input
|
||||
WRITE = HAWK_RIO_CONSOLE_WRITE ///< open for output
|
||||
};
|
||||
|
||||
///
|
||||
@ -481,16 +485,16 @@ public:
|
||||
/// data not more than \a len characters and return the
|
||||
/// number of characters filled into the buufer. It can
|
||||
/// return 0 to indicate EOF and -1 for failure.
|
||||
virtual ssize_t read (Console& io, char_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t read (Console& io, hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
|
||||
/// The write() function is called when the console
|
||||
/// is written for output. It can write upto \a len characters
|
||||
/// available in the buffer \a buf and return the number of
|
||||
/// characters written. It can return 0 to indicate EOF and -1
|
||||
/// for failure.
|
||||
virtual ssize_t write (Console& io, const char_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t write (Console& io, const hawk_ooch_t* buf, hawk_oow_t len) = 0;
|
||||
|
||||
virtual ssize_t writeBytes (Console& io, const hawk_bch_t* buf, size_t len) = 0;
|
||||
virtual hawk_ooi_t writeBytes (Console& io, const hawk_bch_t* buf, hawk_oow_t len) = 0;
|
||||
|
||||
/// You may choose to buffer the data passed to the write()
|
||||
/// function and perform actual writing when flush() is called.
|
||||
@ -512,11 +516,11 @@ public:
|
||||
/// opened for reading or writing.
|
||||
Mode getMode () const;
|
||||
|
||||
int setFileName (const char_t* name);
|
||||
int setFileName (const hawk_ooch_t* name);
|
||||
int setFNR (int_t fnr);
|
||||
|
||||
protected:
|
||||
char_t* filename;
|
||||
hawk_ooch_t* filename;
|
||||
};
|
||||
|
||||
|
||||
@ -529,10 +533,10 @@ public:
|
||||
public:
|
||||
friend class Hawk;
|
||||
|
||||
#if defined(HAWK_AWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW)
|
||||
#if defined(HAWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW)
|
||||
// initialization
|
||||
void* operator new (size_t n, Run* run) throw ();
|
||||
void* operator new[] (size_t n, Run* run) throw ();
|
||||
void* operator new (hawk_oow_t n, Run* run) throw ();
|
||||
void* operator new[] (hawk_oow_t n, Run* run) throw ();
|
||||
|
||||
#if !defined(__BORLANDC__) && !defined(__WATCOMC__)
|
||||
// deletion when initialization fails
|
||||
@ -556,14 +560,14 @@ public:
|
||||
/// The Index() function creates an empty array index.
|
||||
Index ()
|
||||
{
|
||||
this->ptr = (char_t*)Value::getEmptyStr();
|
||||
this->ptr = (hawk_ooch_t*)Value::getEmptyStr();
|
||||
this->len = 0;
|
||||
}
|
||||
|
||||
/// The Index() function creates a string array index.
|
||||
Index (const char_t* ptr, size_t len)
|
||||
Index (const hawk_ooch_t* ptr, hawk_oow_t len)
|
||||
{
|
||||
this->ptr = (char_t*)ptr;
|
||||
this->ptr = (hawk_ooch_t*)ptr;
|
||||
this->len = len;
|
||||
}
|
||||
|
||||
@ -579,12 +583,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
const char_t* pointer () const
|
||||
const hawk_ooch_t* pointer () const
|
||||
{
|
||||
return this->ptr;
|
||||
}
|
||||
|
||||
size_t length () const
|
||||
hawk_oow_t length () const
|
||||
{
|
||||
return this->len;
|
||||
}
|
||||
@ -609,11 +613,11 @@ public:
|
||||
# error SIZEOF(int_t) TOO LARGE.
|
||||
# error INCREASE THE BUFFER SIZE TO SUPPORT IT.
|
||||
#elif HAWK_SIZEOF_LONG_T == 16
|
||||
char_t buf[41];
|
||||
hawk_ooch_t buf[41];
|
||||
#elif HAWK_SIZEOF_LONG_T == 8
|
||||
char_t buf[21];
|
||||
hawk_ooch_t buf[21];
|
||||
#else
|
||||
char_t buf[12];
|
||||
hawk_ooch_t buf[12];
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -643,7 +647,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
IndexIterator (hawk_htb_pair_t* pair, size_t buckno)
|
||||
IndexIterator (hawk_htb_pair_t* pair, hawk_oow_t buckno)
|
||||
{
|
||||
this->pair = pair;
|
||||
this->buckno = buckno;
|
||||
@ -691,7 +695,7 @@ public:
|
||||
operator val_t* () const { return val; }
|
||||
operator int_t () const;
|
||||
operator flt_t () const;
|
||||
operator const char_t* () const;
|
||||
operator const hawk_ooch_t* () const;
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
operator const hawk_bch_t* () const;
|
||||
#endif
|
||||
@ -711,10 +715,10 @@ public:
|
||||
return operator flt_t ();
|
||||
}
|
||||
|
||||
const char_t* toStr (size_t* len) const
|
||||
const hawk_ooch_t* toStr (hawk_oow_t* len) const
|
||||
{
|
||||
const char_t* p;
|
||||
size_t l;
|
||||
const hawk_ooch_t* p;
|
||||
hawk_oow_t l;
|
||||
|
||||
if (this->getStr(&p, &l) <= -1)
|
||||
{
|
||||
@ -726,10 +730,10 @@ public:
|
||||
return p;
|
||||
}
|
||||
|
||||
const hawk_bch_t* toMbs (size_t* len) const
|
||||
const hawk_bch_t* toMbs (hawk_oow_t* len) const
|
||||
{
|
||||
const hawk_bch_t* p;
|
||||
size_t l;
|
||||
hawk_oow_t l;
|
||||
|
||||
if (this->getMbs(&p, &l) <= -1)
|
||||
{
|
||||
@ -744,8 +748,8 @@ public:
|
||||
int getInt (int_t* v) const;
|
||||
int getFlt (flt_t* v) const;
|
||||
int getNum (int_t* lv, flt_t* fv) const;
|
||||
int getStr (const char_t** str, size_t* len) const;
|
||||
int getMbs (const hawk_bch_t** str, size_t* len) const;
|
||||
int getStr (const hawk_ooch_t** str, hawk_oow_t* len) const;
|
||||
int getMbs (const hawk_bch_t** str, hawk_oow_t* len) const;
|
||||
|
||||
int setVal (val_t* v);
|
||||
int setVal (Run* r, val_t* v);
|
||||
@ -755,13 +759,13 @@ public:
|
||||
int setFlt (flt_t v);
|
||||
int setFlt (Run* r, flt_t v);
|
||||
|
||||
int setStr (const char_t* str, size_t len, bool numeric = false);
|
||||
int setStr (Run* r, const char_t* str, size_t len, bool numeric = false);
|
||||
int setStr (const char_t* str, bool numeric = false);
|
||||
int setStr (Run* r, const char_t* str, bool numeric = false);
|
||||
int setStr (const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false);
|
||||
int setStr (Run* r, const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false);
|
||||
int setStr (const hawk_ooch_t* str, bool numeric = false);
|
||||
int setStr (Run* r, const hawk_ooch_t* str, bool numeric = false);
|
||||
|
||||
int setMbs (const hawk_bch_t* str, size_t len);
|
||||
int setMbs (Run* r, const hawk_bch_t* str, size_t len);
|
||||
int setMbs (const hawk_bch_t* str, hawk_oow_t len);
|
||||
int setMbs (Run* r, const hawk_bch_t* str, hawk_oow_t len);
|
||||
int setMbs (const hawk_bch_t* str);
|
||||
int setMbs (Run* r, const hawk_bch_t* str);
|
||||
|
||||
@ -772,13 +776,13 @@ public:
|
||||
int setIndexedFlt (const Index& idx, flt_t v);
|
||||
int setIndexedFlt (Run* r, const Index& idx, flt_t v);
|
||||
|
||||
int setIndexedStr (const Index& idx, const char_t* str, size_t len, bool numeric = false);
|
||||
int setIndexedStr (Run* r, const Index& idx, const char_t* str, size_t len, bool numeric = false);
|
||||
int setIndexedStr (const Index& idx, const char_t* str, bool numeric = false);
|
||||
int setIndexedStr (Run* r, const Index& idx, const char_t* str, bool numeric = false);
|
||||
int setIndexedStr (const Index& idx, const hawk_ooch_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 (const Index& idx, const hawk_ooch_t* str, bool numeric = false);
|
||||
int setIndexedStr (Run* r, const Index& idx, const hawk_ooch_t* str, bool numeric = false);
|
||||
|
||||
int setIndexedMbs (const Index& idx, const hawk_bch_t* str, size_t len);
|
||||
int setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str, size_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 (const Index& idx, const hawk_bch_t* str);
|
||||
int setIndexedMbs (Run* r, const Index& idx, const hawk_bch_t* str);
|
||||
|
||||
@ -831,7 +835,7 @@ public:
|
||||
} cached;
|
||||
|
||||
public:
|
||||
static const char_t* getEmptyStr();
|
||||
static const hawk_ooch_t* getEmptyStr();
|
||||
static const hawk_bch_t* getEmptyMbs();
|
||||
};
|
||||
|
||||
@ -861,17 +865,17 @@ public:
|
||||
|
||||
errnum_t getErrorNumber () const;
|
||||
loc_t getErrorLocation () const;
|
||||
const char_t* getErrorMessage () const;
|
||||
const hawk_ooch_t* getErrorMessage () const;
|
||||
|
||||
void setError (
|
||||
errnum_t code,
|
||||
const oocs_t* args = HAWK_NULL,
|
||||
const hawk_oocs_t* args = HAWK_NULL,
|
||||
const loc_t* loc = HAWK_NULL
|
||||
);
|
||||
|
||||
void setErrorWithMessage (
|
||||
errnum_t code,
|
||||
const char_t* msg,
|
||||
const hawk_ooch_t* msg,
|
||||
const loc_t* loc
|
||||
);
|
||||
|
||||
@ -898,7 +902,7 @@ public:
|
||||
/// \a ptr.
|
||||
/// \return 0 on success, -1 on failure
|
||||
///
|
||||
int setGlobal (int id, const char_t* ptr, size_t len);
|
||||
int setGlobal (int id, const hawk_ooch_t* ptr, hawk_oow_t len);
|
||||
|
||||
///
|
||||
/// The setGlobal() function sets a global variable
|
||||
@ -1028,7 +1032,7 @@ public:
|
||||
const hawk_bch_t* name, ///< function name
|
||||
Value* ret, ///< return value holder
|
||||
const Value* args, ///< argument array
|
||||
size_t nargs ///< number of arguments
|
||||
hawk_oow_t nargs ///< number of arguments
|
||||
);
|
||||
|
||||
///
|
||||
@ -1038,7 +1042,7 @@ public:
|
||||
const hawk_uch_t* name, ///< function name
|
||||
Value* ret, ///< return value holder
|
||||
const Value* args, ///< argument array
|
||||
size_t nargs ///< number of arguments
|
||||
hawk_oow_t nargs ///< number of arguments
|
||||
);
|
||||
|
||||
///
|
||||
@ -1071,14 +1075,14 @@ public:
|
||||
///
|
||||
void setMaxDepth (
|
||||
depth_t id, ///< depth identifier
|
||||
size_t depth ///< new depth
|
||||
hawk_oow_t depth ///< new depth
|
||||
);
|
||||
|
||||
///
|
||||
/// The getMaxDepth() function gets the maximum depth for an operation
|
||||
/// type identified by \a id.
|
||||
///
|
||||
size_t getMaxDepth (
|
||||
hawk_oow_t getMaxDepth (
|
||||
depth_t id ///< depth identifier
|
||||
) const;
|
||||
|
||||
@ -1090,8 +1094,8 @@ public:
|
||||
/// \return 0 on success, -1 on failure
|
||||
///
|
||||
int addArgument (
|
||||
const char_t* arg, ///< string pointer
|
||||
size_t len ///< string length
|
||||
const hawk_ooch_t* arg, ///< string pointer
|
||||
hawk_oow_t len ///< string length
|
||||
);
|
||||
|
||||
///
|
||||
@ -1101,7 +1105,7 @@ public:
|
||||
/// \return 0 on success, -1 on failure
|
||||
///
|
||||
int addArgument (
|
||||
const char_t* arg ///< string pointer
|
||||
const hawk_ooch_t* arg ///< string pointer
|
||||
);
|
||||
|
||||
///
|
||||
@ -1177,7 +1181,7 @@ public:
|
||||
Run& run,
|
||||
Value& ret,
|
||||
Value* args,
|
||||
size_t nargs,
|
||||
hawk_oow_t nargs,
|
||||
const fnc_info_t* fi
|
||||
);
|
||||
|
||||
@ -1187,8 +1191,8 @@ public:
|
||||
///
|
||||
int addFunction (
|
||||
const hawk_bch_t* name, ///< function name
|
||||
size_t minArgs, ///< minimum numbers of arguments
|
||||
size_t maxArgs, ///< maximum numbers of arguments
|
||||
hawk_oow_t minArgs, ///< minimum numbers of arguments
|
||||
hawk_oow_t maxArgs, ///< maximum numbers of arguments
|
||||
const hawk_bch_t* argSpec, ///< argument specification
|
||||
FunctionHandler handler, ///< function handler
|
||||
int validOpts = 0 ///< valid if these options are set
|
||||
@ -1196,8 +1200,8 @@ public:
|
||||
|
||||
int addFunction (
|
||||
const hawk_uch_t* name, ///< function name
|
||||
size_t minArgs, ///< minimum numbers of arguments
|
||||
size_t maxArgs, ///< maximum numbers of arguments
|
||||
hawk_oow_t minArgs, ///< minimum numbers of arguments
|
||||
hawk_oow_t maxArgs, ///< maximum numbers of arguments
|
||||
const hawk_uch_t* argSpec, ///< argument specification
|
||||
FunctionHandler handler, ///< function handler
|
||||
int validOpts = 0 ///< valid if these options are set
|
||||
@ -1208,7 +1212,7 @@ public:
|
||||
/// function by name.
|
||||
///
|
||||
int deleteFunction (
|
||||
const char_t* name ///< function name
|
||||
const hawk_ooch_t* name ///< function name
|
||||
);
|
||||
/// \}
|
||||
|
||||
@ -1295,9 +1299,9 @@ protected:
|
||||
/// on success and -1 on failure.
|
||||
virtual int closePipe (Pipe& io);
|
||||
|
||||
virtual ssize_t readPipe (Pipe& io, char_t* buf, size_t len);
|
||||
virtual ssize_t writePipe (Pipe& io, const char_t* buf, size_t len);
|
||||
virtual ssize_t writePipeBytes (Pipe& io, const hawk_bch_t* buf, size_t len);
|
||||
virtual hawk_ooi_t readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
virtual int flushPipe (Pipe& io);
|
||||
/// \}
|
||||
|
||||
@ -1309,9 +1313,9 @@ protected:
|
||||
///
|
||||
virtual int openFile (File& io);
|
||||
virtual int closeFile (File& io);
|
||||
virtual ssize_t readFile (File& io, char_t* buf, size_t len);
|
||||
virtual ssize_t writeFile (File& io, const char_t* buf, size_t len);
|
||||
virtual ssize_t writeFileBytes (File& io, const hawk_bch_t* buf, size_t len);
|
||||
virtual hawk_ooi_t readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
virtual int flushFile (File& io);
|
||||
/// \}
|
||||
|
||||
@ -1323,9 +1327,9 @@ protected:
|
||||
///
|
||||
virtual int openConsole (Console& io);
|
||||
virtual int closeConsole (Console& io);
|
||||
virtual ssize_t readConsole (Console& io, char_t* buf, size_t len);
|
||||
virtual ssize_t writeConsole (Console& io, const char_t* buf, size_t len);
|
||||
virtual ssize_t writeConsoleBytes (Console& io, const hawk_bch_t* buf, size_t len);
|
||||
virtual hawk_ooi_t readConsole (Console& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writeConsole (Console& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
virtual hawk_ooi_t writeConsoleBytes (Console& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
virtual int flushConsole (Console& io);
|
||||
virtual int nextConsole (Console& io);
|
||||
/// \}
|
||||
@ -1336,25 +1340,25 @@ protected:
|
||||
|
||||
virtual void* modopen (const mod_spec_t* spec) = 0;
|
||||
virtual void modclose (void* handle) = 0;
|
||||
virtual void* modsym (void* handle, const char_t* name) = 0;
|
||||
virtual void* modgetsym (void* handle, const hawk_ooch_t* name) = 0;
|
||||
|
||||
// static glue members for various handlers
|
||||
static ssize_t readSource (
|
||||
static hawk_ooi_t readSource (
|
||||
awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg,
|
||||
char_t* data, size_t count);
|
||||
static ssize_t writeSource (
|
||||
hawk_ooch_t* data, hawk_oow_t count);
|
||||
static hawk_ooi_t writeSource (
|
||||
awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg,
|
||||
char_t* data, size_t count);
|
||||
hawk_ooch_t* data, hawk_oow_t count);
|
||||
|
||||
static ssize_t pipeHandler (
|
||||
static hawk_ooi_t pipeHandler (
|
||||
rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod,
|
||||
void* data, size_t count);
|
||||
static ssize_t fileHandler (
|
||||
void* data, hawk_oow_t count);
|
||||
static hawk_ooi_t fileHandler (
|
||||
rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod,
|
||||
void* data, size_t count);
|
||||
static ssize_t consoleHandler (
|
||||
void* data, hawk_oow_t count);
|
||||
static hawk_ooi_t consoleHandler (
|
||||
rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod,
|
||||
void* data, size_t count);
|
||||
void* data, hawk_oow_t count);
|
||||
|
||||
static int functionHandler (rtx_t* rtx, const fnc_info_t* fi);
|
||||
|
||||
@ -1364,7 +1368,7 @@ protected:
|
||||
|
||||
static void* modopen (awk_t* awk, const mod_spec_t* spec);
|
||||
static void modclose (awk_t* awk, void* handle);
|
||||
static void* modsym (awk_t* awk, void* handle, const char_t* name);
|
||||
static void* modsym (awk_t* awk, void* handle, const hawk_ooch_t* name);
|
||||
|
||||
public:
|
||||
// use this with care
|
||||
@ -1376,7 +1380,7 @@ protected:
|
||||
errstr_t dflerrstr;
|
||||
errinf_t errinf;
|
||||
|
||||
#if defined(HAWK_AWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
|
||||
hawk_htb_t* functionMap;
|
||||
#else
|
||||
|
||||
@ -1403,12 +1407,12 @@ protected:
|
||||
{
|
||||
xstrs_t (): ptr (HAWK_NULL), len (0), capa (0) {}
|
||||
|
||||
int add (awk_t* awk, const char_t* arg, size_t len);
|
||||
int add (awk_t* awk, const hawk_ooch_t* arg, hawk_oow_t len);
|
||||
void clear (awk_t* awk);
|
||||
|
||||
hawk_oocs_t* ptr;
|
||||
size_t len;
|
||||
size_t capa;
|
||||
hawk_oow_t len;
|
||||
hawk_oow_t capa;
|
||||
};
|
||||
|
||||
xstrs_t runarg;
|
||||
@ -1420,7 +1424,7 @@ private:
|
||||
void fini_runctx ();
|
||||
int dispatch_function (Run* run, const fnc_info_t* fi);
|
||||
|
||||
static const char_t* xerrstr (awk_t* a, errnum_t num);
|
||||
static const hawk_ooch_t* xerrstr (awk_t* a, errnum_t num);
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -61,8 +61,8 @@ static hawk_sio_t* open_sio (Hawk* awk, StdHawk::Run* run, const hawk_ooch_t* fi
|
||||
if (sio == HAWK_NULL)
|
||||
{
|
||||
hawk_oocs_t ea;
|
||||
ea.ptr = (StdHawk::char_t*)file;
|
||||
ea.len = hawk_strlen (file);
|
||||
ea.ptr = (hawk_ooch_t*)file;
|
||||
ea.len = hawk_count_oocstr (file);
|
||||
if (run) run->setError (HAWK_EOPEN, &ea);
|
||||
else awk->setError (HAWK_EOPEN, &ea);
|
||||
}
|
||||
@ -72,7 +72,7 @@ static hawk_sio_t* open_sio (Hawk* awk, StdHawk::Run* run, const hawk_ooch_t* fi
|
||||
static hawk_sio_t* open_sio_std (Hawk* awk, StdHawk::Run* run, hawk_sio_std_t std, int flags)
|
||||
{
|
||||
hawk_sio_t* sio;
|
||||
static const StdHawk::char_t* std_names[] =
|
||||
static const hawk_ooch_t* std_names[] =
|
||||
{
|
||||
HAWK_T("stdin"),
|
||||
HAWK_T("stdout"),
|
||||
@ -84,8 +84,8 @@ static hawk_sio_t* open_sio_std (Hawk* awk, StdHawk::Run* run, hawk_sio_std_t st
|
||||
if (sio == HAWK_NULL)
|
||||
{
|
||||
hawk_oocs_t ea;
|
||||
ea.ptr = (StdHawk::char_t*)std_names[std];
|
||||
ea.len = hawk_strlen (std_names[std]);
|
||||
ea.ptr = (hawk_ooch_t*)std_names[std];
|
||||
ea.len = hawk_count_oocstr (std_names[std]);
|
||||
if (run) run->setError (HAWK_EOPEN, &ea);
|
||||
else awk->setError (HAWK_EOPEN, &ea);
|
||||
}
|
||||
@ -211,7 +211,7 @@ int StdHawk::build_argcv (Run* run)
|
||||
{
|
||||
Value argv (run);
|
||||
|
||||
for (size_t i = 0; i < this->runarg.len; i++)
|
||||
for (hawk_oow_t i = 0; i < this->runarg.len; i++)
|
||||
{
|
||||
if (argv.setIndexedStr (
|
||||
Value::IntIndex(i),
|
||||
@ -226,12 +226,12 @@ int StdHawk::build_argcv (Run* run)
|
||||
|
||||
int StdHawk::__build_environ (Run* run, void* envptr)
|
||||
{
|
||||
hawk_env_char_t** envarr = (hawk_env_char_t**)envptr;
|
||||
hawk_env_hawk_ooch_t** envarr = (hawk_env_hawk_ooch_t**)envptr;
|
||||
Value v_env (run);
|
||||
|
||||
if (envarr)
|
||||
{
|
||||
hawk_env_char_t* eq;
|
||||
hawk_env_hawk_ooch_t* eq;
|
||||
hawk_ooch_t* kptr, * vptr;
|
||||
hawk_oow_t klen, count;
|
||||
hawk_mmgr_t* mmgr = ((Hawk*)*run)->getMmgr();
|
||||
@ -332,18 +332,18 @@ int StdHawk::make_additional_globals (Run* run)
|
||||
return 0;
|
||||
}
|
||||
|
||||
hawk_cmgr_t* StdHawk::getiocmgr (const char_t* ioname)
|
||||
hawk_cmgr_t* StdHawk::getiocmgr (const hawk_ooch_t* ioname)
|
||||
{
|
||||
HAWK_ASSERT (this->cmgrtab_inited == true);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
ioattr_t* ioattr = get_ioattr(ioname, hawk_strlen(ioname));
|
||||
ioattr_t* ioattr = get_ioattr(ioname, hawk_count_oocstr(ioname));
|
||||
if (ioattr) return ioattr->cmgr;
|
||||
#endif
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
StdHawk::ioattr_t* StdHawk::get_ioattr (const char_t* ptr, size_t len)
|
||||
StdHawk::ioattr_t* StdHawk::get_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
|
||||
{
|
||||
hawk_htb_pair_t* pair;
|
||||
|
||||
@ -353,7 +353,7 @@ StdHawk::ioattr_t* StdHawk::get_ioattr (const char_t* ptr, size_t len)
|
||||
return (ioattr_t*)HAWK_HTB_VPTR(pair);
|
||||
}
|
||||
|
||||
StdHawk::ioattr_t* StdHawk::find_or_make_ioattr (const char_t* ptr, size_t len)
|
||||
StdHawk::ioattr_t* StdHawk::find_or_make_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
|
||||
{
|
||||
hawk_htb_pair_t* pair;
|
||||
|
||||
@ -384,12 +384,12 @@ static int timeout_code (const hawk_ooch_t* name)
|
||||
}
|
||||
|
||||
int StdHawk::setioattr (
|
||||
Run& run, Value& ret, Value* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
|
||||
const hawk_ooch_t* name, hawk_oow_t len)
|
||||
{
|
||||
HAWK_ASSERT (this->cmgrtab_inited == true);
|
||||
size_t l[3];
|
||||
const char_t* ptr[3];
|
||||
hawk_oow_t l[3];
|
||||
const hawk_ooch_t* ptr[3];
|
||||
|
||||
ptr[0] = args[0].toStr(&l[0]);
|
||||
ptr[1] = args[1].toStr(&l[1]);
|
||||
@ -459,12 +459,12 @@ int StdHawk::setioattr (
|
||||
}
|
||||
|
||||
int StdHawk::getioattr (
|
||||
Run& run, Value& ret, Value* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
|
||||
const hawk_ooch_t* name, hawk_oow_t len)
|
||||
{
|
||||
HAWK_ASSERT (this->cmgrtab_inited == true);
|
||||
size_t l[2];
|
||||
const char_t* ptr[2];
|
||||
hawk_oow_t l[2];
|
||||
const hawk_ooch_t* ptr[2];
|
||||
|
||||
ptr[0] = args[0].toStr(&l[0]);
|
||||
ptr[1] = args[1].toStr(&l[1]);
|
||||
@ -505,7 +505,7 @@ int StdHawk::open_nwio (Pipe& io, int flags, void* nwad)
|
||||
hawk_nwio_tmout_t* tmout = HAWK_NULL;
|
||||
|
||||
const hawk_ooch_t* name = io.getName();
|
||||
ioattr_t* ioattr = get_ioattr (name, hawk_strlen(name));
|
||||
ioattr_t* ioattr = get_ioattr (name, hawk_count_oocstr(name));
|
||||
if (ioattr)
|
||||
{
|
||||
tmout = &tmout_buf;
|
||||
@ -596,7 +596,7 @@ static int parse_rwpipe_uri (const hawk_ooch_t* uri, int* flags, hawk_nwad_t* nw
|
||||
{ HAWK_T("tcpd://"), 7, HAWK_NWIO_TCP | HAWK_NWIO_PASSIVE },
|
||||
{ HAWK_T("udpd://"), 7, HAWK_NWIO_UDP | HAWK_NWIO_PASSIVE }
|
||||
};
|
||||
StdHawk::size_t i;
|
||||
hawk_oow_t i;
|
||||
|
||||
for (i = 0; i < HAWK_COUNTOF(x); i++)
|
||||
{
|
||||
@ -657,21 +657,21 @@ int StdHawk::closePipe (Pipe& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::readPipe (Pipe& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return (io.getUflags() > 0)?
|
||||
hawk_nwio_read ((hawk_nwio_t*)io.getHandle(), buf, len):
|
||||
hawk_pio_read ((hawk_pio_t*)io.getHandle(), HAWK_PIO_OUT, buf, len);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writePipe (Pipe& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return (io.getUflags() > 0)?
|
||||
hawk_nwio_write((hawk_nwio_t*)io.getHandle(), buf, len):
|
||||
hawk_pio_write((hawk_pio_t*)io.getHandle(), HAWK_PIO_IN, buf, len);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writePipeBytes (Pipe& io, const hawk_bch_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return (io.getUflags() > 0)?
|
||||
hawk_nwio_writebytes((hawk_nwio_t*)io.getHandle(), buf, len):
|
||||
@ -724,17 +724,17 @@ int StdHawk::closeFile (File& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::readFile (File& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return hawk_sio_getoochars((hawk_sio_t*)io.getHandle(), buf, len);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writeFile (File& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return hawk_sio_putoochars((hawk_sio_t*)io.getHandle(), buf, len);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writeFileBytes (File& io, const hawk_bch_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return hawk_sio_putbchars((hawk_sio_t*)io.getHandle(), buf, len);
|
||||
}
|
||||
@ -755,7 +755,7 @@ const hawk_cmgr_t* StdHawk::getConsoleCmgr () const
|
||||
return this->console_cmgr;
|
||||
}
|
||||
|
||||
int StdHawk::addConsoleOutput (const char_t* arg, size_t len)
|
||||
int StdHawk::addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len)
|
||||
{
|
||||
HAWK_ASSERT (awk != HAWK_NULL);
|
||||
int n = this->ofile.add (awk, arg, len);
|
||||
@ -763,9 +763,9 @@ int StdHawk::addConsoleOutput (const char_t* arg, size_t len)
|
||||
return n;
|
||||
}
|
||||
|
||||
int StdHawk::addConsoleOutput (const char_t* arg)
|
||||
int StdHawk::addConsoleOutput (const hawk_ooch_t* arg)
|
||||
{
|
||||
return addConsoleOutput (arg, hawk_strlen(arg));
|
||||
return addConsoleOutput (arg, hawk_count_oocstr(arg));
|
||||
}
|
||||
|
||||
void StdHawk::clearConsoleOutputs ()
|
||||
@ -844,11 +844,11 @@ int StdHawk::open_console_in (Console& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hawk_strlen(file) != this->runarg.ptr[this->runarg_index].len)
|
||||
if (hawk_count_oocstr(file) != this->runarg.ptr[this->runarg_index].len)
|
||||
{
|
||||
oocs_t arg;
|
||||
arg.ptr = (char_t*)file;
|
||||
arg.len = hawk_strlen (arg.ptr);
|
||||
hawk_oocs_t arg;
|
||||
arg.ptr = (hawk_ooch_t*)file;
|
||||
arg.len = hawk_count_oocstr (arg.ptr);
|
||||
((Run*)io)->setError (HAWK_EIONMNL, &arg);
|
||||
return -1;
|
||||
}
|
||||
@ -888,12 +888,12 @@ int StdHawk::open_console_in (Console& io)
|
||||
goto nextfile;
|
||||
}
|
||||
|
||||
if (hawk_strlen(as.ptr) < as.len)
|
||||
if (hawk_count_oocstr(as.ptr) < as.len)
|
||||
{
|
||||
/* the name contains one or more '\0' */
|
||||
oocs_t arg;
|
||||
hawk_oocs_t arg;
|
||||
arg.ptr = as.ptr;
|
||||
arg.len = hawk_strlen (as.ptr);
|
||||
arg.len = hawk_count_oocstr (as.ptr);
|
||||
((Run*)io)->setError (HAWK_EIONMNL, &arg);
|
||||
hawk_rtx_freevaloocstr (rtx, v, as.ptr);
|
||||
return -1;
|
||||
@ -911,7 +911,7 @@ int StdHawk::open_console_in (Console& io)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hawk_rtx_setfilename (rtx, file, hawk_strlen(file)) <= -1)
|
||||
if (hawk_rtx_setfilename (rtx, file, hawk_count_oocstr(file)) <= -1)
|
||||
{
|
||||
hawk_sio_close (sio);
|
||||
hawk_rtx_freevaloocstr (rtx, v, as.ptr);
|
||||
@ -973,11 +973,11 @@ int StdHawk::open_console_out (Console& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hawk_strlen(file) != this->ofile.ptr[this->ofile_index].len)
|
||||
if (hawk_count_oocstr(file) != this->ofile.ptr[this->ofile_index].len)
|
||||
{
|
||||
oocs_t arg;
|
||||
arg.ptr = (char_t*)file;
|
||||
arg.len = hawk_strlen (arg.ptr);
|
||||
hawk_oocs_t arg;
|
||||
arg.ptr = (hawk_ooch_t*)file;
|
||||
arg.len = hawk_count_oocstr (arg.ptr);
|
||||
((Run*)io)->setError (HAWK_EIONMNL, &arg);
|
||||
return -1;
|
||||
}
|
||||
@ -989,7 +989,7 @@ int StdHawk::open_console_out (Console& io)
|
||||
if (sio == HAWK_NULL) return -1;
|
||||
|
||||
if (hawk_rtx_setofilename (
|
||||
rtx, file, hawk_strlen(file)) == -1)
|
||||
rtx, file, hawk_count_oocstr(file)) == -1)
|
||||
{
|
||||
hawk_sio_close (sio);
|
||||
return -1;
|
||||
@ -1036,9 +1036,9 @@ int StdHawk::closeConsole (Console& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::readConsole (Console& io, char_t* data, size_t size)
|
||||
hawk_ooi_t StdHawk::readConsole (Console& io, hawk_ooch_t* data, hawk_oow_t size)
|
||||
{
|
||||
hawk_ssize_t nn;
|
||||
hawk_ooi_t nn;
|
||||
|
||||
while ((nn = hawk_sio_getoochars((hawk_sio_t*)io.getHandle(),data,size)) == 0)
|
||||
{
|
||||
@ -1060,12 +1060,12 @@ StdHawk::ssize_t StdHawk::readConsole (Console& io, char_t* data, size_t size)
|
||||
return nn;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writeConsole (Console& io, const char_t* data, size_t size)
|
||||
hawk_ooi_t StdHawk::writeConsole (Console& io, const hawk_ooch_t* data, hawk_oow_t size)
|
||||
{
|
||||
return hawk_sio_putoochars((hawk_sio_t*)io.getHandle(), data, size);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::writeConsoleBytes (Console& io, const hawk_bch_t* data, size_t size)
|
||||
hawk_ooi_t StdHawk::writeConsoleBytes (Console& io, const hawk_bch_t* data, hawk_oow_t size)
|
||||
{
|
||||
return hawk_sio_putbchars((hawk_sio_t*)io.getHandle(), data, size);
|
||||
}
|
||||
@ -1095,12 +1095,12 @@ int StdHawk::nextConsole (Console& io)
|
||||
}
|
||||
|
||||
// memory allocation primitives
|
||||
void* StdHawk::allocMem (size_t n)
|
||||
void* StdHawk::allocMem (hawk_oow_t n)
|
||||
{
|
||||
return ::malloc (n);
|
||||
}
|
||||
|
||||
void* StdHawk::reallocMem (void* ptr, size_t n)
|
||||
void* StdHawk::reallocMem (void* ptr, hawk_oow_t n)
|
||||
{
|
||||
return ::realloc (ptr, n);
|
||||
}
|
||||
@ -1135,10 +1135,10 @@ void StdHawk::modclose (void* handle)
|
||||
hawk_stdmodclose (this->awk, handle);
|
||||
}
|
||||
|
||||
void* StdHawk::modsym (void* handle, const hawk_ooch_t* name)
|
||||
void* StdHawk::modgetsym (void* handle, const hawk_ooch_t* name)
|
||||
{
|
||||
void* s;
|
||||
s = hawk_stdmodsym (this->awk, handle, name);
|
||||
s = hawk_stdmodgetsym (this->awk, handle, name);
|
||||
if (!s) this->retrieveError ();
|
||||
return s;
|
||||
}
|
||||
@ -1181,9 +1181,9 @@ int StdHawk::SourceFile::open (Data& io)
|
||||
else
|
||||
{
|
||||
// open an included file
|
||||
const char_t* ioname, * file;
|
||||
char_t fbuf[64];
|
||||
char_t* dbuf = HAWK_NULL;
|
||||
const hawk_ooch_t* ioname, * file;
|
||||
hawk_ooch_t fbuf[64];
|
||||
hawk_ooch_t* dbuf = HAWK_NULL;
|
||||
|
||||
ioname = io.getName();
|
||||
HAWK_ASSERT (ioname != HAWK_NULL);
|
||||
@ -1201,10 +1201,10 @@ int StdHawk::SourceFile::open (Data& io)
|
||||
base = hawk_basename(outer);
|
||||
if (base != outer && ioname[0] != HAWK_T('/'))
|
||||
{
|
||||
size_t tmplen, totlen, dirlen;
|
||||
hawk_oow_t tmplen, totlen, dirlen;
|
||||
|
||||
dirlen = base - outer;
|
||||
totlen = hawk_strlen(ioname) + dirlen;
|
||||
totlen = hawk_count_oocstr(ioname) + dirlen;
|
||||
if (totlen >= HAWK_COUNTOF(fbuf))
|
||||
{
|
||||
dbuf = (hawk_ooch_t*) HAWK_MMGR_ALLOC (
|
||||
@ -1221,8 +1221,8 @@ int StdHawk::SourceFile::open (Data& io)
|
||||
}
|
||||
else file = fbuf;
|
||||
|
||||
tmplen = hawk_copy_oochars_to_oocstr_unlimited ((char_t*)file, outer, dirlen);
|
||||
hawk_copy_oocstr_unlimited ((char_t*)file + tmplen, ioname);
|
||||
tmplen = hawk_copy_oochars_to_oocstr_unlimited ((hawk_ooch_t*)file, outer, dirlen);
|
||||
hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1250,12 +1250,12 @@ int StdHawk::SourceFile::close (Data& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::SourceFile::read (Data& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::SourceFile::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return hawk_sio_getoochars ((hawk_sio_t*)io.getHandle(), buf, len);
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::SourceFile::write (Data& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::SourceFile::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
return hawk_sio_putoochars ((hawk_sio_t*)io.getHandle(), buf, len);
|
||||
}
|
||||
@ -1275,9 +1275,9 @@ int StdHawk::SourceString::open (Data& io)
|
||||
{
|
||||
// open an included file
|
||||
|
||||
const char_t* ioname, * file;
|
||||
char_t fbuf[64];
|
||||
char_t* dbuf = HAWK_NULL;
|
||||
const hawk_ooch_t* ioname, * file;
|
||||
hawk_ooch_t fbuf[64];
|
||||
hawk_ooch_t* dbuf = HAWK_NULL;
|
||||
|
||||
ioname = io.getName();
|
||||
HAWK_ASSERT (ioname != HAWK_NULL);
|
||||
@ -1295,10 +1295,10 @@ int StdHawk::SourceString::open (Data& io)
|
||||
base = hawk_basename(outer);
|
||||
if (base != outer && ioname[0] != HAWK_T('/'))
|
||||
{
|
||||
size_t tmplen, totlen, dirlen;
|
||||
hawk_oow_t tmplen, totlen, dirlen;
|
||||
|
||||
dirlen = base - outer;
|
||||
totlen = hawk_strlen(ioname) + dirlen;
|
||||
totlen = hawk_count_oocstr(ioname) + dirlen;
|
||||
if (totlen >= HAWK_COUNTOF(fbuf))
|
||||
{
|
||||
dbuf = (hawk_ooch_t*)HAWK_MMGR_ALLOC(
|
||||
@ -1315,8 +1315,8 @@ int StdHawk::SourceString::open (Data& io)
|
||||
}
|
||||
else file = fbuf;
|
||||
|
||||
tmplen = hawk_copy_oochars_to_oocstr_unlimited ((char_t*)file, outer, dirlen);
|
||||
hawk_copy_oocstr_unlimited ((char_t*)file + tmplen, ioname);
|
||||
tmplen = hawk_copy_oochars_to_oocstr_unlimited ((hawk_ooch_t*)file, outer, dirlen);
|
||||
hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1342,7 +1342,7 @@ int StdHawk::SourceString::close (Data& io)
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::SourceString::read (Data& io, char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::SourceString::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
if (io.isMaster())
|
||||
{
|
||||
@ -1356,7 +1356,7 @@ StdHawk::ssize_t StdHawk::SourceString::read (Data& io, char_t* buf, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
StdHawk::ssize_t StdHawk::SourceString::write (Data& io, const char_t* buf, size_t len)
|
||||
hawk_ooi_t StdHawk::SourceString::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
|
||||
{
|
||||
if (io.isMaster())
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
class HAWK_EXPORT SourceFile: public Source
|
||||
{
|
||||
public:
|
||||
SourceFile (const char_t* name, hawk_cmgr_t* cmgr = HAWK_NULL):
|
||||
SourceFile (const hawk_ooch_t* name, hawk_cmgr_t* cmgr = HAWK_NULL):
|
||||
name (name), cmgr (cmgr)
|
||||
{
|
||||
dir.ptr = HAWK_NULL; dir.len = 0;
|
||||
@ -59,11 +59,11 @@ public:
|
||||
|
||||
int open (Data& io);
|
||||
int close (Data& io);
|
||||
ssize_t read (Data& io, char_t* buf, size_t len);
|
||||
ssize_t write (Data& io, const char_t* buf, size_t len);
|
||||
hawk_ooi_t read (Data& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
|
||||
protected:
|
||||
const char_t* name;
|
||||
const hawk_ooch_t* name;
|
||||
hawk_oocs_t dir;
|
||||
hawk_cmgr_t* cmgr;
|
||||
};
|
||||
@ -75,16 +75,16 @@ public:
|
||||
class HAWK_EXPORT SourceString: public Source
|
||||
{
|
||||
public:
|
||||
SourceString (const char_t* str): str (str) {}
|
||||
SourceString (const hawk_ooch_t* str): str (str) {}
|
||||
|
||||
int open (Data& io);
|
||||
int close (Data& io);
|
||||
ssize_t read (Data& io, char_t* buf, size_t len);
|
||||
ssize_t write (Data& io, const char_t* buf, size_t len);
|
||||
hawk_ooi_t read (Data& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
|
||||
protected:
|
||||
const char_t* str;
|
||||
const char_t* ptr;
|
||||
const hawk_ooch_t* str;
|
||||
const hawk_ooch_t* ptr;
|
||||
};
|
||||
|
||||
StdHawk (Mmgr* mmgr = HAWK_NULL): Hawk(mmgr), stdmod_up(false), console_cmgr(HAWK_NULL)
|
||||
@ -110,8 +110,8 @@ public:
|
||||
|
||||
/// The addConsoleOutput() function adds a file to form an
|
||||
/// output console stream.
|
||||
int addConsoleOutput (const char_t* arg, size_t len);
|
||||
int addConsoleOutput (const char_t* arg);
|
||||
int addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len);
|
||||
int addConsoleOutput (const hawk_ooch_t* arg);
|
||||
|
||||
void clearConsoleOutputs ();
|
||||
|
||||
@ -122,39 +122,39 @@ protected:
|
||||
int __build_environ (Run* run, void* envptr);
|
||||
|
||||
// intrinsic functions
|
||||
hawk_cmgr_t* getiocmgr (const char_t* ioname);
|
||||
hawk_cmgr_t* getiocmgr (const hawk_ooch_t* ioname);
|
||||
|
||||
int setioattr (Run& run, Value& ret, Value* args, size_t nargs, const char_t* name, size_t len);
|
||||
int getioattr (Run& run, Value& ret, Value* args, size_t nargs, const char_t* name, size_t len);
|
||||
int setioattr (Run& run, Value& ret, Value* args, hawk_oow_t nargs, const hawk_ooch_t* name, hawk_oow_t len);
|
||||
int getioattr (Run& run, Value& ret, Value* args, hawk_oow_t nargs, const hawk_ooch_t* name, hawk_oow_t len);
|
||||
|
||||
// pipe io handlers
|
||||
int openPipe (Pipe& io);
|
||||
int closePipe (Pipe& io);
|
||||
ssize_t readPipe (Pipe& io, char_t* buf, size_t len);
|
||||
ssize_t writePipe (Pipe& io, const char_t* buf, size_t len);
|
||||
ssize_t writePipeBytes (Pipe& io, const hawk_bch_t* buf, size_t len);
|
||||
hawk_ooi_t readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
int flushPipe (Pipe& io);
|
||||
|
||||
// file io handlers
|
||||
int openFile (File& io);
|
||||
int closeFile (File& io);
|
||||
ssize_t readFile (File& io, char_t* buf, size_t len);
|
||||
ssize_t writeFile (File& io, const char_t* buf, size_t len);
|
||||
ssize_t writeFileBytes (File& io, const hawk_bch_t* buf, size_t len);
|
||||
hawk_ooi_t readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
int flushFile (File& io);
|
||||
|
||||
// console io handlers
|
||||
int openConsole (Console& io);
|
||||
int closeConsole (Console& io);
|
||||
ssize_t readConsole (Console& io, char_t* buf, size_t len);
|
||||
ssize_t writeConsole (Console& io, const char_t* buf, size_t len);
|
||||
ssize_t writeConsoleBytes (Console& io, const hawk_bch_t* buf, size_t len);
|
||||
hawk_ooi_t readConsole (Console& io, hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writeConsole (Console& io, const hawk_ooch_t* buf, hawk_oow_t len);
|
||||
hawk_ooi_t writeConsoleBytes (Console& io, const hawk_bch_t* buf, hawk_oow_t len);
|
||||
int flushConsole (Console& io);
|
||||
int nextConsole (Console& io);
|
||||
|
||||
// primitive handlers
|
||||
void* allocMem (size_t n);
|
||||
void* reallocMem (void* ptr, size_t n);
|
||||
void* allocMem (hawk_oow_t n);
|
||||
void* reallocMem (void* ptr, hawk_oow_t n);
|
||||
void freeMem (void* ptr);
|
||||
|
||||
flt_t pow (flt_t x, flt_t y);
|
||||
@ -162,7 +162,7 @@ protected:
|
||||
|
||||
void* modopen (const mod_spec_t* spec);
|
||||
void modclose (void* handle);
|
||||
void* modsym (void* handle, const char_t* name);
|
||||
void* modsym (void* handle, const hawk_ooch_t* name);
|
||||
|
||||
protected:
|
||||
hawk_htb_t cmgrtab;
|
||||
@ -177,25 +177,25 @@ protected:
|
||||
int gbl_environ;
|
||||
|
||||
// standard input console - reuse runarg
|
||||
size_t runarg_index;
|
||||
size_t runarg_count;
|
||||
hawk_oow_t runarg_index;
|
||||
hawk_oow_t runarg_count;
|
||||
|
||||
// standard output console
|
||||
xstrs_t ofile;
|
||||
size_t ofile_index;
|
||||
size_t ofile_count;
|
||||
hawk_oow_t ofile_index;
|
||||
hawk_oow_t ofile_count;
|
||||
|
||||
public:
|
||||
struct ioattr_t
|
||||
{
|
||||
hawk_cmgr_t* cmgr;
|
||||
char_t cmgr_name[64]; // i assume that the cmgr name never exceeds this length.
|
||||
hawk_ooch_t cmgr_name[64]; // i assume that the cmgr name never exceeds this length.
|
||||
hawk_ntime_t tmout[4];
|
||||
|
||||
ioattr_t (): cmgr (HAWK_NULL)
|
||||
{
|
||||
this->cmgr_name[0] = HAWK_T('\0');
|
||||
for (size_t i = 0; i < HAWK_COUNTOF(this->tmout); i++)
|
||||
for (hawk_oow_t i = 0; i < HAWK_COUNTOF(this->tmout); i++)
|
||||
{
|
||||
this->tmout[i].sec = -999;
|
||||
this->tmout[i].nsec = 0;
|
||||
@ -206,8 +206,8 @@ public:
|
||||
static ioattr_t default_ioattr;
|
||||
|
||||
protected:
|
||||
ioattr_t* get_ioattr (const char_t* ptr, size_t len);
|
||||
ioattr_t* find_or_make_ioattr (const char_t* ptr, size_t len);
|
||||
ioattr_t* get_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len);
|
||||
ioattr_t* find_or_make_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len);
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user