Implement IID for nsJavaXPTCStub. Return associated Java object if returning nsJavaXPTCStub.

Original committer: pedemont%us.ibm.com
Original revision: 1.10
Original date: 2004/10/18 17:04:29
This commit is contained in:
pedemont%us.ibm.com 2006-09-27 15:18:35 +00:00
Родитель dd070f084a
Коммит 45c744033d
1 изменённых файлов: 27 добавлений и 11 удалений

Просмотреть файл

@ -257,18 +257,34 @@ GetMatchingXPCOMObject(JNIEnv* env, jobject aJavaObject)
jobject
GetMatchingJavaObject(JNIEnv* env, void* aXPCOMObject)
{
JavaXPCOMBindingEntry *entry =
NS_STATIC_CAST(JavaXPCOMBindingEntry*,
PL_DHashTableOperate(gXPCOMtoJAVABindings, aXPCOMObject,
PL_DHASH_LOOKUP));
jobject java_obj = nsnull;
nsISupports* xpcom_obj = NS_STATIC_CAST(nsISupports*, aXPCOMObject);
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
LOG("< Get Java<->XPCOM binding (Java=0x%08x | XPCOM=0x%08x)\n",
env->CallIntMethod(entry->mJavaObject, hashCodeMID), (int) aXPCOMObject);
return entry->mJavaObject;
nsJavaXPTCStub* stub = nsnull;
xpcom_obj->QueryInterface(NS_GET_IID(nsJavaXPTCStub), (void**) &stub);
if (stub) {
java_obj = stub->GetJavaObject();
NS_ASSERTION(java_obj != nsnull, "nsJavaXPTCStub w/o matching Java object");
NS_RELEASE(stub);
}
return nsnull;
if (java_obj == nsnull) {
JavaXPCOMBindingEntry *entry =
NS_STATIC_CAST(JavaXPCOMBindingEntry*,
PL_DHashTableOperate(gXPCOMtoJAVABindings, aXPCOMObject,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
java_obj = entry->mJavaObject;
}
}
if (java_obj) {
LOG("< Get Java<->XPCOM binding (Java=0x%08x | XPCOM=0x%08x)\n",
env->CallIntMethod(java_obj, hashCodeMID), (int) aXPCOMObject);
}
return java_obj;
}
@ -364,13 +380,13 @@ InitializeJavaGlobals(JNIEnv *env)
{
return PR_FALSE;
}
if (!(clazz = env->FindClass("org/mozilla/xpcom/XPCOMException")) ||
!(xpcomExceptionClass = (jclass) env->NewGlobalRef(clazz)))
{
return PR_FALSE;
}
if (!(hashCodeMID = env->GetMethodID(objectClass, "hashCode","()I"))) {
return PR_FALSE;
}