Recovered from cvs revision 2007-10-19 15:02:00

This commit is contained in:
hyung-hwan 2007-10-20 00:02:00 +00:00
parent 3b74f61b7f
commit 2659857d81
9 changed files with 61 additions and 405 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Argument.java,v 1.3 2007/10/18 14:51:04 bacon Exp $ * $Id: Argument.java,v 1.4 2007/10/19 03:50:32 bacon Exp $
*/ */
package ase.awk; package ase.awk;
@ -15,28 +15,28 @@ public class Argument
this.valid = valid; this.valid = valid;
} }
long getIntValue () public long getIntValue ()
{ {
return getintval (this.runid, this.valid); return getintval (this.runid, this.valid);
} }
double getRealValue () public double getRealValue ()
{ {
return getrealval (this.runid, this.valid); return getrealval (this.runid, this.valid);
} }
String getStringValue () throws Exception public String getStringValue () throws Exception
{ {
return getstrval (this.runid, this.valid); return getstrval (this.runid, this.valid);
} }
Argument getIndexed (String idx) public Argument getIndexed (String idx)
{ {
// TODO:.. // TODO:..
return null; return null;
} }
Argument getIndexed (long idx) public Argument getIndexed (long idx)
{ {
return getIndexed (Long.toString(idx)); return getIndexed (Long.toString(idx));
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.java,v 1.25 2007/10/18 14:51:04 bacon Exp $ * $Id: Awk.java,v 1.26 2007/10/19 03:50:32 bacon Exp $
* *
* {License} * {License}
*/ */
@ -124,8 +124,6 @@ public abstract class Awk
protected native void delfunc (String name) throws Exception; protected native void delfunc (String name) throws Exception;
native void setfilename (long runid, String name) throws Exception; native void setfilename (long runid, String name) throws Exception;
native void setofilename (long runid, String name) throws Exception; native void setofilename (long runid, String name) throws Exception;
protected native Object strtonum (long runid, String str) throws Exception;
protected native String valtostr (long runid, Object obj) throws Exception;
protected native String strftime (String fmt, long sec); protected native String strftime (String fmt, long sec);
protected native String strfgmtime (String fmt, long sec); protected native String strfgmtime (String fmt, long sec);
protected native int system (String cmd); protected native int system (String cmd);
@ -162,105 +160,19 @@ public abstract class Awk
} }
protected Object handleFunction ( protected Object handleFunction (
Context ctx, String name, Object args[]) throws java.lang.Exception Context ctx, String name, Argument[] args) throws java.lang.Exception
{ {
String mn = (String)functionTable.get(name); String mn = (String)functionTable.get(name);
// name should always be found in this table. // name should always be found in this table.
// otherwise, there is something wrong with this program. // otherwise, there is something wrong with this program.
Class c = this.getClass (); Class c = this.getClass ();
Class[] a = { Context.class, String.class, Object[].class }; Class[] a = { Context.class, String.class, Argument[].class };
Method m = c.getMethod (mn, a); Method m = c.getMethod (mn, a);
return m.invoke (this, /*new Object[] {*/ ctx, name, args/*}*/) ; return m.invoke (this, /*new Object[] {*/ ctx, name, args/*}*/) ;
} }
protected long builtinFunctionArgumentToLong (
Context ctx, Object obj) throws Exception
{
long n;
if (obj == null) n = 0;
else
{
if (obj instanceof String)
obj = strtonum (ctx.getId(), (String)obj);
if (obj instanceof Long)
{
n = ((Long)obj).longValue ();
}
else if (obj instanceof Double)
{
n = ((Double)obj).longValue ();
}
else if (obj instanceof Integer)
{
n = ((Integer)obj).longValue ();
}
else if (obj instanceof Short)
{
n = ((Short)obj).longValue ();
}
else if (obj instanceof Float)
{
n = ((Float)obj).longValue ();
}
else n = 0;
}
return n;
}
protected double builtinFunctionArgumentToDouble (
Context ctx, Object obj) throws Exception
{
double n;
if (obj == null) n = 0.0;
else
{
if (obj instanceof String)
obj = strtonum (ctx.getId(), (String)obj);
if (obj instanceof Long)
{
n = ((Long)obj).doubleValue ();
}
else if (obj instanceof Double)
{
n = ((Double)obj).doubleValue ();
}
else if (obj instanceof Integer)
{
n = ((Integer)obj).doubleValue ();
}
else if (obj instanceof Short)
{
n = ((Short)obj).doubleValue ();
}
else if (obj instanceof Float)
{
n = ((Float)obj).doubleValue ();
}
else n = 0.0;
}
return n;
}
protected String builtinFunctionArgumentToString (
Context ctx, Object obj) throws Exception
{
String str;
if (obj == null) str = "";
else if (obj instanceof String) str = (String)obj;
else str = valtostr (ctx.getId(), obj);
return str;
}
/* == depth limiting == */ /* == depth limiting == */
public int getMaxDepth (int id) throws Exception public int getMaxDepth (int id) throws Exception
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.java,v 1.16 2007/10/18 14:51:04 bacon Exp $ * $Id: StdAwk.java,v 1.17 2007/10/19 03:50:32 bacon Exp $
* *
* {License} * {License}
*/ */
@ -331,107 +331,94 @@ public abstract class StdAwk extends Awk
} }
/* == arithmetic built-in functions */ /* == arithmetic built-in functions */
public Object sin (Context ctx, String name, Object[] args) throws Exception public Object sin (Context ctx, String name, Argument[] args) throws Exception
{ {
/* return new Double (Math.sin(args[0].getRealValue()));
double x = builtinFunctionArgumentToDouble (ctx, args[0]);
return new Double (Math.sin(x));
*/
Argument x = (Argument)args[0];
return new Double (Math.sin(x.getIntValue()));
} }
public Object cos (Context ctx, String name, Object[] args) throws Exception public Object cos (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.cos(args[0].getRealValue()));
return new Double (Math.cos(x));
} }
public Object tan (Context ctx, String name, Object[] args) throws Exception public Object tan (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.tan(args[0].getRealValue()));
return new Double (Math.tan(x));
} }
public Object atan (Context ctx, String name, Object[] args) throws Exception public Object atan (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.atan(args[0].getRealValue()));
return new Double (Math.atan(x));
} }
public Object atan2 (Context ctx, String name, Object[] args) throws Exception public Object atan2 (Context ctx, String name, Argument[] args) throws Exception
{ {
double y = builtinFunctionArgumentToDouble (ctx, args[0]); double y = args[0].getRealValue();
double x = builtinFunctionArgumentToDouble (ctx, args[1]); double x = args[1].getRealValue();
return new Double (Math.atan2(y,x)); return new Double (Math.atan2(y,x));
} }
public Object log (Context ctx, String name, Object[] args) throws Exception public Object log (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.log(args[0].getRealValue()));
return new Double (Math.log(x));
} }
public Object exp (Context ctx, String name, Object[] args) throws Exception public Object exp (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.exp(args[0].getRealValue()));
return new Double (Math.exp(x));
} }
public Object sqrt (Context ctx, String name, Object[] args) throws Exception public Object sqrt (Context ctx, String name, Argument[] args) throws Exception
{ {
double x = builtinFunctionArgumentToDouble (ctx, args[0]); return new Double (Math.sqrt(args[0].getRealValue()));
return new Double (Math.sqrt(x));
} }
public Object bfnint (Context ctx, String name, Object[] args) throws Exception public Object bfnint (Context ctx, String name, Argument[] args) throws Exception
{ {
long x = builtinFunctionArgumentToLong (ctx, args[0]); return new Long (args[0].getIntValue());
return new Long (x);
} }
public Object rand (Context ctx, String name, Object[] args) public Object rand (Context ctx, String name, Argument[] args)
{ {
return new Double (random.nextDouble ()); return new Double (random.nextDouble ());
} }
public Object srand (Context ctx, String name, Object[] args) throws Exception public Object srand (Context ctx, String name, Argument[] args) throws Exception
{ {
long prev_seed = seed; long prev_seed = seed;
seed = (args == null || args.length == 0)? seed = (args == null || args.length == 0)?
System.currentTimeMillis (): System.currentTimeMillis ():
builtinFunctionArgumentToLong (ctx, args[0]); args[0].getIntValue();
random.setSeed (seed); random.setSeed (seed);
return new Long (prev_seed); return new Long (prev_seed);
} }
public Object systime (Context ctx, String name, Object[] args) public Object systime (Context ctx, String name, Argument[] args)
{ {
long msec = System.currentTimeMillis (); long msec = System.currentTimeMillis ();
return new Long (msec / 1000); return new Long (msec / 1000);
} }
public Object strftime (Context ctx, String name, Object[] args) throws Exception public Object strftime (Context ctx, String name, Argument[] args) throws Exception
{ {
String fmt = (args.length<1)? "%c": builtinFunctionArgumentToString (ctx, args[0]); String fmt = (args.length<1)? "%c": args[0].getStringValue();
long t = (args.length<2)? (System.currentTimeMillis()/1000): builtinFunctionArgumentToLong (ctx, args[1]); long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue();
return strftime (fmt, t); return strftime (fmt, t);
} }
public Object strfgmtime (Context ctx, String name, Object[] args) throws Exception public Object strfgmtime (Context ctx, String name, Argument[] args) throws Exception
{ {
String fmt = (args.length<1)? "%c": builtinFunctionArgumentToString (ctx, args[0]); String fmt = (args.length<1)? "%c": args[0].getStringValue();
long t = (args.length<2)? (System.currentTimeMillis()/1000): builtinFunctionArgumentToLong (ctx, args[1]); long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue();
return strfgmtime (fmt, t); return strfgmtime (fmt, t);
} }
/* miscellaneous built-in functions */ /* miscellaneous built-in functions */
public Object system (Context ctx, String name, Object[] args) throws Exception public Object system (Context ctx, String name, Argument[] args) throws Exception
{ {
String str = builtinFunctionArgumentToString (ctx, args[0]); return system (args[0].getStringValue());
return system (str);
} }
/* == utility functions == */ /* == utility functions == */

View File

@ -17,8 +17,6 @@ EXPORTS
Java_ase_awk_Awk_delfunc Java_ase_awk_Awk_delfunc
Java_ase_awk_Awk_setfilename Java_ase_awk_Awk_setfilename
Java_ase_awk_Awk_setofilename Java_ase_awk_Awk_setofilename
Java_ase_awk_Awk_strtonum
Java_ase_awk_Awk_valtostr
Java_ase_awk_Awk_strftime Java_ase_awk_Awk_strftime
Java_ase_awk_Awk_strfgmtime Java_ase_awk_Awk_strfgmtime
Java_ase_awk_Awk_system Java_ase_awk_Awk_system

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.c,v 1.29 2007/10/18 14:51:04 bacon Exp $ * $Id: jni.c,v 1.30 2007/10/19 03:50:32 bacon Exp $
* *
* {License} * {License}
*/ */
@ -1664,7 +1664,7 @@ static int handle_bfn (
class = (*env)->GetObjectClass(env, obj); class = (*env)->GetObjectClass(env, obj);
method = (*env)->GetMethodID ( method = (*env)->GetMethodID (
env, class, "handleFunction", env, class, "handleFunction",
"(Lase/awk/Context;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;"); "(Lase/awk/Context;Ljava/lang/String;[Lase/awk/Argument;)Ljava/lang/Object;");
(*env)->DeleteLocalRef (env, class); (*env)->DeleteLocalRef (env, class);
/*(*env)->ReleaseStringUTFChars (env, name, name_utf);*/ /*(*env)->ReleaseStringUTFChars (env, name, name_utf);*/
@ -1681,7 +1681,7 @@ static int handle_bfn (
} }
args = (*env)->NewObjectArray ( args = (*env)->NewObjectArray (
env, nargs, run_data->object_class, NULL); env, nargs, run_data->argument_class, NULL);
if (args == NULL) if (args == NULL)
{ {
(*env)->DeleteLocalRef (env, name); (*env)->DeleteLocalRef (env, name);
@ -2355,239 +2355,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
} }
} }
JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
JNIEnv* env, jobject obj, jlong runid, jstring str)
{
const jchar* ptr;
jsize len;
jint n;
ase_long_t lv;
ase_real_t rv;
jobject ret;
run_data_t* run_data;
ase_awk_t* awk = ase_awk_getrunawk ((ase_awk_run_t*)runid);
len = (*env)->GetStringLength (env, str);
ptr = (*env)->GetStringChars (env, str, JNI_FALSE);
if (ptr == NULL)
{
(*env)->ExceptionClear (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
jsize x;
ase_char_t* tmp = (ase_char_t*)
ase_awk_malloc (awk, ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
{
(*env)->ReleaseStringChars (env, str, ptr);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_strtonum (
(ase_awk_run_t*)runid, tmp, len, &lv, &rv);
ase_awk_free (awk, tmp);
}
else
{
n = ase_awk_strtonum (
(ase_awk_run_t*)runid,
(ase_char_t*)ptr, len, &lv, &rv);
}
(*env)->ReleaseStringChars (env, str, ptr);
run_data = ase_awk_getruncustomdata ((ase_awk_run_t*)runid);
if (n == 0)
{
ret = (*env)->NewObject (env,
run_data->long_class,
run_data->long_init, (jlong)lv);
}
else
{
ret = (*env)->NewObject (env,
run_data->double_class,
run_data->double_init, (jdouble)rv);
}
return ret;
}
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_valtostr (
JNIEnv* env, jobject obj, jlong runid, jobject val)
{
ase_awk_run_t* run = (ase_awk_run_t*)runid;
run_data_t* run_data;
jstring ret;
ase_awk_val_t* v;
ase_char_t* str;
ase_size_t len;
ase_awk_t* awk;
awk = ase_awk_getrunawk (run);
if (val == NULL)
{
ret = (*env)->NewString (env, NULL, 0);
if (ret == NULL)
{
(*env)->ExceptionClear (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
}
return ret;
}
run_data = ase_awk_getruncustomdata (run);
if ((*env)->IsInstanceOf (env, val, run_data->string_class))
{
const jchar* ptr;
len = (*env)->GetStringLength (env, val);
ptr = (*env)->GetStringChars (env, val, JNI_FALSE);
if (ptr == NULL)
{
(*env)->ExceptionClear (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
ret = (*env)->NewString (env, ptr, len);
(*env)->ReleaseStringChars (env, ret, ptr);
return ret;
}
if ((*env)->IsInstanceOf (env, val, run_data->integer_class))
{
jint jv;
jv = (*env)->CallIntMethod (
env, val, run_data->integer_value);
v = ase_awk_makeintval (run, jv);
}
else if ((*env)->IsInstanceOf (env, val, run_data->long_class))
{
jlong jv = (*env)->CallLongMethod (
env, val, run_data->long_value);
v = ase_awk_makeintval (run, jv);
}
else if ((*env)->IsInstanceOf (env, val, run_data->short_class))
{
jshort jv = (*env)->CallShortMethod (
env, val, run_data->short_value);
v = ase_awk_makeintval (run, jv);
}
else if ((*env)->IsInstanceOf (env, val, run_data->float_class))
{
jfloat jv = (*env)->CallFloatMethod (
env, val, run_data->float_value);
v = ase_awk_makerealval (run, jv);
}
else if ((*env)->IsInstanceOf (env, val, run_data->double_class))
{
jdouble jv = (*env)->CallDoubleMethod (
env, val, run_data->double_value);
v = ase_awk_makerealval (run, jv);
}
else
{
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_EVALTYPE),
ASE_AWK_EVALTYPE,
0);
return NULL;
}
if (v == NULL)
{
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
ase_awk_refupval (run, v);
str = ase_awk_valtostr (run, v, ASE_AWK_VALTOSTR_CLEAR, NULL, &len);
ase_awk_refdownval (run, v);
if (str == NULL)
{
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jchar* tmp = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len);
if (tmp == NULL)
{
ase_awk_free (awk, str);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL;
}
for (i = 0; i < len; i++) tmp[i] = (jchar)str[i];
ret = (*env)->NewString (env, tmp, len);
ase_awk_free (awk, tmp);
}
else
{
ret = (*env)->NewString (env, (jchar*)str, len);
}
ase_awk_free (awk, str);
if (ret == NULL)
{
(*env)->ExceptionClear (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
}
return ret;
}
static jstring JNICALL call_strftime ( static jstring JNICALL call_strftime (
JNIEnv* env, jobject obj, jstring fmt, struct tm* tm) JNIEnv* env, jobject obj, jstring fmt, struct tm* tm)
{ {
@ -2801,12 +2568,13 @@ JNIEXPORT void JNICALL Java_ase_awk_Context_stop (JNIEnv* env, jobject obj, jlon
} }
JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, long runid, long valid) JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, jlong runid, jlong valid)
{ {
int n; int n;
ase_long_t lv; ase_long_t lv;
ase_real_t rv; ase_real_t rv;
n = ase_awk_valtonum ( n = ase_awk_valtonum (
(ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv); (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv);
if (n == 1) lv = (ase_long_t)rv; if (n == 1) lv = (ase_long_t)rv;
@ -2814,7 +2582,7 @@ JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject ob
return (jlong)lv; return (jlong)lv;
} }
JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, long runid, long valid) JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, jlong runid, jlong valid)
{ {
int n; int n;
ase_long_t lv; ase_long_t lv;
@ -2827,7 +2595,7 @@ JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject
return (jdouble)rv; return (jdouble)rv;
} }
JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, long runid, long valid) JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, jlong runid, jlong valid)
{ {
ase_awk_run_t* run = (ase_awk_run_t*)runid; ase_awk_run_t* run = (ase_awk_run_t*)runid;
ase_awk_val_t* val = (ase_awk_val_t*)valid; ase_awk_val_t* val = (ase_awk_val_t*)valid;

View File

@ -16,8 +16,6 @@ EXPORTS
Java_ase_awk_Awk_delfunc Java_ase_awk_Awk_delfunc
Java_ase_awk_Awk_setfilename Java_ase_awk_Awk_setfilename
Java_ase_awk_Awk_setofilename Java_ase_awk_Awk_setofilename
Java_ase_awk_Awk_strtonum
Java_ase_awk_Awk_valtostr
Java_ase_awk_Awk_strftime Java_ase_awk_Awk_strftime
Java_ase_awk_Awk_strfgmtime Java_ase_awk_Awk_strfgmtime
Java_ase_awk_Awk_system Java_ase_awk_Awk_system

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.h,v 1.8 2007/10/18 11:14:48 bacon Exp $ * $Id: jni.h,v 1.9 2007/10/19 03:50:33 bacon Exp $
* *
* {License} * {License}
*/ */
@ -52,11 +52,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename ( JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
JNIEnv* env, jobject obj, jlong runid, jstring name); JNIEnv* env, jobject obj, jlong runid, jstring name);
JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
JNIEnv* env, jobject obj, jlong runid, jstring str);
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_valtostr (
JNIEnv* env, jobject obj, jlong runid, jobject val);
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_strftime ( JNIEXPORT jstring JNICALL Java_ase_awk_Awk_strftime (
JNIEnv* env, jobject obj, jstring fmt, jlong sec); JNIEnv* env, jobject obj, jstring fmt, jlong sec);
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_strfgmtime ( JNIEXPORT jstring JNICALL Java_ase_awk_Awk_strfgmtime (
@ -66,9 +61,9 @@ JNIEXPORT jint JNICALL Java_ase_awk_Awk_system (
JNIEXPORT void JNICALL Java_ase_awk_Context_stop (JNIEnv* env, jobject obj, jlong runid); JNIEXPORT void JNICALL Java_ase_awk_Context_stop (JNIEnv* env, jobject obj, jlong runid);
JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, long runid, long valid); JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, jlong runid, jlong valid);
JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, long runid, long valid); JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, jlong runid, jlong valid);
JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, long runid, long valid); JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, jlong runid, jlong valid);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AseAwk.java,v 1.13 2007/10/18 14:51:04 bacon Exp $ * $Id: AseAwk.java,v 1.15 2007/10/19 05:05:20 bacon Exp $
*/ */
import java.awt.*; import java.awt.*;
@ -23,10 +23,10 @@ import java.net.URL;
import ase.awk.StdAwk; import ase.awk.StdAwk;
import ase.awk.Console; import ase.awk.Console;
import ase.awk.Context; import ase.awk.Context;
import ase.awk.Argument;
public class AseAwk extends StdAwk public class AseAwk extends StdAwk
{ {
private static void run_in_awt () private static void run_in_awt ()
{ {
final Frame frame = new Frame (); final Frame frame = new Frame ();
@ -81,8 +81,7 @@ public class AseAwk extends StdAwk
java.io.File file = new java.io.File (url.getFile()); java.io.File file = new java.io.File (url.getFile());
String osname = System.getProperty ("os.name").toLowerCase(); String osname = System.getProperty ("os.name").toLowerCase();
String aseBase = file.getParentFile().getParentFile().getParent( String aseBase = file.getParentFile().getParentFile().getParent();
);
String path; String path;
if (osname.startsWith ("windows")) if (osname.startsWith ("windows"))
@ -302,10 +301,9 @@ public class AseAwk extends StdAwk
addFunction ("sleep", 1, 1); addFunction ("sleep", 1, 1);
} }
public Object sleep (Context ctx, String name, Object[] args) throws ase.awk.Exception public Object sleep (Context ctx, String name, Argument[] args) throws ase.awk.Exception
{ {
long x = builtinFunctionArgumentToLong (ctx, args[0]); try { Thread.sleep (args[0].getIntValue() * 1000); }
try { Thread.sleep (x * 1000); }
catch (InterruptedException e) {} catch (InterruptedException e) {}
return new Long(0); return new Long(0);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AseAwkPanel.java,v 1.5 2007/10/18 14:51:04 bacon Exp $ * $Id: AseAwkPanel.java,v 1.6 2007/10/19 03:50:33 bacon Exp $
*/ */
import java.awt.*; import java.awt.*;
@ -16,6 +16,7 @@ import java.io.Writer;
import ase.awk.StdAwk; import ase.awk.StdAwk;
import ase.awk.Console; import ase.awk.Console;
import ase.awk.Context; import ase.awk.Context;
import ase.awk.Argument;
public class AseAwkPanel extends Panel public class AseAwkPanel extends Panel
{ {
@ -92,10 +93,9 @@ public class AseAwkPanel extends Panel
addFunction ("sleep", 1, 1); addFunction ("sleep", 1, 1);
} }
public Object sleep (Context ctx, String name, Object[] args) throws ase.awk.Exception public Object sleep (Context ctx, String name, Argument[] args) throws ase.awk.Exception
{ {
long x = builtinFunctionArgumentToLong (ctx, args[0]); try { Thread.sleep (args[0].getIntValue() * 1000); }
try { Thread.sleep (x * 1000); }
catch (InterruptedException e) {} catch (InterruptedException e) {}
return new Long(0); return new Long(0);
} }