added the Mmgr class and modifiled related classes

This commit is contained in:
2009-05-21 04:44:47 +00:00
parent 3ab1bfff92
commit b7f8bba219
23 changed files with 360 additions and 96 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
* $Id: Awk.cpp 148 2009-05-20 10:44:47Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1065,21 +1065,12 @@ void* Awk::Run::getData () const
// Awk
//////////////////////////////////////////////////////////////////
Awk::Awk (): awk (QSE_NULL), functionMap (QSE_NULL),
Awk::Awk () throw (): awk (QSE_NULL), functionMap (QSE_NULL),
sourceIn (Source::READ), sourceOut (Source::WRITE),
errnum (ERR_NOERR), errlin (0), runCallback (false)
{
this->errmsg[0] = QSE_T('\0');
mmgr.alloc = allocMem;
mmgr.realloc = reallocMem;
mmgr.free = freeMem;
mmgr.data = this;
}
Awk::~Awk ()
{
}
Awk::operator Awk::awk_t* () const
@ -1193,7 +1184,7 @@ int Awk::open ()
prm.pow = pow;
prm.sprintf = sprintf;
awk = qse_awk_open (&mmgr, QSE_SIZEOF(xtn_t), &prm);
awk = qse_awk_open (this, QSE_SIZEOF(xtn_t), &prm);
if (awk == QSE_NULL)
{
setError (ERR_NOMEM);
@ -1754,21 +1745,6 @@ void Awk::onRunStatement (rtx_t* run, size_t line, void* data)
r->awk->onRunStatement (*r, line);
}
void* Awk::allocMem (void* data, size_t n)
{
return ((Awk*)data)->allocMem (n);
}
void* Awk::reallocMem (void* data, void* ptr, size_t n)
{
return ((Awk*)data)->reallocMem (ptr, n);
}
void Awk::freeMem (void* data, void* ptr)
{
((Awk*)data)->freeMem (ptr);
}
Awk::real_t Awk::pow (awk_t* awk, real_t x, real_t y)
{
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);

View File

@ -5,8 +5,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
lib_LTLIBRARIES = libqseawk.la
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
libqseawk_la_LDFLAGS= -L../cmn -L../utl -version-info 1:0:0 -no-undefined
libqseawk_la_LIBADD= -lqsecmn -lqseutl
libqseawk_la_LDFLAGS = -L../cmn -L../utl -version-info 1:0:0 -no-undefined
libqseawk_la_LIBADD = -lqsecmn -lqseutl
if ENABLE_CXX
lib_LTLIBRARIES += libqseawk++.la

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
* $Id: StdAwk.cpp 148 2009-05-20 10:44:47Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -37,10 +37,6 @@
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
StdAwk::StdAwk ()
{
}
#define ADDFNC(name,min,max,impl) \
do { \
if (addFunction (name, min, max, \
@ -396,17 +392,17 @@ int StdAwk::flushFile (File& io)
}
// memory allocation primitives
void* StdAwk::allocMem (size_t n)
void* StdAwk::allocMem (size_t n) throw ()
{
return ::malloc (n);
}
void* StdAwk::reallocMem (void* ptr, size_t n)
void* StdAwk::reallocMem (void* ptr, size_t n) throw ()
{
return ::realloc (ptr, n);
}
void StdAwk::freeMem (void* ptr)
void StdAwk::freeMem (void* ptr) throw ()
{
::free (ptr);
}