Recovered from cvs revision 2007-09-07 03:08:00
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.52 2007/08/26 14:33:38 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.53 2007/09/06 08:44:42 bacon Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -57,6 +57,16 @@ namespace ASE
|
||||
extio->handle = handle;
|
||||
}
|
||||
|
||||
const Awk::extio_t* Awk::Extio::getRawExtio () const
|
||||
{
|
||||
return extio;
|
||||
}
|
||||
|
||||
const Awk::run_t* Awk::Extio::getRawRun () const
|
||||
{
|
||||
return extio->run;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Awk::Pipe
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@ -690,14 +700,8 @@ namespace ASE
|
||||
runarg[i].ptr = ase_awk_strxdup (awk, args[i], runarg[i].len);
|
||||
if (runarg[i].ptr == ASE_NULL)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
for (i-- ; i > 0; i--)
|
||||
{
|
||||
ase_awk_free (awk, runarg[i].ptr);
|
||||
}
|
||||
}
|
||||
|
||||
while (i > 0) ase_awk_free (awk, runarg[--i].ptr);
|
||||
ase_awk_free (awk, runarg);
|
||||
setError (ERR_NOMEM);
|
||||
return -1;
|
||||
}
|
||||
@ -706,7 +710,7 @@ namespace ASE
|
||||
runarg[i].ptr = ASE_NULL;
|
||||
runarg[i].len = 0;
|
||||
}
|
||||
|
||||
|
||||
int n = ase_awk_run (
|
||||
awk, main, &runios,
|
||||
(runCallback? &runcbs: ASE_NULL),
|
||||
@ -715,10 +719,7 @@ namespace ASE
|
||||
|
||||
if (runarg != ASE_NULL)
|
||||
{
|
||||
for (i--; i > 0; i--)
|
||||
{
|
||||
ase_awk_free (awk, runarg[i].ptr);
|
||||
}
|
||||
while (i > 0) ase_awk_free (awk, runarg[--i].ptr);
|
||||
ase_awk_free (awk, runarg);
|
||||
}
|
||||
|
||||
|
112
ase/awk/Awk.hpp
112
ase/awk/Awk.hpp
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.50 2007/09/04 08:01:46 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.52 2007/09/06 14:38:56 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_AWK_HPP_
|
||||
@ -12,24 +12,62 @@
|
||||
namespace ASE
|
||||
{
|
||||
/**
|
||||
* the awk class
|
||||
* Provides the awk interpreter engine
|
||||
*/
|
||||
class Awk
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* boolean data type
|
||||
*/
|
||||
typedef ase_bool_t bool_t;
|
||||
|
||||
/**
|
||||
* data type that can hold any character
|
||||
*/
|
||||
|
||||
typedef ase_char_t char_t;
|
||||
|
||||
/**
|
||||
* data type that can hold any character or
|
||||
* an end-of-file value
|
||||
*/
|
||||
typedef ase_cint_t cint_t;
|
||||
|
||||
|
||||
typedef ase_size_t size_t;
|
||||
typedef ase_ssize_t ssize_t;
|
||||
typedef ase_long_t long_t;
|
||||
typedef ase_real_t real_t;
|
||||
|
||||
/**
|
||||
* represents an internal awk value
|
||||
*/
|
||||
typedef ase_awk_val_t val_t;
|
||||
|
||||
/**
|
||||
* represents the internal hash table
|
||||
*/
|
||||
typedef ase_awk_map_t map_t;
|
||||
|
||||
/**
|
||||
* represents a key/value pair
|
||||
*/
|
||||
typedef ase_awk_pair_t pair_t;
|
||||
|
||||
/**
|
||||
* represents the external i/o operation
|
||||
*/
|
||||
typedef ase_awk_extio_t extio_t;
|
||||
|
||||
/**
|
||||
* represents the run-time instance of an awk interpreter
|
||||
*/
|
||||
typedef ase_awk_run_t run_t;
|
||||
|
||||
/**
|
||||
* reprensts the underlying awk interpreter
|
||||
*/
|
||||
typedef ase_awk_t awk_t;
|
||||
|
||||
/**
|
||||
@ -72,6 +110,17 @@ namespace ASE
|
||||
const void* getHandle () const;
|
||||
void setHandle (void* handle);
|
||||
|
||||
/**
|
||||
* returns the underlying extio_t handle
|
||||
*/
|
||||
const extio_t* getRawExtio () const;
|
||||
|
||||
/**
|
||||
* returns the underlying run_t handle associated
|
||||
* with the underlying extio_t handle
|
||||
*/
|
||||
const run_t* getRawRun () const;
|
||||
|
||||
protected:
|
||||
extio_t* extio;
|
||||
};
|
||||
@ -146,7 +195,7 @@ namespace ASE
|
||||
};
|
||||
|
||||
/**
|
||||
* Argument
|
||||
* Represents an argument to an intrinsic function
|
||||
*/
|
||||
class Argument
|
||||
{
|
||||
@ -197,7 +246,7 @@ namespace ASE
|
||||
};
|
||||
|
||||
/**
|
||||
* Return
|
||||
* represents a return value of an intrinsic function
|
||||
*/
|
||||
class Return
|
||||
{
|
||||
@ -233,7 +282,7 @@ namespace ASE
|
||||
};
|
||||
|
||||
/**
|
||||
* ErrorCode
|
||||
* represens the error code
|
||||
*/
|
||||
|
||||
// generated by generrcode.awk
|
||||
@ -475,52 +524,93 @@ namespace ASE
|
||||
virtual int run (const char_t* main = ASE_NULL,
|
||||
const char_t** args = ASE_NULL, size_t nargs = 0);
|
||||
|
||||
/**
|
||||
* defines the user-defined function
|
||||
*/
|
||||
typedef int (Awk::*FunctionHandler) (
|
||||
Return* ret, const Argument* args, size_t nargs,
|
||||
const char_t* name, size_t len);
|
||||
|
||||
/**
|
||||
* adds a new user-defined function
|
||||
*/
|
||||
virtual int addFunction (
|
||||
const char_t* name, size_t minArgs, size_t maxArgs,
|
||||
FunctionHandler handler);
|
||||
|
||||
/**
|
||||
* deletes a user-defined function
|
||||
*/
|
||||
virtual int deleteFunction (const char_t* main);
|
||||
|
||||
/**
|
||||
* enables the run-time callback
|
||||
*/
|
||||
virtual void enableRunCallback ();
|
||||
|
||||
/**
|
||||
* disables the run-time callback
|
||||
*/
|
||||
virtual void disableRunCallback ();
|
||||
|
||||
protected:
|
||||
virtual int dispatchFunction (
|
||||
run_t* run, const char_t* name, size_t len);
|
||||
|
||||
// source code io handlers
|
||||
/**
|
||||
* openSource
|
||||
/**
|
||||
* @name Source code I/O handlers
|
||||
* A subclass should override the following methods to
|
||||
* support the source code input and output.
|
||||
* The awk interpreter calls the following methods when
|
||||
* the parse method is invoked.
|
||||
*/
|
||||
/*@{*/
|
||||
/** opens the source stream */
|
||||
virtual int openSource (Source& io) = 0;
|
||||
/** closes the source stream */
|
||||
virtual int closeSource (Source& io) = 0;
|
||||
/** reads from the source stream */
|
||||
virtual ssize_t readSource (Source& io, char_t* buf, size_t len) = 0;
|
||||
/** writes to the source stream */
|
||||
virtual ssize_t writeSource (Source& io, char_t* buf, size_t len) = 0;
|
||||
/*@}*/
|
||||
|
||||
|
||||
// pipe io handlers
|
||||
/**
|
||||
* @name Pipe I/O handlers
|
||||
* Pipe operations are achieved through the following methods.
|
||||
*/
|
||||
/*@{*/
|
||||
virtual int openPipe (Pipe& io) = 0;
|
||||
virtual int closePipe (Pipe& io) = 0;
|
||||
virtual ssize_t readPipe (Pipe& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writePipe (Pipe& io, char_t* buf, size_t len) = 0;
|
||||
virtual int flushPipe (Pipe& io) = 0;
|
||||
/*@}*/
|
||||
|
||||
// file io handlers
|
||||
/**
|
||||
* @name File I/O handlers
|
||||
* File operations are achieved through the following methods.
|
||||
*/
|
||||
/*@{*/
|
||||
virtual int openFile (File& io) = 0;
|
||||
virtual int closeFile (File& io) = 0;
|
||||
virtual ssize_t readFile (File& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeFile (File& io, char_t* buf, size_t len) = 0;
|
||||
virtual int flushFile (File& io) = 0;
|
||||
/*@}*/
|
||||
|
||||
// console io handlers
|
||||
/**
|
||||
* @name Console I/O handlers
|
||||
* Console operations are achieved through the following methods.
|
||||
*/
|
||||
virtual int openConsole (Console& io) = 0;
|
||||
virtual int closeConsole (Console& io) = 0;
|
||||
virtual ssize_t readConsole (Console& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeConsole (Console& io, char_t* buf, size_t len) = 0;
|
||||
virtual int flushConsole (Console& io) = 0;
|
||||
virtual int nextConsole (Console& io) = 0;
|
||||
/*@}*/
|
||||
|
||||
// run-time callbacks
|
||||
virtual void onRunStart (const Run& run);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.cpp,v 1.24 2007/08/26 14:33:38 bacon Exp $
|
||||
* $Id: StdAwk.cpp,v 1.25 2007/09/06 09:23:34 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/StdAwk.hpp>
|
||||
@ -129,6 +129,13 @@ namespace ASE
|
||||
return ret->set ((long_t)prevSeed);
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER>=1400)
|
||||
#define time_t __time64_t
|
||||
#define time _time64
|
||||
#define localtime _localtime64
|
||||
#define gmtime _gmtime64
|
||||
#endif
|
||||
|
||||
int StdAwk::systime (Return* ret, const Argument* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
{
|
||||
|
Reference in New Issue
Block a user