Bug 683802 - Separate reindentation from previous patch for easier review. No other changes. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Sun, 25 Sep 2011 15:38:00 +0100
changeset 77528 fc259b0fa088434e9b924e5d40c48ab018c0649f
parent 77527 419e8e7166091a0813653ec0ba8980fd48d1c833
child 77529 0ce5751acd70f120dc4300b95c9e4a5842e912c0
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmrbkap
bugs683802
milestone9.0a1
Bug 683802 - Separate reindentation from previous patch for easier review. No other changes. r=mrbkap
js/src/xpconnect/src/xpcwrappednative.cpp
--- a/js/src/xpconnect/src/xpcwrappednative.cpp
+++ b/js/src/xpconnect/src/xpcwrappednative.cpp
@@ -2811,157 +2811,157 @@ CallMethodHelper::ConvertIndependentPara
     }
 
     return JS_TRUE;
 }
 
 JSBool
 CallMethodHelper::ConvertIndependentParam(uint8 i)
 {
-        JSBool useAllocator = JS_FALSE;
-        const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i);
-        const nsXPTType& type = paramInfo.GetType();
-        uint8 type_tag = type.TagPart();
-        nsXPTCVariant* dp = GetDispatchParam(i);
-        dp->type = type;
-
-        if(type_tag == nsXPTType::T_INTERFACE)
+    JSBool useAllocator = JS_FALSE;
+    const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i);
+    const nsXPTType& type = paramInfo.GetType();
+    uint8 type_tag = type.TagPart();
+    nsXPTCVariant* dp = GetDispatchParam(i);
+    dp->type = type;
+
+    if(type_tag == nsXPTType::T_INTERFACE)
+    {
+        dp->SetValIsInterface();
+    }
+
+    jsval src;
+
+    if (!GetOutParamSource(i, &src))
+        return JS_FALSE;
+
+    if(paramInfo.IsOut())
+    {
+        dp->SetPtrIsData();
+        dp->ptr = &dp->val;
+
+        if (type_tag == nsXPTType::T_JSVAL)
         {
-            dp->SetValIsInterface();
+            JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(uint64));
+            jsval *rootp = (jsval *)&dp->val.u64;
+            dp->ptr = rootp;
+            *rootp = JSVAL_VOID;
+            if (!JS_AddValueRoot(mCallContext, rootp))
+                return JS_FALSE;
+            dp->SetValIsJSRoot();
         }
 
-        jsval src;
-
-        if (!GetOutParamSource(i, &src))
-            return JS_FALSE;
-
-        if(paramInfo.IsOut())
+        if(type.IsPointer() &&
+           type_tag != nsXPTType::T_INTERFACE &&
+           !paramInfo.IsShared())
         {
-            dp->SetPtrIsData();
-            dp->ptr = &dp->val;
-
-            if (type_tag == nsXPTType::T_JSVAL)
+            useAllocator = JS_TRUE;
+            dp->SetValIsAllocated();
+        }
+
+        if(!paramInfo.IsIn())
+            return JS_TRUE;
+    }
+    else
+    {
+        if(type.IsPointer())
+        {
+            switch(type_tag)
             {
-                JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(uint64));
-                jsval *rootp = (jsval *)&dp->val.u64;
-                dp->ptr = rootp;
-                *rootp = JSVAL_VOID;
-                if (!JS_AddValueRoot(mCallContext, rootp))
-                    return JS_FALSE;
-                dp->SetValIsJSRoot();
-            }
-
-            if(type.IsPointer() &&
-               type_tag != nsXPTType::T_INTERFACE &&
-               !paramInfo.IsShared())
-            {
+            case nsXPTType::T_IID:
+                dp->SetValIsAllocated();
                 useAllocator = JS_TRUE;
+                break;
+            case nsXPTType::T_CHAR_STR:
                 dp->SetValIsAllocated();
-            }
-
-            if(!paramInfo.IsIn())
-                return JS_TRUE;
-        }
-        else
-        {
-            if(type.IsPointer())
-            {
-                switch(type_tag)
+                useAllocator = JS_TRUE;
+                break;
+            case nsXPTType::T_ASTRING:
+                // Fall through to the T_DOMSTRING case
+
+            case nsXPTType::T_DOMSTRING:
+                if(paramInfo.IsDipper())
                 {
-                case nsXPTType::T_IID:
-                    dp->SetValIsAllocated();
-                    useAllocator = JS_TRUE;
-                    break;
-                case nsXPTType::T_CHAR_STR:
-                    dp->SetValIsAllocated();
-                    useAllocator = JS_TRUE;
-                    break;
-                case nsXPTType::T_ASTRING:
-                    // Fall through to the T_DOMSTRING case
-
-                case nsXPTType::T_DOMSTRING:
-                    if(paramInfo.IsDipper())
+                    // Is an 'out' DOMString. Make a new nsAString
+                    // now and then continue in order to skip the call to
+                    // JSData2Native
+
+                    dp->SetValIsDOMString();
+                    if(!(dp->val.p = new nsAutoString()))
                     {
-                        // Is an 'out' DOMString. Make a new nsAString
-                        // now and then continue in order to skip the call to
-                        // JSData2Native
-
-                        dp->SetValIsDOMString();
-                        if(!(dp->val.p = new nsAutoString()))
-                        {
-                            JS_ReportOutOfMemory(mCallContext);
-                            return JS_FALSE;
-                        }
-                        return JS_TRUE;
+                        JS_ReportOutOfMemory(mCallContext);
+                        return JS_FALSE;
                     }
-                    // else...
-
-                    // Is an 'in' DOMString. Set 'useAllocator' to indicate
-                    // that JSData2Native should allocate a new
-                    // nsAString.
-                    dp->SetValIsDOMString();
-                    useAllocator = JS_TRUE;
-                    break;
-
-                case nsXPTType::T_UTF8STRING:
-                    // Fall through to the C string case for now...
-                case nsXPTType::T_CSTRING:
-                    dp->SetValIsCString();
-                    if(paramInfo.IsDipper())
+                    return JS_TRUE;
+                }
+                // else...
+
+                // Is an 'in' DOMString. Set 'useAllocator' to indicate
+                // that JSData2Native should allocate a new
+                // nsAString.
+                dp->SetValIsDOMString();
+                useAllocator = JS_TRUE;
+                break;
+
+            case nsXPTType::T_UTF8STRING:
+                // Fall through to the C string case for now...
+            case nsXPTType::T_CSTRING:
+                dp->SetValIsCString();
+                if(paramInfo.IsDipper())
+                {
+                    // Is an 'out' CString.
+                    if(!(dp->val.p = new nsCString()))
                     {
-                        // Is an 'out' CString.
-                        if(!(dp->val.p = new nsCString()))
-                        {
-                            JS_ReportOutOfMemory(mCallContext);
-                            return JS_FALSE;
-                        }
-                        return JS_TRUE;
+                        JS_ReportOutOfMemory(mCallContext);
+                        return JS_FALSE;
                     }
-                    // else ...
-                    // Is an 'in' CString.
-                    useAllocator = JS_TRUE;
-                    break;
+                    return JS_TRUE;
                 }
+                // else ...
+                // Is an 'in' CString.
+                useAllocator = JS_TRUE;
+                break;
             }
-            else {
-                if(type_tag == nsXPTType::T_JSVAL) {
-                    dp->SetValIsAllocated();
-                    useAllocator = JS_TRUE;
-                }
+        }
+        else {
+            if(type_tag == nsXPTType::T_JSVAL) {
+                dp->SetValIsAllocated();
+                useAllocator = JS_TRUE;
             }
-
-            // Do this *after* the above because in the case where we have a
-            // "T_DOMSTRING && IsDipper()" then arg might be null since this
-            // is really an 'out' param masquerading as an 'in' param.
-            NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
-                         "Expected either enough arguments or an optional argument");
-            if(i < mArgc)
-                src = mArgv[i];
-            else if(type_tag == nsXPTType::T_JSVAL)
-                src = JSVAL_VOID;
-            else
-                src = JSVAL_NULL;
         }
 
-        nsID param_iid;
-        if(type_tag == nsXPTType::T_INTERFACE &&
-           NS_FAILED(mIFaceInfo->GetIIDForParamNoAlloc(mVTableIndex, &paramInfo,
-                                                       &param_iid)))
-        {
-            ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, i, mCallContext);
-            return JS_FALSE;
-        }
-
-        uintN err;
-        if(!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
-                                      useAllocator, &param_iid, &err))
-        {
-            ThrowBadParam(err, i, mCallContext);
-            return JS_FALSE;
-        }
+        // Do this *after* the above because in the case where we have a
+        // "T_DOMSTRING && IsDipper()" then arg might be null since this
+        // is really an 'out' param masquerading as an 'in' param.
+        NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
+                     "Expected either enough arguments or an optional argument");
+        if(i < mArgc)
+            src = mArgv[i];
+        else if(type_tag == nsXPTType::T_JSVAL)
+            src = JSVAL_VOID;
+        else
+            src = JSVAL_NULL;
+    }
+
+    nsID param_iid;
+    if(type_tag == nsXPTType::T_INTERFACE &&
+       NS_FAILED(mIFaceInfo->GetIIDForParamNoAlloc(mVTableIndex, &paramInfo,
+                                                   &param_iid)))
+    {
+        ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, i, mCallContext);
+        return JS_FALSE;
+    }
+
+    uintN err;
+    if(!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
+                                  useAllocator, &param_iid, &err))
+    {
+        ThrowBadParam(err, i, mCallContext);
+        return JS_FALSE;
+    }
 
     return JS_TRUE;
 }
 
 JSBool
 CallMethodHelper::ConvertDependentParams()
 {
     const uint8 paramCount = mMethodInfo->GetParamCount();