Bug 496441 - Some random cleanup: remove an unnecessary macro. r+sr=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 01 Jul 2009 12:12:04 -0700
changeset 29946 e7c62fc3b92bc0ecefaeefd7db0db76dbf23c7ea
parent 29945 85acdb9128ce699374a725e7000cb9daff19f22e
child 29947 a334624fc37ed006643f9fd6c90085975671d231
push idunknown
push userunknown
push dateunknown
bugs496441
milestone1.9.2a1pre
Bug 496441 - Some random cleanup: remove an unnecessary macro. r+sr=jst
js/src/xpconnect/src/xpcwrappedjsclass.cpp
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -1239,17 +1239,16 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
     uint8 stack_size;
     jsval result;
     uint8 paramCount=0;
     nsresult retval = NS_ERROR_FAILURE;
     nsresult pending_result = NS_OK;
     JSBool success;
     JSBool readyToDoTheCall = JS_FALSE;
     nsID  param_iid;
-    uint8 outConversionFailedIndex;
     JSObject* obj;
     const char* name = info->name;
     jsval fval;
     void* mark;
     JSBool foundDependentParam;
     XPCContext* xpcc;
     JSContext* cx;
     JSObject* thisObj;
@@ -1430,22 +1429,16 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
 
     // this is a function call, so push function and 'this'
     if(stack_size != argc)
     {
         *sp++ = fval;
         *sp++ = OBJECT_TO_JSVAL(thisObj);
     }
 
-    // make certain we leave no garbage in the stack
-    for(i = 0; i < argc; i++)
-    {
-        sp[i] = JSVAL_VOID;
-    }
-
     // build the args
     for(i = 0; i < argc; i++)
     {
         const nsXPTParamInfo& param = info->params[i];
         const nsXPTType& type = param.GetType();
         nsXPTType datum_type;
         JSUint32 array_count;
         PRBool isArray = type.IsArray();
@@ -1687,27 +1680,23 @@ pre_call_clean_up:
         // a report in that case.
 
         retval = CheckForException(ccx, name, GetInterfaceName(), forceReport);
         goto done;
     }
 
     ccx.GetThreadData()->SetException(nsnull); // XXX necessary?
 
-#define HANDLE_OUT_CONVERSION_FAILURE       \
-        {outConversionFailedIndex = i; break;}
-
     // convert out args and result
     // NOTE: this is the total number of native params, not just the args
     // Convert independent params only.
     // When we later convert the dependent params (if any) we will know that
     // the params upon which they depend will have already been converted -
     // regardless of ordering.
 
-    outConversionFailedIndex = paramCount;
     foundDependentParam = JS_FALSE;
     for(i = 0; i < paramCount; i++)
     {
         const nsXPTParamInfo& param = info->params[i];
         if(!param.IsOut() && !param.IsDipper())
             continue;
 
         const nsXPTType& type = param.GetType();
@@ -1728,37 +1717,37 @@ pre_call_clean_up:
             pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
 
         if(param.IsRetval())
             val = result;
         else if(JSVAL_IS_PRIMITIVE(stackbase[i+2]) ||
                 !JS_GetPropertyById(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
                     mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                     &val))
-            HANDLE_OUT_CONVERSION_FAILURE
+            break;
 
         // setup allocator and/or iid
 
         if(type_tag == nsXPTType::T_INTERFACE)
         {
             if(NS_FAILED(GetInterfaceInfo()->
                             GetIIDForParamNoAlloc(methodIndex, &param,
                                                   &param_iid)))
-                HANDLE_OUT_CONVERSION_FAILURE
+                break;
         }
         else if(type.IsPointer() && !param.IsShared() && !param.IsDipper())
             useAllocator = JS_TRUE;
 
         if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                       useAllocator, &param_iid, nsnull))
-            HANDLE_OUT_CONVERSION_FAILURE
+            break;
     }
 
     // if any params were dependent, then we must iterate again to convert them.
-    if(foundDependentParam && outConversionFailedIndex == paramCount)
+    if(foundDependentParam && i == paramCount)
     {
         for(i = 0; i < paramCount; i++)
         {
             const nsXPTParamInfo& param = info->params[i];
             if(!param.IsOut())
                 continue;
 
             const nsXPTType& type = param.GetType();
@@ -1778,77 +1767,77 @@ pre_call_clean_up:
 
             pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
 
             if(param.IsRetval())
                 val = result;
             else if(!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
                         mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                         &val))
-                HANDLE_OUT_CONVERSION_FAILURE
+                break;
 
             // setup allocator and/or iid
 
             if(isArray)
             {
                 if(NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
                                                     &datum_type)))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                    break;
             }
             else
                 datum_type = type;
 
             if(datum_type.IsInterfacePointer())
             {
                if(!GetInterfaceTypeFromParam(cx, info, param, methodIndex,
                                              datum_type, nativeParams,
                                              &param_iid))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                   break;
             }
             else if(type.IsPointer() && !param.IsShared())
                 useAllocator = JS_TRUE;
 
             if(isArray || isSizedString)
             {
                 if(!GetArraySizeFromParam(cx, info, param, methodIndex,
                                           i, GET_LENGTH, nativeParams,
                                           &array_count))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                    break;
             }
 
             if(isArray)
             {
                 if(array_count &&
                    !XPCConvert::JSArray2Native(ccx, (void**)&pv->val, val,
                                                array_count, array_count,
                                                datum_type,
                                                useAllocator, &param_iid,
                                                nsnull))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                    break;
             }
             else if(isSizedString)
             {
                 if(!XPCConvert::JSStringWithSize2Native(ccx,
                                                    (void*)&pv->val, val,
                                                    array_count, array_count,
                                                    datum_type, useAllocator,
                                                    nsnull))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                    break;
             }
             else
             {
                 if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                               useAllocator, &param_iid,
                                               nsnull))
-                    HANDLE_OUT_CONVERSION_FAILURE
+                    break;
             }
         }
     }
 
-    if(outConversionFailedIndex != paramCount)
+    if(i != paramCount)
     {
         // We didn't manage all the result conversions!
         // We have to cleanup any junk that *did* get converted.
 
         for(uint8 k = 0; k < i; k++)
         {
             const nsXPTParamInfo& param = info->params[k];
             if(!param.IsOut())