Recovered from cvs revision 2007-08-16 15:19:00
This commit is contained in:
parent
6270be21c9
commit
b09566a637
@ -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"
|
||||
@ -19,11 +19,15 @@ namespace ASE
|
||||
class StubAwk: public Awk
|
||||
{
|
||||
public:
|
||||
|
||||
StubAwk (Net::Awk^ wrapper): wrapper(wrapper)
|
||||
{
|
||||
}
|
||||
|
||||
~StubAwk ()
|
||||
{
|
||||
wrapper = nullptr;
|
||||
}
|
||||
|
||||
int stubFunctionHandler (
|
||||
Return* ret, const Argument* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
@ -46,7 +50,6 @@ namespace ASE
|
||||
gh.Free ();
|
||||
io.setHandle (NULL);
|
||||
return -1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +392,7 @@ namespace ASE
|
||||
ase_vfprintf (stderr, fmt, arg);
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
msclr::auto_gcroot<ASE::Net::Awk^> wrapper;
|
||||
};
|
||||
|
||||
@ -404,20 +407,54 @@ namespace ASE
|
||||
//throw new AwkException ("cannot open awk");
|
||||
}
|
||||
|
||||
//option = awk->getOption ();
|
||||
//Option = Option | OPTION::CRLF;
|
||||
option = (OPTION)(awk->getOption () | awk->OPT_CRLF);
|
||||
awk->setOption ((int)option);
|
||||
}
|
||||
|
||||
Awk::~Awk ()
|
||||
{
|
||||
Close ();
|
||||
delete awk;
|
||||
System::Diagnostics::Debug::Print ("Awk::~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 ()
|
||||
{
|
||||
System::Diagnostics::Debug::Print ("Awk::Close");
|
||||
if (awk != NULL)
|
||||
{
|
||||
awk->close ();
|
||||
}
|
||||
}
|
||||
|
||||
bool Awk::Parse ()
|
||||
{
|
||||
|
@ -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
|
||||
@ -164,6 +164,7 @@ namespace ASE
|
||||
typedef ASE::Awk::char_t char_t;
|
||||
|
||||
Awk ();
|
||||
!Awk ();
|
||||
virtual ~Awk ();
|
||||
|
||||
//bool Open ();
|
||||
@ -177,15 +178,15 @@ namespace ASE
|
||||
bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
|
||||
bool DeleteFunction (System::String^ name);
|
||||
|
||||
property OPTION^ Option
|
||||
property OPTION Option
|
||||
{
|
||||
OPTION^ get () { return this->option; }
|
||||
void set (OPTION^ opt) { this->option = opt; }
|
||||
OPTION get (); //{ return this->option; }
|
||||
void set (OPTION opt); //{ this->option = opt; }
|
||||
}
|
||||
|
||||
protected:
|
||||
ASE::Awk* awk;
|
||||
OPTION^ option;
|
||||
OPTION option;
|
||||
|
||||
public protected:
|
||||
// Source
|
||||
|
4
ase/test/net/AwkForm.Designer.cs
generated
4
ase/test/net/AwkForm.Designer.cs
generated
@ -65,6 +65,7 @@ namespace asetestnet
|
||||
// tbxSourceInput
|
||||
//
|
||||
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.Multiline = true;
|
||||
this.tbxSourceInput.Name = "tbxSourceInput";
|
||||
@ -136,6 +137,7 @@ namespace asetestnet
|
||||
// tbxSourceOutput
|
||||
//
|
||||
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.Multiline = true;
|
||||
this.tbxSourceOutput.Name = "tbxSourceOutput";
|
||||
@ -169,6 +171,7 @@ namespace asetestnet
|
||||
// tbxConsoleInput
|
||||
//
|
||||
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.Multiline = true;
|
||||
this.tbxConsoleInput.Name = "tbxConsoleInput";
|
||||
@ -201,6 +204,7 @@ namespace asetestnet
|
||||
// tbxConsoleOutput
|
||||
//
|
||||
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.Multiline = true;
|
||||
this.tbxConsoleOutput.Name = "tbxConsoleOutput";
|
||||
|
@ -18,14 +18,15 @@ namespace asetestnet
|
||||
|
||||
private void btnRun_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//using (Awk awk = new Awk())
|
||||
{
|
||||
Awk awk = new Awk();
|
||||
|
||||
tbxSourceOutput.Text = "";
|
||||
tbxConsoleOutput.Text = "";
|
||||
|
||||
if (!awk.Parse(tbxSourceInput, tbxSourceOutput))
|
||||
{
|
||||
MessageBox.Show("Parse error");
|
||||
//MessageBox.Show(awk.ErrorMessage);
|
||||
}
|
||||
else
|
||||
@ -44,19 +45,21 @@ namespace asetestnet
|
||||
args[i] = lbxArguments.Items[i].ToString();
|
||||
n = awk.Run(args);
|
||||
}
|
||||
else*/ n = awk.Run(tbxConsoleInput, tbxConsoleOutput);
|
||||
else*/
|
||||
n = awk.Run(tbxConsoleInput, tbxConsoleOutput);
|
||||
|
||||
if (!n)
|
||||
{
|
||||
//MessageBox.Show(awk.ErrorMessage);
|
||||
MessageBox.Show("Run Error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//awk.Close();
|
||||
|
||||
awk.Close();
|
||||
}
|
||||
//awk.Dispose();
|
||||
}
|
||||
|
||||
|
||||
private void btnAddArgument_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user