Reorganize bindings methods. Also, properly check error conditions in those methods.

Original committer: pedemont%us.ibm.com
Original revision: 1.21
Original date: 2005/01/14 00:09:49
This commit is contained in:
pedemont%us.ibm.com 2006-09-27 15:17:17 +00:00
Родитель 484d50a14a
Коммит d60b55986b
1 изменённых файлов: 14 добавлений и 9 удалений

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

@ -53,7 +53,7 @@ nsJavaXPTCStub::nsJavaXPTCStub(JNIEnv* aJavaEnv, jobject aJavaObject,
{ {
mJavaObject = aJavaEnv->NewGlobalRef(aJavaObject); mJavaObject = aJavaEnv->NewGlobalRef(aJavaObject);
#ifdef DEBUG #ifdef DEBUG_pedemonte
jboolean isCopy = PR_FALSE; jboolean isCopy = PR_FALSE;
jstring name; jstring name;
const char* javaObjectName = nsnull; const char* javaObjectName = nsnull;
@ -85,7 +85,7 @@ nsJavaXPTCStub::nsJavaXPTCStub(JNIEnv* aJavaEnv, jobject aJavaObject,
nsJavaXPTCStub::~nsJavaXPTCStub() nsJavaXPTCStub::~nsJavaXPTCStub()
{ {
#ifdef DEBUG #ifdef DEBUG_pedemonte
jboolean isCopy = PR_FALSE; jboolean isCopy = PR_FALSE;
jstring name; jstring name;
const char* javaObjectName = nsnull; const char* javaObjectName = nsnull;
@ -108,7 +108,7 @@ nsJavaXPTCStub::~nsJavaXPTCStub()
delete (nsJavaXPTCStub*) mChildren[i]; delete (nsJavaXPTCStub*) mChildren[i];
} }
RemoveJavaXPCOMBinding(mJavaEnv, mJavaObject, this); gBindings->RemoveBinding(mJavaEnv, mJavaObject, this);
} }
mJavaEnv->DeleteGlobalRef(mJavaObject); mJavaEnv->DeleteGlobalRef(mJavaObject);
@ -205,9 +205,10 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
} }
// construct IID string // construct IID string
jstring iid_jstr = nsnull;
char* iid_str = aIID.ToString(); char* iid_str = aIID.ToString();
if (iid_str) { if (iid_str) {
jstring iid_jstr = mJavaEnv->NewStringUTF(iid_str); iid_jstr = mJavaEnv->NewStringUTF(iid_str);
} }
if (!iid_str || !iid_jstr) { if (!iid_str || !iid_jstr) {
mJavaEnv->ExceptionClear(); mJavaEnv->ExceptionClear();
@ -312,7 +313,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
const nsXPTMethodInfo *aMethodInfo, const nsXPTMethodInfo *aMethodInfo,
nsXPTCMiniVariant *aParams) nsXPTCMiniVariant *aParams)
{ {
#ifdef DEBUG #ifdef DEBUG_pedemonte
const char* ifaceName; const char* ifaceName;
mIInfo->GetNameShared(&ifaceName); mIInfo->GetNameShared(&ifaceName);
LOG(("nsJavaXPTCStub::CallMethod [%s::%s]\n", ifaceName, aMethodInfo->GetName())); LOG(("nsJavaXPTCStub::CallMethod [%s::%s]\n", ifaceName, aMethodInfo->GetName()));
@ -820,7 +821,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
jobject java_stub = nsnull; jobject java_stub = nsnull;
if (xpcom_obj) { if (xpcom_obj) {
java_stub = GetMatchingJavaObject(mJavaEnv, xpcom_obj); java_stub = gBindings->GetJavaObject(mJavaEnv, xpcom_obj);
if (java_stub == nsnull) { if (java_stub == nsnull) {
// wrap xpcom instance // wrap xpcom instance
@ -845,7 +846,9 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
if (java_stub) { if (java_stub) {
// Associate XPCOM object w/ Java stub // Associate XPCOM object w/ Java stub
AddJavaXPCOMBinding(mJavaEnv, java_stub, inst); rv = gBindings->AddBinding(mJavaEnv, java_stub, inst);
if (NS_FAILED(rv))
break;
} }
} }
} }
@ -1366,7 +1369,7 @@ nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
nsISupports** variant = NS_STATIC_CAST(nsISupports**, aVariant.val.p); nsISupports** variant = NS_STATIC_CAST(nsISupports**, aVariant.val.p);
if (java_obj) { if (java_obj) {
// Check if we already have a corresponding XPCOM object // Check if we already have a corresponding XPCOM object
void* inst = GetMatchingXPCOMObject(mJavaEnv, java_obj); void* inst = gBindings->GetXPCOMObject(mJavaEnv, java_obj);
// Get IID for this param // Get IID for this param
nsID iid; nsID iid;
@ -1394,7 +1397,9 @@ nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
break; break;
} }
inst = SetAsXPTCStub(xpcomStub); inst = SetAsXPTCStub(xpcomStub);
AddJavaXPCOMBinding(mJavaEnv, java_obj, inst); rv = gBindings->AddBinding(mJavaEnv, java_obj, inst);
if (NS_FAILED(rv))
break;
} }
// Get appropriate XPCOM object // Get appropriate XPCOM object