Pick up a few straggler uses of {NS,JS}_ARRAY_LENGTH, probably added since the switch but before the deprecation announcement, and convert them to mozilla::ArrayLength. Also convert the two users of PR_ARRAY_SIZE, yet another length-computing macro, to mozilla::ArrayLength. No bug, r=sparky
authorJeff Walden <jwalden@mit.edu>
Fri, 21 Oct 2011 03:16:47 -0700
changeset 79738 107c941e27dced818c50b5e213a99f3cde5396eb
parent 79737 c09b6f933f7676c167625958a4dd3da195317a5d
child 79739 41f8fb72be221799fbd3ef3aa044eb57dd70cde2
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssparky
milestone10.0a1
Pick up a few straggler uses of {NS,JS}_ARRAY_LENGTH, probably added since the switch but before the deprecation announcement, and convert them to mozilla::ArrayLength. Also convert the two users of PR_ARRAY_SIZE, yet another length-computing macro, to mozilla::ArrayLength. No bug, r=sparky
dom/workers/Events.cpp
dom/workers/Exceptions.cpp
dom/workers/ListenerManager.cpp
dom/workers/WorkerScope.cpp
xpcom/io/nsLocalFileWin.cpp
xpinstall/src/nsXPITriggerInfo.cpp
--- a/dom/workers/Events.cpp
+++ b/dom/workers/Events.cpp
@@ -32,16 +32,18 @@
  * 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 ***** */
 
+#include "mozilla/Util.h"
+
 #include "Events.h"
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsfriendapi.h"
 
 #include "nsTraceRefcnt.h"
 
@@ -52,16 +54,17 @@
   JSPROP_ENUMERATE | JSPROP_SHARED
 
 #define FUNCTION_FLAGS \
   JSPROP_ENUMERATE
 
 #define CONSTANT_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY
 
+using namespace mozilla;
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 class Event : public PrivatizableBase
 {
   static JSClass sClass;
   static JSClass sMainRuntimeClass;
@@ -1121,17 +1124,17 @@ DispatchEventToTarget(JSContext* aCx, JS
   if (!JS_HasProperty(aCx, aTarget, kFunctionName, &hasProperty)) {
     return false;
   }
 
   JSBool preventDefaultCalled = false;
   if (hasProperty) {
     jsval argv[] = { OBJECT_TO_JSVAL(aEvent) };
     jsval rval = JSVAL_VOID;
-    if (!JS_CallFunctionName(aCx, aTarget, kFunctionName, JS_ARRAY_LENGTH(argv),
+    if (!JS_CallFunctionName(aCx, aTarget, kFunctionName, ArrayLength(argv),
                              argv, &rval) ||
         !JS_ValueToBoolean(aCx, rval, &preventDefaultCalled)) {
       return false;
     }
   }
 
   *aPreventDefaultCalled = !!preventDefaultCalled;
   return true;
--- a/dom/workers/Exceptions.cpp
+++ b/dom/workers/Exceptions.cpp
@@ -32,16 +32,18 @@
  * 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 ***** */
 
+#include "mozilla/Util.h"
+
 #include "Exceptions.h"
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsfriendapi.h"
 #include "jsprf.h"
 
 #include "nsTraceRefcnt.h"
@@ -49,16 +51,17 @@
 #include "WorkerInlines.h"
 
 #define PROPERTY_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED
 
 #define CONSTANT_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY
 
+using namespace mozilla;
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 class DOMException : public PrivatizableBase
 {
   static JSClass sClass;
   static JSPropertySpec sProperties[];
@@ -242,19 +245,17 @@ JSObject*
 DOMException::Create(JSContext* aCx, intN aCode)
 {
   JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
   if (!obj) {
     return NULL;
   }
 
   size_t foundIndex = size_t(-1);
-  for (size_t index = 0;
-       index < JS_ARRAY_LENGTH(sStaticProperties) - 1;
-       index++) {
+  for (size_t index = 0; index < ArrayLength(sStaticProperties) - 1; index++) {
     if (sStaticProperties[index].tinyid == aCode) {
       foundIndex = index;
       break;
     }
   }
 
   JS_ASSERT(foundIndex != size_t(-1));
 
@@ -392,19 +393,17 @@ JSObject*
 FileException::Create(JSContext* aCx, intN aCode)
 {
   JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
   if (!obj) {
     return NULL;
   }
 
   size_t foundIndex = size_t(-1);
-  for (size_t index = 0;
-       index < JS_ARRAY_LENGTH(sStaticProperties) - 1;
-       index++) {
+  for (size_t index = 0; index < ArrayLength(sStaticProperties) - 1; index++) {
     if (sStaticProperties[index].tinyid == aCode) {
       foundIndex = index;
       break;
     }
   }
 
   JS_ASSERT(foundIndex != size_t(-1));
 
--- a/dom/workers/ListenerManager.cpp
+++ b/dom/workers/ListenerManager.cpp
@@ -31,25 +31,28 @@
  * 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 ***** */
 
+#include "mozilla/Util.h"
+
 #include "ListenerManager.h"
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "js/Vector.h"
 
 #include "Events.h"
 
-using mozilla::dom::workers::events::ListenerManager;
+using namespace mozilla;
+using dom::workers::events::ListenerManager;
 
 namespace {
 
 struct Listener;
 
 struct ListenerCollection : PRCList
 {
   static ListenerCollection*
@@ -421,17 +424,17 @@ ListenerManager::DispatchEvent(JSContext
           return false;
         }
         continue;
       }
     }
 
     jsval argv[] = { OBJECT_TO_JSVAL(aEvent) };
     jsval rval = JSVAL_VOID;
-    if (!JS_CallFunctionValue(aCx, aTarget, listenerVal, JS_ARRAY_LENGTH(argv),
+    if (!JS_CallFunctionValue(aCx, aTarget, listenerVal, ArrayLength(argv),
                               argv, &rval)) {
       if (!JS_ReportPendingException(aCx)) {
         return false;
       }
       continue;
     }
   }
 
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -32,16 +32,18 @@
  * 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 ***** */
 
+#include "mozilla/Util.h"
+
 #include "WorkerScope.h"
 
 #include "jsapi.h"
 #include "jscntxt.h"
 
 #include "nsTraceRefcnt.h"
 #include "xpcprivate.h"
 
@@ -63,16 +65,17 @@
 #include "WorkerInlines.h"
 
 #define PROPERTY_FLAGS \
   JSPROP_ENUMERATE | JSPROP_SHARED
 
 #define FUNCTION_FLAGS \
   JSPROP_ENUMERATE
 
+using namespace mozilla;
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 class WorkerGlobalScope : public events::EventTarget
 {
   static JSClass sClass;
   static JSPropertySpec sProperties[];
@@ -282,17 +285,17 @@ private:
     if (!JS_GetProperty(aCx, event, "message", &argv[0]) ||
         !JS_GetProperty(aCx, event, "filename", &argv[1]) ||
         !JS_GetProperty(aCx, event, "lineno", &argv[2])) {
       return false;
     }
 
     jsval rval = JSVAL_VOID;
     if (!JS_CallFunctionValue(aCx, JSVAL_TO_OBJECT(scope), listener,
-                              JS_ARRAY_LENGTH(argv), argv, &rval)) {
+                              ArrayLength(argv), argv, &rval)) {
       JS_ReportPendingException(aCx);
       return false;
     }
 
     if (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval) &&
         !JS_CallFunctionName(aCx, event, "preventDefault", 0, NULL, &rval)) {
       return false;
     }
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -2812,17 +2812,17 @@ nsLocalFile::RevealUsingShell()
   if (isDirectory) {
     // We have a directory so we should open the directory itself.
     ITEMIDLIST *dir = sILCreateFromPathW(mResolvedPath.get());
     if (!dir) {
       return NS_ERROR_FAILURE;
     }
 
     const ITEMIDLIST* selection[] = { dir };
-    UINT count = PR_ARRAY_SIZE(selection);
+    UINT count = ArrayLength(selection);
 
     //Perform the open of the directory.
     hr = sSHOpenFolderAndSelectItems(dir, count, selection, 0);
     CoTaskMemFree(dir);
   }
   else {
     // Obtain the parent path of the item we are revealing.
     nsCOMPtr<nsIFile> parentDirectory;
@@ -2841,17 +2841,17 @@ nsLocalFile::RevealUsingShell()
     // Set the item in the directory to select to the file we want to reveal.
     ITEMIDLIST *item = sILCreateFromPathW(mResolvedPath.get());
     if (!item) {
       CoTaskMemFree(dir);
       return NS_ERROR_FAILURE;
     }
     
     const ITEMIDLIST* selection[] = { item };
-    UINT count = PR_ARRAY_SIZE(selection);
+    UINT count = ArrayLength(selection);
 
     //Perform the selection of the file.
     hr = sSHOpenFolderAndSelectItems(dir, count, selection, 0);
 
     CoTaskMemFree(dir);
     CoTaskMemFree(item);
   }
   
--- a/xpinstall/src/nsXPITriggerInfo.cpp
+++ b/xpinstall/src/nsXPITriggerInfo.cpp
@@ -33,30 +33,34 @@
  * 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 ***** */
 
+#include "mozilla/Util.h"
+
 #include "jscntxt.h"
 #include "nscore.h"
 #include "plstr.h"
 #include "nsXPITriggerInfo.h"
 #include "nsNetUtil.h"
 #include "nsDebug.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsIServiceManager.h"
 #include "nsIJSContextStack.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsICryptoHash.h"
 #include "nsIX509Cert.h"
 
+using namespace mozilla;
+
 //
 // nsXPITriggerItem
 //
 
 nsXPITriggerItem::nsXPITriggerItem( const PRUnichar* aName,
                                     const PRUnichar* aURL,
                                     const PRUnichar* aIconURL,
                                     const char* aHash,
@@ -241,17 +245,17 @@ XPITriggerEvent::Run()
     JSObject* innerGlobal = JS_GetGlobalForObject(cx, JSVAL_TO_OBJECT(cbval));
     jsval components;
     if (!JS_LookupProperty(cx, innerGlobal, "Components", &components) ||
         !JSVAL_IS_OBJECT(components))
         return 0;
 
     // Build arguments into rooted jsval array
     jsval args[2] = { JSVAL_NULL, JSVAL_NULL };
-    js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(args), args);
+    js::AutoArrayRooter tvr(cx, ArrayLength(args), args);
 
     // args[0] is the URL
     JSString *str = JS_NewUCStringCopyZ(cx, reinterpret_cast<const jschar*>(URL.get()));
     if (!str)
         return 0;
     args[0] = STRING_TO_JSVAL(str);
 
     // args[1] is the status