enhanced Awk classes

This commit is contained in:
2009-07-09 07:01:45 +00:00
parent b682392d5f
commit 1d88a17c7c
4 changed files with 166 additions and 92 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp 224 2009-07-07 13:05:10Z hyunghwan.chung $
* $Id: Awk.hpp 225 2009-07-08 13:01:45Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -87,7 +87,7 @@ public:
* and Source::WRITE respectively when called from
* Awk::readSource and Awk::writeSource.
*
* <pre>
* @code
* int openSource (Source& io)
* {
* if (io.getMode() == Source::READ)
@ -117,7 +117,7 @@ public:
* }
* return -1;
* }
* </pre>
* @endcode
*
* @return Awk::Source::READ or Awk::Source::WRITE
*/
@ -131,7 +131,7 @@ public:
* Awk::closeSource to get the value set in Awk::openSource
* as shown in the example below.
*
* <pre>
* @code
* int closeSource (Source& io)
* {
* if (io.getMode() == Source::READ)
@ -146,10 +146,10 @@ public:
* }
* return -1;
* }
* </pre>
* @endcode
*
* @return an arbitrary value of type void* set with
* Source::setHandle or QSE_NULL
* Source::setHandle() or QSE_NULL
*/
const void* getHandle () const;
@ -526,7 +526,6 @@ public:
};
// end of enum ErrorNumber
// generated by genoptcode.awk
/** Defines options */
enum Option
@ -708,23 +707,12 @@ public:
*/
int getGlobal (int id, Argument& global) const;
/**
* Sets a value into the data field
*/
void setData (void* data);
/**
* Gets the value stored in the data field
*/
void* getData () const;
void* alloc (size_t size);
void free (void* ptr);
protected:
Awk* awk;
rtx_t* rtx;
void* data;
};
/** Constructor */
@ -829,9 +817,9 @@ public:
* override Awk::openSource, Awk::closeSource, Awk::readSource,
* Awk::writeSource to implement the source code stream.
*
* @return 0 on success, -1 on failure
* @return a Run object on success, QSE_NULL on failure
*/
virtual int parse ();
virtual Awk::Run* parse ();
/**
* Executes the BEGIN block, pattern-action blocks, and the END block.
@ -839,6 +827,15 @@ public:
*/
virtual int loop ();
/**
* Calls a function
*/
virtual int call (
const char_t* name,
const Return* args,
size_t nargs
);
/**
* Makes request to abort execution
*/
@ -1077,6 +1074,11 @@ protected:
xstrs_t runarg;
private:
Run runctx;
int init_runctx ();
void fini_runctx ();
static const char_t* xerrstr (awk_t* a, errnum_t num) throw ();
private: