Recovered from cvs revision 2007-10-04 04:48:00

This commit is contained in:
hyung-hwan 2007-10-04 20:37:00 +00:00
parent e18cdb024a
commit aac112ab21
4 changed files with 81 additions and 82 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.64 2007/10/02 15:21:44 bacon Exp $ * $Id: Awk.cpp,v 1.65 2007/10/03 09:47:07 bacon Exp $
* *
* {License} * {License}
*/ */
@ -395,7 +395,6 @@ int Awk::Argument::getIndexed (const char_t* idxptr, size_t idxlen, Awk::Argumen
return val.init (this->run, (val_t*)pair->val); return val.init (this->run, (val_t*)pair->val);
} }
#include <ase/utl/stdio.h>
int Awk::Argument::getFirstIndex (Awk::Argument& val) const int Awk::Argument::getFirstIndex (Awk::Argument& val) const
{ {
val.clear (); val.clear ();

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.26 2007/09/24 15:12:16 bacon Exp $ * $Id: Awk.cpp,v 1.27 2007/10/03 09:47:07 bacon Exp $
* *
* {License} * {License}
*/ */
@ -317,7 +317,7 @@ namespace ASE
try try
{ {
b = gcnew cli::array<char_t> (len); b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i]; for (size_t i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WriteSource ( return wrapper->WriteSource (
(ASE::Net::Awk::Source^)gh.Target, b, len); (ASE::Net::Awk::Source^)gh.Target, b, len);
} }
@ -385,7 +385,7 @@ namespace ASE
try try
{ {
b = gcnew cli::array<char_t> (len); b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i]; for (size_t i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WritePipe ( return wrapper->WritePipe (
(ASE::Net::Awk::Pipe^)gh.Target, b, len); (ASE::Net::Awk::Pipe^)gh.Target, b, len);
} }
@ -465,7 +465,7 @@ namespace ASE
try try
{ {
b = gcnew cli::array<char_t> (len); b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i]; for (size_t i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WriteFile ( return wrapper->WriteFile (
(ASE::Net::Awk::File^)gh.Target, b, len); (ASE::Net::Awk::File^)gh.Target, b, len);
} }
@ -545,7 +545,7 @@ namespace ASE
try try
{ {
b = gcnew cli::array<char_t> (len); b = gcnew cli::array<char_t> (len);
for (int i = 0; i < len; i++) b[i] = buf[i]; for (size_t i = 0; i < len; i++) b[i] = buf[i];
return wrapper->WriteConsole ( return wrapper->WriteConsole (
(ASE::Net::Awk::Console^)gh.Target, b, len); (ASE::Net::Awk::Console^)gh.Target, b, len);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp,v 1.28 2007/10/02 15:21:44 bacon Exp $ * $Id: Awk.hpp,v 1.29 2007/10/03 09:47:07 bacon Exp $
* *
* {License} * {License}
*/ */
@ -28,20 +28,33 @@ namespace ASE
ref class Argument ref class Argument
{ {
public protected: public:
Argument (const ASE::Awk::Argument& arg): arg(arg) /*
Argument ()
{ {
arg = new ASE::Awk::Argument ();
}
~Argument ()
{
delete arg;
}*/
public protected:
Argument (const ASE::Awk::Argument& arg): arg(&arg)
{
} }
public: public:
property long_t LongValue property long_t LongValue
{ {
long_t get () { return arg.toInt(); } long_t get () { return arg->toInt(); }
} }
property real_t RealValue property real_t RealValue
{ {
real_t get () { return arg.toReal(); } real_t get () { return arg->toReal(); }
} }
property System::String^ StringValue property System::String^ StringValue
@ -49,13 +62,27 @@ namespace ASE
System::String^ get () System::String^ get ()
{ {
size_t len; size_t len;
const char_t* s = arg.toStr(&len); const char_t* s = arg->toStr(&len);
return gcnew System::String (s, 0, len); return gcnew System::String (s, 0, len);
} }
} }
bool GetIndexed (System::String^ idx)
{
ASE::Awk::Argument x;
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return arg->getIndexed (ip, idx->Length, x) == 0;
}
/*
ttt = arg.GetIndexed ("abc");
if (ttt == nullptr)
{
}*/
protected: protected:
const ASE::Awk::Argument& arg; const ASE::Awk::Argument* arg;
ASE::Awk::Argument x;
}; };
ref class Return ref class Return
@ -87,75 +114,55 @@ namespace ASE
return ret.set ((real_t)(float)v) == 0; return ret.set ((real_t)(float)v) == 0;
} }
bool set (System::Double^ v) bool Set (System::Double^ v)
{ {
return ret.set ((real_t)(double)v) == 0; return ret.set ((real_t)(double)v) == 0;
} }
property System::SByte^ SByteValue bool Set (System::SByte^ v)
{ {
void set (System::SByte^ v) return ret.set ((long_t)(__int8)v) == 0;
{
ret.set ((long_t)(__int8)v);
}
} }
property System::Int16^ Int16Value bool Set (System::Int16^ v)
{ {
void set (System::Int16^ v) return ret.set ((long_t)(__int16)v) == 0;
{
ret.set ((long_t)(__int16)v);
}
} }
property System::Int32^ Int32Value bool Set (System::Int32^ v)
{ {
void set (System::Int32^ v) return ret.set ((long_t)(__int32)v) == 0;
{
ret.set ((long_t)(__int32)v);
}
} }
property System::Int64^ Int64Value bool Set (System::Int64^ v)
{ {
void set (System::Int64^ v) return ret.set ((long_t)(__int64)v) == 0;
{
ret.set ((long_t)(__int64)v);
}
} }
property System::Byte^ ByteValue bool Set (System::Byte^ v)
{ {
void set (System::Byte^ v) return ret.set ((long_t)(unsigned __int8)v) == 0;
{
ret.set ((long_t)(unsigned __int8)v);
}
} }
property System::UInt16^ UInt16Value bool Set (System::UInt16^ v)
{ {
void set (System::UInt16^ v) return ret.set ((long_t)(unsigned __int16)v) == 0;
{
ret.set ((long_t)(unsigned __int16)v);
}
} }
property System::UInt32^ UInt32Value bool Set (System::UInt32^ v)
{ {
void set (System::UInt32^ v) return ret.set ((long_t)(unsigned __int32)v) == 0;
{
ret.set ((long_t)(unsigned __int32)v);
}
} }
property System::UInt64^ UInt64Value bool Set (System::UInt64^ v)
{ {
void set (System::UInt64^ v) return ret.set ((long_t)(unsigned __int64)v) == 0;
{
ret.set ((long_t)(unsigned __int64)v);
}
} }
bool IsIndexed ()
{
return ret.isIndexed ();
}
bool SetIndexed (System::String^ idx, System::String^ v) bool SetIndexed (System::String^ idx, System::String^ v)
{ {
@ -236,7 +243,6 @@ namespace ASE
return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int64)v) == 0; return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int64)v) == 0;
} }
protected: protected:
ASE::Awk::Return& ret; ASE::Awk::Return& ret;
}; };

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.cpp,v 1.14 2007/10/02 15:21:44 bacon Exp $ * $Id: StdAwk.cpp,v 1.15 2007/10/03 09:47:07 bacon Exp $
* *
* {License} * {License}
*/ */
@ -14,6 +14,8 @@
#include <vcclr.h> #include <vcclr.h>
#include <time.h> #include <time.h>
#pragma warning(disable:4996)
namespace ASE namespace ASE
{ {
namespace Net namespace Net
@ -62,52 +64,48 @@ namespace ASE
bool StdAwk::Atan (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Atan (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->RealValue = System::Math::Atan (args[0]->RealValue); return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
return true;
} }
bool StdAwk::Atan2 (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Atan2 (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->RealValue = System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue); return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
return true;
} }
bool StdAwk::Log (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Log (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->RealValue = System::Math::Log (args[0]->RealValue); return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
return true;
} }
bool StdAwk::Exp (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Exp (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->RealValue = System::Math::Exp (args[0]->RealValue); return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
return true;
} }
bool StdAwk::Sqrt (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Sqrt (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->RealValue = System::Math::Sqrt (args[0]->RealValue); return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
return true;
} }
bool StdAwk::Int (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Int (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->LongValue = args[0]->LongValue; return ret->Set (args[0]->LongValue);
return true;
} }
bool StdAwk::Rand (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Rand (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->LongValue = random->Next (); return ret->Set ((long_t)random->Next ());
return true;
} }
bool StdAwk::Srand (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Srand (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
int prev_seed = random_seed; int seed = (int)args[0]->LongValue;
random_seed = (int)args[0]->LongValue; System::Random^ tmp = gcnew System::Random (seed);
random = gcnew System::Random (random_seed);
ret->LongValue = prev_seed; if (!ret->Set((long_t)tmp->Next())) return false;
this->random_seed = seed;
this->random = tmp;
return true; return true;
} }
@ -120,9 +118,7 @@ namespace ASE
bool StdAwk::Systime (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Systime (System::String^ name, array<Argument^>^ args, Return^ ret)
{ {
ret->LongValue = (long_t)::time(NULL); return ret->Set ((long_t)::time(NULL));
return true;
} }
bool StdAwk::Strftime (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Strftime (System::String^ name, array<Argument^>^ args, Return^ ret)
@ -149,8 +145,7 @@ namespace ASE
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm); len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
} }
ret->StringValue = gcnew System::String (buf, 0, len); return ret->Set (gcnew System::String (buf, 0, len));
return true;
} }
bool StdAwk::Strfgmtime (System::String^ name, array<Argument^>^ args, Return^ ret) bool StdAwk::Strfgmtime (System::String^ name, array<Argument^>^ args, Return^ ret)
@ -177,8 +172,7 @@ namespace ASE
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm); len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
} }
ret->StringValue = gcnew System::String (buf, 0, len); return ret->Set (gcnew System::String (buf, 0, len));
return true;
} }
int StdAwk::OpenFile (File^ file) int StdAwk::OpenFile (File^ file)