Recovered from cvs revision 2007-08-26 14:33:00

This commit is contained in:
hyung-hwan 2007-08-26 23:33:00 +00:00
parent 24b4d82eea
commit 6bd702fccf
21 changed files with 246 additions and 109 deletions

View File

@ -18,11 +18,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jn
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} {17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk", "test\awk\asetestawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "test\awk\aseawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
@ -33,7 +34,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3} {17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestlsp", "test\lsp\asetestlsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "test\lsp\aselsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2} {42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
@ -44,7 +45,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vc
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk++", "test\awk\asetestawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "test\awk\aseawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
@ -55,7 +56,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asetestnet", "test\net\asetestnet.csproj", "{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asenet", "test\net\asenet.csproj", "{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8A2F5860-6563-4617-BCE0-460F915007F8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -191,4 +194,10 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{868702B0-CB6B-4F1D-B98A-32193347EFAF} = {8A2F5860-6563-4617-BCE0-460F915007F8}
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98} = {8A2F5860-6563-4617-BCE0-460F915007F8}
{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B} = {8A2F5860-6563-4617-BCE0-460F915007F8}
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {8A2F5860-6563-4617-BCE0-460F915007F8}
EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.49 2007/08/21 14:24:37 bacon Exp $ * $Id: Awk.cpp,v 1.51 2007/08/24 15:11:36 bacon Exp $
*/ */
@ -441,6 +441,22 @@ namespace ASE
} }
} }
void Awk::setError (
ErrorCode code, size_t line, const char_t* msg)
{
if (awk != ASE_NULL)
{
ase_awk_seterrmsg (awk, code, line, msg);
retrieveError ();
}
else
{
this->errnum = code;
this->errlin = line;
ase_strxcpy (this->errmsg, ASE_COUNTOF(this->errmsg), msg);
}
}
void Awk::clearError () void Awk::clearError ()
{ {
this->errnum = ERR_NOERR; this->errnum = ERR_NOERR;
@ -569,12 +585,18 @@ namespace ASE
ase_awk_setmaxdepth (awk, ids, depth); ase_awk_setmaxdepth (awk, ids, depth);
} }
size_t Awk::getMaxDepth (int id) const Awk::size_t Awk::getMaxDepth (int id) const
{ {
ASE_ASSERT (awk != ASE_NULL); ASE_ASSERT (awk != ASE_NULL);
return ase_awk_getmaxdepth (awk, id); return ase_awk_getmaxdepth (awk, id);
} }
const Awk::char_t* Awk::getErrorString (ErrorCode num) const
{
ASE_ASSERT (awk != ASE_NULL);
return ase_awk_geterrstr (awk, (int)num);
}
int Awk::setErrorString (ErrorCode num, const char_t* str) int Awk::setErrorString (ErrorCode num, const char_t* str)
{ {
ASE_ASSERT (awk != ASE_NULL); ASE_ASSERT (awk != ASE_NULL);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp,v 1.47 2007/08/21 14:24:37 bacon Exp $ * $Id: Awk.hpp,v 1.48 2007/08/24 13:17:59 bacon Exp $
*/ */
#ifndef _ASE_AWK_AWK_HPP_ #ifndef _ASE_AWK_AWK_HPP_
@ -389,6 +389,8 @@ namespace ASE
protected: protected:
void setError (ErrorCode code, size_t line = 0, void setError (ErrorCode code, size_t line = 0,
const char_t* arg = ASE_NULL, size_t len = 0); const char_t* arg = ASE_NULL, size_t len = 0);
void setError (ErrorCode code, size_t line, const char_t* msg);
void clearError (); void clearError ();
void retrieveError (); void retrieveError ();
@ -412,6 +414,7 @@ namespace ASE
virtual void setMaxDepth (int ids, size_t depth); virtual void setMaxDepth (int ids, size_t depth);
virtual size_t getMaxDepth (int id) const; virtual size_t getMaxDepth (int id) const;
virtual const char_t* getErrorString (ErrorCode num) const;
virtual int setErrorString (ErrorCode num, const char_t* str); virtual int setErrorString (ErrorCode num, const char_t* str);
virtual int setWord ( virtual int setWord (

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.8 2007/06/29 11:36:45 bacon Exp $ * $Id: awk.h,v 1.9 2007/08/24 13:17:59 bacon Exp $
* *
* {License} * {License}
*/ */
@ -202,12 +202,12 @@ enum ase_awk_errnum_t
ASE_AWK_ENOMEM, /* out of memory */ ASE_AWK_ENOMEM, /* out of memory */
ASE_AWK_ENOSUP, /* not supported */ ASE_AWK_ENOSUP, /* not supported */
ASE_AWK_ENOPER, /* operation not allowed */ ASE_AWK_ENOPER, /* operation not allowed */
ASE_AWK_ENODEV, /* function '%.*s' not found */ ASE_AWK_ENODEV, /* no such device */
ASE_AWK_ENOSPC, /* no space left on device */ ASE_AWK_ENOSPC, /* no space left on device */
ASE_AWK_EMFILE, /* too many open files */ ASE_AWK_EMFILE, /* too many open files */
ASE_AWK_EMLINK, /* too many links */ ASE_AWK_EMLINK, /* too many links */
ASE_AWK_EAGAIN, /* resource temporarily unavailable */ ASE_AWK_EAGAIN, /* resource temporarily unavailable */
ASE_AWK_ENOENT, /* file or data not existing */ ASE_AWK_ENOENT, /* "'%.*s' not existing */
ASE_AWK_EEXIST, /* file or data exists */ ASE_AWK_EEXIST, /* file or data exists */
ASE_AWK_EFTBIG, /* file or data too big */ ASE_AWK_EFTBIG, /* file or data too big */
ASE_AWK_ETBUSY, /* system too busy */ ASE_AWK_ETBUSY, /* system too busy */
@ -399,7 +399,10 @@ int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str);
int ase_awk_geterrnum (ase_awk_t* awk); int ase_awk_geterrnum (ase_awk_t* awk);
ase_size_t ase_awk_geterrlin (ase_awk_t* awk); ase_size_t ase_awk_geterrlin (ase_awk_t* awk);
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk); const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk);
void ase_awk_seterrnum (ase_awk_t* awk, int errnum); void ase_awk_seterrnum (ase_awk_t* awk, int errnum);
void ase_awk_seterrmsg (ase_awk_t* awk,
int errnum, ase_size_t errlin, const ase_char_t* errmsg);
void ase_awk_geterror ( void ase_awk_geterror (
ase_awk_t* awk, int* errnum, ase_awk_t* awk, int* errnum,
@ -463,6 +466,8 @@ int ase_awk_getrunerrnum (ase_awk_run_t* run);
ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run); ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run);
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run); const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run);
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum); void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum);
void ase_awk_setrunerrmsg (ase_awk_run_t* run,
int errnum, ase_size_t errlin, const ase_char_t* errmsg);
void ase_awk_getrunerror ( void ase_awk_getrunerror (
ase_awk_run_t* run, int* errnum, ase_awk_run_t* run, int* errnum,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.5 2007/06/29 11:36:45 bacon Exp $ * $Id: err.c,v 1.6 2007/08/24 13:17:59 bacon Exp $
* *
* {License} * {License}
*/ */
@ -219,6 +219,14 @@ void ase_awk_seterrnum (ase_awk_t* awk, int errnum)
awk->errmsg[0] = ASE_T('\0'); awk->errmsg[0] = ASE_T('\0');
} }
void ase_awk_seterrmsg (ase_awk_t* awk,
int errnum, ase_size_t errlin, const ase_char_t* errmsg)
{
awk->errnum = errnum;
awk->errlin = errlin;
ase_strxcpy (awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg);
}
void ase_awk_seterror ( void ase_awk_seterror (
ase_awk_t* awk, int errnum, ase_size_t errlin, ase_awk_t* awk, int errnum, ase_size_t errlin,
const ase_cstr_t* errarg, ase_size_t argcnt) const ase_cstr_t* errarg, ase_size_t argcnt)
@ -346,6 +354,14 @@ void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum)
run->errmsg[0] = ASE_T('\0'); run->errmsg[0] = ASE_T('\0');
} }
void ase_awk_setrunerrmsg (ase_awk_run_t* run,
int errnum, ase_size_t errlin, const ase_char_t* errmsg)
{
run->errnum = errnum;
run->errlin = errlin;
ase_strxcpy (run->errmsg, ASE_COUNTOF(run->errmsg), errmsg);
}
void ase_awk_getrunerror ( void ase_awk_getrunerror (
ase_awk_run_t* run, int* errnum, ase_awk_run_t* run, int* errnum,
ase_size_t* errlin, const ase_char_t** errmsg) ase_size_t* errlin, const ase_char_t** errmsg)

View File

@ -2,6 +2,7 @@
* added ase_awk_setword to enable customization of keywords and * added ase_awk_setword to enable customization of keywords and
intrinsic function names. intrinsic function names.
* added ase_awk_seterrmsg to set the error message to be any string given
* added setWord/unsetWord method to the awk c++ class (awk/Awk.cpp) * added setWord/unsetWord method to the awk c++ class (awk/Awk.cpp)
* added setErrorString method to the awk c++ class (awk/Awk.cpp) * added setErrorString method to the awk c++ class (awk/Awk.cpp)
* added setWord/unsetWord method to the awk java class (awk/Awk.java) * added setWord/unsetWord method to the awk java class (awk/Awk.java)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.21 2007/08/22 13:56:21 bacon Exp $ * $Id: Awk.cpp,v 1.22 2007/08/24 13:17:59 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -60,6 +60,22 @@ namespace ASE
this->wrapper = nullptr; 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 const char_t* getErrorMessage (ASE::Net::Awk^ wrapper) const
{ {
this->wrapper = wrapper; this->wrapper = wrapper;
@ -68,11 +84,12 @@ namespace ASE
return x; return x;
} }
void setError (ASE::Net::Awk^ wrapper) const char_t* getErrorString (ASE::Net::Awk^ wrapper, ErrorCode num) const
{ {
this->wrapper = wrapper; this->wrapper = wrapper;
//Awk::setError (code); const char_t* x = Awk::getErrorString(num);
this->wrapper = nullptr; this->wrapper = nullptr;
return x;
} }
int parse (ASE::Net::Awk^ wrapper) int parse (ASE::Net::Awk^ wrapper)
@ -147,6 +164,8 @@ namespace ASE
void onRunStart (const Run& run) void onRunStart (const Run& run)
{ {
wrapper->runErrorReported = false;
if (wrapper->OnRunStart != nullptr) if (wrapper->OnRunStart != nullptr)
{ {
wrapper->OnRunStart (wrapper); wrapper->OnRunStart (wrapper);
@ -154,15 +173,13 @@ namespace ASE
} }
void onRunEnd (const Run& run) void onRunEnd (const Run& run)
{ {
if (run.getErrorCode() != ERR_NOERR) ErrorCode code = run.getErrorCode();
if (code != ERR_NOERR)
{ {
// TODO: SET THE ERROR CODE TO THIS AWK OBJECT... wrapper->runErrorReported = true;
// TODO: set the error properly when an error is returned through this callback. wrapper->errMsg = gcnew System::String (run.getErrorMessage());
// this callback should always be available.... wrapper->errLine = run.getErrorLine();
ASE::Awk::setError (run.getErrorCode(), run.getErrorLine()); wrapper->errCode = (ASE::Net::Awk::ERROR)code;
// TODO: also make Run to return false in this case. Unlike normal c++ awk, this version of awk doesn't support multiple run instances.
// wrapper->runFailureReported = true;
} }
if (wrapper->OnRunEnd != nullptr) if (wrapper->OnRunEnd != nullptr)
@ -581,21 +598,21 @@ namespace ASE
awk = new ASE::MojoAwk (); awk = new ASE::MojoAwk ();
if (awk->open (this) == -1) if (awk->open (this) == -1)
{ {
// TODO:... throw gcnew System::Exception (gcnew System::String(awk->getErrorMessage(this)));
//throw new AwkException ("cannot open awk");
} }
//option = (OPTION)(awk->getOption (this) | MojoAwk::OPT_CRLF); //option = (OPTION)(awk->getOption (this) | MojoAwk::OPT_CRLF);
option = (OPTION)(awk->getOption (this) | ASE::Awk::OPT_CRLF); option = (OPTION)(awk->getOption (this) | ASE::Awk::OPT_CRLF);
awk->setOption (this, (int)option); awk->setOption (this, (int)option);
errorMsg = ""; errMsg = "";
errLine = 0;
errCode = ASE::Net::Awk::ERROR::NOERR;
runErrorReported = false;
} }
Awk::~Awk () Awk::~Awk ()
{ {
System::Diagnostics::Debug::Print ("Awk::~Awk");
if (awk != NULL) if (awk != NULL)
{ {
awk->close (this); awk->close (this);
@ -613,7 +630,6 @@ System::Diagnostics::Debug::Print ("Awk::~Awk");
Awk::!Awk () Awk::!Awk ()
{ {
System::Diagnostics::Debug::Print ("Awk::!Awk");
if (awk != NULL) if (awk != NULL)
{ {
awk->close (this); awk->close (this);
@ -622,13 +638,6 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
} }
} }
System::String^ Awk::ErrorMessage::get ()
{
if (awk != NULL)
this->errorMsg = gcnew System::String(awk->getErrorMessage (this));
return this->errorMsg;
}
Awk::OPTION Awk::Option::get () Awk::OPTION Awk::Option::get ()
{ {
if (awk != NULL) this->option = (OPTION)awk->getOption (this); if (awk != NULL) this->option = (OPTION)awk->getOption (this);
@ -660,8 +669,14 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
bool Awk::Parse () bool Awk::Parse ()
{ {
if (awk == NULL) return false; if (awk == NULL)
return awk->parse (this) == 0; {
setError (ERROR::NOPER);
return false;
}
bool r = (awk->parse (this) == 0);
if (!r) { retrieveError (); }
return r;
} }
bool Awk::Run () bool Awk::Run ()
@ -671,7 +686,13 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
bool Awk::Run (System::String^ entryPoint, cli::array<System::String^>^ args) bool Awk::Run (System::String^ entryPoint, cli::array<System::String^>^ args)
{ {
if (awk == NULL) return false; runErrorReported = false;
if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
if (OnRunStart != nullptr || OnRunEnd != nullptr || if (OnRunStart != nullptr || OnRunEnd != nullptr ||
OnRunReturn != nullptr || OnRunStatement != nullptr) OnRunReturn != nullptr || OnRunStatement != nullptr)
@ -683,12 +704,18 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
{ {
if (entryPoint == nullptr || entryPoint->Length <= 0) if (entryPoint == nullptr || entryPoint->Length <= 0)
{ {
return awk->run (this) == 0; bool r = (awk->run (this) == 0);
if (runErrorReported) r = false;
else if (!r) retrieveError ();
return r;
} }
else else
{ {
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(entryPoint); cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(entryPoint);
return awk->run (this, nptr) == 0; bool r = (awk->run (this, nptr) == 0);
if (runErrorReported) r = false;
else if (!r) retrieveError ();
return r;
} }
} }
else else
@ -703,7 +730,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
ptr = (ASE::Awk::char_t**)awk->allocMem (nargs * ASE_SIZEOF(ASE::Awk::char_t*)); ptr = (ASE::Awk::char_t**)awk->allocMem (nargs * ASE_SIZEOF(ASE::Awk::char_t*));
if (ptr == ASE_NULL) if (ptr == ASE_NULL)
{ {
// TODO: error handling setError (ERROR::NOMEM);
return false; return false;
} }
for (int i = 0; i < nargs; i++) ptr[i] = ASE_NULL; for (int i = 0; i < nargs; i++) ptr[i] = ASE_NULL;
@ -714,6 +741,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
if (ptr[i] == ASE_NULL) if (ptr[i] == ASE_NULL)
{ {
r = false; r = false;
setError (ERROR::NOMEM);
goto exit_run; goto exit_run;
} }
memcpy (ptr[i], nptr, args[i]->Length*ASE_SIZEOF(ASE::Awk::char_t)); memcpy (ptr[i], nptr, args[i]->Length*ASE_SIZEOF(ASE::Awk::char_t));
@ -741,10 +769,14 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
ptr[i] = ASE_NULL; ptr[i] = ASE_NULL;
} }
} }
awk->freeMem (ptr);
awk->freeMem (ptr);
ptr = ASE_NULL; ptr = ASE_NULL;
} }
if (runErrorReported) r = false;
else if (!r) retrieveError ();
return r; return r;
} }
catch (...) catch (...)
@ -763,7 +795,7 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
ptr = ASE_NULL; ptr = ASE_NULL;
} }
// TODO: error... setError (ERROR::NOMEM);
return false; return false;
} }
} }
@ -773,20 +805,30 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
System::String^ name, int minArgs, int maxArgs, System::String^ name, int minArgs, int maxArgs,
FunctionHandler^ handler) FunctionHandler^ handler)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name); cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
int n = awk->addFunction (this, nptr, minArgs, maxArgs, int n = awk->addFunction (this, nptr, minArgs, maxArgs,
(ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler); (ASE::Awk::FunctionHandler)&MojoAwk::mojoFunctionHandler);
if (n == 0) funcs->Add(name, handler); if (n == 0) funcs->Add(name, handler);
else retrieveError ();
return n == 0; return n == 0;
} }
bool Awk::DeleteFunction (System::String^ name) bool Awk::DeleteFunction (System::String^ name)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name); cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(name);
int n = awk->deleteFunction (this, nptr); int n = awk->deleteFunction (this, nptr);
if (n == 0) funcs->Remove (name); if (n == 0) funcs->Remove (name);
else retrieveError ();
return n == 0; return n == 0;
} }
@ -797,7 +839,11 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
System::String^ nm = gcnew System::String (name, 0, len); System::String^ nm = gcnew System::String (name, 0, len);
FunctionHandler^ fh = (FunctionHandler^)funcs[nm]; FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
if (fh == nullptr) return false; if (fh == nullptr)
{
setError (ERROR::INVAL);
return false;
}
cli::array<Argument^>^ arg_arr = gcnew cli::array<Argument^> (nargs); cli::array<Argument^>^ arg_arr = gcnew cli::array<Argument^> (nargs);
for (size_t i = 0; i < nargs; i++) arg_arr[i] = gcnew Argument(args[i]); for (size_t i = 0; i < nargs; i++) arg_arr[i] = gcnew Argument(args[i]);
@ -808,7 +854,11 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
bool Awk::SetWord (System::String^ ow, System::String^ nw) bool Awk::SetWord (System::String^ ow, System::String^ nw)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow); cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow);
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(nw); cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(nw);
return (awk->setWord (this, optr, ow->Length, nptr, nw->Length) == 0); return (awk->setWord (this, optr, ow->Length, nptr, nw->Length) == 0);
@ -816,35 +866,68 @@ System::Diagnostics::Debug::Print ("Awk::!Awk");
bool Awk::UnsetWord (System::String^ ow) bool Awk::UnsetWord (System::String^ ow)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow); cli::pin_ptr<const ASE::Awk::char_t> optr = PtrToStringChars(ow);
return (awk->unsetWord (this, optr, ow->Length) == 0); return (awk->unsetWord (this, optr, ow->Length) == 0);
} }
bool Awk::UnsetAllWords () bool Awk::UnsetAllWords ()
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
return (awk->unsetAllWords (this) == 0); return (awk->unsetAllWords (this) == 0);
} }
bool Awk::SetMaxDepth (DEPTH id, size_t depth) bool Awk::SetMaxDepth (DEPTH id, size_t depth)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
awk->setMaxDepth (this, (int)id, depth); awk->setMaxDepth (this, (int)id, depth);
return true; return true;
} }
bool Awk::GetMaxDepth (DEPTH id, size_t* depth) bool Awk::GetMaxDepth (DEPTH id, size_t* depth)
{ {
if (awk == NULL) return false; if (awk == NULL)
{
setError (ERROR::NOPER);
return false;
}
*depth = awk->getMaxDepth (this, (int)id); *depth = awk->getMaxDepth (this, (int)id);
return true; return true;
} }
void Awk::SetError () void Awk::setError (ERROR num)
{ {
if (awk == NULL) return; errMsg = "";
awk->setError (this); errLine = 0;
errCode = num;
if (awk != NULL)
{
errMsg = gcnew System::String (
awk->getErrorString (this, (ASE::Awk::ErrorCode)num));
}
}
void Awk::retrieveError ()
{
if (awk != NULL)
{
errMsg = gcnew System::String (awk->getErrorMessage(this));
errLine = awk->getErrorLine (this);
errCode = (ERROR)awk->getErrorCode (this);
}
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp,v 1.18 2007/08/22 13:56:21 bacon Exp $ * $Id: Awk.hpp,v 1.19 2007/08/24 13:17:59 bacon Exp $
*/ */
#pragma once #pragma once
@ -297,7 +297,6 @@ namespace ASE
MODE^ mode; MODE^ mode;
}; };
[System::Flags] enum class OPTION: int [System::Flags] enum class OPTION: int
{ {
NONE = 0, NONE = 0,
@ -460,7 +459,6 @@ namespace ASE
}; };
// end of enum class ERROR // end of enum class ERROR
typedef ASE::Awk::char_t char_t; typedef ASE::Awk::char_t char_t;
Awk (); Awk ();
@ -499,19 +497,25 @@ namespace ASE
void set (OPTION opt); //{ this->option = opt; } void set (OPTION opt); //{ this->option = opt; }
} }
// TODO: Error code, Error line
property System::String^ ErrorMessage property System::String^ ErrorMessage
{ {
System::String^ get (); System::String^ get () { return this->errMsg; }
} }
void SetError (); property ERROR ErrorCode
{
ERROR get () { return this->errCode; }
}
property unsigned int ErrorLine
{
unsigned int get () { return this->errLine; }
}
protected: protected:
MojoAwk* awk; MojoAwk* awk;
OPTION option; OPTION option;
System::Collections::Hashtable^ funcs; System::Collections::Hashtable^ funcs;
System::String^ errorMsg;
public protected: public protected:
// Source // Source
@ -554,6 +558,15 @@ namespace ASE
bool Awk::DispatchFunction (ASE::Awk::Return* ret, bool Awk::DispatchFunction (ASE::Awk::Return* ret,
const ASE::Awk::Argument* args, size_t nargs, const ASE::Awk::Argument* args, size_t nargs,
const char_t* name, size_t len); 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.
}; };
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.cpp,v 1.6 2007/08/21 14:24:37 bacon Exp $ * $Id: StdAwk.cpp,v 1.7 2007/08/24 16:02:49 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -7,6 +7,7 @@
#include <ase/net/StdAwk.hpp> #include <ase/net/StdAwk.hpp>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <tchar.h> #include <tchar.h>
#include <vcclr.h> #include <vcclr.h>

View File

@ -1,17 +1,17 @@
/* /*
* $Id: misc.cpp,v 1.2 2007/08/21 14:24:37 bacon Exp $ * $Id: misc.cpp,v 1.3 2007/08/24 16:02:49 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "misc.h" #include "misc.h"
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#ifndef NDEBUG #ifndef NDEBUG
#include <ase/cmn/types.h> #include <ase/cmn/types.h>
#include <ase/cmn/macros.h> #include <ase/cmn/macros.h>
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#pragma warning(disable:4996) #pragma warning(disable:4996)
#pragma unmanaged #pragma unmanaged

View File

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="asetestawk++" Name="aseawk++"
ProjectGUID="{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}" ProjectGUID="{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
RootNamespace="asetestawk++" RootNamespace="aseawk++"
> >
<Platforms> <Platforms>
<Platform <Platform
@ -38,7 +38,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../release/bin/asetestawk++.tlb" TypeLibraryName=".\../../release/bin/aseawk++.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -50,7 +50,7 @@
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release\cpp\asetestawk++.pch" PrecompiledHeaderFile=".\release\cpp\aseawk++.pch"
AssemblerListingLocation="" AssemblerListingLocation=""
WarningLevel="3" WarningLevel="3"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -88,7 +88,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../release/bin/asetestawk++.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
@ -127,7 +126,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../debug/bin/asetestawk++.tlb" TypeLibraryName=".\../../debug/bin/aseawk++.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -138,7 +137,7 @@
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
PrecompiledHeaderFile=".\debug\cpp\asetestawk++.pch" PrecompiledHeaderFile=".\debug\cpp\aseawk++.pch"
AssemblerListingLocation="" AssemblerListingLocation=""
BrowseInformation="1" BrowseInformation="1"
WarningLevel="3" WarningLevel="3"
@ -179,7 +178,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../debug/bin/asetestawk++.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"

View File

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="asetestawk" Name="aseawk"
ProjectGUID="{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}" ProjectGUID="{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
RootNamespace="asetestawk" RootNamespace="aseawk"
> >
<Platforms> <Platforms>
<Platform <Platform
@ -38,7 +38,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../release/bin/asetestawk.tlb" TypeLibraryName=".\../../release/bin/aseawk.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -86,7 +86,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../release/bin/asetestawk.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
@ -125,7 +124,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../debug/bin/asetestawk.tlb" TypeLibraryName=".\../../debug/bin/aseawk.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -175,7 +174,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../debug/bin/asetestawk.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"

View File

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="asetestlsp" Name="aselsp"
ProjectGUID="{868702B0-CB6B-4F1D-B98A-32193347EFAF}" ProjectGUID="{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
RootNamespace="asetestlsp" RootNamespace="aselsp"
> >
<Platforms> <Platforms>
<Platform <Platform
@ -38,7 +38,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../debug/bin/asetestlsp.tlb" TypeLibraryName=".\../../debug/bin/aselsp.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -89,7 +89,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../debug/bin/asetestlsp.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
@ -128,7 +127,7 @@
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
TypeLibraryName=".\../../release/bin/asetestlsp.tlb" TypeLibraryName=".\../../release/bin/aselsp.tlb"
HeaderFileName="" HeaderFileName=""
/> />
<Tool <Tool
@ -177,7 +176,6 @@
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
SuppressStartupBanner="true" SuppressStartupBanner="true"
OutputFile=".\../../release/bin/asetestlsp.bsc"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"

View File

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace asetestnet namespace ase.net
{ {
public class Awk : ASE.Net.StdAwk public class Awk : ASE.Net.StdAwk
{ {

View File

@ -1,4 +1,4 @@
namespace asetestnet namespace ase.net
{ {
partial class AwkForm partial class AwkForm
{ {

Binary file not shown.

View File

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
namespace asetestnet namespace ase.net
{ {
static class Program static class Program
{ {

View File

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("asetestnet")] [assembly: AssemblyTitle("asenet")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("asetestnet")] [assembly: AssemblyProduct("asenet")]
[assembly: AssemblyCopyright("Copyright © 2007")] [assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace asetestnet.Properties { namespace ase.net.Properties {
using System; using System;
@ -39,7 +39,7 @@ namespace asetestnet.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("asetestnet.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ase.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace asetestnet.Properties { namespace ase.net.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]

View File

@ -7,8 +7,8 @@
<ProjectGuid>{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B}</ProjectGuid> <ProjectGuid>{7CC01C3D-FC1A-4587-868A-7FC4449B3F8B}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>asetestnet</RootNamespace> <RootNamespace>ase.net</RootNamespace>
<AssemblyName>asetestnet</AssemblyName> <AssemblyName>ase.net</AssemblyName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -43,22 +43,12 @@
<Compile Include="AwkForm.designer.cs"> <Compile Include="AwkForm.designer.cs">
<DependentUpon>AwkForm.cs</DependentUpon> <DependentUpon>AwkForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="AwkFormOrg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AwkFormOrg.Designer.cs">
<DependentUpon>AwkFormOrg.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="AwkForm.resx"> <EmbeddedResource Include="AwkForm.resx">
<DependentUpon>AwkForm.cs</DependentUpon> <DependentUpon>AwkForm.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="AwkFormOrg.resx">
<SubType>Designer</SubType>
<DependentUpon>AwkFormOrg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>