зеркало из https://github.com/mozilla/pjs.git
Bug 349002, try #2 - Refactor xptcall into a frozen API, r=timeless - with OS/2 fixup by Peter Weilbacher
This commit is contained in:
Родитель
72fb08abab
Коммит
7b434c0d06
|
@ -519,7 +519,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
||||||
returnParam.ptr = &returnParam.val;
|
returnParam.ptr = &returnParam.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XPTC_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams);
|
rv = NS_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams);
|
||||||
|
|
||||||
// In case someone is holding on to the txFunctionEvaluationContext which
|
// In case someone is holding on to the txFunctionEvaluationContext which
|
||||||
// could thus stay alive longer than this function.
|
// could thus stay alive longer than this function.
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "xptcall.h"
|
#include "nsXPTCUtils.h"
|
||||||
#include "nsIInterfaceInfo.h"
|
#include "nsIInterfaceInfo.h"
|
||||||
#include "nsIInterfaceInfoManager.h"
|
#include "nsIInterfaceInfoManager.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,7 +49,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// nsXTFInterfaceAggregator class
|
// nsXTFInterfaceAggregator class
|
||||||
|
|
||||||
class nsXTFInterfaceAggregator : public nsXPTCStubBase
|
class nsXTFInterfaceAggregator : protected nsAutoXPTCStub
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
friend nsresult
|
friend nsresult
|
||||||
|
@ -59,18 +60,16 @@ protected:
|
||||||
|
|
||||||
nsXTFInterfaceAggregator(const nsIID& iid,
|
nsXTFInterfaceAggregator(const nsIID& iid,
|
||||||
nsISupports* inner,
|
nsISupports* inner,
|
||||||
nsISupports* outer);
|
nsISupports* outer,
|
||||||
|
nsresult *rv);
|
||||||
~nsXTFInterfaceAggregator();
|
~nsXTFInterfaceAggregator();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// nsISupports interface
|
// nsISupports interface
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// nsXPTCStubBase
|
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
|
||||||
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -84,14 +83,17 @@ private:
|
||||||
|
|
||||||
nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
|
nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
|
||||||
nsISupports* inner,
|
nsISupports* inner,
|
||||||
nsISupports* outer)
|
nsISupports* outer,
|
||||||
: mInner(inner), mOuter(outer), mIID(iid)
|
nsresult *rv)
|
||||||
|
: mInner(inner), mOuter(outer), mIID(iid)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// printf("nsXTFInterfaceAggregator CTOR\n");
|
// printf("nsXTFInterfaceAggregator CTOR\n");
|
||||||
#endif
|
#endif
|
||||||
mInner->AddRef();
|
mInner->AddRef();
|
||||||
mOuter->AddRef();
|
mOuter->AddRef();
|
||||||
|
|
||||||
|
*rv = InitStub(iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXTFInterfaceAggregator::~nsXTFInterfaceAggregator()
|
nsXTFInterfaceAggregator::~nsXTFInterfaceAggregator()
|
||||||
|
@ -112,13 +114,17 @@ NS_NewXTFInterfaceAggregator(const nsIID& iid,
|
||||||
if (!aResult)
|
if (!aResult)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsXTFInterfaceAggregator* result = new nsXTFInterfaceAggregator(iid,inner,outer);
|
nsresult rv;
|
||||||
|
|
||||||
|
nsRefPtr<nsXTFInterfaceAggregator> result =
|
||||||
|
new nsXTFInterfaceAggregator(iid, inner, outer, &rv);
|
||||||
if (!result)
|
if (!result)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
NS_ADDREF(result);
|
if (NS_FAILED(rv))
|
||||||
*aResult = result;
|
return rv;
|
||||||
return NS_OK;
|
|
||||||
|
return result->QueryInterface(iid, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -131,7 +137,7 @@ NS_IMETHODIMP
|
||||||
nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
{
|
{
|
||||||
if(aIID.Equals(mIID)) {
|
if(aIID.Equals(mIID)) {
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
*aInstancePtr = mXPTCStub;
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -141,40 +147,37 @@ nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// nsXPTCStubBase implementation
|
// nsXPTCStubBase implementation
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXTFInterfaceAggregator::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager>
|
|
||||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
|
||||||
NS_ASSERTION(iim, "could not get interface info manager");
|
|
||||||
return iim->GetInfoForIID( &mIID, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXTFInterfaceAggregator::CallMethod(PRUint16 methodIndex,
|
nsXTFInterfaceAggregator::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor *info,
|
||||||
nsXPTCMiniVariant* params)
|
nsXPTCMiniVariant* params)
|
||||||
{
|
{
|
||||||
if (methodIndex < 3) {
|
NS_ASSERTION(methodIndex >= 3,
|
||||||
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFInterfaceAggregator.");
|
"huh? indirect nsISupports method call unexpected");
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare args:
|
// prepare args:
|
||||||
int paramCount = info->GetParamCount();
|
int paramCount = info->num_args;
|
||||||
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
|
nsXPTCVariant* fullPars;
|
||||||
|
if (!paramCount) {
|
||||||
|
fullPars = nsnull;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fullPars = new nsXPTCVariant[paramCount];
|
||||||
|
if (!fullPars)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<paramCount; ++i) {
|
for (int i=0; i<paramCount; ++i) {
|
||||||
const nsXPTParamInfo& paramInfo = info->GetParam(i);
|
const nsXPTParamInfo& paramInfo = info->params[i];
|
||||||
PRUint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
PRUint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
||||||
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the call:
|
// make the call:
|
||||||
nsresult rv = XPTC_InvokeByIndex(mInner,
|
nsresult rv = NS_InvokeByIndex(mInner,
|
||||||
methodIndex,
|
methodIndex,
|
||||||
paramCount,
|
paramCount,
|
||||||
fullPars);
|
fullPars);
|
||||||
if (fullPars)
|
if (fullPars)
|
||||||
delete []fullPars;
|
delete []fullPars;
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "xptcall.h"
|
#include "nsXPTCUtils.h"
|
||||||
#include "nsIInterfaceInfo.h"
|
#include "nsIInterfaceInfo.h"
|
||||||
#include "nsIInterfaceInfoManager.h"
|
#include "nsIInterfaceInfoManager.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,27 +49,21 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// nsXTFWeakTearoff class
|
// nsXTFWeakTearoff class
|
||||||
|
|
||||||
class nsXTFWeakTearoff : public nsXPTCStubBase
|
class nsXTFWeakTearoff : protected nsAutoXPTCStub
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
friend nsresult
|
|
||||||
NS_NewXTFWeakTearoff(const nsIID& iid,
|
|
||||||
nsISupports* obj,
|
|
||||||
nsISupports** result);
|
|
||||||
|
|
||||||
nsXTFWeakTearoff(const nsIID& iid,
|
|
||||||
nsISupports* obj);
|
|
||||||
~nsXTFWeakTearoff();
|
~nsXTFWeakTearoff();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
nsXTFWeakTearoff(const nsIID& iid,
|
||||||
|
nsISupports* obj,
|
||||||
|
nsresult *rv);
|
||||||
|
|
||||||
// nsISupports interface
|
// nsISupports interface
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// nsXPTCStubBase
|
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
|
||||||
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,19 +75,18 @@ private:
|
||||||
// implementation:
|
// implementation:
|
||||||
|
|
||||||
nsXTFWeakTearoff::nsXTFWeakTearoff(const nsIID& iid,
|
nsXTFWeakTearoff::nsXTFWeakTearoff(const nsIID& iid,
|
||||||
nsISupports* obj)
|
nsISupports* obj,
|
||||||
: mObj(obj), mIID(iid)
|
nsresult *rv)
|
||||||
|
: mObj(obj), mIID(iid)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
MOZ_COUNT_CTOR(nsXTFWeakTearoff);
|
||||||
// printf("nsXTFWeakTearoff CTOR\n");
|
|
||||||
#endif
|
*rv = InitStub(iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXTFWeakTearoff::~nsXTFWeakTearoff()
|
nsXTFWeakTearoff::~nsXTFWeakTearoff()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
MOZ_COUNT_DTOR(nsXTFWeakTearoff);
|
||||||
// printf("nsXTFWeakTearoff DTOR\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -103,13 +97,17 @@ NS_NewXTFWeakTearoff(const nsIID& iid,
|
||||||
if (!aResult)
|
if (!aResult)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsXTFWeakTearoff* result = new nsXTFWeakTearoff(iid,obj);
|
nsresult rv;
|
||||||
if (! result)
|
|
||||||
|
nsRefPtr<nsXTFWeakTearoff> result =
|
||||||
|
new nsXTFWeakTearoff(iid, obj, &rv);
|
||||||
|
if (!result)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
NS_ADDREF(result);
|
if (NS_FAILED(rv))
|
||||||
*aResult = result;
|
return rv;
|
||||||
return NS_OK;
|
|
||||||
|
return result->QueryInterface(iid, (void**) aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -122,53 +120,44 @@ NS_IMETHODIMP
|
||||||
nsXTFWeakTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
nsXTFWeakTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
{
|
{
|
||||||
if(aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
if(aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
*aInstancePtr = mXPTCStub;
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
// we can't map QI onto the obj, because the xpcom wrapper otherwise
|
// we can't map QI onto the obj, because the xpcom wrapper otherwise
|
||||||
// QI-accumulates all interfaces defined on mObj
|
// QI-accumulates all interfaces defined on mObj
|
||||||
// else return mObj->QueryInterface(aIID, aInstancePtr);
|
// else return mObj->QueryInterface(aIID, aInstancePtr);
|
||||||
else return NS_ERROR_NO_INTERFACE;
|
return NS_ERROR_NO_INTERFACE;
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// nsXPTCStubBase implementation
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXTFWeakTearoff::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager>
|
|
||||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
|
||||||
NS_ASSERTION(iim, "could not get interface info manager");
|
|
||||||
return iim->GetInfoForIID( &mIID, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXTFWeakTearoff::CallMethod(PRUint16 methodIndex,
|
nsXTFWeakTearoff::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params)
|
nsXPTCMiniVariant* params)
|
||||||
{
|
{
|
||||||
if (methodIndex < 3) {
|
NS_ASSERTION(methodIndex >= 3,
|
||||||
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFWeakTearoff.");
|
"huh? indirect nsISupports method call unexpected");
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare args:
|
// prepare args:
|
||||||
int paramCount = info->GetParamCount();
|
int paramCount = info->num_args;
|
||||||
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
|
nsXPTCVariant* fullPars;
|
||||||
|
if (!paramCount) {
|
||||||
|
fullPars = nsnull;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fullPars = new nsXPTCVariant[paramCount];
|
||||||
|
if (!fullPars)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<paramCount; ++i) {
|
for (int i=0; i<paramCount; ++i) {
|
||||||
const nsXPTParamInfo& paramInfo = info->GetParam(i);
|
const nsXPTParamInfo& paramInfo = info->params[i];
|
||||||
uint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
uint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
||||||
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the call:
|
// make the call:
|
||||||
nsresult rv = XPTC_InvokeByIndex(mObj,
|
nsresult rv = NS_InvokeByIndex(mObj, methodIndex, paramCount, fullPars);
|
||||||
methodIndex,
|
|
||||||
paramCount,
|
|
||||||
fullPars);
|
|
||||||
if (fullPars)
|
if (fullPars)
|
||||||
delete []fullPars;
|
delete []fullPars;
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -1477,8 +1477,8 @@ JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||||
ThrowException(env, rv, "Failed to get real XPCOM object");
|
ThrowException(env, rv, "Failed to get real XPCOM object");
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
nsresult invokeResult = XPTC_InvokeByIndex(realObject, methodIndex,
|
nsresult invokeResult = NS_InvokeByIndex(realObject, methodIndex,
|
||||||
paramCount, params);
|
paramCount, params);
|
||||||
NS_RELEASE(realObject);
|
NS_RELEASE(realObject);
|
||||||
|
|
||||||
// Clean up params
|
// Clean up params
|
||||||
|
|
|
@ -881,8 +881,7 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (stub) {
|
if (stub) {
|
||||||
// stub is already AddRef'd and QI'd
|
// stub is already AddRef'd and QI'd
|
||||||
*aResult = NS_STATIC_CAST(nsISupports*,
|
*aResult = stub->GetStub();
|
||||||
NS_STATIC_CAST(nsXPTCStubBase*, stub));
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,10 +900,14 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Create XPCOM stub
|
// Create XPCOM stub
|
||||||
stub = new nsJavaXPTCStub(aJavaObject, iinfo);
|
stub = new nsJavaXPTCStub(aJavaObject, iinfo, &rv);
|
||||||
if (!stub) {
|
if (!stub)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
delete stub;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = gJavaToXPTCStubMap->Add(hash, stub);
|
rv = gJavaToXPTCStubMap->Add(hash, stub);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
delete stub;
|
delete stub;
|
||||||
|
@ -912,14 +915,14 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ADDREF(stub);
|
NS_ADDREF(stub);
|
||||||
*aResult = NS_STATIC_CAST(nsISupports*,
|
*aResult = stub->GetStub();
|
||||||
NS_STATIC_CAST(nsXPTCStubBase*, stub));
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
||||||
|
const XPTMethodDescriptor *methodInfo,
|
||||||
const nsXPTParamInfo ¶mInfo, PRUint8 paramType,
|
const nsXPTParamInfo ¶mInfo, PRUint8 paramType,
|
||||||
PRUint16 methodIndex, nsXPTCMiniVariant *dispatchParams,
|
PRUint16 methodIndex, nsXPTCMiniVariant *dispatchParams,
|
||||||
PRBool isFullVariantArray, nsID &result)
|
PRBool isFullVariantArray, nsID &result)
|
||||||
|
@ -940,7 +943,7 @@ GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const nsXPTParamInfo& arg_param = methodInfo->GetParam(argnum);
|
const nsXPTParamInfo& arg_param = methodInfo->params[argnum];
|
||||||
const nsXPTType& arg_type = arg_param.GetType();
|
const nsXPTType& arg_type = arg_param.GetType();
|
||||||
|
|
||||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||||
|
|
|
@ -295,7 +295,7 @@ nsresult GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject,
|
||||||
const nsIID& aIID, nsISupports** aResult);
|
const nsIID& aIID, nsISupports** aResult);
|
||||||
|
|
||||||
nsresult GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
nsresult GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
||||||
const nsXPTMethodInfo *methodInfo,
|
const XPTMethodDescriptor *methodInfo,
|
||||||
const nsXPTParamInfo ¶mInfo,
|
const nsXPTParamInfo ¶mInfo,
|
||||||
PRUint8 paramType, PRUint16 methodIndex,
|
PRUint8 paramType, PRUint16 methodIndex,
|
||||||
nsXPTCMiniVariant *dispatchParams,
|
nsXPTCMiniVariant *dispatchParams,
|
||||||
|
|
|
@ -46,12 +46,21 @@
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
|
||||||
|
|
||||||
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo)
|
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
|
||||||
|
nsresult *rv)
|
||||||
: mJavaStrongRef(nsnull)
|
: mJavaStrongRef(nsnull)
|
||||||
, mIInfo(aIInfo)
|
, mIInfo(aIInfo)
|
||||||
, mMaster(nsnull)
|
, mMaster(nsnull)
|
||||||
, mWeakRefCnt(0)
|
, mWeakRefCnt(0)
|
||||||
{
|
{
|
||||||
|
const nsIID *iid = nsnull;
|
||||||
|
aIInfo->GetIIDShared(&iid);
|
||||||
|
NS_ASSERTION(iid, "GetIIDShared must not fail!");
|
||||||
|
|
||||||
|
*rv = InitStub(*iid);
|
||||||
|
if (NS_FAILED(*rv))
|
||||||
|
return;
|
||||||
|
|
||||||
JNIEnv* env = GetJNIEnv();
|
JNIEnv* env = GetJNIEnv();
|
||||||
jobject weakref = env->NewObject(weakReferenceClass,
|
jobject weakref = env->NewObject(weakReferenceClass,
|
||||||
weakReferenceConstructorMID, aJavaObject);
|
weakReferenceConstructorMID, aJavaObject);
|
||||||
|
@ -60,13 +69,10 @@ nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo)
|
||||||
aJavaObject);
|
aJavaObject);
|
||||||
|
|
||||||
#ifdef DEBUG_JAVAXPCOM
|
#ifdef DEBUG_JAVAXPCOM
|
||||||
nsIID* iid;
|
|
||||||
mIInfo->GetInterfaceIID(&iid);
|
|
||||||
char* iid_str = iid->ToString();
|
char* iid_str = iid->ToString();
|
||||||
LOG(("+ nsJavaXPTCStub (Java=%08x | XPCOM=%08x | IID=%s)\n",
|
LOG(("+ nsJavaXPTCStub (Java=%08x | XPCOM=%08x | IID=%s)\n",
|
||||||
(PRUint32) mJavaRefHashCode, (PRUint32) this, iid_str));
|
(PRUint32) mJavaRefHashCode, (PRUint32) this, iid_str));
|
||||||
PR_Free(iid_str);
|
PR_Free(iid_str);
|
||||||
nsMemory::Free(iid);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +242,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
||||||
// always return the master stub for nsISupports
|
// always return the master stub for nsISupports
|
||||||
if (aIID.Equals(NS_GET_IID(nsISupports)))
|
if (aIID.Equals(NS_GET_IID(nsISupports)))
|
||||||
{
|
{
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
|
*aInstancePtr = master->mXPTCStub;
|
||||||
NS_STATIC_CAST(nsXPTCStubBase*, master));
|
|
||||||
NS_ADDREF(master);
|
NS_ADDREF(master);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +259,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
||||||
nsJavaXPTCStub *stub = master->FindStubSupportingIID(aIID);
|
nsJavaXPTCStub *stub = master->FindStubSupportingIID(aIID);
|
||||||
if (stub)
|
if (stub)
|
||||||
{
|
{
|
||||||
*aInstancePtr = stub;
|
*aInstancePtr = stub->mXPTCStub;
|
||||||
NS_ADDREF(stub);
|
NS_ADDREF(stub);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -309,10 +314,15 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
stub = new nsJavaXPTCStub(obj, iinfo);
|
stub = new nsJavaXPTCStub(obj, iinfo, &rv);
|
||||||
if (!stub)
|
if (!stub)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
delete stub;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
// add stub to the master's list of children, so we can preserve
|
// add stub to the master's list of children, so we can preserve
|
||||||
// symmetry in future QI calls. the master will delete each child
|
// symmetry in future QI calls. the master will delete each child
|
||||||
// when it is destroyed. the refcount of each child is bound to
|
// when it is destroyed. the refcount of each child is bound to
|
||||||
|
@ -337,7 +347,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
||||||
stub->mMaster = master;
|
stub->mMaster = master;
|
||||||
master->mChildren.AppendElement(stub);
|
master->mChildren.AppendElement(stub);
|
||||||
|
|
||||||
*aInstancePtr = stub;
|
*aInstancePtr = stub->mXPTCStub;
|
||||||
NS_ADDREF(stub);
|
NS_ADDREF(stub);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -378,22 +388,15 @@ nsJavaXPTCStub::FindStubSupportingIID(const nsID &iid)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsJavaXPTCStub::GetInterfaceInfo(nsIInterfaceInfo **aInfo)
|
|
||||||
{
|
|
||||||
NS_ADDREF(*aInfo = mIInfo);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
const nsXPTMethodInfo *aMethodInfo,
|
const XPTMethodDescriptor *aMethodInfo,
|
||||||
nsXPTCMiniVariant *aParams)
|
nsXPTCMiniVariant *aParams)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_JAVAXPCOM
|
#ifdef DEBUG_JAVAXPCOM
|
||||||
const char* ifaceName;
|
const char* ifaceName;
|
||||||
mIInfo->GetNameShared(&ifaceName);
|
mIInfo->GetNameShared(&ifaceName);
|
||||||
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
|
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
@ -403,7 +406,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
nsCAutoString methodSig("(");
|
nsCAutoString methodSig("(");
|
||||||
|
|
||||||
// Create jvalue array to hold Java params
|
// Create jvalue array to hold Java params
|
||||||
PRUint8 paramCount = aMethodInfo->GetParamCount();
|
PRUint8 paramCount = aMethodInfo->num_args;
|
||||||
jvalue* java_params = nsnull;
|
jvalue* java_params = nsnull;
|
||||||
const nsXPTParamInfo* retvalInfo = nsnull;
|
const nsXPTParamInfo* retvalInfo = nsnull;
|
||||||
if (paramCount) {
|
if (paramCount) {
|
||||||
|
@ -413,7 +416,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
|
|
||||||
for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
|
for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo ¶mInfo = aMethodInfo->GetParam(i);
|
const nsXPTParamInfo ¶mInfo = aMethodInfo->params[i];
|
||||||
if (!paramInfo.IsRetval()) {
|
if (!paramInfo.IsRetval()) {
|
||||||
rv = SetupJavaParams(paramInfo, aMethodInfo, aMethodIndex, aParams,
|
rv = SetupJavaParams(paramInfo, aMethodInfo, aMethodIndex, aParams,
|
||||||
aParams[i], java_params[i], methodSig);
|
aParams[i], java_params[i], methodSig);
|
||||||
|
@ -442,15 +445,16 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
jmethodID mid = nsnull;
|
jmethodID mid = nsnull;
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCAutoString methodName;
|
nsCAutoString methodName;
|
||||||
if (aMethodInfo->IsGetter() || aMethodInfo->IsSetter()) {
|
if (XPT_MD_IS_GETTER(aMethodInfo->flags) ||
|
||||||
if (aMethodInfo->IsGetter())
|
XPT_MD_IS_SETTER(aMethodInfo->flags)) {
|
||||||
|
if (XPT_MD_IS_GETTER(aMethodInfo->flags))
|
||||||
methodName.AppendLiteral("get");
|
methodName.AppendLiteral("get");
|
||||||
else
|
else
|
||||||
methodName.AppendLiteral("set");
|
methodName.AppendLiteral("set");
|
||||||
methodName.AppendASCII(aMethodInfo->GetName());
|
methodName.AppendASCII(aMethodInfo->name);
|
||||||
methodName.SetCharAt(toupper(methodName[3]), 3);
|
methodName.SetCharAt(toupper(methodName[3]), 3);
|
||||||
} else {
|
} else {
|
||||||
methodName.AppendASCII(aMethodInfo->GetName());
|
methodName.AppendASCII(aMethodInfo->name);
|
||||||
methodName.SetCharAt(tolower(methodName[0]), 0);
|
methodName.SetCharAt(tolower(methodName[0]), 0);
|
||||||
}
|
}
|
||||||
// If it's a Java keyword, then prepend an underscore
|
// If it's a Java keyword, then prepend an underscore
|
||||||
|
@ -558,7 +562,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
for (PRUint8 i = 0; i < paramCount; i++)
|
for (PRUint8 i = 0; i < paramCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo ¶mInfo = aMethodInfo->GetParam(i);
|
const nsXPTParamInfo ¶mInfo = aMethodInfo->params[i];
|
||||||
if (paramInfo.IsIn() && !paramInfo.IsOut() && !paramInfo.IsDipper()) // 'in'
|
if (paramInfo.IsIn() && !paramInfo.IsOut() && !paramInfo.IsDipper()) // 'in'
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -586,7 +590,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
#endif
|
#endif
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
|
|
||||||
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
|
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +599,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||||
*/
|
*/
|
||||||
nsresult
|
nsresult
|
||||||
nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor* aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsXPTCMiniVariant &aVariant, jvalue &aJValue,
|
nsXPTCMiniVariant &aVariant, jvalue &aJValue,
|
||||||
|
@ -1059,7 +1063,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor* aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsACString &aRetvalSig)
|
nsACString &aRetvalSig)
|
||||||
|
@ -1169,7 +1173,7 @@ nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
||||||
*/
|
*/
|
||||||
nsresult
|
nsresult
|
||||||
nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor *aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsXPTCMiniVariant &aVariant, jvalue &aJValue)
|
nsXPTCMiniVariant &aVariant, jvalue &aJValue)
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#ifndef _nsJavaXPTCStub_h_
|
#ifndef _nsJavaXPTCStub_h_
|
||||||
#define _nsJavaXPTCStub_h_
|
#define _nsJavaXPTCStub_h_
|
||||||
|
|
||||||
#include "xptcall.h"
|
#include "nsXPTCUtils.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
#include "nsIInterfaceInfo.h"
|
#include "nsIInterfaceInfo.h"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
#define NS_JAVAXPTCSTUB_IID \
|
#define NS_JAVAXPTCSTUB_IID \
|
||||||
{0x88dd8130, 0xebe6, 0x4431, {0x9d, 0xa7, 0xe6, 0xb7, 0x54, 0x74, 0xfb, 0x21}}
|
{0x88dd8130, 0xebe6, 0x4431, {0x9d, 0xa7, 0xe6, 0xb7, 0x54, 0x74, 0xfb, 0x21}}
|
||||||
|
|
||||||
class nsJavaXPTCStub : public nsXPTCStubBase,
|
class nsJavaXPTCStub : protected nsAutoXPTCStub,
|
||||||
public nsSupportsWeakReference
|
public nsSupportsWeakReference
|
||||||
{
|
{
|
||||||
friend class nsJavaXPTCStubWeakRef;
|
friend class nsJavaXPTCStubWeakRef;
|
||||||
|
@ -60,19 +60,18 @@ public:
|
||||||
NS_DECL_NSISUPPORTSWEAKREFERENCE
|
NS_DECL_NSISUPPORTSWEAKREFERENCE
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JAVAXPTCSTUB_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JAVAXPTCSTUB_IID)
|
||||||
|
|
||||||
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo);
|
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
|
||||||
|
nsresult *rv);
|
||||||
|
|
||||||
virtual ~nsJavaXPTCStub();
|
virtual ~nsJavaXPTCStub();
|
||||||
|
|
||||||
// return a refcounted pointer to the InterfaceInfo for this object
|
|
||||||
// NOTE: on some platforms this MUST not fail or we crash!
|
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo **aInfo);
|
|
||||||
|
|
||||||
// call this method and return result
|
// call this method and return result
|
||||||
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
|
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
|
||||||
const nsXPTMethodInfo *aInfo,
|
const XPTMethodDescriptor *aInfo,
|
||||||
nsXPTCMiniVariant *aParams);
|
nsXPTCMiniVariant *aParams);
|
||||||
|
|
||||||
|
nsISomeInterface* GetStub() { return mXPTCStub; }
|
||||||
|
|
||||||
// getter for mJavaObject
|
// getter for mJavaObject
|
||||||
jobject GetJavaObject();
|
jobject GetJavaObject();
|
||||||
|
|
||||||
|
@ -101,18 +100,18 @@ private:
|
||||||
PRBool SupportsIID(const nsID &aIID);
|
PRBool SupportsIID(const nsID &aIID);
|
||||||
|
|
||||||
nsresult SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
nsresult SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor* aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsXPTCMiniVariant &aVariant,
|
nsXPTCMiniVariant &aVariant,
|
||||||
jvalue &aJValue, nsACString &aMethodSig);
|
jvalue &aJValue, nsACString &aMethodSig);
|
||||||
nsresult GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
nsresult GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor* aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsACString &aRetvalSig);
|
nsACString &aRetvalSig);
|
||||||
nsresult FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
nsresult FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||||
const nsXPTMethodInfo* aMethodInfo,
|
const XPTMethodDescriptor* aMethodInfo,
|
||||||
PRUint16 aMethodIndex,
|
PRUint16 aMethodIndex,
|
||||||
nsXPTCMiniVariant* aDispatchParams,
|
nsXPTCMiniVariant* aDispatchParams,
|
||||||
nsXPTCMiniVariant &aVariant,
|
nsXPTCMiniVariant &aVariant,
|
||||||
|
|
|
@ -44,7 +44,7 @@ from xpcom import xpt, COMException, nsError, logger
|
||||||
from xpcom._xpcom import IID_nsISupports, IID_nsIClassInfo, \
|
from xpcom._xpcom import IID_nsISupports, IID_nsIClassInfo, \
|
||||||
IID_nsISupportsCString, IID_nsISupportsString, \
|
IID_nsISupportsCString, IID_nsISupportsString, \
|
||||||
IID_nsISupportsWeakReference, IID_nsIWeakReference, \
|
IID_nsISupportsWeakReference, IID_nsIWeakReference, \
|
||||||
XPTI_GetInterfaceInfoManager, GetComponentManager, XPTC_InvokeByIndex
|
XPTI_GetInterfaceInfoManager, GetComponentManager, NS_InvokeByIndex
|
||||||
|
|
||||||
# Attribute names we may be __getattr__'d for, but know we don't want to delegate
|
# Attribute names we may be __getattr__'d for, but know we don't want to delegate
|
||||||
# Could maybe just look for startswith("__") but this may screw things for some objects.
|
# Could maybe just look for startswith("__") but this may screw things for some objects.
|
||||||
|
@ -60,7 +60,7 @@ _float_interfaces = _just_float_interfaces + _just_long_interfaces + _just_int_i
|
||||||
|
|
||||||
method_template = """
|
method_template = """
|
||||||
def %s(self, %s):
|
def %s(self, %s):
|
||||||
return XPTC_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
|
return NS_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
|
||||||
"""
|
"""
|
||||||
def _MakeMethodCode(method):
|
def _MakeMethodCode(method):
|
||||||
# Build a declaration
|
# Build a declaration
|
||||||
|
@ -457,7 +457,7 @@ class _Interface(_XPCOMBase):
|
||||||
if len(param_infos)!=1: # Only expecting a retval
|
if len(param_infos)!=1: # Only expecting a retval
|
||||||
raise RuntimeError, "Can't get properties with this many args!"
|
raise RuntimeError, "Can't get properties with this many args!"
|
||||||
args = ( param_infos, () )
|
args = ( param_infos, () )
|
||||||
return XPTC_InvokeByIndex(self._comobj_, method_index, args)
|
return NS_InvokeByIndex(self._comobj_, method_index, args)
|
||||||
|
|
||||||
# See if we have a method info waiting to be turned into a method.
|
# See if we have a method info waiting to be turned into a method.
|
||||||
# Do this last as it is a one-off hit.
|
# Do this last as it is a one-off hit.
|
||||||
|
@ -485,7 +485,7 @@ class _Interface(_XPCOMBase):
|
||||||
if len(param_infos)!=1: # Only expecting a single input val
|
if len(param_infos)!=1: # Only expecting a single input val
|
||||||
raise RuntimeError, "Can't set properties with this many args!"
|
raise RuntimeError, "Can't set properties with this many args!"
|
||||||
real_param_infos = ( param_infos, (val,) )
|
real_param_infos = ( param_infos, (val,) )
|
||||||
return XPTC_InvokeByIndex(self._comobj_, method_index, real_param_infos)
|
return NS_InvokeByIndex(self._comobj_, method_index, real_param_infos)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<XPCOM interface '%s'>" % (self._object_name_,)
|
return "<XPCOM interface '%s'>" % (self._object_name_,)
|
||||||
|
|
|
@ -144,7 +144,7 @@ PyXPCOMMethod_XPTI_GetInterfaceInfoManager(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyXPCOMMethod_XPTC_InvokeByIndex(PyObject *self, PyObject *args)
|
PyXPCOMMethod_NS_InvokeByIndex(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *obIS, *obParams;
|
PyObject *obIS, *obParams;
|
||||||
nsCOMPtr<nsISupports> pis;
|
nsCOMPtr<nsISupports> pis;
|
||||||
|
@ -182,7 +182,7 @@ PyXPCOMMethod_XPTC_InvokeByIndex(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
nsresult r;
|
nsresult r;
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
r = XPTC_InvokeByIndex(pis, index, arg_helper.m_num_array, arg_helper.m_var_array);
|
r = NS_InvokeByIndex(pis, index, arg_helper.m_num_array, arg_helper.m_var_array);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
if ( NS_FAILED(r) )
|
if ( NS_FAILED(r) )
|
||||||
return PyXPCOM_BuildPyException(r);
|
return PyXPCOM_BuildPyException(r);
|
||||||
|
@ -435,7 +435,7 @@ static struct PyMethodDef xpcom_methods[]=
|
||||||
{"GetComponentManager", PyXPCOMMethod_GetComponentManager, 1},
|
{"GetComponentManager", PyXPCOMMethod_GetComponentManager, 1},
|
||||||
{"GetComponentRegistrar", PyXPCOMMethod_GetComponentRegistrar, 1},
|
{"GetComponentRegistrar", PyXPCOMMethod_GetComponentRegistrar, 1},
|
||||||
{"XPTI_GetInterfaceInfoManager", PyXPCOMMethod_XPTI_GetInterfaceInfoManager, 1},
|
{"XPTI_GetInterfaceInfoManager", PyXPCOMMethod_XPTI_GetInterfaceInfoManager, 1},
|
||||||
{"XPTC_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
|
{"NS_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
|
||||||
{"GetServiceManager", PyXPCOMMethod_GetServiceManager, 1},
|
{"GetServiceManager", PyXPCOMMethod_GetServiceManager, 1},
|
||||||
{"IID", PyXPCOMMethod_IID, 1}, // IID is wrong - deprecated - not just IID, but CID, etc.
|
{"IID", PyXPCOMMethod_IID, 1}, // IID is wrong - deprecated - not just IID, but CID, etc.
|
||||||
{"ID", PyXPCOMMethod_IID, 1}, // This is the official name.
|
{"ID", PyXPCOMMethod_IID, 1}, // This is the official name.
|
||||||
|
|
|
@ -255,7 +255,7 @@ WSPCallContext::CallCompletionListener()
|
||||||
dispatchParams[1].SetValIsInterface();
|
dispatchParams[1].SetValIsInterface();
|
||||||
dispatchParams[1].type.flags = XPT_TDP_POINTER | TD_INTERFACE_TYPE;
|
dispatchParams[1].type.flags = XPT_TDP_POINTER | TD_INTERFACE_TYPE;
|
||||||
|
|
||||||
rv = XPTC_InvokeByIndex(mAsyncListener, 3, 2, dispatchParams);
|
rv = NS_InvokeByIndex(mAsyncListener, 3, 2, dispatchParams);
|
||||||
}
|
}
|
||||||
else if (mResponse) {
|
else if (mResponse) {
|
||||||
nsCOMPtr<nsIWSDLBinding> binding;
|
nsCOMPtr<nsIWSDLBinding> binding;
|
||||||
|
@ -410,8 +410,8 @@ WSPCallContext::CallCompletionListener()
|
||||||
dispatchParams[paramIndex].type.flags =
|
dispatchParams[paramIndex].type.flags =
|
||||||
XPT_TDP_POINTER | TD_INTERFACE_TYPE;
|
XPT_TDP_POINTER | TD_INTERFACE_TYPE;
|
||||||
|
|
||||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
rv = NS_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||||
paramCount, dispatchParams);
|
paramCount, dispatchParams);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
|
|
|
@ -350,8 +350,8 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
|
rv = NS_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
|
||||||
numParams, var);
|
numParams, var);
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
#include "nsSOAPUtils.h"
|
#include "nsSOAPUtils.h"
|
||||||
|
|
||||||
// interface info includes
|
// interface info includes
|
||||||
#include "xptcall.h"
|
#include "nsXPTCUtils.h"
|
||||||
#include "nsIInterfaceInfo.h"
|
#include "nsIInterfaceInfo.h"
|
||||||
|
|
||||||
// WSDL includes
|
// WSDL includes
|
||||||
|
@ -92,7 +92,7 @@ public:
|
||||||
nsACString& aCIdentifier);
|
nsACString& aCIdentifier);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSPProxy : public nsXPTCStubBase,
|
class WSPProxy : protected nsAutoXPTCStub,
|
||||||
public nsIWebServiceProxy,
|
public nsIWebServiceProxy,
|
||||||
public nsIClassInfo
|
public nsIClassInfo
|
||||||
{
|
{
|
||||||
|
@ -104,11 +104,9 @@ public:
|
||||||
NS_DECL_NSIWEBSERVICEPROXY
|
NS_DECL_NSIWEBSERVICEPROXY
|
||||||
NS_DECL_NSICLASSINFO
|
NS_DECL_NSICLASSINFO
|
||||||
|
|
||||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
|
||||||
|
|
||||||
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
||||||
void CallCompleted(WSPCallContext* aContext);
|
void CallCompleted(WSPCallContext* aContext);
|
||||||
|
@ -252,7 +250,7 @@ protected:
|
||||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSPPropertyBagWrapper : public nsXPTCStubBase,
|
class WSPPropertyBagWrapper : protected nsAutoXPTCStub,
|
||||||
public nsIWebServicePropertyBagWrapper,
|
public nsIWebServicePropertyBagWrapper,
|
||||||
public nsIClassInfo
|
public nsIClassInfo
|
||||||
{
|
{
|
||||||
|
@ -264,11 +262,9 @@ public:
|
||||||
NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
|
NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
|
||||||
NS_DECL_NSICLASSINFO
|
NS_DECL_NSICLASSINFO
|
||||||
|
|
||||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
|
||||||
|
|
||||||
static NS_METHOD
|
static NS_METHOD
|
||||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||||
|
|
|
@ -58,7 +58,9 @@ WSPPropertyBagWrapper::Init(nsIPropertyBag* aPropertyBag,
|
||||||
mPropertyBag = aPropertyBag;
|
mPropertyBag = aPropertyBag;
|
||||||
mInterfaceInfo = aInterfaceInfo;
|
mInterfaceInfo = aInterfaceInfo;
|
||||||
mInterfaceInfo->GetIIDShared(&mIID);
|
mInterfaceInfo->GetIIDShared(&mIID);
|
||||||
return NS_OK;
|
|
||||||
|
nsresult rv = InitStub(*mIID);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD
|
NS_METHOD
|
||||||
|
@ -85,8 +87,11 @@ NS_IMPL_RELEASE(WSPPropertyBagWrapper)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
{
|
{
|
||||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
*aInstancePtr = NS_STATIC_CAST(nsIXPTCProxy*, this);
|
||||||
|
}
|
||||||
|
if(mXPTCStub && mIID && aIID.Equals(*mIID)) {
|
||||||
|
*aInstancePtr = mXPTCStub;
|
||||||
}
|
}
|
||||||
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
|
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
|
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
|
||||||
|
@ -103,7 +108,7 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params)
|
nsXPTCMiniVariant* params)
|
||||||
{
|
{
|
||||||
if (methodIndex < 3) {
|
if (methodIndex < 3) {
|
||||||
|
@ -114,7 +119,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsAutoString propName;
|
nsAutoString propName;
|
||||||
|
|
||||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()), propName);
|
rv = WSPFactory::C2XML(nsDependentCString(info->name), propName);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +131,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||||
if (info->IsGetter()) {
|
if (XPT_MD_IS_GETTER(info->flags)) {
|
||||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
const nsXPTParamInfo& paramInfo = info->params[0];
|
||||||
const nsXPTType& type = paramInfo.GetType();
|
const nsXPTType& type = paramInfo.GetType();
|
||||||
uint8 type_tag = type.TagPart();
|
uint8 type_tag = type.TagPart();
|
||||||
|
|
||||||
|
@ -141,12 +146,12 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
|
|
||||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||||
}
|
}
|
||||||
else if (info->GetParamCount() == 2) {
|
else if (info->num_args == 2) {
|
||||||
// If it's not an explicit getter, it has to be an array getter
|
// If it's not an explicit getter, it has to be an array getter
|
||||||
// method.
|
// method.
|
||||||
|
|
||||||
// The first parameter should be the array length out param
|
// The first parameter should be the array length out param
|
||||||
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
|
const nsXPTParamInfo& paramInfo1 = info->params[0];
|
||||||
const nsXPTType& type1 = paramInfo1.GetType();
|
const nsXPTType& type1 = paramInfo1.GetType();
|
||||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||||
NS_ERROR("Unexpected parameter type for getter");
|
NS_ERROR("Unexpected parameter type for getter");
|
||||||
|
@ -154,7 +159,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The second parameter should be the array out pointer itself.
|
// The second parameter should be the array out pointer itself.
|
||||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
const nsXPTParamInfo& paramInfo2 = info->params[1];
|
||||||
const nsXPTType& type2 = paramInfo2.GetType();
|
const nsXPTType& type2 = paramInfo2.GetType();
|
||||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||||
NS_ERROR("Unexpected parameter type for getter");
|
NS_ERROR("Unexpected parameter type for getter");
|
||||||
|
@ -187,17 +192,6 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WSPPropertyBagWrapper::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(info);
|
|
||||||
|
|
||||||
*info = mInterfaceInfo;
|
|
||||||
NS_ADDREF(*info);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Implementation of nsIClassInfo
|
// Implementation of nsIClassInfo
|
||||||
|
|
|
@ -80,6 +80,10 @@ WSPProxy::Init(nsIWSDLPort* aPort, nsIInterfaceInfo* aPrimaryInterface,
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
|
rv = InitStub(*mIID);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mInterfaces = do_CreateInstance(NS_SCRIPTABLE_INTERFACES_CONTRACTID, &rv);
|
mInterfaces = do_CreateInstance(NS_SCRIPTABLE_INTERFACES_CONTRACTID, &rv);
|
||||||
if (!mInterfaces) {
|
if (!mInterfaces) {
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -135,8 +139,13 @@ NS_IMPL_RELEASE(WSPProxy)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
{
|
{
|
||||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
*aInstancePtr = NS_STATIC_CAST(nsIXPTCProxy*, this);
|
||||||
|
NS_ADDREF_THIS();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
if(mXPTCStub && mIID && aIID.Equals(*mIID)) {
|
||||||
|
*aInstancePtr = mXPTCStub;
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +186,7 @@ WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
*/
|
*/
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WSPProxy::CallMethod(PRUint16 methodIndex,
|
WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params)
|
nsXPTCMiniVariant* params)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -293,7 +302,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
PRUint32 i, partCount;
|
PRUint32 i, partCount;
|
||||||
input->GetPartCount(&partCount);
|
input->GetPartCount(&partCount);
|
||||||
|
|
||||||
PRUint32 maxParamIndex = info->GetParamCount()-1;
|
PRUint32 maxParamIndex = info->num_args - 1;
|
||||||
|
|
||||||
// Iterate through the parts to figure out how many are
|
// Iterate through the parts to figure out how many are
|
||||||
// body vs. header blocks
|
// body vs. header blocks
|
||||||
|
@ -450,7 +459,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
PRUint32 arrayLength;
|
PRUint32 arrayLength;
|
||||||
|
|
||||||
if (paramIndex < maxParamIndex &&
|
if (paramIndex < maxParamIndex &&
|
||||||
info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
|
nsXPTType(info->params[paramIndex + 1].type.prefix).IsArray()) {
|
||||||
arrayLength = params[paramIndex++].val.u32;
|
arrayLength = params[paramIndex++].val.u32;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -460,7 +469,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||||
"WSDL/IInfo param count mismatch");
|
"WSDL/IInfo param count mismatch");
|
||||||
|
|
||||||
const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);
|
const nsXPTParamInfo& paramInfo = info->params[paramIndex];
|
||||||
|
|
||||||
nsCOMPtr<nsIVariant> value;
|
nsCOMPtr<nsIVariant> value;
|
||||||
rv = ParameterToVariant(mPrimaryInterface, methodIndex,
|
rv = ParameterToVariant(mPrimaryInterface, methodIndex,
|
||||||
|
@ -492,7 +501,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
|
|
||||||
if (mIsAsync) {
|
if (mIsAsync) {
|
||||||
PRUint8 pcount;
|
PRUint8 pcount;
|
||||||
pcount = info->GetParamCount();
|
pcount = info->num_args;
|
||||||
// There has to be at least one parameter - the retval.
|
// There has to be at least one parameter - the retval.
|
||||||
if (pcount == 0) {
|
if (pcount == 0) {
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
|
@ -501,7 +510,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// The last one should be the retval.
|
// The last one should be the retval.
|
||||||
const nsXPTParamInfo& retParamInfo = info->GetParam(pcount - 1);
|
const nsXPTParamInfo& retParamInfo = info->params[pcount - 1];
|
||||||
if (!retParamInfo.IsRetval()) {
|
if (!retParamInfo.IsRetval()) {
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
goto call_method_end;
|
goto call_method_end;
|
||||||
|
@ -1135,17 +1144,6 @@ WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WSPProxy::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(info);
|
|
||||||
|
|
||||||
*info = mPrimaryInterface;
|
|
||||||
NS_ADDREF(*info);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Implementation of nsIWebServiceProxy
|
// Implementation of nsIWebServiceProxy
|
||||||
|
|
|
@ -1770,10 +1770,10 @@ ipcDConnectService::OnInvoke(PRUint32 peer, const DConnectInvoke *invoke, PRUint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XPTC_InvokeByIndex(wrapper->RealInstance(),
|
rv = NS_InvokeByIndex(wrapper->RealInstance(),
|
||||||
invoke->method_index,
|
invoke->method_index,
|
||||||
paramCount,
|
paramCount,
|
||||||
params);
|
params);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
LOG(("sending INVOKE_REPLY: rv=%x\n", rv));
|
LOG(("sending INVOKE_REPLY: rv=%x\n", rv));
|
||||||
|
|
|
@ -124,14 +124,14 @@ static intN sXPCOMUCStringFinalizerIndex = -1;
|
||||||
|
|
||||||
// static
|
// static
|
||||||
JSBool
|
JSBool
|
||||||
XPCConvert::IsMethodReflectable(const nsXPTMethodInfo& info)
|
XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
|
||||||
{
|
{
|
||||||
if(info.IsNotXPCOM() || info.IsHidden())
|
if(XPT_MD_IS_NOTXPCOM(info.flags) || XPT_MD_IS_HIDDEN(info.flags))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
for(int i = info.GetParamCount()-1; i >= 0; i--)
|
for(int i = info.num_args-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info.GetParam(i);
|
const nsXPTParamInfo& param = info.params[i];
|
||||||
const nsXPTType& type = param.GetType();
|
const nsXPTType& type = param.GetType();
|
||||||
|
|
||||||
uint8 base_type = type.TagPart();
|
uint8 base_type = type.TagPart();
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIModule.h"
|
#include "nsIModule.h"
|
||||||
#include "nsAutoLock.h"
|
#include "nsAutoLock.h"
|
||||||
#include "xptcall.h"
|
#include "nsXPTCUtils.h"
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsdhash.h"
|
#include "jsdhash.h"
|
||||||
#include "jsprf.h"
|
#include "jsprf.h"
|
||||||
|
@ -2154,7 +2154,7 @@ public:
|
||||||
JSObject* GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj);
|
JSObject* GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj);
|
||||||
|
|
||||||
NS_IMETHOD CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
NS_IMETHOD CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
|
|
||||||
JSObject* CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
JSObject* CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
||||||
|
@ -2190,7 +2190,7 @@ private:
|
||||||
enum SizeMode {GET_SIZE, GET_LENGTH};
|
enum SizeMode {GET_SIZE, GET_LENGTH};
|
||||||
|
|
||||||
JSBool GetArraySizeFromParam(JSContext* cx,
|
JSBool GetArraySizeFromParam(JSContext* cx,
|
||||||
const nsXPTMethodInfo* method,
|
const XPTMethodDescriptor* method,
|
||||||
const nsXPTParamInfo& param,
|
const nsXPTParamInfo& param,
|
||||||
uint16 methodIndex,
|
uint16 methodIndex,
|
||||||
uint8 paramIndex,
|
uint8 paramIndex,
|
||||||
|
@ -2199,7 +2199,7 @@ private:
|
||||||
JSUint32* result);
|
JSUint32* result);
|
||||||
|
|
||||||
JSBool GetInterfaceTypeFromParam(JSContext* cx,
|
JSBool GetInterfaceTypeFromParam(JSContext* cx,
|
||||||
const nsXPTMethodInfo* method,
|
const XPTMethodDescriptor* method,
|
||||||
const nsXPTParamInfo& param,
|
const nsXPTParamInfo& param,
|
||||||
uint16 methodIndex,
|
uint16 methodIndex,
|
||||||
const nsXPTType& type,
|
const nsXPTType& type,
|
||||||
|
@ -2226,7 +2226,7 @@ private:
|
||||||
// nsXPCWrappedJS objects are chained together to represent the various
|
// nsXPCWrappedJS objects are chained together to represent the various
|
||||||
// interface on the single underlying (possibly aggregate) JSObject.
|
// interface on the single underlying (possibly aggregate) JSObject.
|
||||||
|
|
||||||
class nsXPCWrappedJS : public nsXPTCStubBase,
|
class nsXPCWrappedJS : protected nsAutoXPTCStub,
|
||||||
public nsWeakRefToIXPConnectWrappedJS,
|
public nsWeakRefToIXPConnectWrappedJS,
|
||||||
public nsSupportsWeakReference,
|
public nsSupportsWeakReference,
|
||||||
public nsIPropertyBag
|
public nsIPropertyBag
|
||||||
|
@ -2238,12 +2238,8 @@ public:
|
||||||
//NS_DECL_NSISUPPORTSWEAKREFERENCE // methods also on nsIXPConnectWrappedJS
|
//NS_DECL_NSISUPPORTSWEAKREFERENCE // methods also on nsIXPConnectWrappedJS
|
||||||
NS_DECL_NSIPROPERTYBAG
|
NS_DECL_NSIPROPERTYBAG
|
||||||
|
|
||||||
// Note that both nsXPTCStubBase and nsIXPConnectWrappedJS declare
|
|
||||||
// GetInterfaceInfo methods with the same sig. So, the declaration
|
|
||||||
// for it here comes from the NS_DECL_NSIXPCONNECTWRAPPEDJS macro
|
|
||||||
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor *info,
|
||||||
nsXPTCMiniVariant* params);
|
nsXPTCMiniVariant* params);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2259,6 +2255,7 @@ public:
|
||||||
nsISupports* aOuter,
|
nsISupports* aOuter,
|
||||||
nsXPCWrappedJS** wrapper);
|
nsXPCWrappedJS** wrapper);
|
||||||
|
|
||||||
|
nsISomeInterface* GetXPTCStub() { return mXPTCStub; }
|
||||||
JSObject* GetJSObject() const {return mJSObj;}
|
JSObject* GetJSObject() const {return mJSObj;}
|
||||||
nsXPCWrappedJSClass* GetClass() const {return mClass;}
|
nsXPCWrappedJSClass* GetClass() const {return mClass;}
|
||||||
REFNSIID GetIID() const {return GetClass()->GetIID();}
|
REFNSIID GetIID() const {return GetClass()->GetIID();}
|
||||||
|
@ -2372,7 +2369,7 @@ private:
|
||||||
class XPCConvert
|
class XPCConvert
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static JSBool IsMethodReflectable(const nsXPTMethodInfo& info);
|
static JSBool IsMethodReflectable(const XPTMethodDescriptor& info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a native object into a jsval.
|
* Convert a native object into a jsval.
|
||||||
|
|
|
@ -349,6 +349,8 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
|
||||||
printf("//////// %d instances of nsXPCWrappedJS created\n", count);
|
printf("//////// %d instances of nsXPCWrappedJS created\n", count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
InitStub(GetClass()->GetIID());
|
||||||
|
|
||||||
// intensionally do double addref - see Release().
|
// intensionally do double addref - see Release().
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
|
@ -469,7 +471,7 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** info)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
|
nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* params)
|
nsXPTCMiniVariant* params)
|
||||||
{
|
{
|
||||||
if(!IsValid())
|
if(!IsValid())
|
||||||
|
|
|
@ -579,7 +579,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||||
if(nsnull != (sibling = self->Find(aIID)))
|
if(nsnull != (sibling = self->Find(aIID)))
|
||||||
{
|
{
|
||||||
NS_ADDREF(sibling);
|
NS_ADDREF(sibling);
|
||||||
*aInstancePtr = (void*) sibling;
|
*aInstancePtr = sibling->GetXPTCStub();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||||
if(nsnull != (sibling = self->FindInherited(aIID)))
|
if(nsnull != (sibling = self->FindInherited(aIID)))
|
||||||
{
|
{
|
||||||
NS_ADDREF(sibling);
|
NS_ADDREF(sibling);
|
||||||
*aInstancePtr = (void*) sibling;
|
*aInstancePtr = sibling->GetXPTCStub();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
||||||
const nsXPTMethodInfo* method,
|
const XPTMethodDescriptor* method,
|
||||||
const nsXPTParamInfo& param,
|
const nsXPTParamInfo& param,
|
||||||
uint16 methodIndex,
|
uint16 methodIndex,
|
||||||
uint8 paramIndex,
|
uint8 paramIndex,
|
||||||
|
@ -726,7 +726,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
||||||
if(NS_FAILED(rv))
|
if(NS_FAILED(rv))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
const nsXPTParamInfo& arg_param = method->GetParam(argnum);
|
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||||
const nsXPTType& arg_type = arg_param.GetType();
|
const nsXPTType& arg_type = arg_param.GetType();
|
||||||
|
|
||||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||||
|
@ -743,7 +743,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
||||||
const nsXPTMethodInfo* method,
|
const XPTMethodDescriptor* method,
|
||||||
const nsXPTParamInfo& param,
|
const nsXPTParamInfo& param,
|
||||||
uint16 methodIndex,
|
uint16 methodIndex,
|
||||||
const nsXPTType& type,
|
const nsXPTType& type,
|
||||||
|
@ -769,7 +769,7 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
||||||
if(NS_FAILED(rv))
|
if(NS_FAILED(rv))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
const nsXPTParamInfo& arg_param = method->GetParam(argnum);
|
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||||
const nsXPTType& arg_type = arg_param.GetType();
|
const nsXPTType& arg_type = arg_param.GetType();
|
||||||
if(arg_type.IsPointer() &&
|
if(arg_type.IsPointer() &&
|
||||||
arg_type.TagPart() == nsXPTType::T_IID)
|
arg_type.TagPart() == nsXPTType::T_IID)
|
||||||
|
@ -981,7 +981,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
const nsXPTMethodInfo* info,
|
const XPTMethodDescriptor* info,
|
||||||
nsXPTCMiniVariant* nativeParams)
|
nsXPTCMiniVariant* nativeParams)
|
||||||
{
|
{
|
||||||
jsval* stackbase;
|
jsval* stackbase;
|
||||||
|
@ -998,7 +998,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
nsID param_iid;
|
nsID param_iid;
|
||||||
uint8 outConversionFailedIndex;
|
uint8 outConversionFailedIndex;
|
||||||
JSObject* obj;
|
JSObject* obj;
|
||||||
const char* name = info->GetName();
|
const char* name = info->name;
|
||||||
jsval fval;
|
jsval fval;
|
||||||
void* mark;
|
void* mark;
|
||||||
JSBool foundDependentParam;
|
JSBool foundDependentParam;
|
||||||
|
@ -1038,9 +1038,9 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
obj = thisObj = wrapper->GetJSObject();
|
obj = thisObj = wrapper->GetJSObject();
|
||||||
|
|
||||||
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
||||||
paramCount = info->GetParamCount();
|
paramCount = info->num_args;
|
||||||
argc = paramCount -
|
argc = paramCount -
|
||||||
(paramCount && info->GetParam(paramCount-1).IsRetval() ? 1 : 0);
|
(paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);
|
||||||
|
|
||||||
if(!cx || !xpcc || !IsReflectable(methodIndex))
|
if(!cx || !xpcc || !IsReflectable(methodIndex))
|
||||||
goto pre_call_clean_up;
|
goto pre_call_clean_up;
|
||||||
|
@ -1059,7 +1059,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
// setup stack
|
// setup stack
|
||||||
|
|
||||||
// if this isn't a function call then we don't need to push extra stuff
|
// if this isn't a function call then we don't need to push extra stuff
|
||||||
if(info->IsGetter() || info->IsSetter())
|
if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
|
||||||
{
|
{
|
||||||
stack_size = argc;
|
stack_size = argc;
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1099,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
|
|
||||||
if(paramCount)
|
if(paramCount)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& firstParam = info->GetParam(0);
|
const nsXPTParamInfo& firstParam = info->params[0];
|
||||||
if(firstParam.IsIn())
|
if(firstParam.IsIn())
|
||||||
{
|
{
|
||||||
const nsXPTType& firstType = firstParam.GetType();
|
const nsXPTType& firstType = firstParam.GetType();
|
||||||
|
@ -1178,7 +1178,8 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
goto pre_call_clean_up;
|
goto pre_call_clean_up;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(info->IsGetter() || sp, "Only a getter needs no stack.");
|
NS_ASSERTION(XPT_MD_IS_GETTER(info->flags) || sp,
|
||||||
|
"Only a getter needs no stack.");
|
||||||
|
|
||||||
// this is a function call, so push function and 'this'
|
// this is a function call, so push function and 'this'
|
||||||
if(stack_size != argc)
|
if(stack_size != argc)
|
||||||
|
@ -1196,7 +1197,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
// build the args
|
// build the args
|
||||||
for(i = 0; i < argc; i++)
|
for(i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info->GetParam(i);
|
const nsXPTParamInfo& param = info->params[i];
|
||||||
const nsXPTType& type = param.GetType();
|
const nsXPTType& type = param.GetType();
|
||||||
nsXPTType datum_type;
|
nsXPTType datum_type;
|
||||||
JSUint32 array_count;
|
JSUint32 array_count;
|
||||||
|
@ -1249,7 +1250,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out what our callee is
|
// Figure out what our callee is
|
||||||
if(info->IsGetter() || info->IsSetter())
|
if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
|
||||||
{
|
{
|
||||||
// Pull the getter or setter off of |obj|
|
// Pull the getter or setter off of |obj|
|
||||||
uintN attrs;
|
uintN attrs;
|
||||||
|
@ -1262,13 +1263,13 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||||
&getter, &setter);
|
&getter, &setter);
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
if(info->IsGetter() && (attrs & JSPROP_GETTER))
|
if(XPT_MD_IS_GETTER(info->flags) && (attrs & JSPROP_GETTER))
|
||||||
{
|
{
|
||||||
// JSPROP_GETTER means the getter is actually a
|
// JSPROP_GETTER means the getter is actually a
|
||||||
// function object.
|
// function object.
|
||||||
ccx.SetCallee((JSObject*)getter);
|
ccx.SetCallee((JSObject*)getter);
|
||||||
}
|
}
|
||||||
else if(info->IsSetter() && (attrs & JSPROP_SETTER))
|
else if(XPT_MD_IS_SETTER(info->flags) && (attrs & JSPROP_SETTER))
|
||||||
{
|
{
|
||||||
// JSPROP_SETTER means the setter is actually a
|
// JSPROP_SETTER means the setter is actually a
|
||||||
// function object.
|
// function object.
|
||||||
|
@ -1338,7 +1339,7 @@ pre_call_clean_up:
|
||||||
// clean up any 'out' params handed in
|
// clean up any 'out' params handed in
|
||||||
for(i = 0; i < paramCount; i++)
|
for(i = 0; i < paramCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info->GetParam(i);
|
const nsXPTParamInfo& param = info->params[i];
|
||||||
if(!param.IsOut())
|
if(!param.IsOut())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1393,9 +1394,9 @@ pre_call_clean_up:
|
||||||
|
|
||||||
JS_ClearPendingException(cx);
|
JS_ClearPendingException(cx);
|
||||||
|
|
||||||
if(info->IsGetter())
|
if(XPT_MD_IS_GETTER(info->flags))
|
||||||
success = JS_GetProperty(cx, obj, name, &result);
|
success = JS_GetProperty(cx, obj, name, &result);
|
||||||
else if(info->IsSetter())
|
else if(XPT_MD_IS_SETTER(info->flags))
|
||||||
success = JS_SetProperty(cx, obj, name, sp-1);
|
success = JS_SetProperty(cx, obj, name, sp-1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1469,7 +1470,7 @@ pre_call_clean_up:
|
||||||
foundDependentParam = JS_FALSE;
|
foundDependentParam = JS_FALSE;
|
||||||
for(i = 0; i < paramCount; i++)
|
for(i = 0; i < paramCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info->GetParam(i);
|
const nsXPTParamInfo& param = info->params[i];
|
||||||
if(!param.IsOut() && !param.IsDipper())
|
if(!param.IsOut() && !param.IsDipper())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1520,7 +1521,7 @@ pre_call_clean_up:
|
||||||
{
|
{
|
||||||
for(i = 0; i < paramCount; i++)
|
for(i = 0; i < paramCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info->GetParam(i);
|
const nsXPTParamInfo& param = info->params[i];
|
||||||
if(!param.IsOut())
|
if(!param.IsOut())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1613,7 +1614,7 @@ pre_call_clean_up:
|
||||||
|
|
||||||
for(uint8 k = 0; k < i; k++)
|
for(uint8 k = 0; k < i; k++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& param = info->GetParam(k);
|
const nsXPTParamInfo& param = info->params[k];
|
||||||
if(!param.IsOut())
|
if(!param.IsOut())
|
||||||
continue;
|
continue;
|
||||||
const nsXPTType& type = param.GetType();
|
const nsXPTType& type = param.GetType();
|
||||||
|
|
|
@ -2158,8 +2158,8 @@ XPCWrappedNative::CallMethod(XPCCallContext& ccx,
|
||||||
AutoJSSuspendRequest req(ccx); // scoped suspend of request
|
AutoJSSuspendRequest req(ccx); // scoped suspend of request
|
||||||
|
|
||||||
// do the invoke
|
// do the invoke
|
||||||
invokeResult = XPTC_InvokeByIndex(callee, vtblIndex,
|
invokeResult = NS_InvokeByIndex(callee, vtblIndex,
|
||||||
paramCount, dispatchParams);
|
paramCount, dispatchParams);
|
||||||
// resume non-blocking JS operations now
|
// resume non-blocking JS operations now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,9 +168,7 @@ void XXXNeverCalled()
|
||||||
#if defined (DEBUG) && !defined (WINCE) && !defined(XP_OS2)
|
#if defined (DEBUG) && !defined (WINCE) && !defined(XP_OS2)
|
||||||
PurePrintf(0);
|
PurePrintf(0);
|
||||||
#endif
|
#endif
|
||||||
XPTC_InvokeByIndex(nsnull, 0, 0, nsnull);
|
NS_InvokeByIndex(nsnull, 0, 0, nsnull);
|
||||||
xptc_dummy();
|
|
||||||
xptc_dummy2();
|
|
||||||
NS_NewGenericFactory(nsnull, nsnull);
|
NS_NewGenericFactory(nsnull, nsnull);
|
||||||
NS_NewGenericModule2(nsnull, nsnull);
|
NS_NewGenericModule2(nsnull, nsnull);
|
||||||
NS_GetWeakReference(nsnull);
|
NS_GetWeakReference(nsnull);
|
||||||
|
|
|
@ -112,6 +112,7 @@ SDK_HEADERS = \
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
nsThreadUtils.h \
|
nsThreadUtils.h \
|
||||||
nsProxyRelease.h \
|
nsProxyRelease.h \
|
||||||
|
nsXPTCUtils.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
SDK_LIBRARY = \
|
SDK_LIBRARY = \
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Mozilla XPCOM.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* the Mozilla Foundation <http://www.mozilla.org/>.
|
||||||
|
*
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Benjamin Smedberg <benjamin@smedbergs.us> - New code
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#ifndef nsXPTCUtils_h__
|
||||||
|
#define nsXPTCUtils_h__
|
||||||
|
|
||||||
|
#include "xptcall.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper class that initializes an xptcall helper at construction
|
||||||
|
* and releases it at destruction.
|
||||||
|
*/
|
||||||
|
class nsAutoXPTCStub : protected nsIXPTCProxy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsISomeInterface* mXPTCStub;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsAutoXPTCStub() : mXPTCStub(nsnull) { }
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
InitStub(const nsIID& aIID)
|
||||||
|
{
|
||||||
|
return NS_GetXPTCallStub(aIID, this, &mXPTCStub);
|
||||||
|
}
|
||||||
|
|
||||||
|
~nsAutoXPTCStub()
|
||||||
|
{
|
||||||
|
if (mXPTCStub)
|
||||||
|
NS_DestroyXPTCallStub(mXPTCStub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // nsXPTCUtils_h__
|
|
@ -127,7 +127,7 @@ nsProxyObject::nsProxyObjectDestructorEvent::Run()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
nsProxyObjectCallInfo::nsProxyObjectCallInfo(nsProxyEventObject* owner,
|
nsProxyObjectCallInfo::nsProxyObjectCallInfo(nsProxyEventObject* owner,
|
||||||
const nsXPTMethodInfo *methodInfo,
|
const XPTMethodDescriptor *methodInfo,
|
||||||
PRUint32 methodIndex,
|
PRUint32 methodIndex,
|
||||||
nsXPTCVariant* parameterList,
|
nsXPTCVariant* parameterList,
|
||||||
PRUint32 parameterCount) :
|
PRUint32 parameterCount) :
|
||||||
|
@ -175,10 +175,10 @@ nsProxyObjectCallInfo::Run()
|
||||||
{
|
{
|
||||||
PROXY_LOG(("PROXY(%p): Run\n", this));
|
PROXY_LOG(("PROXY(%p): Run\n", this));
|
||||||
|
|
||||||
mResult = XPTC_InvokeByIndex(mOwner->GetProxiedInterface(),
|
mResult = NS_InvokeByIndex(mOwner->GetProxiedInterface(),
|
||||||
mMethodIndex,
|
mMethodIndex,
|
||||||
mParameterCount,
|
mParameterCount,
|
||||||
mParameterList);
|
mParameterList);
|
||||||
|
|
||||||
if (IsSync()) {
|
if (IsSync()) {
|
||||||
PostCompleted();
|
PostCompleted();
|
||||||
|
@ -192,7 +192,7 @@ nsProxyObjectCallInfo::RefCountInInterfacePointers(PRBool addRef)
|
||||||
{
|
{
|
||||||
for (PRUint32 i = 0; i < mParameterCount; i++)
|
for (PRUint32 i = 0; i < mParameterCount; i++)
|
||||||
{
|
{
|
||||||
nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i);
|
nsXPTParamInfo paramInfo = mMethodInfo->params[i];
|
||||||
|
|
||||||
if (paramInfo.GetType().IsInterfacePointer() )
|
if (paramInfo.GetType().IsInterfacePointer() )
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ nsProxyObjectCallInfo::CopyStrings(PRBool copy)
|
||||||
{
|
{
|
||||||
for (PRUint32 i = 0; i < mParameterCount; i++)
|
for (PRUint32 i = 0; i < mParameterCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i);
|
const nsXPTParamInfo paramInfo = mMethodInfo->params[i];
|
||||||
|
|
||||||
if (paramInfo.IsIn())
|
if (paramInfo.IsIn())
|
||||||
{
|
{
|
||||||
|
@ -413,7 +413,7 @@ nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
|
||||||
|
|
||||||
for (peo = mFirst; peo; peo = peo->mNext) {
|
for (peo = mFirst; peo; peo = peo->mNext) {
|
||||||
if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
|
if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
|
||||||
*aResult = NS_STATIC_CAST(nsISupports*, peo);
|
*aResult = NS_STATIC_CAST(nsISupports*, peo->mXPTCStub);
|
||||||
peo->AddRef();
|
peo->AddRef();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -430,16 +430,20 @@ nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
peo = new nsProxyEventObject(this, pec,
|
peo = new nsProxyEventObject(this, pec,
|
||||||
already_AddRefed<nsISomeInterface>(newInterface));
|
already_AddRefed<nsISomeInterface>(newInterface), &rv);
|
||||||
if (!peo)
|
if (!peo)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
delete peo;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
peo->mNext = mFirst;
|
peo->mNext = mFirst;
|
||||||
mFirst = peo;
|
mFirst = peo;
|
||||||
|
|
||||||
NS_ADDREF(peo);
|
NS_ADDREF(peo);
|
||||||
|
|
||||||
*aResult = (nsISupports*) peo;
|
*aResult = NS_STATIC_CAST(nsISupports*, peo->mXPTCStub);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,14 @@
|
||||||
|
|
||||||
nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent,
|
nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent,
|
||||||
nsProxyEventClass* aClass,
|
nsProxyEventClass* aClass,
|
||||||
already_AddRefed<nsISomeInterface> aRealInterface)
|
already_AddRefed<nsISomeInterface> aRealInterface,
|
||||||
|
nsresult *rv)
|
||||||
: mRealInterface(aRealInterface),
|
: mRealInterface(aRealInterface),
|
||||||
mClass(aClass),
|
mClass(aClass),
|
||||||
mProxyObject(aParent),
|
mProxyObject(aParent),
|
||||||
mNext(nsnull)
|
mNext(nsnull)
|
||||||
{
|
{
|
||||||
|
*rv = InitStub(aClass->GetProxiedIID());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsProxyEventObject::~nsProxyEventObject()
|
nsProxyEventObject::~nsProxyEventObject()
|
||||||
|
@ -106,7 +108,7 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
{
|
{
|
||||||
if( aIID.Equals(GetClass()->GetProxiedIID()) )
|
if( aIID.Equals(GetClass()->GetProxiedIID()) )
|
||||||
{
|
{
|
||||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
|
*aInstancePtr = NS_STATIC_CAST(nsISupports*, mXPTCStub);
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -118,23 +120,13 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||||
// nsXPTCStubBase implementation...
|
// nsXPTCStubBase implementation...
|
||||||
//
|
//
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsProxyEventObject::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|
||||||
{
|
|
||||||
*info = mClass->GetInterfaceInfo();
|
|
||||||
NS_ASSERTION(*info, "proxy class without interface");
|
|
||||||
|
|
||||||
NS_ADDREF(*info);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsProxyEventObject::convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
|
nsProxyEventObject::convertMiniVariantToVariant(const XPTMethodDescriptor *methodInfo,
|
||||||
nsXPTCMiniVariant * params,
|
nsXPTCMiniVariant * params,
|
||||||
nsXPTCVariant **fullParam,
|
nsXPTCVariant **fullParam,
|
||||||
uint8 *outParamCount)
|
uint8 *outParamCount)
|
||||||
{
|
{
|
||||||
uint8 paramCount = methodInfo->GetParamCount();
|
uint8 paramCount = methodInfo->num_args;
|
||||||
*outParamCount = paramCount;
|
*outParamCount = paramCount;
|
||||||
*fullParam = nsnull;
|
*fullParam = nsnull;
|
||||||
|
|
||||||
|
@ -147,7 +139,7 @@ nsProxyEventObject::convertMiniVariantToVariant(const nsXPTMethodInfo *methodInf
|
||||||
|
|
||||||
for (int i = 0; i < paramCount; i++)
|
for (int i = 0; i < paramCount; i++)
|
||||||
{
|
{
|
||||||
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(i);
|
const nsXPTParamInfo& paramInfo = methodInfo->params[i];
|
||||||
if ((GetProxyType() & NS_PROXY_ASYNC) && paramInfo.IsDipper())
|
if ((GetProxyType() & NS_PROXY_ASYNC) && paramInfo.IsDipper())
|
||||||
{
|
{
|
||||||
NS_WARNING("Async proxying of out parameters is not supported");
|
NS_WARNING("Async proxying of out parameters is not supported");
|
||||||
|
@ -189,14 +181,14 @@ nsProxyThreadFilter::AcceptEvent(nsIRunnable *event)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProxyEventObject::CallMethod(PRUint16 methodIndex,
|
nsProxyEventObject::CallMethod(PRUint16 methodIndex,
|
||||||
const nsXPTMethodInfo* methodInfo,
|
const XPTMethodDescriptor* methodInfo,
|
||||||
nsXPTCMiniVariant * params)
|
nsXPTCMiniVariant * params)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(methodIndex > 2,
|
NS_ASSERTION(methodIndex > 2,
|
||||||
"Calling QI/AddRef/Release through CallMethod");
|
"Calling QI/AddRef/Release through CallMethod");
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (methodInfo->IsNotXPCOM())
|
if (XPT_MD_IS_NOTXPCOM(methodInfo->flags))
|
||||||
return NS_ERROR_PROXY_INVALID_IN_PARAMETER;
|
return NS_ERROR_PROXY_INVALID_IN_PARAMETER;
|
||||||
|
|
||||||
nsXPTCVariant *fullParam;
|
nsXPTCVariant *fullParam;
|
||||||
|
@ -212,8 +204,8 @@ nsProxyEventObject::CallMethod(PRUint16 methodIndex,
|
||||||
callDirectly) {
|
callDirectly) {
|
||||||
|
|
||||||
// invoke directly using xptc
|
// invoke directly using xptc
|
||||||
rv = XPTC_InvokeByIndex(mRealInterface, methodIndex,
|
rv = NS_InvokeByIndex(mRealInterface, methodIndex,
|
||||||
paramCount, fullParam);
|
paramCount, fullParam);
|
||||||
|
|
||||||
if (fullParam)
|
if (fullParam)
|
||||||
free(fullParam);
|
free(fullParam);
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "nsIInterfaceInfo.h"
|
#include "nsIInterfaceInfo.h"
|
||||||
#include "nsIProxyObjectManager.h"
|
#include "nsIProxyObjectManager.h"
|
||||||
|
|
||||||
#include "xptcall.h" // defines nsXPTCVariant
|
#include "nsXPTCUtils.h"
|
||||||
|
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
@ -150,30 +150,31 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyObject, NS_PROXYOBJECT_CLASS_IID)
|
||||||
* This object is maintained in a singly-linked list from the associated
|
* This object is maintained in a singly-linked list from the associated
|
||||||
* "parent" nsProxyObject.
|
* "parent" nsProxyObject.
|
||||||
*/
|
*/
|
||||||
class nsProxyEventObject : public nsXPTCStubBase
|
class nsProxyEventObject : protected nsAutoXPTCStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
|
||||||
|
|
||||||
// call this method and return result
|
// call this method and return result
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex, const nsXPTMethodInfo* info, nsXPTCMiniVariant* params);
|
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||||
|
const XPTMethodDescriptor* info,
|
||||||
|
nsXPTCMiniVariant* params);
|
||||||
|
|
||||||
nsProxyEventClass* GetClass() const { return mClass; }
|
nsProxyEventClass* GetClass() const { return mClass; }
|
||||||
nsISomeInterface* GetProxiedInterface() const { return mRealInterface; }
|
nsISomeInterface* GetProxiedInterface() const { return mRealInterface; }
|
||||||
nsIEventTarget* GetTarget() const { return mProxyObject->GetTarget(); }
|
nsIEventTarget* GetTarget() const { return mProxyObject->GetTarget(); }
|
||||||
PRInt32 GetProxyType() const { return mProxyObject->GetProxyType(); }
|
PRInt32 GetProxyType() const { return mProxyObject->GetProxyType(); }
|
||||||
|
|
||||||
nsresult convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
|
nsresult convertMiniVariantToVariant(const XPTMethodDescriptor *methodInfo,
|
||||||
nsXPTCMiniVariant *params,
|
nsXPTCMiniVariant *params,
|
||||||
nsXPTCVariant **fullParam,
|
nsXPTCVariant **fullParam,
|
||||||
uint8 *outParamCount);
|
uint8 *outParamCount);
|
||||||
|
|
||||||
nsProxyEventObject(nsProxyObject *aParent,
|
nsProxyEventObject(nsProxyObject *aParent,
|
||||||
nsProxyEventClass *aClass,
|
nsProxyEventClass *aClass,
|
||||||
already_AddRefed<nsISomeInterface> aRealInterface);
|
already_AddRefed<nsISomeInterface> aRealInterface,
|
||||||
|
nsresult *rv);
|
||||||
|
|
||||||
friend class nsProxyObject;
|
friend class nsProxyObject;
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_IID)
|
||||||
|
|
||||||
nsProxyObjectCallInfo(nsProxyEventObject* owner,
|
nsProxyObjectCallInfo(nsProxyEventObject* owner,
|
||||||
const nsXPTMethodInfo *methodInfo,
|
const XPTMethodDescriptor *methodInfo,
|
||||||
PRUint32 methodIndex,
|
PRUint32 methodIndex,
|
||||||
nsXPTCVariant* parameterList,
|
nsXPTCVariant* parameterList,
|
||||||
PRUint32 parameterCount);
|
PRUint32 parameterCount);
|
||||||
|
@ -238,7 +239,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
nsresult mResult; /* this is the return result of the called function */
|
nsresult mResult; /* this is the return result of the called function */
|
||||||
const nsXPTMethodInfo *mMethodInfo;
|
const XPTMethodDescriptor *mMethodInfo;
|
||||||
PRUint32 mMethodIndex; /* which method to be called? */
|
PRUint32 mMethodIndex; /* which method to be called? */
|
||||||
nsXPTCVariant *mParameterList; /* marshalled in parameter buffer */
|
nsXPTCVariant *mParameterList; /* marshalled in parameter buffer */
|
||||||
PRUint32 mParameterCount; /* number of params */
|
PRUint32 mParameterCount; /* number of params */
|
||||||
|
|
|
@ -47,11 +47,11 @@ There are really two pieces of functionality: <i>invoke</i> and <i>stubs</i>...
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
The <b><i>invoke</i></b> functionality requires the implementation of the
|
The <b><i>invoke</i></b> functionality requires the implementation of the
|
||||||
following on each platform (from <a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/public/xptcall.h#131">xptcall/public/xptcall.h</a>):
|
following on each platform (from <a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/public/xptcall.h">xptcall/public/xptcall.h</a>):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
XPTC_PUBLIC_API(nsresult)
|
XPTC_PUBLIC_API(nsresult)
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params);
|
PRUint32 paramCount, nsXPTCVariant* params);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ can decide how best to do this for their platforms.
|
||||||
The <b><i>stubs</i></b> functionality is more complex. The goal here is a class
|
The <b><i>stubs</i></b> functionality is more complex. The goal here is a class
|
||||||
whose vtbl can look like the vtbl of any arbitrary xpcom interface. Objects of
|
whose vtbl can look like the vtbl of any arbitrary xpcom interface. Objects of
|
||||||
this class can then be built to impersonate any xpcom object. The base interface
|
this class can then be built to impersonate any xpcom object. The base interface
|
||||||
for this is (from <a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/public/xptcall.h#109">xptcall/public/xptcall.h</a>):
|
for this is (from <a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/public/xptcall.h">xptcall/public/xptcall.h</a>):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
class nsXPTCStubBase : public nsISupports
|
class nsXPTCStubBase : public nsISupports
|
||||||
|
@ -177,7 +177,7 @@ href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/src/md/test">x
|
||||||
Not all of the functionality is exercised, but it is a place to get started.
|
Not all of the functionality is exercised, but it is a place to get started.
|
||||||
<a
|
<a
|
||||||
href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/tests">xptcall/tests
|
href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/tests">xptcall/tests
|
||||||
</a> has an api level test for <code>XPTC_InvokeByIndex</code>, but no tests for
|
</a> has an api level test for <code>NS_InvokeByIndex</code>, but no tests for
|
||||||
the <i>stubs</i> functionality. Such a test ought to be written, but this has not
|
the <i>stubs</i> functionality. Such a test ought to be written, but this has not
|
||||||
yet been done.
|
yet been done.
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
|
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
|
@ -45,27 +46,6 @@
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "xpt_struct.h"
|
#include "xpt_struct.h"
|
||||||
#include "xptinfo.h"
|
#include "xptinfo.h"
|
||||||
#include "nsIInterfaceInfo.h"
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/*
|
|
||||||
* The linkage of XPTC API functions differs depending on whether the file is
|
|
||||||
* used within the XPTC library or not. Any source file within the XPTC
|
|
||||||
* library should define EXPORT_XPTC_API whereas any client of the library
|
|
||||||
* should not.
|
|
||||||
*/
|
|
||||||
#ifdef EXPORT_XPTC_API
|
|
||||||
# define XPTC_PUBLIC_API(t) PR_IMPLEMENT(t)
|
|
||||||
# define XPTC_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t)
|
|
||||||
# define XPTC_EXPORT NS_EXPORT
|
|
||||||
#else
|
|
||||||
# define XPTC_PUBLIC_API(t) NS_IMPORT t
|
|
||||||
# define XPTC_PUBLIC_DATA(t) NS_IMPORT t
|
|
||||||
# define XPTC_EXPORT NS_IMPORT
|
|
||||||
#endif
|
|
||||||
#define XPTC_FRIEND_API(t) XPTC_PUBLIC_API(t)
|
|
||||||
#define XPTC_FRIEND_DATA(t) XPTC_PUBLIC_DATA(t)
|
|
||||||
/***************************************************************************/
|
|
||||||
|
|
||||||
struct nsXPTCMiniVariant
|
struct nsXPTCMiniVariant
|
||||||
{
|
{
|
||||||
|
@ -174,49 +154,48 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************************************************************/
|
class nsIXPTCProxy : public nsISupports
|
||||||
|
|
||||||
#undef IMETHOD_VISIBILITY
|
|
||||||
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
|
|
||||||
|
|
||||||
class XPTC_EXPORT nsXPTCStubBase : public nsISupports
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// We are going to implement this to force the compiler to generate a
|
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
|
||||||
// vtbl for this class. Since this is overridden in the inheriting class
|
const XPTMethodDescriptor *aInfo,
|
||||||
// we expect it to never be called.
|
nsXPTCMiniVariant *aParams) = 0;
|
||||||
// *This is needed by the Irix implementation.*
|
|
||||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
|
||||||
|
|
||||||
// Include generated vtbl stub declarations.
|
|
||||||
// These are virtual and *also* implemented by this class..
|
|
||||||
#include "xptcstubsdecl.inc"
|
|
||||||
|
|
||||||
// The following methods must be provided by inheritor of this class.
|
|
||||||
|
|
||||||
// return a refcounted pointer to the InterfaceInfo for this object
|
|
||||||
// NOTE: on some platforms this MUST not fail or we crash!
|
|
||||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info) = 0;
|
|
||||||
|
|
||||||
// call this method and return result
|
|
||||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
|
||||||
const nsXPTMethodInfo* info,
|
|
||||||
nsXPTCMiniVariant* params) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef IMETHOD_VISIBILITY
|
/**
|
||||||
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
|
* This is a typedef to avoid confusion between the canonical
|
||||||
|
* nsISupports* that provides object identity and an interface pointer
|
||||||
|
* for inheriting interfaces that aren't known at compile-time.
|
||||||
|
*/
|
||||||
|
typedef nsISupports nsISomeInterface;
|
||||||
|
|
||||||
PR_BEGIN_EXTERN_C
|
/**
|
||||||
|
* Get a proxy object to implement the specified interface.
|
||||||
|
*
|
||||||
|
* @param aIID The IID of the interface to implement.
|
||||||
|
* @param aOuter An object to receive method calls from the proxy object.
|
||||||
|
* The stub forwards QueryInterface/AddRef/Release to the
|
||||||
|
* outer object. The proxy object does not hold a reference to
|
||||||
|
* the outer object; it is the caller's responsibility to
|
||||||
|
* ensure that this pointer remains valid until the stub has
|
||||||
|
* been destroyed.
|
||||||
|
* @param aStub Out parameter for the new proxy object. The object is
|
||||||
|
* not addrefed. The object never destroys itself. It must be
|
||||||
|
* explicitly destroyed by calling
|
||||||
|
* NS_DestroyXPTCallStub when it is no longer needed.
|
||||||
|
*/
|
||||||
|
XPCOM_API(nsresult)
|
||||||
|
NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||||
|
nsISomeInterface* *aStub);
|
||||||
|
|
||||||
XPTC_PUBLIC_API(nsresult)
|
/**
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
* Destroys an XPTCall stub previously created with NS_GetXPTCallStub.
|
||||||
PRUint32 paramCount, nsXPTCVariant* params);
|
*/
|
||||||
|
XPCOM_API(void)
|
||||||
|
NS_DestroyXPTCallStub(nsISomeInterface* aStub);
|
||||||
|
|
||||||
// Used to force linking of these obj for the static library into the dll
|
XPCOM_API(nsresult)
|
||||||
extern void xptc_dummy();
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
extern void xptc_dummy2();
|
PRUint32 paramCount, nsXPTCVariant* params);
|
||||||
|
|
||||||
PR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif /* xptcall_h___ */
|
#endif /* xptcall_h___ */
|
||||||
|
|
|
@ -48,6 +48,8 @@ MOZILLA_INTERNAL_API = 1
|
||||||
|
|
||||||
DIRS = md
|
DIRS = md
|
||||||
|
|
||||||
|
REQUIRES = string
|
||||||
|
|
||||||
CPPSRCS = xptcall.cpp
|
CPPSRCS = xptcall.cpp
|
||||||
|
|
||||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||||
|
@ -59,3 +61,5 @@ FORCE_USE_PIC = 1
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
||||||
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
|
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
|
||||||
|
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)/../../xptinfo/src
|
||||||
|
|
|
@ -50,7 +50,11 @@ CPPSRCS = \
|
||||||
../unix/xptcinvoke_gcc_x86_unix.cpp \
|
../unix/xptcinvoke_gcc_x86_unix.cpp \
|
||||||
xptcstubs_gcc_x86_os2.cpp \
|
xptcstubs_gcc_x86_os2.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
LOCAL_INCLUDES = -I$(srcdir)/../unix
|
REQUIRES = string
|
||||||
|
LOCAL_INCLUDES = \
|
||||||
|
-I$(srcdir)/../unix \
|
||||||
|
-I$(srcdir)/../../../../xptinfo/src \
|
||||||
|
$(NULL)
|
||||||
DEFINES += -DMOZ_NEED_LEADING_UNDERSCORE
|
DEFINES += -DMOZ_NEED_LEADING_UNDERSCORE
|
||||||
|
|
||||||
# Force use of PIC
|
# Force use of PIC
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
/* Implement shared vtbl methods. */
|
/* Implement shared vtbl methods. */
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
#include "xptc_platforms_unixish_x86.h"
|
#include "xptc_platforms_unixish_x86.h"
|
||||||
#include "xptc_gcc_x86_unix.h"
|
#include "xptc_gcc_x86_unix.h"
|
||||||
|
|
||||||
|
@ -50,7 +51,6 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
|
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||||
nsIInterfaceInfo* iface_info = NULL;
|
|
||||||
const nsXPTMethodInfo* info;
|
const nsXPTMethodInfo* info;
|
||||||
PRUint8 paramCount;
|
PRUint8 paramCount;
|
||||||
PRUint8 i;
|
PRUint8 i;
|
||||||
|
@ -58,12 +58,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
|
|
||||||
NS_ASSERTION(self,"no self");
|
NS_ASSERTION(self,"no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&iface_info);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||||
NS_ASSERTION(iface_info,"no interface info");
|
|
||||||
|
|
||||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
|
||||||
NS_ASSERTION(info,"no interface info");
|
|
||||||
|
|
||||||
paramCount = info->GetParamCount();
|
paramCount = info->GetParamCount();
|
||||||
|
|
||||||
// setup variant array pointer
|
// setup variant array pointer
|
||||||
|
@ -95,9 +90,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||||
|
|
||||||
NS_RELEASE(iface_info);
|
|
||||||
|
|
||||||
if(dispatchParams != paramBuffer)
|
if(dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -46,6 +46,8 @@ MODULE = xpcom
|
||||||
LIBRARY_NAME = xptcmd
|
LIBRARY_NAME = xptcmd
|
||||||
MOZILLA_INTERNAL_API = 1
|
MOZILLA_INTERNAL_API = 1
|
||||||
|
|
||||||
|
REQUIRES = string
|
||||||
|
|
||||||
#
|
#
|
||||||
# The default is this buildable, but non-functioning code.
|
# The default is this buildable, but non-functioning code.
|
||||||
#
|
#
|
||||||
|
@ -378,7 +380,10 @@ include $(topsrcdir)/config/rules.mk
|
||||||
|
|
||||||
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
|
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
|
||||||
|
|
||||||
INCLUDES += -I$(srcdir)/../..
|
LOCAL_INCLUDES += \
|
||||||
|
-I$(srcdir)/../.. \
|
||||||
|
-I$(srcdir)/../../../../xptinfo/src \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
ifeq ($(OS_ARCH),Linux)
|
ifeq ($(OS_ARCH),Linux)
|
||||||
ifneq (,$(findstring mips, $(OS_TEST)))
|
ifneq (,$(findstring mips, $(OS_TEST)))
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
.text
|
.text
|
||||||
.align 2
|
.align 2
|
||||||
#
|
#
|
||||||
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
# NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
# PRUint32 paramCount, nsXPTCVariant* params)
|
# PRUint32 paramCount, nsXPTCVariant* params)
|
||||||
#
|
#
|
||||||
|
|
||||||
.globl __XPTC_InvokeByIndex
|
.globl __NS_InvokeByIndex
|
||||||
__XPTC_InvokeByIndex:
|
__NS_InvokeByIndex:
|
||||||
mflr r0
|
mflr r0
|
||||||
stw r31,-4(r1)
|
stw r31,-4(r1)
|
||||||
#
|
#
|
||||||
|
|
|
@ -91,9 +91,9 @@ xptc_invoke_copy_to_stack_keeper (void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
XPTC_PUBLIC_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params);
|
PRUint32 paramCount, nsXPTCVariant* params);
|
||||||
|
|
||||||
Each param takes at most two 4-byte words.
|
Each param takes at most two 4-byte words.
|
||||||
It doesn't matter if we push too many words, and calculating the exact
|
It doesn't matter if we push too many words, and calculating the exact
|
||||||
|
@ -117,12 +117,12 @@ xptc_invoke_copy_to_stack_keeper (void)
|
||||||
*/
|
*/
|
||||||
#if defined(XP_WIN32) || defined(XP_OS2)
|
#if defined(XP_WIN32) || defined(XP_OS2)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params);
|
PRUint32 paramCount, nsXPTCVariant* params);
|
||||||
XPTC_PUBLIC_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params) {
|
PRUint32 paramCount, nsXPTCVariant* params) {
|
||||||
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
|
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,12 +133,12 @@ __asm__ (
|
||||||
is what xptcstubs uses. */
|
is what xptcstubs uses. */
|
||||||
".align 2\n\t"
|
".align 2\n\t"
|
||||||
#if defined(XP_WIN32) || defined(XP_OS2)
|
#if defined(XP_WIN32) || defined(XP_OS2)
|
||||||
".globl " SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex\n\t"
|
".globl " SYMBOL_UNDERSCORE "_NS_InvokeByIndex\n\t"
|
||||||
SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex:\n\t"
|
SYMBOL_UNDERSCORE "_NS_InvokeByIndex:\n\t"
|
||||||
#else
|
#else
|
||||||
".globl " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
|
".globl " SYMBOL_UNDERSCORE "NS_InvokeByIndex\n\t"
|
||||||
".type " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex,@function\n"
|
".type " SYMBOL_UNDERSCORE "NS_InvokeByIndex,@function\n"
|
||||||
SYMBOL_UNDERSCORE "XPTC_InvokeByIndex:\n\t"
|
SYMBOL_UNDERSCORE "NS_InvokeByIndex:\n\t"
|
||||||
#endif
|
#endif
|
||||||
"pushl %ebp\n\t"
|
"pushl %ebp\n\t"
|
||||||
"movl %esp, %ebp\n\t"
|
"movl %esp, %ebp\n\t"
|
||||||
|
@ -193,7 +193,7 @@ __asm__ (
|
||||||
"popl %ebp\n\t"
|
"popl %ebp\n\t"
|
||||||
"ret\n"
|
"ret\n"
|
||||||
#if !defined(XP_WIN32) && !defined(XP_OS2)
|
#if !defined(XP_WIN32) && !defined(XP_OS2)
|
||||||
".size " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex, . -" SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
|
".size " SYMBOL_UNDERSCORE "NS_InvokeByIndex, . -" SYMBOL_UNDERSCORE "NS_InvokeByIndex\n\t"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -133,13 +133,13 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
extern "C" nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params);
|
PRUint32 paramCount,
|
||||||
|
nsXPTCVariant* params);
|
||||||
|
|
||||||
extern "C"
|
EXPORT_XPCOM_API(nsresult)
|
||||||
XPTC_PUBLIC_API(nsresult)
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
PRUint32 paramCount, nsXPTCVariant* params)
|
||||||
PRUint32 paramCount, nsXPTCVariant* params)
|
|
||||||
{
|
{
|
||||||
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
|
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,9 @@ invoke_copy_to_stack(PRUint32 paramCount, nsXPTCVariant* s, PRUint32* d)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XPTC_PUBLIC_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params)
|
PRUint32 paramCount, nsXPTCVariant* params)
|
||||||
{
|
{
|
||||||
#ifdef __GNUC__ /* Gnu compiler. */
|
#ifdef __GNUC__ /* Gnu compiler. */
|
||||||
PRUint32 result;
|
PRUint32 result;
|
||||||
|
|
|
@ -131,10 +131,9 @@ invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
EXPORT_XPCOM_API(nsresult)
|
||||||
XPTC_PUBLIC_API(nsresult)
|
NS_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
|
||||||
XPTC_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
|
PRUint32 paramCount, nsXPTCVariant * params)
|
||||||
PRUint32 paramCount, nsXPTCVariant * params)
|
|
||||||
{
|
{
|
||||||
PRUint32 nr_gpr, nr_fpr, nr_stack;
|
PRUint32 nr_gpr, nr_fpr, nr_stack;
|
||||||
invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
|
invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#ifdef __GNUC__ /* Gnu Compiler. */
|
#ifdef __GNUC__ /* Gnu Compiler. */
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
#include "xptc_platforms_unixish_x86.h"
|
#include "xptc_platforms_unixish_x86.h"
|
||||||
#include "xptc_gcc_x86_unix.h"
|
#include "xptc_gcc_x86_unix.h"
|
||||||
|
|
||||||
|
@ -52,7 +53,6 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
|
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||||
nsIInterfaceInfo* iface_info = NULL;
|
|
||||||
const nsXPTMethodInfo* info;
|
const nsXPTMethodInfo* info;
|
||||||
PRUint8 paramCount;
|
PRUint8 paramCount;
|
||||||
PRUint8 i;
|
PRUint8 i;
|
||||||
|
@ -60,12 +60,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
|
|
||||||
NS_ASSERTION(self,"no self");
|
NS_ASSERTION(self,"no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&iface_info);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||||
NS_ASSERTION(iface_info,"no interface info");
|
|
||||||
|
|
||||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
|
||||||
NS_ASSERTION(info,"no interface info");
|
|
||||||
|
|
||||||
paramCount = info->GetParamCount();
|
paramCount = info->GetParamCount();
|
||||||
|
|
||||||
// setup variant array pointer
|
// setup variant array pointer
|
||||||
|
@ -97,9 +92,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||||
|
|
||||||
NS_RELEASE(iface_info);
|
|
||||||
|
|
||||||
if(dispatchParams != paramBuffer)
|
if(dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
|
|
||||||
/* Under the Mac OS X PowerPC ABI, the first 8 integer and 13 floating point
|
/* Under the Mac OS X PowerPC ABI, the first 8 integer and 13 floating point
|
||||||
* parameters are delivered in registers and are not on the stack, although
|
* parameters are delivered in registers and are not on the stack, although
|
||||||
|
@ -80,7 +81,6 @@ PrepareAndDispatch(
|
||||||
|
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant *dispatchParams = NULL;
|
nsXPTCMiniVariant *dispatchParams = NULL;
|
||||||
nsIInterfaceInfo *interfaceInfo = NULL;
|
|
||||||
const nsXPTMethodInfo *methodInfo;
|
const nsXPTMethodInfo *methodInfo;
|
||||||
PRUint8 paramCount;
|
PRUint8 paramCount;
|
||||||
PRUint8 i;
|
PRUint8 i;
|
||||||
|
@ -95,10 +95,7 @@ PrepareAndDispatch(
|
||||||
|
|
||||||
NS_ASSERTION(self, "no self");
|
NS_ASSERTION(self, "no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&interfaceInfo);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
|
||||||
NS_ASSERTION(interfaceInfo, "no interface info");
|
|
||||||
|
|
||||||
interfaceInfo->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
|
|
||||||
NS_ASSERTION(methodInfo, "no method info");
|
NS_ASSERTION(methodInfo, "no method info");
|
||||||
|
|
||||||
paramCount = methodInfo->GetParamCount();
|
paramCount = methodInfo->GetParamCount();
|
||||||
|
@ -181,9 +178,8 @@ PrepareAndDispatch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
|
result = self->mOuter->
|
||||||
|
CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
|
||||||
NS_RELEASE(interfaceInfo);
|
|
||||||
|
|
||||||
if(dispatchParams != paramBuffer)
|
if(dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
#include "xptc_platforms_unixish_x86.h"
|
#include "xptc_platforms_unixish_x86.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
||||||
|
@ -47,7 +48,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
||||||
|
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||||
nsIInterfaceInfo* iface_info = NULL;
|
|
||||||
const nsXPTMethodInfo* info;
|
const nsXPTMethodInfo* info;
|
||||||
PRUint8 paramCount;
|
PRUint8 paramCount;
|
||||||
PRUint8 i;
|
PRUint8 i;
|
||||||
|
@ -55,10 +55,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
||||||
|
|
||||||
NS_ASSERTION(self,"no self");
|
NS_ASSERTION(self,"no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&iface_info);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||||
NS_ASSERTION(iface_info,"no interface info");
|
|
||||||
|
|
||||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
|
||||||
NS_ASSERTION(info,"no interface info");
|
NS_ASSERTION(info,"no interface info");
|
||||||
|
|
||||||
paramCount = info->GetParamCount();
|
paramCount = info->GetParamCount();
|
||||||
|
@ -92,9 +89,8 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
result = self->mOuter->
|
||||||
|
CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||||
NS_RELEASE(iface_info);
|
|
||||||
|
|
||||||
if(dispatchParams != paramBuffer)
|
if(dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
// Implement shared vtbl methods.
|
// Implement shared vtbl methods.
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
|
|
||||||
// The Linux/x86-64 ABI passes the first 6 integer parameters and the
|
// The Linux/x86-64 ABI passes the first 6 integer parameters and the
|
||||||
// first 8 floating point parameters in registers (rdi, rsi, rdx, rcx,
|
// first 8 floating point parameters in registers (rdi, rsi, rdx, rcx,
|
||||||
|
@ -65,7 +66,6 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
|
||||||
{
|
{
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||||
nsIInterfaceInfo* iface_info = NULL;
|
|
||||||
const nsXPTMethodInfo* info;
|
const nsXPTMethodInfo* info;
|
||||||
PRUint32 paramCount;
|
PRUint32 paramCount;
|
||||||
PRUint32 i;
|
PRUint32 i;
|
||||||
|
@ -73,12 +73,7 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
|
||||||
|
|
||||||
NS_ASSERTION(self,"no self");
|
NS_ASSERTION(self,"no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&iface_info);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||||
NS_ASSERTION(iface_info,"no interface info");
|
|
||||||
if (!iface_info)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
|
||||||
NS_ASSERTION(info,"no method info");
|
NS_ASSERTION(info,"no method info");
|
||||||
if (!info)
|
if (!info)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
@ -153,9 +148,7 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
|
result = self->mOuter->CallMethod((PRUint16) methodIndex, info, dispatchParams);
|
||||||
|
|
||||||
NS_RELEASE(iface_info);
|
|
||||||
|
|
||||||
if (dispatchParams != paramBuffer)
|
if (dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -62,6 +62,9 @@ CPPSRCS = xptcinvoke.cpp xptcstubs.cpp
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
REQUIRES = string
|
||||||
|
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)/../../../../xptinfo/src
|
||||||
|
|
||||||
# Force use of PIC
|
# Force use of PIC
|
||||||
FORCE_USE_PIC = 1
|
FORCE_USE_PIC = 1
|
||||||
|
|
|
@ -77,9 +77,9 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning(disable : 4035) // OK to have no return value
|
#pragma warning(disable : 4035) // OK to have no return value
|
||||||
__declspec(naked) XPTC_PUBLIC_API(nsresult)
|
extern "C" NS_EXPORT __declspec(naked) nsresult NS_FROZENCALL
|
||||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||||
PRUint32 paramCount, nsXPTCVariant* params)
|
PRUint32 paramCount, nsXPTCVariant* params)
|
||||||
{
|
{
|
||||||
__asm {
|
__asm {
|
||||||
push ebp
|
push ebp
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
/* Implement shared vtbl methods. */
|
/* Implement shared vtbl methods. */
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#error "This code is for Win32 only"
|
#error "This code is for Win32 only"
|
||||||
|
@ -53,7 +54,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
||||||
|
|
||||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||||
nsIInterfaceInfo* iface_info = NULL;
|
|
||||||
const nsXPTMethodInfo* info = NULL;
|
const nsXPTMethodInfo* info = NULL;
|
||||||
PRUint8 paramCount;
|
PRUint8 paramCount;
|
||||||
PRUint8 i;
|
PRUint8 i;
|
||||||
|
@ -64,11 +64,8 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
||||||
|
|
||||||
NS_ASSERTION(self,"no self");
|
NS_ASSERTION(self,"no self");
|
||||||
|
|
||||||
self->GetInterfaceInfo(&iface_info);
|
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||||
NS_ASSERTION(iface_info,"no interface info");
|
NS_ASSERTION(info,"no method info");
|
||||||
|
|
||||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
|
||||||
NS_ASSERTION(info,"no interface info");
|
|
||||||
|
|
||||||
paramCount = info->GetParamCount();
|
paramCount = info->GetParamCount();
|
||||||
|
|
||||||
|
@ -114,9 +111,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
||||||
}
|
}
|
||||||
*stackBytesToPop = ((PRUint32)ap) - ((PRUint32)args);
|
*stackBytesToPop = ((PRUint32)ap) - ((PRUint32)args);
|
||||||
|
|
||||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||||
|
|
||||||
NS_RELEASE(iface_info);
|
|
||||||
|
|
||||||
if(dispatchParams != paramBuffer)
|
if(dispatchParams != paramBuffer)
|
||||||
delete [] dispatchParams;
|
delete [] dispatchParams;
|
||||||
|
|
|
@ -38,18 +38,58 @@
|
||||||
/* entry point wrappers. */
|
/* entry point wrappers. */
|
||||||
|
|
||||||
#include "xptcprivate.h"
|
#include "xptcprivate.h"
|
||||||
|
#include "xptiprivate.h"
|
||||||
|
|
||||||
// This method is never called and is only here so the compiler
|
NS_IMETHODIMP
|
||||||
// will generate a vtbl for this class.
|
nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
||||||
// *Needed by the Irix implementation.*
|
void **aInstancePtr)
|
||||||
NS_IMETHODIMP nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
|
||||||
void** aInstancePtr)
|
|
||||||
{
|
{
|
||||||
NS_ASSERTION(0,"wowa! nsXPTCStubBase::QueryInterface called");
|
if (aIID.Equals(mEntry->mIID)) {
|
||||||
return NS_ERROR_FAILURE;
|
NS_ADDREF_THIS();
|
||||||
|
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mOuter->QueryInterface(aIID, aInstancePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
NS_IMETHODIMP_(nsrefcnt)
|
||||||
xptc_dummy2()
|
nsXPTCStubBase::AddRef()
|
||||||
{
|
{
|
||||||
|
return mOuter->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP_(nsrefcnt)
|
||||||
|
nsXPTCStubBase::Release()
|
||||||
|
{
|
||||||
|
return mOuter->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT_XPCOM_API(nsresult)
|
||||||
|
NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||||
|
nsISomeInterface* *aResult)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG(aOuter && aResult);
|
||||||
|
|
||||||
|
xptiInterfaceInfoManager *iim =
|
||||||
|
xptiInterfaceInfoManager::GetInterfaceInfoManagerNoAddRef();
|
||||||
|
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
|
xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
|
||||||
|
if (!iie || !iie->EnsureResolved())
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsXPTCStubBase* newbase = new nsXPTCStubBase(aOuter, iie);
|
||||||
|
if (!newbase)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
*aResult = newbase;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT_XPCOM_API(void)
|
||||||
|
NS_DestroyXPTCallStub(nsISomeInterface* aStub)
|
||||||
|
{
|
||||||
|
nsXPTCStubBase* stub = NS_STATIC_CAST(nsXPTCStubBase*, aStub);
|
||||||
|
delete(stub);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,5 +41,52 @@
|
||||||
#define xptcprivate_h___
|
#define xptcprivate_h___
|
||||||
|
|
||||||
#include "xptcall.h"
|
#include "xptcall.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
|
|
||||||
|
class xptiInterfaceEntry;
|
||||||
|
|
||||||
|
#if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__))
|
||||||
|
#define STUB_ENTRY(n) NS_IMETHOD Stub##n() = 0;
|
||||||
|
#else
|
||||||
|
#define STUB_ENTRY(n) NS_IMETHOD Stub##n(PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SENTINEL_ENTRY(n) NS_IMETHOD Sentinel##n() = 0;
|
||||||
|
|
||||||
|
class nsIXPTCStubBase : public nsISupports
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#include "xptcstubsdef.inc"
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef STUB_ENTRY
|
||||||
|
#undef SENTINEL_ENTRY
|
||||||
|
|
||||||
|
#if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__))
|
||||||
|
#define STUB_ENTRY(n) NS_IMETHOD Stub##n();
|
||||||
|
#else
|
||||||
|
#define STUB_ENTRY(n) NS_IMETHOD Stub##n(PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SENTINEL_ENTRY(n) NS_IMETHOD Sentinel##n();
|
||||||
|
|
||||||
|
class nsXPTCStubBase : public nsIXPTCStubBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
|
#include "xptcstubsdef.inc"
|
||||||
|
|
||||||
|
nsXPTCStubBase(nsIXPTCProxy* aOuter, xptiInterfaceEntry *aEntry) :
|
||||||
|
mOuter(aOuter), mEntry(aEntry) { }
|
||||||
|
|
||||||
|
nsIXPTCProxy* mOuter;
|
||||||
|
xptiInterfaceEntry* mEntry;
|
||||||
|
|
||||||
|
~nsXPTCStubBase() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef STUB_ENTRY
|
||||||
|
#undef SENTINEL_ENTRY
|
||||||
|
|
||||||
#endif /* xptcprivate_h___ */
|
#endif /* xptcprivate_h___ */
|
||||||
|
|
|
@ -413,7 +413,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.i32;
|
var[2].ptr = &var[2].val.i32;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 3, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 3, 3, var)))
|
||||||
printf("\t1 + 1 = %d\n", var[2].val.i32);
|
printf("\t1 + 1 = %d\n", var[2].val.i32);
|
||||||
else
|
else
|
||||||
printf("\tFAILED");
|
printf("\tFAILED");
|
||||||
|
@ -431,7 +431,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.i64;
|
var[2].ptr = &var[2].val.i64;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 5, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 5, 3, var)))
|
||||||
printf("\t1L + 1L = %d\n", (int)var[2].val.i64);
|
printf("\t1L + 1L = %d\n", (int)var[2].val.i64);
|
||||||
else
|
else
|
||||||
printf("\tFAILED");
|
printf("\tFAILED");
|
||||||
|
@ -449,7 +449,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.i32;
|
var[2].ptr = &var[2].val.i32;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 4, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 4, 3, var)))
|
||||||
printf("\t2 * 2 = %d\n", var[2].val.i32);
|
printf("\t2 * 2 = %d\n", var[2].val.i32);
|
||||||
else
|
else
|
||||||
printf("\tFAILED");
|
printf("\tFAILED");
|
||||||
|
@ -467,7 +467,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.i64;
|
var[2].ptr = &var[2].val.i64;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 6, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 6, 3, var)))
|
||||||
printf("\t2L * 2L = %d\n", (int)var[2].val.i64);
|
printf("\t2L * 2L = %d\n", (int)var[2].val.i64);
|
||||||
else
|
else
|
||||||
printf("\tFAILED");
|
printf("\tFAILED");
|
||||||
|
@ -517,7 +517,7 @@ int main()
|
||||||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[10].ptr = &var[10].val.i32;
|
var[10].ptr = &var[10].val.i32;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 7, 11, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 7, 11, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
||||||
var[10].val.i32);
|
var[10].val.i32);
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.f;
|
var[2].ptr = &var[2].val.f;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 8, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 8, 3, var)))
|
||||||
printf("\t1 + 2 = %ff\n",
|
printf("\t1 + 2 = %ff\n",
|
||||||
(double) var[2].val.f);
|
(double) var[2].val.f);
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ int main()
|
||||||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[10].ptr = &var[10].val.d;
|
var[10].ptr = &var[10].val.d;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 9, 11, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 9, 11, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %f\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %f\n",
|
||||||
var[10].val.d);
|
var[10].val.d);
|
||||||
else
|
else
|
||||||
|
@ -635,7 +635,7 @@ int main()
|
||||||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[10].ptr = &var[10].val.f;
|
var[10].ptr = &var[10].val.f;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 10, 11, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 10, 11, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %ff\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %ff\n",
|
||||||
(double) var[10].val.f);
|
(double) var[10].val.f);
|
||||||
else
|
else
|
||||||
|
@ -726,7 +726,7 @@ int main()
|
||||||
var[20].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[20].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[20].ptr = &var[20].val.f;
|
var[20].ptr = &var[20].val.f;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 11, 21, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 11, 21, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 = %ff\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 = %ff\n",
|
||||||
(double) var[20].val.f);
|
(double) var[20].val.f);
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ int main()
|
||||||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[10].ptr = &var[10].val.i64;
|
var[10].ptr = &var[10].val.i64;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 12, 11, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 12, 11, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
||||||
(int)var[10].val.i64);
|
(int)var[10].val.i64);
|
||||||
else
|
else
|
||||||
|
@ -826,7 +826,7 @@ int main()
|
||||||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[10].ptr = &var[10].val.i64;
|
var[10].ptr = &var[10].val.i64;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 13, 11, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 13, 11, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = %d\n",
|
||||||
(int)var[10].val.i64);
|
(int)var[10].val.i64);
|
||||||
else
|
else
|
||||||
|
@ -881,7 +881,7 @@ int main()
|
||||||
var[11].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[11].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[11].ptr = &var[11].val.d;
|
var[11].ptr = &var[11].val.d;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 14, 12, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 14, 12, var)))
|
||||||
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 = %f\n",
|
printf("\t1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 = %f\n",
|
||||||
var[11].val.d);
|
var[11].val.d);
|
||||||
else
|
else
|
||||||
|
@ -900,7 +900,7 @@ int main()
|
||||||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||||
var[2].ptr = &var[2].val.p;
|
var[2].ptr = &var[2].val.p;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(XPTC_InvokeByIndex(test, 15, 3, var)))
|
if(NS_SUCCEEDED(NS_InvokeByIndex(test, 15, 3, var)))
|
||||||
printf(" = %s\n", var[2].val.p);
|
printf(" = %s\n", var[2].val.p);
|
||||||
else
|
else
|
||||||
printf("\tFAILED");
|
printf("\tFAILED");
|
||||||
|
@ -1119,12 +1119,12 @@ static void DoMultipleInheritenceTest()
|
||||||
var[0].val.i32 = 1;
|
var[0].val.i32 = 1;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(foo, 3, 1, var);
|
NS_InvokeByIndex(foo, 3, 1, var);
|
||||||
|
|
||||||
var[0].val.i32 = 2;
|
var[0].val.i32 = 2;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(foo, 4, 1, var);
|
NS_InvokeByIndex(foo, 4, 1, var);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -1137,12 +1137,12 @@ static void DoMultipleInheritenceTest()
|
||||||
var[0].val.i32 = 1;
|
var[0].val.i32 = 1;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(bar, 3, 1, var);
|
NS_InvokeByIndex(bar, 3, 1, var);
|
||||||
|
|
||||||
var[0].val.i32 = 2;
|
var[0].val.i32 = 2;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(bar, 4, 1, var);
|
NS_InvokeByIndex(bar, 4, 1, var);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -1289,12 +1289,12 @@ static void DoMultipleInheritenceTest2()
|
||||||
var[0].val.i32 = 1;
|
var[0].val.i32 = 1;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(foo, 3, 1, var);
|
NS_InvokeByIndex(foo, 3, 1, var);
|
||||||
|
|
||||||
var[0].val.i32 = 2;
|
var[0].val.i32 = 2;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(foo, 4, 1, var);
|
NS_InvokeByIndex(foo, 4, 1, var);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -1307,12 +1307,12 @@ static void DoMultipleInheritenceTest2()
|
||||||
var[0].val.i32 = 1;
|
var[0].val.i32 = 1;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(bar, 3, 1, var);
|
NS_InvokeByIndex(bar, 3, 1, var);
|
||||||
|
|
||||||
var[0].val.i32 = 2;
|
var[0].val.i32 = 2;
|
||||||
var[0].type = nsXPTType::T_I32;
|
var[0].type = nsXPTType::T_I32;
|
||||||
var[0].flags = 0;
|
var[0].flags = 0;
|
||||||
XPTC_InvokeByIndex(bar, 4, 1, var);
|
NS_InvokeByIndex(bar, 4, 1, var);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -1362,7 +1362,7 @@ static void DoSpeedTest()
|
||||||
printf("Doing %d invoked call iterations...\n", count);
|
printf("Doing %d invoked call iterations...\n", count);
|
||||||
start = PR_IntervalNow();
|
start = PR_IntervalNow();
|
||||||
for(i = count; i; i--)
|
for(i = count; i; i--)
|
||||||
(void)XPTC_InvokeByIndex(test, 3, 3, var);
|
(void)NS_InvokeByIndex(test, 3, 3, var);
|
||||||
interval_invoke = PR_IntervalNow() - start;
|
interval_invoke = PR_IntervalNow() - start;
|
||||||
|
|
||||||
printf(" direct took %0.2f seconds\n",
|
printf(" direct took %0.2f seconds\n",
|
||||||
|
|
|
@ -1724,18 +1724,21 @@ EntryToInfo(xptiInterfaceEntry* entry, nsIInterfaceInfo **_retval)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xptiInterfaceEntry*
|
||||||
|
xptiInterfaceInfoManager::GetInterfaceEntryForIID(const nsIID *iid)
|
||||||
|
{
|
||||||
|
xptiHashEntry *hashEntry = (xptiHashEntry*)
|
||||||
|
PL_DHashTableOperate(mWorkingSet.mIIDTable, iid, PL_DHASH_LOOKUP);
|
||||||
|
return PL_DHASH_ENTRY_IS_FREE(hashEntry) ? nsnull : hashEntry->value;
|
||||||
|
}
|
||||||
|
|
||||||
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
||||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(iid, "bad param");
|
NS_ASSERTION(iid, "bad param");
|
||||||
NS_ASSERTION(_retval, "bad param");
|
NS_ASSERTION(_retval, "bad param");
|
||||||
|
|
||||||
xptiHashEntry* hashEntry = (xptiHashEntry*)
|
xptiInterfaceEntry* entry = GetInterfaceEntryForIID(iid);
|
||||||
PL_DHashTableOperate(mWorkingSet.mIIDTable, iid, PL_DHASH_LOOKUP);
|
|
||||||
|
|
||||||
xptiInterfaceEntry* entry =
|
|
||||||
PL_DHASH_ENTRY_IS_FREE(hashEntry) ? nsnull : hashEntry->value;
|
|
||||||
|
|
||||||
return EntryToInfo(entry, _retval);
|
return EntryToInfo(entry, _retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -627,6 +627,8 @@ public:
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
|
nsID mIID;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
xptiInterfaceEntry(); // not implemented
|
xptiInterfaceEntry(); // not implemented
|
||||||
|
|
||||||
|
@ -666,7 +668,6 @@ private:
|
||||||
const XPTTypeDescriptor** type);
|
const XPTTypeDescriptor** type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsID mIID;
|
|
||||||
union {
|
union {
|
||||||
xptiTypelib mTypelib; // Valid only until resolved.
|
xptiTypelib mTypelib; // Valid only until resolved.
|
||||||
xptiInterfaceGuts* mInterface; // Valid only after resolved.
|
xptiInterfaceGuts* mInterface; // Valid only after resolved.
|
||||||
|
@ -906,6 +907,8 @@ public:
|
||||||
|
|
||||||
static void WriteToLog(const char *fmt, ...);
|
static void WriteToLog(const char *fmt, ...);
|
||||||
|
|
||||||
|
xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~xptiInterfaceInfoManager();
|
~xptiInterfaceInfoManager();
|
||||||
xptiInterfaceInfoManager(); // not implmented
|
xptiInterfaceInfoManager(); // not implmented
|
||||||
|
|
Загрузка…
Ссылка в новой задаче