Recovered from cvs revision 2007-05-06 04:23:00
This commit is contained in:
parent
ec40ad8648
commit
0f3ea15c69
12
ase/ase.dsw
12
ase/ase.dsw
@ -51,6 +51,18 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "aseawk++"=.\awk\aseawk++.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "asecom"=.\com\asecom.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
17
ase/ase.sln
17
ase/ase.sln
@ -10,7 +10,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "awk\aseawk.vcproj
|
||||
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aesawk_jni", "awk\aseawk_jni.vcproj", "{23B58791-FD44-4F95-9F77-34E4AF45A296}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jni.vcproj", "{23B58791-FD44-4F95-9F77-34E4AF45A296}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
|
||||
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
|
||||
@ -48,6 +48,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asecnt", "cnt\asecnt.csproj
|
||||
{963AF7B5-12E6-42B6-8CBE-89136C1A109B} = {963AF7B5-12E6-42B6-8CBE-89136C1A109B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vcproj", "{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -168,6 +173,16 @@ Global
|
||||
{7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
267
ase/awk/Awk.cpp
267
ase/awk/Awk.cpp
@ -1,12 +1,77 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.6 2007/05/04 10:25:14 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.8 2007/05/05 16:32:46 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/Awk.hpp>
|
||||
#include <ase/cmn/str.h>
|
||||
#include <ase/cmn/mem.h>
|
||||
|
||||
namespace ASE
|
||||
{
|
||||
Awk::Awk (): awk (ASE_NULL)
|
||||
|
||||
Awk::Source::Mode Awk::Source::getMode () const
|
||||
{
|
||||
return this->mode;
|
||||
}
|
||||
|
||||
const void* Awk::Source::getHandle () const
|
||||
{
|
||||
return this->handle;
|
||||
}
|
||||
|
||||
void Awk::Source::setHandle (void* handle)
|
||||
{
|
||||
this->handle = handle;
|
||||
}
|
||||
|
||||
Awk::Extio::Extio (const char_t* name): name(name), handle(ASE_NULL)
|
||||
{
|
||||
}
|
||||
|
||||
const Awk::char_t* Awk::Extio::getName () const
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
|
||||
const void* Awk::Extio::getHandle () const
|
||||
{
|
||||
return this->handle;
|
||||
}
|
||||
|
||||
void Awk::Extio::setHandle (void* handle)
|
||||
{
|
||||
this->handle = handle;
|
||||
}
|
||||
|
||||
Awk::Pipe::Pipe (char_t* name, Mode mode): Extio(name), mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
Awk::File::File (char_t* name, Mode mode): Extio(name), mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
Awk::Console::Console (char_t* name, Mode mode): Extio(name), mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
Awk::Pipe::Mode Awk::Pipe::getMode () const
|
||||
{
|
||||
return this->mode;
|
||||
}
|
||||
|
||||
Awk::File::Mode Awk::File::getMode () const
|
||||
{
|
||||
return this->mode;
|
||||
}
|
||||
|
||||
Awk::Console::Mode Awk::Console::getMode () const
|
||||
{
|
||||
return this->mode;
|
||||
}
|
||||
|
||||
Awk::Awk (): awk (ASE_NULL),
|
||||
sourceIn (Source::READ), sourceOut (Source::WRITE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -25,7 +90,7 @@ namespace ASE
|
||||
srcios.out = sourceWriter;
|
||||
srcios.custom_data = this;
|
||||
|
||||
return ase_awk_parse (awk, ASE_NULL);
|
||||
return ase_awk_parse (awk, &srcios);
|
||||
}
|
||||
|
||||
int Awk::run (const char_t* main, const char_t** args)
|
||||
@ -36,8 +101,18 @@ namespace ASE
|
||||
return -1;
|
||||
}
|
||||
|
||||
//return ase_awk_run (awk, main);
|
||||
return 0;
|
||||
ase_awk_runios_t runios;
|
||||
|
||||
runios.pipe = pipeHandler;
|
||||
runios.coproc = ASE_NULL;
|
||||
/*
|
||||
runios.file = fileHandler;
|
||||
runios.console = consoleHandler;
|
||||
*/
|
||||
runios.custom_data = this;
|
||||
|
||||
return ase_awk_run (
|
||||
awk, main, &runios, ASE_NULL, ASE_NULL, this);
|
||||
}
|
||||
|
||||
int Awk::open ()
|
||||
@ -74,18 +149,33 @@ namespace ASE
|
||||
prmfns.misc.dprintf = dprintf;
|
||||
prmfns.misc.custom_data = this;
|
||||
|
||||
awk = ase_awk_open (&prmfns, ASE_NULL);
|
||||
awk = ase_awk_open (&prmfns, this);
|
||||
if (awk == ASE_NULL)
|
||||
{
|
||||
// TODO: SET ERROR INFO
|
||||
return -1;
|
||||
}
|
||||
|
||||
functionMap = ase_awk_map_open (this, 512, ASE_NULL, 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);
|
||||
@ -93,22 +183,48 @@ namespace ASE
|
||||
}
|
||||
}
|
||||
|
||||
int Awk::dispatchFunction (const char_t* name, size_t len)
|
||||
{
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (functionMap, name, len);
|
||||
if (pair == ASE_NULL) return -1;
|
||||
|
||||
//ASE_AWK_PAIR_VAL(pair);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Awk::addFunction (
|
||||
const char_t* name, size_t minArgs, size_t maxArgs,
|
||||
FunctionHandler handler)
|
||||
{
|
||||
void* p = ase_awk_addbfn (awk, name, ase_strlen(name),
|
||||
0, minArgs, maxArgs, ASE_NULL,
|
||||
functionHandler);
|
||||
|
||||
//ase_memcpy (ASE_NULL, &handler, sizeof(handler));
|
||||
return (p == ASE_NULL)? -1: 0;
|
||||
}
|
||||
|
||||
int Awk::deleteFunction (const char_t* name)
|
||||
{
|
||||
// TODO: open if it is not open....
|
||||
return ase_awk_delbfn (awk, name, ase_strlen(name));
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::sourceReader (
|
||||
int cmd, void* arg, char_t* data, size_t count)
|
||||
{
|
||||
Awk* awk = (Awk*)arg;
|
||||
|
||||
if (cmd == ASE_AWK_IO_OPEN)
|
||||
switch (cmd)
|
||||
{
|
||||
return awk->openSource (Awk::SOURCE_READ);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_CLOSE)
|
||||
{
|
||||
return awk->closeSource (Awk::SOURCE_READ);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_READ)
|
||||
{
|
||||
return awk->readSource (data, count);
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return awk->openSource (awk->sourceIn);
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return awk->closeSource (awk->sourceIn);
|
||||
case ASE_AWK_IO_READ:
|
||||
return awk->readSource (awk->sourceIn, data, count);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -119,22 +235,119 @@ namespace ASE
|
||||
{
|
||||
Awk* awk = (Awk*)arg;
|
||||
|
||||
if (cmd == ASE_AWK_IO_OPEN)
|
||||
switch (cmd)
|
||||
{
|
||||
return awk->openSource (Awk::SOURCE_WRITE);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_CLOSE)
|
||||
{
|
||||
return awk->closeSource (Awk::SOURCE_WRITE);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_WRITE)
|
||||
{
|
||||
return awk->writeSource (data, count);
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return awk->openSource (awk->sourceOut);
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return awk->closeSource (awk->sourceOut);
|
||||
case ASE_AWK_IO_WRITE:
|
||||
return awk->writeSource (awk->sourceOut, data, count);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Awk::ssize_t Awk::pipeHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count)
|
||||
{
|
||||
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
|
||||
Awk* awk = (Awk*)epa->custom_data;
|
||||
|
||||
ASE_ASSERT ((epa->type & 0xFF) == ASE_AWK_EXTIO_PIPE);
|
||||
|
||||
Pipe pipe (epa->name, (Pipe::Mode)epa->mode);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return awk->openPipe (pipe);
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return awk->closePipe (pipe);
|
||||
|
||||
case ASE_AWK_IO_READ:
|
||||
return awk->readPipe (pipe, data, count);
|
||||
case ASE_AWK_IO_WRITE:
|
||||
return awk->writePipe (pipe, data, count);
|
||||
|
||||
case ASE_AWK_IO_FLUSH:
|
||||
return awk->flushPipe (pipe);
|
||||
case ASE_AWK_IO_NEXT:
|
||||
return awk->nextPipe (pipe);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::fileHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count)
|
||||
{
|
||||
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
|
||||
Awk* awk = (Awk*)epa->custom_data;
|
||||
|
||||
ASE_ASSERT ((epa->type & 0xFF) == ASE_AWK_EXTIO_FILE);
|
||||
|
||||
File file (epa->name, (File::Mode)epa->mode);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return awk->openFile (file);
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return awk->closeFile (file);
|
||||
|
||||
case ASE_AWK_IO_READ:
|
||||
return awk->readFile (file, data, count);
|
||||
case ASE_AWK_IO_WRITE:
|
||||
return awk->writeFile (file, data, count);
|
||||
|
||||
case ASE_AWK_IO_FLUSH:
|
||||
return awk->flushFile (file);
|
||||
case ASE_AWK_IO_NEXT:
|
||||
return awk->nextFile (file);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::consoleHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count)
|
||||
{
|
||||
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
|
||||
Awk* awk = (Awk*)epa->custom_data;
|
||||
|
||||
ASE_ASSERT ((epa->type & 0xFF) == ASE_AWK_EXTIO_CONSOLE);
|
||||
|
||||
Console console (epa->name, (Console::Mode)epa->mode);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return awk->openConsole (console);
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return awk->closeConsole (console);
|
||||
|
||||
case ASE_AWK_IO_READ:
|
||||
return awk->readConsole (console, data, count);
|
||||
case ASE_AWK_IO_WRITE:
|
||||
return awk->writeConsole (console, data, count);
|
||||
|
||||
case ASE_AWK_IO_FLUSH:
|
||||
return awk->flushConsole (console);
|
||||
case ASE_AWK_IO_NEXT:
|
||||
return awk->nextConsole (console);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Awk::functionHandler (
|
||||
ase_awk_run_t* run, const char_t* name, size_t len)
|
||||
{
|
||||
Awk* awk = (Awk*) ase_awk_getruncustomdata (run);
|
||||
return awk->dispatchFunction (name, len);
|
||||
}
|
||||
|
||||
void* Awk::malloc (void* custom, size_t n)
|
||||
{
|
||||
return ((Awk*)custom)->malloc (n);
|
||||
|
160
ase/awk/Awk.hpp
160
ase/awk/Awk.hpp
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.5 2007/05/04 10:25:14 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.7 2007/05/05 16:32:46 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_AWK_HPP_
|
||||
#define _ASE_AWK_AWK_HPP_
|
||||
|
||||
#include <ase/awk/awk.h>
|
||||
#include <ase/awk/map.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
namespace ASE
|
||||
@ -21,6 +22,93 @@ namespace ASE
|
||||
typedef ase_ssize_t ssize_t;
|
||||
typedef ase_real_t real_t;
|
||||
|
||||
class Source
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
READ,
|
||||
WRITE
|
||||
};
|
||||
|
||||
Source (Mode mode);
|
||||
|
||||
Mode getMode() const;
|
||||
const void* getHandle () const;
|
||||
void setHandle (void* handle);
|
||||
|
||||
private:
|
||||
Mode mode;
|
||||
void* handle;
|
||||
};
|
||||
|
||||
class Extio
|
||||
{
|
||||
public:
|
||||
Extio (const char_t* name);
|
||||
|
||||
const char_t* getName() const;
|
||||
const void* getHandle () const;
|
||||
void setHandle (void* handle);
|
||||
|
||||
private:
|
||||
const char_t* name;
|
||||
void* handle;
|
||||
};
|
||||
|
||||
class Pipe: public Extio
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_PIPE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_PIPE_WRITE
|
||||
};
|
||||
|
||||
Pipe (char_t* name, Mode mode);
|
||||
|
||||
Mode getMode () const;
|
||||
|
||||
private:
|
||||
Mode mode;
|
||||
};
|
||||
|
||||
class File: public Extio
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_FILE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_FILE_WRITE,
|
||||
APPEND = ASE_AWK_EXTIO_FILE_APPEND
|
||||
};
|
||||
|
||||
File (char_t* name, Mode mode);
|
||||
|
||||
Mode getMode () const;
|
||||
|
||||
private:
|
||||
Mode mode;
|
||||
};
|
||||
|
||||
class Console: public Extio
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
READ = ASE_AWK_EXTIO_CONSOLE_READ,
|
||||
WRITE = ASE_AWK_EXTIO_CONSOLE_WRITE
|
||||
};
|
||||
|
||||
Console (char_t* name, Mode mode);
|
||||
|
||||
Mode getMode () const;
|
||||
|
||||
private:
|
||||
Mode mode;
|
||||
};
|
||||
|
||||
|
||||
Awk ();
|
||||
virtual ~Awk ();
|
||||
|
||||
@ -28,20 +116,57 @@ namespace ASE
|
||||
int run (const char_t* main, const char_t** args);
|
||||
void close ();
|
||||
|
||||
enum SourceMode
|
||||
{
|
||||
SOURCE_READ,
|
||||
SOURCE_WRITE
|
||||
};
|
||||
|
||||
typedef int (Awk::*FunctionHandler) ();
|
||||
|
||||
int addFunction (
|
||||
const char_t* name, size_t minArgs, size_t maxArgs,
|
||||
FunctionHandler handler);
|
||||
int deleteFunction (const char_t* main);
|
||||
|
||||
protected:
|
||||
int open ();
|
||||
|
||||
virtual int openSource (SourceMode mode) = 0;
|
||||
virtual int closeSource (SourceMode mode) = 0;
|
||||
virtual ssize_t readSource (char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeSource (char_t* buf, size_t len) = 0;
|
||||
virtual int dispatchFunction (const char_t* name, size_t len);
|
||||
|
||||
// source code io handlers
|
||||
virtual int openSource (Source& io) = 0;
|
||||
virtual int closeSource (Source& io) = 0;
|
||||
virtual ssize_t readSource (Source& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writeSource (Source& io, char_t* buf, size_t len) = 0;
|
||||
|
||||
// pipe io handlers
|
||||
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;
|
||||
virtual int nextPipe (Pipe& io) = 0;
|
||||
|
||||
// file io handlers
|
||||
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;
|
||||
virtual int nextFile (File& io) = 0;
|
||||
|
||||
// console io handlers
|
||||
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 onStart () {}
|
||||
virtual void onReturn () {}
|
||||
virtual void onStop () {}
|
||||
*/
|
||||
|
||||
// primitive handlers
|
||||
virtual void* malloc (size_t n) = 0;
|
||||
virtual void* realloc (void* ptr, size_t n) = 0;
|
||||
virtual void free (void* ptr) = 0;
|
||||
@ -65,11 +190,22 @@ namespace ASE
|
||||
const char_t* fmt, va_list arg) = 0;
|
||||
virtual void vdprintf (const char_t* fmt, va_list arg) = 0;
|
||||
|
||||
// static glue members for various handlers
|
||||
static ssize_t sourceReader (
|
||||
int cmd, void* arg, char_t* data, size_t count);
|
||||
static ssize_t sourceWriter (
|
||||
int cmd, void* arg, char_t* data, size_t count);
|
||||
|
||||
static ssize_t pipeHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count);
|
||||
static ssize_t fileHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count);
|
||||
static ssize_t consoleHandler (
|
||||
int cmd, void* arg, char_t* data, size_t count);
|
||||
|
||||
static int functionHandler (
|
||||
ase_awk_run_t* run, const char_t* name, size_t len);
|
||||
|
||||
static void* malloc (void* custom, size_t n);
|
||||
static void* realloc (void* custom, void* ptr, size_t n);
|
||||
static void free (void* custom, void* ptr);
|
||||
@ -95,6 +231,10 @@ namespace ASE
|
||||
|
||||
private:
|
||||
ase_awk_t* awk;
|
||||
ase_awk_map_t* functionMap;
|
||||
|
||||
Source sourceIn;
|
||||
Source sourceOut;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: Awk.java,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -99,13 +99,13 @@ public abstract class Awk
|
||||
}
|
||||
|
||||
/* == builtin functions == */
|
||||
public void addBuiltinFunction (
|
||||
public void addFunction (
|
||||
String name, int min_args, int max_args) throws Exception
|
||||
{
|
||||
addbfn (name, min_args, max_args);
|
||||
}
|
||||
|
||||
public void deleteBuiltinFunction (String name) throws Exception
|
||||
public void deleteFunction (String name) throws Exception
|
||||
{
|
||||
delbfn (name);
|
||||
}
|
||||
|
31
ase/awk/StdAwk.cpp
Normal file
31
ase/awk/StdAwk.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* $Id: StdAwk.cpp,v 1.2 2007/05/05 16:32:46 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/StdAwk.hpp>
|
||||
|
||||
namespace ASE
|
||||
{
|
||||
|
||||
StdAwk::StdAwk ()
|
||||
{
|
||||
addFunction (ASE_T("sin"), 1, 1, (FunctionHandler)&StdAwk::sin);
|
||||
addFunction (ASE_T("cos"), 1, 1, (FunctionHandler)&StdAwk::cos);
|
||||
addFunction (ASE_T("tan"), 1, 1, (FunctionHandler)&StdAwk::tan);
|
||||
}
|
||||
|
||||
int StdAwk::sin ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int StdAwk::cos ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int StdAwk::tan ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
28
ase/awk/StdAwk.hpp
Normal file
28
ase/awk/StdAwk.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* $Id: StdAwk.hpp,v 1.2 2007/05/05 16:32:46 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_STDAWK_HPP_
|
||||
#define _ASE_AWK_STDAWK_HPP_
|
||||
|
||||
#include <ase/awk/Awk.hpp>
|
||||
|
||||
|
||||
namespace ASE
|
||||
{
|
||||
class StdAwk: public Awk
|
||||
{
|
||||
public:
|
||||
StdAwk ();
|
||||
|
||||
protected:
|
||||
int sin ();
|
||||
int cos ();
|
||||
int tan ();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.java,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: StdAwk.java,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -50,22 +50,22 @@ public abstract class StdAwk extends Awk
|
||||
seed = System.currentTimeMillis();
|
||||
random = new java.util.Random (seed);
|
||||
|
||||
addBuiltinFunction ("sin", 1, 1);
|
||||
addBuiltinFunction ("cos", 1, 1);
|
||||
addBuiltinFunction ("tan", 1, 1);
|
||||
addBuiltinFunction ("atan2", 1, 1);
|
||||
addBuiltinFunction ("log", 1, 1);
|
||||
addBuiltinFunction ("exp", 1, 1);
|
||||
addBuiltinFunction ("sqrt", 1, 1);
|
||||
addBuiltinFunction ("int", 1, 1);
|
||||
addFunction ("sin", 1, 1);
|
||||
addFunction ("cos", 1, 1);
|
||||
addFunction ("tan", 1, 1);
|
||||
addFunction ("atan2", 1, 1);
|
||||
addFunction ("log", 1, 1);
|
||||
addFunction ("exp", 1, 1);
|
||||
addFunction ("sqrt", 1, 1);
|
||||
addFunction ("int", 1, 1);
|
||||
|
||||
addBuiltinFunction ("srand", 0, 1);
|
||||
addBuiltinFunction ("rand", 0, 0);
|
||||
addFunction ("srand", 0, 1);
|
||||
addFunction ("rand", 0, 0);
|
||||
|
||||
addBuiltinFunction ("systime", 0, 0);
|
||||
addBuiltinFunction ("strftime", 0, Integer.MAX_VALUE);
|
||||
addFunction ("systime", 0, 0);
|
||||
addFunction ("strftime", 0, Integer.MAX_VALUE);
|
||||
|
||||
addBuiltinFunction ("system", 1, 1);
|
||||
addFunction ("system", 1, 1);
|
||||
}
|
||||
|
||||
/* == major methods == */
|
||||
|
122
ase/awk/aseawk++.dsp
Normal file
122
ase/awk/aseawk++.dsp
Normal file
@ -0,0 +1,122 @@
|
||||
# Microsoft Developer Studio Project File - Name="aseawk++" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=aseawk++ - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "aseawk++.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "aseawk++.mak" CFG="aseawk++ - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "aseawk++ - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "aseawk++ - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "aseawk++ - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../release/lib"
|
||||
# PROP Intermediate_Dir "release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /Za /W3 /GX /O2 /I "..\.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /FD /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "aseawk++ - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../debug/lib"
|
||||
# PROP Intermediate_Dir "debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "..\.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "aseawk++ - Win32 Release"
|
||||
# Name "aseawk++ - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Awk.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAwk.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Awk.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAwk.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
217
ase/awk/aseawk++.vcproj
Normal file
217
ase/awk/aseawk++.vcproj
Normal file
@ -0,0 +1,217 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="aseawk++"
|
||||
ProjectGUID="{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}"
|
||||
RootNamespace="aseawk++"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\..\debug\lib"
|
||||
IntermediateDirectory=".\debug"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\.."
|
||||
PreprocessorDefinitions="_DEBUG;WIN32"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
DisableLanguageExtensions="true"
|
||||
PrecompiledHeaderFile=".\debug\aseawk++.pch"
|
||||
AssemblerListingLocation=".\debug\"
|
||||
ObjectFile=".\debug\"
|
||||
ProgramDataBaseFileName=".\debug\"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\..\debug\lib\aseawk++.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\..\debug\lib\aseawk++.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\..\release\lib"
|
||||
IntermediateDirectory=".\release"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\.."
|
||||
PreprocessorDefinitions="NDEBUG;WIN32"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
DisableLanguageExtensions="true"
|
||||
PrecompiledHeaderFile=".\release\aseawk++.pch"
|
||||
AssemblerListingLocation=".\release\"
|
||||
ObjectFile=".\release\"
|
||||
ProgramDataBaseFileName=".\release\"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\..\release\lib\aseawk++.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\..\release\lib\aseawk++.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="Awk.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="Awk.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -1,10 +1,10 @@
|
||||
# Microsoft Developer Studio Project File - Name="aesawk_jni" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Project File - Name="aseawk_jni" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=aesawk_jni - Win32 Debug
|
||||
CFG=aseawk_jni - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
@ -13,12 +13,12 @@ CFG=aesawk_jni - Win32 Debug
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "aseawk_jni.mak" CFG="aesawk_jni - Win32 Debug"
|
||||
!MESSAGE NMAKE /f "aseawk_jni.mak" CFG="aseawk_jni - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "aesawk_jni - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "aesawk_jni - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "aseawk_jni - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "aseawk_jni - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
@ -29,7 +29,7 @@ CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "aesawk_jni - Win32 Release"
|
||||
!IF "$(CFG)" == "aseawk_jni - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
@ -56,7 +56,7 @@ LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 asecmn.lib aseawk.lib aseutl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /implib:"release/aseawk_jni.lib" /libpath:"$(OutDir)"
|
||||
|
||||
!ELSEIF "$(CFG)" == "aesawk_jni - Win32 Debug"
|
||||
!ELSEIF "$(CFG)" == "aseawk_jni - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
@ -87,8 +87,8 @@ LINK32=link.exe
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "aesawk_jni - Win32 Release"
|
||||
# Name "aesawk_jni - Win32 Debug"
|
||||
# Name "aseawk_jni - Win32 Release"
|
||||
# Name "aseawk_jni - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
@ -2,9 +2,9 @@
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="aesawk_jni"
|
||||
Name="aseawk_jni"
|
||||
ProjectGUID="{23B58791-FD44-4F95-9F77-34E4AF45A296}"
|
||||
RootNamespace="aesawk_jni"
|
||||
RootNamespace="aseawk_jni"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: awk.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -61,8 +61,8 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
|
||||
}
|
||||
|
||||
/* TODO: initial map size?? */
|
||||
if (ase_awk_map_open (
|
||||
&awk->tree.afns, awk, 256, free_afn, awk) == ASE_NULL)
|
||||
awk->tree.afns = ase_awk_map_open (awk, 256, free_afn, awk);
|
||||
if (awk->tree.afns == ASE_NULL)
|
||||
{
|
||||
ase_str_close (&awk->token.name);
|
||||
ASE_AWK_FREE (awk, awk);
|
||||
@ -72,7 +72,7 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
|
||||
if (ase_awk_tab_open (&awk->parse.globals, awk) == ASE_NULL)
|
||||
{
|
||||
ase_str_close (&awk->token.name);
|
||||
ase_awk_map_close (&awk->tree.afns);
|
||||
ase_awk_map_close (awk->tree.afns);
|
||||
ASE_AWK_FREE (awk, awk);
|
||||
return ASE_NULL;
|
||||
}
|
||||
@ -80,7 +80,7 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
|
||||
if (ase_awk_tab_open (&awk->parse.locals, awk) == ASE_NULL)
|
||||
{
|
||||
ase_str_close (&awk->token.name);
|
||||
ase_awk_map_close (&awk->tree.afns);
|
||||
ase_awk_map_close (awk->tree.afns);
|
||||
ase_awk_tab_close (&awk->parse.globals);
|
||||
ASE_AWK_FREE (awk, awk);
|
||||
return ASE_NULL;
|
||||
@ -89,7 +89,7 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
|
||||
if (ase_awk_tab_open (&awk->parse.params, awk) == ASE_NULL)
|
||||
{
|
||||
ase_str_close (&awk->token.name);
|
||||
ase_awk_map_close (&awk->tree.afns);
|
||||
ase_awk_map_close (awk->tree.afns);
|
||||
ase_awk_tab_close (&awk->parse.globals);
|
||||
ase_awk_tab_close (&awk->parse.locals);
|
||||
ASE_AWK_FREE (awk, awk);
|
||||
@ -160,7 +160,7 @@ int ase_awk_close (ase_awk_t* awk)
|
||||
if (ase_awk_clear (awk) == -1) return -1;
|
||||
ase_awk_clrbfn (awk);
|
||||
|
||||
ase_awk_map_close (&awk->tree.afns);
|
||||
ase_awk_map_close (awk->tree.afns);
|
||||
ase_awk_tab_close (&awk->parse.globals);
|
||||
ase_awk_tab_close (&awk->parse.locals);
|
||||
ase_awk_tab_close (&awk->parse.params);
|
||||
@ -206,7 +206,7 @@ int ase_awk_clear (ase_awk_t* awk)
|
||||
awk->tree.nglobals = 0;
|
||||
awk->tree.cur_afn.ptr = ASE_NULL;
|
||||
awk->tree.cur_afn.len = 0;
|
||||
ase_awk_map_clear (&awk->tree.afns);
|
||||
ase_awk_map_clear (awk->tree.afns);
|
||||
|
||||
if (awk->tree.begin != ASE_NULL)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: awk_i.h,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -66,7 +66,7 @@ struct ase_awk_tree_t
|
||||
ase_size_t nglobals; /* total number of globals */
|
||||
ase_size_t nbglobals; /* number of builtin globals */
|
||||
ase_cstr_t cur_afn;
|
||||
ase_awk_map_t afns; /* awk function map */
|
||||
ase_awk_map_t* afns; /* awk function map */
|
||||
ase_awk_nde_t* begin;
|
||||
ase_awk_nde_t* end;
|
||||
ase_awk_chain_t* chain;
|
||||
@ -216,7 +216,7 @@ struct ase_awk_chain_t
|
||||
struct ase_awk_run_t
|
||||
{
|
||||
int id;
|
||||
ase_awk_map_t named;
|
||||
ase_awk_map_t* named;
|
||||
|
||||
void** stack;
|
||||
ase_size_t stack_top;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: func.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -51,6 +51,8 @@ void* ase_awk_addbfn (
|
||||
{
|
||||
ase_awk_bfn_t* p;
|
||||
|
||||
/* TODO: make function table hash-accessable */
|
||||
|
||||
if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL)
|
||||
{
|
||||
ase_cstr_t errarg;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: jni.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: jni.c,v 1.4 2007/05/05 12:03:35 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1366,41 +1366,41 @@ static ase_ssize_t __process_extio (
|
||||
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
|
||||
runio_data_t* runio_data = (runio_data_t*)epa->custom_data;
|
||||
|
||||
if (cmd == ASE_AWK_IO_OPEN)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
return __java_open_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"openExtio", epa);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_CLOSE)
|
||||
{
|
||||
return __java_close_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"closeExtio", epa);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_READ)
|
||||
{
|
||||
return __java_read_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"readExtio", epa, data, size);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_WRITE)
|
||||
{
|
||||
return __java_write_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"writeExtio", epa, data, size);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_FLUSH)
|
||||
{
|
||||
return __java_flush_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"flushExtio", epa);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_NEXT)
|
||||
{
|
||||
return __java_next_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"nextExtio", epa);
|
||||
|
||||
case ASE_AWK_IO_OPEN:
|
||||
return __java_open_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"openExtio", epa);
|
||||
|
||||
case ASE_AWK_IO_CLOSE:
|
||||
return __java_close_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"closeExtio", epa);
|
||||
|
||||
case ASE_AWK_IO_READ:
|
||||
return __java_read_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"readExtio", epa, data, size);
|
||||
|
||||
case ASE_AWK_IO_WRITE:
|
||||
|
||||
return __java_write_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"writeExtio", epa, data, size);
|
||||
|
||||
case ASE_AWK_IO_FLUSH:
|
||||
return __java_flush_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"flushExtio", epa);
|
||||
|
||||
case ASE_AWK_IO_NEXT:
|
||||
return __java_next_extio (
|
||||
runio_data->env, runio_data->obj,
|
||||
"nextExtio", epa);
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: map.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -13,26 +13,23 @@ static ase_size_t hashkey (const ase_char_t* keyptr, ase_size_t keylen);
|
||||
|
||||
#define FREE_PAIR(map,pair) \
|
||||
do { \
|
||||
ASE_AWK_FREE ((map)->awk, (ase_char_t*)PAIR_KEYPTR(pair)); \
|
||||
ASE_AWK_FREE ((map)->awk, (ase_char_t*)ASE_AWK_PAIR_KEYPTR(pair)); \
|
||||
if ((map)->freeval != ASE_NULL) \
|
||||
(map)->freeval ((map)->owner, PAIR_VAL(pair)); \
|
||||
(map)->freeval ((map)->owner, ASE_AWK_PAIR_VAL(pair)); \
|
||||
ASE_AWK_FREE ((map)->awk, pair); \
|
||||
} while (0)
|
||||
|
||||
ase_awk_map_t* ase_awk_map_open (
|
||||
ase_awk_map_t* map, void* owner, ase_size_t capa,
|
||||
void* owner, ase_size_t capa,
|
||||
void(*freeval)(void*,void*), ase_awk_t* awk)
|
||||
{
|
||||
ase_awk_map_t* map;
|
||||
|
||||
ASE_ASSERTX (capa > 0, "the initial capacity should be greater than 0");
|
||||
|
||||
if (map == ASE_NULL)
|
||||
{
|
||||
map = (ase_awk_map_t*) ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_awk_map_t));
|
||||
if (map == ASE_NULL) return ASE_NULL;
|
||||
map->__dynamic = ase_true;
|
||||
}
|
||||
else map->__dynamic = ase_false;
|
||||
map = (ase_awk_map_t*) ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_awk_map_t));
|
||||
if (map == ASE_NULL) return ASE_NULL;
|
||||
|
||||
map->awk = awk;
|
||||
map->buck = (ase_awk_pair_t**)
|
||||
@ -56,7 +53,7 @@ void ase_awk_map_close (ase_awk_map_t* map)
|
||||
{
|
||||
ase_awk_map_clear (map);
|
||||
ASE_AWK_FREE (map->awk, map->buck);
|
||||
if (map->__dynamic) ASE_AWK_FREE (map->awk, map);
|
||||
ASE_AWK_FREE (map->awk, map);
|
||||
}
|
||||
|
||||
void ase_awk_map_clear (ase_awk_map_t* map)
|
||||
@ -70,7 +67,7 @@ void ase_awk_map_clear (ase_awk_map_t* map)
|
||||
|
||||
while (pair != ASE_NULL)
|
||||
{
|
||||
next = PAIR_LNK(pair);
|
||||
next = ASE_AWK_PAIR_LNK(pair);
|
||||
FREE_PAIR (map, pair);
|
||||
map->size--;
|
||||
pair = next;
|
||||
@ -98,10 +95,10 @@ ase_awk_pair_t* ase_awk_map_get (
|
||||
{
|
||||
|
||||
if (ase_strxncmp (
|
||||
PAIR_KEYPTR(pair), PAIR_KEYLEN(pair),
|
||||
ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair),
|
||||
keyptr, keylen) == 0) return pair;
|
||||
|
||||
pair = PAIR_LNK(pair);
|
||||
pair = ASE_AWK_PAIR_LNK(pair);
|
||||
}
|
||||
|
||||
return ASE_NULL;
|
||||
@ -131,7 +128,7 @@ int ase_awk_map_putx (
|
||||
while (pair != ASE_NULL)
|
||||
{
|
||||
if (ase_strxncmp (
|
||||
PAIR_KEYPTR(pair), PAIR_KEYLEN(pair),
|
||||
ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair),
|
||||
keyptr, keylen) == 0)
|
||||
{
|
||||
if (px != ASE_NULL)
|
||||
@ -141,7 +138,7 @@ int ase_awk_map_putx (
|
||||
|
||||
return 0; /* value changed for the existing key */
|
||||
}
|
||||
pair = PAIR_LNK(pair);
|
||||
pair = ASE_AWK_PAIR_LNK(pair);
|
||||
}
|
||||
|
||||
pair = (ase_awk_pair_t*) ASE_AWK_MALLOC (
|
||||
@ -149,17 +146,17 @@ int ase_awk_map_putx (
|
||||
if (pair == ASE_NULL) return -1; /* error */
|
||||
|
||||
/* duplicate the key if it is new */
|
||||
PAIR_KEYPTR(pair) = ase_strxdup (
|
||||
ASE_AWK_PAIR_KEYPTR(pair) = ase_strxdup (
|
||||
keyptr, keylen, &map->awk->prmfns.mmgr);
|
||||
if (PAIR_KEYPTR(pair) == ASE_NULL)
|
||||
if (ASE_AWK_PAIR_KEYPTR(pair) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (map->awk, pair);
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
PAIR_KEYLEN(pair) = keylen;
|
||||
PAIR_VAL(pair) = val;
|
||||
PAIR_LNK(pair) = map->buck[hc];
|
||||
ASE_AWK_PAIR_KEYLEN(pair) = keylen;
|
||||
ASE_AWK_PAIR_VAL(pair) = val;
|
||||
ASE_AWK_PAIR_LNK(pair) = map->buck[hc];
|
||||
map->buck[hc] = pair;
|
||||
map->size++;
|
||||
|
||||
@ -179,12 +176,12 @@ ase_awk_pair_t* ase_awk_map_set (
|
||||
while (pair != ASE_NULL)
|
||||
{
|
||||
if (ase_strxncmp (
|
||||
PAIR_KEYPTR(pair), PAIR_KEYLEN(pair),
|
||||
ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair),
|
||||
keyptr, keylen) == 0)
|
||||
{
|
||||
return ase_awk_map_setpair (map, pair, val);
|
||||
}
|
||||
pair = PAIR_LNK(pair);
|
||||
pair = ASE_AWK_PAIR_LNK(pair);
|
||||
}
|
||||
|
||||
return ASE_NULL;
|
||||
@ -198,7 +195,7 @@ ase_awk_pair_t* ase_awk_map_getpair (
|
||||
|
||||
pair = ase_awk_map_get (map, keyptr, keylen);
|
||||
if (pair == ASE_NULL) return ASE_NULL;
|
||||
*val = PAIR_VAL(pair);
|
||||
*val = ASE_AWK_PAIR_VAL(pair);
|
||||
|
||||
return pair;
|
||||
}
|
||||
@ -207,13 +204,13 @@ ase_awk_pair_t* ase_awk_map_setpair (
|
||||
ase_awk_map_t* map, ase_awk_pair_t* pair, void* val)
|
||||
{
|
||||
/* use this function with care */
|
||||
if (PAIR_VAL(pair) != val)
|
||||
if (ASE_AWK_PAIR_VAL(pair) != val)
|
||||
{
|
||||
if (map->freeval != ASE_NULL)
|
||||
{
|
||||
map->freeval (map->owner, PAIR_VAL(pair));
|
||||
map->freeval (map->owner, ASE_AWK_PAIR_VAL(pair));
|
||||
}
|
||||
PAIR_VAL(pair) = val;
|
||||
ASE_AWK_PAIR_VAL(pair) = val;
|
||||
}
|
||||
|
||||
return pair;
|
||||
@ -232,12 +229,12 @@ int ase_awk_map_remove (
|
||||
while (pair != ASE_NULL)
|
||||
{
|
||||
if (ase_strxncmp (
|
||||
PAIR_KEYPTR(pair), PAIR_KEYLEN(pair),
|
||||
ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair),
|
||||
keyptr, keylen) == 0)
|
||||
{
|
||||
if (prev == ASE_NULL)
|
||||
map->buck[hc] = PAIR_LNK(pair);
|
||||
else prev->next = PAIR_LNK(pair);
|
||||
map->buck[hc] = ASE_AWK_PAIR_LNK(pair);
|
||||
else prev->next = ASE_AWK_PAIR_LNK(pair);
|
||||
|
||||
FREE_PAIR (map, pair);
|
||||
map->size--;
|
||||
@ -246,7 +243,7 @@ int ase_awk_map_remove (
|
||||
}
|
||||
|
||||
prev = pair;
|
||||
pair = PAIR_LNK(pair);
|
||||
pair = ASE_AWK_PAIR_LNK(pair);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -264,7 +261,7 @@ int ase_awk_map_walk (ase_awk_map_t* map,
|
||||
|
||||
while (pair != ASE_NULL)
|
||||
{
|
||||
next = PAIR_LNK(pair);
|
||||
next = ASE_AWK_PAIR_LNK(pair);
|
||||
if (walker(pair,arg) == -1) return -1;
|
||||
pair = next;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.h,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: map.h,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -37,17 +37,17 @@ struct ase_awk_map_t
|
||||
ase_bool_t __dynamic;
|
||||
};
|
||||
|
||||
#define PAIR_KEYPTR(p) ((p)->key.ptr)
|
||||
#define PAIR_KEYLEN(p) ((p)->key.len)
|
||||
#define PAIR_VAL(p) ((p)->val)
|
||||
#define PAIR_LNK(p) ((p)->next)
|
||||
#define ASE_AWK_PAIR_KEYPTR(p) ((p)->key.ptr)
|
||||
#define ASE_AWK_PAIR_KEYLEN(p) ((p)->key.len)
|
||||
#define ASE_AWK_PAIR_VAL(p) ((p)->val)
|
||||
#define ASE_AWK_PAIR_LNK(p) ((p)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_awk_map_t* ase_awk_map_open (
|
||||
ase_awk_map_t* map, void* owner, ase_size_t capa,
|
||||
void* owner, ase_size_t capa,
|
||||
void(*freeval)(void*,void*), ase_awk_t* awk);
|
||||
|
||||
void ase_awk_map_close (ase_awk_map_t* map);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: parse.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -707,7 +707,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
if (ase_awk_map_get(&awk->tree.afns, name, name_len) != ASE_NULL)
|
||||
if (ase_awk_map_get(awk->tree.afns, name, name_len) != ASE_NULL)
|
||||
{
|
||||
/* the function is defined previously */
|
||||
SETERRARG (
|
||||
@ -799,7 +799,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
{
|
||||
/* check if a parameter conflicts with a function */
|
||||
if (ase_strxncmp (name_dup, name_len, param, param_len) == 0 ||
|
||||
ase_awk_map_get (&awk->tree.afns, param, param_len) != ASE_NULL)
|
||||
ase_awk_map_get (awk->tree.afns, param, param_len) != ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, name_dup);
|
||||
ase_awk_tab_clear (&awk->parse.params);
|
||||
@ -946,7 +946,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
afn->nargs = nargs;
|
||||
afn->body = body;
|
||||
|
||||
n = ase_awk_map_putx (&awk->tree.afns, name_dup, name_len, afn, &pair);
|
||||
n = ase_awk_map_putx (awk->tree.afns, name_dup, name_len, afn, &pair);
|
||||
if (n < 0)
|
||||
{
|
||||
ASE_AWK_FREE (awk, name_dup);
|
||||
@ -960,8 +960,8 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
/* duplicate functions should have been detected previously */
|
||||
ASE_ASSERT (n != 0);
|
||||
|
||||
afn->name = PAIR_KEYPTR(pair); /* do some trick to save a string. */
|
||||
afn->name_len = PAIR_KEYLEN(pair);
|
||||
afn->name = ASE_AWK_PAIR_KEYPTR(pair); /* do some trick to save a string. */
|
||||
afn->name_len = ASE_AWK_PAIR_KEYLEN(pair);
|
||||
ASE_AWK_FREE (awk, name_dup);
|
||||
|
||||
return body;
|
||||
@ -1241,7 +1241,7 @@ static ase_awk_t* add_global (
|
||||
|
||||
/* check if it conflict with a function name */
|
||||
if (ase_awk_map_get (
|
||||
&awk->tree.afns, name, len) != ASE_NULL)
|
||||
awk->tree.afns, name, len) != ASE_NULL)
|
||||
{
|
||||
SETERRARG (
|
||||
awk, ASE_AWK_EAFNRED, line,
|
||||
@ -1345,7 +1345,7 @@ static ase_awk_t* collect_locals (ase_awk_t* awk, ase_size_t nlocals)
|
||||
awk->tree.cur_afn.ptr, awk->tree.cur_afn.len,
|
||||
local, local_len) == 0 ||
|
||||
ase_awk_map_get (
|
||||
&awk->tree.afns, local, local_len) != ASE_NULL)
|
||||
awk->tree.afns, local, local_len) != ASE_NULL)
|
||||
{
|
||||
SETERRARG (
|
||||
awk, ASE_AWK_EAFNRED, awk->token.line,
|
||||
@ -4917,7 +4917,7 @@ static int deparse (ase_awk_t* awk)
|
||||
df.tmp = tmp;
|
||||
df.tmp_len = ASE_COUNTOF(tmp);
|
||||
|
||||
if (ase_awk_map_walk (&awk->tree.afns, deparse_func, &df) == -1)
|
||||
if (ase_awk_map_walk (awk->tree.afns, deparse_func, &df) == -1)
|
||||
{
|
||||
EXIT_DEPARSE ();
|
||||
}
|
||||
@ -5015,7 +5015,7 @@ static int deparse_func (ase_awk_pair_t* pair, void* arg)
|
||||
ase_awk_afn_t* afn = (ase_awk_afn_t*)pair->val;
|
||||
ase_size_t i, n;
|
||||
|
||||
ASE_ASSERT (ase_strxncmp (PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), afn->name, afn->name_len) == 0);
|
||||
ASE_ASSERT (ase_strxncmp (ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair), afn->name, afn->name_len) == 0);
|
||||
|
||||
if (ase_awk_putsrcstr (df->awk, ASE_T("function ")) == -1) return -1;
|
||||
if (ase_awk_putsrcstr (df->awk, afn->name) == -1) return -1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: run.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -577,7 +577,7 @@ void* ase_awk_getruncustomdata (ase_awk_run_t* run)
|
||||
|
||||
ase_awk_map_t* ase_awk_getrunnamedvarmap (ase_awk_run_t* awk)
|
||||
{
|
||||
return &awk->named;
|
||||
return awk->named;
|
||||
}
|
||||
|
||||
int ase_awk_run (ase_awk_t* awk,
|
||||
@ -598,7 +598,7 @@ int ase_awk_run (ase_awk_t* awk,
|
||||
awk->tree.begin == ASE_NULL &&
|
||||
awk->tree.end == ASE_NULL &&
|
||||
awk->tree.chain_size == 0 &&
|
||||
ase_awk_map_getsize(&awk->tree.afns) == 0)
|
||||
ase_awk_map_getsize(awk->tree.afns) == 0)
|
||||
{
|
||||
/* if not, deny the run */
|
||||
ase_awk_seterror (awk, ASE_AWK_ENOPER, 0, ASE_NULL, 0);
|
||||
@ -742,8 +742,9 @@ static int __init_run (
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ase_awk_map_open (&run->named,
|
||||
run, DEF_BUF_CAPA, __free_namedval, run->awk) == ASE_NULL)
|
||||
run->named = ase_awk_map_open (
|
||||
run, DEF_BUF_CAPA, __free_namedval, run->awk);
|
||||
if (run->named == ASE_NULL)
|
||||
{
|
||||
ase_str_close (&run->format.fmt);
|
||||
ase_str_close (&run->format.out);
|
||||
@ -756,7 +757,7 @@ static int __init_run (
|
||||
ASE_AWK_MALLOC (run->awk, 4096*ASE_SIZEOF(ase_char_t*));
|
||||
if (run->format.tmp.ptr == ASE_NULL)
|
||||
{
|
||||
ase_awk_map_close (&run->named);
|
||||
ase_awk_map_close (run->named);
|
||||
ase_str_close (&run->format.fmt);
|
||||
ase_str_close (&run->format.out);
|
||||
ase_str_close (&run->inrec.line);
|
||||
@ -773,7 +774,7 @@ static int __init_run (
|
||||
if (run->pattern_range_state == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (run->awk, run->format.tmp.ptr);
|
||||
ase_awk_map_close (&run->named);
|
||||
ase_awk_map_close (run->named);
|
||||
ase_str_close (&run->format.fmt);
|
||||
ase_str_close (&run->format.out);
|
||||
ase_str_close (&run->inrec.line);
|
||||
@ -902,7 +903,7 @@ static void __deinit_run (ase_awk_run_t* run)
|
||||
}
|
||||
|
||||
/* destroy named variables */
|
||||
ase_awk_map_close (&run->named);
|
||||
ase_awk_map_close (run->named);
|
||||
|
||||
/* destroy values in free list */
|
||||
while (run->icache_count > 0)
|
||||
@ -2042,7 +2043,7 @@ static int __walk_foreach (ase_awk_pair_t* pair, void* arg)
|
||||
ase_awk_val_t* str;
|
||||
|
||||
str = (ase_awk_val_t*) ase_awk_makestrval (
|
||||
w->run, PAIR_KEYPTR(pair), PAIR_KEYLEN(pair));
|
||||
w->run, ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair));
|
||||
if (str == ASE_NULL)
|
||||
{
|
||||
ase_awk_setrunerror (
|
||||
@ -2277,7 +2278,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
||||
"if a named variable has an index part and a named indexed variable doesn't have an index part, the program is definitely wrong");
|
||||
|
||||
pair = ase_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
run->named, var->id.name, var->id.name_len);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
ase_awk_val_t* tmp;
|
||||
@ -2294,7 +2295,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ase_awk_map_put (&run->named,
|
||||
if (ase_awk_map_put (run->named,
|
||||
var->id.name, var->id.name_len, tmp) == ASE_NULL)
|
||||
{
|
||||
ase_awk_refupval (run, tmp);
|
||||
@ -3026,7 +3027,7 @@ static ase_awk_val_t* __do_assignment_scalar (
|
||||
int n;
|
||||
|
||||
pair = ase_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
run->named, var->id.name, var->id.name_len);
|
||||
if (pair != ASE_NULL &&
|
||||
((ase_awk_val_t*)pair->val)->type == ASE_AWK_VAL_MAP)
|
||||
{
|
||||
@ -3042,7 +3043,7 @@ static ase_awk_val_t* __do_assignment_scalar (
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
n = ase_awk_map_putx (&run->named,
|
||||
n = ase_awk_map_putx (run->named,
|
||||
var->id.name, var->id.name_len, val, ASE_NULL);
|
||||
if (n < 0)
|
||||
{
|
||||
@ -3125,7 +3126,7 @@ static ase_awk_val_t* __do_assignment_map (
|
||||
{
|
||||
ase_awk_pair_t* pair;
|
||||
pair = ase_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
run->named, var->id.name, var->id.name_len);
|
||||
map = (pair == ASE_NULL)?
|
||||
(ase_awk_val_map_t*)ase_awk_val_nil:
|
||||
(ase_awk_val_map_t*)pair->val;
|
||||
@ -3157,7 +3158,7 @@ static ase_awk_val_t* __do_assignment_map (
|
||||
/* doesn't have to decrease the reference count
|
||||
* of the previous value here as it is done by
|
||||
* ase_awk_map_put */
|
||||
if (ase_awk_map_put (&run->named,
|
||||
if (ase_awk_map_put (run->named,
|
||||
var->id.name, var->id.name_len, tmp) == ASE_NULL)
|
||||
{
|
||||
ase_awk_refupval (run, tmp);
|
||||
@ -5198,7 +5199,7 @@ static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
ase_awk_afn_t* afn;
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (&run->awk->tree.afns,
|
||||
pair = ase_awk_map_get (run->awk->tree.afns,
|
||||
call->what.afn.name.ptr, call->what.afn.name.len);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
@ -5527,14 +5528,14 @@ static int __get_reference (
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (
|
||||
&run->named, tgt->id.name, tgt->id.name_len);
|
||||
run->named, tgt->id.name, tgt->id.name_len);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
/* it is bad that the named variable has to be
|
||||
* created in the function named "__get_refernce".
|
||||
* would there be any better ways to avoid this? */
|
||||
pair = ase_awk_map_put (
|
||||
&run->named, tgt->id.name,
|
||||
run->named, tgt->id.name,
|
||||
tgt->id.name_len, ase_awk_val_nil);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
@ -5572,11 +5573,11 @@ static int __get_reference (
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (
|
||||
&run->named, tgt->id.name, tgt->id.name_len);
|
||||
run->named, tgt->id.name, tgt->id.name_len);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
pair = ase_awk_map_put (
|
||||
&run->named, tgt->id.name,
|
||||
run->named, tgt->id.name,
|
||||
tgt->id.name_len, ase_awk_val_nil);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
@ -5784,7 +5785,7 @@ static ase_awk_val_t* __eval_named (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
{
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (&run->named,
|
||||
pair = ase_awk_map_get (run->named,
|
||||
((ase_awk_nde_var_t*)nde)->id.name,
|
||||
((ase_awk_nde_var_t*)nde)->id.name_len);
|
||||
|
||||
@ -5854,10 +5855,10 @@ static ase_awk_val_t* __eval_namedidx (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
ase_awk_nde_var_t* tgt = (ase_awk_nde_var_t*)nde;
|
||||
ase_awk_pair_t* pair;
|
||||
|
||||
pair = ase_awk_map_get (&run->named, tgt->id.name, tgt->id.name_len);
|
||||
pair = ase_awk_map_get (run->named, tgt->id.name, tgt->id.name_len);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
pair = ase_awk_map_put (&run->named,
|
||||
pair = ase_awk_map_put (run->named,
|
||||
tgt->id.name, tgt->id.name_len, ase_awk_val_nil);
|
||||
if (pair == ASE_NULL)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: val.c,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: val.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -240,8 +240,7 @@ ase_awk_val_t* ase_awk_makemapval (ase_awk_run_t* run)
|
||||
|
||||
val->type = ASE_AWK_VAL_MAP;
|
||||
val->ref = 0;
|
||||
val->map = ase_awk_map_open (
|
||||
ASE_NULL, run, 256, free_map_val, run->awk);
|
||||
val->map = ase_awk_map_open (run, 256, free_map_val, run->awk);
|
||||
if (val->map == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (run->awk, val);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: types.h,v 1.3 2007/04/30 05:55:36 bacon Exp $
|
||||
* $Id: types.h,v 1.4 2007/05/05 10:43:08 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -163,7 +163,7 @@ typedef ase_uint_t ase_word_t;
|
||||
typedef char ase_mchar_t;
|
||||
typedef int ase_mcint_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if defined(__cplusplus) && (__cplusplus>1)
|
||||
/* C++ */
|
||||
typedef wchar_t ase_wchar_t;
|
||||
typedef wchar_t ase_wcint_t;
|
||||
|
Loading…
x
Reference in New Issue
Block a user