Recovered from cvs revision 2007-10-18 11:14:00
This commit is contained in:
parent
e46893f4d0
commit
060d42d19b
@ -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);
|
||||
}
|
||||
|
@ -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 ();
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user