Bug 755875 - Use ValueToInt64/ValueToUint64 in XPCConvert::JSData2Native; r=bholley
authorMs2ger <ms2ger@gmail.com>
Fri, 18 May 2012 10:29:40 +0200
changeset 94326 bf96cfd84803d673557ef2f90f275cf685d6906c
parent 94325 5babc7bc7e33fe3237dd18663fdf27df07853ebb
child 94327 01d962e8982e90fc9ca79176362e91c9df2d0e34
push id22706
push userMs2ger@gmail.com
push dateFri, 18 May 2012 08:31:47 +0000
treeherdermozilla-central@4b74c82dd5ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs755875
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 755875 - Use ValueToInt64/ValueToUint64 in XPCConvert::JSData2Native; r=bholley
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -57,16 +57,17 @@
 #include "dombindings.h"
 #include "nsWrapperCacheInlines.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
 #include "mozilla/dom/BindingUtils.h"
 
+using namespace xpc;
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //#define STRICT_CHECK_OF_UNICODE
 #ifdef STRICT_CHECK_OF_UNICODE
 #define ILLEGAL_RANGE(c) (0!=((c) & 0xFF80))
 #else // STRICT_CHECK_OF_UNICODE
 #define ILLEGAL_RANGE(c) (0!=((c) & 0xFF00))
@@ -427,52 +428,35 @@ XPCConvert::JSData2Native(XPCCallContext
             return false;
         *((int16_t*)d)  = int16_t(ti);
         break;
     case nsXPTType::T_I32    :
         if (!JS_ValueToECMAInt32(cx, s, (int32_t*)d))
             return false;
         break;
     case nsXPTType::T_I64    :
-        if (JSVAL_IS_INT(s)) {
-            if (!JS_ValueToECMAInt32(cx, s, &ti))
-                return false;
-           *((int64_t*)d) = ti;
+        return ValueToInt64(cx, s, (int64_t*)d);
 
-        } else {
-            if (!JS_ValueToNumber(cx, s, &td))
-                return false;
-            *((int64_t*)d) = int64_t(td);
-        }
-        break;
     case nsXPTType::T_U8     :
         if (!JS_ValueToECMAUint32(cx, s, &tu))
             return false;
         *((uint8_t*)d)  = uint8_t(tu);
         break;
     case nsXPTType::T_U16    :
         if (!JS_ValueToECMAUint32(cx, s, &tu))
             return false;
         *((uint16_t*)d)  = uint16_t(tu);
         break;
     case nsXPTType::T_U32    :
         if (!JS_ValueToECMAUint32(cx, s, (uint32_t*)d))
             return false;
         break;
     case nsXPTType::T_U64    :
-        if (JSVAL_IS_INT(s)) {
-            if (!JS_ValueToECMAUint32(cx, s, &tu))
-                return false;
-            *((uint64_t*)d) = tu;
-        } else {
-            if (!JS_ValueToNumber(cx, s, &td))
-                return false;
-            *((uint64_t*)d) = uint64_t(td);
-        }
-        break;
+        return ValueToUint64(cx, s, (uint64_t*)d);
+
     case nsXPTType::T_FLOAT  :
         if (!JS_ValueToNumber(cx, s, &td))
             return false;
         *((float*)d) = (float) td;
         break;
     case nsXPTType::T_DOUBLE :
         if (!JS_ValueToNumber(cx, s, (double*)d))
             return false;