From 060d42d19bfdcb7107821af34b19cfb45b9e7bf2 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 18 Oct 2007 23:51:00 +0000 Subject: [PATCH] Recovered from cvs revision 2007-10-18 11:14:00 --- ase/awk/Argument.java | 38 +++++++++++++++++++++++++++- ase/awk/Awk.java | 3 +-- ase/awk/Context.java | 6 +++-- ase/awk/jni-dmc.def | 6 +++-- ase/awk/jni.c | 59 ++++++++++++++++++++++++++++++++++++++----- ase/awk/jni.def | 6 +++-- ase/awk/jni.h | 10 +++++--- ase/awk/val.c | 3 +-- 8 files changed, 111 insertions(+), 20 deletions(-) diff --git a/ase/awk/Argument.java b/ase/awk/Argument.java index 02e702c5..7e86bbc3 100644 --- a/ase/awk/Argument.java +++ b/ase/awk/Argument.java @@ -1,9 +1,45 @@ /* - * $Id: Argument.java,v 1.1 2007/10/15 16:10:09 bacon Exp $ + * $Id: Argument.java,v 1.2 2007/10/17 14:38:28 bacon Exp $ */ package ase.awk; public class Argument { + protected Context ctx; + protected long value; + + Argument (Context ctx) + { + this.ctx = ctx; + } + + long getIntValue () + { + return getintval (ctx.getId(), value); + } + + double getRealValue () + { + return 0.0; + } + + String getStringValue () + { + return null; + } + + Argument getIndexed (String idx) + { + return null; + } + + Argument getIndexed (long idx) + { + return getIndexed (Long.toString(idx)); + } + + protected native long getintval (long runid, long valid); + protected native double getrealval (long runid, long valid); + protected native String getstrval (long runid, long valid); } diff --git a/ase/awk/Awk.java b/ase/awk/Awk.java index 1c21a413..d52af7d0 100644 --- a/ase/awk/Awk.java +++ b/ase/awk/Awk.java @@ -1,5 +1,5 @@ /* - * $Id: Awk.java,v 1.22 2007/10/16 15:30:41 bacon Exp $ + * $Id: Awk.java,v 1.23 2007/10/17 14:38:28 bacon Exp $ * * {License} */ @@ -72,7 +72,6 @@ public abstract class Awk public native void parse () throws Exception; public native void run (String main, String[] args) throws Exception; public native void stop (); - native void stoprun (long runid); private native int getmaxdepth (int id); private native void setmaxdepth (int id, int depth); private native int getoption (); diff --git a/ase/awk/Context.java b/ase/awk/Context.java index e8ccae2e..8e88d44a 100644 --- a/ase/awk/Context.java +++ b/ase/awk/Context.java @@ -1,5 +1,5 @@ /* - * $Id: Context.java,v 1.5 2007/10/16 15:30:41 bacon Exp $ + * $Id: Context.java,v 1.6 2007/10/17 14:38:28 bacon Exp $ */ package ase.awk; @@ -49,9 +49,11 @@ public class Context public void stop () { - awk.stoprun (this.runid); + stop (this.runid); } + protected native void stop (long runid); + // TODO: // setGlobal // getGlobal diff --git a/ase/awk/jni-dmc.def b/ase/awk/jni-dmc.def index d611cfda..03d8eff4 100644 --- a/ase/awk/jni-dmc.def +++ b/ase/awk/jni-dmc.def @@ -7,7 +7,6 @@ EXPORTS Java_ase_awk_Awk_parse Java_ase_awk_Awk_run Java_ase_awk_Awk_stop - Java_ase_awk_Awk_stoprun Java_ase_awk_Awk_getmaxdepth Java_ase_awk_Awk_setmaxdepth Java_ase_awk_Awk_getoption @@ -23,4 +22,7 @@ EXPORTS Java_ase_awk_Awk_strftime Java_ase_awk_Awk_strfgmtime Java_ase_awk_Awk_system - + Java_ase_awk_Context_stop + Java_ase_awk_Argument_getintval + Java_ase_awk_Argument_getrealval + Java_ase_awk_Argument_getstrval diff --git a/ase/awk/jni.c b/ase/awk/jni.c index d2939b99..cd08dbd3 100644 --- a/ase/awk/jni.c +++ b/ase/awk/jni.c @@ -1,5 +1,5 @@ /* - * $Id: jni.c,v 1.26 2007/10/16 15:30:41 bacon Exp $ + * $Id: jni.c,v 1.27 2007/10/17 14:38:28 bacon Exp $ * * {License} */ @@ -976,11 +976,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_stop (JNIEnv* env, jobject obj) if (awk != NULL) ase_awk_stopall (awk); } -JNIEXPORT void JNICALL Java_ase_awk_Awk_stoprun (JNIEnv* env, jobject obj, jlong runid) -{ - ase_awk_stop ((ase_awk_run_t*)runid); -} - static ase_ssize_t java_open_source (JNIEnv* env, jobject obj, int mode) { jclass class; @@ -2911,3 +2906,55 @@ JNIEXPORT jint JNICALL Java_ase_awk_Awk_system ( ase_awk_free (awk, tmp); return ret; } + +JNIEXPORT void JNICALL Java_ase_awk_Context_stop (JNIEnv* env, jobject obj, jlong runid) +{ + ase_awk_stop ((ase_awk_run_t*)runid); +} + + +JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject obj, long runid, long valid) +{ + int n; + ase_long_t lv; + ase_real_t rv; + + n = ase_awk_valtonum ( + (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv); + if (n == 1) lv = (ase_long_t)rv; + + return (jlong)lv; +} + +JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, long runid, long valid) +{ + int n; + ase_long_t lv; + ase_real_t rv; + + n = ase_awk_valtonum ( + (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv); + if (n == 0) rv = (ase_real_t)lv; + + return (jdouble)rv; +} + +JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, long runid, long valid) +{ + int n; + ase_char_t* str; + ase_size_t len; + jstring ret; + + str = ase_awk_valtostr ( + (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, + ASE_AWK_VALTOSTR_CLEAR, ASE_NULL,&len); + if (str == ASE_NULL) return ASE_NULL; + + // TODO: convert string properly.... + ret = (*env)->NewString (env, (jchar*)str, len); + ase_awk_free (ase_awk_getrunawk((ase_awk_run_t*)runid), str); + + // TODO: clear exception if any... + return ret; +} diff --git a/ase/awk/jni.def b/ase/awk/jni.def index eb5e8369..d4d9e1b3 100644 --- a/ase/awk/jni.def +++ b/ase/awk/jni.def @@ -6,7 +6,6 @@ EXPORTS Java_ase_awk_Awk_parse Java_ase_awk_Awk_run Java_ase_awk_Awk_stop - Java_ase_awk_Awk_stoprun Java_ase_awk_Awk_getmaxdepth Java_ase_awk_Awk_setmaxdepth Java_ase_awk_Awk_getoption @@ -22,4 +21,7 @@ EXPORTS Java_ase_awk_Awk_strftime Java_ase_awk_Awk_strfgmtime Java_ase_awk_Awk_system - + Java_ase_awk_Context_stop + Java_ase_awk_Argument_getintval + Java_ase_awk_Argument_getrealval + Java_ase_awk_Argument_getstrval diff --git a/ase/awk/jni.h b/ase/awk/jni.h index 948d1be5..a448cd5b 100644 --- a/ase/awk/jni.h +++ b/ase/awk/jni.h @@ -1,5 +1,5 @@ /* - * $Id: jni.h,v 1.6 2007/10/16 15:30:41 bacon Exp $ + * $Id: jni.h,v 1.7 2007/10/17 14:38:28 bacon Exp $ * * {License} */ @@ -23,8 +23,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj); JNIEXPORT void JNICALL Java_ase_awk_Awk_run ( JNIEnv* env, jobject obj, jstring mfn, jobjectArray args); JNIEXPORT void JNICALL Java_ase_awk_Awk_stop (JNIEnv* env, jobject obj); -JNIEXPORT void JNICALL Java_ase_awk_Awk_stoprun ( - JNIEnv* env, jobject obj, jlong runid); JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc ( JNIEnv* env, jobject obj, jstring name, jint min_args, jint max_args); @@ -66,6 +64,12 @@ JNIEXPORT jstring JNICALL Java_ase_awk_Awk_strfgmtime ( JNIEXPORT jint JNICALL Java_ase_awk_Awk_system ( JNIEnv* env, jobject obj, jstring cmd); +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 jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject obj, long runid, long valid); +JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject obj, long runid, long valid); + #ifdef __cplusplus } #endif diff --git a/ase/awk/val.c b/ase/awk/val.c index 24ee13a0..4852414f 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.8 2007/09/23 16:48:55 bacon Exp $ + * $Id: val.c,v 1.9 2007/10/17 14:38:28 bacon Exp $ * * {License} */ @@ -747,7 +747,6 @@ int ase_awk_strtonum ( /* TODO: do should i handle strings ending with invalid number * characters like "123xx" or "dkdkdkd"? */ return 0; /* long */ - } #define DPRINTF run->awk->prmfns.misc.dprintf