Recovered from cvs revision 2007-10-03 09:47:00

This commit is contained in:
hyung-hwan 2007-10-03 18:47:00 +00:00
parent 442732b538
commit e18cdb024a
6 changed files with 215 additions and 58 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.63 2007/10/01 15:19:23 bacon Exp $
* $Id: Awk.cpp,v 1.64 2007/10/02 15:21:44 bacon Exp $
*
* {License}
*/
@ -370,12 +370,12 @@ bool Awk::Argument::isIndexed () const
return this->val->type == ASE_AWK_VAL_MAP;
}
int Awk::Argument::getIndexedAt (const char_t* idxptr, Awk::Argument& val) const
int Awk::Argument::getIndexed (const char_t* idxptr, Awk::Argument& val) const
{
return getIndexedAt (idxptr, ase_strlen(idxptr), val);
return getIndexed (idxptr, ase_strlen(idxptr), val);
}
int Awk::Argument::getIndexedAt (const char_t* idxptr, size_t idxlen, Awk::Argument& val) const
int Awk::Argument::getIndexed (const char_t* idxptr, size_t idxlen, Awk::Argument& val) const
{
val.clear ();
@ -516,7 +516,13 @@ int Awk::Return::set (const char_t* ptr, size_t len)
return 0;
}
int Awk::Return::set (const char_t* idx, size_t iln, long_t v)
bool Awk::Return::isIndexed () const
{
if (this->val == ASE_NULL) return false;
return this->val->type == ASE_AWK_VAL_MAP;
}
int Awk::Return::setIndexed (const char_t* idx, size_t iln, long_t v)
{
ASE_ASSERT (this->run != ASE_NULL);
@ -591,7 +597,7 @@ int Awk::Return::set (const char_t* idx, size_t iln, long_t v)
return 0;
}
int Awk::Return::set (const char_t* idx, size_t iln, real_t v)
int Awk::Return::setIndexed (const char_t* idx, size_t iln, real_t v)
{
ASE_ASSERT (this->run != ASE_NULL);
@ -666,7 +672,7 @@ int Awk::Return::set (const char_t* idx, size_t iln, real_t v)
return 0;
}
int Awk::Return::set (const char_t* idx, size_t iln, const char_t* str, size_t sln)
int Awk::Return::setIndexed (const char_t* idx, size_t iln, const char_t* str, size_t sln)
{
ASE_ASSERT (this->run != ASE_NULL);
@ -741,6 +747,93 @@ int Awk::Return::set (const char_t* idx, size_t iln, const char_t* str, size_t s
return 0;
}
int Awk::Return::setIndexed (long_t idx, long_t v)
{
char_t ri[128];
Awk* awk = (Awk*)ase_awk_getcustomdata(ase_awk_getrunawk(this->run));
int rl = Awk::sprintf (
awk, ri, ASE_COUNTOF(ri),
#if ASE_SIZEOF_LONG_LONG > 0
ASE_T("%lld"), (long long)idx
#elif ASE_SIZEOF___INT64 > 0
ASE_T("%I64d"), (__int64)idx
#elif ASE_SIZEOF_LONG > 0
ASE_T("%ld"), (long)idx
#elif ASE_SIZEOF_INT > 0
ASE_T("%d"), (int)idx
#else
#error unsupported size
#endif
);
if (rl < 0)
{
ase_awk_setrunerror (this->run, ERR_INTERN, 0, ASE_NULL, 0);
return -1;
}
return setIndexed (ri, rl, v);
}
int Awk::Return::setIndexed (long_t idx, real_t v)
{
char_t ri[128];
Awk* awk = (Awk*)ase_awk_getcustomdata(ase_awk_getrunawk(this->run));
int rl = Awk::sprintf (
awk, ri, ASE_COUNTOF(ri),
#if ASE_SIZEOF_LONG_LONG > 0
ASE_T("%lld"), (long long)idx
#elif ASE_SIZEOF___INT64 > 0
ASE_T("%I64d"), (__int64)idx
#elif ASE_SIZEOF_LONG > 0
ASE_T("%ld"), (long)idx
#elif ASE_SIZEOF_INT > 0
ASE_T("%d"), (int)idx
#else
#error unsupported size
#endif
);
if (rl < 0)
{
ase_awk_setrunerror (this->run, ERR_INTERN, 0, ASE_NULL, 0);
return -1;
}
return setIndexed (ri, rl, v);
}
int Awk::Return::setIndexed (long_t idx, const char_t* str, size_t sln)
{
char_t ri[128];
Awk* awk = (Awk*)ase_awk_getcustomdata(ase_awk_getrunawk(this->run));
int rl = Awk::sprintf (
awk, ri, ASE_COUNTOF(ri),
#if ASE_SIZEOF_LONG_LONG > 0
ASE_T("%lld"), (long long)idx
#elif ASE_SIZEOF___INT64 > 0
ASE_T("%I64d"), (__int64)idx
#elif ASE_SIZEOF_LONG > 0
ASE_T("%ld"), (long)idx
#elif ASE_SIZEOF_INT > 0
ASE_T("%d"), (int)idx
#else
#error unsupported size
#endif
);
if (rl < 0)
{
ase_awk_setrunerror (this->run, ERR_INTERN, 0, ASE_NULL, 0);
return -1;
}
return setIndexed (ri, rl, str, sln);
}
void Awk::Return::clear ()
{
ase_awk_refdownval (this->run, this->val);

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.65 2007/10/01 15:19:23 bacon Exp $
* $Id: Awk.hpp,v 1.66 2007/10/02 15:21:44 bacon Exp $
*
* {License}
*/
@ -324,8 +324,8 @@ public:
bool isIndexed () const;
int getIndexedAt (const char_t* idxptr, Awk::Argument& val) const;
int getIndexedAt (const char_t* idxptr, size_t idxlen, Awk::Argument& val) const;
int getIndexed (const char_t* idxptr, Argument& val) const;
int getIndexed (const char_t* idxptr, size_t idxlen, Argument& val) const;
int getFirstIndex (Awk::Argument& val) const;
int getNextIndex (Awk::Argument& val) const;
@ -367,9 +367,14 @@ public:
int set (real_t v);
int set (const char_t* ptr, size_t len);
int set (const char_t* idx, size_t iln, long_t v);
int set (const char_t* idx, size_t iln, real_t v);
int set (const char_t* idx, size_t iln, const char_t* str, size_t sln);
bool isIndexed () const;
int setIndexed (const char_t* idx, size_t iln, long_t v);
int setIndexed (const char_t* idx, size_t iln, real_t v);
int setIndexed (const char_t* idx, size_t iln, const char_t* str, size_t sln);
int setIndexed (long_t idx, long_t v);
int setIndexed (long_t idx, real_t v);
int setIndexed (long_t idx, const char_t* str, size_t sln);
void clear ();

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.4 2007/05/09 16:07:44 bacon Exp $
* $Id: misc.c,v 1.5 2007/10/02 15:21:44 bacon Exp $
*
* {License}
*/
@ -908,4 +908,3 @@ exit_loop:
ASE_NULL: (match_ptr+match_len);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.27 2007/09/27 11:04:11 bacon Exp $
* $Id: Awk.hpp,v 1.28 2007/10/02 15:21:44 bacon Exp $
*
* {License}
*/
@ -66,45 +66,30 @@ namespace ASE
}
public:
property System::String^ StringValue
bool Set (System::String^ v)
{
void set (System::String^ v)
{
cli::pin_ptr<const char_t> nptr = PtrToStringChars(v);
ret.set (nptr, v->Length);
}
cli::pin_ptr<const char_t> nptr = PtrToStringChars(v);
return ret.set (nptr, v->Length) == 0;
}
property long_t LongValue
bool Set (long_t v)
{
void set (long_t v)
{
ret.set (v);
}
return ret.set (v) == 0;
}
property real_t RealValue
bool Set (real_t v)
{
void set (real_t v)
{
ret.set (v);
}
return ret.set (v) == 0;
}
property System::Single^ SingleValue
bool Set (System::Single^ v)
{
void set (System::Single^ v)
{
ret.set ((real_t)(float)v);
}
return ret.set ((real_t)(float)v) == 0;
}
property System::Double^ DoubleValue
bool set (System::Double^ v)
{
void set (System::Double^ v)
{
ret.set ((real_t)(double)v);
}
return ret.set ((real_t)(double)v) == 0;
}
property System::SByte^ SByteValue
@ -171,6 +156,87 @@ namespace ASE
}
}
bool SetIndexed (System::String^ idx, System::String^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
cli::pin_ptr<const char_t> vp = PtrToStringChars(v);
return ret.setIndexed (ip, idx->Length, vp, v->Length) == 0;
}
bool SetIndexed (System::String^ idx, long_t v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, v) == 0;
}
bool SetIndexed (System::String^ idx, real_t v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, v) == 0;
}
bool SetIndexed (System::String^ idx, System::Single^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (real_t)(float)v) == 0;
}
bool SetIndexed (System::String^ idx, System::Double^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (real_t)(double)v) == 0;
}
bool SetIndexed (System::String^ idx, System::SByte^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(__int8)v) == 0;
}
bool SetIndexed (System::String^ idx, System::Int16^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(__int16)v) == 0;
}
bool SetIndexed (System::String^ idx, System::Int32^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(__int32)v) == 0;
}
bool SetIndexed (System::String^ idx, System::Int64^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(__int64)v) == 0;
}
bool SetIndexed (System::String^ idx, System::Byte^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int8)v) == 0;
}
bool SetIndexed (System::String^ idx, System::UInt16^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int16)v) == 0;
}
bool SetIndexed (System::String^ idx, System::UInt32^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int32)v) == 0;
}
bool SetIndexed (System::String^ idx, System::UInt64^ v)
{
cli::pin_ptr<const char_t> ip = PtrToStringChars(idx);
return ret.setIndexed (ip, idx->Length, (long_t)(unsigned __int64)v) == 0;
}
protected:
ASE::Awk::Return& ret;
};
@ -240,10 +306,12 @@ namespace ASE
}
/* TODO:...
bool GetGlobal (int id, [System::Runtime::InteropServices::Out] Argument^ v)
{
return run.getGlobal (id, v->placeHolder) == 0;
}
*/
protected:
ASE::Awk::Run& run;

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp,v 1.13 2007/09/24 11:22:22 bacon Exp $
* $Id: StdAwk.cpp,v 1.14 2007/10/02 15:21:44 bacon Exp $
*
* {License}
*/
@ -47,20 +47,17 @@ namespace ASE
bool StdAwk::Sin (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Sin (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Sin (args[0]->RealValue));
}
bool StdAwk::Cos (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Cos (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Cos (args[0]->RealValue));
}
bool StdAwk::Tan (System::String^ name, array<Argument^>^ args, Return^ ret)
{
ret->RealValue = System::Math::Tan (args[0]->RealValue);
return true;
return ret->Set ((real_t)System::Math::Tan (args[0]->RealValue));
}
bool StdAwk::Atan (System::String^ name, array<Argument^>^ args, Return^ ret)

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.38 2007/10/01 15:19:23 bacon Exp $
* $Id: Awk.cpp,v 1.39 2007/10/02 15:21:44 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -141,7 +141,7 @@ public:
size_t len;
const char_t* ptr = idx.toStr(&len);
if (args[0].getIndexedAt (ptr, len, val) == -1) return -1;
if (args[0].getIndexed(ptr, len, val) == -1) return -1;
x += val.toInt ();
n = args[0].getNextIndex (idx);
@ -159,7 +159,7 @@ public:
if (!args[0].isIndexed()) return 0;
Argument idx;
size_t i;
long_t i;
char_t buf[128];
int n = args[0].getFirstIndex (idx);
@ -167,13 +167,8 @@ public:
{
size_t len;
const char_t* ptr = idx.toStr(&len);
n = args[0].getNextIndex (idx);
int blen = ase_sprintf (buf, ASE_COUNTOF(buf), ASE_T("%lu"), (unsigned long)i);
if (blen < 0) return -1;
if (ret.set (buf, blen, ptr, len) == -1) return -1;
if (ret.setIndexed (i, ptr, len) == -1) return -1;
}
if (n != 0) return -1;