Bug 712873 - Part 3: Replace JS_ALWAYS_TRUE with MOZ_ALWAYS_TRUE outside js/src/ directory. r=luke
--- a/content/base/src/nsDOMBlobBuilder.cpp
+++ b/content/base/src/nsDOMBlobBuilder.cpp
@@ -229,17 +229,17 @@ nsDOMMultipartFile::ParseBlobArrayArgume
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
if (!JS_IsArrayObject(aCx, obj)) {
return NS_ERROR_TYPE_ERR; // We're not interested
}
BlobSet blobSet;
uint32_t length;
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
for (uint32_t i = 0; i < length; ++i) {
JS::Rooted<JS::Value> element(aCx);
if (!JS_GetElement(aCx, obj, i, &element))
return NS_ERROR_TYPE_ERR;
if (element.isObject()) {
JS::Rooted<JSObject*> obj(aCx, &element.toObject());
nsCOMPtr<nsIDOMBlob> blob = aUnwrapFunc(aCx, obj);
--- a/dom/mobilemessage/src/MmsMessage.cpp
+++ b/dom/mobilemessage/src/MmsMessage.cpp
@@ -209,17 +209,17 @@ MmsMessage::Create(int32_t
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> deliveryInfoObj(aCx, &aDeliveryInfo.toObject());
if (!JS_IsArrayObject(aCx, deliveryInfoObj)) {
return NS_ERROR_INVALID_ARG;
}
uint32_t length;
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
nsTArray<MmsDeliveryInfo> deliveryInfo;
JS::Rooted<JS::Value> infoJsVal(aCx);
for (uint32_t i = 0; i < length; ++i) {
if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) ||
!infoJsVal.isObject()) {
return NS_ERROR_INVALID_ARG;
}
@@ -235,17 +235,17 @@ MmsMessage::Create(int32_t
if (!aReceivers.isObject()) {
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> receiversObj(aCx, &aReceivers.toObject());
if (!JS_IsArrayObject(aCx, receiversObj)) {
return NS_ERROR_INVALID_ARG;
}
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
nsTArray<nsString> receivers;
JS::Rooted<JS::Value> receiverJsVal(aCx);
for (uint32_t i = 0; i < length; ++i) {
if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) ||
!receiverJsVal.isString()) {
return NS_ERROR_INVALID_ARG;
}
@@ -270,17 +270,17 @@ MmsMessage::Create(int32_t
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> attachmentsObj(aCx, &aAttachments.toObject());
if (!JS_IsArrayObject(aCx, attachmentsObj)) {
return NS_ERROR_INVALID_ARG;
}
nsTArray<MmsAttachment> attachments;
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
JS::Rooted<JS::Value> attachmentJsVal(aCx);
for (uint32_t i = 0; i < length; ++i) {
if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) {
return NS_ERROR_INVALID_ARG;
}
MmsAttachment attachment;
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -345,17 +345,17 @@ MobileMessageManager::Delete(JS::Handle<
NS_ENSURE_SUCCESS(rv, rv);
size = 1;
idArray = &id;
} else {
// Int32[], SmsMessage[], or MmsMessage[]
JS::Rooted<JSObject*> ids(aCx, &aParam.toObject());
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, ids, &size));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, ids, &size));
nsAutoArrayPtr<int32_t> idAutoArray(new int32_t[size]);
JS::Rooted<JS::Value> idJsValue(aCx);
for (uint32_t i = 0; i < size; i++) {
if (!JS_GetElement(aCx, ids, i, &idJsValue)) {
return NS_ERROR_INVALID_ARG;
}
--- a/dom/mobilemessage/src/MobileMessageThread.cpp
+++ b/dom/mobilemessage/src/MobileMessageThread.cpp
@@ -6,17 +6,16 @@
#include "MobileMessageThread.h"
#include "nsIDOMClassInfo.h"
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
#include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch
#include "nsJSUtils.h" // For nsDependentJSString
#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
-
using namespace mozilla::dom::mobilemessage;
DOMCI_DATA(MozMobileMessageThread, mozilla::dom::MobileMessageThread)
namespace mozilla {
namespace dom {
NS_INTERFACE_MAP_BEGIN(MobileMessageThread)
@@ -56,17 +55,17 @@ MobileMessageThread::Create(const uint64
}
JS::Rooted<JSObject*> obj(aCx, &aParticipants.toObject());
if (!JS_IsArrayObject(aCx, obj)) {
return NS_ERROR_INVALID_ARG;
}
uint32_t length;
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
for (uint32_t i = 0; i < length; ++i) {
JS::Rooted<JS::Value> val(aCx);
if (!JS_GetElement(aCx, obj, i, &val) || !val.isString()) {
return NS_ERROR_INVALID_ARG;
}
--- a/dom/mobilemessage/src/SmsFilter.cpp
+++ b/dom/mobilemessage/src/SmsFilter.cpp
@@ -167,17 +167,17 @@ SmsFilter::SetNumbers(JSContext* aCx, JS
}
JS::Rooted<JSObject*> obj(aCx, &aNumbers.toObject());
if (!JS_IsArrayObject(aCx, obj)) {
return NS_ERROR_INVALID_ARG;
}
uint32_t size;
- JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &size));
+ MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &size));
nsTArray<nsString> numbers;
for (uint32_t i=0; i<size; ++i) {
JS::Rooted<JS::Value> jsNumber(aCx);
if (!JS_GetElement(aCx, obj, i, &jsNumber)) {
return NS_ERROR_INVALID_ARG;
}
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -37,26 +37,16 @@ namespace js {}
/*
* Pattern used to overwrite freed memory. If you are accessing an object with
* this pattern, you probably have a dangling pointer.
*/
#define JS_FREE_PATTERN 0xDA
#define JS_ASSERT(expr) MOZ_ASSERT(expr)
#define JS_ASSERT_IF(cond, expr) MOZ_ASSERT_IF(cond, expr)
-#define JS_ALWAYS_TRUE(expr) MOZ_ALWAYS_TRUE(expr)
-#define JS_ALWAYS_FALSE(expr) MOZ_ALWAYS_FALSE(expr)
-
-#if defined(JS_DEBUG)
-# define JS_DIAGNOSTICS_ASSERT(expr) MOZ_ASSERT(expr)
-#elif defined(JS_CRASH_DIAGNOSTICS)
-# define JS_DIAGNOSTICS_ASSERT(expr) do { if (!(expr)) MOZ_CRASH(); } while(0)
-#else
-# define JS_DIAGNOSTICS_ASSERT(expr) ((void) 0)
-#endif
#define JS_STATIC_ASSERT(cond) static_assert(cond, "JS_STATIC_ASSERT")
#define JS_STATIC_ASSERT_IF(cond, expr) MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF")
extern MOZ_NORETURN JS_PUBLIC_API(void)
JS_Assert(const char *s, const char *file, int ln);
/*
--- a/js/src/jsutil.h
+++ b/js/src/jsutil.h
@@ -6,23 +6,35 @@
/*
* PR assertion checker.
*/
#ifndef jsutil_h
#define jsutil_h
+#include "mozilla/Assertions.h"
#include "mozilla/Compiler.h"
#include "mozilla/GuardObjects.h"
#include <limits.h>
#include "js/Utility.h"
+#define JS_ALWAYS_TRUE(expr) MOZ_ALWAYS_TRUE(expr)
+#define JS_ALWAYS_FALSE(expr) MOZ_ALWAYS_FALSE(expr)
+
+#if defined(JS_DEBUG)
+# define JS_DIAGNOSTICS_ASSERT(expr) MOZ_ASSERT(expr)
+#elif defined(JS_CRASH_DIAGNOSTICS)
+# define JS_DIAGNOSTICS_ASSERT(expr) do { if (MOZ_UNLIKELY(!(expr))) MOZ_CRASH(); } while(0)
+#else
+# define JS_DIAGNOSTICS_ASSERT(expr) ((void) 0)
+#endif
+
static MOZ_ALWAYS_INLINE void *
js_memcpy(void *dst_, const void *src_, size_t len)
{
char *dst = (char *) dst_;
const char *src = (const char *) src_;
JS_ASSERT_IF(dst >= src, (size_t) (dst - src) >= len);
JS_ASSERT_IF(src >= dst, (size_t) (src - dst) >= len);