Bug 692342 - Create a ConvertDependentParam(i) method to match ConvertIndependentParam(i) (modulo reindentation). r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:07 -0800
changeset 81588 4d417032d8878ed97c1093544e9ae13aa964999d
parent 81587 8790687685ee53327539a05ae6636c6f6ddfcb29
child 81589 a03dd8e80c34d8ae160128641cb7062d05811857
push id628
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 14:41:57 +0000
treeherdermozilla-aurora@24a61ad789e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692342
milestone11.0a1
Bug 692342 - Create a ConvertDependentParam(i) method to match ConvertIndependentParam(i) (modulo reindentation). r=mrbkap
js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -2118,16 +2118,17 @@ class CallMethodHelper
         return const_cast<CallMethodHelper*>(this)->GetDispatchParam(paramIndex);
     }
 
     JS_ALWAYS_INLINE JSBool InitializeDispatchParams();
 
     JS_ALWAYS_INLINE JSBool ConvertIndependentParams(JSBool* foundDependentParam);
     JS_ALWAYS_INLINE JSBool ConvertIndependentParam(uint8 i);
     JS_ALWAYS_INLINE JSBool ConvertDependentParams();
+    JS_ALWAYS_INLINE JSBool ConvertDependentParam(uint8 i);
 
     JS_ALWAYS_INLINE void CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type);
 
     JS_ALWAYS_INLINE JSBool HandleDipperParam(nsXPTCVariant* dp,
                                               const nsXPTParamInfo& paramInfo);
 
     JS_ALWAYS_INLINE nsresult Invoke();
 
@@ -2688,21 +2689,31 @@ CallMethodHelper::ConvertIndependentPara
 }
 
 JSBool
 CallMethodHelper::ConvertDependentParams()
 {
     const uint8 paramCount = mMethodInfo->GetParamCount();
     for (uint8 i = 0; i < paramCount; i++) {
         const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i);
+
+        if (!paramInfo.GetType().IsDependent())
+            continue;
+        if (!ConvertDependentParam(i))
+            return JS_FALSE;
+    }
+
+    return JS_TRUE;
+}
+
+JSBool
+CallMethodHelper::ConvertDependentParam(uint8 i)
+{
+        const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i);
         const nsXPTType& type = paramInfo.GetType();
-
-        if (!type.IsDependent())
-            continue;
-
         nsXPTType datum_type;
         JSUint32 array_count = 0;
         bool isArray = type.IsArray();
 
         bool isSizedString = isArray ?
             JS_FALSE :
             type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
             type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;
@@ -2735,17 +2746,17 @@ CallMethodHelper::ConvertDependentParams
         if (paramInfo.IsOut()) {
             if (datum_type.IsPointer() &&
                 !datum_type.IsInterfacePointer() &&
                 isArray) {
                 dp->SetValNeedsCleanup();
             }
 
             if (!paramInfo.IsIn())
-                continue;
+                return JS_TRUE;
         } else {
             NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
                          "Expected either enough arguments or an optional argument");
             src = i < mArgc ? mArgv[i] : JSVAL_NULL;
 
             if (datum_type.TagPart() == nsXPTType::T_IID ||
                 datum_type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
                 datum_type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS ||
@@ -2786,19 +2797,18 @@ CallMethodHelper::ConvertDependentParams
             }
         } else {
             if (!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
                                            JS_TRUE, &param_iid, &err)) {
                 ThrowBadParam(err, i, mCallContext);
                 return JS_FALSE;
             }
         }
-    }
-
-    return JS_TRUE;
+
+        return JS_TRUE;
 }
 
 // Performs all necessary teardown on a parameter after method invocation.
 //
 // This method should only be called if the value in question was flagged
 // for cleanup (ie, if dp->DoesValNeedCleanup()).
 void
 CallMethodHelper::CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type)