diff --git a/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp b/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp index 8400955d751b..e37018580d13 100644 --- a/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp +++ b/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp @@ -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. diff --git a/content/xtf/src/nsXTFInterfaceAggregator.cpp b/content/xtf/src/nsXTFInterfaceAggregator.cpp index e16a34a5a65f..814bb8392b52 100644 --- a/content/xtf/src/nsXTFInterfaceAggregator.cpp +++ b/content/xtf/src/nsXTFInterfaceAggregator.cpp @@ -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 #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,14 +83,17 @@ private: nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, - nsISupports* outer) - : mInner(inner), mOuter(outer), mIID(iid) + nsISupports* outer, + nsresult *rv) + : mInner(inner), mOuter(outer), mIID(iid) { #ifdef DEBUG // printf("nsXTFInterfaceAggregator CTOR\n"); #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 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,40 +147,37 @@ nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr) //---------------------------------------------------------------------- // nsXPTCStubBase implementation -NS_IMETHODIMP -nsXTFInterfaceAggregator::GetInterfaceInfo(nsIInterfaceInfo** info) -{ - nsCOMPtr - 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; iGetParam(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, - methodIndex, - paramCount, - fullPars); + nsresult rv = NS_InvokeByIndex(mInner, + methodIndex, + paramCount, + fullPars); if (fullPars) delete []fullPars; return rv; diff --git a/content/xtf/src/nsXTFWeakTearoff.cpp b/content/xtf/src/nsXTFWeakTearoff.cpp index 3a74c74b9b8f..1f375eb8bd21 100644 --- a/content/xtf/src/nsXTFWeakTearoff.cpp +++ b/content/xtf/src/nsXTFWeakTearoff.cpp @@ -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 #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) - : mObj(obj), mIID(iid) + 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); - if (! result) + nsresult rv; + + nsRefPtr 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 - iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID)); - NS_ASSERTION(iim, "could not get interface info manager"); - return iim->GetInfoForIID( &mIID, info); + // else return mObj->QueryInterface(aIID, aInstancePtr); + 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; iGetParam(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; diff --git a/extensions/java/xpcom/src/nsJavaWrapper.cpp b/extensions/java/xpcom/src/nsJavaWrapper.cpp index b5f178e317d6..f2b779447c39 100644 --- a/extensions/java/xpcom/src/nsJavaWrapper.cpp +++ b/extensions/java/xpcom/src/nsJavaWrapper.cpp @@ -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 = XPTC_InvokeByIndex(realObject, methodIndex, - paramCount, params); + nsresult invokeResult = NS_InvokeByIndex(realObject, methodIndex, + paramCount, params); NS_RELEASE(realObject); // Clean up params diff --git a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp index ae13b00d71ae..62ad39135600 100644 --- a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp +++ b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp @@ -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. diff --git a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.h b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.h index d1d845a9b70a..865da2e94943 100644 --- a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.h +++ b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.h @@ -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, diff --git a/extensions/java/xpcom/src/nsJavaXPTCStub.cpp b/extensions/java/xpcom/src/nsJavaXPTCStub.cpp index 8a267c04f17a..184df6eafb47 100644 --- a/extensions/java/xpcom/src/nsJavaXPTCStub.cpp +++ b/extensions/java/xpcom/src/nsJavaXPTCStub.cpp @@ -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) diff --git a/extensions/java/xpcom/src/nsJavaXPTCStub.h b/extensions/java/xpcom/src/nsJavaXPTCStub.h index 711d0298ff8e..9a1b55b43ebf 100644 --- a/extensions/java/xpcom/src/nsJavaXPTCStub.h +++ b/extensions/java/xpcom/src/nsJavaXPTCStub.h @@ -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, diff --git a/extensions/python/xpcom/client/__init__.py b/extensions/python/xpcom/client/__init__.py index 58238150cc2b..a294946a6549 100644 --- a/extensions/python/xpcom/client/__init__.py +++ b/extensions/python/xpcom/client/__init__.py @@ -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 "" % (self._object_name_,) diff --git a/extensions/python/xpcom/src/module/_xpcom.cpp b/extensions/python/xpcom/src/module/_xpcom.cpp index c2bbe969a209..7b8e65f43862 100644 --- a/extensions/python/xpcom/src/module/_xpcom.cpp +++ b/extensions/python/xpcom/src/module/_xpcom.cpp @@ -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 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. diff --git a/extensions/webservices/proxy/src/wspcallcontext.cpp b/extensions/webservices/proxy/src/wspcallcontext.cpp index fc3b8256d2fd..f5beec0d65fe 100644 --- a/extensions/webservices/proxy/src/wspcallcontext.cpp +++ b/extensions/webservices/proxy/src/wspcallcontext.cpp @@ -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 binding; @@ -410,8 +410,8 @@ WSPCallContext::CallCompletionListener() dispatchParams[paramIndex].type.flags = XPT_TDP_POINTER | TD_INTERFACE_TYPE; - rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex, - paramCount, dispatchParams); + rv = NS_InvokeByIndex(mAsyncListener, mListenerMethodIndex, + paramCount, dispatchParams); } else { rv = NS_ERROR_FAILURE; diff --git a/extensions/webservices/proxy/src/wspcomplextypewrapper.cpp b/extensions/webservices/proxy/src/wspcomplextypewrapper.cpp index d9aa9baa1015..eeeeb4306a25 100644 --- a/extensions/webservices/proxy/src/wspcomplextypewrapper.cpp +++ b/extensions/webservices/proxy/src/wspcomplextypewrapper.cpp @@ -350,8 +350,8 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex, } } - rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex, - numParams, var); + rv = NS_InvokeByIndex(mComplexTypeInstance, aMethodIndex, + numParams, var); if (NS_FAILED(rv)) { return rv; diff --git a/extensions/webservices/proxy/src/wspprivate.h b/extensions/webservices/proxy/src/wspprivate.h index 9b5a01b1d8cc..53d58aa82a8e 100644 --- a/extensions/webservices/proxy/src/wspprivate.h +++ b/extensions/webservices/proxy/src/wspprivate.h @@ -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 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); diff --git a/extensions/webservices/proxy/src/wsppropertybagwrapper.cpp b/extensions/webservices/proxy/src/wsppropertybagwrapper.cpp index 6cef67523057..ff372e9c68d5 100644 --- a/extensions/webservices/proxy/src/wsppropertybagwrapper.cpp +++ b/extensions/webservices/proxy/src/wsppropertybagwrapper.cpp @@ -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 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 diff --git a/extensions/webservices/proxy/src/wspproxy.cpp b/extensions/webservices/proxy/src/wspproxy.cpp index f12493bd81fc..45fd4f629e7d 100644 --- a/extensions/webservices/proxy/src/wspproxy.cpp +++ b/extensions/webservices/proxy/src/wspproxy.cpp @@ -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 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 diff --git a/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp b/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp index 37bb428db5d3..f6efec455ac2 100644 --- a/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp +++ b/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp @@ -1770,10 +1770,10 @@ ipcDConnectService::OnInvoke(PRUint32 peer, const DConnectInvoke *invoke, PRUint } } - rv = XPTC_InvokeByIndex(wrapper->RealInstance(), - invoke->method_index, - paramCount, - params); + rv = NS_InvokeByIndex(wrapper->RealInstance(), + invoke->method_index, + paramCount, + params); end: LOG(("sending INVOKE_REPLY: rv=%x\n", rv)); diff --git a/js/src/xpconnect/src/xpcconvert.cpp b/js/src/xpconnect/src/xpcconvert.cpp index 69e36ae8debe..03cd8afd6dc8 100644 --- a/js/src/xpconnect/src/xpcconvert.cpp +++ b/js/src/xpconnect/src/xpcconvert.cpp @@ -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(); diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index f9fa7cef8d8d..cd617519a5a5 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -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. diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp index 113a62fe9757..1ccb26eac352 100644 --- a/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -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()) diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 57d1641849df..00d8d1a1bac8 100644 --- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -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(); diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index 93c28467ad7f..56cbb9342dd9 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -2158,8 +2158,8 @@ XPCWrappedNative::CallMethod(XPCCallContext& ccx, AutoJSSuspendRequest req(ccx); // scoped suspend of request // do the invoke - invokeResult = XPTC_InvokeByIndex(callee, vtblIndex, - paramCount, dispatchParams); + invokeResult = NS_InvokeByIndex(callee, vtblIndex, + paramCount, dispatchParams); // resume non-blocking JS operations now } diff --git a/xpcom/build/dlldeps.cpp b/xpcom/build/dlldeps.cpp index 3652fd7b6fd6..7596b7f111f7 100644 --- a/xpcom/build/dlldeps.cpp +++ b/xpcom/build/dlldeps.cpp @@ -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); diff --git a/xpcom/glue/Makefile.in b/xpcom/glue/Makefile.in index 9725ab110bf4..8423dda7dc28 100644 --- a/xpcom/glue/Makefile.in +++ b/xpcom/glue/Makefile.in @@ -112,6 +112,7 @@ SDK_HEADERS = \ EXPORTS = \ nsThreadUtils.h \ nsProxyRelease.h \ + nsXPTCUtils.h \ $(NULL) SDK_LIBRARY = \ diff --git a/xpcom/glue/nsXPTCUtils.h b/xpcom/glue/nsXPTCUtils.h new file mode 100644 index 000000000000..5710c209742a --- /dev/null +++ b/xpcom/glue/nsXPTCUtils.h @@ -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 . + * + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Benjamin Smedberg - 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__ diff --git a/xpcom/proxy/src/nsProxyEvent.cpp b/xpcom/proxy/src/nsProxyEvent.cpp index 39eef30c0854..464c9dff9ef2 100644 --- a/xpcom/proxy/src/nsProxyEvent.cpp +++ b/xpcom/proxy/src/nsProxyEvent.cpp @@ -127,7 +127,7 @@ nsProxyObject::nsProxyObjectDestructorEvent::Run() //----------------------------------------------------------------------------- nsProxyObjectCallInfo::nsProxyObjectCallInfo(nsProxyEventObject* owner, - const nsXPTMethodInfo *methodInfo, + const XPTMethodDescriptor *methodInfo, PRUint32 methodIndex, nsXPTCVariant* parameterList, PRUint32 parameterCount) : @@ -175,10 +175,10 @@ nsProxyObjectCallInfo::Run() { PROXY_LOG(("PROXY(%p): Run\n", this)); - mResult = XPTC_InvokeByIndex(mOwner->GetProxiedInterface(), - mMethodIndex, - mParameterCount, - mParameterList); + mResult = NS_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->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(newInterface)); + already_AddRefed(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; } diff --git a/xpcom/proxy/src/nsProxyEventObject.cpp b/xpcom/proxy/src/nsProxyEventObject.cpp index f68ba9166e65..671321633d41 100644 --- a/xpcom/proxy/src/nsProxyEventObject.cpp +++ b/xpcom/proxy/src/nsProxyEventObject.cpp @@ -55,12 +55,14 @@ nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent, nsProxyEventClass* aClass, - already_AddRefed aRealInterface) + already_AddRefed 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,8 +204,8 @@ nsProxyEventObject::CallMethod(PRUint16 methodIndex, callDirectly) { // invoke directly using xptc - rv = XPTC_InvokeByIndex(mRealInterface, methodIndex, - paramCount, fullParam); + rv = NS_InvokeByIndex(mRealInterface, methodIndex, + paramCount, fullParam); if (fullParam) free(fullParam); diff --git a/xpcom/proxy/src/nsProxyEventPrivate.h b/xpcom/proxy/src/nsProxyEventPrivate.h index dcec286b4c90..04cbe2791072 100644 --- a/xpcom/proxy/src/nsProxyEventPrivate.h +++ b/xpcom/proxy/src/nsProxyEventPrivate.h @@ -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 aRealInterface); + already_AddRefed 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 */ diff --git a/xpcom/reflect/xptcall/porting.html b/xpcom/reflect/xptcall/porting.html index b8b204a1ef6e..5b3472c031ef 100644 --- a/xpcom/reflect/xptcall/porting.html +++ b/xpcom/reflect/xptcall/porting.html @@ -47,11 +47,11 @@ There are really two pieces of functionality: invoke and stubs...

The invoke functionality requires the implementation of the -following on each platform (from xptcall/public/xptcall.h): +following on each platform (from xptcall/public/xptcall.h):

 XPTC_PUBLIC_API(nsresult)
-XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
+NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
                    PRUint32 paramCount, nsXPTCVariant* params);
 
@@ -80,7 +80,7 @@ can decide how best to do this for their platforms. The stubs 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 xptcall/public/xptcall.h): +for this is (from xptcall/public/xptcall.h):
 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. 
 xptcall/tests
- has an api level test for XPTC_InvokeByIndex, but no tests for
+ has an api level test for NS_InvokeByIndex, but no tests for
 the stubs functionality. Such a test ought to be written, but this has not
 yet been done.
 
diff --git a/xpcom/reflect/xptcall/public/xptcall.h b/xpcom/reflect/xptcall/public/xptcall.h
index 69adda7cd987..810d071d1461 100644
--- a/xpcom/reflect/xptcall/public/xptcall.h
+++ b/xpcom/reflect/xptcall/public/xptcall.h
@@ -20,6 +20,7 @@
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ * Benjamin Smedberg 
  *
  * 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,
-                   PRUint32 paramCount, nsXPTCVariant* params);
+/**
+ * Destroys an XPTCall stub previously created with NS_GetXPTCallStub.
+ */
+XPCOM_API(void)
+NS_DestroyXPTCallStub(nsISomeInterface* aStub);
 
-// 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
+XPCOM_API(nsresult)
+NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
+                 PRUint32 paramCount, nsXPTCVariant* params);
 
 #endif /* xptcall_h___ */
diff --git a/xpcom/reflect/xptcall/src/Makefile.in b/xpcom/reflect/xptcall/src/Makefile.in
index 99227490977a..8fe693cbf590 100644
--- a/xpcom/reflect/xptcall/src/Makefile.in
+++ b/xpcom/reflect/xptcall/src/Makefile.in
@@ -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
diff --git a/xpcom/reflect/xptcall/src/md/os2/Makefile.in b/xpcom/reflect/xptcall/src/md/os2/Makefile.in
index f82bd26a101a..aae936e1e661 100644
--- a/xpcom/reflect/xptcall/src/md/os2/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/os2/Makefile.in
@@ -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
diff --git a/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp b/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp
index 6c3c92ed7e92..37339877b984 100644
--- a/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp
+++ b/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
index 463afa7e0584..cea265ec81d4 100644
--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
@@ -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)))
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_rhapsody.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_rhapsody.s
index 8a5c9afbe7df..9d84c8ac0c4e 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_rhapsody.s
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_rhapsody.s
@@ -31,12 +31,12 @@
 .text
 	.align 2
 #
-#   XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
-#                   PRUint32 paramCount, nsXPTCVariant* params)
+#   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)
 #
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
index 5502b5590d07..ac0b689c7b85 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
@@ -91,9 +91,9 @@ xptc_invoke_copy_to_stack_keeper (void)
 
 
 /*
-  XPTC_PUBLIC_API(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);
 
   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 _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);
+    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);
     }
 }
 #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
 );
 
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_rhapsody.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_rhapsody.cpp
index 9a08acfd4b7e..4458995cb1ae 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_rhapsody.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_rhapsody.cpp
@@ -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,
-                   PRUint32 paramCount, nsXPTCVariant* params)
+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);
 }    
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp
index 90fc8da832b0..1e68b2a382f6 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp
@@ -73,9 +73,9 @@ invoke_copy_to_stack(PRUint32 paramCount, nsXPTCVariant* s, PRUint32* d)
 
 }
 
-XPTC_PUBLIC_API(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)
 {
 #ifdef __GNUC__            /* Gnu compiler. */
   PRUint32 result;
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp
index a8d2c6e743c0..a817f23efed2 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp
@@ -131,10 +131,9 @@ invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
     }
 }
 
-extern "C"
-XPTC_PUBLIC_API(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)
 {
     PRUint32 nr_gpr, nr_fpr, nr_stack;
     invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp
index b12da4e513bb..da5a8c5b7649 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
index a7c1883d0a7d..9c4193f51e9c 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp
index 0864045f2653..00ffe7260de7 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
index 3e80ebe1dce5..72bf5826ddd0 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/md/win32/Makefile.in b/xpcom/reflect/xptcall/src/md/win32/Makefile.in
index 2f60597d11bd..31d21cddc0ca 100644
--- a/xpcom/reflect/xptcall/src/md/win32/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/win32/Makefile.in
@@ -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
diff --git a/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp b/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
index 9fbf2f94b71e..145c58002a51 100644
--- a/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
+++ b/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
@@ -77,9 +77,9 @@ 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,
-                   PRUint32 paramCount, nsXPTCVariant* params)
+extern "C" NS_EXPORT __declspec(naked) nsresult NS_FROZENCALL
+NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
+                 PRUint32 paramCount, nsXPTCVariant* params)
 {
     __asm {
         push    ebp
diff --git a/xpcom/reflect/xptcall/src/md/win32/xptcstubs.cpp b/xpcom/reflect/xptcall/src/md/win32/xptcstubs.cpp
index bd5ab9759102..5f3679a15a9b 100644
--- a/xpcom/reflect/xptcall/src/md/win32/xptcstubs.cpp
+++ b/xpcom/reflect/xptcall/src/md/win32/xptcstubs.cpp
@@ -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;
diff --git a/xpcom/reflect/xptcall/src/xptcall.cpp b/xpcom/reflect/xptcall/src/xptcall.cpp
index 8a459170e2ad..0d08ecedbff2 100644
--- a/xpcom/reflect/xptcall/src/xptcall.cpp
+++ b/xpcom/reflect/xptcall/src/xptcall.cpp
@@ -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,
-                                             void** aInstancePtr)
+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;
+    }
+
+    return mOuter->QueryInterface(aIID, aInstancePtr);
 }
 
-void
-xptc_dummy2()
+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);
 }
diff --git a/xpcom/reflect/xptcall/src/xptcprivate.h b/xpcom/reflect/xptcall/src/xptcprivate.h
index 3691fa0a5cc0..a8a6ed39e590 100644
--- a/xpcom/reflect/xptcall/src/xptcprivate.h
+++ b/xpcom/reflect/xptcall/src/xptcprivate.h
@@ -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___ */
diff --git a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
index 76829eb2ad84..224416a05290 100644
--- a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
+++ b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
@@ -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", 
diff --git a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
index a6cf5abdc2cc..92c17ec6a7bd 100644
--- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
@@ -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);
 }
 
diff --git a/xpcom/reflect/xptinfo/src/xptiprivate.h b/xpcom/reflect/xptinfo/src/xptiprivate.h
index 8568ba6765eb..70c48d6cacb8 100644
--- a/xpcom/reflect/xptinfo/src/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/src/xptiprivate.h
@@ -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