Backout xptcall because linux tboxes are stupid, I think.

This commit is contained in:
benjamin%smedbergs.us 2006-11-16 20:17:24 +00:00
Родитель f8b3ccc930
Коммит 62c212952b
50 изменённых файлов: 480 добавлений и 584 удалений

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

@ -515,7 +515,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
returnParam.ptr = &returnParam.val;
}
rv = NS_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams);
rv = XPTC_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams);
// In case someone is holding on to the txFunctionEvaluationContext which
// could thus stay alive longer than this function.

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

@ -37,11 +37,10 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsXPTCUtils.h"
#include "xptcall.h"
#include "nsIInterfaceInfo.h"
#include "nsIInterfaceInfoManager.h"
#include "nsServiceManagerUtils.h"
#include "nsAutoPtr.h"
#ifdef DEBUG
#include <stdio.h>
#endif
@ -49,7 +48,7 @@
////////////////////////////////////////////////////////////////////////
// nsXTFInterfaceAggregator class
class nsXTFInterfaceAggregator : protected nsAutoXPTCStub
class nsXTFInterfaceAggregator : public nsXPTCStubBase
{
protected:
friend nsresult
@ -60,16 +59,18 @@ protected:
nsXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer,
nsresult *rv);
nsISupports* outer);
~nsXTFInterfaceAggregator();
public:
// nsISupports interface
NS_DECL_ISUPPORTS
// nsXPTCStubBase
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
NS_IMETHOD CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
private:
@ -83,17 +84,14 @@ private:
nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer,
nsresult *rv)
: mInner(inner), mOuter(outer), mIID(iid)
nsISupports* outer)
: mInner(inner), mOuter(outer), mIID(iid)
{
#ifdef DEBUG
// printf("nsXTFInterfaceAggregator CTOR\n");
#endif
mInner->AddRef();
mOuter->AddRef();
*rv = InitStub(iid);
}
nsXTFInterfaceAggregator::~nsXTFInterfaceAggregator()
@ -114,17 +112,13 @@ NS_NewXTFInterfaceAggregator(const nsIID& iid,
if (!aResult)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsRefPtr<nsXTFInterfaceAggregator> result =
new nsXTFInterfaceAggregator(iid, inner, outer, &rv);
nsXTFInterfaceAggregator* result = new nsXTFInterfaceAggregator(iid,inner,outer);
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv))
return rv;
return result->QueryInterface(iid, aResult);
NS_ADDREF(result);
*aResult = result;
return NS_OK;
}
//----------------------------------------------------------------------
@ -137,7 +131,7 @@ NS_IMETHODIMP
nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if(aIID.Equals(mIID)) {
*aInstancePtr = mXPTCStub;
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
NS_ADDREF_THIS();
return NS_OK;
}
@ -147,37 +141,40 @@ 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 XPTMethodDescriptor *info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params)
{
NS_ASSERTION(methodIndex >= 3,
"huh? indirect nsISupports method call unexpected");
if (methodIndex < 3) {
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFInterfaceAggregator.");
return NS_ERROR_FAILURE;
}
// prepare args:
int paramCount = info->num_args;
nsXPTCVariant* fullPars;
if (!paramCount) {
fullPars = nsnull;
}
else {
fullPars = new nsXPTCVariant[paramCount];
if (!fullPars)
return NS_ERROR_OUT_OF_MEMORY;
}
int paramCount = info->GetParamCount();
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
for (int i=0; i<paramCount; ++i) {
const nsXPTParamInfo& paramInfo = info->params[i];
const nsXPTParamInfo& paramInfo = info->GetParam(i);
PRUint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
}
// make the call:
nsresult rv = NS_InvokeByIndex(mInner,
methodIndex,
paramCount,
fullPars);
nsresult rv = XPTC_InvokeByIndex(mInner,
methodIndex,
paramCount,
fullPars);
if (fullPars)
delete []fullPars;
return rv;

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

@ -37,11 +37,10 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsXPTCUtils.h"
#include "xptcall.h"
#include "nsIInterfaceInfo.h"
#include "nsIInterfaceInfoManager.h"
#include "nsServiceManagerUtils.h"
#include "nsAutoPtr.h"
#ifdef DEBUG
#include <stdio.h>
#endif
@ -49,21 +48,27 @@
////////////////////////////////////////////////////////////////////////
// nsXTFWeakTearoff class
class nsXTFWeakTearoff : protected nsAutoXPTCStub
class nsXTFWeakTearoff : public nsXPTCStubBase
{
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 XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
private:
@ -75,18 +80,19 @@ private:
// implementation:
nsXTFWeakTearoff::nsXTFWeakTearoff(const nsIID& iid,
nsISupports* obj,
nsresult *rv)
: mObj(obj), mIID(iid)
nsISupports* obj)
: mObj(obj), mIID(iid)
{
MOZ_COUNT_CTOR(nsXTFWeakTearoff);
*rv = InitStub(iid);
#ifdef DEBUG
// printf("nsXTFWeakTearoff CTOR\n");
#endif
}
nsXTFWeakTearoff::~nsXTFWeakTearoff()
{
MOZ_COUNT_DTOR(nsXTFWeakTearoff);
#ifdef DEBUG
// printf("nsXTFWeakTearoff DTOR\n");
#endif
}
nsresult
@ -97,17 +103,13 @@ NS_NewXTFWeakTearoff(const nsIID& iid,
if (!aResult)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsRefPtr<nsXTFWeakTearoff> result =
new nsXTFWeakTearoff(iid, obj, &rv);
if (!result)
nsXTFWeakTearoff* result = new nsXTFWeakTearoff(iid,obj);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv))
return rv;
return result->QueryInterface(iid, (void**) aResult);
NS_ADDREF(result);
*aResult = result;
return NS_OK;
}
//----------------------------------------------------------------------
@ -120,44 +122,53 @@ NS_IMETHODIMP
nsXTFWeakTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if(aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
*aInstancePtr = mXPTCStub;
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
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);
return NS_ERROR_NO_INTERFACE;
// 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);
}
NS_IMETHODIMP
nsXTFWeakTearoff::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params)
{
NS_ASSERTION(methodIndex >= 3,
"huh? indirect nsISupports method call unexpected");
if (methodIndex < 3) {
NS_ERROR("huh? indirect nsISupports method call unexpected on nsXTFWeakTearoff.");
return NS_ERROR_FAILURE;
}
// prepare args:
int paramCount = info->num_args;
nsXPTCVariant* fullPars;
if (!paramCount) {
fullPars = nsnull;
}
else {
fullPars = new nsXPTCVariant[paramCount];
if (!fullPars)
return NS_ERROR_OUT_OF_MEMORY;
}
int paramCount = info->GetParamCount();
nsXPTCVariant* fullPars = paramCount ? new nsXPTCVariant[paramCount] : nsnull;
for (int i=0; i<paramCount; ++i) {
const nsXPTParamInfo& paramInfo = info->params[i];
const nsXPTParamInfo& paramInfo = info->GetParam(i);
uint8 flags = paramInfo.IsOut() ? nsXPTCVariant::PTR_IS_DATA : 0;
fullPars[i].Init(params[i], paramInfo.GetType(), flags);
}
// make the call:
nsresult rv = NS_InvokeByIndex(mObj, methodIndex, paramCount, fullPars);
nsresult rv = XPTC_InvokeByIndex(mObj,
methodIndex,
paramCount,
fullPars);
if (fullPars)
delete []fullPars;
return rv;

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

@ -1477,8 +1477,8 @@ JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
ThrowException(env, rv, "Failed to get real XPCOM object");
return nsnull;
}
nsresult invokeResult = NS_InvokeByIndex(realObject, methodIndex,
paramCount, params);
nsresult invokeResult = XPTC_InvokeByIndex(realObject, methodIndex,
paramCount, params);
NS_RELEASE(realObject);
// Clean up params

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

@ -881,7 +881,8 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
NS_ENSURE_SUCCESS(rv, rv);
if (stub) {
// stub is already AddRef'd and QI'd
*aResult = stub->GetStub();
*aResult = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(nsXPTCStubBase*, stub));
return NS_OK;
}
@ -900,14 +901,10 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
NS_ENSURE_SUCCESS(rv, rv);
// Create XPCOM stub
stub = new nsJavaXPTCStub(aJavaObject, iinfo, &rv);
if (!stub)
stub = new nsJavaXPTCStub(aJavaObject, iinfo);
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;
@ -915,14 +912,14 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
}
NS_ADDREF(stub);
*aResult = stub->GetStub();
*aResult = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(nsXPTCStubBase*, stub));
return NS_OK;
}
nsresult
GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
const XPTMethodDescriptor *methodInfo,
GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
const nsXPTParamInfo &paramInfo, PRUint8 paramType,
PRUint16 methodIndex, nsXPTCMiniVariant *dispatchParams,
PRBool isFullVariantArray, nsID &result)
@ -943,7 +940,7 @@ GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
if (NS_FAILED(rv))
break;
const nsXPTParamInfo& arg_param = methodInfo->params[argnum];
const nsXPTParamInfo& arg_param = methodInfo->GetParam(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 XPTMethodDescriptor *methodInfo,
const nsXPTMethodInfo *methodInfo,
const nsXPTParamInfo &paramInfo,
PRUint8 paramType, PRUint16 methodIndex,
nsXPTCMiniVariant *dispatchParams,

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

@ -46,21 +46,12 @@
#include "nsServiceManagerUtils.h"
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
nsresult *rv)
nsJavaXPTCStub::nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo)
: 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);
@ -69,10 +60,13 @@ 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
}
@ -242,7 +236,8 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
// always return the master stub for nsISupports
if (aIID.Equals(NS_GET_IID(nsISupports)))
{
*aInstancePtr = master->mXPTCStub;
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(nsXPTCStubBase*, master));
NS_ADDREF(master);
return NS_OK;
}
@ -259,7 +254,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
nsJavaXPTCStub *stub = master->FindStubSupportingIID(aIID);
if (stub)
{
*aInstancePtr = stub->mXPTCStub;
*aInstancePtr = stub;
NS_ADDREF(stub);
return NS_OK;
}
@ -314,15 +309,10 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
if (NS_FAILED(rv))
return rv;
stub = new nsJavaXPTCStub(obj, iinfo, &rv);
stub = new nsJavaXPTCStub(obj, iinfo);
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
@ -347,7 +337,7 @@ nsJavaXPTCStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
stub->mMaster = master;
master->mChildren.AppendElement(stub);
*aInstancePtr = stub->mXPTCStub;
*aInstancePtr = stub;
NS_ADDREF(stub);
return NS_OK;
}
@ -388,15 +378,22 @@ 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 XPTMethodDescriptor *aMethodInfo,
const nsXPTMethodInfo *aMethodInfo,
nsXPTCMiniVariant *aParams)
{
#ifdef DEBUG_JAVAXPCOM
const char* ifaceName;
mIInfo->GetNameShared(&ifaceName);
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
#endif
nsresult rv = NS_OK;
@ -406,7 +403,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
nsCAutoString methodSig("(");
// Create jvalue array to hold Java params
PRUint8 paramCount = aMethodInfo->num_args;
PRUint8 paramCount = aMethodInfo->GetParamCount();
jvalue* java_params = nsnull;
const nsXPTParamInfo* retvalInfo = nsnull;
if (paramCount) {
@ -416,7 +413,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
{
const nsXPTParamInfo &paramInfo = aMethodInfo->params[i];
const nsXPTParamInfo &paramInfo = aMethodInfo->GetParam(i);
if (!paramInfo.IsRetval()) {
rv = SetupJavaParams(paramInfo, aMethodInfo, aMethodIndex, aParams,
aParams[i], java_params[i], methodSig);
@ -445,16 +442,15 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
jmethodID mid = nsnull;
if (NS_SUCCEEDED(rv)) {
nsCAutoString methodName;
if (XPT_MD_IS_GETTER(aMethodInfo->flags) ||
XPT_MD_IS_SETTER(aMethodInfo->flags)) {
if (XPT_MD_IS_GETTER(aMethodInfo->flags))
if (aMethodInfo->IsGetter() || aMethodInfo->IsSetter()) {
if (aMethodInfo->IsGetter())
methodName.AppendLiteral("get");
else
methodName.AppendLiteral("set");
methodName.AppendASCII(aMethodInfo->name);
methodName.AppendASCII(aMethodInfo->GetName());
methodName.SetCharAt(toupper(methodName[3]), 3);
} else {
methodName.AppendASCII(aMethodInfo->name);
methodName.AppendASCII(aMethodInfo->GetName());
methodName.SetCharAt(tolower(methodName[0]), 0);
}
// If it's a Java keyword, then prepend an underscore
@ -562,7 +558,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
if (NS_SUCCEEDED(rv)) {
for (PRUint8 i = 0; i < paramCount; i++)
{
const nsXPTParamInfo &paramInfo = aMethodInfo->params[i];
const nsXPTParamInfo &paramInfo = aMethodInfo->GetParam(i);
if (paramInfo.IsIn() && !paramInfo.IsOut() && !paramInfo.IsDipper()) // 'in'
continue;
@ -590,7 +586,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
#endif
env->ExceptionClear();
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
LOG(("<--- (Java) %s::%s()\n", ifaceName, aMethodInfo->GetName()));
return rv;
}
@ -599,7 +595,7 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
*/
nsresult
nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
const XPTMethodDescriptor* aMethodInfo,
const nsXPTMethodInfo* aMethodInfo,
PRUint16 aMethodIndex,
nsXPTCMiniVariant* aDispatchParams,
nsXPTCMiniVariant &aVariant, jvalue &aJValue,
@ -1063,7 +1059,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
nsresult
nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
const XPTMethodDescriptor* aMethodInfo,
const nsXPTMethodInfo* aMethodInfo,
PRUint16 aMethodIndex,
nsXPTCMiniVariant* aDispatchParams,
nsACString &aRetvalSig)
@ -1173,7 +1169,7 @@ nsJavaXPTCStub::GetRetvalSig(const nsXPTParamInfo* aParamInfo,
*/
nsresult
nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
const XPTMethodDescriptor *aMethodInfo,
const nsXPTMethodInfo* aMethodInfo,
PRUint16 aMethodIndex,
nsXPTCMiniVariant* aDispatchParams,
nsXPTCMiniVariant &aVariant, jvalue &aJValue)

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

@ -38,7 +38,7 @@
#ifndef _nsJavaXPTCStub_h_
#define _nsJavaXPTCStub_h_
#include "nsXPTCUtils.h"
#include "xptcall.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 : protected nsAutoXPTCStub,
class nsJavaXPTCStub : public nsXPTCStubBase,
public nsSupportsWeakReference
{
friend class nsJavaXPTCStubWeakRef;
@ -60,18 +60,19 @@ public:
NS_DECL_NSISUPPORTSWEAKREFERENCE
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JAVAXPTCSTUB_IID)
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo,
nsresult *rv);
nsJavaXPTCStub(jobject aJavaObject, nsIInterfaceInfo *aIInfo);
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 XPTMethodDescriptor *aInfo,
const nsXPTMethodInfo *aInfo,
nsXPTCMiniVariant *aParams);
nsISomeInterface* GetStub() { return mXPTCStub; }
// getter for mJavaObject
jobject GetJavaObject();
@ -100,18 +101,18 @@ private:
PRBool SupportsIID(const nsID &aIID);
nsresult SetupJavaParams(const nsXPTParamInfo &aParamInfo,
const XPTMethodDescriptor* aMethodInfo,
const nsXPTMethodInfo* aMethodInfo,
PRUint16 aMethodIndex,
nsXPTCMiniVariant* aDispatchParams,
nsXPTCMiniVariant &aVariant,
jvalue &aJValue, nsACString &aMethodSig);
nsresult GetRetvalSig(const nsXPTParamInfo* aParamInfo,
const XPTMethodDescriptor* aMethodInfo,
const nsXPTMethodInfo* aMethodInfo,
PRUint16 aMethodIndex,
nsXPTCMiniVariant* aDispatchParams,
nsACString &aRetvalSig);
nsresult FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
const XPTMethodDescriptor* aMethodInfo,
const nsXPTMethodInfo* 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, NS_InvokeByIndex
XPTI_GetInterfaceInfoManager, GetComponentManager, XPTC_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 NS_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
return XPTC_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 NS_InvokeByIndex(self._comobj_, method_index, args)
return XPTC_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 NS_InvokeByIndex(self._comobj_, method_index, real_param_infos)
return XPTC_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_NS_InvokeByIndex(PyObject *self, PyObject *args)
PyXPCOMMethod_XPTC_InvokeByIndex(PyObject *self, PyObject *args)
{
PyObject *obIS, *obParams;
nsCOMPtr<nsISupports> pis;
@ -182,7 +182,7 @@ PyXPCOMMethod_NS_InvokeByIndex(PyObject *self, PyObject *args)
nsresult r;
Py_BEGIN_ALLOW_THREADS;
r = NS_InvokeByIndex(pis, index, arg_helper.m_num_array, arg_helper.m_var_array);
r = XPTC_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},
{"NS_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
{"XPTC_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 = NS_InvokeByIndex(mAsyncListener, 3, 2, dispatchParams);
rv = XPTC_InvokeByIndex(mAsyncListener, 3, 2, dispatchParams);
}
else if (mResponse) {
nsCOMPtr<nsIWSDLBinding> binding;
@ -410,8 +410,8 @@ WSPCallContext::CallCompletionListener()
dispatchParams[paramIndex].type.flags =
XPT_TDP_POINTER | TD_INTERFACE_TYPE;
rv = NS_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
paramCount, dispatchParams);
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
paramCount, dispatchParams);
}
else {
rv = NS_ERROR_FAILURE;

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

@ -350,8 +350,8 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
}
}
rv = NS_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
numParams, var);
rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
numParams, var);
if (NS_FAILED(rv)) {
return rv;

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

@ -59,7 +59,7 @@
#include "nsSOAPUtils.h"
// interface info includes
#include "nsXPTCUtils.h"
#include "xptcall.h"
#include "nsIInterfaceInfo.h"
// WSDL includes
@ -92,7 +92,7 @@ public:
nsACString& aCIdentifier);
};
class WSPProxy : protected nsAutoXPTCStub,
class WSPProxy : public nsXPTCStubBase,
public nsIWebServiceProxy,
public nsIClassInfo
{
@ -104,9 +104,11 @@ public:
NS_DECL_NSIWEBSERVICEPROXY
NS_DECL_NSICLASSINFO
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
NS_IMETHOD CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
void CallCompleted(WSPCallContext* aContext);
@ -250,7 +252,7 @@ protected:
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
};
class WSPPropertyBagWrapper : protected nsAutoXPTCStub,
class WSPPropertyBagWrapper : public nsXPTCStubBase,
public nsIWebServicePropertyBagWrapper,
public nsIClassInfo
{
@ -262,9 +264,11 @@ public:
NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
NS_DECL_NSICLASSINFO
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
NS_IMETHOD CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);

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

@ -58,9 +58,7 @@ WSPPropertyBagWrapper::Init(nsIPropertyBag* aPropertyBag,
mPropertyBag = aPropertyBag;
mInterfaceInfo = aInterfaceInfo;
mInterfaceInfo->GetIIDShared(&mIID);
nsresult rv = InitStub(*mIID);
return rv;
return NS_OK;
}
NS_METHOD
@ -87,11 +85,8 @@ NS_IMPL_RELEASE(WSPPropertyBagWrapper)
NS_IMETHODIMP
WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (aIID.Equals(NS_GET_IID(nsISupports))) {
*aInstancePtr = NS_STATIC_CAST(nsIXPTCProxy*, this);
}
if(mXPTCStub && mIID && aIID.Equals(*mIID)) {
*aInstancePtr = mXPTCStub;
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
}
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
@ -108,7 +103,7 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params)
{
if (methodIndex < 3) {
@ -119,7 +114,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
nsresult rv = NS_OK;
nsAutoString propName;
rv = WSPFactory::C2XML(nsDependentCString(info->name), propName);
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()), propName);
if (NS_FAILED(rv)) {
return rv;
}
@ -131,8 +126,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
}
nsCOMPtr<nsIInterfaceInfo> iinfo;
if (XPT_MD_IS_GETTER(info->flags)) {
const nsXPTParamInfo& paramInfo = info->params[0];
if (info->IsGetter()) {
const nsXPTParamInfo& paramInfo = info->GetParam(0);
const nsXPTType& type = paramInfo.GetType();
uint8 type_tag = type.TagPart();
@ -146,12 +141,12 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
}
else if (info->num_args == 2) {
else if (info->GetParamCount() == 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->params[0];
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
const nsXPTType& type1 = paramInfo1.GetType();
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
NS_ERROR("Unexpected parameter type for getter");
@ -159,7 +154,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
}
// The second parameter should be the array out pointer itself.
const nsXPTParamInfo& paramInfo2 = info->params[1];
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
const nsXPTType& type2 = paramInfo2.GetType();
if (!paramInfo2.IsOut() || !type2.IsArray()) {
NS_ERROR("Unexpected parameter type for getter");
@ -192,6 +187,17 @@ 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,10 +80,6 @@ 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;
@ -139,13 +135,8 @@ NS_IMPL_RELEASE(WSPProxy)
NS_IMETHODIMP
WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
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;
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
NS_ADDREF_THIS();
return NS_OK;
}
@ -186,7 +177,7 @@ WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
*/
NS_IMETHODIMP
WSPProxy::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params)
{
nsresult rv;
@ -302,7 +293,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
PRUint32 i, partCount;
input->GetPartCount(&partCount);
PRUint32 maxParamIndex = info->num_args - 1;
PRUint32 maxParamIndex = info->GetParamCount()-1;
// Iterate through the parts to figure out how many are
// body vs. header blocks
@ -459,7 +450,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
PRUint32 arrayLength;
if (paramIndex < maxParamIndex &&
nsXPTType(info->params[paramIndex + 1].type.prefix).IsArray()) {
info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
arrayLength = params[paramIndex++].val.u32;
}
else {
@ -469,7 +460,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
NS_ASSERTION(paramIndex <= maxParamIndex,
"WSDL/IInfo param count mismatch");
const nsXPTParamInfo& paramInfo = info->params[paramIndex];
const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);
nsCOMPtr<nsIVariant> value;
rv = ParameterToVariant(mPrimaryInterface, methodIndex,
@ -501,7 +492,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
if (mIsAsync) {
PRUint8 pcount;
pcount = info->num_args;
pcount = info->GetParamCount();
// There has to be at least one parameter - the retval.
if (pcount == 0) {
rv = NS_ERROR_FAILURE;
@ -510,7 +501,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
#ifdef DEBUG
// The last one should be the retval.
const nsXPTParamInfo& retParamInfo = info->params[pcount - 1];
const nsXPTParamInfo& retParamInfo = info->GetParam(pcount - 1);
if (!retParamInfo.IsRetval()) {
rv = NS_ERROR_FAILURE;
goto call_method_end;
@ -1144,6 +1135,17 @@ 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,10 +1770,10 @@ ipcDConnectService::OnInvoke(PRUint32 peer, const DConnectInvoke *invoke, PRUint
}
}
rv = NS_InvokeByIndex(wrapper->RealInstance(),
invoke->method_index,
paramCount,
params);
rv = XPTC_InvokeByIndex(wrapper->RealInstance(),
invoke->method_index,
paramCount,
params);
end:
LOG(("sending INVOKE_REPLY: rv=%x\n", rv));

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

@ -124,14 +124,14 @@ static intN sXPCOMUCStringFinalizerIndex = -1;
// static
JSBool
XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
XPCConvert::IsMethodReflectable(const nsXPTMethodInfo& info)
{
if(XPT_MD_IS_NOTXPCOM(info.flags) || XPT_MD_IS_HIDDEN(info.flags))
if(info.IsNotXPCOM() || info.IsHidden())
return JS_FALSE;
for(int i = info.num_args-1; i >= 0; i--)
for(int i = info.GetParamCount()-1; i >= 0; i--)
{
const nsXPTParamInfo& param = info.params[i];
const nsXPTParamInfo& param = info.GetParam(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 "nsXPTCUtils.h"
#include "xptcall.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 XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
JSObject* CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
@ -2190,7 +2190,7 @@ private:
enum SizeMode {GET_SIZE, GET_LENGTH};
JSBool GetArraySizeFromParam(JSContext* cx,
const XPTMethodDescriptor* method,
const nsXPTMethodInfo* method,
const nsXPTParamInfo& param,
uint16 methodIndex,
uint8 paramIndex,
@ -2199,7 +2199,7 @@ private:
JSUint32* result);
JSBool GetInterfaceTypeFromParam(JSContext* cx,
const XPTMethodDescriptor* method,
const nsXPTMethodInfo* 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 : protected nsAutoXPTCStub,
class nsXPCWrappedJS : public nsXPTCStubBase,
public nsWeakRefToIXPConnectWrappedJS,
public nsSupportsWeakReference,
public nsIPropertyBag
@ -2238,8 +2238,12 @@ 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 XPTMethodDescriptor *info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params);
/*
@ -2255,7 +2259,6 @@ 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();}
@ -2369,7 +2372,7 @@ private:
class XPCConvert
{
public:
static JSBool IsMethodReflectable(const XPTMethodDescriptor& info);
static JSBool IsMethodReflectable(const nsXPTMethodInfo& info);
/**
* Convert a native object into a jsval.

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

@ -349,8 +349,6 @@ 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();
@ -471,7 +469,7 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** info)
NS_IMETHODIMP
nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant* params)
{
if(!IsValid())

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

@ -579,7 +579,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
if(nsnull != (sibling = self->Find(aIID)))
{
NS_ADDREF(sibling);
*aInstancePtr = sibling->GetXPTCStub();
*aInstancePtr = (void*) sibling;
return NS_OK;
}
@ -587,7 +587,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
if(nsnull != (sibling = self->FindInherited(aIID)))
{
NS_ADDREF(sibling);
*aInstancePtr = sibling->GetXPTCStub();
*aInstancePtr = (void*) sibling;
return NS_OK;
}
@ -708,7 +708,7 @@ xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
JSBool
nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
const XPTMethodDescriptor* method,
const nsXPTMethodInfo* 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->params[argnum];
const nsXPTParamInfo& arg_param = method->GetParam(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 XPTMethodDescriptor* method,
const nsXPTMethodInfo* 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->params[argnum];
const nsXPTParamInfo& arg_param = method->GetParam(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 XPTMethodDescriptor* info,
const nsXPTMethodInfo* 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->name;
const char* name = info->GetName();
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->num_args;
paramCount = info->GetParamCount();
argc = paramCount -
(paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);
(paramCount && info->GetParam(paramCount-1).IsRetval() ? 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(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
if(info->IsGetter() || info->IsSetter())
{
stack_size = argc;
}
@ -1099,7 +1099,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
if(paramCount)
{
const nsXPTParamInfo& firstParam = info->params[0];
const nsXPTParamInfo& firstParam = info->GetParam(0);
if(firstParam.IsIn())
{
const nsXPTType& firstType = firstParam.GetType();
@ -1178,8 +1178,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
goto pre_call_clean_up;
}
NS_ASSERTION(XPT_MD_IS_GETTER(info->flags) || sp,
"Only a getter needs no stack.");
NS_ASSERTION(info->IsGetter() || sp, "Only a getter needs no stack.");
// this is a function call, so push function and 'this'
if(stack_size != argc)
@ -1197,7 +1196,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
// build the args
for(i = 0; i < argc; i++)
{
const nsXPTParamInfo& param = info->params[i];
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTType datum_type;
JSUint32 array_count;
@ -1250,7 +1249,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
}
// Figure out what our callee is
if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
if(info->IsGetter() || info->IsSetter())
{
// Pull the getter or setter off of |obj|
uintN attrs;
@ -1263,13 +1262,13 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
&getter, &setter);
if(ok)
{
if(XPT_MD_IS_GETTER(info->flags) && (attrs & JSPROP_GETTER))
if(info->IsGetter() && (attrs & JSPROP_GETTER))
{
// JSPROP_GETTER means the getter is actually a
// function object.
ccx.SetCallee((JSObject*)getter);
}
else if(XPT_MD_IS_SETTER(info->flags) && (attrs & JSPROP_SETTER))
else if(info->IsSetter() && (attrs & JSPROP_SETTER))
{
// JSPROP_SETTER means the setter is actually a
// function object.
@ -1339,7 +1338,7 @@ pre_call_clean_up:
// clean up any 'out' params handed in
for(i = 0; i < paramCount; i++)
{
const nsXPTParamInfo& param = info->params[i];
const nsXPTParamInfo& param = info->GetParam(i);
if(!param.IsOut())
continue;
@ -1394,9 +1393,9 @@ pre_call_clean_up:
JS_ClearPendingException(cx);
if(XPT_MD_IS_GETTER(info->flags))
if(info->IsGetter())
success = JS_GetProperty(cx, obj, name, &result);
else if(XPT_MD_IS_SETTER(info->flags))
else if(info->IsSetter())
success = JS_SetProperty(cx, obj, name, sp-1);
else
{
@ -1470,7 +1469,7 @@ pre_call_clean_up:
foundDependentParam = JS_FALSE;
for(i = 0; i < paramCount; i++)
{
const nsXPTParamInfo& param = info->params[i];
const nsXPTParamInfo& param = info->GetParam(i);
if(!param.IsOut() && !param.IsDipper())
continue;
@ -1521,7 +1520,7 @@ pre_call_clean_up:
{
for(i = 0; i < paramCount; i++)
{
const nsXPTParamInfo& param = info->params[i];
const nsXPTParamInfo& param = info->GetParam(i);
if(!param.IsOut())
continue;
@ -1614,7 +1613,7 @@ pre_call_clean_up:
for(uint8 k = 0; k < i; k++)
{
const nsXPTParamInfo& param = info->params[k];
const nsXPTParamInfo& param = info->GetParam(k);
if(!param.IsOut())
continue;
const nsXPTType& type = param.GetType();

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

@ -2158,8 +2158,8 @@ XPCWrappedNative::CallMethod(XPCCallContext& ccx,
AutoJSSuspendRequest req(ccx); // scoped suspend of request
// do the invoke
invokeResult = NS_InvokeByIndex(callee, vtblIndex,
paramCount, dispatchParams);
invokeResult = XPTC_InvokeByIndex(callee, vtblIndex,
paramCount, dispatchParams);
// resume non-blocking JS operations now
}

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

@ -168,7 +168,9 @@ void XXXNeverCalled()
#if defined (DEBUG) && !defined (WINCE) && !defined(XP_OS2)
PurePrintf(0);
#endif
NS_InvokeByIndex(nsnull, 0, 0, nsnull);
XPTC_InvokeByIndex(nsnull, 0, 0, nsnull);
xptc_dummy();
xptc_dummy2();
NS_NewGenericFactory(nsnull, nsnull);
NS_NewGenericModule2(nsnull, nsnull);
NS_GetWeakReference(nsnull);

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

@ -112,7 +112,6 @@ SDK_HEADERS = \
EXPORTS = \
nsThreadUtils.h \
nsProxyRelease.h \
nsXPTCUtils.h \
$(NULL)
SDK_LIBRARY = \

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

@ -1,69 +0,0 @@
/* ***** 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 XPTMethodDescriptor *methodInfo,
const nsXPTMethodInfo *methodInfo,
PRUint32 methodIndex,
nsXPTCVariant* parameterList,
PRUint32 parameterCount) :
@ -175,10 +175,10 @@ nsProxyObjectCallInfo::Run()
{
PROXY_LOG(("PROXY(%p): Run\n", this));
mResult = NS_InvokeByIndex(mOwner->GetProxiedInterface(),
mMethodIndex,
mParameterCount,
mParameterList);
mResult = XPTC_InvokeByIndex(mOwner->GetProxiedInterface(),
mMethodIndex,
mParameterCount,
mParameterList);
if (IsSync()) {
PostCompleted();
@ -192,7 +192,7 @@ nsProxyObjectCallInfo::RefCountInInterfacePointers(PRBool addRef)
{
for (PRUint32 i = 0; i < mParameterCount; i++)
{
nsXPTParamInfo paramInfo = mMethodInfo->params[i];
nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i);
if (paramInfo.GetType().IsInterfacePointer() )
{
@ -220,7 +220,7 @@ nsProxyObjectCallInfo::CopyStrings(PRBool copy)
{
for (PRUint32 i = 0; i < mParameterCount; i++)
{
const nsXPTParamInfo paramInfo = mMethodInfo->params[i];
const nsXPTParamInfo paramInfo = mMethodInfo->GetParam(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->mXPTCStub);
*aResult = NS_STATIC_CAST(nsISupports*, peo);
peo->AddRef();
return NS_OK;
}
@ -430,20 +430,16 @@ nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
return rv;
peo = new nsProxyEventObject(this, pec,
already_AddRefed<nsISomeInterface>(newInterface), &rv);
already_AddRefed<nsISomeInterface>(newInterface));
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 = NS_STATIC_CAST(nsISupports*, peo->mXPTCStub);
*aResult = (nsISupports*) peo;
return NS_OK;
}

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

@ -55,14 +55,12 @@
nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent,
nsProxyEventClass* aClass,
already_AddRefed<nsISomeInterface> aRealInterface,
nsresult *rv)
already_AddRefed<nsISomeInterface> aRealInterface)
: mRealInterface(aRealInterface),
mClass(aClass),
mProxyObject(aParent),
mNext(nsnull)
{
*rv = InitStub(aClass->GetProxiedIID());
}
nsProxyEventObject::~nsProxyEventObject()
@ -108,7 +106,7 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if( aIID.Equals(GetClass()->GetProxiedIID()) )
{
*aInstancePtr = NS_STATIC_CAST(nsISupports*, mXPTCStub);
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
NS_ADDREF_THIS();
return NS_OK;
}
@ -120,13 +118,23 @@ 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 XPTMethodDescriptor *methodInfo,
nsProxyEventObject::convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
nsXPTCMiniVariant * params,
nsXPTCVariant **fullParam,
uint8 *outParamCount)
{
uint8 paramCount = methodInfo->num_args;
uint8 paramCount = methodInfo->GetParamCount();
*outParamCount = paramCount;
*fullParam = nsnull;
@ -139,7 +147,7 @@ nsProxyEventObject::convertMiniVariantToVariant(const XPTMethodDescriptor *metho
for (int i = 0; i < paramCount; i++)
{
const nsXPTParamInfo& paramInfo = methodInfo->params[i];
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(i);
if ((GetProxyType() & NS_PROXY_ASYNC) && paramInfo.IsDipper())
{
NS_WARNING("Async proxying of out parameters is not supported");
@ -181,14 +189,14 @@ nsProxyThreadFilter::AcceptEvent(nsIRunnable *event)
NS_IMETHODIMP
nsProxyEventObject::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* methodInfo,
const nsXPTMethodInfo* methodInfo,
nsXPTCMiniVariant * params)
{
NS_ASSERTION(methodIndex > 2,
"Calling QI/AddRef/Release through CallMethod");
nsresult rv;
if (XPT_MD_IS_NOTXPCOM(methodInfo->flags))
if (methodInfo->IsNotXPCOM())
return NS_ERROR_PROXY_INVALID_IN_PARAMETER;
nsXPTCVariant *fullParam;
@ -204,8 +212,8 @@ nsProxyEventObject::CallMethod(PRUint16 methodIndex,
callDirectly) {
// invoke directly using xptc
rv = NS_InvokeByIndex(mRealInterface, methodIndex,
paramCount, fullParam);
rv = XPTC_InvokeByIndex(mRealInterface, methodIndex,
paramCount, fullParam);
if (fullParam)
free(fullParam);

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

@ -45,7 +45,7 @@
#include "nsIInterfaceInfo.h"
#include "nsIProxyObjectManager.h"
#include "nsXPTCUtils.h"
#include "xptcall.h" // defines nsXPTCVariant
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
@ -150,31 +150,30 @@ 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 : protected nsAutoXPTCStub
class nsProxyEventObject : public nsXPTCStubBase
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
// call this method and return result
NS_IMETHOD CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
nsXPTCMiniVariant* params);
NS_IMETHOD CallMethod(PRUint16 methodIndex, const nsXPTMethodInfo* 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 XPTMethodDescriptor *methodInfo,
nsresult convertMiniVariantToVariant(const nsXPTMethodInfo *methodInfo,
nsXPTCMiniVariant *params,
nsXPTCVariant **fullParam,
uint8 *outParamCount);
nsProxyEventObject(nsProxyObject *aParent,
nsProxyEventClass *aClass,
already_AddRefed<nsISomeInterface> aRealInterface,
nsresult *rv);
already_AddRefed<nsISomeInterface> aRealInterface);
friend class nsProxyObject;
@ -211,7 +210,7 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_IID)
nsProxyObjectCallInfo(nsProxyEventObject* owner,
const XPTMethodDescriptor *methodInfo,
const nsXPTMethodInfo *methodInfo,
PRUint32 methodIndex,
nsXPTCVariant* parameterList,
PRUint32 parameterCount);
@ -239,7 +238,7 @@ public:
private:
nsresult mResult; /* this is the return result of the called function */
const XPTMethodDescriptor *mMethodInfo;
const nsXPTMethodInfo *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">xptcall/public/xptcall.h</a>):
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>):
<pre>
XPTC_PUBLIC_API(nsresult)
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
XPTC_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">xptcall/public/xptcall.h</a>):
for this is (from <a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/public/xptcall.h#109">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>NS_InvokeByIndex</code>, but no tests for
</a> has an api level test for <code>XPTC_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,7 +20,6 @@
* 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"),
@ -46,6 +45,27 @@
#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
{
@ -154,48 +174,49 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
}
};
class nsIXPTCProxy : public nsISupports
/***************************************************************************/
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
class XPTC_EXPORT nsXPTCStubBase : public nsISupports
{
public:
NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
const XPTMethodDescriptor *aInfo,
nsXPTCMiniVariant *aParams) = 0;
// 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;
};
/**
* 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;
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
/**
* 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);
PR_BEGIN_EXTERN_C
/**
* Destroys an XPTCall stub previously created with NS_GetXPTCallStub.
*/
XPCOM_API(void)
NS_DestroyXPTCallStub(nsISomeInterface* aStub);
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
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,8 +48,6 @@ 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.
@ -61,5 +59,3 @@ FORCE_USE_PIC = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
LOCAL_INCLUDES += -I$(srcdir)/../../xptinfo/src

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

@ -50,11 +50,7 @@ CPPSRCS = \
../unix/xptcinvoke_gcc_x86_unix.cpp \
xptcstubs_gcc_x86_os2.cpp \
$(NULL)
REQUIRES = string
LOCAL_INCLUDES = \
-I$(srcdir)/../unix \
-I$(srcdir)/../../../../xptinfo/src \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)/../unix
DEFINES += -DMOZ_NEED_LEADING_UNDERSCORE
# Force use of PIC

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

@ -38,7 +38,6 @@
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
#include "xptiprivate.h"
#include "xptc_platforms_unixish_x86.h"
#include "xptc_gcc_x86_unix.h"
@ -51,6 +50,7 @@ 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,7 +58,12 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
NS_ASSERTION(self,"no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
@ -90,7 +95,9 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
}
}
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -46,8 +46,6 @@ MODULE = xpcom
LIBRARY_NAME = xptcmd
MOZILLA_INTERNAL_API = 1
REQUIRES = string
#
# The default is this buildable, but non-functioning code.
#
@ -380,10 +378,7 @@ include $(topsrcdir)/config/rules.mk
DEFINES += -DEXPORT_XPTC_API -D_IMPL_NS_COM
LOCAL_INCLUDES += \
-I$(srcdir)/../.. \
-I$(srcdir)/../../../../xptinfo/src \
$(NULL)
INCLUDES += -I$(srcdir)/../..
ifeq ($(OS_ARCH),Linux)
ifneq (,$(findstring mips, $(OS_TEST)))

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

@ -31,12 +31,12 @@
.text
.align 2
#
# NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
#
.globl __NS_InvokeByIndex
__NS_InvokeByIndex:
.globl __XPTC_InvokeByIndex
__XPTC_InvokeByIndex:
mflr r0
stw r31,-4(r1)
#

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

@ -91,9 +91,9 @@ xptc_invoke_copy_to_stack_keeper (void)
/*
EXPORT_XPCOM_API(nsresult)
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
Each param takes at most two 4-byte words.
It doesn't matter if we push too many words, and calculating the exact
@ -117,12 +117,12 @@ xptc_invoke_copy_to_stack_keeper (void)
*/
#if defined(XP_WIN32) || defined(XP_OS2)
extern "C" {
nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
EXPORT_XPCOM_API(nsresult)
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params) {
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params) {
return _XPTC_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 "_NS_InvokeByIndex\n\t"
SYMBOL_UNDERSCORE "_NS_InvokeByIndex:\n\t"
".globl " SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex\n\t"
SYMBOL_UNDERSCORE "_XPTC_InvokeByIndex:\n\t"
#else
".globl " SYMBOL_UNDERSCORE "NS_InvokeByIndex\n\t"
".type " SYMBOL_UNDERSCORE "NS_InvokeByIndex,@function\n"
SYMBOL_UNDERSCORE "NS_InvokeByIndex:\n\t"
".globl " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
".type " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex,@function\n"
SYMBOL_UNDERSCORE "XPTC_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 "NS_InvokeByIndex, . -" SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
".size " SYMBOL_UNDERSCORE "XPTC_InvokeByIndex, . -" SYMBOL_UNDERSCORE "XPTC_InvokeByIndex\n\t"
#endif
);

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

@ -133,13 +133,13 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double
}
}
extern "C" nsresult _NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount,
nsXPTCVariant* params);
extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
EXPORT_XPCOM_API(nsresult)
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
extern "C"
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
}

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

@ -73,9 +73,9 @@ invoke_copy_to_stack(PRUint32 paramCount, nsXPTCVariant* s, PRUint32* d)
}
EXPORT_XPCOM_API(nsresult)
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
#ifdef __GNUC__ /* Gnu compiler. */
PRUint32 result;

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

@ -131,9 +131,10 @@ invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
}
}
EXPORT_XPCOM_API(nsresult)
NS_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant * params)
extern "C"
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant * params)
{
PRUint32 nr_gpr, nr_fpr, nr_stack;
invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);

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

@ -40,7 +40,6 @@
#ifdef __GNUC__ /* Gnu Compiler. */
#include "xptcprivate.h"
#include "xptiprivate.h"
#include "xptc_platforms_unixish_x86.h"
#include "xptc_gcc_x86_unix.h"
@ -53,6 +52,7 @@ 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,7 +60,12 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
NS_ASSERTION(self,"no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
@ -92,7 +97,9 @@ PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
}
}
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -37,7 +37,6 @@
* ***** 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
@ -81,6 +80,7 @@ PrepareAndDispatch(
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant *dispatchParams = NULL;
nsIInterfaceInfo *interfaceInfo = NULL;
const nsXPTMethodInfo *methodInfo;
PRUint8 paramCount;
PRUint8 i;
@ -95,7 +95,10 @@ PrepareAndDispatch(
NS_ASSERTION(self, "no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
self->GetInterfaceInfo(&interfaceInfo);
NS_ASSERTION(interfaceInfo, "no interface info");
interfaceInfo->GetMethodInfo(PRUint16(methodIndex), &methodInfo);
NS_ASSERTION(methodInfo, "no method info");
paramCount = methodInfo->GetParamCount();
@ -178,8 +181,9 @@ PrepareAndDispatch(
}
}
result = self->mOuter->
CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
result = self->CallMethod((PRUint16)methodIndex, methodInfo, dispatchParams);
NS_RELEASE(interfaceInfo);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -39,7 +39,6 @@
#include "xptcprivate.h"
#include "xptc_platforms_unixish_x86.h"
#include "xptiprivate.h"
static nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
@ -48,6 +47,7 @@ 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,7 +55,10 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
NS_ASSERTION(self,"no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
@ -89,8 +92,9 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
}
}
result = self->mOuter->
CallMethod((PRUint16)methodIndex, info, dispatchParams);
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -39,7 +39,6 @@
// 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,
@ -66,6 +65,7 @@ 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,7 +73,12 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
NS_ASSERTION(self,"no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
if (!iface_info)
return NS_ERROR_UNEXPECTED;
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no method info");
if (!info)
return NS_ERROR_UNEXPECTED;
@ -148,7 +153,9 @@ PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
}
}
result = self->mOuter->CallMethod((PRUint16) methodIndex, info, dispatchParams);
result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if (dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -62,9 +62,6 @@ CPPSRCS = xptcinvoke.cpp xptcstubs.cpp
endif
REQUIRES = string
LOCAL_INCLUDES += -I$(srcdir)/../../../../xptinfo/src
# Force use of PIC
FORCE_USE_PIC = 1

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

@ -77,9 +77,9 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
}
#pragma warning(disable : 4035) // OK to have no return value
extern "C" NS_EXPORT __declspec(naked) nsresult NS_FROZENCALL
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
__declspec(naked) XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
__asm {
push ebp

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

@ -38,7 +38,6 @@
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
#include "xptiprivate.h"
#ifndef WIN32
#error "This code is for Win32 only"
@ -54,6 +53,7 @@ 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,8 +64,11 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
NS_ASSERTION(self,"no self");
self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no method info");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
@ -111,7 +114,9 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
}
*stackBytesToPop = ((PRUint32)ap) - ((PRUint32)args);
result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;

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

@ -38,58 +38,18 @@
/* entry point wrappers. */
#include "xptcprivate.h"
#include "xptiprivate.h"
NS_IMETHODIMP
nsXPTCStubBase::QueryInterface(REFNSIID aIID,
void **aInstancePtr)
// 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,
void** aInstancePtr)
{
if (aIID.Equals(mEntry->mIID)) {
NS_ADDREF_THIS();
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
return NS_OK;
}
return mOuter->QueryInterface(aIID, aInstancePtr);
NS_ASSERTION(0,"wowa! nsXPTCStubBase::QueryInterface called");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(nsrefcnt)
nsXPTCStubBase::AddRef()
void
xptc_dummy2()
{
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,52 +41,5 @@
#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(NS_InvokeByIndex(test, 3, 3, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 5, 3, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 4, 3, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 6, 3, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 7, 11, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 8, 3, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 9, 11, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 10, 11, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 11, 21, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 12, 11, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 13, 11, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 14, 12, var)))
if(NS_SUCCEEDED(XPTC_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(NS_InvokeByIndex(test, 15, 3, var)))
if(NS_SUCCEEDED(XPTC_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;
NS_InvokeByIndex(foo, 3, 1, var);
XPTC_InvokeByIndex(foo, 3, 1, var);
var[0].val.i32 = 2;
var[0].type = nsXPTType::T_I32;
var[0].flags = 0;
NS_InvokeByIndex(foo, 4, 1, var);
XPTC_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;
NS_InvokeByIndex(bar, 3, 1, var);
XPTC_InvokeByIndex(bar, 3, 1, var);
var[0].val.i32 = 2;
var[0].type = nsXPTType::T_I32;
var[0].flags = 0;
NS_InvokeByIndex(bar, 4, 1, var);
XPTC_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;
NS_InvokeByIndex(foo, 3, 1, var);
XPTC_InvokeByIndex(foo, 3, 1, var);
var[0].val.i32 = 2;
var[0].type = nsXPTType::T_I32;
var[0].flags = 0;
NS_InvokeByIndex(foo, 4, 1, var);
XPTC_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;
NS_InvokeByIndex(bar, 3, 1, var);
XPTC_InvokeByIndex(bar, 3, 1, var);
var[0].val.i32 = 2;
var[0].type = nsXPTType::T_I32;
var[0].flags = 0;
NS_InvokeByIndex(bar, 4, 1, var);
XPTC_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)NS_InvokeByIndex(test, 3, 3, var);
(void)XPTC_InvokeByIndex(test, 3, 3, var);
interval_invoke = PR_IntervalNow() - start;
printf(" direct took %0.2f seconds\n",

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

@ -1724,21 +1724,18 @@ 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");
xptiInterfaceEntry* entry = GetInterfaceEntryForIID(iid);
xptiHashEntry* hashEntry = (xptiHashEntry*)
PL_DHashTableOperate(mWorkingSet.mIIDTable, iid, PL_DHASH_LOOKUP);
xptiInterfaceEntry* entry =
PL_DHASH_ENTRY_IS_FREE(hashEntry) ? nsnull : hashEntry->value;
return EntryToInfo(entry, _retval);
}

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

@ -627,8 +627,6 @@ public:
//////////////////////
nsID mIID;
private:
xptiInterfaceEntry(); // not implemented
@ -668,6 +666,7 @@ private:
const XPTTypeDescriptor** type);
private:
nsID mIID;
union {
xptiTypelib mTypelib; // Valid only until resolved.
xptiInterfaceGuts* mInterface; // Valid only after resolved.
@ -907,8 +906,6 @@ public:
static void WriteToLog(const char *fmt, ...);
xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
private:
~xptiInterfaceInfoManager();
xptiInterfaceInfoManager(); // not implmented