Recovered from cvs revision 2007-05-18 05:50:00

This commit is contained in:
hyung-hwan 2007-05-19 01:30:00 +00:00
parent a4d7743175
commit 314b089f0d
2 changed files with 113 additions and 69 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.30 2007/05/16 07:13:32 bacon Exp $
* $Id: Awk.cpp,v 1.31 2007/05/17 15:02:54 bacon Exp $
*/
#include <ase/awk/Awk.hpp>
@ -400,7 +400,9 @@ namespace ASE
//////////////////////////////////////////////////////////////////
Awk::Awk (): awk (ASE_NULL), functionMap (ASE_NULL),
sourceIn (Source::READ), sourceOut (Source::WRITE)
sourceIn (Source::READ), sourceOut (Source::WRITE),
errnum (E_NOERR), errlin (0)
{
}
@ -408,6 +410,97 @@ namespace ASE
{
}
Awk::ErrorCode Awk::getErrorCode ()
{
return this->errnum;
}
Awk::size_t Awk::getErrorLine ()
{
return this->errlin;
}
void Awk::setError (ErrorCode code, size_t line)
{
this->errnum = code;
this->errlin = line;
}
void Awk::clearError ()
{
this->errnum = E_NOERR;
this->errlin = 0;
}
int Awk::open ()
{
ASE_ASSERT (awk == ASE_NULL && functionMap == ASE_NULL);
ase_awk_prmfns_t prmfns;
prmfns.mmgr.malloc = allocMem;
prmfns.mmgr.realloc = reallocMem;
prmfns.mmgr.free = freeMem;
prmfns.mmgr.custom_data = this;
prmfns.ccls.is_upper = isUpper;
prmfns.ccls.is_lower = isLower;
prmfns.ccls.is_alpha = isAlpha;
prmfns.ccls.is_digit = isDigit;
prmfns.ccls.is_xdigit = isXdigit;
prmfns.ccls.is_alnum = isAlnum;
prmfns.ccls.is_space = isSpace;
prmfns.ccls.is_print = isPrint;
prmfns.ccls.is_graph = isGraph;
prmfns.ccls.is_cntrl = isCntrl;
prmfns.ccls.is_punct = isPunct;
prmfns.ccls.to_upper = toUpper;
prmfns.ccls.to_lower = toLower;
prmfns.ccls.custom_data = this;
prmfns.misc.pow = pow;
prmfns.misc.sprintf = sprintf;
prmfns.misc.dprintf = dprintf;
prmfns.misc.custom_data = this;
awk = ase_awk_open (&prmfns, this);
if (awk == ASE_NULL)
{
setError (E_NOMEM);
return -1;
}
functionMap = ase_awk_map_open (
this, 512, freeFunctionMapValue, awk);
if (functionMap == ASE_NULL)
{
ase_awk_close (awk);
awk = ASE_NULL;
setError (E_NOMEM);
return -1;
}
return 0;
}
void Awk::close ()
{
if (functionMap != ASE_NULL)
{
ase_awk_map_close (functionMap);
functionMap = ASE_NULL;
}
if (awk != ASE_NULL)
{
ase_awk_close (awk);
awk = ASE_NULL;
}
clearError ();
}
int Awk::parse ()
{
ASE_ASSERT (awk != ASE_NULL);
@ -491,72 +584,6 @@ namespace ASE
return n;
}
int Awk::open ()
{
ASE_ASSERT (awk == ASE_NULL && functionMap == ASE_NULL);
ase_awk_prmfns_t prmfns;
prmfns.mmgr.malloc = allocMem;
prmfns.mmgr.realloc = reallocMem;
prmfns.mmgr.free = freeMem;
prmfns.mmgr.custom_data = this;
prmfns.ccls.is_upper = isUpper;
prmfns.ccls.is_lower = isLower;
prmfns.ccls.is_alpha = isAlpha;
prmfns.ccls.is_digit = isDigit;
prmfns.ccls.is_xdigit = isXdigit;
prmfns.ccls.is_alnum = isAlnum;
prmfns.ccls.is_space = isSpace;
prmfns.ccls.is_print = isPrint;
prmfns.ccls.is_graph = isGraph;
prmfns.ccls.is_cntrl = isCntrl;
prmfns.ccls.is_punct = isPunct;
prmfns.ccls.to_upper = toUpper;
prmfns.ccls.to_lower = toLower;
prmfns.ccls.custom_data = this;
prmfns.misc.pow = pow;
prmfns.misc.sprintf = sprintf;
prmfns.misc.dprintf = dprintf;
prmfns.misc.custom_data = this;
awk = ase_awk_open (&prmfns, this);
if (awk == ASE_NULL)
{
// TODO: SET ERROR INFO
return -1;
}
functionMap = ase_awk_map_open (
this, 512, freeFunctionMapValue, awk);
if (functionMap == ASE_NULL)
{
// TODO: set ERROR INFO -> ENOMEM...
ase_awk_close (awk);
awk = ASE_NULL;
return -1;
}
return 0;
}
void Awk::close ()
{
if (functionMap != ASE_NULL)
{
ase_awk_map_close (functionMap);
functionMap = ASE_NULL;
}
if (awk != ASE_NULL)
{
ase_awk_close (awk);
awk = ASE_NULL;
}
}
int Awk::dispatchFunction (
run_t* run, const char_t* name, size_t len)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.28 2007/05/16 07:13:32 bacon Exp $
* $Id: Awk.hpp,v 1.29 2007/05/17 15:02:54 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_HPP_
@ -222,9 +222,23 @@ namespace ASE
run_t* run;
};
enum ErrorCode
{
E_NOERR = ASE_AWK_ENOERR,
E_NOMEM = ASE_AWK_ENOMEM
};
Awk ();
virtual ~Awk ();
ErrorCode getErrorCode ();
size_t getErrorLine ();
protected:
void setError (ErrorCode code, size_t line = 0);
void clearError ();
public:
virtual int open ();
virtual void close ();
@ -351,6 +365,9 @@ namespace ASE
Source sourceIn;
Source sourceOut;
ErrorCode errnum;
size_t errlin;
private:
Awk (const Awk&);
Awk& operator= (const Awk&);