Recovered from cvs revision 2007-10-18 11:14:00

This commit is contained in:
hyung-hwan 2007-10-18 23:51:00 +00:00
parent e46893f4d0
commit 060d42d19b
8 changed files with 111 additions and 20 deletions

View File

@ -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; package ase.awk;
public class Argument 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);
} }

View File

@ -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} * {License}
*/ */
@ -72,7 +72,6 @@ public abstract class Awk
public native void parse () throws Exception; public native void parse () throws Exception;
public native void run (String main, String[] args) throws Exception; public native void run (String main, String[] args) throws Exception;
public native void stop (); public native void stop ();
native void stoprun (long runid);
private native int getmaxdepth (int id); private native int getmaxdepth (int id);
private native void setmaxdepth (int id, int depth); private native void setmaxdepth (int id, int depth);
private native int getoption (); private native int getoption ();

View File

@ -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; package ase.awk;
@ -49,9 +49,11 @@ public class Context
public void stop () public void stop ()
{ {
awk.stoprun (this.runid); stop (this.runid);
} }
protected native void stop (long runid);
// TODO: // TODO:
// setGlobal // setGlobal
// getGlobal // getGlobal

View File

@ -7,7 +7,6 @@ EXPORTS
Java_ase_awk_Awk_parse Java_ase_awk_Awk_parse
Java_ase_awk_Awk_run Java_ase_awk_Awk_run
Java_ase_awk_Awk_stop Java_ase_awk_Awk_stop
Java_ase_awk_Awk_stoprun
Java_ase_awk_Awk_getmaxdepth Java_ase_awk_Awk_getmaxdepth
Java_ase_awk_Awk_setmaxdepth Java_ase_awk_Awk_setmaxdepth
Java_ase_awk_Awk_getoption Java_ase_awk_Awk_getoption
@ -23,4 +22,7 @@ EXPORTS
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
Java_ase_awk_Context_stop
Java_ase_awk_Argument_getintval
Java_ase_awk_Argument_getrealval
Java_ase_awk_Argument_getstrval

View File

@ -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} * {License}
*/ */
@ -976,11 +976,6 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_stop (JNIEnv* env, jobject obj)
if (awk != NULL) ase_awk_stopall (awk); 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) static ase_ssize_t java_open_source (JNIEnv* env, jobject obj, int mode)
{ {
jclass class; jclass class;
@ -2911,3 +2906,55 @@ JNIEXPORT jint JNICALL Java_ase_awk_Awk_system (
ase_awk_free (awk, tmp); ase_awk_free (awk, tmp);
return ret; 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;
}

View File

@ -6,7 +6,6 @@ EXPORTS
Java_ase_awk_Awk_parse Java_ase_awk_Awk_parse
Java_ase_awk_Awk_run Java_ase_awk_Awk_run
Java_ase_awk_Awk_stop Java_ase_awk_Awk_stop
Java_ase_awk_Awk_stoprun
Java_ase_awk_Awk_getmaxdepth Java_ase_awk_Awk_getmaxdepth
Java_ase_awk_Awk_setmaxdepth Java_ase_awk_Awk_setmaxdepth
Java_ase_awk_Awk_getoption Java_ase_awk_Awk_getoption
@ -22,4 +21,7 @@ EXPORTS
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
Java_ase_awk_Context_stop
Java_ase_awk_Argument_getintval
Java_ase_awk_Argument_getrealval
Java_ase_awk_Argument_getstrval

View File

@ -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} * {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 ( JNIEXPORT void JNICALL Java_ase_awk_Awk_run (
JNIEnv* env, jobject obj, jstring mfn, jobjectArray args); 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_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 ( JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
JNIEnv* env, jobject obj, jstring name, jint min_args, jint max_args); 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 ( JNIEXPORT jint JNICALL Java_ase_awk_Awk_system (
JNIEnv* env, jobject obj, jstring cmd); 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -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} * {License}
*/ */
@ -747,7 +747,6 @@ int ase_awk_strtonum (
/* TODO: do should i handle strings ending with invalid number /* TODO: do should i handle strings ending with invalid number
* characters like "123xx" or "dkdkdkd"? */ * characters like "123xx" or "dkdkdkd"? */
return 0; /* long */ return 0; /* long */
} }
#define DPRINTF run->awk->prmfns.misc.dprintf #define DPRINTF run->awk->prmfns.misc.dprintf