Merging the following javaxpcom+xulrunner bugs to the 1.8 branches: 302099, 305815, 315401, 272662, 316098, 316090, 320441, 320449, 320574, 317012, 315917, 311240 - all these bugs are either javaxpcom-only, xulrunner-only, or a=drivers (xpcom glue changes only which do not affect firefox/thunderbird)
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@187179 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsJavaInterfaces.h"
|
||||
#include "nsJavaWrapper.h"
|
||||
#include "nsJavaXPTCStub.h"
|
||||
#include "nsJavaXPCOMBindingUtils.h"
|
||||
@@ -44,8 +45,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#define JAVAPROXY_NATIVE(func) Java_org_mozilla_xpcom_XPCOMJavaProxy_##func
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
static nsID nullID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
|
||||
@@ -137,7 +137,7 @@ CreateJavaArray(JNIEnv* env, PRUint8 aType, PRUint32 aSize, const nsID& aIID,
|
||||
}
|
||||
|
||||
case nsXPTType::T_VOID:
|
||||
array = env->NewIntArray(aSize);
|
||||
array = env->NewLongArray(aSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -226,7 +226,7 @@ GetNativeArrayElement(PRUint8 aType, void* aArray, PRUint32 aIndex,
|
||||
break;
|
||||
|
||||
case nsXPTType::T_VOID:
|
||||
aResult->val.u32 = NS_STATIC_CAST(PRUint32*, aArray)[aIndex];
|
||||
aResult->val.p = NS_STATIC_CAST(void**, aArray)[aIndex];
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -296,7 +296,7 @@ CreateNativeArray(PRUint8 aType, PRUint32 aSize, void** aResult)
|
||||
break;
|
||||
|
||||
case nsXPTType::T_VOID:
|
||||
array = PR_Malloc(aSize * sizeof(PRUint32));
|
||||
array = PR_Malloc(aSize * sizeof(void*));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -849,16 +849,16 @@ SetupParams(JNIEnv *env, const jobject aParam, PRUint8 aType, PRBool aIsOut,
|
||||
break;
|
||||
}
|
||||
|
||||
// handle "void *" as an "int" in Java
|
||||
// handle "void *" as an "long" in Java
|
||||
case nsXPTType::T_VOID:
|
||||
{
|
||||
LOG(("int (void*)\n"));
|
||||
LOG(("long (void*)\n"));
|
||||
if (!aIsOut && !aIsArrayElement) { // 'in'
|
||||
aVariant.val.p = (void*) env->CallIntMethod(aParam, intValueMID);
|
||||
aVariant.val.p = (void*) env->CallLongMethod(aParam, longValueMID);
|
||||
} else { // 'inout' & 'array'
|
||||
jint value;
|
||||
jlong value;
|
||||
if (aParam) {
|
||||
env->GetIntArrayRegion((jintArray) aParam, aIndex, 1, &value);
|
||||
env->GetLongArrayRegion((jlongArray) aParam, aIndex, 1, &value);
|
||||
}
|
||||
|
||||
if (aIsOut) { // 'inout'
|
||||
@@ -870,7 +870,7 @@ SetupParams(JNIEnv *env, const jobject aParam, PRUint8 aType, PRBool aIsOut,
|
||||
}
|
||||
aVariant.SetPtrIsData();
|
||||
} else { // 'array'
|
||||
NS_STATIC_CAST(PRUint32*, aVariant.val.p)[aIndex] = value;
|
||||
NS_STATIC_CAST(void**, aVariant.val.p)[aIndex] = (void*) value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1216,11 +1216,11 @@ FinalizeParams(JNIEnv *env, const nsXPTParamInfo &aParamInfo, PRUint8 aType,
|
||||
case nsXPTType::T_VOID:
|
||||
{
|
||||
if (NS_SUCCEEDED(aInvokeResult)) {
|
||||
jint value = NS_REINTERPRET_CAST(jint, aVariant.val.p);
|
||||
jlong value = NS_REINTERPRET_CAST(jlong, aVariant.val.p);
|
||||
if (aParamInfo.IsRetval() && !aIsArrayElement) {
|
||||
*aParam = env->NewObject(intClass, intInitMID, value);
|
||||
*aParam = env->NewObject(longClass, longInitMID, value);
|
||||
} else if ((aParamInfo.IsOut() || aIsArrayElement) && *aParam) {
|
||||
env->SetIntArrayRegion((jintArray) *aParam, aIndex, 1, &value);
|
||||
env->SetLongArrayRegion((jlongArray) *aParam, aIndex, 1, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1378,9 +1378,9 @@ QueryMethodInfo(nsIInterfaceInfo* aIInfo, const char* aMethodName,
|
||||
}
|
||||
|
||||
/**
|
||||
* org.mozilla.xpcom.XPCOMJavaProxy.callXPCOMMethod
|
||||
* org.mozilla.xpcom.XPCOMJavaProxy.internal.callXPCOMMethod
|
||||
*/
|
||||
extern "C" JX_EXPORT jobject JNICALL
|
||||
extern "C" NS_EXPORT jobject
|
||||
JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||
jstring aMethodName, jobjectArray aParams)
|
||||
{
|
||||
@@ -1518,9 +1518,17 @@ JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||
}
|
||||
|
||||
// Call the XPCOM method
|
||||
nsresult invokeResult;
|
||||
invokeResult = XPTC_InvokeByIndex(inst->GetInstance(), methodIndex,
|
||||
paramCount, params);
|
||||
const nsIID* iid;
|
||||
iinfo->GetIIDShared(&iid);
|
||||
nsISupports* realObject;
|
||||
rv = inst->GetInstance()->QueryInterface(*iid, (void**) &realObject);
|
||||
if (NS_FAILED(rv)) {
|
||||
ThrowException(env, rv, "Failed to get real XPCOM object");
|
||||
return nsnull;
|
||||
}
|
||||
nsresult invokeResult = XPTC_InvokeByIndex(realObject, methodIndex,
|
||||
paramCount, params);
|
||||
NS_RELEASE(realObject);
|
||||
|
||||
// Clean up params
|
||||
jobject result = nsnull;
|
||||
@@ -1684,8 +1692,8 @@ GetXPCOMInstFromProxy(JNIEnv* env, jobject aJavaObject, void** aResult)
|
||||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
long xpcom_obj = env->CallStaticLongMethod(xpcomJavaProxyClass,
|
||||
getNativeXPCOMInstMID, aJavaObject);
|
||||
jlong xpcom_obj = env->CallStaticLongMethod(xpcomJavaProxyClass,
|
||||
getNativeXPCOMInstMID, aJavaObject);
|
||||
|
||||
if (!xpcom_obj || env->ExceptionCheck()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -1707,9 +1715,9 @@ GetXPCOMInstFromProxy(JNIEnv* env, jobject aJavaObject, void** aResult)
|
||||
}
|
||||
|
||||
/**
|
||||
* org.mozilla.xpcom.XPCOMJavaProxy.finalizeProxy
|
||||
* org.mozilla.xpcom.internal.XPCOMJavaProxy.finalizeProxy
|
||||
*/
|
||||
extern "C" JX_EXPORT void JNICALL
|
||||
extern "C" NS_EXPORT void
|
||||
JAVAPROXY_NATIVE(finalizeProxy) (JNIEnv *env, jclass that, jobject aJavaProxy)
|
||||
{
|
||||
#ifdef DEBUG_JAVAXPCOM
|
||||
@@ -1754,3 +1762,26 @@ JAVAPROXY_NATIVE(finalizeProxy) (JNIEnv *env, jclass that, jobject aJavaProxy)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* org.mozilla.xpcom.XPCOMJavaProxy.isSameXPCOMObject
|
||||
*/
|
||||
extern "C" NS_EXPORT jboolean
|
||||
JAVAPROXY_NATIVE(isSameXPCOMObject) (JNIEnv *env, jclass that,
|
||||
jobject aProxy1, jobject aProxy2)
|
||||
{
|
||||
void* xpcom_obj1;
|
||||
nsresult rv = GetXPCOMInstFromProxy(env, aProxy1, &xpcom_obj1);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
void* xpcom_obj2;
|
||||
rv = GetXPCOMInstFromProxy(env, aProxy2, &xpcom_obj2);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
JavaXPCOMInstance* inst1 = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj1);
|
||||
JavaXPCOMInstance* inst2 = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj2);
|
||||
if (inst1->GetInstance() == inst2->GetInstance()) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user