Recovered from cvs revision 2007-10-21 07:59:00

This commit is contained in:
hyung-hwan 2007-10-22 00:05:00 +00:00
parent 18d04a7243
commit 2c5bbc7552
3 changed files with 157 additions and 296 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.78 2007/10/19 15:02:33 bacon Exp $ * $Id: Awk.cpp,v 1.79 2007/10/20 15:06:26 bacon Exp $
* *
* {License} * {License}
*/ */
@ -178,7 +178,7 @@ void Awk::Argument::clear ()
this->str.ptr = ASE_NULL; this->str.ptr = ASE_NULL;
this->str.len = 0; this->str.len = 0;
} }
else if (this->val->type == ASE_AWK_VAL_MAP) else if (ASE_AWK_VAL_TYPE(this->val) == ASE_AWK_VAL_MAP)
{ {
ASE_ASSERT (this->run != ASE_NULL); ASE_ASSERT (this->run != ASE_NULL);
@ -193,7 +193,7 @@ void Awk::Argument::clear ()
if (this->str.ptr != ASE_NULL) if (this->str.ptr != ASE_NULL)
{ {
if (this->val->type != ASE_AWK_VAL_STR) if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_STR)
{ {
awk_t* awk = this->run->awk->awk; awk_t* awk = this->run->awk->awk;
ase_awk_free (awk, this->str.ptr); ase_awk_free (awk, this->str.ptr);
@ -267,7 +267,7 @@ int Awk::Argument::init (val_t* v)
ase_awk_refupval (this->run->run, v); ase_awk_refupval (this->run->run, v);
this->val = v; this->val = v;
if (v->type == ASE_AWK_VAL_STR) if (ASE_AWK_VAL_TYPE(v) == ASE_AWK_VAL_STR)
{ {
int n = ase_awk_valtonum ( int n = ase_awk_valtonum (
this->run->run, v, &this->inum, &this->rnum); this->run->run, v, &this->inum, &this->rnum);
@ -286,7 +286,7 @@ int Awk::Argument::init (val_t* v)
return 0; return 0;
} }
} }
else if (v->type == ASE_AWK_VAL_INT) else if (ASE_AWK_VAL_TYPE(v) == ASE_AWK_VAL_INT)
{ {
this->inum = ((ase_awk_val_int_t*)v)->val; this->inum = ((ase_awk_val_int_t*)v)->val;
this->rnum = (ase_real_t)((ase_awk_val_int_t*)v)->val; this->rnum = (ase_real_t)((ase_awk_val_int_t*)v)->val;
@ -295,7 +295,7 @@ int Awk::Argument::init (val_t* v)
this->run->run, v, 0, ASE_NULL, &this->str.len); this->run->run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0; if (this->str.ptr != ASE_NULL) return 0;
} }
else if (v->type == ASE_AWK_VAL_REAL) else if (ASE_AWK_VAL_TYPE(v) == ASE_AWK_VAL_REAL)
{ {
this->inum = (ase_long_t)((ase_awk_val_real_t*)v)->val; this->inum = (ase_long_t)((ase_awk_val_real_t*)v)->val;
this->rnum = ((ase_awk_val_real_t*)v)->val; this->rnum = ((ase_awk_val_real_t*)v)->val;
@ -304,7 +304,7 @@ int Awk::Argument::init (val_t* v)
this->run->run, v, 0, ASE_NULL, &this->str.len); this->run->run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0; if (this->str.ptr != ASE_NULL) return 0;
} }
else if (v->type == ASE_AWK_VAL_NIL) else if (ASE_AWK_VAL_TYPE(v) == ASE_AWK_VAL_NIL)
{ {
this->inum = 0; this->inum = 0;
this->rnum = 0.0; this->rnum = 0.0;
@ -313,7 +313,7 @@ int Awk::Argument::init (val_t* v)
this->run->run, v, 0, ASE_NULL, &this->str.len); this->run->run, v, 0, ASE_NULL, &this->str.len);
if (this->str.ptr != ASE_NULL) return 0; if (this->str.ptr != ASE_NULL) return 0;
} }
else if (v->type == ASE_AWK_VAL_MAP) else if (ASE_AWK_VAL_TYPE(v) == ASE_AWK_VAL_MAP)
{ {
this->inum = 0; this->inum = 0;
this->rnum = 0.0; this->rnum = 0.0;
@ -362,7 +362,8 @@ Awk::real_t Awk::Argument::toReal () const
const Awk::char_t* Awk::Argument::toStr (size_t* len) const const Awk::char_t* Awk::Argument::toStr (size_t* len) const
{ {
if (this->val != ASE_NULL && this->val->type == ASE_AWK_VAL_MAP) if (this->val != ASE_NULL &&
ASE_AWK_VAL_TYPE(this->val) == ASE_AWK_VAL_MAP)
{ {
*len = 0; *len = 0;
return ASE_T(""); return ASE_T("");
@ -382,7 +383,7 @@ const Awk::char_t* Awk::Argument::toStr (size_t* len) const
bool Awk::Argument::isIndexed () const bool Awk::Argument::isIndexed () const
{ {
if (this->val == ASE_NULL) return false; if (this->val == ASE_NULL) return false;
return this->val->type == ASE_AWK_VAL_MAP; return ASE_AWK_VAL_TYPE(this->val) == ASE_AWK_VAL_MAP;
} }
int Awk::Argument::getIndexed (const char_t* idxptr, Awk::Argument& val) const int Awk::Argument::getIndexed (const char_t* idxptr, Awk::Argument& val) const
@ -398,7 +399,7 @@ int Awk::Argument::getIndexed (
// not initialized yet. val is just nil. not an error // not initialized yet. val is just nil. not an error
if (this->val == ASE_NULL) return 0; if (this->val == ASE_NULL) return 0;
// not a map. val is just nil. not an error // not a map. val is just nil. not an error
if (this->val->type != ASE_AWK_VAL_MAP) return 0; if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP) return 0;
// get the value from the map. // get the value from the map.
ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val; ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val;
@ -419,7 +420,7 @@ int Awk::Argument::getIndexed (long_t idx, Argument& val) const
if (this->val == ASE_NULL) return 0; if (this->val == ASE_NULL) return 0;
// not a map. val is just nil. not an error // not a map. val is just nil. not an error
if (this->val->type != ASE_AWK_VAL_MAP) return 0; if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP) return 0;
char_t ri[128]; char_t ri[128];
@ -460,7 +461,7 @@ int Awk::Argument::getFirstIndex (Awk::Argument& val) const
val.clear (); val.clear ();
if (this->val == ASE_NULL) return -1; if (this->val == ASE_NULL) return -1;
if (this->val->type != ASE_AWK_VAL_MAP) return -1; if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP) return -1;
ase_size_t buckno; ase_size_t buckno;
ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val; ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val;
@ -481,7 +482,7 @@ int Awk::Argument::getNextIndex (Awk::Argument& val) const
val.clear (); val.clear ();
if (this->val == ASE_NULL) return -1; if (this->val == ASE_NULL) return -1;
if (this->val->type != ASE_AWK_VAL_MAP) return -1; if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP) return -1;
ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val; ase_awk_val_map_t* m = (ase_awk_val_map_t*)this->val;
@ -582,7 +583,7 @@ int Awk::Return::set (const char_t* ptr, size_t len)
bool Awk::Return::isIndexed () const bool Awk::Return::isIndexed () const
{ {
if (this->val == ASE_NULL) return false; if (this->val == ASE_NULL) return false;
return this->val->type == ASE_AWK_VAL_MAP; return ASE_AWK_VAL_TYPE(this->val) == ASE_AWK_VAL_MAP;
} }
int Awk::Return::setIndexed (const char_t* idx, size_t iln, long_t v) int Awk::Return::setIndexed (const char_t* idx, size_t iln, long_t v)
@ -597,7 +598,7 @@ int Awk::Return::setIndexed (const char_t* idx, size_t iln, long_t v)
return -1; return -1;
} }
if (this->val->type != ASE_AWK_VAL_MAP) if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP)
{ {
ase_awk_val_t* x = ase_awk_makemapval (this->run->run); ase_awk_val_t* x = ase_awk_makemapval (this->run->run);
if (x == ASE_NULL) if (x == ASE_NULL)
@ -666,7 +667,7 @@ int Awk::Return::setIndexed (const char_t* idx, size_t iln, real_t v)
return -1; return -1;
} }
if (this->val->type != ASE_AWK_VAL_MAP) if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP)
{ {
ase_awk_val_t* x = ase_awk_makemapval (this->run->run); ase_awk_val_t* x = ase_awk_makemapval (this->run->run);
if (x == ASE_NULL) if (x == ASE_NULL)
@ -735,7 +736,7 @@ int Awk::Return::setIndexed (const char_t* idx, size_t iln, const char_t* str, s
return -1; return -1;
} }
if (this->val->type != ASE_AWK_VAL_MAP) if (ASE_AWK_VAL_TYPE(this->val) != ASE_AWK_VAL_MAP)
{ {
ase_awk_val_t* x = ase_awk_makemapval (this->run->run); ase_awk_val_t* x = ase_awk_makemapval (this->run->run);
if (x == ASE_NULL) if (x == ASE_NULL)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.c,v 1.31 2007/10/19 15:02:33 bacon Exp $ * $Id: jni.c,v 1.32 2007/10/20 15:06:26 bacon Exp $
* *
* {License} * {License}
*/ */
@ -106,6 +106,7 @@ struct run_data_t
jclass float_class; jclass float_class;
jclass double_class; jclass double_class;
jclass object_class; jclass object_class;
jclass exception_class;
jclass context_class; jclass context_class;
jclass argument_class; jclass argument_class;
@ -123,6 +124,10 @@ struct run_data_t
jmethodID float_value; jmethodID float_value;
jmethodID double_value; jmethodID double_value;
jmethodID exception_get_code;
jmethodID exception_get_line;
jmethodID exception_get_message;
jobject context_object; jobject context_object;
}; };
@ -351,6 +356,41 @@ static void throw_exception (
(*env)->DeleteLocalRef (env, except_obj); (*env)->DeleteLocalRef (env, except_obj);
} }
#define THROW_STATIC_EXCEPTION(env,errnum) \
throw_exception (env, ase_awk_geterrstr(ASE_NULL, errnum), errnum, 0)
#define EXCEPTION_ON_NULL_AWK(env,awk) \
if (awk == NULL) \
{ \
THROW_STATIC_EXCEPTION(env,ASE_AWK_ENOPER); \
return; \
}
#define EXCEPTION_ON_NULL_AWK_RETURNING(env,awk,ret) \
if (awk == NULL) \
{ \
THROW_STATIC_EXCEPTION(env,ASE_AWK_ENOPER); \
return ret; \
}
#define THROW_NOMEM_EXCEPTION(env) \
THROW_STATIC_EXCEPTION(env,ASE_AWK_ENOMEM)
#define THROW_AWK_EXCEPTION(env,awk) \
throw_exception ( \
env, \
ase_awk_geterrmsg(awk), \
ase_awk_geterrnum(awk), \
ase_awk_geterrlin(awk))
#define THROW_RUN_EXCEPTION(env,run) \
throw_exception ( \
env, \
ase_awk_getrunerrmsg(run), \
ase_awk_getrunerrnum(run), \
ase_awk_getrunerrlin(run))
static jboolean is_debug (ase_awk_t* awk) static jboolean is_debug (ase_awk_t* awk)
{ {
awk_data_t* awk_data = (awk_data_t*)ase_awk_getcustomdata (awk); awk_data_t* awk_data = (awk_data_t*)ase_awk_getcustomdata (awk);
@ -380,11 +420,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
heap = HeapCreate (0, 0, 0); heap = HeapCreate (0, 0, 0);
if (heap == NULL) if (heap == NULL)
{ {
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env, return;
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
} }
#endif #endif
@ -429,11 +466,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
#if defined(_WIN32) && defined(__DMC__) #if defined(_WIN32) && defined(__DMC__)
HeapDestroy (heap); HeapDestroy (heap);
#endif #endif
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -452,11 +485,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
#else #else
awk_free (NULL, awk_data); awk_free (NULL, awk_data);
#endif #endif
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -529,28 +558,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj, jlong a
_CrtDumpMemoryLeaks (); _CrtDumpMemoryLeaks ();
#endif #endif
#endif #endif
}
#define EXCEPTION_ON_NULL_AWK(awk) \
if (awk == NULL) \
{ \
throw_exception ( \
env, \
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOPER), \
ASE_AWK_ENOPER, \
0); \
return; \
}
#define EXCEPTION_ON_NULL_AWK_RETURNING(awk,ret) \
if (awk == NULL) \
{ \
throw_exception ( \
env, \
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOPER), \
ASE_AWK_ENOPER, \
0); \
return ret; \
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj, jlong awkid) JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj, jlong awkid)
@ -560,7 +568,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj, jlong a
srcio_data_t srcio_data; srcio_data_t srcio_data;
awk = (ase_awk_t*) awkid; awk = (ase_awk_t*) awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
srcio_data.env = env; srcio_data.env = env;
srcio_data.obj = obj; srcio_data.obj = obj;
@ -571,12 +579,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj, jlong a
if (ase_awk_parse (awk, &srcios) == -1) if (ase_awk_parse (awk, &srcios) == -1)
{ {
throw_exception ( THROW_AWK_EXCEPTION (env, awk);
env,
ase_awk_geterrmsg(awk),
ase_awk_geterrnum(awk),
ase_awk_geterrlin(awk));
return; return;
} }
} }
@ -589,6 +592,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj, jlong a
(*env)->DeleteLocalRef (env, run_data.double_class); \ (*env)->DeleteLocalRef (env, run_data.double_class); \
(*env)->DeleteLocalRef (env, run_data.string_class); \ (*env)->DeleteLocalRef (env, run_data.string_class); \
(*env)->DeleteLocalRef (env, run_data.object_class); \ (*env)->DeleteLocalRef (env, run_data.object_class); \
(*env)->DeleteLocalRef (env, run_data.exception_class); \
(*env)->DeleteLocalRef (env, run_data.context_class); \ (*env)->DeleteLocalRef (env, run_data.context_class); \
(*env)->DeleteLocalRef (env, run_data.argument_class); \ (*env)->DeleteLocalRef (env, run_data.argument_class); \
if (run_data.context_object != NULL) \ if (run_data.context_object != NULL) \
@ -685,7 +689,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
const jchar* ptr; const jchar* ptr;
awk = (ase_awk_t*) awkid; awk = (ase_awk_t*) awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
memset (&run_data, 0, sizeof(run_data)); memset (&run_data, 0, sizeof(run_data));
@ -703,6 +707,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
run_data.float_class = (*env)->FindClass (env, "java/lang/Float"); run_data.float_class = (*env)->FindClass (env, "java/lang/Float");
run_data.double_class = (*env)->FindClass (env, "java/lang/Double"); run_data.double_class = (*env)->FindClass (env, "java/lang/Double");
run_data.object_class = (*env)->FindClass (env, "java/lang/Object"); run_data.object_class = (*env)->FindClass (env, "java/lang/Object");
run_data.exception_class = (*env)->FindClass (env, CLASS_EXCEPTION);
run_data.context_class = (*env)->FindClass (env, CLASS_CONTEXT); run_data.context_class = (*env)->FindClass (env, CLASS_CONTEXT);
run_data.argument_class = (*env)->FindClass (env, CLASS_ARGUMENT); run_data.argument_class = (*env)->FindClass (env, CLASS_ARGUMENT);
@ -713,6 +718,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
ASE_ASSERT (run_data.float_class != NULL); ASE_ASSERT (run_data.float_class != NULL);
ASE_ASSERT (run_data.double_class != NULL); ASE_ASSERT (run_data.double_class != NULL);
ASE_ASSERT (run_data.object_class != NULL); ASE_ASSERT (run_data.object_class != NULL);
ASE_ASSERT (run_data.exception_class != NULL);
ASE_ASSERT (run_data.context_class != NULL); ASE_ASSERT (run_data.context_class != NULL);
ASE_ASSERT (run_data.argument_class != NULL); ASE_ASSERT (run_data.argument_class != NULL);
@ -750,6 +756,13 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
run_data.double_value = (*env)->GetMethodID ( run_data.double_value = (*env)->GetMethodID (
env, run_data.double_class, "doubleValue", "()D"); env, run_data.double_class, "doubleValue", "()D");
run_data.exception_get_code = (*env)->GetMethodID (
env, run_data.exception_class, "getCode", "()I");
run_data.exception_get_line = (*env)->GetMethodID (
env, run_data.exception_class, "getLine", "()I");
run_data.exception_get_message = (*env)->GetMethodID (
env, run_data.exception_class, "getMessage", "()Ljava/lang/String;");
ASE_ASSERTX (run_data.integer_value != NULL, ASE_ASSERTX (run_data.integer_value != NULL,
"The Integer class must has the method - int intValue()"); "The Integer class must has the method - int intValue()");
ASE_ASSERTX (run_data.long_value != NULL, ASE_ASSERTX (run_data.long_value != NULL,
@ -760,6 +773,9 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
"The Float class must has the method - float floatValue()"); "The Float class must has the method - float floatValue()");
ASE_ASSERTX (run_data.double_value != NULL, ASE_ASSERTX (run_data.double_value != NULL,
"The Double class must has the method - double doubleValue()"); "The Double class must has the method - double doubleValue()");
ASE_ASSERT (run_data.exception_get_code != NULL);
ASE_ASSERT (run_data.exception_get_line != NULL);
ASE_ASSERT (run_data.exception_get_message != NULL);
/* No NewGlobalRef are needed on obj and run_data->context_object /* No NewGlobalRef are needed on obj and run_data->context_object
* because they are valid while this run method runs */ * because they are valid while this run method runs */
@ -770,11 +786,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
if (is_debug(awk)) (*env)->ExceptionDescribe (env); if (is_debug(awk)) (*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -811,11 +823,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -824,11 +832,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
{ {
(*env)->ReleaseStringChars (env, mfn, ptr); (*env)->ReleaseStringChars (env, mfn, ptr);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -869,13 +873,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
if (mmm != NULL) ase_awk_free (awk, mmm); if (mmm != NULL) ase_awk_free (awk, mmm);
if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -899,12 +897,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -922,13 +915,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
if (mmm != NULL) ase_awk_free (awk, mmm); if (mmm != NULL) ase_awk_free (awk, mmm);
if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr);
DELETE_CLASS_REFS (env, run_data); DELETE_CLASS_REFS (env, run_data);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -961,14 +948,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
run_data.errnum, run_data.errnum,
run_data.errlin); run_data.errlin);
} }
else else THROW_AWK_EXCEPTION (env, awk);
{
throw_exception (
env,
ase_awk_geterrmsg(awk),
ase_awk_geterrnum(awk),
ase_awk_geterrlin(awk));
}
return; return;
} }
@ -986,7 +966,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jlong awk
JNIEXPORT void JNICALL Java_ase_awk_Awk_stop (JNIEnv* env, jobject obj, jlong awkid) JNIEXPORT void JNICALL Java_ase_awk_Awk_stop (JNIEnv* env, jobject obj, jlong awkid)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
ase_awk_stopall (awk); ase_awk_stopall (awk);
} }
@ -1631,6 +1611,7 @@ static int handle_bfn (
{ {
jclass class; jclass class;
jmethodID method; jmethodID method;
jthrowable throwable;
jstring name; jstring name;
//const char* name_utf; //const char* name_utf;
run_data_t* run_data; run_data_t* run_data;
@ -1756,18 +1737,35 @@ static int handle_bfn (
ret = (*env)->CallObjectMethod ( ret = (*env)->CallObjectMethod (
env, obj, method, run_data->context_object, name, args); env, obj, method, run_data->context_object, name, args);
if ((*env)->ExceptionOccurred (env)) throwable = (*env)->ExceptionOccurred (env);
if (throwable)
{ {
int code, line;
jstring mesg;
const jchar* ptr;
jsize len;
OutputDebugStringA("0000\n");
code = (*env)->CallIntMethod (env, throwable, run_data->exception_get_code);
line = (*env)->CallIntMethod (env, throwable, run_data->exception_get_line);
mesg = (*env)->CallObjectMethod (env, throwable, run_data->exception_get_message);
OutputDebugStringA("222222\n");
if (is_debug(ase_awk_getrunawk(run))) if (is_debug(ase_awk_getrunawk(run)))
(*env)->ExceptionDescribe (env); (*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
(*env)->DeleteLocalRef (env, args); (*env)->DeleteLocalRef (env, args);
(*env)->DeleteLocalRef (env, name); (*env)->DeleteLocalRef (env, name);
/* TODO: retrieve message from the exception and len = (*env)->GetStringLength (env, ret);
* set the error message with setrunerrmsg... */ ptr = (*env)->GetStringChars (env, ret, JNI_FALSE);
ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL);
ase_awk_setrunerrmsg (run, code, line, ptr);
(*env)->ReleaseStringChars (env, ret, ptr);
return -1; return -1;
} }
@ -1943,12 +1941,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -1960,11 +1953,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -1981,15 +1970,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
if (n == -1) THROW_AWK_EXCEPTION (env, awk);
if (n == -1)
{
throw_exception (
env,
ase_awk_geterrmsg(awk),
ase_awk_geterrnum(awk),
ase_awk_geterrlin(awk));
}
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc ( JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
@ -2021,11 +2002,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2037,11 +2014,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2055,49 +2028,41 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
} }
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
if (n == -1) THROW_AWK_EXCEPTION (env, awk);
if (n == -1)
{
throw_exception (
env,
ase_awk_geterrmsg(awk),
ase_awk_geterrnum(awk),
ase_awk_geterrlin(awk));
}
} }
JNIEXPORT jint JNICALL Java_ase_awk_Awk_getmaxdepth (JNIEnv* env, jobject obj, jlong awkid, jint id) JNIEXPORT jint JNICALL Java_ase_awk_Awk_getmaxdepth (JNIEnv* env, jobject obj, jlong awkid, jint id)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK_RETURNING (awk, 0); EXCEPTION_ON_NULL_AWK_RETURNING (env, awk, 0);
return (jint)ase_awk_getmaxdepth (awk, id); return (jint)ase_awk_getmaxdepth (awk, id);
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_setmaxdepth (JNIEnv* env, jobject obj, jlong awkid, jint ids, jint depth) JNIEXPORT void JNICALL Java_ase_awk_Awk_setmaxdepth (JNIEnv* env, jobject obj, jlong awkid, jint ids, jint depth)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
ase_awk_setmaxdepth (awk, ids, depth); ase_awk_setmaxdepth (awk, ids, depth);
} }
JNIEXPORT jint JNICALL Java_ase_awk_Awk_getoption (JNIEnv* env, jobject obj, jlong awkid) JNIEXPORT jint JNICALL Java_ase_awk_Awk_getoption (JNIEnv* env, jobject obj, jlong awkid)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK_RETURNING (awk, 0); EXCEPTION_ON_NULL_AWK_RETURNING (env, awk, 0);
return ase_awk_getoption (awk); return ase_awk_getoption (awk);
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_setoption (JNIEnv* env, jobject obj, jlong awkid, jint options) JNIEXPORT void JNICALL Java_ase_awk_Awk_setoption (JNIEnv* env, jobject obj, jlong awkid, jint options)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
ase_awk_setoption (awk, (int)options); ase_awk_setoption (awk, (int)options);
} }
JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug (JNIEnv* env, jobject obj, jlong awkid) JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug (JNIEnv* env, jobject obj, jlong awkid)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK_RETURNING (awk, JNI_FALSE); EXCEPTION_ON_NULL_AWK_RETURNING (env, awk, JNI_FALSE);
return ((awk_data_t*)ase_awk_getcustomdata(awk))->debug? JNI_TRUE: JNI_FALSE; return ((awk_data_t*)ase_awk_getcustomdata(awk))->debug? JNI_TRUE: JNI_FALSE;
} }
@ -2105,7 +2070,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug (
JNIEnv* env, jobject obj, jlong awkid, jboolean debug) JNIEnv* env, jobject obj, jlong awkid, jboolean debug)
{ {
ase_awk_t* awk = (ase_awk_t*)awkid; ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
((awk_data_t*)ase_awk_getcustomdata(awk))->debug = debug; ((awk_data_t*)ase_awk_getcustomdata(awk))->debug = debug;
} }
@ -2119,7 +2084,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
jint r; jint r;
awk = (ase_awk_t*) awkid; awk = (ase_awk_t*) awkid;
EXCEPTION_ON_NULL_AWK (awk); EXCEPTION_ON_NULL_AWK (env, awk);
if (ow != NULL) if (ow != NULL)
{ {
@ -2128,11 +2093,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (op == NULL) if (op == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
} }
@ -2146,11 +2107,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (ow != NULL) if (ow != NULL)
(*env)->ReleaseStringChars (env, ow, op); (*env)->ReleaseStringChars (env, ow, op);
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
} }
@ -2164,11 +2121,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np); if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op); if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2187,11 +2140,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np); if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op); if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2207,14 +2156,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np); if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op); if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
if (r == -1) if (r == -1) THROW_AWK_EXCEPTION (env, awk);
{
throw_exception (
env,
ase_awk_geterrmsg(awk),
ase_awk_geterrnum(awk),
ase_awk_geterrlin(awk));
}
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename ( JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
@ -2232,11 +2174,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2248,12 +2186,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2268,14 +2201,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
if (n == -1) if (n == -1) THROW_RUN_EXCEPTION (env, run);
{
throw_exception (
env,
ase_awk_getrunerrmsg(run),
ase_awk_getrunerrnum(run),
ase_awk_getrunerrlin(run));
}
} }
JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename ( JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
@ -2293,11 +2219,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2309,12 +2231,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return; return;
} }
@ -2329,14 +2246,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
(*env)->ReleaseStringChars (env, name, ptr); (*env)->ReleaseStringChars (env, name, ptr);
if (n == -1) if (n == -1) THROW_RUN_EXCEPTION (env, run);
{
throw_exception (
env,
ase_awk_getrunerrmsg(run),
ase_awk_getrunerrnum(run),
ase_awk_getrunerrlin(run));
}
} }
static jstring JNICALL call_strftime ( static jstring JNICALL call_strftime (
@ -2370,11 +2280,7 @@ static jstring JNICALL call_strftime (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL; return NULL;
} }
@ -2382,11 +2288,7 @@ static jstring JNICALL call_strftime (
if (tmp == NULL) if (tmp == NULL)
{ {
(*env)->ReleaseStringChars (env, fmt, ptr); (*env)->ReleaseStringChars (env, fmt, ptr);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL; return NULL;
} }
@ -2403,11 +2305,7 @@ static jstring JNICALL call_strftime (
tmp2 = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len); tmp2 = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len);
if (tmp2 == NULL) if (tmp2 == NULL)
{ {
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return NULL; return NULL;
} }
for (i = 0; i < len; i++) tmp2[i] = (jchar)buf[i]; for (i = 0; i < len; i++) tmp2[i] = (jchar)buf[i];
@ -2422,12 +2320,7 @@ static jstring JNICALL call_strftime (
if (ret == NULL) if (ret == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
THROW_NOMEM_EXCEPTION (env);
throw_exception (
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
} }
return ret; return ret;
@ -2495,11 +2388,7 @@ JNIEXPORT jint JNICALL Java_ase_awk_Awk_system (
if (ptr == NULL) if (ptr == NULL)
{ {
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return -1; return -1;
} }
@ -2507,11 +2396,7 @@ JNIEXPORT jint JNICALL Java_ase_awk_Awk_system (
if (tmp == NULL) if (tmp == NULL)
{ {
(*env)->ReleaseStringChars (env, cmd, ptr); (*env)->ReleaseStringChars (env, cmd, ptr);
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return -1; return -1;
} }
@ -2556,20 +2441,13 @@ JNIEXPORT jlong JNICALL Java_ase_awk_Argument_getintval (JNIEnv* env, jobject ob
{ {
ase_awk_run_t* run = (ase_awk_run_t*)runid; ase_awk_run_t* run = (ase_awk_run_t*)runid;
int n; int n;
ase_long_t lv; ase_long_t lv = 0;
ase_real_t rv; ase_real_t rv = 0.0;
n = ase_awk_valtonum ( n = ase_awk_valtonum (
(ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv); (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv);
if (n == -1) if (n == -1) THROW_RUN_EXCEPTION (env, run);
{ else if (n == 1) lv = (ase_long_t)rv;
throw_exception (
env,
ase_awk_getrunerrmsg(run),
ase_awk_getrunerrnum(run),
ase_awk_getrunerrlin(run));
}
if (n == 1) lv = (ase_long_t)rv;
return (jlong)lv; return (jlong)lv;
} }
@ -2578,20 +2456,13 @@ JNIEXPORT jdouble JNICALL Java_ase_awk_Argument_getrealval (JNIEnv* env, jobject
{ {
ase_awk_run_t* run = (ase_awk_run_t*)runid; ase_awk_run_t* run = (ase_awk_run_t*)runid;
int n; int n;
ase_long_t lv; ase_long_t lv = 0;
ase_real_t rv; ase_real_t rv = 0.0;
n = ase_awk_valtonum ( n = ase_awk_valtonum (
(ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv); (ase_awk_run_t*)runid, (ase_awk_val_t*)valid, &lv, &rv);
if (n == -1) if (n == -1) THROW_RUN_EXCEPTION (env, run);
{ else if (n == 0) rv = (ase_real_t)lv;
throw_exception (
env,
ase_awk_getrunerrmsg(run),
ase_awk_getrunerrnum(run),
ase_awk_getrunerrlin(run));
}
if (n == 0) rv = (ase_real_t)lv;
return (jdouble)rv; return (jdouble)rv;
} }
@ -2610,11 +2481,7 @@ JNIEXPORT jstring JNICALL Java_ase_awk_Argument_getstrval (JNIEnv* env, jobject
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len);
if (str == ASE_NULL) if (str == ASE_NULL)
{ {
throw_exception ( THROW_RUN_EXCEPTION (env, run);
env,
ase_awk_getrunerrmsg(run),
ase_awk_getrunerrnum(run),
ase_awk_getrunerrlin(run));
return ret; return ret;
} }
@ -2649,11 +2516,7 @@ nomem:
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
} }
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
} }
return ret; return ret;
@ -2662,7 +2525,7 @@ nomem:
JNIEXPORT jboolean JNICALL Java_ase_awk_Argument_isindexed (JNIEnv* env, jobject obj, jlong runid, jlong valid) JNIEXPORT jboolean JNICALL Java_ase_awk_Argument_isindexed (JNIEnv* env, jobject obj, jlong runid, jlong valid)
{ {
ase_awk_val_t* val = (ase_awk_val_t*)valid; ase_awk_val_t* val = (ase_awk_val_t*)valid;
return (val->type == ASE_AWK_VAL_MAP)? JNI_TRUE: JNI_FALSE; return (ASE_AWK_VAL_TYPE(val) == ASE_AWK_VAL_MAP)? JNI_TRUE: JNI_FALSE;
} }
JNIEXPORT jobject JNICALL Java_ase_awk_Argument_getindexed (JNIEnv* env, jobject obj, jlong runid, jlong valid, jstring index) JNIEXPORT jobject JNICALL Java_ase_awk_Argument_getindexed (JNIEnv* env, jobject obj, jlong runid, jlong valid, jstring index)
@ -2678,7 +2541,7 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Argument_getindexed (JNIEnv* env, jobject
ase_char_t* rptr; ase_char_t* rptr;
ase_size_t len; ase_size_t len;
if (val->type != ASE_AWK_VAL_MAP) return ASE_NULL; if (ASE_AWK_VAL_TYPE(val) != ASE_AWK_VAL_MAP) return ASE_NULL;
len = (*env)->GetStringLength (env, index); len = (*env)->GetStringLength (env, index);
ptr = (*env)->GetStringChars (env, index, JNI_FALSE); ptr = (*env)->GetStringChars (env, index, JNI_FALSE);
@ -2718,12 +2581,7 @@ nomem:
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
} }
throw_exception ( THROW_NOMEM_EXCEPTION (env);
env,
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
ASE_AWK_ENOMEM,
0);
return ASE_NULL; return ASE_NULL;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.h,v 1.6 2007/09/23 16:48:55 bacon Exp $ * $Id: val.h,v 1.7 2007/10/20 15:06:26 bacon Exp $
* *
* {License} * {License}
*/ */
@ -14,6 +14,7 @@
#include <ase/cmn/str.h> #include <ase/cmn/str.h>
#include <ase/awk/map.h> #include <ase/awk/map.h>
enum ase_awk_val_type_t enum ase_awk_val_type_t
{ {
/* the values between ASE_AWK_VAL_NIL and ASE_AWK_VAL_STR inclusive /* the values between ASE_AWK_VAL_NIL and ASE_AWK_VAL_STR inclusive
@ -78,6 +79,7 @@ typedef struct ase_awk_nde_int_t ase_awk_nde_int_t;
typedef struct ase_awk_nde_real_t ase_awk_nde_real_t; typedef struct ase_awk_nde_real_t ase_awk_nde_real_t;
#endif #endif
#define ASE_AWK_VAL_TYPE(x) ((x)->type)
struct ase_awk_val_t struct ase_awk_val_t
{ {