Recovered from cvs revision 2007-08-22 11:25:00
This commit is contained in:
parent
a7a4d8de4c
commit
a2c56938e7
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.cpp,v 1.48 2007/08/18 15:41:46 bacon Exp $
|
* $Id: Awk.cpp,v 1.49 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <ase/awk/Awk.hpp>
|
#include <ase/awk/Awk.hpp>
|
||||||
#include <ase/awk/val.h>
|
#include <ase/awk/val.h>
|
||||||
#include <ase/cmn/str.h>
|
#include <ase/cmn/str.h>
|
||||||
@ -568,7 +569,7 @@ namespace ASE
|
|||||||
ase_awk_setmaxdepth (awk, ids, depth);
|
ase_awk_setmaxdepth (awk, ids, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Awk::getMaxDepth (int id) const
|
size_t Awk::getMaxDepth (int id) const
|
||||||
{
|
{
|
||||||
ASE_ASSERT (awk != ASE_NULL);
|
ASE_ASSERT (awk != ASE_NULL);
|
||||||
return ase_awk_getmaxdepth (awk, id);
|
return ase_awk_getmaxdepth (awk, id);
|
||||||
@ -1014,7 +1015,6 @@ namespace ASE
|
|||||||
{
|
{
|
||||||
Run* r = (Run*)custom;
|
Run* r = (Run*)custom;
|
||||||
if (r->callbackFailed) return;
|
if (r->callbackFailed) return;
|
||||||
|
|
||||||
r->awk->onRunStatement (*r, line);
|
r->awk->onRunStatement (*r, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp,v 1.46 2007/08/18 15:41:46 bacon Exp $
|
* $Id: Awk.hpp,v 1.47 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASE_AWK_AWK_HPP_
|
#ifndef _ASE_AWK_AWK_HPP_
|
||||||
@ -410,7 +410,7 @@ namespace ASE
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void setMaxDepth (int ids, size_t depth);
|
virtual void setMaxDepth (int ids, size_t depth);
|
||||||
virtual int getMaxDepth (int id) const;
|
virtual size_t getMaxDepth (int id) const;
|
||||||
|
|
||||||
virtual int setErrorString (ErrorCode num, const char_t* str);
|
virtual int setErrorString (ErrorCode num, const char_t* str);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: StdAwk.cpp,v 1.22 2007/07/15 16:31:59 bacon Exp $
|
* $Id: StdAwk.cpp,v 1.23 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/StdAwk.hpp>
|
#include <ase/awk/StdAwk.hpp>
|
||||||
@ -22,7 +22,7 @@ namespace ASE
|
|||||||
|
|
||||||
StdAwk::StdAwk ()
|
StdAwk::StdAwk ()
|
||||||
{
|
{
|
||||||
seed = ::time(NULL);
|
seed = (unsigned int)::time(NULL);
|
||||||
::srand (seed);
|
::srand (seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.9 2007/07/25 07:00:09 bacon Exp $
|
* $Id: run.c,v 1.10 2007/08/21 14:24:37 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -1724,7 +1724,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
|
|||||||
(run)->cbs->on_statement != ASE_NULL) \
|
(run)->cbs->on_statement != ASE_NULL) \
|
||||||
{ \
|
{ \
|
||||||
(run)->cbs->on_statement ( \
|
(run)->cbs->on_statement ( \
|
||||||
run, (nde)->line, (run)->custom_data); \
|
run, (nde)->line, (run)->cbs->custom_data); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __run_statement (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
static int __run_statement (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
* added the error code ASE_AWK_ELXDIG to indicate a wrong digit in
|
* added the error code ASE_AWK_ELXDIG to indicate a wrong digit in
|
||||||
octal number tokenization.
|
octal number tokenization.
|
||||||
* added setWord/unsetWord method to the awk com module (com/Awk.cpp)
|
* added setWord/unsetWord method to the awk com module (com/Awk.cpp)
|
||||||
|
* added the .NET interface to the awk interpreter (net/Awk.cpp net/StdAwk.cpp)
|
||||||
|
|
||||||
* changed the wrong macro name WIN32 to _WIN32 in utl/stdio.h
|
* changed the wrong macro name WIN32 to _WIN32 in utl/stdio.h
|
||||||
* changed test/awk/Awk.cpp to include an option(-w) to utilize
|
* changed test/awk/Awk.cpp to include an option(-w) to utilize
|
||||||
|
179
ase/net/Awk.cpp
179
ase/net/Awk.cpp
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.cpp,v 1.17 2007/08/20 14:19:58 bacon Exp $
|
* $Id: Awk.cpp,v 1.18 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
using System::Runtime::InteropServices::GCHandle;
|
using System::Runtime::InteropServices::GCHandle;
|
||||||
|
|
||||||
|
extern "C" void outputxxx (const wchar_t* x);
|
||||||
|
|
||||||
namespace ASE
|
namespace ASE
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -76,6 +78,89 @@ namespace ASE
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setWord (ASE::Net::Awk^ wrapper, const char_t* ow, size_t olen, const char_t* nw, size_t nlen)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
int n = Awk::setWord (ow, olen, nw, nlen);
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unsetWord (ASE::Net::Awk^ wrapper, const char_t* ow, size_t olen)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
int n = Awk::unsetWord (ow, olen);
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unsetAllWords (ASE::Net::Awk^ wrapper)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
int n = Awk::unsetAllWords ();
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMaxDepth (ASE::Net::Awk^ wrapper, int ids, size_t depth)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
Awk::setMaxDepth (ids, depth);
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getMaxDepth (ASE::Net::Awk^ wrapper, int id) const
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
size_t n = Awk::getMaxDepth (id);
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableRunCallback (ASE::Net::Awk^ wrapper)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
Awk::enableRunCallback ();
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableRunCallback (ASE::Net::Awk^ wrapper)
|
||||||
|
{
|
||||||
|
this->wrapper = wrapper;
|
||||||
|
Awk::disableRunCallback ();
|
||||||
|
this->wrapper = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onRunStart (const Run& run)
|
||||||
|
{
|
||||||
|
if (wrapper->OnRunStart != nullptr)
|
||||||
|
{
|
||||||
|
wrapper->OnRunStart ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void onRunEnd (const Run& run)
|
||||||
|
{
|
||||||
|
if (wrapper->OnRunEnd != nullptr)
|
||||||
|
{
|
||||||
|
wrapper->OnRunEnd ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void onRunReturn (const Run& run, const Argument& ret)
|
||||||
|
{
|
||||||
|
if (wrapper->OnRunReturn != nullptr)
|
||||||
|
{
|
||||||
|
wrapper->OnRunReturn ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onRunStatement (const Run& run, size_t line)
|
||||||
|
{
|
||||||
|
if (wrapper->OnRunStatement != nullptr)
|
||||||
|
{
|
||||||
|
wrapper->OnRunStatement ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int addFunction (
|
int addFunction (
|
||||||
ASE::Net::Awk^ wrapper, const char_t* name,
|
ASE::Net::Awk^ wrapper, const char_t* name,
|
||||||
size_t minArgs, size_t maxArgs, FunctionHandler handler)
|
size_t minArgs, size_t maxArgs, FunctionHandler handler)
|
||||||
@ -121,7 +206,7 @@ namespace ASE
|
|||||||
|
|
||||||
int closeSource (Source& io)
|
int closeSource (Source& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle ());
|
System::IntPtr ip ((void*)io.getHandle ());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -135,7 +220,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t readSource (Source& io, char_t* buf, size_t len)
|
ssize_t readSource (Source& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -154,7 +239,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t writeSource (Source& io, char_t* buf, size_t len)
|
ssize_t writeSource (Source& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -189,7 +274,7 @@ namespace ASE
|
|||||||
|
|
||||||
int closePipe (Pipe& io)
|
int closePipe (Pipe& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle ());
|
System::IntPtr ip ((void*)io.getHandle ());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -203,7 +288,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t readPipe (Pipe& io, char_t* buf, size_t len)
|
ssize_t readPipe (Pipe& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -222,7 +307,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t writePipe (Pipe& io, char_t* buf, size_t len)
|
ssize_t writePipe (Pipe& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -239,7 +324,7 @@ namespace ASE
|
|||||||
|
|
||||||
int flushPipe (Pipe& io)
|
int flushPipe (Pipe& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -270,7 +355,7 @@ namespace ASE
|
|||||||
|
|
||||||
int closeFile (File& io)
|
int closeFile (File& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle ());
|
System::IntPtr ip ((void*)io.getHandle ());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -284,7 +369,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t readFile (File& io, char_t* buf, size_t len)
|
ssize_t readFile (File& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -302,7 +387,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t writeFile (File& io, char_t* buf, size_t len)
|
ssize_t writeFile (File& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -319,7 +404,7 @@ namespace ASE
|
|||||||
|
|
||||||
int flushFile (File& io)
|
int flushFile (File& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -350,7 +435,7 @@ namespace ASE
|
|||||||
|
|
||||||
int closeConsole (Console& io)
|
int closeConsole (Console& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle ());
|
System::IntPtr ip ((void*)io.getHandle ());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -364,7 +449,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t readConsole (Console& io, char_t* buf, size_t len)
|
ssize_t readConsole (Console& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -382,7 +467,7 @@ namespace ASE
|
|||||||
|
|
||||||
ssize_t writeConsole (Console& io, char_t* buf, size_t len)
|
ssize_t writeConsole (Console& io, char_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
cli::array<char_t>^ b = nullptr;
|
cli::array<char_t>^ b = nullptr;
|
||||||
@ -399,7 +484,7 @@ namespace ASE
|
|||||||
|
|
||||||
int flushConsole (Console& io)
|
int flushConsole (Console& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -412,7 +497,7 @@ namespace ASE
|
|||||||
|
|
||||||
int nextConsole (Console& io)
|
int nextConsole (Console& io)
|
||||||
{
|
{
|
||||||
IntPtr ip ((void*)io.getHandle());
|
System::IntPtr ip ((void*)io.getHandle());
|
||||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -524,7 +609,19 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
|
|
||||||
void Awk::Close ()
|
void Awk::Close ()
|
||||||
{
|
{
|
||||||
if (awk != NULL) awk->close (this);
|
if (awk != NULL)
|
||||||
|
{
|
||||||
|
awk->close (this);
|
||||||
|
delete awk;
|
||||||
|
awk = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (funcs != nullptr)
|
||||||
|
{
|
||||||
|
funcs->Clear ();
|
||||||
|
delete funcs;
|
||||||
|
funcs = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Awk::Parse ()
|
bool Awk::Parse ()
|
||||||
@ -536,6 +633,13 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
bool Awk::Run ()
|
bool Awk::Run ()
|
||||||
{
|
{
|
||||||
if (awk == NULL) return false;
|
if (awk == NULL) return false;
|
||||||
|
|
||||||
|
if (OnRunStart != nullptr || OnRunEnd != nullptr ||
|
||||||
|
OnRunReturn != nullptr || OnRunStatement != nullptr)
|
||||||
|
{
|
||||||
|
awk->enableRunCallback (this);
|
||||||
|
}
|
||||||
|
|
||||||
return awk->run (this) == 0;
|
return awk->run (this) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +647,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
System::String^ name, int minArgs, int maxArgs,
|
System::String^ name, int minArgs, int maxArgs,
|
||||||
FunctionHandler^ handler)
|
FunctionHandler^ handler)
|
||||||
{
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
|
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
|
||||||
int n = awk->addFunction (this, nptr, minArgs, maxArgs,
|
int n = awk->addFunction (this, nptr, minArgs, maxArgs,
|
||||||
(ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler);
|
(ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler);
|
||||||
@ -552,6 +657,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
|
|
||||||
bool Awk::DeleteFunction (System::String^ name)
|
bool Awk::DeleteFunction (System::String^ name)
|
||||||
{
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
|
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
|
||||||
int n = awk->deleteFunction (this, nptr);
|
int n = awk->deleteFunction (this, nptr);
|
||||||
if (n == 0) funcs->Remove (name);
|
if (n == 0) funcs->Remove (name);
|
||||||
@ -565,7 +671,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
System::String^ nm = gcnew System::String (name, 0, len);
|
System::String^ nm = gcnew System::String (name, 0, len);
|
||||||
|
|
||||||
FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
|
FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
|
||||||
if (fh == nullptr) return -1;
|
if (fh == nullptr) return false;
|
||||||
|
|
||||||
cli::array<Argument^>^ arg_arr = gcnew cli::array<Argument^> (nargs);
|
cli::array<Argument^>^ arg_arr = gcnew cli::array<Argument^> (nargs);
|
||||||
for (size_t i = 0; i < nargs; i++) arg_arr[i] = gcnew Argument(args[i]);
|
for (size_t i = 0; i < nargs; i++) arg_arr[i] = gcnew Argument(args[i]);
|
||||||
@ -574,6 +680,41 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
|
|||||||
return fh(nm, arg_arr, r);
|
return fh(nm, arg_arr, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Awk::SetWord (System::String^ ow, System::String^ nw)
|
||||||
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
|
cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow);
|
||||||
|
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(nw);
|
||||||
|
return (awk->setWord (this, optr, ow->Length, nptr, nw->Length) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Awk::UnsetWord (System::String^ ow)
|
||||||
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
|
cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow);
|
||||||
|
return (awk->unsetWord (this, optr, ow->Length) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Awk::UnsetAllWords ()
|
||||||
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
|
return (awk->unsetAllWords (this) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Awk::SetMaxDepth (DEPTH id, size_t depth)
|
||||||
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
|
awk->setMaxDepth (this, (int)id, depth);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Awk::GetMaxDepth (DEPTH id, size_t* depth)
|
||||||
|
{
|
||||||
|
if (awk == NULL) return false;
|
||||||
|
*depth = awk->getMaxDepth (this, (int)id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp,v 1.14 2007/08/20 14:19:58 bacon Exp $
|
* $Id: Awk.hpp,v 1.15 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -7,8 +7,6 @@
|
|||||||
#include <ase/awk/Awk.hpp>
|
#include <ase/awk/Awk.hpp>
|
||||||
#include <vcclr.h>
|
#include <vcclr.h>
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
|
|
||||||
namespace ASE
|
namespace ASE
|
||||||
{
|
{
|
||||||
class MojoAwk;
|
class MojoAwk;
|
||||||
@ -22,6 +20,9 @@ namespace ASE
|
|||||||
typedef ASE::Awk::real_t real_t;
|
typedef ASE::Awk::real_t real_t;
|
||||||
typedef ASE::Awk::char_t char_t;
|
typedef ASE::Awk::char_t char_t;
|
||||||
typedef ASE::Awk::size_t size_t;
|
typedef ASE::Awk::size_t size_t;
|
||||||
|
typedef ASE::Awk::ssize_t ssize_t;
|
||||||
|
typedef ASE::Awk::cint_t cint_t;
|
||||||
|
typedef ASE::Awk::bool_t bool_t;
|
||||||
|
|
||||||
ref class Argument
|
ref class Argument
|
||||||
{
|
{
|
||||||
@ -297,7 +298,7 @@ namespace ASE
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
[Flags] enum class OPTION: int
|
[System::Flags] enum class OPTION: int
|
||||||
{
|
{
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
IMPLICIT = ASE::Awk::OPT_IMPLICIT,
|
IMPLICIT = ASE::Awk::OPT_IMPLICIT,
|
||||||
@ -317,22 +318,46 @@ namespace ASE
|
|||||||
ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN
|
ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class DEPTH: int
|
||||||
|
{
|
||||||
|
BLOCK_PARSE = ASE::Awk::DEPTH_BLOCK_PARSE,
|
||||||
|
BLOCK_RUN = ASE::Awk::DEPTH_BLOCK_RUN,
|
||||||
|
EXPR_PARSE = ASE::Awk::DEPTH_EXPR_PARSE,
|
||||||
|
EXPR_RUN = ASE::Awk::DEPTH_EXPR_RUN,
|
||||||
|
REX_BUILD = ASE::Awk::DEPTH_REX_BUILD,
|
||||||
|
REX_MATCH = ASE::Awk::DEPTH_REX_MATCH
|
||||||
|
};
|
||||||
|
|
||||||
typedef ASE::Awk::char_t char_t;
|
typedef ASE::Awk::char_t char_t;
|
||||||
|
|
||||||
Awk ();
|
Awk ();
|
||||||
!Awk ();
|
!Awk ();
|
||||||
virtual ~Awk ();
|
virtual ~Awk ();
|
||||||
|
|
||||||
//bool Open ();
|
virtual void Close ();
|
||||||
void Close ();
|
virtual bool Parse ();
|
||||||
|
virtual bool Run ();
|
||||||
|
|
||||||
bool Parse ();
|
delegate void RunStartHandler ();
|
||||||
bool Run ();
|
delegate void RunEndHandler ();
|
||||||
|
delegate void RunReturnHandler ();
|
||||||
|
delegate void RunStatementHandler ();
|
||||||
|
|
||||||
|
/*event*/ RunStartHandler^ OnRunStart;
|
||||||
|
/*event*/ RunEndHandler^ OnRunEnd;
|
||||||
|
/*event*/ RunReturnHandler^ OnRunReturn;
|
||||||
|
/*event*/ RunStatementHandler^ OnRunStatement;
|
||||||
|
|
||||||
delegate bool FunctionHandler (System::String^ name, array<Argument^>^ args, Return^ ret);
|
delegate bool FunctionHandler (System::String^ name, array<Argument^>^ args, Return^ ret);
|
||||||
|
virtual bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
|
||||||
|
virtual bool DeleteFunction (System::String^ name);
|
||||||
|
|
||||||
bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
|
virtual bool SetWord (System::String^ ow, System::String^ nw);
|
||||||
bool DeleteFunction (System::String^ name);
|
virtual bool UnsetWord (System::String^ ow);
|
||||||
|
virtual bool UnsetAllWords ();
|
||||||
|
|
||||||
|
virtual bool SetMaxDepth (DEPTH id, size_t depth);
|
||||||
|
virtual bool GetMaxDepth (DEPTH id, size_t* depth);
|
||||||
|
|
||||||
property OPTION Option
|
property OPTION Option
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: StdAwk.cpp,v 1.5 2007/08/20 14:27:47 bacon Exp $
|
* $Id: StdAwk.cpp,v 1.6 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
@ -136,20 +136,20 @@ namespace ASE
|
|||||||
|
|
||||||
if (fp == NULL) return -1;
|
if (fp == NULL) return -1;
|
||||||
|
|
||||||
pipe->Handle = IntPtr ((void*)fp);
|
pipe->Handle = System::IntPtr ((void*)fp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StdAwk::ClosePipe (Pipe^ pipe)
|
int StdAwk::ClosePipe (Pipe^ pipe)
|
||||||
{
|
{
|
||||||
IntPtr ip = (IntPtr)pipe->Handle;
|
System::IntPtr ip = (System::IntPtr)pipe->Handle;
|
||||||
FILE* fp = (FILE*)ip.ToPointer();
|
FILE* fp = (FILE*)ip.ToPointer();
|
||||||
return (::_pclose (fp) == EOF)? -1: 0;
|
return (::_pclose (fp) == EOF)? -1: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StdAwk::ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
int StdAwk::ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
||||||
{
|
{
|
||||||
IntPtr ip = (IntPtr)pipe->Handle;
|
System::IntPtr ip = (System::IntPtr)pipe->Handle;
|
||||||
FILE* fp = (FILE*)ip.ToPointer();
|
FILE* fp = (FILE*)ip.ToPointer();
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -168,7 +168,7 @@ namespace ASE
|
|||||||
|
|
||||||
int StdAwk::WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
int StdAwk::WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
||||||
{
|
{
|
||||||
IntPtr ip = (IntPtr)pipe->Handle;
|
System::IntPtr ip = (System::IntPtr)pipe->Handle;
|
||||||
FILE* fp = (FILE*)ip.ToPointer();
|
FILE* fp = (FILE*)ip.ToPointer();
|
||||||
int left;
|
int left;
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ namespace ASE
|
|||||||
|
|
||||||
int StdAwk::FlushPipe (Pipe^ pipe)
|
int StdAwk::FlushPipe (Pipe^ pipe)
|
||||||
{
|
{
|
||||||
IntPtr ip = (IntPtr)pipe->Handle;
|
System::IntPtr ip = (System::IntPtr)pipe->Handle;
|
||||||
FILE* fp = (FILE*)ip.ToPointer();
|
FILE* fp = (FILE*)ip.ToPointer();
|
||||||
return (::fflush (fp) == EOF)? -1: 0;
|
return (::fflush (fp) == EOF)? -1: 0;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.cpp,v 1.1 2007/07/20 09:23:37 bacon Exp $
|
* $Id: misc.cpp,v 1.2 2007/08/21 14:24:37 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user