From 6a9990e991db7131e00b7ac8e38f4ab2f82c0afd Mon Sep 17 00:00:00 2001 From: Bob Jamison Date: Fri, 21 Mar 2008 19:34:33 +0000 Subject: Start working toward multiple inheritance (bzr r5148) --- src/bind/dobinding.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/bind/dobinding.cpp') diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp index 639e27062..6f9010533 100644 --- a/src/bind/dobinding.cpp +++ b/src/bind/dobinding.cpp @@ -75,29 +75,41 @@ typedef struct //# BASE OBJECT //######################################################################## +static jmethodID _getPointer_id = NULL; + static jlong getPointer(JNIEnv *env, jobject obj) { - jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "_pointer", "J"); - if (!id) + if (!_getPointer_id) { - err("getPointer: %s", EXCEPTION); - return 0; - } - jlong val = env->GetLongField(obj, id); + _getPointer_id = env->GetMethodID(env->GetObjectClass(obj), "getPointer", "()J"); + if (!_getPointer_id) + { + err("getPointer(): %s", EXCEPTION); + return 0; + } + } + jlong val = env->CallLongMethod(obj, _getPointer_id); return val; } + +static jmethodID _setPointer_id = NULL; + static void setPointer(JNIEnv *env, jobject obj, jlong val) { - jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "_pointer", "J"); - if (!id) + if (!_setPointer_id) { - err("setPointer: %s", EXCEPTION); - return; + _setPointer_id = env->GetMethodID(env->GetObjectClass(obj), "setPointer", "(J)V"); + if (!_setPointer_id) + { + err("setPointer(): %s", EXCEPTION); + return; + } } - env->SetLongField(obj, id, val); + env->CallVoidMethod(obj, _setPointer_id, val); } + static void JNICALL BaseObject_construct (JNIEnv *env, jobject obj) { @@ -107,7 +119,7 @@ static void JNICALL BaseObject_construct static void JNICALL BaseObject_destruct (JNIEnv *env, jobject obj) { - NodePtr *ptr = (NodePtr *)getPointer(env, obj); + BaseObject *ptr = (BaseObject *)getPointer(env, obj); if (ptr) { delete ptr; -- cgit v1.2.3