mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 952650 (part 11) - Remove JSVAL_TO_INT. r=njn.
--HG-- extra : rebase_source : 41923458bbf8fd957c9a57685df4969f1190bd9f
This commit is contained in:
parent
75b31bf370
commit
3a5329b969
@ -70,7 +70,7 @@ CoerceDouble(JS::Value v, double* d)
|
||||
if (v.isDouble()) {
|
||||
*d = v.toDouble();
|
||||
} else if (v.isInt32()) {
|
||||
*d = double(JSVAL_TO_INT(v));
|
||||
*d = double(v.toInt32());
|
||||
} else if (v.isUndefined()) {
|
||||
*d = 0.0;
|
||||
} else {
|
||||
|
@ -3553,7 +3553,7 @@ nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t slen = JSVAL_TO_INT(lenval);
|
||||
int32_t slen = lenval.toInt32();
|
||||
if (slen < 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3585,7 +3585,7 @@ nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
bool ok = ::JS_GetProperty(cx, obj, "length", &len_val);
|
||||
|
||||
if (ok && len_val.isInt32()) {
|
||||
int32_t length = JSVAL_TO_INT(len_val);
|
||||
int32_t length = len_val.toInt32();
|
||||
|
||||
for (int32_t i = 0; ok && i < length; ++i) {
|
||||
ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nullptr, nullptr,
|
||||
|
@ -389,7 +389,7 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
|
||||
} else if (val.isBoolean()) {
|
||||
BOOLEAN_TO_NPVARIANT(val.toBoolean(), *variant);
|
||||
} else if (val.isInt32()) {
|
||||
INT32_TO_NPVARIANT(JSVAL_TO_INT(val), *variant);
|
||||
INT32_TO_NPVARIANT(val.toInt32(), *variant);
|
||||
} else if (val.isDouble()) {
|
||||
double d = val.toDouble();
|
||||
int i;
|
||||
@ -903,7 +903,7 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
|
||||
} else {
|
||||
NS_ASSERTION(v.isInt32(),
|
||||
"The element in ida must be either string or int!\n");
|
||||
id = IntToNPIdentifier(JSVAL_TO_INT(v));
|
||||
id = IntToNPIdentifier(v.toInt32());
|
||||
}
|
||||
|
||||
(*idarray)[i] = id;
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
do_GetService(NS_AUDIOMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(aResult.isInt32(), NS_OK);
|
||||
|
||||
int32_t volIndex = JSVAL_TO_INT(aResult);
|
||||
int32_t volIndex = aResult.toInt32();
|
||||
if (aName.EqualsLiteral("audio.volume.content")) {
|
||||
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content,
|
||||
volIndex);
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
|
||||
{
|
||||
if (aResult.isInt32()) {
|
||||
int32_t mode = JSVAL_TO_INT(aResult);
|
||||
int32_t mode = aResult.toInt32();
|
||||
SetAutoMounterMode(mode);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -225,7 +225,7 @@ JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id,
|
||||
SkDisplayTypes displayableType = displayable->getType();
|
||||
int members;
|
||||
const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members);
|
||||
int idIndex = JSVAL_TO_INT(id);
|
||||
int idIndex = id.toInt32();
|
||||
SkASSERT(idIndex >= 0 && idIndex < members);
|
||||
info = &info[idIndex];
|
||||
SkDisplayTypes infoType = (SkDisplayTypes) info->fType;
|
||||
@ -297,7 +297,7 @@ JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsva
|
||||
SkDisplayTypes displayableType = displayable->getType();
|
||||
int members;
|
||||
const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members);
|
||||
int idIndex = JSVAL_TO_INT(id);
|
||||
int idIndex = id.toInt32();
|
||||
SkASSERT(idIndex >= 0 && idIndex < members);
|
||||
info = &info[idIndex];
|
||||
SkDisplayTypes infoType = info->getType();
|
||||
@ -312,11 +312,11 @@ JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsva
|
||||
break;
|
||||
case SkType_Color:
|
||||
case SkType_S32:
|
||||
s32 = JSVAL_TO_INT(value);
|
||||
s32 = value.toInt32();
|
||||
break;
|
||||
case SkType_Scalar:
|
||||
if (value.isInt32())
|
||||
scalar = SkIntToScalar(JSVAL_TO_INT(value));
|
||||
scalar = SkIntToScalar(value.toInt32());
|
||||
else {
|
||||
SkASSERT(value.isDouble());
|
||||
scalar = (float) *(double*) value.toDouble();
|
||||
|
@ -156,7 +156,7 @@ jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval)
|
||||
jsval val = jsdval->val;
|
||||
if(!val.isInt32())
|
||||
return 0;
|
||||
return JSVAL_TO_INT(val);
|
||||
return val.toInt32();
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -1821,13 +1821,6 @@ static_assert(sizeof(jsval_layout) == sizeof(JS::Value),
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
static inline int32_t
|
||||
JSVAL_TO_INT(jsval v)
|
||||
{
|
||||
MOZ_ASSERT(v.isInt32());
|
||||
return JSVAL_TO_INT32_IMPL(JSVAL_TO_IMPL(v));
|
||||
}
|
||||
|
||||
static inline JS_VALUE_CONSTEXPR jsval
|
||||
INT_TO_JSVAL(int32_t i)
|
||||
{
|
||||
|
@ -821,7 +821,7 @@ GetABICode(JSObject* obj)
|
||||
return INVALID_ABI;
|
||||
|
||||
jsval result = JS_GetReservedSlot(obj, SLOT_ABICODE);
|
||||
return ABICode(JSVAL_TO_INT(result));
|
||||
return ABICode(result.toInt32());
|
||||
}
|
||||
|
||||
static const JSErrorFormatString ErrorFormatString[CTYPESERR_LIMIT] = {
|
||||
@ -1580,7 +1580,7 @@ jsvalToBool(JSContext* cx, jsval val, bool* result)
|
||||
return true;
|
||||
}
|
||||
if (val.isInt32()) {
|
||||
int32_t i = JSVAL_TO_INT(val);
|
||||
int32_t i = val.toInt32();
|
||||
*result = i != 0;
|
||||
return i == 0 || i == 1;
|
||||
}
|
||||
@ -1606,7 +1606,7 @@ jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
|
||||
if (val.isInt32()) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
// sign.
|
||||
int32_t i = JSVAL_TO_INT(val);
|
||||
int32_t i = val.toInt32();
|
||||
return ConvertExact(i, result);
|
||||
}
|
||||
if (val.isDouble()) {
|
||||
@ -1697,7 +1697,7 @@ jsvalToFloat(JSContext *cx, jsval val, FloatType* result)
|
||||
// argument be exactly representable as a 32-bit float is
|
||||
// unrealistic: it would allow 1/2 to pass but not 1/3.
|
||||
if (val.isInt32()) {
|
||||
*result = FloatType(JSVAL_TO_INT(val));
|
||||
*result = FloatType(val.toInt32());
|
||||
return true;
|
||||
}
|
||||
if (val.isDouble()) {
|
||||
@ -1811,7 +1811,7 @@ jsvalToBigInteger(JSContext* cx,
|
||||
if (val.isInt32()) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
// sign.
|
||||
int32_t i = JSVAL_TO_INT(val);
|
||||
int32_t i = val.toInt32();
|
||||
return ConvertExact(i, result);
|
||||
}
|
||||
if (val.isDouble()) {
|
||||
@ -1974,7 +1974,7 @@ jsvalToPtrExplicit(JSContext* cx, jsval val, uintptr_t* result)
|
||||
if (val.isInt32()) {
|
||||
// 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);
|
||||
int32_t i = val.toInt32();
|
||||
*result = i < 0 ? uintptr_t(intptr_t(i)) : uintptr_t(i);
|
||||
return true;
|
||||
}
|
||||
@ -3296,7 +3296,7 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj)
|
||||
return;
|
||||
|
||||
// The contents of our slots depends on what kind of type we are.
|
||||
switch (TypeCode(JSVAL_TO_INT(slot))) {
|
||||
switch (TypeCode(slot.toInt32())) {
|
||||
case TYPE_function: {
|
||||
// Free the FunctionInfo.
|
||||
slot = JS_GetReservedSlot(obj, SLOT_FNINFO);
|
||||
@ -3341,7 +3341,7 @@ CType::Trace(JSTracer* trc, JSObject* obj)
|
||||
return;
|
||||
|
||||
// The contents of our slots depends on what kind of type we are.
|
||||
switch (TypeCode(JSVAL_TO_INT(slot))) {
|
||||
switch (TypeCode(slot.toInt32())) {
|
||||
case TYPE_struct: {
|
||||
slot = obj->getReservedSlot(SLOT_FIELDINFO);
|
||||
if (slot.isUndefined())
|
||||
@ -3400,7 +3400,7 @@ CType::GetTypeCode(JSObject* typeObj)
|
||||
JS_ASSERT(IsCType(typeObj));
|
||||
|
||||
jsval result = JS_GetReservedSlot(typeObj, SLOT_TYPECODE);
|
||||
return TypeCode(JSVAL_TO_INT(result));
|
||||
return TypeCode(result.toInt32());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3482,7 +3482,7 @@ CType::GetSafeSize(JSObject* obj, size_t* result)
|
||||
// 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 (size.isInt32()) {
|
||||
*result = JSVAL_TO_INT(size);
|
||||
*result = size.toInt32();
|
||||
return true;
|
||||
}
|
||||
if (size.isDouble()) {
|
||||
@ -3507,7 +3507,7 @@ CType::GetSize(JSObject* obj)
|
||||
// (for arrays of undefined length), and must always fit in a size_t.
|
||||
// For callers who know it can never be JSVAL_VOID, return a size_t directly.
|
||||
if (size.isInt32())
|
||||
return JSVAL_TO_INT(size);
|
||||
return size.toInt32();
|
||||
return Convert<size_t>(size.toDouble());
|
||||
}
|
||||
|
||||
@ -3530,7 +3530,7 @@ CType::GetAlignment(JSObject* obj)
|
||||
JS_ASSERT(CType::IsCType(obj));
|
||||
|
||||
jsval slot = JS_GetReservedSlot(obj, SLOT_ALIGN);
|
||||
return static_cast<size_t>(JSVAL_TO_INT(slot));
|
||||
return static_cast<size_t>(slot.toInt32());
|
||||
}
|
||||
|
||||
ffi_type*
|
||||
|
@ -26,7 +26,7 @@ BEGIN_TEST(test_BindCallable)
|
||||
|
||||
CHECK(retval.isInt32());
|
||||
|
||||
CHECK(JSVAL_TO_INT(retval) == 1717);
|
||||
CHECK(retval.toInt32() == 1717);
|
||||
return true;
|
||||
}
|
||||
END_TEST(test_BindCallable)
|
||||
|
@ -98,7 +98,7 @@ BEGIN_TEST(testChromeBuffer)
|
||||
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, JS::NullPtr(), fun, v, &rval));
|
||||
CHECK(JSVAL_TO_INT(rval) == 100);
|
||||
CHECK(rval.toInt32() == 100);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -176,7 +176,7 @@ BEGIN_TEST(testChromeBuffer)
|
||||
JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, JS::NullPtr(), fun, arg, &rval));
|
||||
CHECK(JSVAL_TO_INT(rval) == 42);
|
||||
CHECK(rval.toInt32() == 42);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -75,7 +75,7 @@ BEGIN_TEST(testCustomIterator_bug612523)
|
||||
"j;", &result);
|
||||
|
||||
CHECK(result.isInt32());
|
||||
CHECK_EQUAL(JSVAL_TO_INT(result), 100);
|
||||
CHECK_EQUAL(result.toInt32(), 100);
|
||||
CHECK_EQUAL(iterCount, 101);
|
||||
|
||||
return true;
|
||||
|
@ -137,7 +137,7 @@ TestArrayFromBuffer(JSContext *cx)
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK(JS_GetElement(cx, shortArray, 0, &v2));
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK_EQUAL(long(JSVAL_TO_INT(v)), long(reinterpret_cast<Element*>(data)[0]));
|
||||
CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[0]));
|
||||
|
||||
v = INT_TO_JSVAL(40);
|
||||
JS_SetElement(cx, array, elts / 2, v);
|
||||
@ -145,7 +145,7 @@ TestArrayFromBuffer(JSContext *cx)
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK(JS_GetElement(cx, ofsArray, 0, &v2));
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK_EQUAL(long(JSVAL_TO_INT(v)), long(reinterpret_cast<Element*>(data)[elts / 2]));
|
||||
CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[elts / 2]));
|
||||
|
||||
v = INT_TO_JSVAL(41);
|
||||
JS_SetElement(cx, array, elts - 1, v);
|
||||
@ -153,7 +153,7 @@ TestArrayFromBuffer(JSContext *cx)
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK(JS_GetElement(cx, ofsArray, elts / 2 - 1, &v2));
|
||||
CHECK_SAME(v, v2);
|
||||
CHECK_EQUAL(long(JSVAL_TO_INT(v)), long(reinterpret_cast<Element*>(data)[elts - 1]));
|
||||
CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[elts - 1]));
|
||||
|
||||
JS::RootedObject copy(cx, CreateFromArray(cx, array));
|
||||
CHECK(JS_GetElement(cx, array, 0, &v));
|
||||
|
@ -259,7 +259,7 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
{
|
||||
uint32_t idx = JSVAL_TO_INT(*statep);
|
||||
uint32_t idx = statep->toInt32();
|
||||
nsIInterfaceInfo* interface = mInterfaces.SafeElementAt(idx);
|
||||
*statep = UINT_TO_JSVAL(idx + 1);
|
||||
|
||||
@ -507,7 +507,7 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
{
|
||||
uint32_t idx = JSVAL_TO_INT(*statep);
|
||||
uint32_t idx = statep->toInt32();
|
||||
nsIInterfaceInfo* interface = mInterfaces.SafeElementAt(idx);
|
||||
*statep = UINT_TO_JSVAL(idx + 1);
|
||||
if (interface) {
|
||||
|
@ -1223,11 +1223,11 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
bool isResult = false;
|
||||
|
||||
if (s.isInt32()) {
|
||||
rv = (nsresult) JSVAL_TO_INT(s);
|
||||
rv = (nsresult) s.toInt32();
|
||||
if (NS_FAILED(rv))
|
||||
isResult = true;
|
||||
else
|
||||
number = (double) JSVAL_TO_INT(s);
|
||||
number = (double) s.toInt32();
|
||||
} else {
|
||||
number = s.toDouble();
|
||||
if (number > 0.0 &&
|
||||
|
@ -249,7 +249,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
||||
// 5.2.9(10) of C++11, so add an intermediate cast.
|
||||
rv = (nsresult)(uint32_t)(jsexception.toDouble());
|
||||
else
|
||||
rv = (nsresult)(JSVAL_TO_INT(jsexception));
|
||||
rv = (nsresult)(jsexception.toInt32());
|
||||
|
||||
if (rv == NS_NOINTERFACE)
|
||||
JS_ClearPendingException(cx);
|
||||
|
@ -945,7 +945,7 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
|
||||
"passed in non-integer for key size");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
keySize = JSVAL_TO_INT(argv[0]);
|
||||
keySize = argv[0].toInt32();
|
||||
if (!argv[1].isNull()) {
|
||||
JS::Rooted<JS::Value> v(cx, argv[1]);
|
||||
jsString = JS::ToString(cx, v);
|
||||
|
@ -111,7 +111,7 @@ StatementParams::NewEnumerate(nsIXPConnectWrappedNative *aWrapper,
|
||||
NS_ASSERTION(*_statep != JSVAL_NULL, "Internal state is null!");
|
||||
|
||||
// Make sure we are in range first.
|
||||
uint32_t index = static_cast<uint32_t>(JSVAL_TO_INT(*_statep));
|
||||
uint32_t index = static_cast<uint32_t>(_statep->toInt32());
|
||||
if (index >= mParamCount) {
|
||||
*_statep = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user