Recovered from cvs revision 2007-10-30 03:08:00
This commit is contained in:
parent
8ca13ac266
commit
a72a41480a
@ -1,11 +1,29 @@
|
||||
/*
|
||||
* $Id: Context.java,v 1.6 2007/10/17 14:38:28 bacon Exp $
|
||||
* $Id: Context.java,v 1.7 2007/10/29 15:20:13 bacon Exp $
|
||||
*/
|
||||
|
||||
package ase.awk;
|
||||
|
||||
public class Context
|
||||
{
|
||||
public static int GLOBAL_ARGC = 0;
|
||||
public static int GLOBAL_ARGV = 1;
|
||||
public static int GLOBAL_CONVFMT = 2;
|
||||
public static int GLOBAL_FILENAME = 3;
|
||||
public static int GLOBAL_FNR = 4;
|
||||
public static int GLOBAL_FS = 5;
|
||||
public static int GLOBAL_IGNORECASE = 6;
|
||||
public static int GLOBAL_NF = 7;
|
||||
public static int GLOBAL_NR = 8;
|
||||
public static int GLOBAL_OFILENAME = 9;
|
||||
public static int GLOBAL_OFMT = 10;
|
||||
public static int GLOBAL_OFS = 11;
|
||||
public static int GLOBAL_ORS = 12;
|
||||
public static int GLOBAL_RLENGTH = 13;
|
||||
public static int GLOBAL_RS = 14;
|
||||
public static int GLOBAL_RSTART = 15;
|
||||
public static int GLOBAL_SUBSEP = 16;
|
||||
|
||||
private Awk awk;
|
||||
private long runid;
|
||||
private Object custom;
|
||||
@ -52,7 +70,21 @@ public class Context
|
||||
stop (this.runid);
|
||||
}
|
||||
|
||||
public void setGlobal (int id, Return ret) throws Exception
|
||||
{
|
||||
// regardless of the result, the value field
|
||||
// of the return object is reset to 0 by setglobal.
|
||||
setglobal (this.runid, id, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
public void getGlobal (int id, Argument arg) throws Exception
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
protected native void stop (long runid);
|
||||
protected native void setglobal (long runid, int id, Return ret);
|
||||
|
||||
// TODO:
|
||||
// setGlobal
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Return.java,v 1.4 2007/10/24 14:17:32 bacon Exp $
|
||||
* $Id: Return.java,v 1.5 2007/10/29 15:20:13 bacon Exp $
|
||||
*/
|
||||
|
||||
package ase.awk;
|
||||
@ -14,6 +14,12 @@ public class Return
|
||||
* referenced that way, the setXXX methods may cause
|
||||
* JVM to crash */
|
||||
|
||||
public Return (Context ctx)
|
||||
{
|
||||
this.runid = ctx.getId();
|
||||
this.valid = 0;
|
||||
}
|
||||
|
||||
Return (long runid, long valid)
|
||||
{
|
||||
this.runid = runid;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: jni.c,v 1.40 2007/10/24 14:17:32 bacon Exp $
|
||||
* $Id: jni.c,v 1.41 2007/10/29 15:20:13 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1788,9 +1788,11 @@ static int handle_bfn (
|
||||
if (vi != 0)
|
||||
{
|
||||
ase_awk_setretval (run, (ase_awk_val_t*)vi);
|
||||
|
||||
/* invalidate the value field in return object */
|
||||
ase_awk_refdownval (run, (ase_awk_val_t*)vi);
|
||||
}
|
||||
(*env)->SetLongField (env, ret, run_data->return_valid, (jlong)0);
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef (env, args);
|
||||
(*env)->DeleteLocalRef (env, ret);
|
||||
@ -2323,6 +2325,34 @@ JNIEXPORT void JNICALL Java_ase_awk_Context_stop (JNIEnv* env, jobject obj, jlon
|
||||
ase_awk_stop ((ase_awk_run_t*)runid);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_ase_awk_Context_setglobal (JNIEnv* env, jobject obj, jlong runid, jint id, jobject ret)
|
||||
{
|
||||
ase_awk_run_t* run = (ase_awk_run_t*)runid;
|
||||
run_data_t* run_data;
|
||||
jlong vi;
|
||||
|
||||
run_data = (run_data_t*)ase_awk_getruncustomdata (run);
|
||||
|
||||
vi = (*env)->GetLongField (env, ret, run_data->return_valid);
|
||||
if (vi != 0)
|
||||
{
|
||||
if (ase_awk_setglobal(run, id, (ase_awk_val_t*)vi) == -1)
|
||||
{
|
||||
/* invalidate the value field in the return object
|
||||
* even when an exception is thrown. otherwise,
|
||||
* the value might never be freed. */
|
||||
ase_awk_refdownval (run, (ase_awk_val_t*)vi);
|
||||
(*env)->SetLongField (env, ret, run_data->return_valid, (jlong)0);
|
||||
|
||||
THROW_RUN_EXCEPTION (env, run);
|
||||
return;
|
||||
}
|
||||
|
||||
/* invalidate the value field in the return object */
|
||||
ase_awk_refdownval (run, (ase_awk_val_t*)vi);
|
||||
(*env)->SetLongField (env, ret, run_data->return_valid, (jlong)0);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, jlong runid, jlong valid)
|
||||
{
|
||||
@ -2879,7 +2909,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Return_setindexedstrval (JNIEnv* env, jobjec
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_ase_awk_Return_clearval (JNIEnv* env, jobject obj, jlong runid, jlong valid)
|
||||
{
|
||||
ase_awk_run_t* run = (ase_awk_run_t*)runid;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: AseAwkPanel.java,v 1.13 2007/10/28 15:03:22 bacon Exp $
|
||||
* $Id: AseAwkPanel.java,v 1.14 2007/10/29 15:20:13 bacon Exp $
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
@ -100,7 +100,7 @@ public class AseAwkPanel extends Panel
|
||||
setWord ("OFMT", "ofmt");
|
||||
}
|
||||
|
||||
public void sleep (Context ctx, String name, Return ret, Argument[] args)
|
||||
public void sleep (Context ctx, String name, Return ret, Argument[] args) throws ase.awk.Exception
|
||||
{
|
||||
try { Thread.sleep (args[0].getIntValue() * 1000); }
|
||||
catch (InterruptedException e) {}
|
||||
@ -111,6 +111,10 @@ public class AseAwkPanel extends Panel
|
||||
ret.setIndexedStringValue (3, "3dk3kd");
|
||||
ret.setIndexedIntValue (4, 444);
|
||||
ret.setIndexedIntValue (5, 55555);
|
||||
|
||||
Return r = new Return (ctx);
|
||||
r.setStringValue ("[[%.6f]]");
|
||||
ctx.setGlobal (Context.GLOBAL_CONVFMT, ret);
|
||||
}
|
||||
|
||||
protected int openSource (int mode)
|
||||
|
Loading…
Reference in New Issue
Block a user