added the Mmgr class and modifiled related classes
This commit is contained in:
@ -4,6 +4,10 @@ SUBDIRS = cmn utl awk lsp
|
||||
|
||||
pkginclude_HEADERS = config.h.in conf_msw.h conf_vms.h types.h macros.h pack1.h unpack.h
|
||||
|
||||
if ENABLE_CXX
|
||||
pkginclude_HEADERS += Mmgr.hpp
|
||||
endif
|
||||
|
||||
pkgincludedir= $(includedir)/qse
|
||||
|
||||
CLEANFILES = *dist
|
||||
|
67
qse/include/qse/Mmgr.hpp
Normal file
67
qse/include/qse/Mmgr.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_MMGR_HPP_
|
||||
#define _QSE_MMGR_HPP_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
class Mmgr: public qse_mmgr_t
|
||||
{
|
||||
public:
|
||||
Mmgr () throw ()
|
||||
{
|
||||
this->alloc = alloc_mem;
|
||||
this->realloc = realloc_mem;
|
||||
this->free = free_mem;
|
||||
this->data = this;
|
||||
}
|
||||
|
||||
virtual ~Mmgr () {}
|
||||
|
||||
protected:
|
||||
virtual void* allocMem (qse_size_t n) throw () = 0;
|
||||
virtual void* reallocMem (void* ptr, qse_size_t n) throw () = 0;
|
||||
virtual void freeMem (void* ptr) throw () = 0;
|
||||
|
||||
static void* alloc_mem (void* data, qse_size_t n) throw ()
|
||||
{
|
||||
return ((Mmgr*)data)->allocMem (n);
|
||||
}
|
||||
|
||||
static void* realloc_mem (void* data, void* ptr, qse_size_t n) throw ()
|
||||
{
|
||||
return ((Mmgr*)data)->reallocMem (ptr, n);
|
||||
}
|
||||
|
||||
static void free_mem (void* data, void* ptr) throw ()
|
||||
{
|
||||
return ((Mmgr*)data)->freeMem (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
* $Id: Awk.hpp 148 2009-05-20 10:44:47Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include <qse/awk/awk.h>
|
||||
#include <qse/cmn/map.h>
|
||||
#include <qse/cmn/chr.h>
|
||||
#include <qse/Mmgr.hpp>
|
||||
#include <stdarg.h>
|
||||
|
||||
/////////////////////////////////
|
||||
@ -31,7 +32,7 @@ QSE_BEGIN_NAMESPACE(QSE)
|
||||
/**
|
||||
* Represents the AWK interpreter engine
|
||||
*/
|
||||
class Awk
|
||||
class Awk: public Mmgr
|
||||
{
|
||||
public:
|
||||
/** Boolean data type */
|
||||
@ -732,9 +733,7 @@ public:
|
||||
};
|
||||
|
||||
/** Constructor */
|
||||
Awk ();
|
||||
/** Destructor */
|
||||
virtual ~Awk ();
|
||||
Awk () throw ();
|
||||
|
||||
/** Returns the underlying handle */
|
||||
operator awk_t* () const;
|
||||
@ -1022,10 +1021,6 @@ protected:
|
||||
virtual void onRunStatement (Run& run, size_t line);
|
||||
|
||||
// primitive handlers
|
||||
virtual void* allocMem (size_t n) = 0;
|
||||
virtual void* reallocMem (void* ptr, size_t n) = 0;
|
||||
virtual void freeMem (void* ptr) = 0;
|
||||
|
||||
virtual real_t pow (real_t x, real_t y) = 0;
|
||||
virtual int vsprintf (char_t* buf, size_t size,
|
||||
const char_t* fmt, va_list arg) = 0;
|
||||
@ -1054,10 +1049,6 @@ protected:
|
||||
static void onRunExit (rtx_t* run, val_t* ret, void* data);
|
||||
static void onRunStatement (rtx_t* run, size_t line, void* data);
|
||||
|
||||
static void* allocMem (void* data, size_t n);
|
||||
static void* reallocMem (void* data, void* ptr, size_t n);
|
||||
static void freeMem (void* data, void* ptr);
|
||||
|
||||
static real_t pow (awk_t* data, real_t x, real_t y);
|
||||
static int sprintf (awk_t* data, char_t* buf, size_t size,
|
||||
const char_t* fmt, ...);
|
||||
@ -1078,8 +1069,6 @@ protected:
|
||||
private:
|
||||
Awk (const Awk&);
|
||||
Awk& operator= (const Awk&);
|
||||
|
||||
mmgr_t mmgr;
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
* $Id: StdAwk.hpp 148 2009-05-20 10:44:47Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -33,7 +33,6 @@ QSE_BEGIN_NAMESPACE(QSE)
|
||||
class StdAwk: public Awk
|
||||
{
|
||||
public:
|
||||
StdAwk ();
|
||||
int open ();
|
||||
int run (const char_t** args, size_t nargs);
|
||||
|
||||
@ -80,9 +79,9 @@ protected:
|
||||
int flushFile (File& io);
|
||||
|
||||
// primitive handlers
|
||||
void* allocMem (size_t n);
|
||||
void* reallocMem (void* ptr, size_t n);
|
||||
void freeMem (void* ptr);
|
||||
void* allocMem (size_t n) throw ();
|
||||
void* reallocMem (void* ptr, size_t n) throw ();
|
||||
void freeMem (void* ptr) throw ();
|
||||
|
||||
real_t pow (real_t x, real_t y);
|
||||
int vsprintf (char_t* buf, size_t size,
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h
|
||||
|
||||
#if ENABLE_CXX
|
||||
#pkginclude_HEADERS +=
|
||||
#endif
|
||||
|
||||
pkgincludedir = $(includedir)/qse/cmn
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = sed.h
|
||||
pkginclude_HEADERS = sed.h Sed.hpp StdSed.hpp
|
||||
|
||||
pkgincludedir= $(includedir)/qse/sed
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef _QSE_SED_SED_HPP_
|
||||
#define _QSE_SED_SED_HPP_
|
||||
|
||||
#include <qse/Mmgr.hpp>
|
||||
#include <qse/sed/sed.h>
|
||||
|
||||
/////////////////////////////////
|
||||
@ -28,11 +29,10 @@ QSE_BEGIN_NAMESPACE(QSE)
|
||||
/**
|
||||
* The Sed class implements a stream editor.
|
||||
*/
|
||||
class Sed:
|
||||
class Sed: public Mmgr
|
||||
{
|
||||
public:
|
||||
Sed () throw ();
|
||||
~Sed () throw ();
|
||||
Sed () throw (): sed (QSE_NULL) {}
|
||||
|
||||
int open () throw ();
|
||||
void close () throw ();
|
||||
|
42
qse/include/qse/sed/StdSed.hpp
Normal file
42
qse/include/qse/sed/StdSed.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_SED_STDSED_HPP_
|
||||
#define _QSE_SED_STDSED_HPP_
|
||||
|
||||
#include <qse/sed/Sed.hpp>
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
class StdSed: public Sed
|
||||
{
|
||||
public:
|
||||
|
||||
protected:
|
||||
void* allocMem (qse_size_t n) throw ();
|
||||
void* reallocMem (void* ptr, qse_size_t n) throw ();
|
||||
void freeMem (void* ptr) throw ();
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user