*not part of the build*
fix for 86789 git-svn-id: svn://10.0.0.236/trunk@97937 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -34,7 +34,7 @@ jclass bcJavaStub::objectClass = NULL;
|
||||
jclass bcJavaStub::utilitiesClass = NULL;
|
||||
jmethodID bcJavaStub::callMethodByIndexMID = NULL;
|
||||
|
||||
bcJavaStub::bcJavaStub(jobject obj) {
|
||||
bcJavaStub::bcJavaStub(jobject obj) : orb(NULL) {
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcJavaStub::bcJavaStub \n"));
|
||||
if (!obj) {
|
||||
@@ -43,11 +43,24 @@ bcJavaStub::bcJavaStub(jobject obj) {
|
||||
}
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
object = env->NewGlobalRef(obj);
|
||||
refCounter = 0;
|
||||
}
|
||||
|
||||
|
||||
bcJavaStub::~bcJavaStub() {
|
||||
bcJavaGlobal::GetJNIEnv()->DeleteGlobalRef(object);
|
||||
if (orb != NULL) {
|
||||
orb->UnregisterStub(oid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bcJavaStub::SetORB(bcIORB *_orb) {
|
||||
orb = _orb;
|
||||
}
|
||||
|
||||
void bcJavaStub::SetOID(bcOID _oid) {
|
||||
oid = _oid;
|
||||
}
|
||||
|
||||
void bcJavaStub::Dispatch(bcICall *call) {
|
||||
@@ -57,6 +70,20 @@ void bcJavaStub::Dispatch(bcICall *call) {
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
jobjectArray args;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
|
||||
if (mid == 1) { //AddRef
|
||||
refCounter++;
|
||||
return;
|
||||
} else if (mid == 2) { //Release
|
||||
refCounter--;
|
||||
printf("-java mid==2\n");
|
||||
if (refCounter <= 0) {
|
||||
printf("-java delete\n");
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if((iimgr = XPTI_GetInterfaceInfoManager()) != NULL) {
|
||||
|
||||
@@ -31,8 +31,13 @@ class bcJavaStub : public bcIStub {
|
||||
bcJavaStub(jobject obj);
|
||||
virtual ~bcJavaStub();
|
||||
virtual void Dispatch(bcICall *call) ;
|
||||
virtual void SetORB(bcIORB *orb);
|
||||
virtual void SetOID(bcOID oid);
|
||||
private:
|
||||
bcIORB *orb;
|
||||
bcOID oid;
|
||||
jobject object;
|
||||
PRUint32 refCounter;
|
||||
static jclass objectClass;
|
||||
static jclass utilitiesClass;
|
||||
static jmethodID callMethodByIndexMID;
|
||||
|
||||
@@ -52,8 +52,15 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
str = env->GetStringUTFChars(jiid,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jiid,str);
|
||||
if (mid == 2) {
|
||||
INVOKE_RELEASE(&oid,&iid,orb);
|
||||
return NULL;
|
||||
} else if (mid == 1) {
|
||||
INVOKE_ADDREF(&oid,&iid,orb);
|
||||
return NULL;
|
||||
}
|
||||
bcICall *call = orb->CreateCall(&iid, &oid, mid);
|
||||
|
||||
|
||||
/*****/
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
|
||||
Reference in New Issue
Block a user