Recovered from cvs revision 2007-08-16 15:19:00

This commit is contained in:
hyung-hwan 2007-08-17 00:19:00 +00:00
parent 6270be21c9
commit b09566a637
4 changed files with 94 additions and 49 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.11 2007/08/05 14:52:54 bacon Exp $ * $Id: Awk.cpp,v 1.13 2007/08/15 15:25:06 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -19,11 +19,15 @@ namespace ASE
class StubAwk: public Awk class StubAwk: public Awk
{ {
public: public:
StubAwk (Net::Awk^ wrapper): wrapper(wrapper) StubAwk (Net::Awk^ wrapper): wrapper(wrapper)
{ {
} }
~StubAwk ()
{
wrapper = nullptr;
}
int stubFunctionHandler ( int stubFunctionHandler (
Return* ret, const Argument* args, size_t nargs, Return* ret, const Argument* args, size_t nargs,
const char_t* name, size_t len) const char_t* name, size_t len)
@ -46,7 +50,6 @@ namespace ASE
gh.Free (); gh.Free ();
io.setHandle (NULL); io.setHandle (NULL);
return -1; return -1;
} }
} }
@ -389,7 +392,7 @@ namespace ASE
ase_vfprintf (stderr, fmt, arg); ase_vfprintf (stderr, fmt, arg);
} }
private: protected:
msclr::auto_gcroot<ASE::Net::Awk^> wrapper; msclr::auto_gcroot<ASE::Net::Awk^> wrapper;
}; };
@ -404,19 +407,53 @@ namespace ASE
//throw new AwkException ("cannot open awk"); //throw new AwkException ("cannot open awk");
} }
//option = awk->getOption (); option = (OPTION)(awk->getOption () | awk->OPT_CRLF);
//Option = Option | OPTION::CRLF; awk->setOption ((int)option);
} }
Awk::~Awk () Awk::~Awk ()
{ {
Close (); System::Diagnostics::Debug::Print ("Awk::~Awk");
delete awk; if (awk != NULL)
{
awk->close ();
ASE::Awk* tmp = awk;
awk = NULL;
delete tmp;
}
}
Awk::!Awk ()
{
System::Diagnostics::Debug::Print ("Awk::!Awk");
if (awk != NULL)
{
awk->close ();
ASE::Awk* tmp = awk;
awk = NULL;
delete tmp; // this causes Awk::~Awk to be called because the destrucotr of StubAwk reference to this with auto_gcroot
}
}
Awk::OPTION Awk::Option::get ()
{
if (awk != NULL) this->option = (OPTION)awk->getOption ();
return this->option;
}
void Awk::Option::set (Awk::OPTION opt)
{
this->option = opt;
if (awk != NULL) awk->setOption ((int)this->option);
} }
void Awk::Close () void Awk::Close ()
{ {
awk->close (); System::Diagnostics::Debug::Print ("Awk::Close");
if (awk != NULL)
{
awk->close ();
}
} }
bool Awk::Parse () bool Awk::Parse ()

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp,v 1.9 2007/08/05 14:52:54 bacon Exp $ * $Id: Awk.hpp,v 1.11 2007/08/15 15:25:06 bacon Exp $
*/ */
#pragma once #pragma once
@ -164,6 +164,7 @@ namespace ASE
typedef ASE::Awk::char_t char_t; typedef ASE::Awk::char_t char_t;
Awk (); Awk ();
!Awk ();
virtual ~Awk (); virtual ~Awk ();
//bool Open (); //bool Open ();
@ -177,15 +178,15 @@ namespace ASE
bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler); bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
bool DeleteFunction (System::String^ name); bool DeleteFunction (System::String^ name);
property OPTION^ Option property OPTION Option
{ {
OPTION^ get () { return this->option; } OPTION get (); //{ return this->option; }
void set (OPTION^ opt) { this->option = opt; } void set (OPTION opt); //{ this->option = opt; }
} }
protected: protected:
ASE::Awk* awk; ASE::Awk* awk;
OPTION^ option; OPTION option;
public protected: public protected:
// Source // Source

View File

@ -65,6 +65,7 @@ namespace asetestnet
// tbxSourceInput // tbxSourceInput
// //
this.tbxSourceInput.Dock = System.Windows.Forms.DockStyle.Fill; this.tbxSourceInput.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbxSourceInput.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxSourceInput.Location = new System.Drawing.Point(0, 19); this.tbxSourceInput.Location = new System.Drawing.Point(0, 19);
this.tbxSourceInput.Multiline = true; this.tbxSourceInput.Multiline = true;
this.tbxSourceInput.Name = "tbxSourceInput"; this.tbxSourceInput.Name = "tbxSourceInput";
@ -136,6 +137,7 @@ namespace asetestnet
// tbxSourceOutput // tbxSourceOutput
// //
this.tbxSourceOutput.Dock = System.Windows.Forms.DockStyle.Fill; this.tbxSourceOutput.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbxSourceOutput.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxSourceOutput.Location = new System.Drawing.Point(0, 19); this.tbxSourceOutput.Location = new System.Drawing.Point(0, 19);
this.tbxSourceOutput.Multiline = true; this.tbxSourceOutput.Multiline = true;
this.tbxSourceOutput.Name = "tbxSourceOutput"; this.tbxSourceOutput.Name = "tbxSourceOutput";
@ -169,6 +171,7 @@ namespace asetestnet
// tbxConsoleInput // tbxConsoleInput
// //
this.tbxConsoleInput.Dock = System.Windows.Forms.DockStyle.Fill; this.tbxConsoleInput.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbxConsoleInput.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxConsoleInput.Location = new System.Drawing.Point(0, 19); this.tbxConsoleInput.Location = new System.Drawing.Point(0, 19);
this.tbxConsoleInput.Multiline = true; this.tbxConsoleInput.Multiline = true;
this.tbxConsoleInput.Name = "tbxConsoleInput"; this.tbxConsoleInput.Name = "tbxConsoleInput";
@ -201,6 +204,7 @@ namespace asetestnet
// tbxConsoleOutput // tbxConsoleOutput
// //
this.tbxConsoleOutput.Dock = System.Windows.Forms.DockStyle.Fill; this.tbxConsoleOutput.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbxConsoleOutput.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxConsoleOutput.Location = new System.Drawing.Point(0, 19); this.tbxConsoleOutput.Location = new System.Drawing.Point(0, 19);
this.tbxConsoleOutput.Multiline = true; this.tbxConsoleOutput.Multiline = true;
this.tbxConsoleOutput.Name = "tbxConsoleOutput"; this.tbxConsoleOutput.Name = "tbxConsoleOutput";

View File

@ -18,46 +18,49 @@ namespace asetestnet
private void btnRun_Click(object sender, EventArgs e) private void btnRun_Click(object sender, EventArgs e)
{ {
//using (Awk awk = new Awk())
{
Awk awk = new Awk(); Awk awk = new Awk();
tbxSourceOutput.Text = "";
tbxConsoleOutput.Text = "";
tbxSourceOutput.Text = ""; if (!awk.Parse(tbxSourceInput, tbxSourceOutput))
tbxConsoleOutput.Text = "";
if (!awk.Parse(tbxSourceInput, tbxSourceOutput))
{
//MessageBox.Show(awk.ErrorMessage);
}
else
{
/*
awk.EntryPoint = cbxEntryPoint.Text;
awk.ArgumentsToEntryPoint = chkPassArgumentsToEntryPoint.Checked;*/
bool n;
/*int nargs = lbxArguments.Items.Count;
if (nargs > 0)
{
string[] args = new string[nargs];
for (int i = 0; i < nargs; i++)
args[i] = lbxArguments.Items[i].ToString();
n = awk.Run(args);
}
else*/ n = awk.Run(tbxConsoleInput, tbxConsoleOutput);
if (!n)
{ {
MessageBox.Show("Parse error");
//MessageBox.Show(awk.ErrorMessage); //MessageBox.Show(awk.ErrorMessage);
} }
else
{
/*
awk.EntryPoint = cbxEntryPoint.Text;
awk.ArgumentsToEntryPoint = chkPassArgumentsToEntryPoint.Checked;*/
bool n;
/*int nargs = lbxArguments.Items.Count;
if (nargs > 0)
{
string[] args = new string[nargs];
for (int i = 0; i < nargs; i++)
args[i] = lbxArguments.Items[i].ToString();
n = awk.Run(args);
}
else*/
n = awk.Run(tbxConsoleInput, tbxConsoleOutput);
if (!n)
{
//MessageBox.Show(awk.ErrorMessage);
MessageBox.Show("Run Error");
}
}
awk.Close();
} }
//awk.Dispose();
//awk.Close();
} }
private void btnAddArgument_Click(object sender, EventArgs e) private void btnAddArgument_Click(object sender, EventArgs e)
{ {
if (tbxArgument.Text.Length > 0) if (tbxArgument.Text.Length > 0)