jni.cc (_Jv_JNI_PopLocalFrame): Leave loop when `n == NULL'.
* jni.cc (_Jv_JNI_PopLocalFrame): Leave loop when `n == NULL'. (_Jv_JNI_conversion_call): _Jv_JNI_PopLocalFrame will never leave `locals == NULL'. (wrap_value): New function. (_Jv_JNI_CallAnyMethodV): Use it. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_GetField): Use wrap_value; removed specialized version. (_Jv_JNI_GetStaticField): Likewise. From-SVN: r31736
This commit is contained in:
parent
5dc489c190
commit
ee7f72e41f
2 changed files with 43 additions and 44 deletions
|
@ -1,5 +1,14 @@
|
||||||
2000-02-01 Tom Tromey <tromey@cygnus.com>
|
2000-02-01 Tom Tromey <tromey@cygnus.com>
|
||||||
|
|
||||||
|
* jni.cc (_Jv_JNI_PopLocalFrame): Leave loop when `n == NULL'.
|
||||||
|
(_Jv_JNI_conversion_call): _Jv_JNI_PopLocalFrame will never leave
|
||||||
|
`locals == NULL'.
|
||||||
|
(wrap_value): New function.
|
||||||
|
(_Jv_JNI_CallAnyMethodV): Use it.
|
||||||
|
(_Jv_JNI_CallAnyMethodA): Likewise.
|
||||||
|
(_Jv_JNI_GetField): Use wrap_value; removed specialized version.
|
||||||
|
(_Jv_JNI_GetStaticField): Likewise.
|
||||||
|
|
||||||
* jni.cc (_Jv_JNI_GetField): Specialize for jobject.
|
* jni.cc (_Jv_JNI_GetField): Specialize for jobject.
|
||||||
(_Jv_JNI_GetStaticField): Likewise.
|
(_Jv_JNI_GetStaticField): Likewise.
|
||||||
|
|
||||||
|
|
|
@ -255,15 +255,35 @@ _Jv_JNI_PopLocalFrame (JNIEnv *env, jobject result)
|
||||||
// must not free it. However, we must be sure to clear all its
|
// must not free it. However, we must be sure to clear all its
|
||||||
// elements, since we might conceivably reuse it.
|
// elements, since we might conceivably reuse it.
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
memset (&rf->vec[0], 0, rf->size * sizeof (jobject));
|
{
|
||||||
else
|
memset (&rf->vec[0], 0, rf->size * sizeof (jobject));
|
||||||
_Jv_Free (rf);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Jv_Free (rf);
|
||||||
rf = n;
|
rf = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result == NULL ? NULL : _Jv_JNI_NewLocalRef (env, result);
|
return result == NULL ? NULL : _Jv_JNI_NewLocalRef (env, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function is used from other template functions. It wraps the
|
||||||
|
// return value appropriately; we specialize it so that object returns
|
||||||
|
// are turned into local references.
|
||||||
|
template<typename T>
|
||||||
|
static T
|
||||||
|
wrap_value (JNIEnv *, T value)
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
static jobject
|
||||||
|
wrap_value (JNIEnv *env, jobject value)
|
||||||
|
{
|
||||||
|
return _Jv_JNI_NewLocalRef (env, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
|
@ -533,16 +553,8 @@ _Jv_JNI_CallAnyMethodV (JNIEnv *env, jobject obj, jclass klass,
|
||||||
if (ex != NULL)
|
if (ex != NULL)
|
||||||
env->ex = ex;
|
env->ex = ex;
|
||||||
|
|
||||||
if (! return_type->isPrimitive ())
|
|
||||||
{
|
|
||||||
// Make sure we create a local reference. The cast hackery is
|
|
||||||
// to avoid problems for template instantations we know won't be
|
|
||||||
// used.
|
|
||||||
return (T) (long long) _Jv_JNI_NewLocalRef (env, result.l);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cheat a little here. FIXME.
|
// We cheat a little here. FIXME.
|
||||||
return * (T *) &result;
|
return wrap_value (env, * (T *) &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, invocation_type style>
|
template<typename T, invocation_type style>
|
||||||
|
@ -585,16 +597,8 @@ _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass,
|
||||||
if (ex != NULL)
|
if (ex != NULL)
|
||||||
env->ex = ex;
|
env->ex = ex;
|
||||||
|
|
||||||
if (! return_type->isPrimitive ())
|
|
||||||
{
|
|
||||||
// Make sure we create a local reference. The cast hackery is
|
|
||||||
// to avoid problems for template instantations we know won't be
|
|
||||||
// used.
|
|
||||||
return (T) (long long) _Jv_JNI_NewLocalRef (env, result.l);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cheat a little here. FIXME.
|
// We cheat a little here. FIXME.
|
||||||
return * (T *) &result;
|
return wrap_value (env, * (T *) &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<invocation_type style>
|
template<invocation_type style>
|
||||||
|
@ -813,18 +817,10 @@ _Jv_JNI_NewObjectA (JNIEnv *env, jclass klass, jmethodID id,
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T
|
static T
|
||||||
_Jv_JNI_GetField (JNIEnv *, jobject obj, jfieldID field)
|
_Jv_JNI_GetField (JNIEnv *env, jobject obj, jfieldID field)
|
||||||
{
|
{
|
||||||
T *ptr = (T *) ((char *) obj + field->getOffset ());
|
T *ptr = (T *) ((char *) obj + field->getOffset ());
|
||||||
return *ptr;
|
return wrap_value (env, *ptr);
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
static jobject
|
|
||||||
_Jv_JNI_GetField<jobject> (JNIEnv *env, jobject obj, jfieldID field)
|
|
||||||
{
|
|
||||||
jobject *ptr = (jobject *) ((char *) obj + field->getOffset ());
|
|
||||||
return _Jv_JNI_NewLocalRef (env, *ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -886,21 +882,12 @@ _Jv_JNI_GetAnyFieldID (JNIEnv *env, jclass clazz,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: local reference
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T
|
static T
|
||||||
_Jv_JNI_GetStaticField (JNIEnv *, jclass, jfieldID field)
|
_Jv_JNI_GetStaticField (JNIEnv *env, jclass, jfieldID field)
|
||||||
{
|
{
|
||||||
T *ptr = (T *) field->u.addr;
|
T *ptr = (T *) field->u.addr;
|
||||||
return *ptr;
|
return wrap_value (env, *ptr);
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
static jobject
|
|
||||||
_Jv_JNI_GetStaticField<jobject> (JNIEnv *env, jclass, jfieldID field)
|
|
||||||
{
|
|
||||||
jobject *ptr = (jobject *) field->u.addr;
|
|
||||||
return _Jv_JNI_NewLocalRef (env, *ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -1240,8 +1227,11 @@ _Jv_JNI_conversion_call (fixme)
|
||||||
|
|
||||||
T result = FIXME_ffi_call (args);
|
T result = FIXME_ffi_call (args);
|
||||||
|
|
||||||
while (env.locals != NULL)
|
do
|
||||||
_Jv_JNI_PopLocalFrame (&env, result);
|
{
|
||||||
|
_Jv_JNI_PopLocalFrame (&env, result);
|
||||||
|
}
|
||||||
|
while (env.locals != frame);
|
||||||
|
|
||||||
if (env.ex)
|
if (env.ex)
|
||||||
JvThrow (env.ex);
|
JvThrow (env.ex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue