Recovered from cvs revision 2007-10-04 14:26:00
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.27 2007/10/03 09:47:07 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.28 2007/10/04 04:48:27 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -13,7 +13,7 @@
|
||||
#include <math.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <msclr/auto_gcroot.h>
|
||||
//#include <msclr/auto_gcroot.h>
|
||||
#include <msclr/gcroot.h>
|
||||
|
||||
using System::Runtime::InteropServices::GCHandle;
|
||||
@ -921,7 +921,8 @@ namespace ASE
|
||||
const ASE::Awk::Argument* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
{
|
||||
System::String^ nm = gcnew System::String (name, 0, len);
|
||||
System::String^ nm =
|
||||
gcnew System::String (name, 0, len);
|
||||
|
||||
FunctionHandler^ fh = (FunctionHandler^)funcs[nm];
|
||||
if (fh == nullptr)
|
||||
@ -930,13 +931,21 @@ namespace ASE
|
||||
return false;
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
Return^ r = gcnew Return (ret);
|
||||
cli::array<Argument^>^ a =
|
||||
gcnew cli::array<Argument^> (nargs);
|
||||
|
||||
return fh (nm, arg_arr, r);
|
||||
size_t i;
|
||||
for (i = 0; i < nargs; i++)
|
||||
a[i] = gcnew Argument(args[i]);
|
||||
|
||||
bool n = fh (nm, a, r);
|
||||
|
||||
while (i > 0) delete a[--i];
|
||||
delete a;
|
||||
delete r;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
bool Awk::SetWord (System::String^ ow, System::String^ nw)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.29 2007/10/03 09:47:07 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.30 2007/10/04 04:48:27 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -28,33 +28,20 @@ namespace ASE
|
||||
|
||||
ref class Argument
|
||||
{
|
||||
public:
|
||||
/*
|
||||
Argument ()
|
||||
{
|
||||
arg = new ASE::Awk::Argument ();
|
||||
}
|
||||
|
||||
~Argument ()
|
||||
{
|
||||
delete arg;
|
||||
}*/
|
||||
|
||||
public protected:
|
||||
Argument (const ASE::Awk::Argument& arg): arg(&arg)
|
||||
Argument (const ASE::Awk::Argument& arg): arg(arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
property long_t LongValue
|
||||
{
|
||||
long_t get () { return arg->toInt(); }
|
||||
long_t get () { return arg.toInt(); }
|
||||
}
|
||||
|
||||
property real_t RealValue
|
||||
{
|
||||
real_t get () { return arg->toReal(); }
|
||||
real_t get () { return arg.toReal(); }
|
||||
}
|
||||
|
||||
property System::String^ StringValue
|
||||
@ -62,27 +49,43 @@ namespace ASE
|
||||
System::String^ get ()
|
||||
{
|
||||
size_t len;
|
||||
const char_t* s = arg->toStr(&len);
|
||||
const char_t* s = arg.toStr(&len);
|
||||
return gcnew System::String (s, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
bool GetIndexed (System::String^ idx)
|
||||
bool GetIndexedLong (System::String^ idx, [System::Runtime::InteropServices::Out] long_t% v)
|
||||
{
|
||||
ASE::Awk::Argument x;
|
||||
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
|
||||
return arg->getIndexed (ip, idx->Length, x) == 0;
|
||||
if (arg.getIndexed (ip, idx->Length, x) == -1) return false;
|
||||
v = x.toInt ();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
ttt = arg.GetIndexed ("abc");
|
||||
if (ttt == nullptr)
|
||||
bool GetIndexedReal (System::String^ idx, [System::Runtime::InteropServices::Out] real_t% v)
|
||||
{
|
||||
}*/
|
||||
ASE::Awk::Argument x;
|
||||
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
|
||||
if (arg.getIndexed (ip, idx->Length, x) == -1) return false;
|
||||
v = x.toReal ();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetIndexedString (System::String^ idx, [System::Runtime::InteropServices::Out] System::String^% v)
|
||||
{
|
||||
ASE::Awk::Argument x;
|
||||
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
|
||||
if (arg.getIndexed (ip, idx->Length, x) == -1) return false;
|
||||
|
||||
size_t len;
|
||||
const char_t* s = arg.toStr(&len);
|
||||
v = gcnew System::String (s, 0, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
const ASE::Awk::Argument* arg;
|
||||
ASE::Awk::Argument x;
|
||||
const ASE::Awk::Argument& arg;
|
||||
};
|
||||
|
||||
ref class Return
|
||||
|
Reference in New Issue
Block a user