Bug 952650 (part 4) - Remove JSVAL_IS_DOUBLE. r=njn.
authorRodrigo Rodriguez Jr. <rrodrigue96@hotmail.com>
Sun, 27 Apr 2014 19:35:40 -0700
changeset 181293 899b41829e76f541f19bb3fbfa6d57e2b5a3a0c7
parent 181292 840f2ac959d4d3919248b436305f736c608c731a
child 181294 77173a0f4085f708941164ba3666aac9ecd3f54a
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersnjn
bugs952650
milestone32.0a1
Bug 952650 (part 4) - Remove JSVAL_IS_DOUBLE. r=njn.
content/canvas/src/CanvasUtils.cpp
dom/plugins/base/nsJSNPRuntime.cpp
gfx/skia/trunk/src/xml/SkJSDisplayable.cpp
js/jsd/jsd_val.cpp
js/jsd/jsd_xpc.cpp
js/public/Value.h
js/src/ctypes/CTypes.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
--- a/content/canvas/src/CanvasUtils.cpp
+++ b/content/canvas/src/CanvasUtils.cpp
@@ -62,17 +62,17 @@ DoDrawImageSecurityCheck(dom::HTMLCanvas
     }
 
     aCanvasElement->SetWriteOnly();
 }
 
 bool
 CoerceDouble(JS::Value v, double* d)
 {
-    if (JSVAL_IS_DOUBLE(v)) {
+    if (v.isDouble()) {
         *d = JSVAL_TO_DOUBLE(v);
     } else if (JSVAL_IS_INT(v)) {
         *d = double(JSVAL_TO_INT(v));
     } else if (v.isUndefined()) {
         *d = 0.0;
     } else {
         return false;
     }
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -385,17 +385,17 @@ JSValToNPVariant(NPP npp, JSContext *cx,
     if (val == JSVAL_VOID) {
       VOID_TO_NPVARIANT(*variant);
     } else if (val.isNull()) {
       NULL_TO_NPVARIANT(*variant);
     } else if (JSVAL_IS_BOOLEAN(val)) {
       BOOLEAN_TO_NPVARIANT(val.toBoolean(), *variant);
     } else if (JSVAL_IS_INT(val)) {
       INT32_TO_NPVARIANT(JSVAL_TO_INT(val), *variant);
-    } else if (JSVAL_IS_DOUBLE(val)) {
+    } else if (val.isDouble()) {
       double d = JSVAL_TO_DOUBLE(val);
       int i;
       if (JS_DoubleIsInt32(d, &i)) {
         INT32_TO_NPVARIANT(i, *variant);
       } else {
         DOUBLE_TO_NPVARIANT(d, *variant);
       }
     } else if (JSVAL_IS_STRING(val)) {
--- a/gfx/skia/trunk/src/xml/SkJSDisplayable.cpp
+++ b/gfx/skia/trunk/src/xml/SkJSDisplayable.cpp
@@ -313,17 +313,17 @@ JSBool SkJSDisplayable::SetProperty(JSCo
         case SkType_Color:
         case SkType_S32:
             s32 = JSVAL_TO_INT(value);
             break;
         case SkType_Scalar:
             if (JSVAL_IS_INT(value))
                 scalar = SkIntToScalar(JSVAL_TO_INT(value));
             else {
-                SkASSERT(JSVAL_IS_DOUBLE(value));
+                SkASSERT(value.isDouble());
                 scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
             }
             break;
         case SkType_String:
             str = JS_ValueToString(cx, value);
             string.set(JS_GetStringBytes(str));
             break;
         default:
--- a/js/jsd/jsd_val.cpp
+++ b/js/jsd/jsd_val.cpp
@@ -73,17 +73,17 @@ bool
 jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval)
 {
     return JSVAL_IS_INT(jsdval->val);
 }
 
 bool
 jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval)
 {
-    return JSVAL_IS_DOUBLE(jsdval->val);
+    return jsdval->val.isDouble();
 }
 
 bool
 jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval)
 {
     return JSVAL_IS_STRING(jsdval->val);
 }
 
@@ -157,17 +157,17 @@ jsd_GetValueInt(JSDContext* jsdc, JSDVal
     if(!JSVAL_IS_INT(val))
         return 0;
     return JSVAL_TO_INT(val);
 }
 
 double
 jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval)
 {
-    if(!JSVAL_IS_DOUBLE(jsdval->val))
+    if(!jsdval->val.isDouble())
         return 0;
     return JSVAL_TO_DOUBLE(jsdval->val);
 }
 
 JSString*
 jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
 {
     AutoSafeJSContext cx;
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -2157,17 +2157,17 @@ jsdValue::GetJsType (uint32_t *_rval)
 {
     ASSERT_VALID_EPHEMERAL;
     JS::RootedValue val(JSD_GetJSRuntime(mCx), JSD_GetValueWrappedJSVal (mCx, mValue));
 
     if (val.isNull())
         *_rval = TYPE_NULL;
     else if (JSVAL_IS_BOOLEAN(val))
         *_rval = TYPE_BOOLEAN;
-    else if (JSVAL_IS_DOUBLE(val))
+    else if (val.isDouble())
         *_rval = TYPE_DOUBLE;
     else if (JSVAL_IS_INT(val))
         *_rval = TYPE_INT;
     else if (JSVAL_IS_STRING(val))
         *_rval = TYPE_STRING;
     else if (val.isUndefined())
         *_rval = TYPE_VOID;
     else if (JSD_IsValueFunction (mCx, mValue))
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1835,27 +1835,21 @@ JSVAL_TO_INT(jsval v)
 }
 
 static inline JS_VALUE_CONSTEXPR jsval
 INT_TO_JSVAL(int32_t i)
 {
     return IMPL_TO_JSVAL(INT32_TO_JSVAL_IMPL(i));
 }
 
-static inline bool
-JSVAL_IS_DOUBLE(jsval v)
-{
-    return JSVAL_IS_DOUBLE_IMPL(JSVAL_TO_IMPL(v));
-}
-
 static inline double
 JSVAL_TO_DOUBLE(jsval v)
 {
     jsval_layout l;
-    MOZ_ASSERT(JSVAL_IS_DOUBLE(v));
+    MOZ_ASSERT(v.isDouble());
     l = JSVAL_TO_IMPL(v);
     return l.asDouble;
 }
 
 static inline JS_VALUE_CONSTEXPR jsval
 DOUBLE_TO_JSVAL(double d)
 {
     /*
@@ -1963,17 +1957,17 @@ static inline jsval
 PRIVATE_TO_JSVAL(void *ptr)
 {
     return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr));
 }
 
 static inline void *
 JSVAL_TO_PRIVATE(jsval v)
 {
-    MOZ_ASSERT(JSVAL_IS_DOUBLE(v));
+    MOZ_ASSERT(v.isDouble());
     return JSVAL_TO_PRIVATE_PTR_IMPL(JSVAL_TO_IMPL(v));
 }
 
 // JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and
 // constructing values from scratch (e.g. Int32Value(0)).  These constants are
 // stored in memory and initialized at startup, so testing against them and
 // using them requires memory loads and will be correspondingly slow.
 extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL;
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1579,17 +1579,17 @@ jsvalToBool(JSContext* cx, jsval val, bo
     *result = val.toBoolean();
     return true;
   }
   if (JSVAL_IS_INT(val)) {
     int32_t i = JSVAL_TO_INT(val);
     *result = i != 0;
     return i == 0 || i == 1;
   }
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     double d = JSVAL_TO_DOUBLE(val);
     *result = d != 0;
     // Allow -0.
     return d == 1 || d == 0;
   }
   // Don't silently convert null to bool. It's probably a mistake.
   return false;
 }
@@ -1604,17 +1604,17 @@ jsvalToInteger(JSContext* cx, jsval val,
   JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
 
   if (JSVAL_IS_INT(val)) {
     // Make sure the integer fits in the alotted precision, and has the right
     // sign.
     int32_t i = JSVAL_TO_INT(val);
     return ConvertExact(i, result);
   }
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     // Don't silently lose bits here -- check that val really is an
     // integer value, and has the right sign.
     double d = JSVAL_TO_DOUBLE(val);
     return ConvertExact(d, result);
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (CData::IsCData(obj)) {
@@ -1695,17 +1695,17 @@ jsvalToFloat(JSContext *cx, jsval val, F
   // The following casts may silently throw away some bits, but there's
   // no good way around it. Sternly requiring that the 64-bit double
   // argument be exactly representable as a 32-bit float is
   // unrealistic: it would allow 1/2 to pass but not 1/3.
   if (JSVAL_IS_INT(val)) {
     *result = FloatType(JSVAL_TO_INT(val));
     return true;
   }
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     *result = FloatType(JSVAL_TO_DOUBLE(val));
     return true;
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (CData::IsCData(obj)) {
       JSObject* typeObj = CData::GetCType(obj);
       void* data = CData::GetData(obj);
@@ -1809,17 +1809,17 @@ jsvalToBigInteger(JSContext* cx,
   JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
 
   if (JSVAL_IS_INT(val)) {
     // Make sure the integer fits in the alotted precision, and has the right
     // sign.
     int32_t i = JSVAL_TO_INT(val);
     return ConvertExact(i, result);
   }
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     // Don't silently lose bits here -- check that val really is an
     // integer value, and has the right sign.
     double d = JSVAL_TO_DOUBLE(val);
     return ConvertExact(d, result);
   }
   if (allowString && JSVAL_IS_STRING(val)) {
     // Allow conversion from base-10 or base-16 strings, provided the result
     // fits in IntegerType. (This allows an Int64 or UInt64 object to be passed
@@ -1939,17 +1939,17 @@ SizeTojsval(JSContext* cx, size_t size, 
 
 // Forcefully convert val to IntegerType when explicitly requested.
 template<class IntegerType>
 static bool
 jsvalToIntegerExplicit(jsval val, IntegerType* result)
 {
   JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
 
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     // Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
     double d = JSVAL_TO_DOUBLE(val);
     *result = mozilla::IsFinite(d) ? IntegerType(d) : 0;
     return true;
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     // Convert Int64 and UInt64 values by C-style cast.
     JSObject* obj = JSVAL_TO_OBJECT(val);
@@ -1973,17 +1973,17 @@ jsvalToPtrExplicit(JSContext* cx, jsval 
 {
   if (JSVAL_IS_INT(val)) {
     // int32_t always fits in intptr_t. If the integer is negative, cast through
     // an intptr_t intermediate to sign-extend.
     int32_t i = JSVAL_TO_INT(val);
     *result = i < 0 ? uintptr_t(intptr_t(i)) : uintptr_t(i);
     return true;
   }
-  if (JSVAL_IS_DOUBLE(val)) {
+  if (val.isDouble()) {
     double d = JSVAL_TO_DOUBLE(val);
     if (d < 0) {
       // Cast through an intptr_t intermediate to sign-extend.
       intptr_t i = Convert<intptr_t>(d);
       if (double(i) != d)
         return false;
 
       *result = uintptr_t(i);
@@ -3480,17 +3480,17 @@ CType::GetSafeSize(JSObject* obj, size_t
   jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   // The "size" property can be an int, a double, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   if (JSVAL_IS_INT(size)) {
     *result = JSVAL_TO_INT(size);
     return true;
   }
-  if (JSVAL_IS_DOUBLE(size)) {
+  if (size.isDouble()) {
     *result = Convert<size_t>(JSVAL_TO_DOUBLE(size));
     return true;
   }
 
   JS_ASSERT(size.isUndefined());
   return false;
 }
 
@@ -3515,17 +3515,17 @@ bool
 CType::IsSizeDefined(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
   jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   // The "size" property can be an int, a double, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
-  JS_ASSERT(JSVAL_IS_INT(size) || JSVAL_IS_DOUBLE(size) || size.isUndefined());
+  JS_ASSERT(JSVAL_IS_INT(size) || size.isDouble() || size.isUndefined());
   return !size.isUndefined();
 }
 
 size_t
 CType::GetAlignment(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -238,17 +238,17 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
 
                     if (e &&
                         NS_SUCCEEDED(e->GetResult(&rv)) &&
                         rv == NS_NOINTERFACE) {
                         JS_ClearPendingException(cx);
                     }
                 } else if (JSVAL_IS_NUMBER(jsexception)) {
                     // JS often throws an nsresult.
-                    if (JSVAL_IS_DOUBLE(jsexception))
+                    if (jsexception.isDouble())
                         // Visual Studio 9 doesn't allow casting directly from
                         // a double to an enumeration type, contrary to
                         // 5.2.9(10) of C++11, so add an intermediate cast.
                         rv = (nsresult)(uint32_t)(JSVAL_TO_DOUBLE(jsexception));
                     else
                         rv = (nsresult)(JSVAL_TO_INT(jsexception));
 
                     if (rv == NS_NOINTERFACE)