Recovered from cvs revision 2007-07-21 04:14:00

This commit is contained in:
hyung-hwan 2007-07-25 18:53:00 +00:00
parent f263c4f96f
commit 21550f9acf
24 changed files with 532 additions and 340 deletions

View File

@ -12,20 +12,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "awk\aseawk.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jni.vcproj", "{23B58791-FD44-4F95-9F77-34E4AF45A296}"
ProjectSection(ProjectDependencies) = postProject
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}"
ProjectSection(ProjectDependencies) = postProject
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk", "test\awk\asetestawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
ProjectSection(ProjectDependencies) = postProject
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj", "{42FE7CED-34B7-45C8-92C9-8856E16640D2}"
@ -35,8 +35,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestlsp", "test\lsp\asetestlsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
ProjectSection(ProjectDependencies) = postProject
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vcproj", "{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}"
@ -46,11 +46,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vc
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk++", "test\awk\asetestawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
ProjectSection(ProjectDependencies) = postProject
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj", "{A63E9DF9-1D47-4D81-834C-1D40406C18C4}"
ProjectSection(ProjectDependencies) = postProject
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asetestnet", "test\net\asetestnet.csproj", "{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B}"
EndProject

View File

@ -46,7 +46,7 @@
PreprocessorDefinitions="_DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
DisableLanguageExtensions="true"
WarningLevel="3"
SuppressStartupBanner="true"

View File

@ -117,7 +117,7 @@
PreprocessorDefinitions="_DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
DisableLanguageExtensions="true"
WarningLevel="3"
SuppressStartupBanner="true"

View File

@ -148,7 +148,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\debug/aseawk_jni.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.11 2007/06/29 11:36:45 bacon Exp $
* $Id: parse.c,v 1.12 2007/07/20 09:23:37 bacon Exp $
*
* {License}
*/
@ -582,6 +582,12 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
}
else if (MATCH(awk,TOKEN_BEGIN))
{
if (awk->tree.begin != ASE_NULL)
{
SETERRLIN (awk, ASE_AWK_EDUPBEG, awk->token.prev.line);
return ASE_NULL;
}
awk->parse.id.block = PARSE_BEGIN;
if (get_token(awk) == -1) return ASE_NULL;
@ -605,6 +611,12 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
}
else if (MATCH(awk,TOKEN_END))
{
if (awk->tree.end != ASE_NULL)
{
SETERRLIN (awk, ASE_AWK_EDUPEND, awk->token.prev.line);
return ASE_NULL;
}
awk->parse.id.block = PARSE_END;
if (get_token(awk) == -1) return ASE_NULL;

View File

@ -46,7 +46,7 @@
PreprocessorDefinitions="_DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
DisableLanguageExtensions="true"
WarningLevel="3"
SuppressStartupBanner="true"

View File

@ -52,7 +52,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\debug/asecom.pch"

View File

@ -115,7 +115,7 @@
PreprocessorDefinitions="_DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.8 2007/07/19 14:35:10 bacon Exp $
* $Id: Awk.cpp,v 1.9 2007/07/20 09:23:37 bacon Exp $
*/
#include "stdafx.h"
@ -48,8 +48,8 @@ namespace ASE
}
System::IO::StreamReader^ reader = gcnew System::IO::StreamReader (wrapper->SourceInputStream);
System::Runtime::InteropServices::GCHandle gh = System::Runtime::InteropServices::GCHandle::Alloc (reader);
System::IntPtr^ ip = System::Runtime::InteropServices::GCHandle::ToIntPtr(gh);
GCHandle gh = GCHandle::Alloc (reader);
System::IntPtr^ ip = GCHandle::ToIntPtr(gh);
io.setHandle (ip->ToPointer());
}
else
@ -66,8 +66,8 @@ namespace ASE
}
System::IO::StreamWriter^ writer = gcnew System::IO::StreamWriter (wrapper->SourceOutputStream);
System::Runtime::InteropServices::GCHandle gh = System::Runtime::InteropServices::GCHandle::Alloc (writer);
System::IntPtr^ ip = System::Runtime::InteropServices::GCHandle::ToIntPtr(gh);
GCHandle gh = GCHandle::Alloc (writer);
System::IntPtr^ ip = GCHandle::ToIntPtr(gh);
io.setHandle (ip->ToPointer());
}
@ -77,7 +77,7 @@ namespace ASE
int closeSource (Source& io)
{
System::IntPtr ip ((void*)io.getHandle());
System::Runtime::InteropServices::GCHandle gh = System::Runtime::InteropServices::GCHandle::FromIntPtr (ip);
GCHandle gh = GCHandle::FromIntPtr (ip);
if (io.getMode() == Source::READ)
{
@ -97,7 +97,7 @@ namespace ASE
ssize_t readSource (Source& io, char_t* buf, size_t len)
{
System::IntPtr ip ((void*)io.getHandle());
System::Runtime::InteropServices::GCHandle gh = System::Runtime::InteropServices::GCHandle::FromIntPtr (ip);
GCHandle gh = GCHandle::FromIntPtr (ip);
System::IO::StreamReader^ reader = (System::IO::StreamReader^)gh.Target;
@ -111,7 +111,7 @@ namespace ASE
ssize_t writeSource (Source& io, char_t* buf, size_t len)
{
System::IntPtr ip ((void*)io.getHandle());
System::Runtime::InteropServices::GCHandle gh = System::Runtime::InteropServices::GCHandle::FromIntPtr (ip);
GCHandle gh = GCHandle::FromIntPtr (ip);
System::IO::StreamWriter^ writer = (System::IO::StreamWriter^)gh.Target;
@ -131,16 +131,28 @@ namespace ASE
GCHandle gh = GCHandle::Alloc (nio);
io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
return wrapper->FireOpenPipe (nio);
try { return wrapper->OpenPipe (nio); }
catch (...)
{
gh.Free ();
io.setHandle (NULL);
return -1;
}
}
int closePipe (Pipe& io)
{
IntPtr ip ((void*)io.getHandle ());
GCHandle gh = GCHandle::FromIntPtr (ip);
int n = wrapper->FireClosePipe ((ASE::Net::Awk::Pipe^)gh.Target);
gh.Free ();
return n;
try
{
return wrapper->ClosePipe (
(ASE::Net::Awk::Pipe^)gh.Target);
}
catch (...) { return -1; }
finally { gh.Free (); }
}
ssize_t readPipe (Pipe& io, char_t* buf, size_t len)
@ -148,26 +160,48 @@ namespace ASE
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
int n = wrapper->FireReadPipe ((ASE::Net::Awk::Pipe^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
int n = wrapper->ReadPipe (
(ASE::Net::Awk::Pipe^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
ssize_t writePipe (Pipe& io, char_t* buf, size_t len)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->FireWritePipe ((ASE::Net::Awk::Pipe^)gh.Target, b, len);
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WritePipe (
(ASE::Net::Awk::Pipe^)gh.Target, b, len);
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
int flushPipe (Pipe& io)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
return wrapper->FireFlushPipe ((ASE::Net::Awk::Pipe^)gh.Target);
try
{
return wrapper->FlushPipe (
(ASE::Net::Awk::Pipe^)gh.Target);
}
catch (...) { return -1; }
}
int openFile (File& io)
@ -179,16 +213,27 @@ namespace ASE
GCHandle gh = GCHandle::Alloc (nio);
io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
return wrapper->FireOpenFile (nio);
try { return wrapper->OpenFile (nio); }
catch (...)
{
gh.Free ();
io.setHandle (NULL);
return -1;
}
}
int closeFile (File& io)
{
IntPtr ip ((void*)io.getHandle ());
GCHandle gh = GCHandle::FromIntPtr (ip);
int n = wrapper->FireCloseFile ((ASE::Net::Awk::File^)gh.Target);
gh.Free ();
return n;
try
{
return wrapper->CloseFile (
(ASE::Net::Awk::File^)gh.Target);
}
catch (...) { return -1; }
finally { gh.Free (); }
}
ssize_t readFile (File& io, char_t* buf, size_t len)
@ -196,26 +241,47 @@ namespace ASE
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
int n = wrapper->FireReadFile ((ASE::Net::Awk::File^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
int n = wrapper->ReadFile (
(ASE::Net::Awk::File^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
ssize_t writeFile (File& io, char_t* buf, size_t len)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->FireWriteFile ((ASE::Net::Awk::File^)gh.Target, b, len);
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WriteFile (
(ASE::Net::Awk::File^)gh.Target, b, len);
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
int flushFile (File& io)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
return wrapper->FireFlushFile ((ASE::Net::Awk::File^)gh.Target);
try
{
return wrapper->FlushFile (
(ASE::Net::Awk::File^)gh.Target);
}
catch (...) { return -1; }
}
int openConsole (Console& io)
@ -227,49 +293,88 @@ namespace ASE
GCHandle gh = GCHandle::Alloc (nio);
io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
return wrapper->FireOpenConsole (nio);
try { return wrapper->OpenConsole (nio); }
catch (...)
{
gh.Free ();
io.setHandle (NULL);
return -1;
}
}
int closeConsole (Console& io)
{
IntPtr ip ((void*)io.getHandle ());
GCHandle gh = GCHandle::FromIntPtr (ip);
int n = wrapper->FireCloseConsole ((ASE::Net::Awk::Console^)gh.Target);
gh.Free ();
return n;
try
{
return wrapper->CloseConsole (
(ASE::Net::Awk::Console^)gh.Target);
}
catch (...) { return -1; }
finally { gh.Free (); }
}
ssize_t readConsole (Console& io, char_t* buf, size_t len)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
int n = wrapper->FireReadConsole ((ASE::Net::Awk::Console^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
int n = wrapper->ReadConsole (
(ASE::Net::Awk::Console^)gh.Target, b, len);
for (int i = 0; i < n; i++) buf[i] = b[i];
return n;
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
ssize_t writeConsole (Console& io, char_t* buf, size_t len)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->FireWriteConsole ((ASE::Net::Awk::Console^)gh.Target, b, len);
cli::array<char_t>^ b = nullptr;
try
{
b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WriteConsole (
(ASE::Net::Awk::Console^)gh.Target, b, len);
}
catch (...) { return -1; }
finally { if (b != nullptr) delete b; }
}
int flushConsole (Console& io)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
return wrapper->FireFlushConsole ((ASE::Net::Awk::Console^)gh.Target);
try
{
return wrapper->FlushConsole (
(ASE::Net::Awk::Console^)gh.Target);
}
catch (...) { return -1; }
}
int nextConsole (Console& io)
{
IntPtr ip ((void*)io.getHandle());
GCHandle gh = GCHandle::FromIntPtr (ip);
return wrapper->FireNextConsole ((ASE::Net::Awk::Console^)gh.Target);
try
{
return wrapper->NextConsole (
(ASE::Net::Awk::Console^)gh.Target);
}
catch (...) { return -1; }
}
// primitive operations
@ -363,73 +468,6 @@ namespace ASE
return 0;
}
int Awk::FireOpenFile (File^ file)
{
return OpenFileHandler (file);
}
int Awk::FireCloseFile (File^ file)
{
return CloseFileHandler (file);
}
int Awk::FireReadFile (File^ file, cli::array<char_t>^ buf, int len)
{
return ReadFileHandler (file, buf, len);
}
int Awk::FireWriteFile (File^ file, cli::array<char_t>^ buf, int len)
{
return WriteFileHandler (file, buf, len);
}
int Awk::FireFlushFile (File^ file)
{
return FlushFileHandler (file);
}
int Awk::FireOpenPipe (Pipe^ pipe)
{
return OpenPipeHandler (pipe);
}
int Awk::FireClosePipe (Pipe^ pipe)
{
return ClosePipeHandler (pipe);
}
int Awk::FireReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
return ReadPipeHandler (pipe, buf, len);
}
int Awk::FireWritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
return WritePipeHandler (pipe, buf, len);
}
int Awk::FireFlushPipe (Pipe^ pipe)
{
return FlushPipeHandler (pipe);
}
int Awk::FireOpenConsole (Console^ console)
{
return OpenConsoleHandler (console);
}
int Awk::FireCloseConsole (Console^ console)
{
return CloseConsoleHandler (console);
}
int Awk::FireReadConsole (Console^ console, cli::array<char_t>^ buf, int len)
{
return ReadConsoleHandler (console, buf, len);
}
int Awk::FireWriteConsole (Console^ console, cli::array<char_t>^ buf, int len)
{
return WriteConsoleHandler (console, buf, len);
}
int Awk::FireFlushConsole (Console^ console)
{
return FlushConsoleHandler (console);
}
int Awk::FireNextConsole (Console^ console)
{
return NextConsoleHandler (console);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.6 2007/07/19 14:35:10 bacon Exp $
* $Id: Awk.hpp,v 1.7 2007/07/20 09:23:37 bacon Exp $
*/
#pragma once
@ -172,71 +172,46 @@ namespace ASE
}
}
delegate int OpenPipe (Pipe^ pipe);
delegate int ClosePipe (Pipe^ pipe);
delegate int ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
delegate int WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
delegate int FlushPipe (Pipe^ pipe);
delegate int OpenFile (File^ file);
delegate int CloseFile (File^ file);
delegate int ReadFile (File^ file, cli::array<char_t>^ buf, int len);
delegate int WriteFile (File^ file, cli::array<char_t>^ buf, int len);
delegate int FlushFile (File^ file);
delegate int OpenConsole (Console^ console);
delegate int CloseConsole (Console^ console);
delegate int ReadConsole (Console^ console, cli::array<char_t>^ buf, int len);
delegate int WriteConsole (Console^ console, cli::array<char_t>^ buf, int len);
delegate int FlushConsole (Console^ console);
delegate int NextConsole (Console^ console);
event OpenPipe^ OpenPipeHandler;
event ClosePipe^ ClosePipeHandler;
event ReadPipe^ ReadPipeHandler;
event WritePipe^ WritePipeHandler;
event FlushPipe^ FlushPipeHandler;
event OpenFile^ OpenFileHandler;
event CloseFile^ CloseFileHandler;
event ReadFile^ ReadFileHandler;
event WriteFile^ WriteFileHandler;
event FlushFile^ FlushFileHandler;
event OpenConsole^ OpenConsoleHandler;
event CloseConsole^ CloseConsoleHandler;
event ReadConsole^ ReadConsoleHandler;
event WriteConsole^ WriteConsoleHandler;
event FlushConsole^ FlushConsoleHandler;
event NextConsole^ NextConsoleHandler;
protected:
ASE::Awk* awk;
System::IO::Stream^ sourceInputStream;
System::IO::Stream^ sourceOutputStream;
public protected:
// File
virtual int OpenFile (File^ file) = 0;
virtual int CloseFile (File^ file) = 0;
virtual int ReadFile (
File^ file, cli::array<char_t>^ buf, int len) = 0;
virtual int WriteFile (
File^ file, cli::array<char_t>^ buf, int len) = 0;
virtual int FlushFile (File^ file) = 0;
// Pipe
virtual int OpenPipe (Pipe^ pipe) = 0;
virtual int ClosePipe (Pipe^ pipe) = 0;
virtual int ReadPipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) = 0;
virtual int WritePipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) = 0;
virtual int FlushPipe (Pipe^ pipe) = 0;
// Console
virtual int OpenConsole (Console^ console) = 0;
virtual int CloseConsole (Console^ console) = 0;
virtual int ReadConsole (
Console^ console, cli::array<char_t>^ buf, int len) = 0;
virtual int WriteConsole (
Console^ console, cli::array<char_t>^ buf, int len) = 0;
virtual int FlushConsole (Console^ console) = 0;
virtual int NextConsole (Console^ console) = 0;
public protected:
int DispatchFunction (System::String^ name);
int FireOpenFile (File^ file);
int FireCloseFile (File^ file);
int FireReadFile (File^ file, cli::array<char_t>^ buf, int len);
int FireWriteFile (File^ file, cli::array<char_t>^ buf, int len);
int FireFlushFile (File^ file);
int FireOpenPipe (Pipe^ pipe);
int FireClosePipe (Pipe^ pipe);
int FireReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
int FireWritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
int FireFlushPipe (Pipe^ pipe);
int FireOpenConsole (Console^ console);
int FireCloseConsole (Console^ console);
int FireReadConsole (Console^ console, cli::array<char_t>^ buf, int len);
int FireWriteConsole (Console^ console, cli::array<char_t>^ buf, int len);
int FireFlushConsole (Console^ console);
int FireNextConsole (Console^ console);
};
}

View File

@ -1,10 +1,14 @@
/*
* $Id: StdAwk.cpp,v 1.2 2007/07/19 14:35:10 bacon Exp $
* $Id: StdAwk.cpp,v 1.3 2007/07/20 09:23:37 bacon Exp $
*/
#include "stdafx.h"
#include "misc.h"
#include <ase/net/StdAwk.hpp>
#include <stdio.h>
#include <tchar.h>
#include <vcclr.h>
namespace ASE
{
@ -13,62 +17,50 @@ namespace ASE
StdAwk::StdAwk ()
{
OpenFileHandler += gcnew OpenFile (this, &StdAwk::openFile);
CloseFileHandler += gcnew CloseFile (this, &StdAwk::closeFile);
ReadFileHandler += gcnew ReadFile (this, &StdAwk::readFile);
WriteFileHandler += gcnew WriteFile (this, &StdAwk::writeFile);
FlushFileHandler += gcnew FlushFile (this, &StdAwk::flushFile);
}
StdAwk::~StdAwk ()
{
}
int StdAwk::openFile (File^ file)
int StdAwk::OpenFile (File^ file)
{
System::IO::FileMode mode;
System::IO::FileAccess access;
System::IO::FileStream^ fs;
try
if (file->Mode->Equals(File::MODE::READ))
{
if (file->Mode->Equals(File::MODE::READ))
{
mode = System::IO::FileMode::Open;
access = System::IO::FileAccess::Read;
mode = System::IO::FileMode::Open;
access = System::IO::FileAccess::Read;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamReader^ rd = gcnew System::IO::StreamReader (fs);
file->Handle = rd;
}
else if (file->Mode->Equals(File::MODE::WRITE))
{
mode = System::IO::FileMode::Create;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
else /* File::MODE::APPEND */
{
mode = System::IO::FileMode::Append;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
return 1;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamReader^ rd = gcnew System::IO::StreamReader (fs);
file->Handle = rd;
}
catch (System::Exception^)
else if (file->Mode->Equals(File::MODE::WRITE))
{
return -1;
mode = System::IO::FileMode::Create;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
else /* File::MODE::APPEND */
{
mode = System::IO::FileMode::Append;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
return 1;
}
int StdAwk::closeFile (File^ file)
int StdAwk::CloseFile (File^ file)
{
if (file->Mode == File::MODE::READ)
{
@ -83,34 +75,135 @@ namespace ASE
return 0;
}
int StdAwk::readFile (File^ file, cli::array<char_t>^ buf, int len)
int StdAwk::ReadFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
try { return sr->Read (buf, 0, len); }
catch (System::Exception^) { return -1; }
return sr->Read (buf, 0, len);
}
int StdAwk::writeFile (File^ file, cli::array<char_t>^ buf, int len)
int StdAwk::WriteFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
try
{
sw->Write (buf, 0, len);
return len;
}
catch (System::Exception^) { return -1; }
sw->Write (buf, 0, len);
return len;
}
int StdAwk::flushFile (File^ file)
int StdAwk::FlushFile (File^ file)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
try
{
sw->Flush ();
return 0;
}
catch (System::Exception^) { return -1; }
sw->Flush ();
return 0;
}
int StdAwk::OpenPipe (Pipe^ pipe)
{
FILE* fp = NULL;
cli::pin_ptr<const wchar_t> name =
PtrToStringChars(pipe->Name);
if (pipe->Mode->Equals(Pipe::MODE::READ))
{
fp = _wpopen (name, L"r");
}
else // Pipe::MODE::WRITE
{
fp = _wpopen (name, L"w");
}
if (fp == NULL) return -1;
pipe->Handle = IntPtr ((void*)fp);
return 1;
}
int StdAwk::ClosePipe (Pipe^ pipe)
{
IntPtr ip = (IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::_pclose (fp) == EOF)? -1: 0;
}
int StdAwk::ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
IntPtr ip = (IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int n = 0;
while (n < len)
{
wint_t c = fgetwc (fp);
if (c == WEOF) break;
buf[n++] = c;
if (c == L'\n') break;
}
return n;
}
int StdAwk::WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
IntPtr ip = (IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int left;
cli::pin_ptr<char_t> bp = &buf[0];
/* somehow, fwprintf returns 0 when non-ascii
* characters are included in the buffer.
while (left > 0)
{
if (*bp == ASE_T('\0'))
{
if (fputwc (*ptr, fp) == WEOF)
{
return -1;
}
left -= 1; bp += 1;
}
else
{
int n = fwprintf (fp, L"%.*s", left, bp);
if (n < 0 || n > left) return -1;
left -= n; bp += n;
}
}*/
/* so the scheme has been changed to the following */
char* mbp = unicode_to_multibyte (bp, len, &left);
if (mbp == NULL) return -1;
char* ptr = mbp;
while (left > 0)
{
if (*ptr == '\0')
{
if (fputwc (*ptr, fp) == WEOF)
{
return -1;
}
left -= 1; ptr += 1;
}
else
{
int n = fprintf (fp, "%.*s", left, ptr);
if (n < 0 || n > left) return -1;
left -= n; ptr += n;
}
}
::free (mbp);
return len;
}
int StdAwk::FlushPipe (Pipe^ pipe)
{
IntPtr ip = (IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::fflush (fp) == EOF)? -1: 0;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.hpp,v 1.3 2007/07/19 14:35:10 bacon Exp $
* $Id: StdAwk.hpp,v 1.4 2007/07/20 09:23:37 bacon Exp $
*/
#include <ase/net/Awk.hpp>
@ -9,20 +9,30 @@ namespace ASE
namespace Net
{
public ref class StdAwk: Awk
public ref class StdAwk abstract: public Awk
{
public:
StdAwk ();
~StdAwk ();
protected:
int openFile (File^ file);
int closeFile (File^ file);
int readFile (File^ file, cli::array<char_t>^ buf, int len);
int writeFile (File^ file, cli::array<char_t>^ buf, int len);
int flushFile (File^ file);
};
public protected:
// File
virtual int OpenFile (File^ file) override;
virtual int CloseFile (File^ file) override;
virtual int ReadFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int WriteFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int FlushFile (File^ file) override;
// Pipe
virtual int OpenPipe (Pipe^ pipe) override;
virtual int ClosePipe (Pipe^ pipe) override;
virtual int ReadPipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int WritePipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int FlushPipe (Pipe^ pipe) override;
};
}
}

View File

@ -188,11 +188,11 @@
>
</File>
<File
RelativePath=".\assert.cpp"
RelativePath=".\Awk.cpp"
>
</File>
<File
RelativePath=".\Awk.cpp"
RelativePath=".\misc.cpp"
>
</File>
<File
@ -233,6 +233,10 @@
RelativePath=".\Awk.hpp"
>
</File>
<File
RelativePath=".\misc.h"
>
</File>
<File
RelativePath=".\resource.h"
>

View File

@ -1,8 +1,9 @@
/*
* $Id: assert.cpp,v 1.2 2007/07/16 11:12:12 bacon Exp $
* $Id: misc.cpp,v 1.1 2007/07/20 09:23:37 bacon Exp $
*/
#include "stdafx.h"
#include "misc.h"
#ifndef NDEBUG
@ -41,3 +42,14 @@ void ase_assert_printf (const ase_char_t* fmt, ...)
}
#endif
char* unicode_to_multibyte (const wchar_t* in, int inlen, int* outlen)
{
int n;
n = WideCharToMultiByte (CP_UTF8, 0, in, inlen, NULL, 0, NULL, 0);
char* ptr = (char*)::malloc (sizeof(char)*n);
if (ptr == NULL) return NULL;
*outlen = WideCharToMultiByte (CP_UTF8, 0, in, inlen, ptr, n, NULL, 0);
return ptr;
}

18
ase/net/misc.h Normal file
View File

@ -0,0 +1,18 @@
/*
* $Id: misc.h,v 1.1 2007/07/20 09:23:37 bacon Exp $
*/
#ifndef _MISC_H_
#define _MISC_H_
#ifdef __cplusplus
extern "C" {
#endif
char* unicode_to_multibyte (const wchar_t* in, int inlen, int* outlen);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.30 2007/07/15 16:31:59 bacon Exp $
* $Id: Awk.cpp,v 1.31 2007/07/20 09:23:37 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -77,8 +77,11 @@ public:
numConOutFiles = 0;
#ifdef _WIN32
HeapDestroy (heap);
heap = ASE_NULL;
if (heap != ASE_NULL)
{
HeapDestroy (heap);
heap = ASE_NULL;
}
#endif
}

View File

@ -105,8 +105,8 @@
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\..\..\debug\bin"
IntermediateDirectory=".\debug\cpp"
OutputDirectory="..\..\debug\bin"
IntermediateDirectory="debug\cpp"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -137,7 +137,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\debug\cpp\asetestawk++.pch"
AssemblerListingLocation=""
BrowseInformation="1"

View File

@ -135,7 +135,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"

View File

@ -48,7 +48,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"

View File

@ -8,8 +8,43 @@ using System.Windows.Forms;
namespace asetestnet
{
public partial class Form1 : Form
{
public class Awk : ASE.Net.StdAwk
{
protected override int OpenConsole(ASE.Net.StdAwk.Console console)
{
return -1;
}
protected override int CloseConsole(ASE.Net.StdAwk.Console console)
{
return -1;
}
protected override int ReadConsole(ASE.Net.StdAwk.Console console, char[] buf, int len)
{
return -1;
}
protected override int WriteConsole(ASE.Net.StdAwk.Console console, char[] buf, int len)
{
return -1;
}
protected override int FlushConsole(ASE.Net.StdAwk.Console console)
{
return -1;
}
protected override int NextConsole(ASE.Net.StdAwk.Console console)
{
return -1;
}
}
public Form1()
{
InitializeComponent();
@ -17,8 +52,8 @@ namespace asetestnet
private void button1_Click(object sender, EventArgs e)
{
ASE.Net.Awk awk = new ASE.Net.StdAwk();
ASE.Net.Awk awk = new Awk();
/*awk.OpenFileHandler += new ASE.Net.Awk.OpenFile (OpenFile);
awk.CloseFileHandler += CloseFile;*/

View File

@ -8,64 +8,56 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace asetestnet.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("asetestnet.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
namespace asetestnet.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("asetestnet.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -8,23 +8,19 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace asetestnet.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
namespace asetestnet.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -56,6 +56,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

View File

@ -116,7 +116,7 @@
PreprocessorDefinitions="_DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
DisableLanguageExtensions="true"
WarningLevel="3"
SuppressStartupBanner="true"