Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie

This commit is contained in:
Jan de Mooij 2015-06-30 21:10:04 -07:00
parent 303b210317
commit 2c2b7af49c
20 changed files with 96 additions and 104 deletions

View File

@ -972,7 +972,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
p->GetData(&data);
*aArgv = INT_TO_JSVAL(data);
aArgv->setInt32(data);
break;
}
@ -984,7 +984,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
p->GetData(&data);
*aArgv = INT_TO_JSVAL(data);
aArgv->setInt32(data);
break;
}
@ -996,7 +996,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
p->GetData(&data);
*aArgv = INT_TO_JSVAL(data);
aArgv->setInt32(data);
break;
}
@ -1023,7 +1023,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
p->GetData(&data);
*aArgv = INT_TO_JSVAL(data);
aArgv->setInt32(data);
break;
}
@ -1035,7 +1035,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
p->GetData(&data);
*aArgv = INT_TO_JSVAL(data);
aArgv->setInt32(data);
break;
}

View File

@ -5570,7 +5570,7 @@ def convertConstIDLValueToJSVal(value):
tag = value.type.tag()
if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16,
IDLType.Tags.uint16, IDLType.Tags.int32]:
return "INT_TO_JSVAL(%s)" % (value.value)
return "JS::Int32Value(%s)" % (value.value)
if tag == IDLType.Tags.uint32:
return "UINT_TO_JSVAL(%sU)" % (value.value)
if tag in [IDLType.Tags.int64, IDLType.Tags.uint64]:

View File

@ -159,7 +159,7 @@ SetJsObject(JSContext* aContext,
break;
}
case BluetoothValue::Tuint32_t:
val = INT_TO_JSVAL(v.get_uint32_t());
val.setInt32(v.get_uint32_t());
break;
case BluetoothValue::Tbool:
val.setBoolean(v.get_bool());

View File

@ -357,7 +357,7 @@ void CleanupOSFileConstants()
* Produces a |ConstantSpec|.
*/
#define INT_CONSTANT(name) \
{ #name, INT_TO_JSVAL(name) }
{ #name, JS::Int32Value(name) }
/**
* Define a simple read-only property holding an unsigned integer.
@ -576,94 +576,94 @@ static const dom::ConstantSpec gLibcProperties[] =
#if defined(XP_UNIX)
// The size of |mode_t|.
{ "OSFILE_SIZEOF_MODE_T", INT_TO_JSVAL(sizeof (mode_t)) },
{ "OSFILE_SIZEOF_MODE_T", JS::Int32Value(sizeof (mode_t)) },
// The size of |gid_t|.
{ "OSFILE_SIZEOF_GID_T", INT_TO_JSVAL(sizeof (gid_t)) },
{ "OSFILE_SIZEOF_GID_T", JS::Int32Value(sizeof (gid_t)) },
// The size of |uid_t|.
{ "OSFILE_SIZEOF_UID_T", INT_TO_JSVAL(sizeof (uid_t)) },
{ "OSFILE_SIZEOF_UID_T", JS::Int32Value(sizeof (uid_t)) },
// The size of |time_t|.
{ "OSFILE_SIZEOF_TIME_T", INT_TO_JSVAL(sizeof (time_t)) },
{ "OSFILE_SIZEOF_TIME_T", JS::Int32Value(sizeof (time_t)) },
// The size of |fsblkcnt_t|.
{ "OSFILE_SIZEOF_FSBLKCNT_T", INT_TO_JSVAL(sizeof (fsblkcnt_t)) },
{ "OSFILE_SIZEOF_FSBLKCNT_T", JS::Int32Value(sizeof (fsblkcnt_t)) },
#if !defined(ANDROID)
// The size of |posix_spawn_file_actions_t|.
{ "OSFILE_SIZEOF_POSIX_SPAWN_FILE_ACTIONS_T", INT_TO_JSVAL(sizeof (posix_spawn_file_actions_t)) },
{ "OSFILE_SIZEOF_POSIX_SPAWN_FILE_ACTIONS_T", JS::Int32Value(sizeof (posix_spawn_file_actions_t)) },
#endif // !defined(ANDROID)
// Defining |dirent|.
// Size
{ "OSFILE_SIZEOF_DIRENT", INT_TO_JSVAL(sizeof (dirent)) },
{ "OSFILE_SIZEOF_DIRENT", JS::Int32Value(sizeof (dirent)) },
// Defining |flock|.
#if defined(XP_UNIX)
{ "OSFILE_SIZEOF_FLOCK", INT_TO_JSVAL(sizeof (struct flock)) },
{ "OSFILE_OFFSETOF_FLOCK_L_START", INT_TO_JSVAL(offsetof (struct flock, l_start)) },
{ "OSFILE_OFFSETOF_FLOCK_L_LEN", INT_TO_JSVAL(offsetof (struct flock, l_len)) },
{ "OSFILE_OFFSETOF_FLOCK_L_PID", INT_TO_JSVAL(offsetof (struct flock, l_pid)) },
{ "OSFILE_OFFSETOF_FLOCK_L_TYPE", INT_TO_JSVAL(offsetof (struct flock, l_type)) },
{ "OSFILE_OFFSETOF_FLOCK_L_WHENCE", INT_TO_JSVAL(offsetof (struct flock, l_whence)) },
{ "OSFILE_SIZEOF_FLOCK", JS::Int32Value(sizeof (struct flock)) },
{ "OSFILE_OFFSETOF_FLOCK_L_START", JS::Int32Value(offsetof (struct flock, l_start)) },
{ "OSFILE_OFFSETOF_FLOCK_L_LEN", JS::Int32Value(offsetof (struct flock, l_len)) },
{ "OSFILE_OFFSETOF_FLOCK_L_PID", JS::Int32Value(offsetof (struct flock, l_pid)) },
{ "OSFILE_OFFSETOF_FLOCK_L_TYPE", JS::Int32Value(offsetof (struct flock, l_type)) },
{ "OSFILE_OFFSETOF_FLOCK_L_WHENCE", JS::Int32Value(offsetof (struct flock, l_whence)) },
#endif // defined(XP_UNIX)
// Offset of field |d_name|.
{ "OSFILE_OFFSETOF_DIRENT_D_NAME", INT_TO_JSVAL(offsetof (struct dirent, d_name)) },
{ "OSFILE_OFFSETOF_DIRENT_D_NAME", JS::Int32Value(offsetof (struct dirent, d_name)) },
// An upper bound to the length of field |d_name| of struct |dirent|.
// (may not be exact, depending on padding).
{ "OSFILE_SIZEOF_DIRENT_D_NAME", INT_TO_JSVAL(sizeof (struct dirent) - offsetof (struct dirent, d_name)) },
{ "OSFILE_SIZEOF_DIRENT_D_NAME", JS::Int32Value(sizeof (struct dirent) - offsetof (struct dirent, d_name)) },
// Defining |timeval|.
{ "OSFILE_SIZEOF_TIMEVAL", INT_TO_JSVAL(sizeof (struct timeval)) },
{ "OSFILE_OFFSETOF_TIMEVAL_TV_SEC", INT_TO_JSVAL(offsetof (struct timeval, tv_sec)) },
{ "OSFILE_OFFSETOF_TIMEVAL_TV_USEC", INT_TO_JSVAL(offsetof (struct timeval, tv_usec)) },
{ "OSFILE_SIZEOF_TIMEVAL", JS::Int32Value(sizeof (struct timeval)) },
{ "OSFILE_OFFSETOF_TIMEVAL_TV_SEC", JS::Int32Value(offsetof (struct timeval, tv_sec)) },
{ "OSFILE_OFFSETOF_TIMEVAL_TV_USEC", JS::Int32Value(offsetof (struct timeval, tv_usec)) },
#if defined(DT_UNKNOWN)
// Position of field |d_type| in |dirent|
// Not strictly posix, but seems defined on all platforms
// except mingw32.
{ "OSFILE_OFFSETOF_DIRENT_D_TYPE", INT_TO_JSVAL(offsetof (struct dirent, d_type)) },
{ "OSFILE_OFFSETOF_DIRENT_D_TYPE", JS::Int32Value(offsetof (struct dirent, d_type)) },
#endif // defined(DT_UNKNOWN)
// Under MacOS X and BSDs, |dirfd| is a macro rather than a
// function, so we need a little help to get it to work
#if defined(dirfd)
{ "OSFILE_SIZEOF_DIR", INT_TO_JSVAL(sizeof (DIR)) },
{ "OSFILE_SIZEOF_DIR", JS::Int32Value(sizeof (DIR)) },
{ "OSFILE_OFFSETOF_DIR_DD_FD", INT_TO_JSVAL(offsetof (DIR, __dd_fd)) },
{ "OSFILE_OFFSETOF_DIR_DD_FD", JS::Int32Value(offsetof (DIR, __dd_fd)) },
#endif
// Defining |stat|
{ "OSFILE_SIZEOF_STAT", INT_TO_JSVAL(sizeof (struct stat)) },
{ "OSFILE_SIZEOF_STAT", JS::Int32Value(sizeof (struct stat)) },
{ "OSFILE_OFFSETOF_STAT_ST_MODE", INT_TO_JSVAL(offsetof (struct stat, st_mode)) },
{ "OSFILE_OFFSETOF_STAT_ST_UID", INT_TO_JSVAL(offsetof (struct stat, st_uid)) },
{ "OSFILE_OFFSETOF_STAT_ST_GID", INT_TO_JSVAL(offsetof (struct stat, st_gid)) },
{ "OSFILE_OFFSETOF_STAT_ST_SIZE", INT_TO_JSVAL(offsetof (struct stat, st_size)) },
{ "OSFILE_OFFSETOF_STAT_ST_MODE", JS::Int32Value(offsetof (struct stat, st_mode)) },
{ "OSFILE_OFFSETOF_STAT_ST_UID", JS::Int32Value(offsetof (struct stat, st_uid)) },
{ "OSFILE_OFFSETOF_STAT_ST_GID", JS::Int32Value(offsetof (struct stat, st_gid)) },
{ "OSFILE_OFFSETOF_STAT_ST_SIZE", JS::Int32Value(offsetof (struct stat, st_size)) },
#if defined(HAVE_ST_ATIMESPEC)
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", INT_TO_JSVAL(offsetof (struct stat, st_atimespec)) },
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", INT_TO_JSVAL(offsetof (struct stat, st_mtimespec)) },
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", INT_TO_JSVAL(offsetof (struct stat, st_ctimespec)) },
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", JS::Int32Value(offsetof (struct stat, st_atimespec)) },
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", JS::Int32Value(offsetof (struct stat, st_mtimespec)) },
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", JS::Int32Value(offsetof (struct stat, st_ctimespec)) },
#else
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", INT_TO_JSVAL(offsetof (struct stat, st_atime)) },
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", INT_TO_JSVAL(offsetof (struct stat, st_mtime)) },
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", INT_TO_JSVAL(offsetof (struct stat, st_ctime)) },
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", JS::Int32Value(offsetof (struct stat, st_atime)) },
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", JS::Int32Value(offsetof (struct stat, st_mtime)) },
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", JS::Int32Value(offsetof (struct stat, st_ctime)) },
#endif // defined(HAVE_ST_ATIME)
// Several OSes have a birthtime field. For the moment, supporting only Darwin.
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
{ "OSFILE_OFFSETOF_STAT_ST_BIRTHTIME", INT_TO_JSVAL(offsetof (struct stat, st_birthtime)) },
{ "OSFILE_OFFSETOF_STAT_ST_BIRTHTIME", JS::Int32Value(offsetof (struct stat, st_birthtime)) },
#endif // defined(_DARWIN_FEATURE_64_BIT_INODE)
// Defining |statvfs|
{ "OSFILE_SIZEOF_STATVFS", INT_TO_JSVAL(sizeof (struct statvfs)) },
{ "OSFILE_SIZEOF_STATVFS", JS::Int32Value(sizeof (struct statvfs)) },
{ "OSFILE_OFFSETOF_STATVFS_F_BSIZE", INT_TO_JSVAL(offsetof (struct statvfs, f_bsize)) },
{ "OSFILE_OFFSETOF_STATVFS_F_BAVAIL", INT_TO_JSVAL(offsetof (struct statvfs, f_bavail)) },
{ "OSFILE_OFFSETOF_STATVFS_F_BSIZE", JS::Int32Value(offsetof (struct statvfs, f_bsize)) },
{ "OSFILE_OFFSETOF_STATVFS_F_BAVAIL", JS::Int32Value(offsetof (struct statvfs, f_bavail)) },
#endif // defined(XP_UNIX)
@ -678,7 +678,7 @@ static const dom::ConstantSpec gLibcProperties[] =
// whenever macro _DARWIN_FEATURE_64_BIT_INODE is set. We export
// this value to be able to do so from JavaScript.
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
{ "_DARWIN_FEATURE_64_BIT_INODE", INT_TO_JSVAL(1) },
{ "_DARWIN_FEATURE_64_BIT_INODE", JS::Int32Value(1) },
#endif // defined(_DARWIN_FEATURE_64_BIT_INODE)
// Similar feature for Linux
@ -738,7 +738,7 @@ static const dom::ConstantSpec gWinProperties[] =
INT_CONSTANT(FILE_FLAG_BACKUP_SEMANTICS),
// CreateFile error constant
{ "INVALID_HANDLE_VALUE", INT_TO_JSVAL(INT_PTR(INVALID_HANDLE_VALUE)) },
{ "INVALID_HANDLE_VALUE", JS::Int32Value(INT_PTR(INVALID_HANDLE_VALUE)) },
// CreateFile flags
@ -922,9 +922,9 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
#endif
#if defined(HAVE_64BIT_BUILD)
JS::Rooted<JS::Value> valBits(cx, INT_TO_JSVAL(64));
JS::Rooted<JS::Value> valBits(cx, JS::Int32Value(64));
#else
JS::Rooted<JS::Value> valBits(cx, INT_TO_JSVAL(32));
JS::Rooted<JS::Value> valBits(cx, JS::Int32Value(32));
#endif //defined (HAVE_64BIT_BUILD)
if (!JS_SetProperty(cx, objSys, "bits", valBits)) {
return false;

View File

@ -1392,12 +1392,10 @@ UndefinedValue()
#endif
}
static inline Value
static inline JS_VALUE_CONSTEXPR Value
Int32Value(int32_t i32)
{
Value v;
v.setInt32(i32);
return v;
return IMPL_TO_JSVAL(INT32_TO_JSVAL_IMPL(i32));
}
static inline Value
@ -1934,12 +1932,6 @@ static_assert(sizeof(jsval_layout) == sizeof(JS::Value),
/************************************************************************/
static inline JS_VALUE_CONSTEXPR jsval
INT_TO_JSVAL(int32_t i)
{
return IMPL_TO_JSVAL(INT32_TO_JSVAL_IMPL(i));
}
static inline JS_VALUE_CONSTEXPR jsval
DOUBLE_TO_JSVAL(double d)
{
@ -1967,7 +1959,7 @@ static inline JS_VALUE_CONSTEXPR jsval
UINT_TO_JSVAL(uint32_t i)
{
return i <= JSVAL_INT_MAX
? INT_TO_JSVAL((int32_t)i)
? JS::Int32Value(int32_t(i))
: DOUBLE_TO_JSVAL((double)i);
}

View File

@ -1590,7 +1590,7 @@ DefineABIConstant(JSContext* cx,
RootedObject obj(cx, JS_NewObjectWithGivenProto(cx, &sCABIClass, prototype));
if (!obj)
return false;
JS_SetReservedSlot(obj, SLOT_ABICODE, INT_TO_JSVAL(code));
JS_SetReservedSlot(obj, SLOT_ABICODE, Int32Value(code));
if (!JS_FreezeObject(cx, obj))
return false;
@ -1866,8 +1866,8 @@ InitTypeClasses(JSContext* cx, HandleObject ctypesObj)
#define DEFINE_TYPE(name, type, ffiType) \
RootedObject typeObj_##name(cx, \
CType::DefineBuiltin(cx, ctypesObj, #name, CTypeProto, CDataProto, #name, \
TYPE_##name, INT_TO_JSVAL(sizeof(type)), \
INT_TO_JSVAL(ffiType.alignment), &ffiType)); \
TYPE_##name, Int32Value(sizeof(type)), \
Int32Value(ffiType.alignment), &ffiType)); \
if (!typeObj_##name) \
return false;
CTYPES_FOR_EACH_TYPE(DEFINE_TYPE)
@ -3926,7 +3926,7 @@ CType::Create(JSContext* cx,
return nullptr;
// Set up the reserved slots.
JS_SetReservedSlot(typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type));
JS_SetReservedSlot(typeObj, SLOT_TYPECODE, Int32Value(type));
if (ffiType)
JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PrivateValue(ffiType));
if (name)
@ -4622,8 +4622,8 @@ PointerType::CreateInternal(JSContext* cx, HandleObject baseType)
// Create a new CType object with the common properties and slots.
JSObject* typeObj = CType::Create(cx, typeProto, dataProto, TYPE_pointer,
nullptr, INT_TO_JSVAL(sizeof(void*)),
INT_TO_JSVAL(ffi_type_pointer.alignment),
nullptr, Int32Value(sizeof(void*)),
Int32Value(ffi_type_pointer.alignment),
&ffi_type_pointer);
if (!typeObj)
return nullptr;
@ -4949,7 +4949,7 @@ ArrayType::CreateInternal(JSContext* cx,
// Create a new CType object with the common properties and slots.
JSObject* typeObj = CType::Create(cx, typeProto, dataProto, TYPE_array, nullptr,
sizeVal, INT_TO_JSVAL(align), nullptr);
sizeVal, Int32Value(align), nullptr);
if (!typeObj)
return nullptr;
@ -5638,7 +5638,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PrivateValue(fields.release()));
JS_SetReservedSlot(typeObj, SLOT_SIZE, sizeVal);
JS_SetReservedSlot(typeObj, SLOT_ALIGN, INT_TO_JSVAL(structAlign));
JS_SetReservedSlot(typeObj, SLOT_ALIGN, Int32Value(structAlign));
//if (!JS_FreezeObject(cx, prototype)0 // XXX fixme - see bug 541212!
// return false;
JS_SetReservedSlot(typeObj, SLOT_PROTO, ObjectValue(*prototype));
@ -6654,9 +6654,9 @@ FunctionType::Call(JSContext* cx,
if (!objCTypes)
return false;
JS_SetReservedSlot(objCTypes, SLOT_ERRNO, INT_TO_JSVAL(errnoStatus));
JS_SetReservedSlot(objCTypes, SLOT_ERRNO, Int32Value(errnoStatus));
#if defined(XP_WIN)
JS_SetReservedSlot(objCTypes, SLOT_LASTERROR, INT_TO_JSVAL(lastErrorStatus));
JS_SetReservedSlot(objCTypes, SLOT_LASTERROR, Int32Value(lastErrorStatus));
#endif // defined(XP_WIN)
// Small integer types get returned as a word-sized ffi_arg. Coerce it back
@ -7965,9 +7965,9 @@ CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, jsval* vp)
CDataFinalizer::CallFinalizer(p, &errnoStatus, nullptr);
#endif // defined(XP_WIN)
JS_SetReservedSlot(objCTypes, SLOT_ERRNO, INT_TO_JSVAL(errnoStatus));
JS_SetReservedSlot(objCTypes, SLOT_ERRNO, Int32Value(errnoStatus));
#if defined(XP_WIN)
JS_SetReservedSlot(objCTypes, SLOT_LASTERROR, INT_TO_JSVAL(lastErrorStatus));
JS_SetReservedSlot(objCTypes, SLOT_LASTERROR, Int32Value(lastErrorStatus));
#endif // defined(XP_WIN)
if (ConvertToJS(cx, resultType, nullptr, p->rvalue, false, true, &result)) {

View File

@ -92,10 +92,10 @@ ExhaustiveTest(const char funcode[])
ClearElements(elems);
CHECK(argsobj->maybeGetElements(i, j, elems.begin()));
for (size_t k = 0; k < j; k++)
CHECK_SAME(elems[k], INT_TO_JSVAL(i + k));
CHECK(elems[k].isInt32(i + k));
for (size_t k = j; k < MAX_ELEMS - 1; k++)
CHECK(elems[k].isNull());
CHECK_SAME(elems[MAX_ELEMS - 1], INT_TO_JSVAL(42));
CHECK(elems[MAX_ELEMS - 1].isInt32(42));
}
}

View File

@ -39,9 +39,9 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
CHECK(JS_IsArrayBufferObject(obj));
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), size);
JS_GetProperty(cx, obj, "byteLength", &v);
CHECK_SAME(v, INT_TO_JSVAL(size));
CHECK(v.isInt32(size));
JS_GetProperty(cx, view, "byteLength", &v);
CHECK_SAME(v, INT_TO_JSVAL(size));
CHECK(v.isInt32(size));
// Modifying the underlying data should update the value returned through the view
{
@ -51,7 +51,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
*reinterpret_cast<uint32_t*>(data) = MAGIC_VALUE_2;
}
CHECK(JS_GetElement(cx, view, 0, &v));
CHECK_SAME(v, INT_TO_JSVAL(MAGIC_VALUE_2));
CHECK(v.isInt32(MAGIC_VALUE_2));
// Steal the contents
void* contents = JS_StealArrayBufferContents(cx, obj);
@ -60,13 +60,13 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
// Check that the original ArrayBuffer is neutered
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0u);
CHECK(JS_GetProperty(cx, obj, "byteLength", &v));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(v.isInt32(0));
CHECK(JS_GetProperty(cx, view, "byteLength", &v));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(v.isInt32(0));
CHECK(JS_GetProperty(cx, view, "byteOffset", &v));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(v.isInt32(0));
CHECK(JS_GetProperty(cx, view, "length", &v));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(v.isInt32(0));
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0u);
v.setUndefined();
JS_GetElement(cx, obj, 0, &v);
@ -91,7 +91,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
CHECK_EQUAL(*reinterpret_cast<uint32_t*>(data), MAGIC_VALUE_2);
}
CHECK(JS_GetElement(cx, dstview, 0, &v));
CHECK_SAME(v, INT_TO_JSVAL(MAGIC_VALUE_2));
CHECK(v.isInt32(MAGIC_VALUE_2));
}
return true;

View File

@ -62,8 +62,8 @@ BEGIN_TEST(testClassGetter_isCalled)
JS::RootedValue rval(cx);
CHECK(JS_CallFunctionName(cx, global, "check", JS::HandleValueArray::empty(),
&rval));
CHECK_SAME(INT_TO_JSVAL(called_test_fn), INT_TO_JSVAL(i));
CHECK_SAME(INT_TO_JSVAL(called_test_prop_get), INT_TO_JSVAL(4 * i));
CHECK(called_test_fn == i);
CHECK(called_test_prop_get == 4 * i);
}
return true;
}

View File

@ -57,7 +57,7 @@ bool testIndirectEval(JS::HandleObject scope, const char* code)
JS::RootedValue hitsv(cx);
EVAL("hits", &hitsv);
CHECK_SAME(hitsv, INT_TO_JSVAL(1));
CHECK(hitsv.isInt32(1));
return true;
}
END_TEST(testDebugger_newScriptHook)

View File

@ -54,7 +54,7 @@ struct LooseEqualityData
qNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::quiet_NaN());
sNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::signaling_NaN());
d42 = DOUBLE_TO_JSVAL(42.0);
i42 = INT_TO_JSVAL(42);
i42 = JS::Int32Value(42);
undef = JS::UndefinedValue();
null = JS::NullValue();
obj = JS::ObjectOrNullValue(JS::CurrentGlobalOrNull(cx));

View File

@ -90,7 +90,7 @@ BEGIN_TEST(testNewObject_1)
CHECK(JS_GetArrayLength(cx, obj, &len));
CHECK_EQUAL(len, N);
CHECK(JS_GetElement(cx, obj, N - 1, &v));
CHECK_SAME(v, INT_TO_JSVAL(N - 1));
CHECK(v.isInt32(N - 1));
// With JSClass.construct.
static const JSClass cls = {

View File

@ -57,7 +57,7 @@ BEGIN_TEST(testOps_bug559006)
JS::RootedValue rval(cx);
CHECK(JS_CallFunctionName(cx, global, "main", JS::HandleValueArray::empty(),
&rval));
CHECK_SAME(rval, INT_TO_JSVAL(123));
CHECK(rval.isInt32(123));
}
return true;
}

View File

@ -48,13 +48,13 @@ BEGIN_TEST(testParseJSON_success)
expected = JS::NullValue();
CHECK(TryParse(cx, "null", expected));
expected = INT_TO_JSVAL(0);
expected.setInt32(0);
CHECK(TryParse(cx, "0", expected));
expected = INT_TO_JSVAL(1);
expected.setInt32(1);
CHECK(TryParse(cx, "1", expected));
expected = INT_TO_JSVAL(-1);
expected.setInt32(-1);
CHECK(TryParse(cx, "-1", expected));
expected = DOUBLE_TO_JSVAL(1);
@ -130,7 +130,7 @@ BEGIN_TEST(testParseJSON_success)
obj = &v.toObject();
CHECK(!JS_IsArrayObject(cx, obj));
CHECK(JS_GetProperty(cx, obj, "f", &v2));
CHECK_SAME(v2, INT_TO_JSVAL(17));
CHECK(v2.isInt32(17));
return true;
}

View File

@ -58,7 +58,7 @@ BEGIN_TEST(testSetProperty_NativeGetterStubSetter)
static bool
NativeGet(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
vp.set(INT_TO_JSVAL(17));
vp.setInt32(17);
return true;
}
END_TEST(testSetProperty_NativeGetterStubSetter)

View File

@ -83,7 +83,7 @@ TestPlainTypedArray(JSContext* cx)
}
RootedValue v(cx);
CHECK(JS_GetElement(cx, array, 0, &v));
CHECK_SAME(v, INT_TO_JSVAL(13));
CHECK_SAME(v, Int32Value(13));
return true;
}
@ -135,7 +135,7 @@ TestArrayFromBuffer(JSContext* cx)
CHECK_EQUAL(JS_GetTypedArrayByteLength(ofsArray), nbytes / 2);
// Make sure all 3 views reflect the same buffer at the expected locations
JS::RootedValue v(cx, INT_TO_JSVAL(39));
JS::RootedValue v(cx, JS::Int32Value(39));
JS_SetElement(cx, array, 0, v);
JS::RootedValue v2(cx);
CHECK(JS_GetElement(cx, array, 0, &v2));
@ -149,7 +149,7 @@ TestArrayFromBuffer(JSContext* cx)
CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[0]));
}
v = INT_TO_JSVAL(40);
v.setInt32(40);
JS_SetElement(cx, array, elts / 2, v);
CHECK(JS_GetElement(cx, array, elts / 2, &v2));
CHECK_SAME(v, v2);
@ -162,7 +162,7 @@ TestArrayFromBuffer(JSContext* cx)
CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[elts / 2]));
}
v = INT_TO_JSVAL(41);
v.setInt32(41);
JS_SetElement(cx, array, elts - 1, v);
CHECK(JS_GetElement(cx, array, elts - 1, &v2));
CHECK_SAME(v, v2);
@ -181,7 +181,7 @@ TestArrayFromBuffer(JSContext* cx)
CHECK_SAME(v, v2);
/* The copy should not see changes in the original */
v2 = INT_TO_JSVAL(42);
v2.setInt32(42);
JS_SetElement(cx, array, 0, v2);
CHECK(JS_GetElement(cx, copy, 0, &v2));
CHECK_SAME(v2, v); /* v is still the original value from 'array' */

View File

@ -740,7 +740,7 @@ JS_NumberValue(double d)
int32_t i;
d = JS::CanonicalizeNaN(d);
if (mozilla::NumberIsInt32(d, &i))
return INT_TO_JSVAL(i);
return JS::Int32Value(i);
return DOUBLE_TO_JSVAL(d);
}

View File

@ -162,7 +162,7 @@ private:
return false;
}
rval.set(INT_TO_JSVAL(result));
rval.setInt32(result);
return true;
}

View File

@ -592,22 +592,22 @@ TreeBoxObject::GetCoordsForCellItem(JSContext* cx,
{
int32_t x, y, w, h;
GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h);
JS::Rooted<JS::Value> v(cx, INT_TO_JSVAL(x));
JS::Rooted<JS::Value> v(cx, JS::Int32Value(x));
if (!JS_SetProperty(cx, xOut, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
v = INT_TO_JSVAL(y);
v.setInt32(y);
if (!JS_SetProperty(cx, yOut, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
v = INT_TO_JSVAL(w);
v.setInt32(w);
if (!JS_SetProperty(cx, widthOut, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
v = INT_TO_JSVAL(h);
v.setInt32(h);
if (!JS_SetProperty(cx, heightOut, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;

View File

@ -1139,7 +1139,7 @@ FillRanges(JSContext *cx, JS::Handle<JSObject*> array, Histogram *h)
{
JS::Rooted<JS::Value> range(cx);
for (size_t i = 0; i < h->bucket_count(); i++) {
range = INT_TO_JSVAL(h->ranges(i));
range.setInt32(h->ranges(i));
if (!JS_DefineElement(cx, array, i, range, JSPROP_ENUMERATE))
return false;
}