Recovered from cvs revision 2007-05-12 02:34:00

This commit is contained in:
hyung-hwan 2007-05-12 19:14:00 +00:00
parent 573570870a
commit 4f272ec778
14 changed files with 665 additions and 235 deletions

View File

@ -12,20 +12,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "awk\aseawk.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jni.vcproj", "{23B58791-FD44-4F95-9F77-34E4AF45A296}"
ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}"
ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk", "test\awk\asetestawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj", "{42FE7CED-34B7-45C8-92C9-8856E16640D2}"
@ -35,8 +35,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestlsp", "test\lsp\asetestlsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
ProjectSection(ProjectDependencies) = postProject
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asetestcnt", "test\cnt\asetestcnt.csproj", "{F14B75D8-3ED7-4621-B5B9-E96A80B5D809}"
@ -53,6 +53,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vc
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk++", "test\awk\asetestawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
ProjectSection(ProjectDependencies) = postProject
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -183,6 +189,16 @@ Global
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Mixed Platforms.Build.0 = Release|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Win32.ActiveCfg = Release|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Release|Win32.Build.0 = Release|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Any CPU.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Win32.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Win32.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Any CPU.ActiveCfg = Release|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Mixed Platforms.Build.0 = Release|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Win32.ActiveCfg = Release|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.17 2007/05/10 16:08:37 bacon Exp $
* $Id: Awk.cpp,v 1.21 2007/05/11 16:40:20 bacon Exp $
*/
#include <ase/awk/Awk.hpp>
@ -75,13 +75,13 @@ namespace ASE
return this->mode;
}
Awk::Value::Value (): run (ASE_NULL), val (ASE_NULL)
Awk::Argument::Argument (): run (ASE_NULL), val (ASE_NULL)
{
this->str.ptr = ASE_NULL;
this->str.len = 0;
}
Awk::Value::~Value ()
Awk::Argument::~Argument ()
{
if (this->str.ptr != ASE_NULL)
{
@ -95,140 +95,185 @@ namespace ASE
if (this->val != ASE_NULL)
{
ASE_ASSERT (this->run != ASE_NULL);
ase_awk_refdownval (
ase_awk_getrunawk(this->run), this->val);
ase_awk_refdownval (this->run, this->val);
}
}
void Awk::Value::init (ase_awk_run_t* run, ase_awk_val_t* val)
int Awk::Argument::init (ase_awk_run_t* run, ase_awk_val_t* v)
{
/* this method is used internally.
* and should never be called more than once */
ASE_ASSERT (this->run == ASE_NULL && this->val == ASE_NULL &&
run != ASE_NULL && val != ASE_NULL);
ASE_ASSERT (this->run == ASE_NULL && this->val == ASE_NULL);
ASE_ASSERT (run != ASE_NULL && v != ASE_NULL);
ase_awk_refupval (run, v);
this->run = run;
this->val = val;
this->val = v;
ase_awk_refupval (this->run, this->val);
}
bool Awk::Value::isNil () const
{
return val == ASE_NULL || val->type == ASE_AWK_VAL_NIL;
}
bool Awk::Value::isInt () const
{
return val != ASE_NULL && val->type == ASE_AWK_VAL_INT;
}
bool Awk::Value::isReal () const
{
return val != ASE_NULL && val->type == ASE_AWK_VAL_REAL;
}
bool Awk::Value::isStr () const
{
return val != ASE_NULL && val->type == ASE_AWK_VAL_STR;
}
Awk::long_t Awk::Value::toInt () const
{
if (this->val == ASE_NULL) return 0;
long_t l;
real_t r;
n = ase_awk_valtonum (this->run, this->val, &l, &r);
if (n == 0) return 1;
if (n == 1) return (long_t)r;
return 0; /* return 0 on error */
}
Awk::real_t Awk::Value::toReal () const
{
if (this->val == ASE_NULL) return 0;
long_t l;
real_t r;
n = ase_awk_valtonum (this->run, this->val, &l, &r);
if (n == 0) return (real_t)1;
if (n == 1) return r;
return 0.0; /* return 0 on error */
}
const Awk::char_t* Awk::Value::toStr (ase_awk_t* awk, size_t* len) const
{
if (this->val == ASE_NULL)
if (v->type == ASE_AWK_VAL_STR)
{
tmp = ase_awk_strxdup(
ase_awk_getrunawk(this->run), ASE_T(""), 0);
int n = ase_awk_valtonum (
run, v, &this->inum, &this->rnum);
if (n == 0)
{
this->rnum = (ase_real_t)this->inum;
return 0;
}
else if (n == 1)
{
this->inum = (ase_long_t)this->rnum;
return 0;
}
}
else if (v->type == ASE_AWK_VAL_INT)
{
this->inum = ((ase_awk_val_int_t*)v)->val;
this->rnum = (ase_real_t)((ase_awk_val_int_t*)v)->val;
this->str.ptr = ase_awk_valtostr (run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0;
}
else if (v->type == ASE_AWK_VAL_REAL)
{
this->inum = (ase_long_t)((ase_awk_val_real_t*)v)->val;
this->rnum = ((ase_awk_val_real_t*)v)->val;
this->str.ptr = ase_awk_valtostr (run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0;
}
else if (v->type == ASE_AWK_VAL_NIL)
{
this->inum = 0;
this->rnum = 0.0;
this->str.ptr = ase_awk_valtostr (run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0;
}
ase_awk_refdownval (run, v);
this->run = ASE_NULL;
this->val = ASE_NULL;
return -1;
}
Awk::long_t Awk::Argument::toInt () const
{
ASE_ASSERT (this->run != ASE_NULL && this->val != ASE_NULL);
return this->inum;
}
Awk::real_t Awk::Argument::toReal () const
{
ASE_ASSERT (this->run != ASE_NULL && this->val != ASE_NULL);
return this->rnum;
}
const Awk::char_t* Awk::Argument::toStr (size_t* len) const
{
ASE_ASSERT (this->run != ASE_NULL && this->val != ASE_NULL);
if (this->str.ptr != ASE_NULL)
{
*len = this->str.len;
return this->str.ptr;
}
else
{
ASE_ASSERT (val->type == ASE_AWK_VAL_STR);
*len = ((ase_awk_val_str_t*)this->val)->len;
return ((ase_awk_val_str_t*)this->val)->buf;
}
}
void Awk::Value::setInt (long_t l)
Awk::Return::Return (ase_awk_run_t* run): run (run), type (ASE_AWK_VAL_NIL)
{
if (this->type == ASE_AWK_VAL_INT &&
this->num.l == l) return;
}
if (this->str.ptr != ASE_NULL)
Awk::Return::~Return ()
{
clear ();
}
ase_awk_val_t* Awk::Return::toVal () const
{
switch (this->type)
{
ASE_ASSERT (this->str.awk != ASE_NULL);
ase_awk_free (this->str.awk, this->str.ptr);
this->str.ptr = ASE_NULL;
this->str.awk = ASE_NULL;
case ASE_AWK_VAL_NIL:
return ase_awk_val_nil;
case ASE_AWK_VAL_INT:
return ase_awk_makeintval (this->run, this->v.inum);
case ASE_AWK_VAL_REAL:
return ase_awk_makerealval (this->run, this->v.rnum);
case ASE_AWK_VAL_STR:
return ase_awk_makestrval (
this->run, this->v.str.ptr, this->v.str.len);
}
return ASE_NULL;
}
ase_awk_run_t* Awk::Return::getRun () const
{
return this->run;
}
ase_awk_t* Awk::Return::getAwk () const
{
return ase_awk_getrunawk (this->run);
}
int Awk::Return::set (long_t v)
{
clear ();
this->type = ASE_AWK_VAL_INT;
this->num.l = l;
this->v.inum = v;
return 0;
}
void Awk::Value::setReal (real_t r)
int Awk::Return::set (real_t v)
{
if (this->type == ASE_AWK_VAL_REAL &&
this->num.r == r) return;
if (this->str.ptr != ASE_NULL)
{
ASE_ASSERT (this->str.awk != ASE_NULL);
ase_awk_free (this->str.awk, this->str.ptr);
this->str.ptr = ASE_NULL;
this->str.awk = ASE_NULL;
}
clear ();
this->type = ASE_AWK_VAL_REAL;
this->num.r = r;
this->v.rnum = v;
return 0;
}
const Awk::char_t* Awk::Value::setStr (
ase_awk_t* awk, const char_t* ptr, size_t len)
int Awk::Return::set (char_t* ptr, size_t len)
{
ase_awk_t* awk = ase_awk_getrunawk(this->run);
char_t* tmp = ase_awk_strxdup (awk, ptr, len);
if (tmp == ASE_NULL) return ASE_NULL;
if (tmp == ASE_NULL) return -1;
if (this->str.ptr != ASE_NULL)
clear ();
this->type = ASE_AWK_VAL_STR;
this->v.str.ptr = tmp;
this->v.str.len = len;
return 0;
}
void Awk::Return::clear ()
{
if (this->type == ASE_AWK_VAL_STR)
{
ASE_ASSERT (this->str.awk != ASE_NULL);
ase_awk_free (this->str.awk, this->str.ptr);
this->str.ptr = ASE_NULL;
this->str.awk = ASE_NULL;
ASE_ASSERT (this->v.str.ptr != ASE_NULL);
ase_awk_t* awk = ase_awk_getrunawk(this->run);
ase_awk_free (awk, this->v.str.ptr);
this->v.str.ptr = ASE_NULL;
this->v.str.len = 0;
}
this->str.awk = awk;
this->str.ptr = tmp;
this->str.len = len;
return tmp;
this->type = ASE_AWK_VAL_NIL;
}
Awk::Awk (): awk (ASE_NULL), functionMap (ASE_NULL),
sourceIn (Source::READ), sourceOut (Source::WRITE)
{
@ -337,55 +382,61 @@ namespace ASE
ase_awk_run_t* run, const char_t* name, size_t len)
{
ase_awk_pair_t* pair;
ase_awk_t* awk;
awk = ase_awk_getrunawk (run);
pair = ase_awk_map_get (functionMap, name, len);
if (pair == ASE_NULL) return -1;
if (pair == ASE_NULL)
{
// TODO: SET ERROR INFO
return -1;
}
FunctionHandler handler;
handler = *(FunctionHandler*)ASE_AWK_PAIR_VAL(pair);
size_t i, nargs = ase_awk_getnargs(run);
Value* args = new Value [nargs];
Argument* args = ASE_NULL;
try { args = new Argument [nargs]; } catch (...) {}
if (args == ASE_NULL)
{
// TODO: SET ERROR INFO
return -1;
}
for (i = 0; i < nargs; i++)
{
ase_awk_val_t* v = ase_awk_getarg (run, i);
Value* obj = ASE_NULL;
switch (v->type)
if (args[i].init (run, v) == -1)
{
case ASE_AWK_VAL_INT:
args[i].setInt (((ase_awk_val_int_t*)v)->val);
break;
case ASE_AWK_VAL_REAL:
args[i].setReal (((ase_awk_val_real_t*)v)->val);
break;
case ASE_AWK_VAL_STR:
if (args[i].setStr (awk,
((ase_awk_val_str_t*)v)->buf,
((ase_awk_val_str_t*)v)->len) == ASE_NULL)
{
// TODO: handle error...
}
break;
case ASE_AWK_VAL_NIL:
break;
delete[] args;
// TODO: SET ERROR INFO
return -1;
}
}
Value ret;
int n = (this->*handler) (nargs, args, &ret);
Return ret (run);
int n = (this->*handler) (&ret, args, nargs);
delete[] args;
if (n <= -1) return -1;
if (n <= -1)
{
// TODO: SET ERROR INFO
return -1;
}
// TODO: convert the return value to normal value...
ase_awk_val_t* r = ret.toVal ();
if (r == ASE_NULL)
{
// TODO: SET ERROR INFO
return -1;
}
ase_awk_setretval (run, r);
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.16 2007/05/10 16:08:37 bacon Exp $
* $Id: Awk.hpp,v 1.21 2007/05/11 17:21:01 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_HPP_
@ -109,42 +109,76 @@ namespace ASE
Mode mode;
};
class Value
class Argument
{
public:
Value ();
~Value ();
protected:
friend class Awk;
Argument ();
~Argument ();
private:
Argument (const Argument&);
Argument& operator= (const Argument&);
protected:
void init (ase_awk_run_t* run, ase_awk_val_t* v);
int init (ase_awk_run_t* run, ase_awk_val_t* v);
public:
bool isNil () const;
bool isInt () const;
bool isReal () const;
bool isStr () const;
long_t toInt () const;
real_t toReal () const;
const char_t* toStr (
ase_awk_t* awk, size_t* len) const;
void setInt (long_t l);
void setReal (real_t r);
const char_t* setStr (
ase_awk_t* awk, const char_t* ptr, size_t len);
const char_t* toStr (size_t* len) const;
protected:
ase_awk_run_t* run;
ase_awk_val_t* val;
mutable struct
ase_long_t inum;
ase_real_t rnum;
struct
{
char_t* ptr;
size_t len;
} str;
};
class Return
{
protected:
friend class Awk;
Return (ase_awk_run_t* run);
~Return ();
ase_awk_val_t* toVal () const;
public:
ase_awk_run_t* getRun () const;
ase_awk_t* getAwk () const;
int set (long_t v);
int set (real_t v);
int set (char_t* ptr, size_t len);
void clear ();
protected:
ase_awk_run_t* run;
int type;
union
{
ase_long_t inum;
ase_real_t rnum;
struct
{
char_t* ptr;
size_t len;
} str;
} v;
};
Awk ();
virtual ~Awk ();
@ -156,7 +190,7 @@ namespace ASE
const char_t** args = ASE_NULL);
typedef int (Awk::*FunctionHandler) (
size_t nargs, const Value* args, Value* ret);
Return* ret, const Argument* args, size_t nargs);
virtual int addFunction (
const char_t* name, size_t minArgs, size_t maxArgs,

View File

@ -1,14 +1,26 @@
/*
* $Id: StdAwk.cpp,v 1.6 2007/05/09 16:07:44 bacon Exp $
* $Id: StdAwk.cpp,v 1.11 2007/05/11 17:21:01 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef _WIN32
#include <tchar.h>
#else
#include <wchar.h>
#endif
namespace ASE
{
StdAwk::StdAwk ()
{
seed = ::time(NULL);
::srand (seed);
}
int StdAwk::open ()
@ -31,26 +43,156 @@ namespace ASE
ASE_AWK_ARGSTOMAIN*/;
ase_awk_setoption (awk, opt);
addFunction (ASE_T("sin"), 1, 1, (FunctionHandler)&StdAwk::sin);
addFunction (ASE_T("cos"), 1, 1, (FunctionHandler)&StdAwk::cos);
addFunction (ASE_T("tan"), 1, 1, (FunctionHandler)&StdAwk::tan);
addFunction (ASE_T("atan2"), 2, 2, (FunctionHandler)&StdAwk::atan2);
addFunction (ASE_T("log"), 1, 1, (FunctionHandler)&StdAwk::log);
addFunction (ASE_T("exp"), 1, 1, (FunctionHandler)&StdAwk::exp);
addFunction (ASE_T("sqrt"), 1, 1, (FunctionHandler)&StdAwk::sqrt);
addFunction (ASE_T("int"), 1, 1, (FunctionHandler)&StdAwk::fnint);
addFunction (ASE_T("rand"), 0, 0, (FunctionHandler)&StdAwk::rand);
addFunction (ASE_T("srand"), 1, 1, (FunctionHandler)&StdAwk::srand);
addFunction (ASE_T("systime"), 0, 0, (FunctionHandler)&StdAwk::systime);
addFunction (ASE_T("strftime"), 0, 2, (FunctionHandler)&StdAwk::strftime);
addFunction (ASE_T("strfgmtime"), 0, 2, (FunctionHandler)&StdAwk::strfgmtime);
addFunction (ASE_T("system"), 1, 1, (FunctionHandler)&StdAwk::system);
}
return n;
}
int StdAwk::sin (size_t nargs, const Value* args, Value* ret)
int StdAwk::sin (Return* ret, const Argument* args, size_t nargs)
{
return 0;
return ret->set ((real_t)::sin(args[0].toReal()));
}
int StdAwk::cos (size_t nargs, const Value* args, Value* ret)
int StdAwk::cos (Return* ret, const Argument* args, size_t nargs)
{
return 0;
return ret->set ((real_t)::cos(args[0].toReal()));
}
int StdAwk::tan (size_t nargs, const Value* args, Value* ret)
int StdAwk::tan (Return* ret, const Argument* args, size_t nargs)
{
return 0;
return ret->set ((real_t)::tan(args[0].toReal()));
}
int StdAwk::atan2 (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((real_t)::atan2(args[0].toReal(), args[1].toReal()));
}
int StdAwk::log (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((real_t)::log(args[0].toReal()));
}
int StdAwk::exp (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((real_t)::exp(args[0].toReal()));
}
int StdAwk::sqrt (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((real_t)::sqrt(args[0].toReal()));
}
int StdAwk::fnint (Return* ret, const Argument* args, size_t nargs)
{
return ret->set (args[0].toInt());
}
int StdAwk::rand (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((long_t)::rand());
}
int StdAwk::srand (Return* ret, const Argument* args, size_t nargs)
{
unsigned int prevSeed = seed;
seed = (unsigned int)args[0].toInt();
::srand (seed);
return ret->set ((long_t)prevSeed);
}
int StdAwk::systime (Return* ret, const Argument* args, size_t nargs)
{
return ret->set ((long_t)::time(NULL));
}
int StdAwk::strftime (Return* ret, const Argument* args, size_t nargs)
{
const char_t* fmt;
size_t fln;
fmt = (nargs < 1)? ASE_T("%c"): args[0].toStr(&fln);
time_t t = (nargs < 2)? ::time(NULL): (time_t)args[1].toInt();
char_t buf[128];
struct tm* tm;
#ifdef _WIN32
tm = localtime (&t);
#else
struct tm tmb;
tm = localtime_r (&t, &tmb);
#endif
#ifdef ASE_CHAR_IS_MCHAR
size_t len = strftime (buf, ASE_COUNTOF(buf), fmt, tm);
#else
size_t len = wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
#endif
return ret->set (buf, len);
}
int StdAwk::strfgmtime (Return* ret, const Argument* args, size_t nargs)
{
const char_t* fmt;
size_t fln;
fmt = (nargs < 1)? ASE_T("%c"): args[0].toStr(&fln);
time_t t = (nargs < 2)? ::time(NULL): (time_t)args[1].toInt();
char_t buf[128];
struct tm* tm;
#ifdef _WIN32
tm = gmtime (&t);
#else
struct tm tmb;
tm = gmtime_r (&t, &tmb);
#endif
#ifdef ASE_CHAR_IS_MCHAR
size_t len = strftime (buf, ASE_COUNTOF(buf), fmt, tm);
#else
size_t len = wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
#endif
return ret->set (buf, len);
}
int StdAwk::system (Return* ret, const Argument* args, size_t nargs)
{
size_t len;
const char_t* ptr = args[0].toStr(&len);
#ifdef _WIN32
return ret->set ((long_t)::_tsystem(ptr));
#elif defined(ASE_CHAR_IS_MCHAR)
return ret->set ((long_t)::system(ptr));
#else
char* mbs = (char*)ase_awk_malloc (ret->getAwk(), len*5+1);
if (mbs == ASE_NULL) return -1;
::size_t mbl = ::wcstombs (mbs, ptr, len*5);
if (mbl == (::size_t)-1) return -1;
mbs[mbl] = '\0';
int n = ret->set ((long_t)::system(mbs));
ase_awk_free (ret->getAwk(), mbs);
return n;
#endif
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.hpp,v 1.5 2007/05/09 16:07:44 bacon Exp $
* $Id: StdAwk.hpp,v 1.7 2007/05/11 16:25:38 bacon Exp $
*/
#ifndef _ASE_AWK_STDAWK_HPP_
@ -18,9 +18,23 @@ namespace ASE
int open ();
protected:
int sin (size_t nargs, const Value* args, Value* ret);
int cos (size_t nargs, const Value* args, Value* ret);
int tan (size_t nargs, const Value* args, Value* ret);
int sin (Return* ret, const Argument* args, size_t nargs);
int cos (Return* ret, const Argument* args, size_t nargs);
int tan (Return* ret, const Argument* args, size_t nargs);
int atan2 (Return* ret, const Argument* args, size_t nargs);
int log (Return* ret, const Argument* args, size_t nargs);
int exp (Return* ret, const Argument* args, size_t nargs);
int sqrt (Return* ret, const Argument* args, size_t nargs);
int fnint (Return* ret, const Argument* args, size_t nargs);
int rand (Return* ret, const Argument* args, size_t nargs);
int srand (Return* ret, const Argument* args, size_t nargs);
int systime (Return* ret, const Argument* args, size_t nargs);
int strftime (Return* ret, const Argument* args, size_t nargs);
int strfgmtime (Return* ret, const Argument* args, size_t nargs);
int system (Return* ret, const Argument* args, size_t nargs);
protected:
unsigned int seed;
};
}

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.java,v 1.4 2007/05/05 16:32:46 bacon Exp $
* $Id: StdAwk.java,v 1.5 2007/05/11 16:25:38 bacon Exp $
*
* {License}
*/
@ -63,7 +63,7 @@ public abstract class StdAwk extends Awk
addFunction ("rand", 0, 0);
addFunction ("systime", 0, 0);
addFunction ("strftime", 0, Integer.MAX_VALUE);
addFunction ("strftime", 0, 2);
addFunction ("system", 1, 1);
}

View File

@ -17,7 +17,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory=".\..\debug\lib"
IntermediateDirectory=".\debug"
IntermediateDirectory=".\debug\cpp"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -48,10 +48,6 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\debug\aseawk++.pch"
AssemblerListingLocation=".\debug\"
ObjectFile=".\debug\"
ProgramDataBaseFileName=".\debug\"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -69,7 +65,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\..\debug\lib\aseawk++.lib"
SuppressStartupBanner="true"
/>
<Tool
@ -93,7 +88,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory=".\..\release\lib"
IntermediateDirectory=".\release"
IntermediateDirectory=".\release\cpp"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -125,10 +120,6 @@
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\release\aseawk++.pch"
AssemblerListingLocation=".\release\"
ObjectFile=".\release\"
ProgramDataBaseFileName=".\release\"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -145,7 +136,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\..\release\lib\aseawk++.lib"
SuppressStartupBanner="true"
/>
<Tool

View File

@ -49,10 +49,6 @@
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\release/aseawk.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -69,7 +65,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aseawk.lib"
SuppressStartupBanner="true"
/>
<Tool
@ -124,10 +119,6 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\debug/aseawk.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -145,7 +136,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aseawk.lib"
SuppressStartupBanner="true"
/>
<Tool

View File

@ -48,10 +48,6 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\debug/asecmn.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -69,7 +65,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\asecmn.lib"
/>
<Tool
Name="VCALinkTool"
@ -124,10 +119,6 @@
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\release/asecmn.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -144,7 +135,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\asecmn.lib"
/>
<Tool
Name="VCALinkTool"

View File

@ -48,10 +48,6 @@
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release/aselsp.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -68,7 +64,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aselsp.lib"
/>
<Tool
Name="VCALinkTool"
@ -121,10 +116,6 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug/aselsp.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -142,7 +133,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aselsp.lib"
/>
<Tool
Name="VCALinkTool"

View File

@ -0,0 +1,241 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="asetestawk++"
ProjectGUID="{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
RootNamespace="asetestawk++"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\..\..\release\bin"
IntermediateDirectory=".\release\cpp"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../../release/bin/asetestawk++.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release\cpp\asetestawk++.pch"
AssemblerListingLocation=""
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="asecmn.lib aseawk.lib aseawk++.lib aseutl.lib"
OutputFile="..\..\release\bin\aseawk++.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\release\lib"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../../release/bin/asetestawk++.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\..\..\debug\bin"
IntermediateDirectory=".\debug\cpp"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../../debug/bin/asetestawk++.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug\cpp\asetestawk++.pch"
AssemblerListingLocation=""
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="asecmn.lib aseawk.lib aseawk++.lib aseutl.lib"
OutputFile="..\..\debug\bin\aseawk++.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\debug\lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../../debug/bin/asetestawk++.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="Awk.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -50,10 +50,6 @@
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release/asetestawk.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -75,7 +71,6 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\release\lib"
ProgramDatabaseFile=".\../../release/bin/aseawk.pdb"
SubSystem="1"
TargetMachine="1"
/>
@ -141,10 +136,6 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug/asetestawk.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
@ -169,7 +160,6 @@
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\debug\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../../debug/bin/aseawk.pdb"
SubSystem="1"
TargetMachine="1"
/>

View File

@ -49,10 +49,6 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug/asetestlsp.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
@ -144,10 +140,6 @@
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release/asetestlsp.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>

View File

@ -49,10 +49,6 @@
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\release/aseutl.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -69,7 +65,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aseutl.lib"
/>
<Tool
Name="VCALinkTool"
@ -123,10 +118,6 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DisableLanguageExtensions="true"
PrecompiledHeaderFile=".\debug/aseutl.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -144,7 +135,6 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\aseutl.lib"
/>
<Tool
Name="VCALinkTool"