diff --git a/ase/ase.sln b/ase/ase.sln index 7281c666..a2598635 100644 --- a/ase/ase.sln +++ b/ase/ase.sln @@ -41,8 +41,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestlsp", "test\lsp\aset EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asetestcnt", "test\cnt\asetestcnt.csproj", "{F14B75D8-3ED7-4621-B5B9-E96A80B5D809}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj", "{4CBF0E86-D018-49D7-A6B8-0CDA698203F7}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asecnt", "cnt\asecnt.csproj", "{7F679165-41FB-4E1E-B3F5-23C5EE94166A}" ProjectSection(ProjectDependencies) = postProject {963AF7B5-12E6-42B6-8CBE-89136C1A109B} = {963AF7B5-12E6-42B6-8CBE-89136C1A109B} @@ -59,6 +57,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk++", "test\awk\as {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj", "{A63E9DF9-1D47-4D81-834C-1D40406C18C4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -159,16 +159,6 @@ Global {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Win32.ActiveCfg = Release|Any CPU - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Win32.ActiveCfg = Debug|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Win32.Build.0 = Debug|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Any CPU.ActiveCfg = Release|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Mixed Platforms.Build.0 = Release|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Win32.ActiveCfg = Release|Win32 - {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Win32.Build.0 = Release|Win32 {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -199,6 +189,16 @@ Global {3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Mixed Platforms.Build.0 = Release|Win32 {3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Win32.ActiveCfg = Release|Win32 {3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Win32.Build.0 = Release|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Win32.ActiveCfg = Debug|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Win32.Build.0 = Debug|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Release|Any CPU.ActiveCfg = Release|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Release|Mixed Platforms.Build.0 = Release|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Release|Win32.ActiveCfg = Release|Win32 + {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ase/net/Awk.cpp b/ase/net/Awk.cpp new file mode 100644 index 00000000..1c81239f --- /dev/null +++ b/ase/net/Awk.cpp @@ -0,0 +1,139 @@ +/* +* $Id: Awk.cpp,v 1.1 2007/05/15 08:29:30 bacon Exp $ +*/ + +#include "stdafx.h" +#include "Awk.hpp" + +#include +#include +#include +#include + +#include + + +namespace ASE +{ + + class StubAwk: public Awk + { + public: + StubAwk (NET::Awk^ wrapper): wrapper(wrapper) + { + } + + int openSource (Source& io) + { + NET::Awk::Source^ nio = gcnew NET::Awk::Source (); + int n = wrapper->OpenSource (nio); + // TODO: put nio back to io. + return n; + } + + int closeSource (Source& io) + { + return 0; + } + + ssize_t readSource (Source& io, char_t* buf, size_t len) + { + return 0; + } + + ssize_t writeSource (Source& io, char_t* buf, size_t len) + { + return 0; + } + + int openPipe (Pipe& io) {return 0; } + int closePipe (Pipe& io) {return 0; } + ssize_t readPipe (Pipe& io, char_t* buf, size_t len) {return 0; } + ssize_t writePipe (Pipe& io, char_t* buf, size_t len) {return 0; } + int flushPipe (Pipe& io) {return 0; } + + int openFile (File& io) {return 0; } + int closeFile (File& io) {return 0; } + ssize_t readFile (File& io, char_t* buf, size_t len) {return 0; } + ssize_t writeFile (File& io, char_t* buf, size_t len) {return 0; } + int flushFile (File& io) {return 0; } + + int openConsole (Console& io) {return 0; } + int closeConsole (Console& io) {return 0; } + ssize_t readConsole (Console& io, char_t* buf, size_t len) {return 0; } + ssize_t writeConsole (Console& io, char_t* buf, size_t len) {return 0; } + int flushConsole (Console& io) {return 0; } + int nextConsole (Console& io) {return 0; } + + // primitive operations + void* allocMem (size_t n) { return ::malloc (n); } + void* reallocMem (void* ptr, size_t n) { return ::realloc (ptr, n); } + void freeMem (void* ptr) { ::free (ptr); } + + bool_t isUpper (cint_t c) { return ase_isupper (c); } + bool_t isLower (cint_t c) { return ase_islower (c); } + bool_t isAlpha (cint_t c) { return ase_isalpha (c); } + bool_t isDigit (cint_t c) { return ase_isdigit (c); } + bool_t isXdigit (cint_t c) { return ase_isxdigit (c); } + bool_t isAlnum (cint_t c) { return ase_isalnum (c); } + bool_t isSpace (cint_t c) { return ase_isspace (c); } + bool_t isPrint (cint_t c) { return ase_isprint (c); } + bool_t isGraph (cint_t c) { return ase_isgraph (c); } + bool_t isCntrl (cint_t c) { return ase_iscntrl (c); } + bool_t isPunct (cint_t c) { return ase_ispunct (c); } + cint_t toUpper (cint_t c) { return ase_toupper (c); } + cint_t toLower (cint_t c) { return ase_tolower (c); } + + real_t pow (real_t x, real_t y) + { + return ::pow (x, y); + } + + int vsprintf (char_t* buf, size_t size, const char_t* fmt, va_list arg) + { + return ase_vsprintf (buf, size, fmt, arg); + } + + void vdprintf (const char_t* fmt, va_list arg) + { + ase_vfprintf (stderr, fmt, arg); + } + + private: + msclr::auto_gcroot wrapper; + }; + + namespace NET + { + + Awk::Awk () + { + awk = new ASE::StubAwk (this); + } + + Awk::~Awk () + { + delete awk; + } + + bool Awk::Parse () + { + return awk->parse () == 0; + } + + bool Awk::Run () + { + return awk->run () == 0; + } + + bool Awk::AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler) + { + return false; + } + + bool Awk::DeleteFunction (System::String^ name) + { + return false; + } + } +} diff --git a/ase/net/Awk.hpp b/ase/net/Awk.hpp new file mode 100644 index 00000000..9689b26b --- /dev/null +++ b/ase/net/Awk.hpp @@ -0,0 +1,123 @@ +/* + * $Id: Awk.hpp,v 1.1 2007/05/15 08:29:30 bacon Exp $ + */ + +#pragma once + +#include + +using namespace System; + +namespace ASE +{ + namespace NET + { + + public ref class Awk abstract + { + public: + + ref class Source + { + public: + enum class MODE + { + READ = ASE::Awk::Source::READ, + WRITE = ASE::Awk::Source::WRITE + }; + + property MODE^ Mode + { + MODE^ get () { return this->mode; } + void set (MODE^ mode) { this->mode = mode; } + }; + + private: + MODE^ mode; + }; + + ref class Extio + { + + }; + + ref class Pipe: public Extio + { + public: + enum class MODE + { + READ = ASE::Awk::Pipe::READ, + WRITE = ASE::Awk::Pipe::WRITE + }; + + property MODE^ Mode + { + MODE^ get () { return this->mode; } + void set (MODE^ mode) { this->mode = mode; } + }; + + private: + MODE^ mode; + }; + + ref class File: public Extio + { + public: + enum class MODE + { + READ = ASE::Awk::File::READ, + WRITE = ASE::Awk::File::WRITE, + APPEND = ASE::Awk::File::APPEND + }; + + property MODE^ Mode + { + MODE^ get () { return this->mode; } + void set (MODE^ mode) { this->mode = mode; } + }; + + private: + MODE^ mode; + }; + + ref class Console: public Extio + { + public: + enum class MODE + { + READ = ASE::Awk::Console::READ, + WRITE = ASE::Awk::Console::WRITE + }; + + property MODE^ Mode + { + MODE^ get () { return this->mode; } + void set (MODE^ mode) { this->mode = mode; } + }; + + private: + MODE^ mode; + }; + + Awk (); + virtual ~Awk (); + + bool Parse (); + bool Run (); + + delegate System::Object^ FunctionHandler (array^ args); + + bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler); + bool DeleteFunction (System::String^ name); + + virtual int OpenSource (Source^ io) = 0; + virtual int CloseSource (Source^ io) = 0; + virtual int ReadSource (Source^ io, ASE::Awk::char_t* buf, ASE::Awk::size_t len) = 0; + virtual int WriteSource (Source^ io, ASE::Awk::char_t* buf, ASE::Awk::size_t len) = 0; + + private: + ASE::Awk* awk; + }; + + } +} diff --git a/ase/net/asenet.cpp b/ase/net/asenet.cpp new file mode 100644 index 00000000..cb77187f --- /dev/null +++ b/ase/net/asenet.cpp @@ -0,0 +1,7 @@ +/* + * $Id: asenet.cpp,v 1.1 2007/05/15 08:29:30 bacon Exp $ + */ + +#include "stdafx.h" +#include "asenet.h" + diff --git a/ase/net/asenet.h b/ase/net/asenet.h new file mode 100644 index 00000000..42f2954b --- /dev/null +++ b/ase/net/asenet.h @@ -0,0 +1,15 @@ +/* + * $Id: asenet.h,v 1.1 2007/05/15 08:29:30 bacon Exp $ + */ + +#pragma once + +using namespace System; + +namespace ASE +{ + namespace NET + { + + } +} diff --git a/ase/net/asenet.vcproj b/ase/net/asenet.vcproj index 7a13b631..00ac650e 100644 --- a/ase/net/asenet.vcproj +++ b/ase/net/asenet.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="asenet" - ProjectGUID="{4CBF0E86-D018-49D7-A6B8-0CDA698203F7}" + ProjectGUID="{A63E9DF9-1D47-4D81-834C-1D40406C18C4}" RootNamespace="asenet" Keyword="ManagedCProj" > @@ -41,6 +41,7 @@ @@ -183,10 +187,18 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + @@ -213,6 +225,14 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + + + diff --git a/ase/test/cnt/asetestcnt.csproj b/ase/test/cnt/asetestcnt.csproj index 67842324..a8c1e213 100644 --- a/ase/test/cnt/asetestcnt.csproj +++ b/ase/test/cnt/asetestcnt.csproj @@ -18,6 +18,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -77,6 +78,10 @@ {7F679165-41FB-4E1E-B3F5-23C5EE94166A} asecnt + + {A63E9DF9-1D47-4D81-834C-1D40406C18C4} + asenet +