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}
*/
@ -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);
}
#include <ase/utl/stdio.h>
int Awk::Argument::getFirstIndex (Awk::Argument& val) const
{
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}
*/
@ -317,7 +317,7 @@ namespace ASE
try
{
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 (
(ASE::Net::Awk::Source^)gh.Target, b, len);
}
@ -385,7 +385,7 @@ namespace ASE
try
{
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 (
(ASE::Net::Awk::Pipe^)gh.Target, b, len);
}
@ -465,7 +465,7 @@ namespace ASE
try
{
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 (
(ASE::Net::Awk::File^)gh.Target, b, len);
}
@ -545,7 +545,7 @@ namespace ASE
try
{
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 (
(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}
*/
@ -28,20 +28,33 @@ namespace ASE
ref class Argument
{
public protected:
Argument (const ASE::Awk::Argument& arg): arg(arg)
public:
/*
Argument ()
{
arg = new ASE::Awk::Argument ();
}
~Argument ()
{
delete arg;
}*/
public protected:
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
@ -49,13 +62,27 @@ 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)
{
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:
const ASE::Awk::Argument& arg;
const ASE::Awk::Argument* arg;
ASE::Awk::Argument x;
};
ref class Return
@ -87,75 +114,55 @@ namespace ASE
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;
}
property System::SByte^ SByteValue
bool Set (System::SByte^ v)
{
void set (System::SByte^ v)
{
ret.set ((long_t)(__int8)v);
}
return ret.set ((long_t)(__int8)v) == 0;
}
property System::Int16^ Int16Value
bool Set (System::Int16^ v)
{
void set (System::Int16^ v)
{
ret.set ((long_t)(__int16)v);
}
return ret.set ((long_t)(__int16)v) == 0;
}
property System::Int32^ Int32Value
bool Set (System::Int32^ v)
{
void set (System::Int32^ v)
{
ret.set ((long_t)(__int32)v);
}
return ret.set ((long_t)(__int32)v) == 0;
}
property System::Int64^ Int64Value
bool Set (System::Int64^ v)
{
void set (System::Int64^ v)
{
ret.set ((long_t)(__int64)v);
}
return ret.set ((long_t)(__int64)v) == 0;
}
property System::Byte^ ByteValue
bool Set (System::Byte^ v)
{
void set (System::Byte^ v)
{
ret.set ((long_t)(unsigned __int8)v);
}
return ret.set ((long_t)(unsigned __int8)v) == 0;
}
property System::UInt16^ UInt16Value
bool Set (System::UInt16^ v)
{
void set (System::UInt16^ v)
{
ret.set ((long_t)(unsigned __int16)v);
}
return ret.set ((long_t)(unsigned __int16)v) == 0;
}
property System::UInt32^ UInt32Value
bool Set (System::UInt32^ v)
{
void set (System::UInt32^ v)
{
ret.set ((long_t)(unsigned __int32)v);
}
return ret.set ((long_t)(unsigned __int32)v) == 0;
}
property System::UInt64^ UInt64Value
bool Set (System::UInt64^ v)
{
void set (System::UInt64^ v)
{
ret.set ((long_t)(unsigned __int64)v);
}
return ret.set ((long_t)(unsigned __int64)v) == 0;
}
bool IsIndexed ()
{
return ret.isIndexed ();
}
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;
}
protected:
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}
*/
@ -14,6 +14,8 @@
#include <vcclr.h>
#include <time.h>
#pragma warning(disable:4996)
namespace ASE
{
namespace Net
@ -62,52 +64,48 @@ namespace ASE
bool StdAwk::Atan (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Atan (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
}
bool StdAwk::Atan2 (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
}
bool StdAwk::Log (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Log (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
}
bool StdAwk::Exp (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Exp (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
}
bool StdAwk::Sqrt (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Sqrt (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
}
bool StdAwk::Int (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->LongValue = args[0]->LongValue;
return true;
return ret->Set (args[0]->LongValue);
}
bool StdAwk::Rand (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->LongValue = random->Next ();
return true;
return ret->Set ((long_t)random->Next ());
}
bool StdAwk::Srand (System::String^ name, array<Argument^>^ args, Return^ ret)
{
int prev_seed = random_seed;
random_seed = (int)args[0]->LongValue;
random = gcnew System::Random (random_seed);
ret->LongValue = prev_seed;
int seed = (int)args[0]->LongValue;
System::Random^ tmp = gcnew System::Random (seed);
if (!ret->Set((long_t)tmp->Next())) return false;
this->random_seed = seed;
this->random = tmp;
return true;
}
@ -120,9 +118,7 @@ namespace ASE
bool StdAwk::Systime (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->LongValue = (long_t)::time(NULL);
return true;
return ret->Set ((long_t)::time(NULL));
}
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);
}
ret->StringValue = gcnew System::String (buf, 0, len);
return true;
return ret->Set (gcnew System::String (buf, 0, len));
}
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);
}
ret->StringValue = gcnew System::String (buf, 0, len);
return true;
return ret->Set (gcnew System::String (buf, 0, len));
}
int StdAwk::OpenFile (File^ file)