Recovered from cvs revision 2007-08-12 14:19:00
This commit is contained in:
parent
b9a4af9a4e
commit
6270be21c9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.10 2007/07/29 14:42:33 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.11 2007/08/05 14:52:54 bacon Exp $
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
@ -32,98 +32,6 @@ namespace ASE
|
||||
return wrapper->DispatchFunction (nm);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int openSource (Source& io)
|
||||
{
|
||||
if (io.getMode() == Source::READ)
|
||||
{
|
||||
if (wrapper->SourceInputStream == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!wrapper->SourceInputStream->CanRead)
|
||||
{
|
||||
wrapper->SourceInputStream->Close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
System::IO::StreamReader^ reader = gcnew System::IO::StreamReader (wrapper->SourceInputStream);
|
||||
GCHandle gh = GCHandle::Alloc (reader);
|
||||
System::IntPtr^ ip = GCHandle::ToIntPtr(gh);
|
||||
io.setHandle (ip->ToPointer());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wrapper->SourceOutputStream == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!wrapper->SourceOutputStream->CanWrite)
|
||||
{
|
||||
wrapper->SourceOutputStream->Close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
System::IO::StreamWriter^ writer = gcnew System::IO::StreamWriter (wrapper->SourceOutputStream);
|
||||
GCHandle gh = GCHandle::Alloc (writer);
|
||||
System::IntPtr^ ip = GCHandle::ToIntPtr(gh);
|
||||
io.setHandle (ip->ToPointer());
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int closeSource (Source& io)
|
||||
{
|
||||
System::IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
|
||||
if (io.getMode() == Source::READ)
|
||||
{
|
||||
System::IO::StreamReader^ reader = (System::IO::StreamReader^)gh.Target;
|
||||
reader->Close ();
|
||||
}
|
||||
else
|
||||
{
|
||||
System::IO::StreamWriter^ writer = (System::IO::StreamWriter^)gh.Target;
|
||||
writer->Close ();
|
||||
}
|
||||
|
||||
gh.Free ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t readSource (Source& io, char_t* buf, size_t len)
|
||||
{
|
||||
System::IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
|
||||
System::IO::StreamReader^ reader = (System::IO::StreamReader^)gh.Target;
|
||||
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t>(len);
|
||||
int n = reader->Read (b, 0, len);
|
||||
for (int i = 0; i < n; i++) buf[i] = b[i];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t writeSource (Source& io, char_t* buf, size_t len)
|
||||
{
|
||||
System::IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
|
||||
System::IO::StreamWriter^ writer = (System::IO::StreamWriter^)gh.Target;
|
||||
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t>(len);
|
||||
for (int i = 0; i < (int)len; i++) b[i] = buf[i];
|
||||
writer->Write (b, 0, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
int openSource (Source& io)
|
||||
{
|
||||
ASE::Net::Awk::Source^ nio = gcnew ASE::Net::Awk::Source (
|
||||
@ -495,6 +403,9 @@ namespace ASE
|
||||
// TODO:...
|
||||
//throw new AwkException ("cannot open awk");
|
||||
}
|
||||
|
||||
//option = awk->getOption ();
|
||||
//Option = Option | OPTION::CRLF;
|
||||
}
|
||||
|
||||
Awk::~Awk ()
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.8 2007/07/29 14:42:33 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.9 2007/08/05 14:52:54 bacon Exp $
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -140,6 +140,27 @@ namespace ASE
|
||||
MODE^ mode;
|
||||
};
|
||||
|
||||
|
||||
[Flags] enum class OPTION: int
|
||||
{
|
||||
NONE = 0,
|
||||
IMPLICIT = ASE::Awk::OPT_IMPLICIT,
|
||||
EXPLICIT = ASE::Awk::OPT_EXPLICIT,
|
||||
UNIQUEFN = ASE::Awk::OPT_UNIQUEFN,
|
||||
SHADING = ASE::Awk::OPT_SHADING,
|
||||
SHIFT = ASE::Awk::OPT_SHIFT,
|
||||
IDIV = ASE::Awk::OPT_IDIV,
|
||||
STRCONCAT = ASE::Awk::OPT_STRCONCAT,
|
||||
EXTIO = ASE::Awk::OPT_EXTIO,
|
||||
COPROC = ASE::Awk::OPT_COPROC,
|
||||
BLOCKLESS = ASE::Awk::OPT_BLOCKLESS,
|
||||
STRBASEONE = ASE::Awk::OPT_STRBASEONE,
|
||||
STRIPSPACES = ASE::Awk::OPT_STRIPSPACES,
|
||||
NEXTOFILE = ASE::Awk::OPT_NEXTOFILE,
|
||||
CRLF = ASE::Awk::OPT_CRLF,
|
||||
ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN
|
||||
};
|
||||
|
||||
typedef ASE::Awk::char_t char_t;
|
||||
|
||||
Awk ();
|
||||
@ -156,41 +177,15 @@ namespace ASE
|
||||
bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
|
||||
bool DeleteFunction (System::String^ name);
|
||||
|
||||
#if 0
|
||||
property System::IO::Stream^ SourceInputStream
|
||||
property OPTION^ Option
|
||||
{
|
||||
System::IO::Stream^ get ()
|
||||
{
|
||||
return this->sourceInputStream;
|
||||
}
|
||||
|
||||
void set (System::IO::Stream^ stream)
|
||||
{
|
||||
this->sourceInputStream = stream;
|
||||
}
|
||||
OPTION^ get () { return this->option; }
|
||||
void set (OPTION^ opt) { this->option = opt; }
|
||||
}
|
||||
|
||||
property System::IO::Stream^ SourceOutputStream
|
||||
{
|
||||
System::IO::Stream^ get ()
|
||||
{
|
||||
return this->sourceOutputStream;
|
||||
}
|
||||
|
||||
void set (System::IO::Stream^ stream)
|
||||
{
|
||||
this->sourceOutputStream = stream;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
ASE::Awk* awk;
|
||||
|
||||
#if 0
|
||||
System::IO::Stream^ sourceInputStream;
|
||||
System::IO::Stream^ sourceOutputStream;
|
||||
#endif
|
||||
OPTION^ option;
|
||||
|
||||
public protected:
|
||||
// Source
|
||||
@ -231,7 +226,6 @@ namespace ASE
|
||||
|
||||
public protected:
|
||||
int DispatchFunction (System::String^ name);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user