Recovered from cvs revision 2007-10-24 14:17:00

This commit is contained in:
hyung-hwan 2007-10-24 23:17:00 +00:00
parent 119ec4e513
commit 62ce250c12
8 changed files with 368 additions and 455 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Return.java,v 1.2 2007/10/21 13:58:47 bacon Exp $ * $Id: Return.java,v 1.3 2007/10/24 04:58:35 bacon Exp $
*/ */
package ase.awk; package ase.awk;
@ -90,6 +90,11 @@ public class Return
setindexedstrval (this.runid, this.valid, index, v); setindexedstrval (this.runid, this.valid, index, v);
} }
public void clear ()
{
clearval (this.runid, this.valid);
}
protected native void setintval (long runid, long valid, long v); protected native void setintval (long runid, long valid, long v);
protected native void setrealval (long runid, long valid, double v); protected native void setrealval (long runid, long valid, double v);
protected native void setstrval (long runid, long valid, String v); protected native void setstrval (long runid, long valid, String v);
@ -100,4 +105,6 @@ public class Return
long runid, long valid, String index, double v); long runid, long valid, String index, double v);
protected native void setindexedstrval ( protected native void setindexedstrval (
long runid, long valid, String index, String v); long runid, long valid, String index, String v);
protected native void clearval (long runid, long valid);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.java,v 1.19 2007/10/23 15:18:47 bacon Exp $ * $Id: StdAwk.java,v 1.20 2007/10/24 03:46:51 bacon Exp $
* *
* {License} * {License}
*/ */
@ -346,44 +346,44 @@ public abstract class StdAwk extends Awk
ret.setRealValue (Math.tan(args[0].getRealValue())); ret.setRealValue (Math.tan(args[0].getRealValue()));
} }
public Object atan (Context ctx, String name, Argument[] args) public void atan (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Double (Math.atan(args[0].getRealValue())); ret.setRealValue (Math.atan(args[0].getRealValue()));
} }
public Object atan2 (Context ctx, String name, Argument[] args) public void atan2 (Context ctx, String name, Return ret, Argument[] args)
{ {
double y = args[0].getRealValue(); double y = args[0].getRealValue();
double x = args[1].getRealValue(); double x = args[1].getRealValue();
return new Double (Math.atan2(y,x)); ret.setRealValue (Math.atan2(y,x));
} }
public Object log (Context ctx, String name, Argument[] args) public void log (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Double (Math.log(args[0].getRealValue())); ret.setRealValue (Math.log(args[0].getRealValue()));
} }
public Object exp (Context ctx, String name, Argument[] args) public void exp (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Double (Math.exp(args[0].getRealValue())); ret.setRealValue (Math.exp(args[0].getRealValue()));
} }
public Object sqrt (Context ctx, String name, Argument[] args) public void sqrt (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Double (Math.sqrt(args[0].getRealValue())); ret.setRealValue (Math.sqrt(args[0].getRealValue()));
} }
public Object bfnint (Context ctx, String name, Argument[] args) public void bfnint (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Long (args[0].getIntValue()); ret.setIntValue (args[0].getIntValue());
} }
public Object rand (Context ctx, String name, Argument[] args) public void rand (Context ctx, String name, Return ret, Argument[] args)
{ {
return new Double (random.nextDouble ()); ret.setRealValue (random.nextDouble ());
} }
public Object srand (Context ctx, String name, Argument[] args) public void srand (Context ctx, String name, Return ret, Argument[] args)
{ {
long prev_seed = seed; long prev_seed = seed;
@ -392,33 +392,33 @@ public abstract class StdAwk extends Awk
args[0].getIntValue(); args[0].getIntValue();
random.setSeed (seed); random.setSeed (seed);
return new Long (prev_seed); ret.setIntValue (prev_seed);
} }
public Object systime (Context ctx, String name, Argument[] args) public void systime (Context ctx, String name, Return ret, Argument[] args)
{ {
long msec = System.currentTimeMillis (); long msec = System.currentTimeMillis ();
return new Long (msec / 1000); ret.setIntValue (msec / 1000);
} }
public Object strftime (Context ctx, String name, Argument[] args) throws Exception public void strftime (Context ctx, String name, Return ret, Argument[] args) throws Exception
{ {
String fmt = (args.length<1)? "%c": args[0].getStringValue(); String fmt = (args.length<1)? "%c": args[0].getStringValue();
long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue(); long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue();
return strftime (fmt, t); ret.setStringValue (strftime (fmt, t));
} }
public Object strfgmtime (Context ctx, String name, Argument[] args) throws Exception public void strfgmtime (Context ctx, String name, Return ret, Argument[] args) throws Exception
{ {
String fmt = (args.length<1)? "%c": args[0].getStringValue(); String fmt = (args.length<1)? "%c": args[0].getStringValue();
long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue(); long t = (args.length<2)? (System.currentTimeMillis()/1000): args[1].getIntValue();
return strfgmtime (fmt, t); ret.setStringValue (strfgmtime (fmt, t));
} }
/* miscellaneous built-in functions */ /* miscellaneous built-in functions */
public Object system (Context ctx, String name, Argument[] args) throws Exception public void system (Context ctx, String name, Return ret, Argument[] args) throws Exception
{ {
return system (args[0].getStringValue()); ret.setIntValue (system (args[0].getStringValue()));
} }
/* == utility functions == */ /* == utility functions == */

View File

@ -27,3 +27,7 @@ EXPORTS
Java_ase_awk_Argument_getstrval Java_ase_awk_Argument_getstrval
Java_ase_awk_Argument_isindexed Java_ase_awk_Argument_isindexed
Java_ase_awk_Argument_getindexed Java_ase_awk_Argument_getindexed
Java_ase_awk_Return_setintval
Java_ase_awk_Return_setrealval
Java_ase_awk_Return_setstrval
Java_ase_awk_Return_clearval

File diff suppressed because it is too large Load Diff

View File

@ -26,3 +26,7 @@ EXPORTS
Java_ase_awk_Argument_getstrval Java_ase_awk_Argument_getstrval
Java_ase_awk_Argument_isindexed Java_ase_awk_Argument_isindexed
Java_ase_awk_Argument_getindexed Java_ase_awk_Argument_getindexed
Java_ase_awk_Return_setintval
Java_ase_awk_Return_setrealval
Java_ase_awk_Return_setstrval
Java_ase_awk_Return_clearval

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.h,v 1.13 2007/10/23 15:18:47 bacon Exp $ * $Id: jni.h,v 1.14 2007/10/24 04:58:35 bacon Exp $
* *
* {License} * {License}
*/ */
@ -69,6 +69,8 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Argument_getindexed (JNIEnv* env, jobject
JNIEXPORT void JNICALL Java_ase_awk_Return_setintval (JNIEnv* env, jobject obj, jlong runid, jlong valid, jlong newval); JNIEXPORT void JNICALL Java_ase_awk_Return_setintval (JNIEnv* env, jobject obj, jlong runid, jlong valid, jlong newval);
JNIEXPORT void JNICALL Java_ase_awk_Return_setrealval (JNIEnv* env, jobject obj, jlong runid, jlong valid, jdouble newval); JNIEXPORT void JNICALL Java_ase_awk_Return_setrealval (JNIEnv* env, jobject obj, jlong runid, jlong valid, jdouble newval);
JNIEXPORT void JNICALL Java_ase_awk_Return_setstrval (JNIEnv* env, jobject obj, jlong runid, jlong valid, jstring newval);
JNIEXPORT void JNICALL Java_ase_awk_Return_clearval (JNIEnv* env, jobject obj, jlong runid, jlong valid);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AseAwk.java,v 1.15 2007/10/19 05:05:20 bacon Exp $ * $Id: AseAwk.java,v 1.16 2007/10/24 03:46:51 bacon Exp $
*/ */
import java.awt.*; import java.awt.*;
@ -24,6 +24,7 @@ import ase.awk.StdAwk;
import ase.awk.Console; import ase.awk.Console;
import ase.awk.Context; import ase.awk.Context;
import ase.awk.Argument; import ase.awk.Argument;
import ase.awk.Return;
public class AseAwk extends StdAwk public class AseAwk extends StdAwk
{ {
@ -301,11 +302,11 @@ public class AseAwk extends StdAwk
addFunction ("sleep", 1, 1); addFunction ("sleep", 1, 1);
} }
public Object sleep (Context ctx, String name, Argument[] args) throws ase.awk.Exception public void sleep (Context ctx, String name, Return ret, Argument[] args) throws ase.awk.Exception
{ {
try { Thread.sleep (args[0].getIntValue() * 1000); } try { Thread.sleep (args[0].getIntValue() * 1000); }
catch (InterruptedException e) {} catch (InterruptedException e) {}
return new Long(0); ret.setIntValue (0);
} }
public void parse () throws ase.awk.Exception public void parse () throws ase.awk.Exception

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AseAwkPanel.java,v 1.7 2007/10/21 13:58:47 bacon Exp $ * $Id: AseAwkPanel.java,v 1.8 2007/10/24 03:46:51 bacon Exp $
*/ */
import java.awt.*; import java.awt.*;
@ -17,6 +17,7 @@ import ase.awk.StdAwk;
import ase.awk.Console; import ase.awk.Console;
import ase.awk.Context; import ase.awk.Context;
import ase.awk.Argument; import ase.awk.Argument;
import ase.awk.Return;
public class AseAwkPanel extends Panel public class AseAwkPanel extends Panel
{ {
@ -93,11 +94,11 @@ public class AseAwkPanel extends Panel
addFunction ("sleep", 1, 1); addFunction ("sleep", 1, 1);
} }
public Object sleep (Context ctx, String name, Argument[] args) public void sleep (Context ctx, String name, Return ret, Argument[] args)
{ {
try { Thread.sleep (args[0].getIntValue() * 1000); } try { Thread.sleep (args[0].getIntValue() * 1000); }
catch (InterruptedException e) {} catch (InterruptedException e) {}
return new Long(0); ret.setIntValue (0);
} }
protected int openSource (int mode) protected int openSource (int mode)