зеркало из https://github.com/mozilla/gecko-dev.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:
Родитель
d64ea70394
Коммит
122614bb23
|
@ -519,7 +519,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
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
|
||||
// could thus stay alive longer than this function.
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
@ -48,7 +49,7 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXTFInterfaceAggregator class
|
||||
|
||||
class nsXTFInterfaceAggregator : public nsXPTCStubBase
|
||||
class nsXTFInterfaceAggregator : protected nsAutoXPTCStub
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
|
@ -59,18 +60,16 @@ protected:
|
|||
|
||||
nsXTFInterfaceAggregator(const nsIID& iid,
|
||||
nsISupports* inner,
|
||||
nsISupports* outer);
|
||||
nsISupports* outer,
|
||||
nsresult *rv);
|
||||
~nsXTFInterfaceAggregator();
|
||||
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsXPTCStubBase
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
private:
|
||||
|
@ -84,7 +83,8 @@ private:
|
|||
|
||||
nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
|
||||
nsISupports* inner,
|
||||
nsISupports* outer)
|
||||
nsISupports* outer,
|
||||
nsresult *rv)
|
||||
: mInner(inner), mOuter(outer), mIID(iid)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -92,6 +92,8 @@ nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
|
|||
#endif
|
||||
mInner->AddRef();
|
||||
mOuter->AddRef();
|
||||
|
||||
*rv = InitStub(iid);
|
||||
}
|
||||
|
||||
nsXTFInterfaceAggregator::~nsXTFInterfaceAggregator()
|
||||
|
@ -112,13 +114,17 @@ NS_NewXTFInterfaceAggregator(const nsIID& iid,
|
|||
if (!aResult)
|
||||
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)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
return NS_OK;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return result->QueryInterface(iid, aResult);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -131,7 +137,7 @@ NS_IMETHODIMP
|
|||
nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if(aIID.Equals(mIID)) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
*aInstancePtr = mXPTCStub;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -141,37 +147,34 @@ nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
//----------------------------------------------------------------------
|
||||
// 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
|
||||
nsXTFInterfaceAggregator::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor *info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
if (methodIndex < 3) {
|
||||
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFInterfaceAggregator.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ASSERTION(methodIndex >= 3,
|
||||
"huh? indirect nsISupports method call unexpected");
|
||||
|
||||
// prepare args:
|
||||
int paramCount = info->GetParamCount();
|
||||
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
|
||||
int paramCount = info->num_args;
|
||||
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) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(i);
|
||||
const nsXPTParamInfo& paramInfo = info->params[i];
|
||||
PRUint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
||||
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
||||
}
|
||||
|
||||
// make the call:
|
||||
nsresult rv = XPTC_InvokeByIndex(mInner,
|
||||
nsresult rv = NS_InvokeByIndex(mInner,
|
||||
methodIndex,
|
||||
paramCount,
|
||||
fullPars);
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
@ -48,27 +49,21 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXTFWeakTearoff class
|
||||
|
||||
class nsXTFWeakTearoff : public nsXPTCStubBase
|
||||
class nsXTFWeakTearoff : protected nsAutoXPTCStub
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewXTFWeakTearoff(const nsIID& iid,
|
||||
nsISupports* obj,
|
||||
nsISupports** result);
|
||||
|
||||
nsXTFWeakTearoff(const nsIID& iid,
|
||||
nsISupports* obj);
|
||||
~nsXTFWeakTearoff();
|
||||
|
||||
public:
|
||||
nsXTFWeakTearoff(const nsIID& iid,
|
||||
nsISupports* obj,
|
||||
nsresult *rv);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsXPTCStubBase
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
private:
|
||||
|
@ -80,19 +75,18 @@ private:
|
|||
// implementation:
|
||||
|
||||
nsXTFWeakTearoff::nsXTFWeakTearoff(const nsIID& iid,
|
||||
nsISupports* obj)
|
||||
nsISupports* obj,
|
||||
nsresult *rv)
|
||||
: mObj(obj), mIID(iid)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// printf("nsXTFWeakTearoff CTOR\n");
|
||||
#endif
|
||||
MOZ_COUNT_CTOR(nsXTFWeakTearoff);
|
||||
|
||||
*rv = InitStub(iid);
|
||||
}
|
||||
|
||||
nsXTFWeakTearoff::~nsXTFWeakTearoff()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// printf("nsXTFWeakTearoff DTOR\n");
|
||||
#endif
|
||||
MOZ_COUNT_DTOR(nsXTFWeakTearoff);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -103,13 +97,17 @@ NS_NewXTFWeakTearoff(const nsIID& iid,
|
|||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsXTFWeakTearoff* result = new nsXTFWeakTearoff(iid,obj);
|
||||
nsresult rv;
|
||||
|
||||
nsRefPtr<nsXTFWeakTearoff> result =
|
||||
new nsXTFWeakTearoff(iid, obj, &rv);
|
||||
if (!result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
return NS_OK;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return result->QueryInterface(iid, (void**) aResult);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -122,53 +120,44 @@ NS_IMETHODIMP
|
|||
nsXTFWeakTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if(aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
*aInstancePtr = mXPTCStub;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
// we can't map QI onto the obj, because the xpcom wrapper otherwise
|
||||
// QI-accumulates all interfaces defined on mObj
|
||||
// else return mObj->QueryInterface(aIID, aInstancePtr);
|
||||
else 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);
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXTFWeakTearoff::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
if (methodIndex < 3) {
|
||||
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFWeakTearoff.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ASSERTION(methodIndex >= 3,
|
||||
"huh? indirect nsISupports method call unexpected");
|
||||
|
||||
// prepare args:
|
||||
int paramCount = info->GetParamCount();
|
||||
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
|
||||
int paramCount = info->num_args;
|
||||
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) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(i);
|
||||
const nsXPTParamInfo& paramInfo = info->params[i];
|
||||
uint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
|
||||
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
|
||||
}
|
||||
|
||||
// make the call:
|
||||
nsresult rv = XPTC_InvokeByIndex(mObj,
|
||||
methodIndex,
|
||||
paramCount,
|
||||
fullPars);
|
||||
nsresult rv = NS_InvokeByIndex(mObj, methodIndex, paramCount, fullPars);
|
||||
if (fullPars)
|
||||
delete []fullPars;
|
||||
return rv;
|
||||
|
|
|
@ -1477,7 +1477,7 @@ JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
|||
ThrowException(env, rv, "Failed to get real XPCOM object");
|
||||
return nsnull;
|
||||
}
|
||||
nsresult invokeResult = XPTC_InvokeByIndex(realObject, methodIndex,
|
||||
nsresult invokeResult = NS_InvokeByIndex(realObject, methodIndex,
|
||||
paramCount, params);
|
||||
NS_RELEASE(realObject);
|
||||
|
||||
|
|
|
@ -881,8 +881,7 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (stub) {
|
||||
// stub is already AddRef'd and QI'd
|
||||
*aResult = NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsXPTCStubBase*, stub));
|
||||
*aResult = stub->GetStub();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -901,10 +900,14 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Create XPCOM stub
|
||||
stub = new nsJavaXPTCStub(aJavaObject, iinfo);
|
||||
if (!stub) {
|
||||
stub = new nsJavaXPTCStub(aJavaObject, iinfo, &rv);
|
||||
if (!stub)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (NS_FAILED(rv)) {
|
||||
delete stub;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = gJavaToXPTCStubMap->Add(hash, stub);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete stub;
|
||||
|
@ -912,14 +915,14 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
|||
}
|
||||
|
||||
NS_ADDREF(stub);
|
||||
*aResult = NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsXPTCStubBase*, stub));
|
||||
*aResult = stub->GetStub();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
||||
GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
||||
const XPTMethodDescriptor *methodInfo,
|
||||
const nsXPTParamInfo ¶mInfo, PRUint8 paramType,
|
||||
PRUint16 methodIndex, nsXPTCMiniVariant *dispatchParams,
|
||||
PRBool isFullVariantArray, nsID &result)
|
||||
|
@ -940,7 +943,7 @@ GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
|||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
const nsXPTParamInfo& arg_param = methodInfo->GetParam(argnum);
|
||||
const nsXPTParamInfo& arg_param = methodInfo->params[argnum];
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
|
||||
// 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);
|
||||
|
||||
nsresult GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
||||
const nsXPTMethodInfo *methodInfo,
|
||||
const XPTMethodDescriptor *methodInfo,
|
||||
const nsXPTParamInfo ¶mInfo,
|
||||
PRUint8 paramType, PRUint16 methodIndex,
|
||||
nsXPTCMiniVariant *dispatchParams,
|
||||
|
|
|
@ -46,12 +46,21 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
|
||||
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo)
|
||||
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
|
||||
nsresult *rv)
|
||||
: mJavaStrongRef(nsnull)
|
||||
, mIInfo(aIInfo)
|
||||
, mMaster(nsnull)
|
||||
, 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();
|
||||
jobject weakref = env->NewObject(weakReferenceClass,
|
||||
weakReferenceConstructorMID, aJavaObject);
|
||||
|
@ -60,13 +69,10 @@ nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo)
|
|||
aJavaObject);
|
||||
|
||||
#ifdef DEBUG_JAVAXPCOM
|
||||
nsIID* iid;
|
||||
mIInfo->GetInterfaceIID(&iid);
|
||||
char* iid_str = iid->ToString();
|
||||
LOG(("+ nsJavaXPTCStub (Java=%08x | XPCOM=%08x | IID=%s)\n",
|
||||
(PRUint32) mJavaRefHashCode, (PRUint32) this, iid_str));
|
||||
PR_Free(iid_str);
|
||||
nsMemory::Free(iid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -236,8 +242,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
|||
// always return the master stub for nsISupports
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports)))
|
||||
{
|
||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsXPTCStubBase*, master));
|
||||
*aInstancePtr = master->mXPTCStub;
|
||||
NS_ADDREF(master);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -254,7 +259,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
|||
nsJavaXPTCStub *stub = master->FindStubSupportingIID(aIID);
|
||||
if (stub)
|
||||
{
|
||||
*aInstancePtr = stub;
|
||||
*aInstancePtr = stub->mXPTCStub;
|
||||
NS_ADDREF(stub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -309,10 +314,15 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
stub = new nsJavaXPTCStub(obj, iinfo);
|
||||
stub = new nsJavaXPTCStub(obj, iinfo, &rv);
|
||||
if (!stub)
|
||||
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
|
||||
// symmetry in future QI calls. the master will delete each child
|
||||
// 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;
|
||||
master->mChildren.AppendElement(stub);
|
||||
|
||||
*aInstancePtr = stub;
|
||||
*aInstancePtr = stub->mXPTCStub;
|
||||
NS_ADDREF(stub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -378,22 +388,15 @@ nsJavaXPTCStub::FindStubSupportingIID(const nsID &iid)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJavaXPTCStub::GetInterfaceInfo(nsIInterfaceInfo **aInfo)
|
||||
{
|
||||
NS_ADDREF(*aInfo = mIInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||
const nsXPTMethodInfo *aMethodInfo,
|
||||
const XPTMethodDescriptor *aMethodInfo,
|
||||
nsXPTCMiniVariant *aParams)
|
||||
{
|
||||
#ifdef DEBUG_JAVAXPCOM
|
||||
const char* ifaceName;
|
||||
mIInfo->GetNameShared(&ifaceName);
|
||||
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
|
||||
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
|
||||
#endif
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -403,7 +406,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
nsCAutoString methodSig("(");
|
||||
|
||||
// Create jvalue array to hold Java params
|
||||
PRUint8 paramCount = aMethodInfo->GetParamCount();
|
||||
PRUint8 paramCount = aMethodInfo->num_args;
|
||||
jvalue* java_params = nsnull;
|
||||
const nsXPTParamInfo* retvalInfo = nsnull;
|
||||
if (paramCount) {
|
||||
|
@ -413,7 +416,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
|
||||
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()) {
|
||||
rv = SetupJavaParams(paramInfo, aMethodInfo, aMethodIndex, aParams,
|
||||
aParams[i], java_params[i], methodSig);
|
||||
|
@ -442,15 +445,16 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
jmethodID mid = nsnull;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString methodName;
|
||||
if (aMethodInfo->IsGetter() || aMethodInfo->IsSetter()) {
|
||||
if (aMethodInfo->IsGetter())
|
||||
if (XPT_MD_IS_GETTER(aMethodInfo->flags) ||
|
||||
XPT_MD_IS_SETTER(aMethodInfo->flags)) {
|
||||
if (XPT_MD_IS_GETTER(aMethodInfo->flags))
|
||||
methodName.AppendLiteral("get");
|
||||
else
|
||||
methodName.AppendLiteral("set");
|
||||
methodName.AppendASCII(aMethodInfo->GetName());
|
||||
methodName.AppendASCII(aMethodInfo->name);
|
||||
methodName.SetCharAt(toupper(methodName[3]), 3);
|
||||
} else {
|
||||
methodName.AppendASCII(aMethodInfo->GetName());
|
||||
methodName.AppendASCII(aMethodInfo->name);
|
||||
methodName.SetCharAt(tolower(methodName[0]), 0);
|
||||
}
|
||||
// If it's a Java keyword, then prepend an underscore
|
||||
|
@ -558,7 +562,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
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'
|
||||
continue;
|
||||
|
||||
|
@ -586,7 +590,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
#endif
|
||||
env->ExceptionClear();
|
||||
|
||||
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
|
||||
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -595,7 +599,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
|||
*/
|
||||
nsresult
|
||||
nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor* aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsXPTCMiniVariant &aVariant, jvalue &aJValue,
|
||||
|
@ -1059,7 +1063,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
|||
|
||||
nsresult
|
||||
nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor* aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsACString &aRetvalSig)
|
||||
|
@ -1169,7 +1173,7 @@ nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
|||
*/
|
||||
nsresult
|
||||
nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor *aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsXPTCMiniVariant &aVariant, jvalue &aJValue)
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#ifndef _nsJavaXPTCStub_h_
|
||||
#define _nsJavaXPTCStub_h_
|
||||
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "jni.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
@ -50,7 +50,7 @@
|
|||
#define NS_JAVAXPTCSTUB_IID \
|
||||
{0x88dd8130, 0xebe6, 0x4431, {0x9d, 0xa7, 0xe6, 0xb7, 0x54, 0x74, 0xfb, 0x21}}
|
||||
|
||||
class nsJavaXPTCStub : public nsXPTCStubBase,
|
||||
class nsJavaXPTCStub : protected nsAutoXPTCStub,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsJavaXPTCStubWeakRef;
|
||||
|
@ -60,19 +60,18 @@ public:
|
|||
NS_DECL_NSISUPPORTSWEAKREFERENCE
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JAVAXPTCSTUB_IID)
|
||||
|
||||
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo);
|
||||
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
|
||||
nsresult *rv);
|
||||
|
||||
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
|
||||
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
|
||||
const nsXPTMethodInfo *aInfo,
|
||||
const XPTMethodDescriptor *aInfo,
|
||||
nsXPTCMiniVariant *aParams);
|
||||
|
||||
nsISomeInterface* GetStub() { return mXPTCStub; }
|
||||
|
||||
// getter for mJavaObject
|
||||
jobject GetJavaObject();
|
||||
|
||||
|
@ -101,18 +100,18 @@ private:
|
|||
PRBool SupportsIID(const nsID &aIID);
|
||||
|
||||
nsresult SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor* aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsXPTCMiniVariant &aVariant,
|
||||
jvalue &aJValue, nsACString &aMethodSig);
|
||||
nsresult GetRetvalSig(const nsXPTParamInfo* aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor* aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsACString &aRetvalSig);
|
||||
nsresult FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
const XPTMethodDescriptor* aMethodInfo,
|
||||
PRUint16 aMethodIndex,
|
||||
nsXPTCMiniVariant* aDispatchParams,
|
||||
nsXPTCMiniVariant &aVariant,
|
||||
|
|
|
@ -44,7 +44,7 @@ from xpcom import xpt, COMException, nsError, logger
|
|||
from xpcom._xpcom import IID_nsISupports, IID_nsIClassInfo, \
|
||||
IID_nsISupportsCString, IID_nsISupportsString, \
|
||||
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
|
||||
# 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 = """
|
||||
def %s(self, %s):
|
||||
return XPTC_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
|
||||
return NS_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
|
||||
"""
|
||||
def _MakeMethodCode(method):
|
||||
# Build a declaration
|
||||
|
@ -457,7 +457,7 @@ class _Interface(_XPCOMBase):
|
|||
if len(param_infos)!=1: # Only expecting a retval
|
||||
raise RuntimeError, "Can't get properties with this many args!"
|
||||
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.
|
||||
# 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
|
||||
raise RuntimeError, "Can't set properties with this many args!"
|
||||
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):
|
||||
return "<XPCOM interface '%s'>" % (self._object_name_,)
|
||||
|
|
|
@ -144,7 +144,7 @@ PyXPCOMMethod_XPTI_GetInterfaceInfoManager(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
PyXPCOMMethod_XPTC_InvokeByIndex(PyObject *self, PyObject *args)
|
||||
PyXPCOMMethod_NS_InvokeByIndex(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *obIS, *obParams;
|
||||
nsCOMPtr<nsISupports> pis;
|
||||
|
@ -182,7 +182,7 @@ PyXPCOMMethod_XPTC_InvokeByIndex(PyObject *self, PyObject *args)
|
|||
|
||||
nsresult r;
|
||||
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;
|
||||
if ( NS_FAILED(r) )
|
||||
return PyXPCOM_BuildPyException(r);
|
||||
|
@ -435,7 +435,7 @@ static struct PyMethodDef xpcom_methods[]=
|
|||
{"GetComponentManager", PyXPCOMMethod_GetComponentManager, 1},
|
||||
{"GetComponentRegistrar", PyXPCOMMethod_GetComponentRegistrar, 1},
|
||||
{"XPTI_GetInterfaceInfoManager", PyXPCOMMethod_XPTI_GetInterfaceInfoManager, 1},
|
||||
{"XPTC_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
|
||||
{"NS_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
|
||||
{"GetServiceManager", PyXPCOMMethod_GetServiceManager, 1},
|
||||
{"IID", PyXPCOMMethod_IID, 1}, // IID is wrong - deprecated - not just IID, but CID, etc.
|
||||
{"ID", PyXPCOMMethod_IID, 1}, // This is the official name.
|
||||
|
|
|
@ -255,7 +255,7 @@ WSPCallContext::CallCompletionListener()
|
|||
dispatchParams[1].SetValIsInterface();
|
||||
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) {
|
||||
nsCOMPtr<nsIWSDLBinding> binding;
|
||||
|
@ -410,7 +410,7 @@ WSPCallContext::CallCompletionListener()
|
|||
dispatchParams[paramIndex].type.flags =
|
||||
XPT_TDP_POINTER | TD_INTERFACE_TYPE;
|
||||
|
||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
rv = NS_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
paramCount, dispatchParams);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -350,7 +350,7 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
|
||||
rv = NS_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
|
||||
numParams, var);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#include "nsSOAPUtils.h"
|
||||
|
||||
// interface info includes
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
||||
// WSDL includes
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
nsACString& aCIdentifier);
|
||||
};
|
||||
|
||||
class WSPProxy : public nsXPTCStubBase,
|
||||
class WSPProxy : protected nsAutoXPTCStub,
|
||||
public nsIWebServiceProxy,
|
||||
public nsIClassInfo
|
||||
{
|
||||
|
@ -104,11 +104,9 @@ public:
|
|||
NS_DECL_NSIWEBSERVICEPROXY
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
||||
void CallCompleted(WSPCallContext* aContext);
|
||||
|
@ -252,7 +250,7 @@ protected:
|
|||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
};
|
||||
|
||||
class WSPPropertyBagWrapper : public nsXPTCStubBase,
|
||||
class WSPPropertyBagWrapper : protected nsAutoXPTCStub,
|
||||
public nsIWebServicePropertyBagWrapper,
|
||||
public nsIClassInfo
|
||||
{
|
||||
|
@ -264,11 +262,9 @@ public:
|
|||
NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
|
|
@ -58,7 +58,9 @@ WSPPropertyBagWrapper::Init(nsIPropertyBag* aPropertyBag,
|
|||
mPropertyBag = aPropertyBag;
|
||||
mInterfaceInfo = aInterfaceInfo;
|
||||
mInterfaceInfo->GetIIDShared(&mIID);
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = InitStub(*mIID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
@ -85,8 +87,11 @@ NS_IMPL_RELEASE(WSPPropertyBagWrapper)
|
|||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIXPTCProxy*, this);
|
||||
}
|
||||
if(mXPTCStub && mIID && aIID.Equals(*mIID)) {
|
||||
*aInstancePtr = mXPTCStub;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
|
||||
|
@ -103,7 +108,7 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
if (methodIndex < 3) {
|
||||
|
@ -114,7 +119,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
nsresult rv = NS_OK;
|
||||
nsAutoString propName;
|
||||
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()), propName);
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->name), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -126,8 +131,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (info->IsGetter()) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
||||
if (XPT_MD_IS_GETTER(info->flags)) {
|
||||
const nsXPTParamInfo& paramInfo = info->params[0];
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
uint8 type_tag = type.TagPart();
|
||||
|
||||
|
@ -141,12 +146,12 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
|
||||
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
|
||||
// method.
|
||||
|
||||
// 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();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
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.
|
||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
||||
const nsXPTParamInfo& paramInfo2 = info->params[1];
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
|
@ -187,17 +192,6 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::GetInterfaceInfo(nsIInterfaceInfo** info)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(info);
|
||||
|
||||
*info = mInterfaceInfo;
|
||||
NS_ADDREF(*info);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation of nsIClassInfo
|
||||
|
|
|
@ -80,6 +80,10 @@ WSPProxy::Init(nsIWSDLPort* aPort, nsIInterfaceInfo* aPrimaryInterface,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
rv = InitStub(*mIID);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mInterfaces = do_CreateInstance(NS_SCRIPTABLE_INTERFACES_CONTRACTID, &rv);
|
||||
if (!mInterfaces) {
|
||||
return rv;
|
||||
|
@ -135,8 +139,13 @@ NS_IMPL_RELEASE(WSPProxy)
|
|||
NS_IMETHODIMP
|
||||
WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIXPTCProxy*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if(mXPTCStub && mIID && aIID.Equals(*mIID)) {
|
||||
*aInstancePtr = mXPTCStub;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -177,7 +186,7 @@ WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
*/
|
||||
NS_IMETHODIMP
|
||||
WSPProxy::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -293,7 +302,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint32 i, 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
|
||||
// body vs. header blocks
|
||||
|
@ -450,7 +459,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint32 arrayLength;
|
||||
|
||||
if (paramIndex < maxParamIndex &&
|
||||
info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
|
||||
nsXPTType(info->params[paramIndex + 1].type.prefix).IsArray()) {
|
||||
arrayLength = params[paramIndex++].val.u32;
|
||||
}
|
||||
else {
|
||||
|
@ -460,7 +469,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);
|
||||
const nsXPTParamInfo& paramInfo = info->params[paramIndex];
|
||||
|
||||
nsCOMPtr<nsIVariant> value;
|
||||
rv = ParameterToVariant(mPrimaryInterface, methodIndex,
|
||||
|
@ -492,7 +501,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
|
||||
if (mIsAsync) {
|
||||
PRUint8 pcount;
|
||||
pcount = info->GetParamCount();
|
||||
pcount = info->num_args;
|
||||
// There has to be at least one parameter - the retval.
|
||||
if (pcount == 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
@ -501,7 +510,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
|
||||
#ifdef DEBUG
|
||||
// The last one should be the retval.
|
||||
const nsXPTParamInfo& retParamInfo = info->GetParam(pcount - 1);
|
||||
const nsXPTParamInfo& retParamInfo = info->params[pcount - 1];
|
||||
if (!retParamInfo.IsRetval()) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto call_method_end;
|
||||
|
@ -1135,17 +1144,6 @@ WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
|||
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
|
||||
|
|
|
@ -1770,7 +1770,7 @@ ipcDConnectService::OnInvoke(PRUint32 peer, const DConnectInvoke *invoke, PRUint
|
|||
}
|
||||
}
|
||||
|
||||
rv = XPTC_InvokeByIndex(wrapper->RealInstance(),
|
||||
rv = NS_InvokeByIndex(wrapper->RealInstance(),
|
||||
invoke->method_index,
|
||||
paramCount,
|
||||
params);
|
||||
|
|
|
@ -124,14 +124,14 @@ static intN sXPCOMUCStringFinalizerIndex = -1;
|
|||
|
||||
// static
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
uint8 base_type = type.TagPart();
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jsprf.h"
|
||||
|
@ -2154,7 +2154,7 @@ public:
|
|||
JSObject* GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj);
|
||||
|
||||
NS_IMETHOD CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
JSObject* CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
||||
|
@ -2190,7 +2190,7 @@ private:
|
|||
enum SizeMode {GET_SIZE, GET_LENGTH};
|
||||
|
||||
JSBool GetArraySizeFromParam(JSContext* cx,
|
||||
const nsXPTMethodInfo* method,
|
||||
const XPTMethodDescriptor* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 methodIndex,
|
||||
uint8 paramIndex,
|
||||
|
@ -2199,7 +2199,7 @@ private:
|
|||
JSUint32* result);
|
||||
|
||||
JSBool GetInterfaceTypeFromParam(JSContext* cx,
|
||||
const nsXPTMethodInfo* method,
|
||||
const XPTMethodDescriptor* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 methodIndex,
|
||||
const nsXPTType& type,
|
||||
|
@ -2226,7 +2226,7 @@ private:
|
|||
// nsXPCWrappedJS objects are chained together to represent the various
|
||||
// interface on the single underlying (possibly aggregate) JSObject.
|
||||
|
||||
class nsXPCWrappedJS : public nsXPTCStubBase,
|
||||
class nsXPCWrappedJS : protected nsAutoXPTCStub,
|
||||
public nsWeakRefToIXPConnectWrappedJS,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIPropertyBag
|
||||
|
@ -2238,12 +2238,8 @@ public:
|
|||
//NS_DECL_NSISUPPORTSWEAKREFERENCE // methods also on nsIXPConnectWrappedJS
|
||||
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,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor *info,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
/*
|
||||
|
@ -2259,6 +2255,7 @@ public:
|
|||
nsISupports* aOuter,
|
||||
nsXPCWrappedJS** wrapper);
|
||||
|
||||
nsISomeInterface* GetXPTCStub() { return mXPTCStub; }
|
||||
JSObject* GetJSObject() const {return mJSObj;}
|
||||
nsXPCWrappedJSClass* GetClass() const {return mClass;}
|
||||
REFNSIID GetIID() const {return GetClass()->GetIID();}
|
||||
|
@ -2372,7 +2369,7 @@ private:
|
|||
class XPCConvert
|
||||
{
|
||||
public:
|
||||
static JSBool IsMethodReflectable(const nsXPTMethodInfo& info);
|
||||
static JSBool IsMethodReflectable(const XPTMethodDescriptor& info);
|
||||
|
||||
/**
|
||||
* Convert a native object into a jsval.
|
||||
|
|
|
@ -349,6 +349,8 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
|
|||
printf("//////// %d instances of nsXPCWrappedJS created\n", count);
|
||||
#endif
|
||||
|
||||
InitStub(GetClass()->GetIID());
|
||||
|
||||
// intensionally do double addref - see Release().
|
||||
NS_ADDREF_THIS();
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -469,7 +471,7 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
if(!IsValid())
|
||||
|
|
|
@ -579,7 +579,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
|||
if(nsnull != (sibling = self->Find(aIID)))
|
||||
{
|
||||
NS_ADDREF(sibling);
|
||||
*aInstancePtr = (void*) sibling;
|
||||
*aInstancePtr = sibling->GetXPTCStub();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
|||
if(nsnull != (sibling = self->FindInherited(aIID)))
|
||||
{
|
||||
NS_ADDREF(sibling);
|
||||
*aInstancePtr = (void*) sibling;
|
||||
*aInstancePtr = sibling->GetXPTCStub();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
|
|||
|
||||
JSBool
|
||||
nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
||||
const nsXPTMethodInfo* method,
|
||||
const XPTMethodDescriptor* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 methodIndex,
|
||||
uint8 paramIndex,
|
||||
|
@ -726,7 +726,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
|||
if(NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
|
||||
const nsXPTParamInfo& arg_param = method->GetParam(argnum);
|
||||
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
|
||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||
|
@ -743,7 +743,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
|||
|
||||
JSBool
|
||||
nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
||||
const nsXPTMethodInfo* method,
|
||||
const XPTMethodDescriptor* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 methodIndex,
|
||||
const nsXPTType& type,
|
||||
|
@ -769,7 +769,7 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
|||
if(NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
|
||||
const nsXPTParamInfo& arg_param = method->GetParam(argnum);
|
||||
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
if(arg_type.IsPointer() &&
|
||||
arg_type.TagPart() == nsXPTType::T_IID)
|
||||
|
@ -981,7 +981,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* nativeParams)
|
||||
{
|
||||
jsval* stackbase;
|
||||
|
@ -998,7 +998,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
nsID param_iid;
|
||||
uint8 outConversionFailedIndex;
|
||||
JSObject* obj;
|
||||
const char* name = info->GetName();
|
||||
const char* name = info->name;
|
||||
jsval fval;
|
||||
void* mark;
|
||||
JSBool foundDependentParam;
|
||||
|
@ -1038,9 +1038,9 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
obj = thisObj = wrapper->GetJSObject();
|
||||
|
||||
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
||||
paramCount = info->GetParamCount();
|
||||
paramCount = info->num_args;
|
||||
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))
|
||||
goto pre_call_clean_up;
|
||||
|
@ -1059,7 +1059,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
// setup stack
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -1099,7 +1099,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
|
||||
if(paramCount)
|
||||
{
|
||||
const nsXPTParamInfo& firstParam = info->GetParam(0);
|
||||
const nsXPTParamInfo& firstParam = info->params[0];
|
||||
if(firstParam.IsIn())
|
||||
{
|
||||
const nsXPTType& firstType = firstParam.GetType();
|
||||
|
@ -1178,7 +1178,8 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
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'
|
||||
if(stack_size != argc)
|
||||
|
@ -1196,7 +1197,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
// build the args
|
||||
for(i = 0; i < argc; i++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
const nsXPTParamInfo& param = info->params[i];
|
||||
const nsXPTType& type = param.GetType();
|
||||
nsXPTType datum_type;
|
||||
JSUint32 array_count;
|
||||
|
@ -1249,7 +1250,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
}
|
||||
|
||||
// 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|
|
||||
uintN attrs;
|
||||
|
@ -1262,13 +1263,13 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||
&getter, &setter);
|
||||
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
|
||||
// function object.
|
||||
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
|
||||
// function object.
|
||||
|
@ -1338,7 +1339,7 @@ pre_call_clean_up:
|
|||
// clean up any 'out' params handed in
|
||||
for(i = 0; i < paramCount; i++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
const nsXPTParamInfo& param = info->params[i];
|
||||
if(!param.IsOut())
|
||||
continue;
|
||||
|
||||
|
@ -1393,9 +1394,9 @@ pre_call_clean_up:
|
|||
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
if(info->IsGetter())
|
||||
if(XPT_MD_IS_GETTER(info->flags))
|
||||
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);
|
||||
else
|
||||
{
|
||||
|
@ -1469,7 +1470,7 @@ pre_call_clean_up:
|
|||
foundDependentParam = JS_FALSE;
|
||||
for(i = 0; i < paramCount; i++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
const nsXPTParamInfo& param = info->params[i];
|
||||
if(!param.IsOut() && !param.IsDipper())
|
||||
continue;
|
||||
|
||||
|
@ -1520,7 +1521,7 @@ pre_call_clean_up:
|
|||
{
|
||||
for(i = 0; i < paramCount; i++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
const nsXPTParamInfo& param = info->params[i];
|
||||
if(!param.IsOut())
|
||||
continue;
|
||||
|
||||
|
@ -1613,7 +1614,7 @@ pre_call_clean_up:
|
|||
|
||||
for(uint8 k = 0; k < i; k++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(k);
|
||||
const nsXPTParamInfo& param = info->params[k];
|
||||
if(!param.IsOut())
|
||||
continue;
|
||||
const nsXPTType& type = param.GetType();
|
||||
|
|
|
@ -2158,7 +2158,7 @@ XPCWrappedNative::CallMethod(XPCCallContext& ccx,
|
|||
AutoJSSuspendRequest req(ccx); // scoped suspend of request
|
||||
|
||||
// do the invoke
|
||||
invokeResult = XPTC_InvokeByIndex(callee, vtblIndex,
|
||||
invokeResult = NS_InvokeByIndex(callee, vtblIndex,
|
||||
paramCount, dispatchParams);
|
||||
// resume non-blocking JS operations now
|
||||
}
|
||||
|
|
|
@ -168,9 +168,7 @@ void XXXNeverCalled()
|
|||
#if defined (DEBUG) && !defined (WINCE) && !defined(XP_OS2)
|
||||
PurePrintf(0);
|
||||
#endif
|
||||
XPTC_InvokeByIndex(nsnull, 0, 0, nsnull);
|
||||
xptc_dummy();
|
||||
xptc_dummy2();
|
||||
NS_InvokeByIndex(nsnull, 0, 0, nsnull);
|
||||
NS_NewGenericFactory(nsnull, nsnull);
|
||||
NS_NewGenericModule2(nsnull, nsnull);
|
||||
NS_GetWeakReference(nsnull);
|
||||
|
|
|
@ -112,6 +112,7 @@ SDK_HEADERS = \
|
|||
EXPORTS = \
|
||||
nsThreadUtils.h \
|
||||
nsProxyRelease.h \
|
||||
nsXPTCUtils.h \
|
||||
$(NULL)
|
||||
|
||||
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,
|
||||
const nsXPTMethodInfo *methodInfo,
|
||||
const XPTMethodDescriptor *methodInfo,
|
||||
PRUint32 methodIndex,
|
||||
nsXPTCVariant* parameterList,
|
||||
PRUint32 parameterCount) :
|
||||
|
@ -175,7 +175,7 @@ nsProxyObjectCallInfo::Run()
|
|||
{
|
||||
PROXY_LOG(("PROXY(%p): Run\n", this));
|
||||
|
||||
mResult = XPTC_InvokeByIndex(mOwner->GetProxiedInterface(),
|
||||
mResult = NS_InvokeByIndex(mOwner->GetProxiedInterface(),
|
||||
mMethodIndex,
|
||||
mParameterCount,
|
||||
mParameterList);
|
||||
|
@ -192,7 +192,7 @@ nsProxyObjectCallInfo::RefCountInInterfacePointers(PRBool addRef)
|
|||
{
|
||||
for (PRUint32 i = 0; i < mParameterCount; i++)
|
||||
{
|
||||
nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i);
|
||||
nsXPTParamInfo paramInfo = mMethodInfo->params[i];
|
||||
|
||||
if (paramInfo.GetType().IsInterfacePointer() )
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ nsProxyObjectCallInfo::CopyStrings(PRBool copy)
|
|||
{
|
||||
for (PRUint32 i = 0; i < mParameterCount; i++)
|
||||
{
|
||||
const nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i);
|
||||
const nsXPTParamInfo paramInfo = mMethodInfo->params[i];
|
||||
|
||||
if (paramInfo.IsIn())
|
||||
{
|
||||
|
@ -413,7 +413,7 @@ nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
|
|||
|
||||
for (peo = mFirst; peo; peo = peo->mNext) {
|
||||
if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, peo);
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, peo->mXPTCStub);
|
||||
peo->AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -430,16 +430,20 @@ nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
|
|||
return rv;
|
||||
|
||||
peo = new nsProxyEventObject(this, pec,
|
||||
already_AddRefed<nsISomeInterface>(newInterface));
|
||||
already_AddRefed<nsISomeInterface>(newInterface), &rv);
|
||||
if (!peo)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (NS_FAILED(rv)) {
|
||||
delete peo;
|
||||
return rv;
|
||||
}
|
||||
|
||||
peo->mNext = mFirst;
|
||||
mFirst = peo;
|
||||
|
||||
NS_ADDREF(peo);
|
||||
|
||||
*aResult = (nsISupports*) peo;
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, peo->mXPTCStub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,14 @@
|
|||
|
||||
nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent,
|
||||
nsProxyEventClass* aClass,
|
||||
already_AddRefed<nsISomeInterface> aRealInterface)
|
||||
already_AddRefed<nsISomeInterface> aRealInterface,
|
||||
nsresult *rv)
|
||||
: mRealInterface(aRealInterface),
|
||||
mClass(aClass),
|
||||
mProxyObject(aParent),
|
||||
mNext(nsnull)
|
||||
{
|
||||
*rv = InitStub(aClass->GetProxiedIID());
|
||||
}
|
||||
|
||||
nsProxyEventObject::~nsProxyEventObject()
|
||||
|
@ -106,7 +108,7 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
{
|
||||
if( aIID.Equals(GetClass()->GetProxiedIID()) )
|
||||
{
|
||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
|
||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*, mXPTCStub);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -118,23 +120,13 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
// 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
|
||||
nsProxyEventObject::convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
|
||||
nsProxyEventObject::convertMiniVariantToVariant(const XPTMethodDescriptor *methodInfo,
|
||||
nsXPTCMiniVariant * params,
|
||||
nsXPTCVariant **fullParam,
|
||||
uint8 *outParamCount)
|
||||
{
|
||||
uint8 paramCount = methodInfo->GetParamCount();
|
||||
uint8 paramCount = methodInfo->num_args;
|
||||
*outParamCount = paramCount;
|
||||
*fullParam = nsnull;
|
||||
|
||||
|
@ -147,7 +139,7 @@ nsProxyEventObject::convertMiniVariantToVariant(const nsXPTMethodInfo *methodInf
|
|||
|
||||
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())
|
||||
{
|
||||
NS_WARNING("Async proxying of out parameters is not supported");
|
||||
|
@ -189,14 +181,14 @@ nsProxyThreadFilter::AcceptEvent(nsIRunnable *event)
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsProxyEventObject::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* methodInfo,
|
||||
const XPTMethodDescriptor* methodInfo,
|
||||
nsXPTCMiniVariant * params)
|
||||
{
|
||||
NS_ASSERTION(methodIndex > 2,
|
||||
"Calling QI/AddRef/Release through CallMethod");
|
||||
nsresult rv;
|
||||
|
||||
if (methodInfo->IsNotXPCOM())
|
||||
if (XPT_MD_IS_NOTXPCOM(methodInfo->flags))
|
||||
return NS_ERROR_PROXY_INVALID_IN_PARAMETER;
|
||||
|
||||
nsXPTCVariant *fullParam;
|
||||
|
@ -212,7 +204,7 @@ nsProxyEventObject::CallMethod(PRUint16 methodIndex,
|
|||
callDirectly) {
|
||||
|
||||
// invoke directly using xptc
|
||||
rv = XPTC_InvokeByIndex(mRealInterface, methodIndex,
|
||||
rv = NS_InvokeByIndex(mRealInterface, methodIndex,
|
||||
paramCount, fullParam);
|
||||
|
||||
if (fullParam)
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
||||
#include "xptcall.h" // defines nsXPTCVariant
|
||||
#include "nsXPTCUtils.h"
|
||||
|
||||
#include "nsAutoPtr.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
|
||||
* "parent" nsProxyObject.
|
||||
*/
|
||||
class nsProxyEventObject : public nsXPTCStubBase
|
||||
class nsProxyEventObject : protected nsAutoXPTCStub
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
// 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; }
|
||||
nsISomeInterface* GetProxiedInterface() const { return mRealInterface; }
|
||||
nsIEventTarget* GetTarget() const { return mProxyObject->GetTarget(); }
|
||||
PRInt32 GetProxyType() const { return mProxyObject->GetProxyType(); }
|
||||
|
||||
nsresult convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
|
||||
nsresult convertMiniVariantToVariant(const XPTMethodDescriptor *methodInfo,
|
||||
nsXPTCMiniVariant *params,
|
||||
nsXPTCVariant **fullParam,
|
||||
uint8 *outParamCount);
|
||||
|
||||
nsProxyEventObject(nsProxyObject *aParent,
|
||||
nsProxyEventClass *aClass,
|
||||
already_AddRefed<nsISomeInterface> aRealInterface);
|
||||
already_AddRefed<nsISomeInterface> aRealInterface,
|
||||
nsresult *rv);
|
||||
|
||||
friend class nsProxyObject;
|
||||
|
||||
|
@ -210,7 +211,7 @@ public:
|
|||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_IID)
|
||||
|
||||
nsProxyObjectCallInfo(nsProxyEventObject* owner,
|
||||
const nsXPTMethodInfo *methodInfo,
|
||||
const XPTMethodDescriptor *methodInfo,
|
||||
PRUint32 methodIndex,
|
||||
nsXPTCVariant* parameterList,
|
||||
PRUint32 parameterCount);
|
||||
|
@ -238,7 +239,7 @@ public:
|
|||
private:
|
||||
|
||||
nsresult mResult; /* this is the return result of the called function */
|
||||
const nsXPTMethodInfo *mMethodInfo;
|
||||
const XPTMethodDescriptor *mMethodInfo;
|
||||
PRUint32 mMethodIndex; /* which method to be called? */
|
||||
nsXPTCVariant *mParameterList; /* marshalled in parameter buffer */
|
||||
PRUint32 mParameterCount; /* number of params */
|
||||
|
|
|
@ -47,11 +47,11 @@ There are really two pieces of functionality: <i>invoke</i> and <i>stubs</i>...
|
|||
<p>
|
||||
|
||||
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>
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params);
|
||||
</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
|
||||
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
|
||||
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>
|
||||
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.
|
||||
<a
|
||||
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
|
||||
yet been done.
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* 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"),
|
||||
|
@ -45,27 +46,6 @@
|
|||
#include "nsISupports.h"
|
||||
#include "xpt_struct.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
|
||||
{
|
||||
|
@ -174,49 +154,48 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
|
|||
}
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#undef IMETHOD_VISIBILITY
|
||||
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
|
||||
|
||||
class XPTC_EXPORT nsXPTCStubBase : public nsISupports
|
||||
class nsIXPTCProxy : public nsISupports
|
||||
{
|
||||
public:
|
||||
// We are going to implement this to force the compiler to generate a
|
||||
// vtbl for this class. Since this is overridden in the inheriting class
|
||||
// we expect it to never be called.
|
||||
// *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;
|
||||
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
|
||||
const XPTMethodDescriptor *aInfo,
|
||||
nsXPTCMiniVariant *aParams) = 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.
|
||||
*/
|
||||
XPCOM_API(void)
|
||||
NS_DestroyXPTCallStub(nsISomeInterface* aStub);
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params);
|
||||
|
||||
// Used to force linking of these obj for the static library into the dll
|
||||
extern void xptc_dummy();
|
||||
extern void xptc_dummy2();
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* xptcall_h___ */
|
||||
|
|
|
@ -48,6 +48,8 @@ MOZILLA_INTERNAL_API = 1
|
|||
|
||||
DIRS = md
|
||||
|
||||
REQUIRES = string
|
||||
|
||||
CPPSRCS = xptcall.cpp
|
||||
|
||||
# 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
|
||||
|
||||
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 \
|
||||
xptcstubs_gcc_x86_os2.cpp \
|
||||
$(NULL)
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../unix
|
||||
REQUIRES = string
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../unix \
|
||||
-I$(srcdir)/../../../../xptinfo/src \
|
||||
$(NULL)
|
||||
DEFINES += -DMOZ_NEED_LEADING_UNDERSCORE
|
||||
|
||||
# Force use of PIC
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
/* Implement shared vtbl methods. */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
#include "xptc_platforms_unixish_x86.h"
|
||||
#include "xptc_gcc_x86_unix.h"
|
||||
|
||||
|
@ -50,7 +51,6 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
|
@ -58,12 +58,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no interface info");
|
||||
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
paramCount = info->GetParamCount();
|
||||
|
||||
// setup variant array pointer
|
||||
|
@ -95,9 +90,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -46,6 +46,8 @@ MODULE = xpcom
|
|||
LIBRARY_NAME = xptcmd
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
REQUIRES = string
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
INCLUDES += -I$(srcdir)/../..
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../.. \
|
||||
-I$(srcdir)/../../../../xptinfo/src \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
ifneq (,$(findstring mips, $(OS_TEST)))
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
.text
|
||||
.align 2
|
||||
#
|
||||
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
# NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
# PRUint32 paramCount, nsXPTCVariant* params)
|
||||
#
|
||||
|
||||
.globl __XPTC_InvokeByIndex
|
||||
__XPTC_InvokeByIndex:
|
||||
.globl __NS_InvokeByIndex
|
||||
__NS_InvokeByIndex:
|
||||
mflr r0
|
||||
stw r31,-4(r1)
|
||||
#
|
||||
|
|
|
@ -91,8 +91,8 @@ xptc_invoke_copy_to_stack_keeper (void)
|
|||
|
||||
|
||||
/*
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params);
|
||||
|
||||
Each param takes at most two 4-byte words.
|
||||
|
@ -117,12 +117,12 @@ xptc_invoke_copy_to_stack_keeper (void)
|
|||
*/
|
||||
#if defined(XP_WIN32) || defined(XP_OS2)
|
||||
extern "C" {
|
||||
nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params);
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params) {
|
||||
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -133,12 +133,12 @@ __asm__ (
|
|||
is what xptcstubs uses. */
|
||||
".align 2\n\t"
|
||||
#if defined(XP_WIN32) || defined(XP_OS2)
|
||||
".globl " SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex\n\t"
|
||||
SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex:\n\t"
|
||||
".globl " SYMBOL_UNDERSCORE "_NS_InvokeByIndex\n\t"
|
||||
SYMBOL_UNDERSCORE "_NS_InvokeByIndex:\n\t"
|
||||
#else
|
||||
".globl " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
|
||||
".type " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex,@function\n"
|
||||
SYMBOL_UNDERSCORE "XPTC_InvokeByIndex:\n\t"
|
||||
".globl " SYMBOL_UNDERSCORE "NS_InvokeByIndex\n\t"
|
||||
".type " SYMBOL_UNDERSCORE "NS_InvokeByIndex,@function\n"
|
||||
SYMBOL_UNDERSCORE "NS_InvokeByIndex:\n\t"
|
||||
#endif
|
||||
"pushl %ebp\n\t"
|
||||
"movl %esp, %ebp\n\t"
|
||||
|
@ -193,7 +193,7 @@ __asm__ (
|
|||
"popl %ebp\n\t"
|
||||
"ret\n"
|
||||
#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
|
||||
);
|
||||
|
||||
|
|
|
@ -133,13 +133,13 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params);
|
||||
extern "C" nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount,
|
||||
nsXPTCVariant* params);
|
||||
|
||||
extern "C"
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params)
|
||||
{
|
||||
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
|
||||
}
|
||||
|
|
|
@ -73,8 +73,8 @@ invoke_copy_to_stack(PRUint32 paramCount, nsXPTCVariant* s, PRUint32* d)
|
|||
|
||||
}
|
||||
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params)
|
||||
{
|
||||
#ifdef __GNUC__ /* Gnu compiler. */
|
||||
|
|
|
@ -131,9 +131,8 @@ invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
|
|||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant * params)
|
||||
{
|
||||
PRUint32 nr_gpr, nr_fpr, nr_stack;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#ifdef __GNUC__ /* Gnu Compiler. */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
#include "xptc_platforms_unixish_x86.h"
|
||||
#include "xptc_gcc_x86_unix.h"
|
||||
|
||||
|
@ -52,7 +53,6 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
|
@ -60,12 +60,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no interface info");
|
||||
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
paramCount = info->GetParamCount();
|
||||
|
||||
// setup variant array pointer
|
||||
|
@ -97,9 +92,7 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
|||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
/* 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
|
||||
|
@ -80,7 +81,6 @@ PrepareAndDispatch(
|
|||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant *dispatchParams = NULL;
|
||||
nsIInterfaceInfo *interfaceInfo = NULL;
|
||||
const nsXPTMethodInfo *methodInfo;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
|
@ -95,10 +95,7 @@ PrepareAndDispatch(
|
|||
|
||||
NS_ASSERTION(self, "no self");
|
||||
|
||||
self->GetInterfaceInfo(&interfaceInfo);
|
||||
NS_ASSERTION(interfaceInfo, "no interface info");
|
||||
|
||||
interfaceInfo->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
|
||||
NS_ASSERTION(methodInfo, "no method info");
|
||||
|
||||
paramCount = methodInfo->GetParamCount();
|
||||
|
@ -181,9 +178,8 @@ PrepareAndDispatch(
|
|||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
|
||||
|
||||
NS_RELEASE(interfaceInfo);
|
||||
result = self->mOuter->
|
||||
CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptc_platforms_unixish_x86.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
static nsresult
|
||||
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
||||
|
@ -47,7 +48,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
|||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
|
@ -55,10 +55,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
|||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no interface info");
|
||||
|
||||
paramCount = info->GetParamCount();
|
||||
|
@ -92,9 +89,8 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
|
|||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
result = self->mOuter->
|
||||
CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
// Implement shared vtbl methods.
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
// The Linux/x86-64 ABI passes the first 6 integer parameters and the
|
||||
// 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* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info;
|
||||
PRUint32 paramCount;
|
||||
PRUint32 i;
|
||||
|
@ -73,12 +73,7 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
|
|||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
if (!iface_info)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no method info");
|
||||
if (!info)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -153,9 +148,7 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
result = self->mOuter->CallMethod((PRUint16) methodIndex, info, dispatchParams);
|
||||
|
||||
if (dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -62,6 +62,9 @@ CPPSRCS = xptcinvoke.cpp xptcstubs.cpp
|
|||
|
||||
endif
|
||||
|
||||
REQUIRES = string
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../../../../xptinfo/src
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
|
|
|
@ -77,8 +77,8 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
|||
}
|
||||
|
||||
#pragma warning(disable : 4035) // OK to have no return value
|
||||
__declspec(naked) XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
extern "C" NS_EXPORT __declspec(naked) nsresult NS_FROZENCALL
|
||||
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
|
||||
PRUint32 paramCount, nsXPTCVariant* params)
|
||||
{
|
||||
__asm {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
/* Implement shared vtbl methods. */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#error "This code is for Win32 only"
|
||||
|
@ -53,7 +54,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
|||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info = NULL;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
|
@ -64,11 +64,8 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
|||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no interface info");
|
||||
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no method info");
|
||||
|
||||
paramCount = info->GetParamCount();
|
||||
|
||||
|
@ -114,9 +111,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
|
|||
}
|
||||
*stackBytesToPop = ((PRUint32)ap) - ((PRUint32)args);
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
|
|
@ -38,18 +38,58 @@
|
|||
/* entry point wrappers. */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
// This method is never called and is only here so the compiler
|
||||
// will generate a vtbl for this class.
|
||||
// *Needed by the Irix implementation.*
|
||||
NS_IMETHODIMP nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
||||
NS_IMETHODIMP
|
||||
nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
NS_ASSERTION(0,"wowa! nsXPTCStubBase::QueryInterface called");
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aIID.Equals(mEntry->mIID)) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
xptc_dummy2()
|
||||
{
|
||||
return mOuter->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
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___
|
||||
|
||||
#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___ */
|
||||
|
|
|
@ -413,7 +413,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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);
|
||||
else
|
||||
printf("\tFAILED");
|
||||
|
@ -431,7 +431,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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);
|
||||
else
|
||||
printf("\tFAILED");
|
||||
|
@ -449,7 +449,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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);
|
||||
else
|
||||
printf("\tFAILED");
|
||||
|
@ -467,7 +467,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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);
|
||||
else
|
||||
printf("\tFAILED");
|
||||
|
@ -517,7 +517,7 @@ int main()
|
|||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
var[10].val.i32);
|
||||
|
||||
|
@ -534,7 +534,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
(double) var[2].val.f);
|
||||
|
||||
|
@ -584,7 +584,7 @@ int main()
|
|||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
var[10].val.d);
|
||||
else
|
||||
|
@ -635,7 +635,7 @@ int main()
|
|||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
(double) var[10].val.f);
|
||||
else
|
||||
|
@ -726,7 +726,7 @@ int main()
|
|||
var[20].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
(double) var[20].val.f);
|
||||
|
||||
|
@ -775,7 +775,7 @@ int main()
|
|||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
(int)var[10].val.i64);
|
||||
else
|
||||
|
@ -826,7 +826,7 @@ int main()
|
|||
var[10].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
(int)var[10].val.i64);
|
||||
else
|
||||
|
@ -881,7 +881,7 @@ int main()
|
|||
var[11].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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",
|
||||
var[11].val.d);
|
||||
else
|
||||
|
@ -900,7 +900,7 @@ int main()
|
|||
var[2].flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
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);
|
||||
else
|
||||
printf("\tFAILED");
|
||||
|
@ -1119,12 +1119,12 @@ static void DoMultipleInheritenceTest()
|
|||
var[0].val.i32 = 1;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(foo, 3, 1, var);
|
||||
NS_InvokeByIndex(foo, 3, 1, var);
|
||||
|
||||
var[0].val.i32 = 2;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(foo, 4, 1, var);
|
||||
NS_InvokeByIndex(foo, 4, 1, var);
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
@ -1137,12 +1137,12 @@ static void DoMultipleInheritenceTest()
|
|||
var[0].val.i32 = 1;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(bar, 3, 1, var);
|
||||
NS_InvokeByIndex(bar, 3, 1, var);
|
||||
|
||||
var[0].val.i32 = 2;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(bar, 4, 1, var);
|
||||
NS_InvokeByIndex(bar, 4, 1, var);
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
@ -1289,12 +1289,12 @@ static void DoMultipleInheritenceTest2()
|
|||
var[0].val.i32 = 1;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(foo, 3, 1, var);
|
||||
NS_InvokeByIndex(foo, 3, 1, var);
|
||||
|
||||
var[0].val.i32 = 2;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(foo, 4, 1, var);
|
||||
NS_InvokeByIndex(foo, 4, 1, var);
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
@ -1307,12 +1307,12 @@ static void DoMultipleInheritenceTest2()
|
|||
var[0].val.i32 = 1;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(bar, 3, 1, var);
|
||||
NS_InvokeByIndex(bar, 3, 1, var);
|
||||
|
||||
var[0].val.i32 = 2;
|
||||
var[0].type = nsXPTType::T_I32;
|
||||
var[0].flags = 0;
|
||||
XPTC_InvokeByIndex(bar, 4, 1, var);
|
||||
NS_InvokeByIndex(bar, 4, 1, var);
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ static void DoSpeedTest()
|
|||
printf("Doing %d invoked call iterations...\n", count);
|
||||
start = PR_IntervalNow();
|
||||
for(i = count; i; i--)
|
||||
(void)XPTC_InvokeByIndex(test, 3, 3, var);
|
||||
(void)NS_InvokeByIndex(test, 3, 3, var);
|
||||
interval_invoke = PR_IntervalNow() - start;
|
||||
|
||||
printf(" direct took %0.2f seconds\n",
|
||||
|
|
|
@ -1724,18 +1724,21 @@ EntryToInfo(xptiInterfaceEntry* entry, nsIInterfaceInfo **_retval)
|
|||
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); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(iid, "bad param");
|
||||
NS_ASSERTION(_retval, "bad param");
|
||||
|
||||
xptiHashEntry* hashEntry = (xptiHashEntry*)
|
||||
PL_DHashTableOperate(mWorkingSet.mIIDTable, iid, PL_DHASH_LOOKUP);
|
||||
|
||||
xptiInterfaceEntry* entry =
|
||||
PL_DHASH_ENTRY_IS_FREE(hashEntry) ? nsnull : hashEntry->value;
|
||||
|
||||
xptiInterfaceEntry* entry = GetInterfaceEntryForIID(iid);
|
||||
return EntryToInfo(entry, _retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -627,6 +627,8 @@ public:
|
|||
|
||||
//////////////////////
|
||||
|
||||
nsID mIID;
|
||||
|
||||
private:
|
||||
xptiInterfaceEntry(); // not implemented
|
||||
|
||||
|
@ -666,7 +668,6 @@ private:
|
|||
const XPTTypeDescriptor** type);
|
||||
|
||||
private:
|
||||
nsID mIID;
|
||||
union {
|
||||
xptiTypelib mTypelib; // Valid only until resolved.
|
||||
xptiInterfaceGuts* mInterface; // Valid only after resolved.
|
||||
|
@ -906,6 +907,8 @@ public:
|
|||
|
||||
static void WriteToLog(const char *fmt, ...);
|
||||
|
||||
xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
|
||||
|
||||
private:
|
||||
~xptiInterfaceInfoManager();
|
||||
xptiInterfaceInfoManager(); // not implmented
|
||||
|
|
Загрузка…
Ссылка в новой задаче