diff --git a/ase/ase.sln b/ase/ase.sln
index 9a36c4ba..d706a4a4 100644
--- a/ase/ase.sln
+++ b/ase/ase.sln
@@ -19,15 +19,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jn
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}"
ProjectSection(ProjectDependencies) = postProject
- {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
- {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
+ {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
+ {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "test\awk\aseawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
ProjectSection(ProjectDependencies) = postProject
- {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
+ {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj", "{42FE7CED-34B7-45C8-92C9-8856E16640D2}"
@@ -37,8 +37,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "test\lsp\aselsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
ProjectSection(ProjectDependencies) = postProject
- {42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
+ {42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vcproj", "{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}"
@@ -48,8 +48,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vc
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "test\awk\aseawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
ProjectSection(ProjectDependencies) = postProject
- {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
+ {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}"
@@ -85,6 +85,7 @@ Global
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug MD|Win32.Build.0 = Debug MD|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Any CPU.Build.0 = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -100,6 +101,7 @@ Global
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug MD|Win32.Build.0 = Debug MD|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Any CPU.Build.0 = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -115,6 +117,7 @@ Global
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug MD|Win32.Build.0 = Debug MD|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Any CPU.Build.0 = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -130,6 +133,7 @@ Global
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug MD|Win32.Build.0 = Debug MD|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Any CPU.Build.0 = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -145,6 +149,7 @@ Global
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug MD|Win32.Build.0 = Debug MD|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Any CPU.Build.0 = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -160,6 +165,7 @@ Global
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug MD|Win32.Build.0 = Debug MD|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Any CPU.Build.0 = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -175,6 +181,7 @@ Global
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug MD|Win32.Build.0 = Debug MD|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Any CPU.Build.0 = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -190,6 +197,7 @@ Global
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug MD|Win32.Build.0 = Debug MD|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Any CPU.Build.0 = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -205,6 +213,7 @@ Global
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug MD|Win32.Build.0 = Debug MD|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Any CPU.Build.0 = 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
@@ -220,6 +229,7 @@ Global
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug MD|Win32.Build.0 = Debug MD|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Any CPU.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -235,6 +245,7 @@ Global
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug MD|Win32.Build.0 = Debug MD|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Any CPU.Build.0 = 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
diff --git a/ase/awk/Awk.cpp b/ase/awk/Awk.cpp
index 1202a68c..dca2cb7a 100644
--- a/ase/awk/Awk.cpp
+++ b/ase/awk/Awk.cpp
@@ -1,5 +1,5 @@
/*
- * $Id: Awk.cpp,v 1.69 2007/10/08 09:43:15 bacon Exp $
+ * $Id: Awk.cpp,v 1.70 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -935,16 +935,34 @@ const Awk::char_t* Awk::Run::getErrorMessage () const
return ase_awk_getrunerrmsg (this->run);
}
-void Awk::Run::setError (
- ErrorCode code, size_t line, const char_t* arg, size_t len)
+void Awk::Run::setError (ErrorCode code)
{
ASE_ASSERT (this->run != ASE_NULL);
+ ase_awk_setrunerror (this->run, code, 0, ASE_NULL, 0);
+}
- ase_cstr_t x = { arg, len };
+void Awk::Run::setError (ErrorCode code, size_t line)
+{
+ ASE_ASSERT (this->run != ASE_NULL);
+ ase_awk_setrunerror (this->run, code, line, ASE_NULL, 0);
+}
+
+void Awk::Run::setError (ErrorCode code, size_t line, const char_t* arg)
+{
+ ASE_ASSERT (this->run != ASE_NULL);
+ ase_cstr_t x = { arg, ase_strlen(arg) };
ase_awk_setrunerror (this->run, code, line, &x, 1);
}
void Awk::Run::setError (
+ ErrorCode code, size_t line, const char_t* arg, size_t len)
+{
+ ASE_ASSERT (this->run != ASE_NULL);
+ ase_cstr_t x = { arg, len };
+ ase_awk_setrunerror (this->run, code, line, &x, 1);
+}
+
+void Awk::Run::setErrorWithMessage (
ErrorCode code, size_t line, const char_t* msg)
{
ASE_ASSERT (this->run != ASE_NULL);
@@ -1063,8 +1081,22 @@ const Awk::char_t* Awk::getErrorMessage () const
return this->errmsg;
}
-void Awk::setError (
- ErrorCode code, size_t line, const char_t* arg, size_t len)
+void Awk::setError (ErrorCode code)
+{
+ setError (code, 0, ASE_NULL, 0);
+}
+
+void Awk::setError (ErrorCode code, size_t line)
+{
+ setError (code, line, ASE_NULL, 0);
+}
+
+void Awk::setError (ErrorCode code, size_t line, const char_t* arg)
+{
+ setError (code, line, arg, ase_strlen(arg));
+}
+
+void Awk::setError (ErrorCode code, size_t line, const char_t* arg, size_t len)
{
if (awk != ASE_NULL)
{
@@ -1082,8 +1114,7 @@ void Awk::setError (
}
}
-void Awk::setError (
- ErrorCode code, size_t line, const char_t* msg)
+void Awk::setErrorWithMessage (ErrorCode code, size_t line, const char_t* msg)
{
if (awk != ASE_NULL)
{
diff --git a/ase/awk/Awk.hpp b/ase/awk/Awk.hpp
index 0883dda6..0831a6e5 100644
--- a/ase/awk/Awk.hpp
+++ b/ase/awk/Awk.hpp
@@ -1,5 +1,5 @@
/*
- * $Id: Awk.hpp,v 1.70 2007/10/08 09:43:15 bacon Exp $
+ * $Id: Awk.hpp,v 1.71 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -578,9 +578,13 @@ public:
size_t getErrorLine () const;
const char_t* getErrorMessage () const;
- void setError (ErrorCode code, size_t line = 0,
- const char_t* arg = ASE_NULL, size_t len = 0);
- void setError (ErrorCode code, size_t line, const char_t* msg);
+ void setError (ErrorCode code);
+ void setError (ErrorCode code, size_t line);
+ void setError (ErrorCode code, size_t line, const char_t* arg);
+ void setError (ErrorCode code, size_t line, const char_t* arg, size_t len);
+
+ void setErrorWithMessage (
+ ErrorCode code, size_t line, const char_t* msg);
/**
* Sets the value of a global variable. The global variable
@@ -705,9 +709,13 @@ public:
const char_t* getErrorMessage () const;
protected:
- void setError (ErrorCode code, size_t line = 0,
- const char_t* arg = ASE_NULL, size_t len = 0);
- void setError (ErrorCode code, size_t line, const char_t* msg);
+ void setError (ErrorCode code);
+ void setError (ErrorCode code, size_t line);
+ void setError (ErrorCode code, size_t line, const char_t* arg);
+ void setError (ErrorCode code, size_t line, const char_t* arg, size_t len);
+
+ void setErrorWithMessage (
+ ErrorCode code, size_t line, const char_t* msg);
void clearError ();
void retrieveError ();
diff --git a/ase/awk/aseawk_jni.vcproj b/ase/awk/aseawk_jni.vcproj
index e1b10383..e9afea04 100644
--- a/ase/awk/aseawk_jni.vcproj
+++ b/ase/awk/aseawk_jni.vcproj
@@ -17,7 +17,7 @@
@@ -79,9 +75,6 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(OutDir)"
- ProgramDatabaseFile=".\../release/lib/aseawk_jni.pdb"
- ImportLibrary="release/aseawk_jni.lib"
- TargetMachine="1"
/>
=1400)
+ #pragma warning(disable:4996)
+
+ #define time_t __time64_t
+ #define time _time64
+ #define localtime _localtime64
+ #define gmtime _gmtime64
+#endif
enum
{
@@ -1450,10 +1457,10 @@ static int __handle_bfn (
return -1;
}
- tmp[0] = (jchar*)'b';
- tmp[1] = (jchar*)'f';
- tmp[2] = (jchar*)'n';
- tmp[3] = (jchar*)'_';
+ tmp[0] = (jchar)'b';
+ tmp[1] = (jchar)'f';
+ tmp[2] = (jchar)'n';
+ tmp[3] = (jchar)'_';
for (i = 0; i < fnl; i++) tmp[i+4] = (jchar)fnm[i];
name = (*env)->NewString (env, tmp, fnl+4);
free (tmp);
@@ -1689,7 +1696,7 @@ static int __handle_bfn (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -1700,7 +1707,7 @@ static int __handle_bfn (
return -1;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
v = ase_awk_makestrval (run, tmp, len);
free (tmp);
}
@@ -1771,7 +1778,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -1785,7 +1792,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
return;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = (ase_awk_addfunc (awk, tmp, len, 0,
min_args, max_args, ASE_NULL, __handle_bfn) == NULL)? -1: 0;
free (tmp);
@@ -1848,7 +1855,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -1862,7 +1869,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
return;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_delfunc (awk, tmp, len);
free (tmp);
}
@@ -2069,7 +2076,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (ol > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ox = (ase_char_t*)malloc (ASE_SIZEOF(ase_char_t)*ol);
if (ox == ASE_NULL)
{
@@ -2084,13 +2091,13 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
return;
}
- for (i = 0; i < ol; i++) ox[i] = (ase_char_t)op[i];
+ for (x = 0; x < ol; x++) ox[x] = (ase_char_t)op[x];
}
else ox = (ase_char_t*)op;
if (nl > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
nx = (ase_char_t*) malloc (ASE_SIZEOF(ase_char_t)*nl);
if (nx == ASE_NULL)
{
@@ -2107,7 +2114,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
return;
}
- for (i = 0; i < nl; i++) nx[i] = (ase_char_t)np[i];
+ for (x = 0; x < nl; x++) nx[x] = (ase_char_t)np[x];
}
else nx = (ase_char_t*)np;
@@ -2152,7 +2159,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -2167,7 +2174,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
return;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_setfilename (run, tmp, len);
free (tmp);
}
@@ -2211,7 +2218,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -2226,7 +2233,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
return;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_setofilename (run, tmp, len);
free (tmp);
}
@@ -2273,7 +2280,7 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
- ase_size_t i;
+ jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@@ -2287,7 +2294,7 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
return NULL;
}
- for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
+ for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_strtonum (
(ase_awk_run_t*)runid, tmp, len, &lv, &rv);
free (tmp);
diff --git a/ase/awk/parse.c b/ase/awk/parse.c
index 3db2aa0e..a5ae2180 100644
--- a/ase/awk/parse.c
+++ b/ase/awk/parse.c
@@ -1,5 +1,5 @@
/*
- * $Id: parse.c,v 1.18 2007/09/25 15:27:54 bacon Exp $
+ * $Id: parse.c,v 1.19 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -237,8 +237,8 @@ static kwent_t kwtab[] =
{ ASE_T("in"), 2, TOKEN_IN, 0 },
/* top-level block starters */
- { ASE_T("BEGIN"), 5, TOKEN_BEGIN, 0 },
- { ASE_T("END"), 3, TOKEN_END, 0 },
+ { ASE_T("BEGIN"), 5, TOKEN_BEGIN, ASE_AWK_PABLOCK },
+ { ASE_T("END"), 3, TOKEN_END, ASE_AWK_PABLOCK },
{ ASE_T("function"), 8, TOKEN_FUNCTION, 0 },
{ ASE_T("func"), 4, TOKEN_FUNCTION, 0 },
@@ -649,6 +649,13 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
else if (MATCH(awk,TOKEN_LBRACE))
{
/* patternless block */
+ if ((awk->option & ASE_AWK_PABLOCK) == 0)
+ {
+ /* TODO: SET ERROR */
+ SETERRTOK (awk, ASE_AWK_EFUNC);
+ return ASE_NULL;
+ }
+
awk->parse.id.block = PARSE_ACTION_BLOCK;
if (parse_pattern_block (
awk, ASE_NULL, ase_false) == ASE_NULL) return ASE_NULL;
@@ -666,6 +673,13 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
*/
ase_awk_nde_t* ptn;
+ if ((awk->option & ASE_AWK_PABLOCK) == 0)
+ {
+ /* TODO: SET ERROR */
+ SETERRTOK (awk, ASE_AWK_EFUNC);
+ return ASE_NULL;
+ }
+
awk->parse.id.block = PARSE_PATTERN;
ptn = parse_expression (awk, awk->token.line);
diff --git a/ase/net/Awk.cpp b/ase/net/Awk.cpp
index eb175cd3..a52fcdde 100644
--- a/ase/net/Awk.cpp
+++ b/ase/net/Awk.cpp
@@ -1,5 +1,5 @@
/*
- * $Id: Awk.cpp,v 1.31 2007/10/08 09:43:15 bacon Exp $
+ * $Id: Awk.cpp,v 1.32 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -18,1041 +18,1110 @@
using System::Runtime::InteropServices::GCHandle;
-namespace ASE
+ASE_BEGIN_NAMESPACE2(ASE,Net)
+
+class MojoAwk: protected ASE::Awk
{
+public:
+ MojoAwk (): wrapper(nullptr)
+ {
+ }
- class MojoAwk: protected Awk
+ ~MojoAwk ()
{
- public:
- MojoAwk (): wrapper(nullptr)
- {
- }
+ }
- ~MojoAwk ()
+ int open (ASE::Net::Awk^ wrapper)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::open ();
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ void close (ASE::Net::Awk^ wrapper)
+ {
+ this->wrapper = wrapper;
+ Awk::close ();
+ this->wrapper = nullptr;
+ }
+
+ int getOption (ASE::Net::Awk^ wrapper) const
+ {
+ this->wrapper = wrapper;
+ int n = Awk::getOption ();
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ void setOption (ASE::Net::Awk^ wrapper, int opt)
+ {
+ this->wrapper = wrapper;
+ Awk::setOption (opt);
+ this->wrapper = nullptr;
+ }
+
+ size_t getErrorLine (ASE::Net::Awk^ wrapper) const
+ {
+ this->wrapper = wrapper;
+ size_t x = Awk::getErrorLine ();
+ this->wrapper = nullptr;
+ return x;
+ }
+
+ ErrorCode getErrorCode (ASE::Net::Awk^ wrapper) const
+ {
+ this->wrapper = wrapper;
+ ASE::Awk::ErrorCode x = Awk::getErrorCode ();
+ this->wrapper = nullptr;
+ return x;
+ }
+
+ const char_t* getErrorMessage (ASE::Net::Awk^ wrapper) const
+ {
+ this->wrapper = wrapper;
+ const char_t* x = Awk::getErrorMessage();
+ this->wrapper = nullptr;
+ return x;
+ }
+
+ const char_t* getErrorString (ASE::Net::Awk^ wrapper, ErrorCode num) const
+ {
+ this->wrapper = wrapper;
+ const char_t* x = Awk::getErrorString (num);
+ this->wrapper = nullptr;
+ return x;
+ }
+
+ void setError (ASE::Net::Awk^ wrapper, ErrorCode num)
+ {
+ this->wrapper = wrapper;
+ Awk::setError (num);
+ this->wrapper = nullptr;
+ }
+
+ void setError (ASE::Net::Awk^ wrapper, ErrorCode num, size_t line)
+ {
+ this->wrapper = wrapper;
+ Awk::setError (num, line);
+ this->wrapper = nullptr;
+ }
+
+ void setError (ASE::Net::Awk^ wrapper, ErrorCode num, size_t line, const char_t* arg, size_t len)
+ {
+ this->wrapper = wrapper;
+ Awk::setError (num, line, arg, len);
+ this->wrapper = nullptr;
+ }
+
+ void setErrorWithMessage (ASE::Net::Awk^ wrapper, ErrorCode num, size_t line, const char_t* msg)
+ {
+ this->wrapper = wrapper;
+ Awk::setErrorWithMessage (num, line, msg);
+ this->wrapper = nullptr;
+ }
+
+ int setErrorString (ASE::Net::Awk^ wrapper, ErrorCode num, const char_t* msg)
+ {
+ this->wrapper = wrapper;
+ int x = Awk::setErrorString (num, msg);
+ this->wrapper = nullptr;
+ return x;
+ }
+
+ int parse (ASE::Net::Awk^ wrapper)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::parse ();
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ int run (ASE::Net::Awk^ wrapper, const char_t* main = ASE_NULL,
+ const char_t** args = ASE_NULL, size_t nargs = 0)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::run (main, args, nargs);
+ this->wrapper = nullptr;
+ 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 (Run& run)
+ {
+ wrapper->runErrorReported = false;
+
+ Net::Awk::Context^ ctx = gcnew Net::Awk::Context (wrapper, run);
+ GCHandle gh = GCHandle::Alloc (ctx);
+ run.setCustom ((void*)GCHandle::ToIntPtr(gh));
+
+ if (wrapper->OnRunStart != nullptr)
{
+ //wrapper->OnRunStart (wrapper);
+ wrapper->OnRunStart (ctx);
}
- int open (ASE::Net::Awk^ wrapper)
+ // TODO: exception handling when OnRunStart throws an exception.
+ // may need to destroy gh. or what???
+ }
+ void onRunEnd (Run& run)
+ {
+ System::IntPtr ip ((void*)run.getCustom ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ ErrorCode code = run.getErrorCode();
+ if (code != ERR_NOERR)
{
- this->wrapper = wrapper;
- int n = Awk::open ();
- this->wrapper = nullptr;
- return n;
+ wrapper->runErrorReported = true;
+ wrapper->errMsg = gcnew System::String (run.getErrorMessage());
+ wrapper->errLine = run.getErrorLine();
+ wrapper->errCode = (ASE::Net::Awk::ERROR)code;
}
- void close (ASE::Net::Awk^ wrapper)
+ if (wrapper->OnRunEnd != nullptr)
{
- this->wrapper = wrapper;
- Awk::close ();
- this->wrapper = nullptr;
+ //wrapper->OnRunEnd (wrapper);
+ wrapper->OnRunEnd ((ASE::Net::Awk::Context^)gh.Target);
}
- int getOption (ASE::Net::Awk^ wrapper) const
- {
- this->wrapper = wrapper;
- int n = Awk::getOption ();
- this->wrapper = nullptr;
- return n;
- }
+ gh.Free ();
+ }
- void setOption (ASE::Net::Awk^ wrapper, int opt)
- {
- this->wrapper = wrapper;
- Awk::setOption (opt);
- this->wrapper = nullptr;
- }
-
- size_t getErrorLine (ASE::Net::Awk^ wrapper) const
- {
- this->wrapper = wrapper;
- size_t x = Awk::getErrorLine ();
- this->wrapper = nullptr;
- return x;
- }
-
- ErrorCode getErrorCode (ASE::Net::Awk^ wrapper) const
- {
- this->wrapper = wrapper;
- ASE::Awk::ErrorCode x = Awk::getErrorCode ();
- this->wrapper = nullptr;
- return x;
- }
-
- const char_t* getErrorMessage (ASE::Net::Awk^ wrapper) const
- {
- this->wrapper = wrapper;
- const char_t* x = Awk::getErrorMessage();
- this->wrapper = nullptr;
- return x;
- }
-
- const char_t* getErrorString (ASE::Net::Awk^ wrapper, ErrorCode num) const
- {
- this->wrapper = wrapper;
- const char_t* x = Awk::getErrorString (num);
- this->wrapper = nullptr;
- return x;
- }
-
- int setErrorString (ASE::Net::Awk^ wrapper, ErrorCode num, const char_t* msg)
- {
- this->wrapper = wrapper;
- int x = Awk::setErrorString (num, msg);
- this->wrapper = nullptr;
- return x;
- }
-
- int parse (ASE::Net::Awk^ wrapper)
- {
- this->wrapper = wrapper;
- int n = Awk::parse ();
- this->wrapper = nullptr;
- return n;
- }
-
- int run (ASE::Net::Awk^ wrapper, const char_t* main = ASE_NULL,
- const char_t** args = ASE_NULL, size_t nargs = 0)
- {
- this->wrapper = wrapper;
- int n = Awk::run (main, args, nargs);
- this->wrapper = nullptr;
- 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 (Run& run)
- {
- wrapper->runErrorReported = false;
-
- Net::Awk::Context^ ctx = gcnew Net::Awk::Context (wrapper, run);
- GCHandle gh = GCHandle::Alloc (ctx);
- run.setCustom ((void*)GCHandle::ToIntPtr(gh));
-
- if (wrapper->OnRunStart != nullptr)
- {
- //wrapper->OnRunStart (wrapper);
- wrapper->OnRunStart (ctx);
- }
-
- // TODO: exception handling when OnRunStart throws an exception.
- // may need to destroy gh. or what???
- }
- void onRunEnd (Run& run)
+ void onRunReturn (Run& run, const Argument& ret)
+ {
+ if (wrapper->OnRunReturn != nullptr)
{
System::IntPtr ip ((void*)run.getCustom ());
GCHandle gh = GCHandle::FromIntPtr (ip);
- ErrorCode code = run.getErrorCode();
- if (code != ERR_NOERR)
- {
- wrapper->runErrorReported = true;
- wrapper->errMsg = gcnew System::String (run.getErrorMessage());
- wrapper->errLine = run.getErrorLine();
- wrapper->errCode = (ASE::Net::Awk::ERROR)code;
- }
+ //wrapper->OnRunReturn (wrapper);
+ wrapper->OnRunReturn ((ASE::Net::Awk::Context^)gh.Target);
+ }
+ }
- if (wrapper->OnRunEnd != nullptr)
- {
- //wrapper->OnRunEnd (wrapper);
- wrapper->OnRunEnd ((ASE::Net::Awk::Context^)gh.Target);
- }
+ void onRunStatement (Run& run, size_t line)
+ {
+ if (wrapper->stopRequested) run.stop ();
+ if (wrapper->OnRunStatement != nullptr)
+ {
+ System::IntPtr ip ((void*)run.getCustom ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ //wrapper->OnRunStatement (wrapper);
+ wrapper->OnRunStatement ((ASE::Net::Awk::Context^)gh.Target);
+ }
+ }
+
+ int addGlobal (ASE::Net::Awk^ wrapper, const char_t* name)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::addGlobal (name);
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ int deleteGlobal (ASE::Net::Awk^ wrapper, const char_t* name)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::deleteGlobal (name);
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ int addFunction (
+ ASE::Net::Awk^ wrapper, const char_t* name,
+ size_t minArgs, size_t maxArgs, FunctionHandler handler)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::addFunction (name, minArgs, maxArgs, handler);
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ int deleteFunction (ASE::Net::Awk^ wrapper, const char_t* main)
+ {
+ this->wrapper = wrapper;
+ int n = Awk::deleteFunction (main);
+ this->wrapper = nullptr;
+ return n;
+ }
+
+ int mojoFunctionHandler (
+ Run& run, Return& ret, const Argument* args, size_t nargs,
+ const char_t* name, size_t len)
+ {
+ System::IntPtr ip ((void*)run.getCustom ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ return wrapper->DispatchFunction (
+ (ASE::Net::Awk::Context^)gh.Target,
+ ret, args, nargs, name, len)? 0: -1;
+ }
+
+ int openSource (Source& io)
+ {
+ ASE::Net::Awk::Source^ nio = gcnew ASE::Net::Awk::Source (
+ (ASE::Net::Awk::Source::MODE)io.getMode());
+
+ GCHandle gh = GCHandle::Alloc (nio);
+ io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
+
+ try { return wrapper->OpenSource (nio); }
+ catch (...)
+ {
gh.Free ();
+ io.setHandle (NULL);
+ return -1;
}
+ }
- void onRunReturn (Run& run, const Argument& ret)
- {
- if (wrapper->OnRunReturn != nullptr)
- {
- System::IntPtr ip ((void*)run.getCustom ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- //wrapper->OnRunReturn (wrapper);
- wrapper->OnRunReturn ((ASE::Net::Awk::Context^)gh.Target);
- }
- }
-
- void onRunStatement (Run& run, size_t line)
- {
- //if (wrapper->stopRequested) run.stop ();
-
- if (wrapper->OnRunStatement != nullptr)
- {
- System::IntPtr ip ((void*)run.getCustom ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- //wrapper->OnRunStatement (wrapper);
- wrapper->OnRunStatement ((ASE::Net::Awk::Context^)gh.Target);
- }
- }
-
- int addGlobal (ASE::Net::Awk^ wrapper, const char_t* name)
- {
- this->wrapper = wrapper;
- int n = Awk::addGlobal (name);
- this->wrapper = nullptr;
- return n;
- }
-
- int deleteGlobal (ASE::Net::Awk^ wrapper, const char_t* name)
- {
- this->wrapper = wrapper;
- int n = Awk::deleteGlobal (name);
- this->wrapper = nullptr;
- return n;
- }
-
- int addFunction (
- ASE::Net::Awk^ wrapper, const char_t* name,
- size_t minArgs, size_t maxArgs, FunctionHandler handler)
- {
- this->wrapper = wrapper;
- int n = Awk::addFunction (name, minArgs, maxArgs, handler);
- this->wrapper = nullptr;
- return n;
- }
-
- int deleteFunction (ASE::Net::Awk^ wrapper, const char_t* main)
- {
- this->wrapper = wrapper;
- int n = Awk::deleteFunction (main);
- this->wrapper = nullptr;
- return n;
- }
-
- int mojoFunctionHandler (
- Run& run, Return& ret, const Argument* args, size_t nargs,
- const char_t* name, size_t len)
- {
- System::IntPtr ip ((void*)run.getCustom ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- return wrapper->DispatchFunction (
- (ASE::Net::Awk::Context^)gh.Target,
- ret, args, nargs, name, len)? 0: -1;
- }
-
- int openSource (Source& io)
- {
- ASE::Net::Awk::Source^ nio = gcnew ASE::Net::Awk::Source (
- (ASE::Net::Awk::Source::MODE)io.getMode());
-
- GCHandle gh = GCHandle::Alloc (nio);
- io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
-
- try { return wrapper->OpenSource (nio); }
- catch (...)
- {
- gh.Free ();
- io.setHandle (NULL);
- return -1;
- }
- }
-
- int closeSource (Source& io)
- {
- System::IntPtr ip ((void*)io.getHandle ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- try
- {
- return wrapper->CloseSource (
- (ASE::Net::Awk::Source^)gh.Target);
- }
- catch (...) { return -1; }
- finally { gh.Free (); }
- }
-
- ssize_t readSource (Source& io, char_t* buf, size_t len)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
-
- try
- {
- b = gcnew cli::array (len);
- int n = wrapper->ReadSource (
- (ASE::Net::Awk::Source^)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 writeSource (Source& io, char_t* buf, size_t len)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (len);
- for (size_t i = 0; i < len; i++) b[i] = buf[i];
- return wrapper->WriteSource (
- (ASE::Net::Awk::Source^)gh.Target, b, len);
- }
- catch (...) { return -1; }
- finally { if (b != nullptr) delete b; }
- }
-
- int openPipe (Pipe& io)
- {
- ASE::Net::Awk::Pipe^ nio = gcnew ASE::Net::Awk::Pipe (
- gcnew System::String (io.getName ()),
- (ASE::Net::Awk::Pipe::MODE)io.getMode());
-
- GCHandle gh = GCHandle::Alloc (nio);
- io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
-
- try { return wrapper->OpenPipe (nio); }
- catch (...)
- {
- gh.Free ();
- io.setHandle (NULL);
- return -1;
- }
- }
-
- int closePipe (Pipe& io)
- {
- System::IntPtr ip ((void*)io.getHandle ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
-
- try
- {
- b = gcnew cli::array (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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (len);
- for (size_t 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- try
- {
- return wrapper->FlushPipe (
- (ASE::Net::Awk::Pipe^)gh.Target);
- }
- catch (...) { return -1; }
- }
-
- int openFile (File& io)
- {
- ASE::Net::Awk::File^ nio = gcnew ASE::Net::Awk::File (
- gcnew System::String (io.getName ()),
- (ASE::Net::Awk::File::MODE)io.getMode());
-
- GCHandle gh = GCHandle::Alloc (nio);
- io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
-
- try { return wrapper->OpenFile (nio); }
- catch (...)
- {
- gh.Free ();
- io.setHandle (NULL);
- return -1;
- }
- }
-
- int closeFile (File& io)
- {
- System::IntPtr ip ((void*)io.getHandle ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (len);
- for (size_t 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- try
- {
- return wrapper->FlushFile (
- (ASE::Net::Awk::File^)gh.Target);
- }
- catch (...) { return -1; }
- }
-
- int openConsole (Console& io)
- {
- ASE::Net::Awk::Console^ nio = gcnew ASE::Net::Awk::Console (
- gcnew System::String (io.getName ()),
- (ASE::Net::Awk::Console::MODE)io.getMode());
-
- GCHandle gh = GCHandle::Alloc (nio);
- io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
-
- try { return wrapper->OpenConsole (nio); }
- catch (...)
- {
- gh.Free ();
- io.setHandle (NULL);
- return -1;
- }
- }
-
- int closeConsole (Console& io)
- {
- System::IntPtr ip ((void*)io.getHandle ());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- cli::array^ b = nullptr;
- try
- {
- b = gcnew cli::array (len);
- for (size_t 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)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- try
- {
- return wrapper->FlushConsole (
- (ASE::Net::Awk::Console^)gh.Target);
- }
- catch (...) { return -1; }
- }
-
- int nextConsole (Console& io)
- {
- System::IntPtr ip ((void*)io.getHandle());
- GCHandle gh = GCHandle::FromIntPtr (ip);
-
- try
- {
- return wrapper->NextConsole (
- (ASE::Net::Awk::Console^)gh.Target);
- }
- catch (...) { return -1; }
- }
-
- // 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);
- }
-
- protected:
- //msclr::auto_gcroot wrapper;
- mutable gcroot wrapper;
- };
-
- namespace Net
+ int closeSource (Source& io)
{
- Awk::Awk ()
+ System::IntPtr ip ((void*)io.getHandle ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
{
- funcs = gcnew System::Collections::Hashtable();
-
- awk = new ASE::MojoAwk ();
- if (awk->open (this) == -1)
- {
- throw gcnew System::Exception (gcnew System::String(awk->getErrorMessage(this)));
- }
-
- //option = (OPTION)(awk->getOption (this) | MojoAwk::OPT_CRLF);
- option = (OPTION)(awk->getOption (this) | ASE::Awk::OPT_CRLF);
- awk->setOption (this, (int)option);
-
- errMsg = "";
- errLine = 0;
- errCode = ASE::Net::Awk::ERROR::NOERR;
- runErrorReported = false;
+ return wrapper->CloseSource (
+ (ASE::Net::Awk::Source^)gh.Target);
}
+ catch (...) { return -1; }
+ finally { gh.Free (); }
+ }
- Awk::~Awk ()
+ ssize_t readSource (Source& io, char_t* buf, size_t len)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+
+ try
{
- if (awk != NULL)
- {
- awk->close (this);
- delete awk;
- awk = NULL;
- }
-
- if (funcs != nullptr)
- {
- funcs->Clear ();
- delete funcs;
- funcs = nullptr;
- }
- }
-
- Awk::!Awk ()
- {
- if (awk != NULL)
- {
- awk->close (this);
- delete awk;
- awk = NULL;
- }
- }
-
- Awk::OPTION Awk::Option::get ()
- {
- if (awk != NULL) this->option = (OPTION)awk->getOption (this);
- return this->option;
- }
-
- void Awk::Option::set (Awk::OPTION opt)
- {
- this->option = opt;
- if (awk != NULL) awk->setOption (this, (int)this->option);
- }
-
- bool Awk::SetErrorString (Awk::ERROR num, System::String^ msg)
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
-
- cli::pin_ptr nptr = PtrToStringChars(msg);
- bool r = (awk->setErrorString (this, (ASE::Awk::ErrorCode)num, nptr) == 0);
- if (!r) { retrieveError (); }
- return r;
- }
-
- void Awk::Close ()
- {
- if (awk != NULL)
- {
- awk->close (this);
- delete awk;
- awk = NULL;
- }
-
- if (funcs != nullptr)
- {
- funcs->Clear ();
- delete funcs;
- funcs = nullptr;
- }
- }
-
- bool Awk::Parse ()
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- bool r = (awk->parse (this) == 0);
- if (!r) { retrieveError (); }
- return r;
- }
-
- bool Awk::Run ()
- {
- return Run (nullptr, nullptr);
- }
-
- bool Awk::Run (System::String^ entryPoint, cli::array^ args)
- {
- runErrorReported = false;
- //stopRequested = false;
-
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
-
- //if (OnRunStart != nullptr || OnRunEnd != nullptr ||
- // OnRunReturn != nullptr || OnRunStatement != nullptr)
- //{
- awk->enableRunCallback (this);
- //}
-
- if (args == nullptr || args->Length <= 0)
- {
- if (entryPoint == nullptr || entryPoint->Length <= 0)
- {
- bool r = (awk->run (this) == 0);
- if (runErrorReported) r = false;
- else if (!r) retrieveError ();
- return r;
- }
- else
- {
- cli::pin_ptr nptr = PtrToStringChars(entryPoint);
- bool r = (awk->run (this, nptr) == 0);
- if (runErrorReported) r = false;
- else if (!r) retrieveError ();
- return r;
- }
- }
- else
- {
- int nargs = args->Length;
- ASE::Awk::char_t** ptr = ASE_NULL;
-
- try
- {
- bool r = false;
-
- ptr = (ASE::Awk::char_t**)awk->allocMem (nargs * ASE_SIZEOF(ASE::Awk::char_t*));
- if (ptr == ASE_NULL)
- {
- setError (ERROR::NOMEM);
- return false;
- }
- for (int i = 0; i < nargs; i++) ptr[i] = ASE_NULL;
- for (int i = 0; i < nargs; i++)
- {
- cli::pin_ptr nptr = PtrToStringChars (args[i]);
- ptr[i] = (ASE::Awk::char_t*)awk->allocMem ((args[i]->Length+1)*ASE_SIZEOF(ASE::Awk::char_t));
- if (ptr[i] == ASE_NULL)
- {
- r = false;
- setError (ERROR::NOMEM);
- goto exit_run;
- }
- memcpy (ptr[i], nptr, args[i]->Length*ASE_SIZEOF(ASE::Awk::char_t));
- ptr[i][args[i]->Length] = ASE_T('\0');
- }
-
- if (entryPoint == nullptr || entryPoint->Length <= 0)
- {
- r = (awk->run (this, ASE_NULL, (const ASE::Awk::char_t**)ptr, nargs) == 0);
- }
- else
- {
- cli::pin_ptr nptr = PtrToStringChars(entryPoint);
- r = (awk->run (this, nptr, (const ASE::Awk::char_t**)ptr, nargs) == 0);
- }
-
- exit_run:
- if (ptr != ASE_NULL)
- {
- for (int i = 0; i < nargs; i++)
- {
- if (ptr[i] != ASE_NULL)
- {
- awk->freeMem (ptr[i]);
- ptr[i] = ASE_NULL;
- }
- }
-
- awk->freeMem (ptr);
- ptr = ASE_NULL;
- }
-
- if (runErrorReported) r = false;
- else if (!r) retrieveError ();
-
- return r;
- }
- catch (...)
- {
- if (ptr != ASE_NULL)
- {
- for (int i = 0; i < nargs; i++)
- {
- if (ptr[i] != ASE_NULL)
- {
- awk->freeMem (ptr[i]);
- ptr[i] = ASE_NULL;
- }
- }
- awk->freeMem (ptr);
- ptr = ASE_NULL;
- }
-
- setError (ERROR::NOMEM);
- return false;
- }
- }
- }
-
- void Awk::Stop ()
- {
- //stopRequested = true;
- // TODO: implement it...
- }
-
- bool Awk::AddGlobal (System::String^ name, [System::Runtime::InteropServices::Out] int% id)
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
-
- cli::pin_ptr nptr = PtrToStringChars(name);
- int n = awk->addGlobal (this, nptr);
- if (n == -1)
- {
- retrieveError ();
- return false;
- }
-
- id = n;
- return true;
- }
-
- bool Awk::DeleteGlobal (System::String^ name)
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
-
- cli::pin_ptr nptr = PtrToStringChars(name);
- int n = awk->deleteGlobal (this, nptr);
- if (n == -1) retrieveError ();
- return n == 0;
- }
-
- bool Awk::AddFunction (
- System::String^ name, int minArgs, int maxArgs,
- FunctionHandler^ handler)
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- cli::pin_ptr nptr = PtrToStringChars(name);
- int n = awk->addFunction (this, nptr, minArgs, maxArgs,
- (ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler);
- if (n == 0) funcs->Add(name, handler);
- else retrieveError ();
- return n == 0;
- }
-
- bool Awk::DeleteFunction (System::String^ name)
- {
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- cli::pin_ptr nptr = PtrToStringChars(name);
- int n = awk->deleteFunction (this, nptr);
- if (n == 0) funcs->Remove (name);
- else retrieveError ();
- return n == 0;
- }
-
- bool Awk::DispatchFunction (
- Context^ ctx, ASE::Awk::Return& ret,
- const ASE::Awk::Argument* args, size_t nargs,
- const char_t* name, size_t len)
- {
- System::String^ nm =
- gcnew System::String (name, 0, len);
-
- FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
- if (fh == nullptr)
- {
- // TODO: ctx.setError...
- setError (ERROR::INVAL);
- return false;
- }
-
- Return^ r = gcnew Return (ret);
- cli::array^ a =
- gcnew cli::array (nargs);
-
- size_t i;
- for (i = 0; i < nargs; i++)
- a[i] = gcnew Argument(ctx, args[i]);
-
- bool n = fh (ctx, nm, a, r);
-
- while (i > 0) delete a[--i];
- delete a;
- delete r;
-
+ b = gcnew cli::array (len);
+ int n = wrapper->ReadSource (
+ (ASE::Net::Awk::Source^)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; }
+ }
- bool Awk::SetWord (System::String^ ow, System::String^ nw)
+ ssize_t writeSource (Source& io, char_t* buf, size_t len)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
{
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- cli::pin_ptr optr = PtrToStringChars(ow);
- cli::pin_ptr nptr = PtrToStringChars(nw);
- return (awk->setWord (this, optr, ow->Length, nptr, nw->Length) == 0);
+ b = gcnew cli::array (len);
+ for (size_t i = 0; i < len; i++) b[i] = buf[i];
+ return wrapper->WriteSource (
+ (ASE::Net::Awk::Source^)gh.Target, b, len);
}
+ catch (...) { return -1; }
+ finally { if (b != nullptr) delete b; }
+ }
- bool Awk::UnsetWord (System::String^ ow)
+ int openPipe (Pipe& io)
+ {
+ ASE::Net::Awk::Pipe^ nio = gcnew ASE::Net::Awk::Pipe (
+ gcnew System::String (io.getName ()),
+ (ASE::Net::Awk::Pipe::MODE)io.getMode());
+
+ GCHandle gh = GCHandle::Alloc (nio);
+ io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
+
+ try { return wrapper->OpenPipe (nio); }
+ catch (...)
+ {
+ gh.Free ();
+ io.setHandle (NULL);
+ return -1;
+ }
+ }
+
+ int closePipe (Pipe& io)
+ {
+ System::IntPtr ip ((void*)io.getHandle ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
{
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- cli::pin_ptr optr = PtrToStringChars(ow);
- return (awk->unsetWord (this, optr, ow->Length) == 0);
+ return wrapper->ClosePipe (
+ (ASE::Net::Awk::Pipe^)gh.Target);
}
+ catch (...) { return -1; }
+ finally { gh.Free (); }
+ }
- bool Awk::UnsetAllWords ()
+ ssize_t readPipe (Pipe& io, char_t* buf, size_t len)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+
+ try
{
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- return (awk->unsetAllWords (this) == 0);
+ b = gcnew cli::array (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; }
+ }
- bool Awk::SetMaxDepth (DEPTH id, size_t depth)
+ ssize_t writePipe (Pipe& io, char_t* buf, size_t len)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
{
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- awk->setMaxDepth (this, (int)id, depth);
- return true;
+ b = gcnew cli::array (len);
+ for (size_t 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; }
+ }
- bool Awk::GetMaxDepth (DEPTH id, size_t* depth)
+ int flushPipe (Pipe& io)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
{
- if (awk == NULL)
- {
- setError (ERROR::NOPER);
- return false;
- }
- *depth = awk->getMaxDepth (this, (int)id);
- return true;
+ return wrapper->FlushPipe (
+ (ASE::Net::Awk::Pipe^)gh.Target);
}
+ catch (...) { return -1; }
+ }
- void Awk::setError (ERROR num)
+ int openFile (File& io)
+ {
+ ASE::Net::Awk::File^ nio = gcnew ASE::Net::Awk::File (
+ gcnew System::String (io.getName ()),
+ (ASE::Net::Awk::File::MODE)io.getMode());
+
+ GCHandle gh = GCHandle::Alloc (nio);
+ io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
+
+ try { return wrapper->OpenFile (nio); }
+ catch (...)
{
- errMsg = "";
- errLine = 0;
- errCode = num;
-
- if (awk != NULL)
- {
- errMsg = gcnew System::String (
- awk->getErrorString (this, (ASE::Awk::ErrorCode)num));
- }
+ gh.Free ();
+ io.setHandle (NULL);
+ return -1;
}
+ }
- void Awk::retrieveError ()
+ int closeFile (File& io)
+ {
+ System::IntPtr ip ((void*)io.getHandle ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
{
- if (awk != NULL)
- {
- errMsg = gcnew System::String (awk->getErrorMessage(this));
- errLine = awk->getErrorLine (this);
- errCode = (ERROR)awk->getErrorCode (this);
- }
+ 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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
+ {
+ b = gcnew cli::array (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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
+ {
+ b = gcnew cli::array (len);
+ for (size_t 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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
+ {
+ return wrapper->FlushFile (
+ (ASE::Net::Awk::File^)gh.Target);
+ }
+ catch (...) { return -1; }
+ }
+
+ int openConsole (Console& io)
+ {
+ ASE::Net::Awk::Console^ nio = gcnew ASE::Net::Awk::Console (
+ gcnew System::String (io.getName ()),
+ (ASE::Net::Awk::Console::MODE)io.getMode());
+
+ GCHandle gh = GCHandle::Alloc (nio);
+ io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
+
+ try { return wrapper->OpenConsole (nio); }
+ catch (...)
+ {
+ gh.Free ();
+ io.setHandle (NULL);
+ return -1;
+ }
+ }
+
+ int closeConsole (Console& io)
+ {
+ System::IntPtr ip ((void*)io.getHandle ());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ 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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
+ {
+ b = gcnew cli::array (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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ cli::array^ b = nullptr;
+ try
+ {
+ b = gcnew cli::array (len);
+ for (size_t 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)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
+ {
+ return wrapper->FlushConsole (
+ (ASE::Net::Awk::Console^)gh.Target);
+ }
+ catch (...) { return -1; }
+ }
+
+ int nextConsole (Console& io)
+ {
+ System::IntPtr ip ((void*)io.getHandle());
+ GCHandle gh = GCHandle::FromIntPtr (ip);
+
+ try
+ {
+ return wrapper->NextConsole (
+ (ASE::Net::Awk::Console^)gh.Target);
+ }
+ catch (...) { return -1; }
+ }
+
+ // 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);
+ }
+
+protected:
+ //msclr::auto_gcroot wrapper;
+ mutable gcroot wrapper;
+};
+
+Awk::Awk ()
+{
+ funcs = gcnew System::Collections::Hashtable();
+
+ awk = new ASE::Net::MojoAwk ();
+ if (awk->open (this) == -1)
+ {
+ throw gcnew System::Exception (gcnew System::String(awk->getErrorMessage(this)));
+ }
+
+ //option = (OPTION)(awk->getOption (this) | MojoAwk::OPT_CRLF);
+ option = (OPTION)(awk->getOption (this) | ASE::Awk::OPT_CRLF);
+ awk->setOption (this, (int)option);
+
+ errMsg = "";
+ errLine = 0;
+ errCode = ASE::Net::Awk::ERROR::NOERR;
+ runErrorReported = false;
+}
+
+Awk::~Awk ()
+{
+ if (awk != NULL)
+ {
+ awk->close (this);
+ delete awk;
+ awk = NULL;
+ }
+
+ if (funcs != nullptr)
+ {
+ funcs->Clear ();
+ delete funcs;
+ funcs = nullptr;
}
}
+Awk::!Awk ()
+{
+ if (awk != NULL)
+ {
+ awk->close (this);
+ delete awk;
+ awk = NULL;
+ }
+}
+
+Awk::OPTION Awk::Option::get ()
+{
+ if (awk != NULL) this->option = (OPTION)awk->getOption (this);
+ return this->option;
+}
+
+void Awk::Option::set (Awk::OPTION opt)
+{
+ this->option = opt;
+ if (awk != NULL) awk->setOption (this, (int)this->option);
+}
+
+bool Awk::SetErrorString (Awk::ERROR num, System::String^ msg)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+
+ cli::pin_ptr nptr = PtrToStringChars(msg);
+ bool r = (awk->setErrorString (this, (ASE::Awk::ErrorCode)num, nptr) == 0);
+ if (!r) { RetrieveError (); }
+ return r;
+}
+
+void Awk::Close ()
+{
+ if (awk != NULL)
+ {
+ awk->close (this);
+ delete awk;
+ awk = NULL;
+ }
+
+ if (funcs != nullptr)
+ {
+ funcs->Clear ();
+ delete funcs;
+ funcs = nullptr;
+ }
+}
+
+bool Awk::Parse ()
+{
+ if (awk != NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ bool r = (awk->parse (this) == 0);
+ if (!r) { RetrieveError (); }
+ return r;
+}
+
+bool Awk::Run ()
+{
+ return Run (nullptr, nullptr);
+}
+
+bool Awk::Run (System::String^ entryPoint, cli::array^ args)
+{
+ runErrorReported = false;
+ stopRequested = false;
+
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+
+ //if (OnRunStart != nullptr || OnRunEnd != nullptr ||
+ // OnRunReturn != nullptr || OnRunStatement != nullptr)
+ //{
+ awk->enableRunCallback (this);
+ //}
+
+ if (args == nullptr || args->Length <= 0)
+ {
+ if (entryPoint == nullptr || entryPoint->Length <= 0)
+ {
+ bool r = (awk->run (this) == 0);
+ if (runErrorReported) r = false;
+ else if (!r) RetrieveError ();
+ return r;
+ }
+ else
+ {
+ cli::pin_ptr nptr = PtrToStringChars(entryPoint);
+ bool r = (awk->run (this, nptr) == 0);
+ if (runErrorReported) r = false;
+ else if (!r) RetrieveError ();
+ return r;
+ }
+ }
+ else
+ {
+ int nargs = args->Length;
+ ASE::Awk::char_t** ptr = ASE_NULL;
+
+ try
+ {
+ bool r = false;
+
+ ptr = (ASE::Awk::char_t**)awk->allocMem (nargs * ASE_SIZEOF(ASE::Awk::char_t*));
+ if (ptr == ASE_NULL)
+ {
+ SetError (ERROR::NOMEM);
+ return false;
+ }
+ for (int i = 0; i < nargs; i++) ptr[i] = ASE_NULL;
+ for (int i = 0; i < nargs; i++)
+ {
+ cli::pin_ptr nptr = PtrToStringChars (args[i]);
+ ptr[i] = (ASE::Awk::char_t*)awk->allocMem ((args[i]->Length+1)*ASE_SIZEOF(ASE::Awk::char_t));
+ if (ptr[i] == ASE_NULL)
+ {
+ r = false;
+ SetError (ERROR::NOMEM);
+ goto exit_run;
+ }
+ memcpy (ptr[i], nptr, args[i]->Length*ASE_SIZEOF(ASE::Awk::char_t));
+ ptr[i][args[i]->Length] = ASE_T('\0');
+ }
+
+ if (entryPoint == nullptr || entryPoint->Length <= 0)
+ {
+ r = (awk->run (this, ASE_NULL, (const ASE::Awk::char_t**)ptr, nargs) == 0);
+ }
+ else
+ {
+ cli::pin_ptr nptr = PtrToStringChars(entryPoint);
+ r = (awk->run (this, nptr, (const ASE::Awk::char_t**)ptr, nargs) == 0);
+ }
+
+ exit_run:
+ if (ptr != ASE_NULL)
+ {
+ for (int i = 0; i < nargs; i++)
+ {
+ if (ptr[i] != ASE_NULL)
+ {
+ awk->freeMem (ptr[i]);
+ ptr[i] = ASE_NULL;
+ }
+ }
+
+ awk->freeMem (ptr);
+ ptr = ASE_NULL;
+ }
+
+ if (runErrorReported) r = false;
+ else if (!r) RetrieveError ();
+
+ return r;
+ }
+ catch (...)
+ {
+ if (ptr != ASE_NULL)
+ {
+ for (int i = 0; i < nargs; i++)
+ {
+ if (ptr[i] != ASE_NULL)
+ {
+ awk->freeMem (ptr[i]);
+ ptr[i] = ASE_NULL;
+ }
+ }
+ awk->freeMem (ptr);
+ ptr = ASE_NULL;
+ }
+
+ SetError (ERROR::NOMEM);
+ return false;
+ }
+ }
+}
+
+void Awk::Stop ()
+{
+ stopRequested = true;
+}
+
+bool Awk::AddGlobal (System::String^ name, [System::Runtime::InteropServices::Out] int% id)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+
+ cli::pin_ptr nptr = PtrToStringChars(name);
+ int n = awk->addGlobal (this, nptr);
+ if (n == -1)
+ {
+ RetrieveError ();
+ return false;
+ }
+
+ id = n;
+ return true;
+}
+
+bool Awk::DeleteGlobal (System::String^ name)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+
+ cli::pin_ptr nptr = PtrToStringChars(name);
+ int n = awk->deleteGlobal (this, nptr);
+ if (n == -1) RetrieveError ();
+ return n == 0;
+}
+
+bool Awk::AddFunction (
+ System::String^ name, int minArgs, int maxArgs,
+ FunctionHandler^ handler)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ cli::pin_ptr nptr = PtrToStringChars(name);
+ int n = awk->addFunction (this, nptr, minArgs, maxArgs,
+ (ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler);
+ if (n == 0) funcs->Add(name, handler);
+ else RetrieveError ();
+ return n == 0;
+}
+
+bool Awk::DeleteFunction (System::String^ name)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ cli::pin_ptr nptr = PtrToStringChars(name);
+ int n = awk->deleteFunction (this, nptr);
+ if (n == 0) funcs->Remove (name);
+ else RetrieveError ();
+ return n == 0;
+}
+
+bool Awk::DispatchFunction (
+ Context^ ctx, ASE::Awk::Return& ret,
+ const ASE::Awk::Argument* args, size_t nargs,
+ const char_t* name, size_t len)
+{
+ System::String^ nm = gcnew System::String (name, 0, len);
+
+ FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
+ if (fh == nullptr)
+ {
+ ctx->SetError (ERROR::INVAL);
+ return false;
+ }
+
+ Return^ r = gcnew Return (ret);
+ cli::array^ a = gcnew cli::array (nargs);
+
+ size_t i;
+ for (i = 0; i < nargs; i++)
+ a[i] = gcnew Argument(ctx, args[i]);
+
+ bool n = fh (ctx, nm, a, r);
+
+ while (i > 0) delete a[--i];
+ delete a;
+ delete r;
+
+ return n;
+}
+
+bool Awk::SetWord (System::String^ ow, System::String^ nw)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+
+ cli::pin_ptr optr = PtrToStringChars(ow);
+ cli::pin_ptr nptr = PtrToStringChars(nw);
+ return (awk->setWord (this, optr, ow->Length, nptr, nw->Length) == 0);
+}
+
+bool Awk::UnsetWord (System::String^ ow)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ cli::pin_ptr optr = PtrToStringChars(ow);
+ return (awk->unsetWord (this, optr, ow->Length) == 0);
+}
+
+bool Awk::UnsetAllWords ()
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ return (awk->unsetAllWords (this) == 0);
+}
+
+bool Awk::SetMaxDepth (DEPTH id, size_t depth)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ awk->setMaxDepth (this, (int)id, depth);
+ return true;
+}
+
+bool Awk::GetMaxDepth (DEPTH id, size_t* depth)
+{
+ if (awk == NULL)
+ {
+ SetError (ERROR::NOPER);
+ return false;
+ }
+ *depth = awk->getMaxDepth (this, (int)id);
+ return true;
+}
+
+void Awk::SetError (ERROR num)
+{
+ if (awk != NULL)
+ {
+ awk->setError (this, (ASE::Awk::ErrorCode)num);
+ RetrieveError ();
+ }
+ else
+ {
+ errMsg = "";
+ errLine = 0;
+ errCode = num;
+ }
+}
+
+void Awk::SetError (ERROR num, size_t line)
+{
+ if (awk != NULL)
+ {
+ awk->setError (this, (ASE::Awk::ErrorCode)num, line);
+ RetrieveError ();
+ }
+ else
+ {
+ errMsg = "";
+ errLine = line;
+ errCode = num;
+ }
+}
+
+void Awk::SetError (ERROR num, size_t line, System::String^ arg)
+{
+ if (awk != NULL)
+ {
+ cli::pin_ptr p = PtrToStringChars(arg);
+ awk->setError (this, (ASE::Awk::ErrorCode)num, line, p, arg->Length);
+ RetrieveError ();
+ }
+ else
+ {
+ errMsg = "";
+ errLine = line;
+ errCode = num;
+ }
+}
+
+void Awk::SetErrorWithMessage (ERROR num, size_t line, System::String^ msg)
+{
+ if (awk != NULL)
+ {
+ cli::pin_ptr p = PtrToStringChars(msg);
+ awk->setErrorWithMessage (this, (ASE::Awk::ErrorCode)num, line, p);
+ RetrieveError ();
+ }
+ else
+ {
+ errMsg = msg;
+ errLine = line;
+ errCode = num;
+ }
+}
+
+void Awk::RetrieveError ()
+{
+ if (awk != NULL)
+ {
+ errMsg = gcnew System::String (awk->getErrorMessage(this));
+ errLine = awk->getErrorLine (this);
+ errCode = (ERROR)awk->getErrorCode (this);
+ }
+}
+
+ASE_END_NAMESPACE2(Net,ASE)
diff --git a/ase/net/Awk.hpp b/ase/net/Awk.hpp
index ed200c50..cdfe35bd 100644
--- a/ase/net/Awk.hpp
+++ b/ase/net/Awk.hpp
@@ -1,5 +1,5 @@
/*
- * $Id: Awk.hpp,v 1.36 2007/10/08 09:50:52 bacon Exp $
+ * $Id: Awk.hpp,v 1.37 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -9,769 +9,795 @@
#include
#include
-namespace ASE
+///////////////////////////////
+ASE_BEGIN_NAMESPACE2(ASE,Net)
+///////////////////////////////
+
+class MojoAwk;
+
+public ref class Awk abstract
{
- class MojoAwk;
+public:
+ typedef ASE::Awk::long_t long_t;
+ typedef ASE::Awk::real_t real_t;
+ typedef ASE::Awk::char_t char_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;
- namespace Net
+ [System::Flags] enum class OPTION: int
{
- public ref class Awk abstract
+ 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_BASEONE,
+ STRIPSPACES = ASE::Awk::OPT_STRIPSPACES,
+ NEXTOFILE = ASE::Awk::OPT_NEXTOFILE,
+ CRLF = ASE::Awk::OPT_CRLF,
+ ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN,
+ RESET = ASE::Awk::OPT_RESET,
+ MAPTOVAR = ASE::Awk::OPT_MAPTOVAR
+ };
+
+ 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
+ };
+
+ // generated by generrcode-net.awk
+ enum class ERROR: int
+ {
+ NOERR = ASE::Awk::ERR_NOERR,
+ INVAL = ASE::Awk::ERR_INVAL,
+ NOMEM = ASE::Awk::ERR_NOMEM,
+ NOSUP = ASE::Awk::ERR_NOSUP,
+ NOPER = ASE::Awk::ERR_NOPER,
+ NODEV = ASE::Awk::ERR_NODEV,
+ NOSPC = ASE::Awk::ERR_NOSPC,
+ MFILE = ASE::Awk::ERR_MFILE,
+ MLINK = ASE::Awk::ERR_MLINK,
+ AGAIN = ASE::Awk::ERR_AGAIN,
+ NOENT = ASE::Awk::ERR_NOENT,
+ EXIST = ASE::Awk::ERR_EXIST,
+ FTBIG = ASE::Awk::ERR_FTBIG,
+ TBUSY = ASE::Awk::ERR_TBUSY,
+ ISDIR = ASE::Awk::ERR_ISDIR,
+ IOERR = ASE::Awk::ERR_IOERR,
+ OPEN = ASE::Awk::ERR_OPEN,
+ READ = ASE::Awk::ERR_READ,
+ WRITE = ASE::Awk::ERR_WRITE,
+ CLOSE = ASE::Awk::ERR_CLOSE,
+ INTERN = ASE::Awk::ERR_INTERN,
+ RUNTIME = ASE::Awk::ERR_RUNTIME,
+ BLKNST = ASE::Awk::ERR_BLKNST,
+ EXPRNST = ASE::Awk::ERR_EXPRNST,
+ SINOP = ASE::Awk::ERR_SINOP,
+ SINCL = ASE::Awk::ERR_SINCL,
+ SINRD = ASE::Awk::ERR_SINRD,
+ SOUTOP = ASE::Awk::ERR_SOUTOP,
+ SOUTCL = ASE::Awk::ERR_SOUTCL,
+ SOUTWR = ASE::Awk::ERR_SOUTWR,
+ LXCHR = ASE::Awk::ERR_LXCHR,
+ LXDIG = ASE::Awk::ERR_LXDIG,
+ LXUNG = ASE::Awk::ERR_LXUNG,
+ ENDSRC = ASE::Awk::ERR_ENDSRC,
+ ENDCMT = ASE::Awk::ERR_ENDCMT,
+ ENDSTR = ASE::Awk::ERR_ENDSTR,
+ ENDREX = ASE::Awk::ERR_ENDREX,
+ LBRACE = ASE::Awk::ERR_LBRACE,
+ LPAREN = ASE::Awk::ERR_LPAREN,
+ RPAREN = ASE::Awk::ERR_RPAREN,
+ RBRACK = ASE::Awk::ERR_RBRACK,
+ COMMA = ASE::Awk::ERR_COMMA,
+ SCOLON = ASE::Awk::ERR_SCOLON,
+ COLON = ASE::Awk::ERR_COLON,
+ STMEND = ASE::Awk::ERR_STMEND,
+ IN = ASE::Awk::ERR_IN,
+ NOTVAR = ASE::Awk::ERR_NOTVAR,
+ EXPRES = ASE::Awk::ERR_EXPRES,
+ WHILE = ASE::Awk::ERR_WHILE,
+ ASSIGN = ASE::Awk::ERR_ASSIGN,
+ IDENT = ASE::Awk::ERR_IDENT,
+ FNNAME = ASE::Awk::ERR_FNNAME,
+ BLKBEG = ASE::Awk::ERR_BLKBEG,
+ BLKEND = ASE::Awk::ERR_BLKEND,
+ DUPBEG = ASE::Awk::ERR_DUPBEG,
+ DUPEND = ASE::Awk::ERR_DUPEND,
+ BFNRED = ASE::Awk::ERR_BFNRED,
+ AFNRED = ASE::Awk::ERR_AFNRED,
+ GBLRED = ASE::Awk::ERR_GBLRED,
+ PARRED = ASE::Awk::ERR_PARRED,
+ DUPPAR = ASE::Awk::ERR_DUPPAR,
+ DUPGBL = ASE::Awk::ERR_DUPGBL,
+ DUPLCL = ASE::Awk::ERR_DUPLCL,
+ BADPAR = ASE::Awk::ERR_BADPAR,
+ BADVAR = ASE::Awk::ERR_BADVAR,
+ UNDEF = ASE::Awk::ERR_UNDEF,
+ LVALUE = ASE::Awk::ERR_LVALUE,
+ GBLTM = ASE::Awk::ERR_GBLTM,
+ LCLTM = ASE::Awk::ERR_LCLTM,
+ PARTM = ASE::Awk::ERR_PARTM,
+ DELETE = ASE::Awk::ERR_DELETE,
+ BREAK = ASE::Awk::ERR_BREAK,
+ CONTINUE = ASE::Awk::ERR_CONTINUE,
+ NEXTBEG = ASE::Awk::ERR_NEXTBEG,
+ NEXTEND = ASE::Awk::ERR_NEXTEND,
+ NEXTFBEG = ASE::Awk::ERR_NEXTFBEG,
+ NEXTFEND = ASE::Awk::ERR_NEXTFEND,
+ PRINTFARG = ASE::Awk::ERR_PRINTFARG,
+ PREPST = ASE::Awk::ERR_PREPST,
+ GLNCPS = ASE::Awk::ERR_GLNCPS,
+ DIVBY0 = ASE::Awk::ERR_DIVBY0,
+ OPERAND = ASE::Awk::ERR_OPERAND,
+ POSIDX = ASE::Awk::ERR_POSIDX,
+ ARGTF = ASE::Awk::ERR_ARGTF,
+ ARGTM = ASE::Awk::ERR_ARGTM,
+ FNNONE = ASE::Awk::ERR_FNNONE,
+ NOTIDX = ASE::Awk::ERR_NOTIDX,
+ NOTDEL = ASE::Awk::ERR_NOTDEL,
+ NOTMAP = ASE::Awk::ERR_NOTMAP,
+ NOTMAPIN = ASE::Awk::ERR_NOTMAPIN,
+ NOTMAPNILIN = ASE::Awk::ERR_NOTMAPNILIN,
+ NOTREF = ASE::Awk::ERR_NOTREF,
+ NOTASS = ASE::Awk::ERR_NOTASS,
+ IDXVALASSMAP = ASE::Awk::ERR_IDXVALASSMAP,
+ POSVALASSMAP = ASE::Awk::ERR_POSVALASSMAP,
+ MAPTOSCALAR = ASE::Awk::ERR_MAPTOSCALAR,
+ SCALARTOMAP = ASE::Awk::ERR_SCALARTOMAP,
+ MAPNOTALLOWED = ASE::Awk::ERR_MAPNOTALLOWED,
+ VALTYPE = ASE::Awk::ERR_VALTYPE,
+ RDELETE = ASE::Awk::ERR_RDELETE,
+ RNEXTBEG = ASE::Awk::ERR_RNEXTBEG,
+ RNEXTEND = ASE::Awk::ERR_RNEXTEND,
+ RNEXTFBEG = ASE::Awk::ERR_RNEXTFBEG,
+ RNEXTFEND = ASE::Awk::ERR_RNEXTFEND,
+ BFNUSER = ASE::Awk::ERR_BFNUSER,
+ BFNIMPL = ASE::Awk::ERR_BFNIMPL,
+ IOUSER = ASE::Awk::ERR_IOUSER,
+ IONONE = ASE::Awk::ERR_IONONE,
+ IOIMPL = ASE::Awk::ERR_IOIMPL,
+ IONMEM = ASE::Awk::ERR_IONMEM,
+ IONMNL = ASE::Awk::ERR_IONMNL,
+ FMTARG = ASE::Awk::ERR_FMTARG,
+ FMTCNV = ASE::Awk::ERR_FMTCNV,
+ CONVFMTCHR = ASE::Awk::ERR_CONVFMTCHR,
+ OFMTCHR = ASE::Awk::ERR_OFMTCHR,
+ REXRECUR = ASE::Awk::ERR_REXRECUR,
+ REXRPAREN = ASE::Awk::ERR_REXRPAREN,
+ REXRBRACKET = ASE::Awk::ERR_REXRBRACKET,
+ REXRBRACE = ASE::Awk::ERR_REXRBRACE,
+ REXUNBALPAR = ASE::Awk::ERR_REXUNBALPAR,
+ REXCOLON = ASE::Awk::ERR_REXCOLON,
+ REXCRANGE = ASE::Awk::ERR_REXCRANGE,
+ REXCCLASS = ASE::Awk::ERR_REXCCLASS,
+ REXBRANGE = ASE::Awk::ERR_REXBRANGE,
+ REXEND = ASE::Awk::ERR_REXEND,
+ REXGARBAGE = ASE::Awk::ERR_REXGARBAGE
+ };
+ // end of enum class ERROR
+
+ ref class Context;
+
+ ref class Argument
+ {
+ public:
+ Argument (Context^ ctx)
{
- public:
- typedef ASE::Awk::long_t long_t;
- typedef ASE::Awk::real_t real_t;
- typedef ASE::Awk::char_t char_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 Context;
-
- ref class Argument
+ arg = new((ASE::Awk::awk_t*)(ASE::Awk*)ctx->run) ASE::Awk::Argument (ctx->run);
+ if (arg == ASE_NULL)
{
- public:
- Argument (Context^ ctx)
- {
- arg = new((ASE::Awk::awk_t*)(ASE::Awk*)ctx->run) ASE::Awk::Argument (ctx->run);
- if (arg == ASE_NULL)
- {
- throw gcnew System::OutOfMemoryException ("cannot create an instance of ASE::Awk::Argument");
- }
+ throw gcnew System::OutOfMemoryException ("cannot create an instance of ASE::Awk::Argument");
+ }
- arg_new = true;
- }
+ arg_new = true;
+ }
- public protected:
- Argument (Context^ ctx, const ASE::Awk::Argument& arg):
- ctx(ctx), arg((ASE::Awk::Argument*)&arg), arg_new (false)
- {
- }
+ public protected:
+ Argument (Context^ ctx, const ASE::Awk::Argument& arg):
+ ctx(ctx), arg((ASE::Awk::Argument*)&arg), arg_new (false)
+ {
+ }
- public:
- ~Argument ()
- {
- if (arg_new && arg != ASE_NULL)
- {
- delete arg;
- arg = ASE_NULL;
- }
- }
-
- !Argument ()
- {
- if (arg_new && arg != ASE_NULL)
- {
- delete arg;
- arg = ASE_NULL;
- }
- }
-
- public:
- property long_t LongValue
- {
- long_t get () { return arg->toInt(); }
- }
-
- property real_t RealValue
- {
- real_t get () { return arg->toReal(); }
- }
-
- property System::String^ StringValue
- {
- System::String^ get ()
- {
- size_t len;
- const char_t* s = arg->toStr(&len);
- return gcnew System::String (s, 0, len);
- }
- }
-
- bool GetIndexed (System::String^ idx, [System::Runtime::InteropServices::Out] Argument^% v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return arg->getIndexed (ip, idx->Length, *v->arg) == 0;
- }
-
- public protected:
- Context^ ctx;
- ASE::Awk::Argument* arg;
- bool arg_new;
- };
-
- ref class Return
+ public:
+ ~Argument ()
+ {
+ if (arg_new && arg != ASE_NULL)
{
- public protected:
- Return (ASE::Awk::Return& ret): ret (ret)
- {
- }
+ delete arg;
+ arg = ASE_NULL;
+ }
+ }
- public:
- void Clear ()
- {
- ret.clear ();
- }
-
- bool Set (System::String^ v)
- {
- cli::pin_ptr nptr = PtrToStringChars(v);
- return ret.set (nptr, v->Length) == 0;
- }
-
- bool Set (long_t v)
- {
- return ret.set (v) == 0;
- }
-
- bool Set (real_t v)
- {
- return ret.set (v) == 0;
- }
-
- bool Set (System::Single^ v)
- {
- return ret.set ((real_t)(float)v) == 0;
- }
-
- bool Set (System::Double^ v)
- {
- return ret.set ((real_t)(double)v) == 0;
- }
-
- bool Set (System::SByte^ v)
- {
- return ret.set ((long_t)(__int8)v) == 0;
- }
-
- bool Set (System::Int16^ v)
- {
- return ret.set ((long_t)(__int16)v) == 0;
- }
-
- bool Set (System::Int32^ v)
- {
- return ret.set ((long_t)(__int32)v) == 0;
- }
-
- bool Set (System::Int64^ v)
- {
- return ret.set ((long_t)(__int64)v) == 0;
- }
-
- bool Set (System::Byte^ v)
- {
- return ret.set ((long_t)(unsigned __int8)v) == 0;
- }
-
- bool Set (System::UInt16^ v)
- {
- return ret.set ((long_t)(unsigned __int16)v) == 0;
- }
-
- bool Set (System::UInt32^ v)
- {
- return ret.set ((long_t)(unsigned __int32)v) == 0;
- }
-
- bool Set (System::UInt64^ v)
- {
- return ret.set ((long_t)(unsigned __int64)v) == 0;
- }
-
- bool IsIndexed ()
- {
- return ret.isIndexed ();
- }
-
- bool SetIndexed (System::String^ idx, System::String^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- cli::pin_ptr vp = PtrToStringChars(v);
- return ret.setIndexed (ip, idx->Length, vp, v->Length) == 0;
- }
-
- bool SetIndexed (System::String^ idx, long_t v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, real_t v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Single^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (real_t)(float)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Double^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (real_t)(double)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::SByte^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(__int8)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Int16^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(__int16)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Int32^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(__int32)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Int64^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(__int64)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::Byte^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int8)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::UInt16^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int16)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::UInt32^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int32)v) == 0;
- }
-
- bool SetIndexed (System::String^ idx, System::UInt64^ v)
- {
- cli::pin_ptr ip = PtrToStringChars(idx);
- return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int64)v) == 0;
- }
-
- public protected:
- ASE::Awk::Return& ret;
- };
-
- ref class Context
+ !Argument ()
+ {
+ if (arg_new && arg != ASE_NULL)
{
- public protected:
- Context (Awk^ owner, const ASE::Awk::Run& run): owner (owner), run ((ASE::Awk::Run&)run)
- {
- }
+ delete arg;
+ arg = ASE_NULL;
+ }
+ }
- public:
- property Awk^ Owner
- {
- Awk^ get () { return this->owner; }
- }
+ public:
+ property long_t LongValue
+ {
+ long_t get () { return arg->toInt(); }
+ }
- bool Stop ()
- {
- return run.stop () == 0;
- }
+ property real_t RealValue
+ {
+ real_t get () { return arg->toReal(); }
+ }
- /* TODO:
- * GetError
- * SetError
- */
-
- bool SetGlobal (int id, System::String^ v)
- {
- cli::pin_ptr nptr = PtrToStringChars(v);
- return run.setGlobal (id, nptr, v->Length) == 0;
- }
-
- bool SetGlobal (int id, long_t v)
- {
- return run.setGlobal (id, v) == 0;
- }
- bool SetGlobal (int id, System::SByte^ v)
- {
- return run.setGlobal (id, (long_t)(__int8)v) == 0;
- }
- bool SetGlobal (int id, System::Int16^ v)
- {
- return run.setGlobal (id, (long_t)(__int16)v) == 0;
- }
- bool SetGlobal (int id, System::Int32^ v)
- {
- return run.setGlobal (id, (long_t)(__int32)v) == 0;
- }
- bool SetGlobal (int id, System::Int64^ v)
- {
- return run.setGlobal (id, (long_t)(__int64)v) == 0;
- }
- bool SetGlobal (int id, System::Byte^ v)
- {
- return run.setGlobal (id, (long_t)(unsigned __int8)v) == 0;
- }
- bool SetGlobal (int id, System::UInt16^ v)
- {
- return run.setGlobal (id, (long_t)(unsigned __int16)v) == 0;
- }
- bool SetGlobal (int id, System::UInt32^ v)
- {
- return run.setGlobal (id, (long_t)(unsigned __int32)v) == 0;
- }
- bool SetGlobal (int id, System::UInt64^ v)
- {
- return run.setGlobal (id, (long_t)(unsigned __int64)v) == 0;
- }
-
- bool SetGlobal (int id, real_t v)
- {
- return run.setGlobal (id, v) == 0;
- }
- bool SetGlobal (int id, System::Single^ v)
- {
- return run.setGlobal (id, (real_t)(float)v) == 0;
- }
- bool SetGlobal (int id, System::Double^ v)
- {
- return run.setGlobal (id, (real_t)(double)v) == 0;
- }
-
- bool SetGlobal (int id, Return^ v)
- {
- return run.setGlobal (id, v->ret) == 0;
- }
-
- bool GetGlobal (int id, [System::Runtime::InteropServices::Out] Argument^% v)
- {
- return run.getGlobal (id, *v->arg) == 0;
- }
-
- public protected:
- Awk^ owner;
- ASE::Awk::Run& run;
- };
-
- ref class Source
+ property System::String^ StringValue
+ {
+ System::String^ get ()
{
- public:
- enum class MODE
- {
- READ = ASE::Awk::Source::READ,
- WRITE = ASE::Awk::Source::WRITE
- };
+ size_t len;
+ const char_t* s = arg->toStr(&len);
+ return gcnew System::String (s, 0, len);
+ }
+ }
- Source (MODE^ mode): handle (nullptr)
- {
- this->mode = mode;
- }
+ bool GetIndexed (System::String^ idx, [System::Runtime::InteropServices::Out] Argument^% v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return arg->getIndexed (ip, idx->Length, *v->arg) == 0;
+ }
- property Object^ Handle
- {
- Object^ get () { return this->handle; }
- void set (Object^ handle) { this->handle = handle; }
- }
+ public protected:
+ Context^ ctx;
+ ASE::Awk::Argument* arg;
+ bool arg_new;
+ };
- property MODE^ Mode
- {
- MODE^ get () { return this->mode; }
- };
+ ref class Return
+ {
+ public protected:
+ Return (ASE::Awk::Return& ret): ret (ret)
+ {
+ }
- private:
- MODE^ mode;
- Object^ handle;
- };
+ public:
+ void Clear ()
+ {
+ ret.clear ();
+ }
+
+ bool Set (System::String^ v)
+ {
+ cli::pin_ptr nptr = PtrToStringChars(v);
+ return ret.set (nptr, v->Length) == 0;
+ }
- ref class Extio
- {
- public:
- Extio (System::String^ name): handle (nullptr)
- {
- this->name = name;
- }
+ bool Set (long_t v)
+ {
+ return ret.set (v) == 0;
+ }
- property Object^ Handle
- {
- Object^ get () { return this->handle; }
- void set (Object^ handle) { this->handle = handle; }
- }
+ bool Set (real_t v)
+ {
+ return ret.set (v) == 0;
+ }
- property System::String^ Name
- {
- System::String^ get () { return this->name; }
- };
+ bool Set (System::Single^ v)
+ {
+ return ret.set ((real_t)(float)v) == 0;
+ }
- private:
- Object^ handle;
- System::String^ name;
- };
+ bool Set (System::Double^ v)
+ {
+ return ret.set ((real_t)(double)v) == 0;
+ }
- ref class Pipe: public Extio
- {
- public:
- enum class MODE
- {
- READ = ASE::Awk::Pipe::READ,
- WRITE = ASE::Awk::Pipe::WRITE
- };
+ bool Set (System::SByte^ v)
+ {
+ return ret.set ((long_t)(__int8)v) == 0;
+ }
- property MODE^ Mode
- {
- MODE^ get () { return this->mode; }
- };
+ bool Set (System::Int16^ v)
+ {
+ return ret.set ((long_t)(__int16)v) == 0;
+ }
+
+ bool Set (System::Int32^ v)
+ {
+ return ret.set ((long_t)(__int32)v) == 0;
+ }
- Pipe (System::String^ name, MODE^ mode): Extio (name)
- {
- this->mode = mode;
- }
+ bool Set (System::Int64^ v)
+ {
+ return ret.set ((long_t)(__int64)v) == 0;
+ }
- private:
- MODE^ mode;
- };
+ bool Set (System::Byte^ v)
+ {
+ return ret.set ((long_t)(unsigned __int8)v) == 0;
+ }
- ref class File: public Extio
- {
- public:
- enum class MODE
- {
- READ = ASE::Awk::File::READ,
- WRITE = ASE::Awk::File::WRITE,
- APPEND = ASE::Awk::File::APPEND
- };
+ bool Set (System::UInt16^ v)
+ {
+ return ret.set ((long_t)(unsigned __int16)v) == 0;
+ }
+
+ bool Set (System::UInt32^ v)
+ {
+ return ret.set ((long_t)(unsigned __int32)v) == 0;
+ }
- property MODE^ Mode
- {
- MODE^ get () { return this->mode; }
- };
+ bool Set (System::UInt64^ v)
+ {
+ return ret.set ((long_t)(unsigned __int64)v) == 0;
+ }
- File (System::String^ name, MODE^ mode): Extio (name)
- {
- this->mode = mode;
- }
+ bool IsIndexed ()
+ {
+ return ret.isIndexed ();
+ }
- private:
- MODE^ mode;
- };
+ bool SetIndexed (System::String^ idx, System::String^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ cli::pin_ptr vp = PtrToStringChars(v);
+ return ret.setIndexed (ip, idx->Length, vp, v->Length) == 0;
+ }
- ref class Console: public Extio
- {
- public:
- enum class MODE
- {
- READ = ASE::Awk::Console::READ,
- WRITE = ASE::Awk::Console::WRITE
- };
+ bool SetIndexed (System::String^ idx, long_t v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, v) == 0;
+ }
- property MODE^ Mode
- {
- MODE^ get () { return this->mode; }
- };
+ bool SetIndexed (System::String^ idx, real_t v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, v) == 0;
+ }
- Console (System::String^ name, MODE^ mode): Extio (name)
- {
- this->mode = mode;
- }
+ bool SetIndexed (System::String^ idx, System::Single^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (real_t)(float)v) == 0;
+ }
- private:
- MODE^ mode;
- };
+ bool SetIndexed (System::String^ idx, System::Double^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (real_t)(double)v) == 0;
+ }
+
+ bool SetIndexed (System::String^ idx, System::SByte^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(__int8)v) == 0;
+ }
+
+ bool SetIndexed (System::String^ idx, System::Int16^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(__int16)v) == 0;
+ }
- [System::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_BASEONE,
- STRIPSPACES = ASE::Awk::OPT_STRIPSPACES,
- NEXTOFILE = ASE::Awk::OPT_NEXTOFILE,
- CRLF = ASE::Awk::OPT_CRLF,
- ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN,
- RESET = ASE::Awk::OPT_RESET,
- MAPTOVAR = ASE::Awk::OPT_MAPTOVAR
- };
+ bool SetIndexed (System::String^ idx, System::Int32^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(__int32)v) == 0;
+ }
- 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
- };
+ bool SetIndexed (System::String^ idx, System::Int64^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(__int64)v) == 0;
+ }
- // generated by generrcode-net.awk
- enum class ERROR: int
- {
- NOERR = ASE::Awk::ERR_NOERR,
- INVAL = ASE::Awk::ERR_INVAL,
- NOMEM = ASE::Awk::ERR_NOMEM,
- NOSUP = ASE::Awk::ERR_NOSUP,
- NOPER = ASE::Awk::ERR_NOPER,
- NODEV = ASE::Awk::ERR_NODEV,
- NOSPC = ASE::Awk::ERR_NOSPC,
- MFILE = ASE::Awk::ERR_MFILE,
- MLINK = ASE::Awk::ERR_MLINK,
- AGAIN = ASE::Awk::ERR_AGAIN,
- NOENT = ASE::Awk::ERR_NOENT,
- EXIST = ASE::Awk::ERR_EXIST,
- FTBIG = ASE::Awk::ERR_FTBIG,
- TBUSY = ASE::Awk::ERR_TBUSY,
- ISDIR = ASE::Awk::ERR_ISDIR,
- IOERR = ASE::Awk::ERR_IOERR,
- OPEN = ASE::Awk::ERR_OPEN,
- READ = ASE::Awk::ERR_READ,
- WRITE = ASE::Awk::ERR_WRITE,
- CLOSE = ASE::Awk::ERR_CLOSE,
- INTERN = ASE::Awk::ERR_INTERN,
- RUNTIME = ASE::Awk::ERR_RUNTIME,
- BLKNST = ASE::Awk::ERR_BLKNST,
- EXPRNST = ASE::Awk::ERR_EXPRNST,
- SINOP = ASE::Awk::ERR_SINOP,
- SINCL = ASE::Awk::ERR_SINCL,
- SINRD = ASE::Awk::ERR_SINRD,
- SOUTOP = ASE::Awk::ERR_SOUTOP,
- SOUTCL = ASE::Awk::ERR_SOUTCL,
- SOUTWR = ASE::Awk::ERR_SOUTWR,
- LXCHR = ASE::Awk::ERR_LXCHR,
- LXDIG = ASE::Awk::ERR_LXDIG,
- LXUNG = ASE::Awk::ERR_LXUNG,
- ENDSRC = ASE::Awk::ERR_ENDSRC,
- ENDCMT = ASE::Awk::ERR_ENDCMT,
- ENDSTR = ASE::Awk::ERR_ENDSTR,
- ENDREX = ASE::Awk::ERR_ENDREX,
- LBRACE = ASE::Awk::ERR_LBRACE,
- LPAREN = ASE::Awk::ERR_LPAREN,
- RPAREN = ASE::Awk::ERR_RPAREN,
- RBRACK = ASE::Awk::ERR_RBRACK,
- COMMA = ASE::Awk::ERR_COMMA,
- SCOLON = ASE::Awk::ERR_SCOLON,
- COLON = ASE::Awk::ERR_COLON,
- STMEND = ASE::Awk::ERR_STMEND,
- IN = ASE::Awk::ERR_IN,
- NOTVAR = ASE::Awk::ERR_NOTVAR,
- EXPRES = ASE::Awk::ERR_EXPRES,
- WHILE = ASE::Awk::ERR_WHILE,
- ASSIGN = ASE::Awk::ERR_ASSIGN,
- IDENT = ASE::Awk::ERR_IDENT,
- FNNAME = ASE::Awk::ERR_FNNAME,
- BLKBEG = ASE::Awk::ERR_BLKBEG,
- BLKEND = ASE::Awk::ERR_BLKEND,
- DUPBEG = ASE::Awk::ERR_DUPBEG,
- DUPEND = ASE::Awk::ERR_DUPEND,
- BFNRED = ASE::Awk::ERR_BFNRED,
- AFNRED = ASE::Awk::ERR_AFNRED,
- GBLRED = ASE::Awk::ERR_GBLRED,
- PARRED = ASE::Awk::ERR_PARRED,
- DUPPAR = ASE::Awk::ERR_DUPPAR,
- DUPGBL = ASE::Awk::ERR_DUPGBL,
- DUPLCL = ASE::Awk::ERR_DUPLCL,
- BADPAR = ASE::Awk::ERR_BADPAR,
- BADVAR = ASE::Awk::ERR_BADVAR,
- UNDEF = ASE::Awk::ERR_UNDEF,
- LVALUE = ASE::Awk::ERR_LVALUE,
- GBLTM = ASE::Awk::ERR_GBLTM,
- LCLTM = ASE::Awk::ERR_LCLTM,
- PARTM = ASE::Awk::ERR_PARTM,
- DELETE = ASE::Awk::ERR_DELETE,
- BREAK = ASE::Awk::ERR_BREAK,
- CONTINUE = ASE::Awk::ERR_CONTINUE,
- NEXTBEG = ASE::Awk::ERR_NEXTBEG,
- NEXTEND = ASE::Awk::ERR_NEXTEND,
- NEXTFBEG = ASE::Awk::ERR_NEXTFBEG,
- NEXTFEND = ASE::Awk::ERR_NEXTFEND,
- PRINTFARG = ASE::Awk::ERR_PRINTFARG,
- PREPST = ASE::Awk::ERR_PREPST,
- GLNCPS = ASE::Awk::ERR_GLNCPS,
- DIVBY0 = ASE::Awk::ERR_DIVBY0,
- OPERAND = ASE::Awk::ERR_OPERAND,
- POSIDX = ASE::Awk::ERR_POSIDX,
- ARGTF = ASE::Awk::ERR_ARGTF,
- ARGTM = ASE::Awk::ERR_ARGTM,
- FNNONE = ASE::Awk::ERR_FNNONE,
- NOTIDX = ASE::Awk::ERR_NOTIDX,
- NOTDEL = ASE::Awk::ERR_NOTDEL,
- NOTMAP = ASE::Awk::ERR_NOTMAP,
- NOTMAPIN = ASE::Awk::ERR_NOTMAPIN,
- NOTMAPNILIN = ASE::Awk::ERR_NOTMAPNILIN,
- NOTREF = ASE::Awk::ERR_NOTREF,
- NOTASS = ASE::Awk::ERR_NOTASS,
- IDXVALASSMAP = ASE::Awk::ERR_IDXVALASSMAP,
- POSVALASSMAP = ASE::Awk::ERR_POSVALASSMAP,
- MAPTOSCALAR = ASE::Awk::ERR_MAPTOSCALAR,
- SCALARTOMAP = ASE::Awk::ERR_SCALARTOMAP,
- MAPNOTALLOWED = ASE::Awk::ERR_MAPNOTALLOWED,
- VALTYPE = ASE::Awk::ERR_VALTYPE,
- RDELETE = ASE::Awk::ERR_RDELETE,
- RNEXTBEG = ASE::Awk::ERR_RNEXTBEG,
- RNEXTEND = ASE::Awk::ERR_RNEXTEND,
- RNEXTFBEG = ASE::Awk::ERR_RNEXTFBEG,
- RNEXTFEND = ASE::Awk::ERR_RNEXTFEND,
- BFNUSER = ASE::Awk::ERR_BFNUSER,
- BFNIMPL = ASE::Awk::ERR_BFNIMPL,
- IOUSER = ASE::Awk::ERR_IOUSER,
- IONONE = ASE::Awk::ERR_IONONE,
- IOIMPL = ASE::Awk::ERR_IOIMPL,
- IONMEM = ASE::Awk::ERR_IONMEM,
- IONMNL = ASE::Awk::ERR_IONMNL,
- FMTARG = ASE::Awk::ERR_FMTARG,
- FMTCNV = ASE::Awk::ERR_FMTCNV,
- CONVFMTCHR = ASE::Awk::ERR_CONVFMTCHR,
- OFMTCHR = ASE::Awk::ERR_OFMTCHR,
- REXRECUR = ASE::Awk::ERR_REXRECUR,
- REXRPAREN = ASE::Awk::ERR_REXRPAREN,
- REXRBRACKET = ASE::Awk::ERR_REXRBRACKET,
- REXRBRACE = ASE::Awk::ERR_REXRBRACE,
- REXUNBALPAR = ASE::Awk::ERR_REXUNBALPAR,
- REXCOLON = ASE::Awk::ERR_REXCOLON,
- REXCRANGE = ASE::Awk::ERR_REXCRANGE,
- REXCCLASS = ASE::Awk::ERR_REXCCLASS,
- REXBRANGE = ASE::Awk::ERR_REXBRANGE,
- REXEND = ASE::Awk::ERR_REXEND,
- REXGARBAGE = ASE::Awk::ERR_REXGARBAGE
- };
- // end of enum class ERROR
+ bool SetIndexed (System::String^ idx, System::Byte^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int8)v) == 0;
+ }
- typedef ASE::Awk::char_t char_t;
+ bool SetIndexed (System::String^ idx, System::UInt16^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int16)v) == 0;
+ }
+
+ bool SetIndexed (System::String^ idx, System::UInt32^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int32)v) == 0;
+ }
- Awk ();
- !Awk ();
- virtual ~Awk ();
+ bool SetIndexed (System::String^ idx, System::UInt64^ v)
+ {
+ cli::pin_ptr ip = PtrToStringChars(idx);
+ return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int64)v) == 0;
+ }
- virtual void Close ();
- virtual bool Parse ();
- virtual bool Run ();
- virtual bool Run (System::String^ entryPoint, cli::array^ args);
- virtual void Stop ();
+ public protected:
+ ASE::Awk::Return& ret;
+ };
- delegate void RunStartHandler (Context^ ctx);
- delegate void RunEndHandler (Context^ ctx);
- delegate void RunReturnHandler (Context^ ctx);
- delegate void RunStatementHandler (Context^ ctx);
+ ref class Context
+ {
+ public protected:
+ Context (Awk^ owner, const ASE::Awk::Run& run): owner (owner), run ((ASE::Awk::Run&)run)
+ {
+ }
- /*event*/ RunStartHandler^ OnRunStart;
- /*event*/ RunEndHandler^ OnRunEnd;
- /*event*/ RunReturnHandler^ OnRunReturn;
- /*event*/ RunStatementHandler^ OnRunStatement;
+ public:
+ property Awk^ Owner
+ {
+ Awk^ get () { return this->owner; }
+ }
- virtual bool AddGlobal (
- System::String^ name,
- [System::Runtime::InteropServices::Out] int% id);
- virtual bool DeleteGlobal (System::String^ name);
+ bool Stop ()
+ {
+ return run.stop () == 0;
+ }
- delegate bool FunctionHandler (
- Context^ ctx, System::String^ name,
- cli::array^ args, Return^ ret);
+ void SetError (ASE::Net::Awk::ERROR num)
+ {
+ return run.setError ((ASE::Awk::ErrorCode)num);
+ }
- virtual bool AddFunction (
- System::String^ name, int minArgs,
- int maxArgs, FunctionHandler^ handler);
- virtual bool DeleteFunction (System::String^ name);
+ void SetError (ASE::Net::Awk::ERROR num, size_t line)
+ {
+ return run.setError ((ASE::Awk::ErrorCode)num, line);
+ }
- virtual bool SetWord (System::String^ ow, System::String^ nw);
- virtual bool UnsetWord (System::String^ ow);
- virtual bool UnsetAllWords ();
+ void SetError (ASE::Net::Awk::ERROR num, size_t line, System::String^ arg)
+ {
+ cli::pin_ptr p = PtrToStringChars(arg);
+ return run.setError (
+ (ASE::Awk::ErrorCode)num, line, p, arg->Length);
+ }
- virtual bool SetMaxDepth (DEPTH id, size_t depth);
- virtual bool GetMaxDepth (DEPTH id, size_t* depth);
+ void SetErrorWithMessage (
+ ASE::Net::Awk::ERROR num, size_t line, System::String^ msg)
+ {
+ cli::pin_ptr p = PtrToStringChars(msg);
+ return run.setErrorWithMessage (
+ (ASE::Awk::ErrorCode)num, line, p);
+ }
- virtual bool SetErrorString (ERROR num, System::String^ str);
-
- property OPTION Option
- {
- OPTION get ();
- void set (OPTION opt);
- }
+ bool SetGlobal (int id, System::String^ v)
+ {
+ cli::pin_ptr nptr = PtrToStringChars(v);
+ return run.setGlobal (id, nptr, v->Length) == 0;
+ }
- property System::String^ ErrorMessage
- {
- System::String^ get () { return this->errMsg; }
- }
+ bool SetGlobal (int id, long_t v)
+ {
+ return run.setGlobal (id, v) == 0;
+ }
+ bool SetGlobal (int id, System::SByte^ v)
+ {
+ return run.setGlobal (id, (long_t)(__int8)v) == 0;
+ }
+ bool SetGlobal (int id, System::Int16^ v)
+ {
+ return run.setGlobal (id, (long_t)(__int16)v) == 0;
+ }
+ bool SetGlobal (int id, System::Int32^ v)
+ {
+ return run.setGlobal (id, (long_t)(__int32)v) == 0;
+ }
+ bool SetGlobal (int id, System::Int64^ v)
+ {
+ return run.setGlobal (id, (long_t)(__int64)v) == 0;
+ }
+ bool SetGlobal (int id, System::Byte^ v)
+ {
+ return run.setGlobal (id, (long_t)(unsigned __int8)v) == 0;
+ }
+ bool SetGlobal (int id, System::UInt16^ v)
+ {
+ return run.setGlobal (id, (long_t)(unsigned __int16)v) == 0;
+ }
+ bool SetGlobal (int id, System::UInt32^ v)
+ {
+ return run.setGlobal (id, (long_t)(unsigned __int32)v) == 0;
+ }
+ bool SetGlobal (int id, System::UInt64^ v)
+ {
+ return run.setGlobal (id, (long_t)(unsigned __int64)v) == 0;
+ }
- property ERROR ErrorCode
- {
- ERROR get () { return this->errCode; }
- }
+ bool SetGlobal (int id, real_t v)
+ {
+ return run.setGlobal (id, v) == 0;
+ }
+ bool SetGlobal (int id, System::Single^ v)
+ {
+ return run.setGlobal (id, (real_t)(float)v) == 0;
+ }
+ bool SetGlobal (int id, System::Double^ v)
+ {
+ return run.setGlobal (id, (real_t)(double)v) == 0;
+ }
- property unsigned int ErrorLine
- {
- unsigned int get () { return this->errLine; }
- }
+ bool SetGlobal (int id, Return^ v)
+ {
+ return run.setGlobal (id, v->ret) == 0;
+ }
- protected:
- MojoAwk* awk;
- OPTION option;
- System::Collections::Hashtable^ funcs;
+ bool GetGlobal (int id, [System::Runtime::InteropServices::Out] Argument^% v)
+ {
+ return run.getGlobal (id, *v->arg) == 0;
+ }
- public protected:
- // Source
- virtual int OpenSource (Source^ source) = 0;
- virtual int CloseSource (Source^ source) = 0;
- virtual int ReadSource (
- Source^ source, cli::array^ buf, int len) = 0;
- virtual int WriteSource (
- Source^ source, cli::array^ buf, int len) = 0;
-
- // File
- virtual int OpenFile (File^ file) = 0;
- virtual int CloseFile (File^ file) = 0;
- virtual int ReadFile (
- File^ file, cli::array^ buf, int len) = 0;
- virtual int WriteFile (
- File^ file, cli::array^ buf, int len) = 0;
- virtual int FlushFile (File^ file) = 0;
+ public protected:
+ Awk^ owner;
+ ASE::Awk::Run& run;
+ };
- // Pipe
- virtual int OpenPipe (Pipe^ pipe) = 0;
- virtual int ClosePipe (Pipe^ pipe) = 0;
- virtual int ReadPipe (
- Pipe^ pipe, cli::array^ buf, int len) = 0;
- virtual int WritePipe (
- Pipe^ pipe, cli::array^ 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^ buf, int len) = 0;
- virtual int WriteConsole (
- Console^ console, cli::array^ buf, int len) = 0;
- virtual int FlushConsole (Console^ console) = 0;
- virtual int NextConsole (Console^ console) = 0;
-
- public protected:
- bool Awk::DispatchFunction (
- Context^ ctx, ASE::Awk::Return& ret,
- const ASE::Awk::Argument* args, size_t nargs,
- const char_t* name, size_t len);
-
- public protected:
- System::String^ errMsg;
- unsigned int errLine;
- ERROR errCode;
-
- void setError (ERROR num);
- void retrieveError ();
- bool runErrorReported; // only used if the run-callback is activated.
+ ref class Source
+ {
+ public:
+ enum class MODE
+ {
+ READ = ASE::Awk::Source::READ,
+ WRITE = ASE::Awk::Source::WRITE
};
+ Source (MODE^ mode): handle (nullptr)
+ {
+ this->mode = mode;
+ }
+
+ property Object^ Handle
+ {
+ Object^ get () { return this->handle; }
+ void set (Object^ handle) { this->handle = handle; }
+ }
+
+ property MODE^ Mode
+ {
+ MODE^ get () { return this->mode; }
+ };
+
+ private:
+ MODE^ mode;
+ Object^ handle;
+ };
+
+ ref class Extio
+ {
+ public:
+ Extio (System::String^ name): handle (nullptr)
+ {
+ this->name = name;
+ }
+
+ property Object^ Handle
+ {
+ Object^ get () { return this->handle; }
+ void set (Object^ handle) { this->handle = handle; }
+ }
+
+ property System::String^ Name
+ {
+ System::String^ get () { return this->name; }
+ };
+
+ private:
+ Object^ handle;
+ System::String^ name;
+ };
+
+ 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; }
+ };
+
+ Pipe (System::String^ name, MODE^ mode): Extio (name)
+ {
+ 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; }
+ };
+
+ File (System::String^ name, MODE^ mode): Extio (name)
+ {
+ 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; }
+ };
+
+ Console (System::String^ name, MODE^ mode): Extio (name)
+ {
+ this->mode = mode;
+ }
+
+ private:
+ MODE^ mode;
+ };
+
+ Awk ();
+ !Awk ();
+ virtual ~Awk ();
+
+ virtual void Close ();
+ virtual bool Parse ();
+ virtual bool Run ();
+ virtual bool Run (System::String^ entryPoint, cli::array^ args);
+ virtual void Stop ();
+
+ delegate void RunStartHandler (Context^ ctx);
+ delegate void RunEndHandler (Context^ ctx);
+ delegate void RunReturnHandler (Context^ ctx);
+ delegate void RunStatementHandler (Context^ ctx);
+
+ /*event*/ RunStartHandler^ OnRunStart;
+ /*event*/ RunEndHandler^ OnRunEnd;
+ /*event*/ RunReturnHandler^ OnRunReturn;
+ /*event*/ RunStatementHandler^ OnRunStatement;
+
+ virtual bool AddGlobal (
+ System::String^ name,
+ [System::Runtime::InteropServices::Out] int% id);
+ virtual bool DeleteGlobal (System::String^ name);
+
+ delegate bool FunctionHandler (
+ Context^ ctx, System::String^ name,
+ cli::array^ args, Return^ ret);
+
+ virtual bool AddFunction (
+ System::String^ name, int minArgs,
+ int maxArgs, FunctionHandler^ handler);
+ virtual bool DeleteFunction (System::String^ name);
+
+ virtual bool SetWord (System::String^ ow, System::String^ nw);
+ 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);
+
+ virtual bool SetErrorString (ERROR num, System::String^ str);
+
+ property OPTION Option
+ {
+ OPTION get ();
+ void set (OPTION opt);
}
-}
+
+ property System::String^ ErrorMessage
+ {
+ System::String^ get () { return this->errMsg; }
+ }
+
+ property ERROR ErrorCode
+ {
+ ERROR get () { return this->errCode; }
+ }
+
+ property unsigned int ErrorLine
+ {
+ unsigned int get () { return this->errLine; }
+ }
+
+protected:
+
+ MojoAwk* awk;
+ OPTION option;
+ System::Collections::Hashtable^ funcs;
+
+public protected:
+ // Source
+ virtual int OpenSource (Source^ source) = 0;
+ virtual int CloseSource (Source^ source) = 0;
+ virtual int ReadSource (
+ Source^ source, cli::array^ buf, int len) = 0;
+ virtual int WriteSource (
+ Source^ source, cli::array^ buf, int len) = 0;
+
+ // File
+ virtual int OpenFile (File^ file) = 0;
+ virtual int CloseFile (File^ file) = 0;
+ virtual int ReadFile (
+ File^ file, cli::array^ buf, int len) = 0;
+ virtual int WriteFile (
+ File^ file, cli::array^ 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^ buf, int len) = 0;
+ virtual int WritePipe (
+ Pipe^ pipe, cli::array^ 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^ buf, int len) = 0;
+ virtual int WriteConsole (
+ Console^ console, cli::array^ buf, int len) = 0;
+ virtual int FlushConsole (Console^ console) = 0;
+ virtual int NextConsole (Console^ console) = 0;
+
+public protected:
+ bool Awk::DispatchFunction (
+ Context^ ctx, ASE::Awk::Return& ret,
+ const ASE::Awk::Argument* args, size_t nargs,
+ const char_t* name, size_t len);
+
+public protected:
+ System::String^ errMsg;
+ unsigned int errLine;
+ ERROR errCode;
+
+ void SetError (ERROR num);
+ void SetError (ERROR num, size_t line);
+ void SetError (ERROR num, size_t line, System::String^ arg);
+ void SetErrorWithMessage (ERROR num, size_t line, System::String^ msg);
+
+ void RetrieveError ();
+
+ bool runErrorReported; // only used if the run-callback is activated.
+ bool stopRequested;
+};
+
+//////////////////////////////
+ASE_END_NAMESPACE2(Net,ASE)
+//////////////////////////////
diff --git a/ase/net/StdAwk.cpp b/ase/net/StdAwk.cpp
index 47c8be92..aade0ff9 100644
--- a/ase/net/StdAwk.cpp
+++ b/ase/net/StdAwk.cpp
@@ -1,5 +1,5 @@
/*
- * $Id: StdAwk.cpp,v 1.16 2007/10/08 09:43:15 bacon Exp $
+ * $Id: StdAwk.cpp,v 1.17 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@@ -16,98 +16,95 @@
#pragma warning(disable:4996)
-namespace ASE
+ASE_BEGIN_NAMESPACE2(ASE,Net)
+
+StdAwk::StdAwk ()
{
- namespace Net
- {
+ random_seed = (gcnew System::Random)->Next (System::Int32::MinValue, System::Int32::MaxValue);
+ random = gcnew System::Random (random_seed);
- StdAwk::StdAwk ()
- {
- random_seed = (gcnew System::Random)->Next (System::Int32::MinValue, System::Int32::MaxValue);
- random = gcnew System::Random (random_seed);
+ // TODO: exception/error handling....
+ AddFunction ("sin", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sin));
+ AddFunction ("cos", 1, 1, gcnew FunctionHandler (this, &StdAwk::Cos));
+ AddFunction ("tan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Tan));
+ AddFunction ("atan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Atan));
+ AddFunction ("atan2", 2, 2, gcnew FunctionHandler (this, &StdAwk::Atan2));
+ AddFunction ("log", 1, 1, gcnew FunctionHandler (this, &StdAwk::Log));
+ AddFunction ("exp", 1, 1, gcnew FunctionHandler (this, &StdAwk::Exp));
+ AddFunction ("sqrt", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sqrt));
+ AddFunction ("int", 1, 1, gcnew FunctionHandler (this, &StdAwk::Int));
+ AddFunction ("rand", 0, 0, gcnew FunctionHandler (this, &StdAwk::Rand));
+ AddFunction ("srand", 1, 1, gcnew FunctionHandler (this, &StdAwk::Srand));
+ AddFunction ("systime", 0, 0, gcnew FunctionHandler (this, &StdAwk::Systime));
+ AddFunction ("strftime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strftime));
+ AddFunction ("strfgmtime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strfgmtime));
+}
- // TODO: exception/error handling....
- AddFunction ("sin", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sin));
- AddFunction ("cos", 1, 1, gcnew FunctionHandler (this, &StdAwk::Cos));
- AddFunction ("tan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Tan));
- AddFunction ("atan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Atan));
- AddFunction ("atan2", 2, 2, gcnew FunctionHandler (this, &StdAwk::Atan2));
- AddFunction ("log", 1, 1, gcnew FunctionHandler (this, &StdAwk::Log));
- AddFunction ("exp", 1, 1, gcnew FunctionHandler (this, &StdAwk::Exp));
- AddFunction ("sqrt", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sqrt));
- AddFunction ("int", 1, 1, gcnew FunctionHandler (this, &StdAwk::Int));
- AddFunction ("rand", 0, 0, gcnew FunctionHandler (this, &StdAwk::Rand));
- AddFunction ("srand", 1, 1, gcnew FunctionHandler (this, &StdAwk::Srand));
- AddFunction ("systime", 0, 0, gcnew FunctionHandler (this, &StdAwk::Systime));
- AddFunction ("strftime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strftime));
- AddFunction ("strfgmtime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strfgmtime));
- }
+StdAwk::~StdAwk ()
+{
+}
- StdAwk::~StdAwk ()
- {
- }
+bool StdAwk::Sin (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Sin (args[0]->RealValue));
+}
- bool StdAwk::Sin (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Sin (args[0]->RealValue));
- }
+bool StdAwk::Cos (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Cos (args[0]->RealValue));
+}
- bool StdAwk::Cos (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Cos (args[0]->RealValue));
- }
+bool StdAwk::Tan (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Tan (args[0]->RealValue));
+}
- bool StdAwk::Tan (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Tan (args[0]->RealValue));
- }
+bool StdAwk::Atan (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
+}
- bool StdAwk::Atan (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
- }
+bool StdAwk::Atan2 (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
+}
- bool StdAwk::Atan2 (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
- }
+bool StdAwk::Log (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
+}
- bool StdAwk::Log (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
- }
+bool StdAwk::Exp (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
+}
- bool StdAwk::Exp (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
- }
+bool StdAwk::Sqrt (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
+}
- bool StdAwk::Sqrt (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
- }
+bool StdAwk::Int (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set (args[0]->LongValue);
+}
- bool StdAwk::Int (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set (args[0]->LongValue);
- }
+bool StdAwk::Rand (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((long_t)random->Next ());
+}
- bool StdAwk::Rand (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((long_t)random->Next ());
- }
+bool StdAwk::Srand (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ int seed = (int)args[0]->LongValue;
+ System::Random^ tmp = gcnew System::Random (seed);
- bool StdAwk::Srand (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- int seed = (int)args[0]->LongValue;
- System::Random^ tmp = gcnew System::Random (seed);
+ if (!ret->Set((long_t)tmp->Next())) return false;
- if (!ret->Set((long_t)tmp->Next())) return false;
-
- this->random_seed = seed;
- this->random = tmp;
- return true;
- }
+ this->random_seed = seed;
+ this->random = tmp;
+ return true;
+}
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER>=1400)
#define time_t __time64_t
@@ -116,251 +113,251 @@ namespace ASE
#define gmtime _gmtime64
#endif
- bool StdAwk::Systime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- return ret->Set ((long_t)::time(NULL));
- }
+bool StdAwk::Systime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ return ret->Set ((long_t)::time(NULL));
+}
- bool StdAwk::Strftime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- wchar_t buf[128];
- struct tm* tm;
- size_t len;
+bool StdAwk::Strftime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ wchar_t buf[128];
+ struct tm* tm;
+ size_t len;
- if (args->Length < 1)
- {
- const wchar_t* fmt = L"%c";
- time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
+ if (args->Length < 1)
+ {
+ const wchar_t* fmt = L"%c";
+ time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
- tm = ::localtime (&t);
- len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
- }
- else
- {
- cli::pin_ptr fmt = PtrToStringChars(args[0]->StringValue);
+ tm = ::localtime (&t);
+ len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
+ }
+ else
+ {
+ cli::pin_ptr fmt = PtrToStringChars(args[0]->StringValue);
- time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
+ time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
- tm = ::localtime (&t);
- len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
- }
+ tm = ::localtime (&t);
+ len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
+ }
- return ret->Set (gcnew System::String (buf, 0, len));
- }
+ return ret->Set (gcnew System::String (buf, 0, len));
+}
- bool StdAwk::Strfgmtime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
- {
- wchar_t buf[128];
- struct tm* tm;
- size_t len;
+bool StdAwk::Strfgmtime (Context^ ctx, System::String^ name, array^ args, Return^ ret)
+{
+ wchar_t buf[128];
+ struct tm* tm;
+ size_t len;
- if (args->Length < 1)
- {
- const wchar_t* fmt = L"%c";
- time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
+ if (args->Length < 1)
+ {
+ const wchar_t* fmt = L"%c";
+ time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
- tm = ::gmtime (&t);
- len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
- }
- else
- {
- cli::pin_ptr fmt = PtrToStringChars(args[0]->StringValue);
+ tm = ::gmtime (&t);
+ len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
+ }
+ else
+ {
+ cli::pin_ptr fmt = PtrToStringChars(args[0]->StringValue);
- time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
+ time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
- tm = ::gmtime (&t);
- len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
- }
+ tm = ::gmtime (&t);
+ len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
+ }
- return ret->Set (gcnew System::String (buf, 0, len));
- }
+ return ret->Set (gcnew System::String (buf, 0, len));
+}
- int StdAwk::OpenFile (File^ file)
+int StdAwk::OpenFile (File^ file)
+{
+ System::IO::FileMode mode;
+ System::IO::FileAccess access;
+ System::IO::FileStream^ fs;
+
+ if (file->Mode->Equals(File::MODE::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;
+}
+
+int StdAwk::CloseFile (File^ file)
+{
+ if (file->Mode->Equals(File::MODE::READ))
+ {
+ System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
+ sr->Close ();
+ }
+ else
+ {
+ System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
+ sw->Close ();
+ }
+ return 0;
+}
+
+int StdAwk::ReadFile (File^ file, cli::array^ buf, int len)
+{
+ System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
+ return sr->Read (buf, 0, len);
+}
+
+int StdAwk::WriteFile (File^ file, cli::array^ buf, int len)
+{
+ System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
+ sw->Write (buf, 0, len);
+ return len;
+}
+
+int StdAwk::FlushFile (File^ file)
+{
+ System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
+ sw->Flush ();
+ return 0;
+}
+
+
+int StdAwk::OpenPipe (Pipe^ pipe)
+{
+ FILE* fp = NULL;
+
+ cli::pin_ptr 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 = System::IntPtr ((void*)fp);
+ return 1;
+}
+
+int StdAwk::ClosePipe (Pipe^ pipe)
+{
+ System::IntPtr ip = (System::IntPtr)pipe->Handle;
+ FILE* fp = (FILE*)ip.ToPointer();
+ return (::_pclose (fp) == EOF)? -1: 0;
+}
+
+int StdAwk::ReadPipe (Pipe^ pipe, cli::array^ buf, int len)
+{
+ System::IntPtr ip = (System::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^ buf, int len)
+{
+ System::IntPtr ip = (System::IntPtr)pipe->Handle;
+ FILE* fp = (FILE*)ip.ToPointer();
+ int left;
+
+ cli::pin_ptr bp = &buf[0];
+
+ /* somehow, fwprintf returns 0 when non-ascii
+ * characters are included in the buffer.
+ while (left > 0)
+ {
+ if (*bp == ASE_T('\0'))
{
- System::IO::FileMode mode;
- System::IO::FileAccess access;
- System::IO::FileStream^ fs;
-
- if (file->Mode->Equals(File::MODE::READ))
+ if (fputwc (*ptr, fp) == WEOF)
{
- 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;
+ return -1;
}
- else if (file->Mode->Equals(File::MODE::WRITE))
- {
- mode = System::IO::FileMode::Create;
- access = System::IO::FileAccess::Write;
+ left -= 1; bp += 1;
+ }
+ else
+ {
+ int n = fwprintf (fp, L"%.*s", left, bp);
+ if (n < 0 || n > left) return -1;
+ left -= n; bp += n;
+ }
+ }*/
- fs = gcnew System::IO::FileStream (file->Name, mode, access);
- System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
- file->Handle = wr;
+ /* 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)
+ {
+ ::free (mbp);
+ return -1;
}
- else /* File::MODE::APPEND */
+ left -= 1; ptr += 1;
+ }
+ else
+ {
+ int n = fprintf (fp, "%.*s", left, ptr);
+ if (n < 0 || n > left)
{
- 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;
+ ::free (mbp);
+ return -1;
}
-
- return 1;
- }
-
- int StdAwk::CloseFile (File^ file)
- {
- if (file->Mode->Equals(File::MODE::READ))
- {
- System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
- sr->Close ();
- }
- else
- {
- System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
- sw->Close ();
- }
- return 0;
- }
-
- int StdAwk::ReadFile (File^ file, cli::array^ buf, int len)
- {
- System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
- return sr->Read (buf, 0, len);
- }
-
- int StdAwk::WriteFile (File^ file, cli::array^ buf, int len)
- {
- System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
- sw->Write (buf, 0, len);
- return len;
- }
-
- int StdAwk::FlushFile (File^ file)
- {
- System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
- sw->Flush ();
- return 0;
- }
-
-
- int StdAwk::OpenPipe (Pipe^ pipe)
- {
- FILE* fp = NULL;
-
- cli::pin_ptr 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 = System::IntPtr ((void*)fp);
- return 1;
- }
-
- int StdAwk::ClosePipe (Pipe^ pipe)
- {
- System::IntPtr ip = (System::IntPtr)pipe->Handle;
- FILE* fp = (FILE*)ip.ToPointer();
- return (::_pclose (fp) == EOF)? -1: 0;
- }
-
- int StdAwk::ReadPipe (Pipe^ pipe, cli::array^ buf, int len)
- {
- System::IntPtr ip = (System::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^ buf, int len)
- {
- System::IntPtr ip = (System::IntPtr)pipe->Handle;
- FILE* fp = (FILE*)ip.ToPointer();
- int left;
-
- cli::pin_ptr 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)
- {
- ::free (mbp);
- return -1;
- }
- left -= 1; ptr += 1;
- }
- else
- {
- int n = fprintf (fp, "%.*s", left, ptr);
- if (n < 0 || n > left)
- {
- ::free (mbp);
- return -1;
- }
- left -= n; ptr += n;
- }
- }
-
- ::free (mbp);
- return len;
- }
-
- int StdAwk::FlushPipe (Pipe^ pipe)
- {
- System::IntPtr ip = (System::IntPtr)pipe->Handle;
- FILE* fp = (FILE*)ip.ToPointer();
- return (::fflush (fp) == EOF)? -1: 0;
+ left -= n; ptr += n;
}
}
+
+ ::free (mbp);
+ return len;
}
+
+int StdAwk::FlushPipe (Pipe^ pipe)
+{
+ System::IntPtr ip = (System::IntPtr)pipe->Handle;
+ FILE* fp = (FILE*)ip.ToPointer();
+ return (::fflush (fp) == EOF)? -1: 0;
+}
+
+ASE_END_NAMESPACE2(Net,ASE)
diff --git a/ase/net/StdAwk.hpp b/ase/net/StdAwk.hpp
index 630c7551..3ba2913b 100644
--- a/ase/net/StdAwk.hpp
+++ b/ase/net/StdAwk.hpp
@@ -1,57 +1,54 @@
/*
- * $Id: StdAwk.hpp,v 1.8 2007/10/08 09:43:15 bacon Exp $
+ * $Id: StdAwk.hpp,v 1.9 2007/10/10 03:37:49 bacon Exp $
*/
#include
-namespace ASE
+ASE_BEGIN_NAMESPACE2(ASE,Net)
+
+public ref class StdAwk abstract: public Awk
{
- namespace Net
- {
-
- public ref class StdAwk abstract: public Awk
- {
- public:
- StdAwk ();
- ~StdAwk ();
+public:
+ StdAwk ();
+ ~StdAwk ();
- protected:
- int random_seed;
- System::Random^ random;
+protected:
+ int random_seed;
+ System::Random^ random;
- bool Sin (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Cos (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Tan (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Atan (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Atan2 (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Log (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Exp (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Sqrt (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Int (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Rand (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Srand (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Systime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Strftime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- bool Strfgmtime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Sin (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Cos (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Tan (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Atan (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Atan2 (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Log (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Exp (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Sqrt (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Int (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Rand (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Srand (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Systime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Strftime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
+ bool Strfgmtime (Context^ ctx, System::String^ name, array^ args, Return^ ret);
- public protected:
- // File
- virtual int OpenFile (File^ file) override;
- virtual int CloseFile (File^ file) override;
- virtual int ReadFile (
- File^ file, cli::array^ buf, int len) override;
- virtual int WriteFile (
- File^ file, cli::array^ buf, int len) override;
- virtual int FlushFile (File^ file) override;
+public protected:
+ // File
+ virtual int OpenFile (File^ file) override;
+ virtual int CloseFile (File^ file) override;
+ virtual int ReadFile (
+ File^ file, cli::array^ buf, int len) override;
+ virtual int WriteFile (
+ File^ file, cli::array^ 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^ buf, int len) override;
- virtual int WritePipe (
- Pipe^ pipe, cli::array^ buf, int len) override;
- virtual int FlushPipe (Pipe^ pipe) override;
- };
- }
-}
+ // Pipe
+ virtual int OpenPipe (Pipe^ pipe) override;
+ virtual int ClosePipe (Pipe^ pipe) override;
+ virtual int ReadPipe (
+ Pipe^ pipe, cli::array^ buf, int len) override;
+ virtual int WritePipe (
+ Pipe^ pipe, cli::array^ buf, int len) override;
+ virtual int FlushPipe (Pipe^ pipe) override;
+};
+
+ASE_END_NAMESPACE2(Net,ASE)
diff --git a/ase/test/awk/Awk.cpp b/ase/test/awk/Awk.cpp
index 8618622d..94e3f5bc 100644
--- a/ase/test/awk/Awk.cpp
+++ b/ase/test/awk/Awk.cpp
@@ -1,5 +1,5 @@
/*
- * $Id: Awk.cpp,v 1.41 2007/10/07 15:27:39 bacon Exp $
+ * $Id: Awk.cpp,v 1.42 2007/10/10 03:37:49 bacon Exp $
*/
#include
@@ -16,6 +16,11 @@
#include
#endif
+#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
+#define _CRTDBG_MAP_ALLOC
+#include
+#endif
+
class TestAwk: public ASE::StdAwk
{
public:
diff --git a/ase/test/net/AwkForm.cs b/ase/test/net/AwkForm.cs
index a06b8887..259fceb5 100644
Binary files a/ase/test/net/AwkForm.cs and b/ase/test/net/AwkForm.cs differ