Bug 733260 followup: use uint32_t for array and string lengths, r=luke

--HG--
extra : rebase_source : 1729b4b927fde0678872b9de62a7466381aa07c3
This commit is contained in:
David Mandelin 2012-03-06 15:52:55 -08:00
parent 2dc291ee58
commit 68c407c176
40 changed files with 167 additions and 167 deletions

View File

@ -602,7 +602,7 @@ nsWebSocket::Initialize(nsISupports* aOwner,
if (JSVAL_IS_OBJECT(aArgv[1]) &&
(jsobj = JSVAL_TO_OBJECT(aArgv[1])) &&
JS_IsArrayObject(aContext, jsobj)) {
unsigned len;
uint32_t len;
JS_GetArrayLength(aContext, jsobj, &len);
for (PRUint32 index = 0; index < len; ++index) {

View File

@ -122,7 +122,7 @@ JSValToMatrixElts(JSContext* cx, const jsval& val,
double* (&elts)[N], nsresult* rv)
{
JSObject* obj;
unsigned length;
uint32_t length;
if (JSVAL_IS_PRIMITIVE(val) ||
!(obj = JSVAL_TO_OBJECT(val)) ||

View File

@ -146,11 +146,11 @@ JSValToDashArray(JSContext* cx, const jsval& patternArray,
{
// The cap is pretty arbitrary. 16k should be enough for
// anybody...
static const unsigned MAX_NUM_DASHES = 1 << 14;
static const uint32_t MAX_NUM_DASHES = 1 << 14;
if (!JSVAL_IS_PRIMITIVE(patternArray)) {
JSObject* obj = JSVAL_TO_OBJECT(patternArray);
unsigned length;
uint32_t length;
if (!JS_GetArrayLength(cx, obj, &length)) {
// Not an array-like thing
return NS_ERROR_INVALID_ARG;

View File

@ -90,7 +90,7 @@ ConvertCloneReadInfosToArrayInternal(
}
if (!aReadInfos.IsEmpty()) {
if (!JS_SetArrayLength(aCx, array, unsigned(aReadInfos.Length()))) {
if (!JS_SetArrayLength(aCx, array, uint32_t(aReadInfos.Length()))) {
NS_WARNING("Failed to set array length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}

View File

@ -410,7 +410,7 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
JSObject* obj = JSVAL_TO_OBJECT(val);
unsigned length;
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -421,7 +421,7 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
keyPathArray.SetCapacity(length);
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
jsval val;
JSString* jsstr;
nsDependentJSString str;
@ -566,7 +566,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
// See if this is a JS array.
if (JS_IsArrayObject(aCx, obj)) {
unsigned length;
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -577,7 +577,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
storesToOpen.SetCapacity(length);
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
jsval val;
JSString* jsstr;
nsDependentJSString str;

View File

@ -904,7 +904,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
}
if (!keys.IsEmpty()) {
if (!JS_SetArrayLength(aCx, array, unsigned(keys.Length()))) {
if (!JS_SetArrayLength(aCx, array, uint32_t(keys.Length()))) {
NS_WARNING("Failed to set array length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}

View File

@ -618,12 +618,12 @@ IDBObjectStore::AppendIndexUpdateInfo(PRInt64 aIndexID,
if (aMultiEntry && !JSVAL_IS_PRIMITIVE(key) &&
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(key))) {
JSObject* array = JSVAL_TO_OBJECT(key);
unsigned arrayLength;
uint32_t arrayLength;
if (!JS_GetArrayLength(aCx, array, &arrayLength)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (unsigned arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
jsval arrayItem;
if (!JS_GetElement(aCx, array, arrayIndex, &arrayItem)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
@ -1700,7 +1700,7 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
JSObject* obj = JSVAL_TO_OBJECT(aKeyPath);
unsigned length;
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1711,7 +1711,7 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
keyPathArray.SetCapacity(length);
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
jsval val;
JSString* jsstr;
nsDependentJSString str;

View File

@ -170,12 +170,12 @@ Key::EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset)
aTypeOffset < (eMaxType * MaxArrayCollapse),
"Wrong typeoffset");
unsigned length;
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
jsval val;
if (!JS_GetElement(aCx, obj, index, &val)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
@ -220,7 +220,7 @@ Key::DecodeJSVal(const unsigned char*& aPos, const unsigned char* aEnd,
aTypeOffset = 0;
}
unsigned index = 0;
uint32_t index = 0;
while (aPos < aEnd && *aPos - aTypeOffset != eTerminator) {
jsval val;
nsresult rv = DecodeJSVal(aPos, aEnd, aCx, aTypeOffset, &val);

View File

@ -190,12 +190,12 @@ SmsFilter::SetNumbers(JSContext* aCx, const jsval& aNumbers)
return NS_ERROR_INVALID_ARG;
}
unsigned size;
uint32_t size;
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, &obj, &size));
nsTArray<nsString> numbers;
for (unsigned i=0; i<size; ++i) {
for (uint32_t i=0; i<size; ++i) {
jsval jsNumber;
if (!JS_GetElement(aCx, &obj, i, &jsNumber)) {
return NS_ERROR_INVALID_ARG;

View File

@ -199,12 +199,12 @@ SmsManager::Send(const jsval& aNumber, const nsAString& aMessage, jsval* aReturn
// Must be an array then.
JSObject& numbers = aNumber.toObject();
unsigned size;
uint32_t size;
JS_ALWAYS_TRUE(JS_GetArrayLength(cx, &numbers, &size));
jsval* requests = new jsval[size];
for (unsigned i=0; i<size; ++i) {
for (uint32_t i=0; i<size; ++i) {
jsval number;
if (!JS_GetElement(cx, &numbers, i, &number)) {
return NS_ERROR_INVALID_ARG;

View File

@ -1955,7 +1955,7 @@ ImplicitConvert(JSContext* cx,
JS_IsArrayObject(cx, JSVAL_TO_OBJECT(val))) {
// Convert each element of the array by calling ImplicitConvert.
JSObject* sourceArray = JSVAL_TO_OBJECT(val);
unsigned sourceLength;
uint32_t sourceLength;
if (!JS_GetArrayLength(cx, sourceArray, &sourceLength) ||
targetLength != size_t(sourceLength)) {
JS_ReportError(cx, "ArrayType length does not match source array length");
@ -1971,7 +1971,7 @@ ImplicitConvert(JSContext* cx,
return false;
}
for (unsigned i = 0; i < sourceLength; ++i) {
for (uint32_t i = 0; i < sourceLength; ++i) {
js::AutoValueRooter item(cx);
if (!JS_GetElement(cx, sourceArray, i, item.jsval_addr()))
return false;
@ -4112,7 +4112,7 @@ StructType::Create(JSContext* cx, unsigned argc, jsval* vp)
JSBool
StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj)
{
unsigned len;
uint32_t len;
ASSERT_OK(JS_GetArrayLength(cx, fieldsObj, &len));
// Get the common prototype for CData objects of this type from
@ -4150,7 +4150,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj
structSize = 0;
structAlign = 0;
for (unsigned i = 0; i < len; ++i) {
for (uint32_t i = 0; i < len; ++i) {
js::AutoValueRooter item(cx);
if (!JS_GetElement(cx, fieldsObj, i, item.jsval_addr()))
return JS_FALSE;
@ -4925,7 +4925,7 @@ FunctionType::Create(JSContext* cx, unsigned argc, jsval* vp)
}
arrayObj = JSVAL_TO_OBJECT(argv[2]);
unsigned len;
uint32_t len;
ASSERT_OK(JS_GetArrayLength(cx, arrayObj, &len));
if (!argTypes.appendN(JSVAL_VOID, len)) {
@ -4937,7 +4937,7 @@ FunctionType::Create(JSContext* cx, unsigned argc, jsval* vp)
// Pull out the argument types from the array, if any.
JS_ASSERT(!argTypes.length() || arrayObj);
js::AutoArrayRooter items(cx, argTypes.length(), argTypes.begin());
for (unsigned i = 0; i < argTypes.length(); ++i) {
for (uint32_t i = 0; i < argTypes.length(); ++i) {
if (!JS_GetElement(cx, arrayObj, i, &argTypes[i]))
return JS_FALSE;
}

View File

@ -127,7 +127,7 @@ cls_testIsAboutToBeFinalized_bug528645::createAndTestRooted()
array = JSVAL_TO_OBJECT(root.value());
JS_ASSERT(JS_IsArrayObject(cx, array));
unsigned tmp;
uint32_t tmp;
CHECK(JS_GetArrayLength(cx, array, &tmp));
CHECK(ok);

View File

@ -55,7 +55,7 @@ BEGIN_TEST(testNewObject_1)
CHECK(obj);
jsvalRoot rt(cx, OBJECT_TO_JSVAL(obj));
CHECK(JS_IsArrayObject(cx, obj));
unsigned len;
uint32_t len;
CHECK(JS_GetArrayLength(cx, obj, &len));
CHECK_EQUAL(len, 0);

View File

@ -4409,8 +4409,8 @@ JS_NewArrayObject(JSContext *cx, int length, jsval *vector)
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, JSValueArray(vector, vector ? (unsigned)length : 0));
return NewDenseCopiedArray(cx, (unsigned)length, vector);
assertSameCompartment(cx, JSValueArray(vector, vector ? (uint32_t)length : 0));
return NewDenseCopiedArray(cx, (uint32_t)length, vector);
}
JS_PUBLIC_API(JSBool)
@ -4421,7 +4421,7 @@ JS_IsArrayObject(JSContext *cx, JSObject *obj)
}
JS_PUBLIC_API(JSBool)
JS_GetArrayLength(JSContext *cx, JSObject *obj, unsigned *lengthp)
JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
@ -4430,7 +4430,7 @@ JS_GetArrayLength(JSContext *cx, JSObject *obj, unsigned *lengthp)
}
JS_PUBLIC_API(JSBool)
JS_SetArrayLength(JSContext *cx, JSObject *obj, unsigned length)
JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);

View File

@ -1896,8 +1896,8 @@ JSID_TO_INT(jsid id)
static JS_ALWAYS_INLINE JSBool
INT_FITS_IN_JSID(int32_t i)
{
return ((unsigned)(i) - (unsigned)JSID_INT_MIN <=
(unsigned)(JSID_INT_MAX - JSID_INT_MIN));
return ((uint32_t)(i) - (uint32_t)JSID_INT_MIN <=
(uint32_t)(JSID_INT_MAX - JSID_INT_MIN));
}
static JS_ALWAYS_INLINE jsid
@ -3986,10 +3986,10 @@ extern JS_PUBLIC_API(JSBool)
JS_IsArrayObject(JSContext *cx, JSObject *obj);
extern JS_PUBLIC_API(JSBool)
JS_GetArrayLength(JSContext *cx, JSObject *obj, unsigned *lengthp);
JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp);
extern JS_PUBLIC_API(JSBool)
JS_SetArrayLength(JSContext *cx, JSObject *obj, unsigned length);
JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length);
extern JS_PUBLIC_API(JSBool)
JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value,

View File

@ -148,7 +148,7 @@ using namespace js::gc;
using namespace js::types;
JSBool
js_GetLengthProperty(JSContext *cx, JSObject *obj, unsigned *lengthp)
js_GetLengthProperty(JSContext *cx, JSObject *obj, uint32_t *lengthp)
{
if (obj->isArray()) {
*lengthp = obj->getArrayLength();
@ -168,7 +168,7 @@ js_GetLengthProperty(JSContext *cx, JSObject *obj, unsigned *lengthp)
return false;
if (tvr.value().isInt32()) {
*lengthp = unsigned(tvr.value().toInt32()); /* unsigned cast does ToUint32_t */
*lengthp = uint32_t(tvr.value().toInt32()); /* uint32_t cast does ToUint32_t */
return true;
}
@ -198,7 +198,7 @@ namespace js {
*
*/
JS_FRIEND_API(bool)
StringIsArrayIndex(JSLinearString *str, unsigned *indexp)
StringIsArrayIndex(JSLinearString *str, uint32_t *indexp)
{
const jschar *s = str->chars();
uint32_t length = str->length();
@ -237,7 +237,7 @@ StringIsArrayIndex(JSLinearString *str, unsigned *indexp)
}
static JSBool
BigIndexToId(JSContext *cx, JSObject *obj, unsigned index, JSBool createAtom,
BigIndexToId(JSContext *cx, JSObject *obj, uint32_t index, JSBool createAtom,
jsid *idp)
{
@ -319,8 +319,8 @@ IndexToId(JSContext* cx, JSObject* obj, double index, JSBool* hole, jsid* idp,
return JS_TRUE;
}
if (index <= unsigned(-1)) {
if (!BigIndexToId(cx, obj, unsigned(index), createAtom, idp))
if (index <= uint32_t(-1)) {
if (!BigIndexToId(cx, obj, uint32_t(index), createAtom, idp))
return JS_FALSE;
if (hole && JSID_IS_VOID(*idp))
*hole = JS_TRUE;
@ -438,7 +438,7 @@ GetElementsSlow(JSContext *cx, JSObject *aobj, uint32_t length, Value *vp)
}
bool
GetElements(JSContext *cx, JSObject *aobj, unsigned length, Value *vp)
GetElements(JSContext *cx, JSObject *aobj, uint32_t length, Value *vp)
{
if (aobj->isDenseArray() && length <= aobj->getDenseArrayInitializedLength() &&
!js_PrototypeHasIndexedProperties(cx, aobj)) {
@ -476,9 +476,9 @@ SetArrayElement(JSContext *cx, JSObject *obj, double index, const Value &v)
/* Predicted/prefetched code should favor the remains-dense case. */
JSObject::EnsureDenseResult result = JSObject::ED_SPARSE;
do {
if (index > unsigned(-1))
if (index > uint32_t(-1))
break;
unsigned idx = unsigned(index);
uint32_t idx = uint32_t(index);
result = obj->ensureDenseArrayElements(cx, idx, 1);
if (result != JSObject::ED_OK)
break;
@ -630,8 +630,8 @@ array_length_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value
* us to disregard length when reading from arrays as long we are within
* the initialized capacity.
*/
unsigned oldcap = obj->getDenseArrayCapacity();
unsigned oldinit = obj->getDenseArrayInitializedLength();
uint32_t oldcap = obj->getDenseArrayCapacity();
uint32_t oldinit = obj->getDenseArrayInitializedLength();
if (oldinit > newlen)
obj->setDenseArrayInitializedLength(newlen);
if (oldcap > newlen)
@ -661,13 +661,13 @@ array_length_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value
if (!iter)
return false;
unsigned gap = oldlen - newlen;
uint32_t gap = oldlen - newlen;
for (;;) {
if (!JS_CHECK_OPERATION_LIMIT(cx) || !JS_NextProperty(cx, iter, &id))
return false;
if (JSID_IS_VOID(id))
break;
unsigned index;
uint32_t index;
Value junk;
if (js_IdIsIndex(id, &index) && index - newlen < gap &&
!obj->deleteElement(cx, index, &junk, false)) {
@ -864,7 +864,7 @@ array_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Valu
static JSBool
slowarray_addProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
{
unsigned index, length;
uint32_t index, length;
if (!js_IdIsIndex(id, &index))
return JS_TRUE;
@ -1489,11 +1489,11 @@ array_toSource(JSContext *cx, unsigned argc, Value *vp)
if (!sb.append('['))
return false;
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return false;
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
JSBool hole;
Value elt;
if (!JS_CHECK_OPERATION_LIMIT(cx) ||
@ -1609,7 +1609,7 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
return true;
}
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return false;
@ -1650,7 +1650,7 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
}
}
} else {
for (unsigned index = 0; index < length; index++) {
for (uint32_t index = 0; index < length; index++) {
if (!JS_CHECK_OPERATION_LIMIT(cx))
return false;
@ -1794,7 +1794,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, uint32_t start, uint32_t count,
JS_ASSERT(result == JSObject::ED_SPARSE);
break;
}
unsigned newlen = start + count;
uint32_t newlen = start + count;
if (newlen > obj->getArrayLength())
obj->setDenseArrayLength(newlen);
@ -1837,7 +1837,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, uint32_t start, uint32_t count,
#if 0
static JSBool
InitArrayObject(JSContext *cx, JSObject *obj, unsigned length, const Value *vector)
InitArrayObject(JSContext *cx, JSObject *obj, uint32_t length, const Value *vector)
{
JS_ASSERT(obj->isArray());
@ -1856,7 +1856,7 @@ InitArrayObject(JSContext *cx, JSObject *obj, unsigned length, const Value *vect
obj->setDenseArrayInitializedLength(length);
bool hole = false;
for (unsigned i = 0; i < length; i++) {
for (uint32_t i = 0; i < length; i++) {
obj->setDenseArrayElement(i, vector[i]);
hole |= vector[i].isMagic(JS_ARRAY_HOLE);
}
@ -1899,7 +1899,7 @@ array_reverse(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
unsigned len;
uint32_t len;
if (!js_GetLengthProperty(cx, obj, &len))
return false;
@ -1961,7 +1961,7 @@ array_reverse(JSContext *cx, unsigned argc, Value *vp)
} while (false);
Value lowval, hival;
for (unsigned i = 0, half = len / 2; i < half; i++) {
for (uint32_t i = 0, half = len / 2; i < half; i++) {
JSBool hole, hole2;
if (!JS_CHECK_OPERATION_LIMIT(cx) ||
!GetElement(cx, obj, i, &hole, &lowval) ||
@ -2203,7 +2203,7 @@ js::array_sort(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
unsigned len;
uint32_t len;
if (!js_GetLengthProperty(cx, obj, &len))
return false;
if (len == 0) {
@ -2250,7 +2250,7 @@ js::array_sort(JSContext *cx, unsigned argc, Value *vp)
undefs = 0;
bool allStrings = true;
bool allInts = true;
for (unsigned i = 0; i < len; i++) {
for (uint32_t i = 0; i < len; i++) {
if (!JS_CHECK_OPERATION_LIMIT(cx))
return false;
@ -2341,7 +2341,7 @@ js::array_sort(JSContext *cx, unsigned argc, Value *vp)
}
}
if (!InitArrayElements(cx, obj, 0, unsigned(n), result, DontUpdateTypes))
if (!InitArrayElements(cx, obj, 0, uint32_t(n), result, DontUpdateTypes))
return false;
}
@ -2367,7 +2367,7 @@ js::array_sort(JSContext *cx, unsigned argc, Value *vp)
static bool
array_push_slowly(JSContext *cx, JSObject *obj, CallArgs &args)
{
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return false;
@ -2451,7 +2451,7 @@ js::array_push(JSContext *cx, unsigned argc, Value *vp)
static JSBool
array_pop_slowly(JSContext *cx, JSObject* obj, CallArgs &args)
{
unsigned index;
uint32_t index;
if (!js_GetLengthProperty(cx, obj, &index))
return false;
@ -2477,7 +2477,7 @@ array_pop_slowly(JSContext *cx, JSObject* obj, CallArgs &args)
static JSBool
array_pop_dense(JSContext *cx, JSObject* obj, CallArgs &args)
{
unsigned index = obj->getArrayLength();
uint32_t index = obj->getArrayLength();
if (index == 0) {
args.rval().setUndefined();
return JS_TRUE;
@ -2538,7 +2538,7 @@ js::array_shift(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return JS_FALSE;
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return JS_FALSE;
@ -2567,7 +2567,7 @@ js::array_shift(JSContext *cx, unsigned argc, Value *vp)
/* Slide down the array above the first element. */
AutoValueRooter tvr(cx);
for (unsigned i = 0; i < length; i++) {
for (uint32_t i = 0; i < length; i++) {
if (!JS_CHECK_OPERATION_LIMIT(cx) ||
!GetElement(cx, obj, i + 1, &hole, tvr.addr()) ||
!SetOrDeleteArrayElement(cx, obj, i, hole, tvr.value())) {
@ -2590,7 +2590,7 @@ array_unshift(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return JS_FALSE;
@ -2936,11 +2936,11 @@ js::array_concat(JSContext *cx, unsigned argc, Value *vp)
return false;
JSObject *nobj;
unsigned length;
uint32_t length;
if (aobj->isDenseArray()) {
length = aobj->getArrayLength();
const Value *vector = aobj->getDenseArrayElements();
unsigned initlen = aobj->getDenseArrayInitializedLength();
uint32_t initlen = aobj->getDenseArrayInitializedLength();
nobj = NewDenseCopiedArray(cx, initlen, vector);
if (!nobj)
return JS_FALSE;
@ -2967,7 +2967,7 @@ js::array_concat(JSContext *cx, unsigned argc, Value *vp)
if (v.isObject()) {
JSObject &obj = v.toObject();
if (ObjectClassIs(obj, ESClass_Array, cx)) {
unsigned alength;
uint32_t alength;
if (!js_GetLengthProperty(cx, &obj, &alength))
return false;
for (uint32_t slot = 0; slot < alength; slot++) {
@ -3000,7 +3000,7 @@ static JSBool
array_slice(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *nobj;
unsigned length, begin, end, slot;
uint32_t length, begin, end, slot;
JSBool hole;
CallArgs args = CallArgsFromVp(argc, vp);
@ -3025,7 +3025,7 @@ array_slice(JSContext *cx, unsigned argc, Value *vp)
} else if (d > length) {
d = length;
}
begin = (unsigned)d;
begin = (uint32_t)d;
if (args.hasDefined(1)) {
if (!ToInteger(cx, args[1], &d))
@ -3037,7 +3037,7 @@ array_slice(JSContext *cx, unsigned argc, Value *vp)
} else if (d > length) {
d = length;
}
end = (unsigned)d;
end = (uint32_t)d;
}
}
@ -3081,7 +3081,7 @@ enum IndexOfKind {
static JSBool
array_indexOfHelper(JSContext *cx, IndexOfKind mode, CallArgs &args)
{
unsigned length, i, stop;
uint32_t length, i, stop;
Value tosearch;
int direction;
JSBool hole;
@ -3110,14 +3110,14 @@ array_indexOfHelper(JSContext *cx, IndexOfKind mode, CallArgs &args)
goto not_found;
i = 0;
} else {
i = (unsigned)start;
i = (uint32_t)start;
}
} else if (start >= length) {
if (mode == IndexOf)
goto not_found;
i = length - 1;
} else {
i = (unsigned)start;
i = (uint32_t)start;
}
}
@ -3132,7 +3132,7 @@ array_indexOfHelper(JSContext *cx, IndexOfKind mode, CallArgs &args)
for (;;) {
Value elt;
if (!JS_CHECK_OPERATION_LIMIT(cx) ||
!GetElement(cx, obj, (unsigned)i, &hole, &elt)) {
!GetElement(cx, obj, (uint32_t)i, &hole, &elt)) {
return JS_FALSE;
}
if (!hole) {
@ -3736,7 +3736,7 @@ js_InitArrayClass(JSContext *cx, JSObject *obj)
namespace js {
static inline bool
EnsureNewArrayElements(JSContext *cx, JSObject *obj, unsigned length)
EnsureNewArrayElements(JSContext *cx, JSObject *obj, uint32_t length)
{
/*
* If ensureElements creates dynamically allocated slots, then having

View File

@ -57,13 +57,13 @@ const uint32_t MAX_ARRAY_INDEX = 4294967294u;
}
inline JSBool
js_IdIsIndex(jsid id, unsigned *indexp)
js_IdIsIndex(jsid id, uint32_t *indexp)
{
if (JSID_IS_INT(id)) {
int32_t i = JSID_TO_INT(id);
if (i < 0)
return JS_FALSE;
*indexp = (unsigned)i;
*indexp = (uint32_t)i;
return JS_TRUE;
}
@ -137,7 +137,7 @@ NewSlowEmptyArray(JSContext *cx);
} /* namespace js */
extern JSBool
js_GetLengthProperty(JSContext *cx, JSObject *obj, unsigned *lengthp);
js_GetLengthProperty(JSContext *cx, JSObject *obj, uint32_t *lengthp);
extern JSBool
js_SetLengthProperty(JSContext *cx, JSObject *obj, double length);
@ -158,7 +158,7 @@ array_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, J
* js_GetLengthProperty on aobj.
*/
extern bool
GetElements(JSContext *cx, JSObject *aobj, unsigned length, js::Value *vp);
GetElements(JSContext *cx, JSObject *aobj, uint32_t length, js::Value *vp);
/* Natives exposed for optimization by the interpreter and JITs. */

View File

@ -712,9 +712,9 @@ js_CheckForStringIndex(jsid id)
const jschar *cp = s;
const jschar *end = s + n;
unsigned index = JS7_UNDEC(*cp++);
unsigned oldIndex = 0;
unsigned c = 0;
uint32_t index = JS7_UNDEC(*cp++);
uint32_t oldIndex = 0;
uint32_t c = 0;
if (index != 0) {
while (JS7_ISDEC(*cp)) {

View File

@ -513,7 +513,7 @@ JS_FRIEND_API(bool)
GetPropertyNames(JSContext *cx, JSObject *obj, unsigned flags, js::AutoIdVector *props);
JS_FRIEND_API(bool)
StringIsArrayIndex(JSLinearString *str, unsigned *indexp);
StringIsArrayIndex(JSLinearString *str, uint32_t *indexp);
JS_FRIEND_API(void)
SetPreserveWrapperCallback(JSRuntime *rt, PreserveWrapperCallback callback);

View File

@ -1296,7 +1296,7 @@ js_fun_apply(JSContext *cx, unsigned argc, Value *vp)
* original version of ES5).
*/
JSObject *aobj = &vp[3].toObject();
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, aobj, &length))
return false;

View File

@ -724,7 +724,7 @@ Chunk::removeFromAvailableList()
* it to the most recently freed arena when we free, and forcing it to
* the last alloc + 1 when we allocate.
*/
unsigned
uint32_t
Chunk::findDecommittedArenaOffset()
{
/* Note: lastFreeArenaOffset can be past the end of the list. */

View File

@ -2905,7 +2905,7 @@ BEGIN_CASE(JSOP_TABLESWITCH)
int32_t high = GET_JUMP_OFFSET(pc2);
i -= low;
if ((unsigned)i < (unsigned)(high - low + 1)) {
if ((uint32_t)i < (uint32_t)(high - low + 1)) {
pc2 += JUMP_OFFSET_LEN + JUMP_OFFSET_LEN * i;
int32_t off = (int32_t) GET_JUMP_OFFSET(pc2);
if (off)
@ -3557,9 +3557,9 @@ BEGIN_CASE(JSOP_INITELEM)
if (rref.isMagic(JS_ARRAY_HOLE)) {
JS_ASSERT(obj->isArray());
JS_ASSERT(JSID_IS_INT(id));
JS_ASSERT(unsigned(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
JS_ASSERT(uint32_t(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
if (JSOp(regs.pc[JSOP_INITELEM_LENGTH]) == JSOP_ENDINIT &&
!js_SetLengthProperty(cx, obj, (unsigned) (JSID_TO_INT(id) + 1))) {
!js_SetLengthProperty(cx, obj, (uint32_t) (JSID_TO_INT(id) + 1))) {
goto error;
}
} else {

View File

@ -232,7 +232,7 @@ GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp
if (lval.isObject()) {
JSObject *obj = &lval.toObject();
if (obj->isArray()) {
unsigned length = obj->getArrayLength();
uint32_t length = obj->getArrayLength();
*vp = NumberValue(length);
return true;
}
@ -804,13 +804,13 @@ SetObjectElementOperation(JSContext *cx, JSObject *obj, jsid id, const Value &va
do {
if (obj->isDenseArray() && JSID_IS_INT(id)) {
unsigned length = obj->getDenseArrayInitializedLength();
uint32_t length = obj->getDenseArrayInitializedLength();
int32_t i = JSID_TO_INT(id);
if ((unsigned)i < length) {
if ((uint32_t)i < length) {
if (obj->getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE)) {
if (js_PrototypeHasIndexedProperties(cx, obj))
break;
if ((unsigned)i >= obj->getArrayLength())
if ((uint32_t)i >= obj->getArrayLength())
obj->setArrayLength(cx, i + 1);
}
obj->setDenseArrayElementWithType(cx, i, value);

View File

@ -2194,7 +2194,7 @@ DefinePropertyOnArray(JSContext *cx, JSObject *obj, const jsid &id, const PropDe
if (obj->isDenseArray() && !obj->makeDenseArraySlow(cx))
return JS_FALSE;
unsigned oldLen = obj->getArrayLength();
uint32_t oldLen = obj->getArrayLength();
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
/*

View File

@ -500,7 +500,7 @@ JA(JSContext *cx, JSObject *obj, StringifyContext *scx)
return JS_FALSE;
/* Step 6. */
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return JS_FALSE;
@ -649,7 +649,7 @@ js_Stringify(JSContext *cx, Value *vp, JSObject *replacer, Value space, StringBu
*/
/* Step 4b(ii). */
unsigned len;
uint32_t len;
JS_ALWAYS_TRUE(js_GetLengthProperty(cx, replacer, &len));
if (replacer->isDenseArray())
len = JS_MIN(len, replacer->getDenseArrayCapacity());
@ -659,7 +659,7 @@ js_Stringify(JSContext *cx, Value *vp, JSObject *replacer, Value space, StringBu
return false;
/* Step 4b(iii). */
unsigned i = 0;
uint32_t i = 0;
/* Step 4b(iv). */
for (; i < len; i++) {

View File

@ -1825,7 +1825,7 @@ GetLocal(SprintStack *ss, int i)
if (obj->isBlock()) {
uint32_t depth = obj->asBlock().stackDepth();
uint32_t count = obj->asBlock().slotCount();
if (unsigned(i - depth) < unsigned(count))
if (uint32_t(i - depth) < uint32_t(count))
return GetLocalInSlot(ss, i, int(i - depth), obj);
}
}
@ -1838,7 +1838,7 @@ GetLocal(SprintStack *ss, int i)
if (obj->isBlock()) {
uint32_t depth = obj->asBlock().stackDepth();
uint32_t count = obj->asBlock().slotCount();
if (unsigned(i - depth) < unsigned(count))
if (uint32_t(i - depth) < uint32_t(count))
return GetLocalInSlot(ss, i, int(i - depth), obj);
}
}

View File

@ -494,11 +494,11 @@ ArrayToIdVector(JSContext *cx, const Value &array, AutoIdVector &props)
return true;
JSObject *obj = &array.toObject();
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return false;
for (unsigned n = 0; n < length; ++n) {
for (uint32_t n = 0; n < length; ++n) {
if (!JS_CHECK_OPERATION_LIMIT(cx))
return false;
Value v;

View File

@ -644,7 +644,7 @@ JSObject::addPropertyInternal(JSContext *cx, jsid id,
{
shape = self->lastProperty();
unsigned index;
uint32_t index;
bool indexed = js_IdIsIndex(id, &index);
UnownedBaseShape *nbase;
if (shape->base()->matchesGetterSetter(getter, setter) && !indexed) {
@ -758,7 +758,7 @@ JSObject::putProperty(JSContext *cx, jsid id,
RootedVar<UnownedBaseShape*> nbase(cx);
{
unsigned index;
uint32_t index;
bool indexed = js_IdIsIndex(id, &index);
StackBaseShape base(self->lastProperty()->base());
base.updateGetterSetter(attrs, getter, setter);

View File

@ -877,31 +877,31 @@ out_of_range:
*
* Return the index of pat in text, or -1 if not found.
*/
static const unsigned sBMHCharSetSize = 256; /* ISO-Latin-1 */
static const unsigned sBMHPatLenMax = 255; /* skip table element is uint8_t */
static const uint32_t sBMHCharSetSize = 256; /* ISO-Latin-1 */
static const uint32_t sBMHPatLenMax = 255; /* skip table element is uint8_t */
static const int sBMHBadPattern = -2; /* return value if pat is not ISO-Latin-1 */
int
js_BoyerMooreHorspool(const jschar *text, unsigned textlen,
const jschar *pat, unsigned patlen)
js_BoyerMooreHorspool(const jschar *text, uint32_t textlen,
const jschar *pat, uint32_t patlen)
{
uint8_t skip[sBMHCharSetSize];
JS_ASSERT(0 < patlen && patlen <= sBMHPatLenMax);
for (unsigned i = 0; i < sBMHCharSetSize; i++)
for (uint32_t i = 0; i < sBMHCharSetSize; i++)
skip[i] = (uint8_t)patlen;
unsigned m = patlen - 1;
for (unsigned i = 0; i < m; i++) {
uint32_t m = patlen - 1;
for (uint32_t i = 0; i < m; i++) {
jschar c = pat[i];
if (c >= sBMHCharSetSize)
return sBMHBadPattern;
skip[c] = (uint8_t)(m - i);
}
jschar c;
for (unsigned k = m;
for (uint32_t k = m;
k < textlen;
k += ((c = text[k]) >= sBMHCharSetSize) ? patlen : skip[c]) {
for (unsigned i = k, j = m; ; i--, j--) {
for (uint32_t i = k, j = m; ; i--, j--) {
if (text[i] != pat[j])
break;
if (j == 0)
@ -912,8 +912,8 @@ js_BoyerMooreHorspool(const jschar *text, unsigned textlen,
}
struct MemCmp {
typedef unsigned Extent;
static JS_ALWAYS_INLINE Extent computeExtent(const jschar *, unsigned patlen) {
typedef uint32_t Extent;
static JS_ALWAYS_INLINE Extent computeExtent(const jschar *, uint32_t patlen) {
return (patlen - 1) * sizeof(jschar);
}
static JS_ALWAYS_INLINE bool match(const jschar *p, const jschar *t, Extent extent) {
@ -923,7 +923,7 @@ struct MemCmp {
struct ManualCmp {
typedef const jschar *Extent;
static JS_ALWAYS_INLINE Extent computeExtent(const jschar *pat, unsigned patlen) {
static JS_ALWAYS_INLINE Extent computeExtent(const jschar *pat, uint32_t patlen) {
return pat + patlen;
}
static JS_ALWAYS_INLINE bool match(const jschar *p, const jschar *t, Extent extent) {
@ -937,7 +937,7 @@ struct ManualCmp {
template <class InnerMatch>
static int
UnrolledMatch(const jschar *text, unsigned textlen, const jschar *pat, unsigned patlen)
UnrolledMatch(const jschar *text, uint32_t textlen, const jschar *pat, uint32_t patlen)
{
JS_ASSERT(patlen > 0 && textlen > 0);
const jschar *textend = text + textlen - (patlen - 1);
@ -982,8 +982,8 @@ UnrolledMatch(const jschar *text, unsigned textlen, const jschar *pat, unsigned
}
static JS_ALWAYS_INLINE int
StringMatch(const jschar *text, unsigned textlen,
const jschar *pat, unsigned patlen)
StringMatch(const jschar *text, uint32_t textlen,
const jschar *pat, uint32_t patlen)
{
if (patlen == 0)
return 0;
@ -1046,7 +1046,7 @@ static const size_t sRopeMatchThresholdRatioLog2 = 5;
* the 'match' outparam (-1 for not found).
*/
static bool
RopeMatch(JSContext *cx, JSString *textstr, const jschar *pat, unsigned patlen, int *match)
RopeMatch(JSContext *cx, JSString *textstr, const jschar *pat, uint32_t patlen, int *match)
{
JS_ASSERT(textstr->isRope());
@ -1157,21 +1157,21 @@ str_indexOf(JSContext *cx, unsigned argc, Value *vp)
if (!patstr)
return false;
unsigned textlen = str->length();
uint32_t textlen = str->length();
const jschar *text = str->getChars(cx);
if (!text)
return false;
unsigned patlen = patstr->length();
uint32_t patlen = patstr->length();
const jschar *pat = patstr->chars();
unsigned start;
uint32_t start;
if (args.length() > 1) {
if (args[1].isInt32()) {
int i = args[1].toInt32();
if (i <= 0) {
start = 0;
} else if (unsigned(i) > textlen) {
} else if (uint32_t(i) > textlen) {
start = textlen;
textlen = 0;
} else {
@ -3957,7 +3957,7 @@ Decode(JSContext *cx, JSString *str, const jschar *reservedSet, Value *rval)
goto report_bad_uri;
if (!JS7_ISHEX(chars[k+1]) || !JS7_ISHEX(chars[k+2]))
goto report_bad_uri;
unsigned B = JS7_UNHEX(chars[k+1]) * 16 + JS7_UNHEX(chars[k+2]);
uint32_t B = JS7_UNHEX(chars[k+1]) * 16 + JS7_UNHEX(chars[k+2]);
k += 2;
if (!(B & 0x80)) {
c = (jschar)B;

View File

@ -81,7 +81,7 @@ using namespace js::types;
static const uint8_t ARRAYBUFFER_RESERVED_SLOTS = JSObject::MAX_FIXED_SLOTS - 1;
static bool
ValueIsLength(JSContext *cx, const Value &v, unsigned *len)
ValueIsLength(JSContext *cx, const Value &v, uint32_t *len)
{
if (v.isInt32()) {
int32_t i = v.toInt32();
@ -96,7 +96,7 @@ ValueIsLength(JSContext *cx, const Value &v, unsigned *len)
if (JSDOUBLE_IS_NaN(d))
return false;
unsigned length = unsigned(d);
uint32_t length = uint32_t(d);
if (d != double(length))
return false;
@ -730,9 +730,9 @@ TypedArray::getTypedArray(JSObject *obj)
}
inline bool
TypedArray::isArrayIndex(JSContext *cx, JSObject *obj, jsid id, unsigned *ip)
TypedArray::isArrayIndex(JSContext *cx, JSObject *obj, jsid id, uint32_t *ip)
{
unsigned index;
uint32_t index;
if (js_IdIsIndex(id, &index) && index < getLength(obj)) {
if (ip)
*ip = index;
@ -1264,7 +1264,7 @@ class TypedArrayTemplate
return true;
}
unsigned index;
uint32_t index;
// We can't just chain to js_SetPropertyHelper, because we're not a normal object.
if (!isArrayIndex(cx, tarray, id, &index)) {
// Silent ignore is better than an exception here, because
@ -1509,7 +1509,7 @@ class TypedArrayTemplate
/* N.B. there may not be an argv[-2]/argv[-1]. */
/* () or (number) */
unsigned len = 0;
uint32_t len = 0;
if (argc == 0 || ValueIsLength(cx, argv[0], &len)) {
JSObject *bufobj = createBufferWithSizeAndCount(cx, len);
if (!bufobj)
@ -1663,7 +1663,7 @@ class TypedArrayTemplate
if (!copyFromTypedArray(cx, obj, src, offset))
return false;
} else {
unsigned len;
uint32_t len;
if (!js_GetLengthProperty(cx, arg0, &len))
return false;
@ -1734,7 +1734,7 @@ class TypedArrayTemplate
* Otherwise create a new typed array and copy len properties from the
* object.
*/
unsigned len;
uint32_t len;
if (!js_GetLengthProperty(cx, other, &len))
return NULL;
@ -1824,7 +1824,7 @@ class TypedArrayTemplate
static bool
copyFromArray(JSContext *cx, JSObject *thisTypedArrayObj,
JSObject *ar, unsigned len, unsigned offset = 0)
JSObject *ar, uint32_t len, uint32_t offset = 0)
{
thisTypedArrayObj = getTypedArray(thisTypedArrayObj);
JS_ASSERT(thisTypedArrayObj);
@ -1858,7 +1858,7 @@ class TypedArrayTemplate
}
static bool
copyFromTypedArray(JSContext *cx, JSObject *thisTypedArrayObj, JSObject *tarray, unsigned offset)
copyFromTypedArray(JSContext *cx, JSObject *thisTypedArrayObj, JSObject *tarray, uint32_t offset)
{
thisTypedArrayObj = getTypedArray(thisTypedArrayObj);
JS_ASSERT(thisTypedArrayObj);
@ -1935,7 +1935,7 @@ class TypedArrayTemplate
}
static bool
copyFromWithOverlap(JSContext *cx, JSObject *self, JSObject *tarray, unsigned offset)
copyFromWithOverlap(JSContext *cx, JSObject *self, JSObject *tarray, uint32_t offset)
{
JS_ASSERT(offset <= getLength(self));
@ -2532,13 +2532,13 @@ js_IsTypedArray(JSObject *obj)
}
JS_FRIEND_API(JSObject *)
js_CreateArrayBuffer(JSContext *cx, unsigned nbytes)
js_CreateArrayBuffer(JSContext *cx, uint32_t nbytes)
{
return ArrayBuffer::create(cx, nbytes);
}
JS_FRIEND_API(JSObject *)
JS_NewArrayBuffer(JSContext *cx, unsigned nbytes)
JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes)
{
return js_CreateArrayBuffer(cx, nbytes);
}
@ -2581,7 +2581,7 @@ TypedArrayConstruct(JSContext *cx, int atype, unsigned argc, Value *argv)
}
JS_FRIEND_API(JSObject *)
js_CreateTypedArray(JSContext *cx, int atype, unsigned nelements)
js_CreateTypedArray(JSContext *cx, int atype, uint32_t nelements)
{
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);

View File

@ -252,7 +252,7 @@ struct JS_FRIEND_API(TypedArray) {
public:
static bool
isArrayIndex(JSContext *cx, JSObject *obj, jsid id, unsigned *ip = NULL);
isArrayIndex(JSContext *cx, JSObject *obj, jsid id, uint32_t *ip = NULL);
static inline uint32_t slotWidth(int atype) {
switch (atype) {
@ -335,7 +335,7 @@ JS_FRIEND_API(JSBool)
JS_IsArrayBufferObject(JSObject *obj);
JS_FRIEND_API(JSObject *)
JS_NewArrayBuffer(JSContext *cx, unsigned nbytes);
JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes);
JS_FRIEND_API(uint32_t)
JS_GetArrayBufferByteLength(JSObject *obj);

View File

@ -4665,7 +4665,7 @@ HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
}
static bool
IdValIsIndex(JSContext *cx, jsval id, unsigned *indexp, bool *isIndex)
IdValIsIndex(JSContext *cx, jsval id, uint32_t *indexp, bool *isIndex)
{
if (JSVAL_IS_INT(id)) {
int32_t i = JSVAL_TO_INT(id);
@ -4673,7 +4673,7 @@ IdValIsIndex(JSContext *cx, jsval id, unsigned *indexp, bool *isIndex)
*isIndex = false;
return true;
}
*indexp = (unsigned)i;
*indexp = (uint32_t)i;
*isIndex = true;
return true;
}
@ -6198,7 +6198,7 @@ static JSBool
xml_namespace(JSContext *cx, unsigned argc, jsval *vp)
{
JSLinearString *prefix, *nsprefix;
unsigned i, length;
uint32_t i, length;
JSObject *ns;
NON_LIST_XML_METHOD_PROLOG;

View File

@ -1143,7 +1143,7 @@ ic::SplatApplyArgs(VMFrame &f)
/* Steps 4-5. */
JSObject *aobj = &vp[3].toObject();
unsigned length;
uint32_t length;
if (!js_GetLengthProperty(cx, aobj, &length))
THROWV(false);

View File

@ -234,13 +234,13 @@ stubs::SetElem(VMFrame &f)
do {
if (obj->isDenseArray() && JSID_IS_INT(id)) {
unsigned length = obj->getDenseArrayInitializedLength();
uint32_t length = obj->getDenseArrayInitializedLength();
int32_t i = JSID_TO_INT(id);
if ((unsigned)i < length) {
if ((uint32_t)i < length) {
if (obj->getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE)) {
if (js_PrototypeHasIndexedProperties(cx, obj))
break;
if ((unsigned)i >= obj->getArrayLength())
if ((uint32_t)i >= obj->getArrayLength())
obj->setArrayLength(cx, i + 1);
}
obj->setDenseArrayElementWithType(cx, i, rval);
@ -1034,8 +1034,8 @@ stubs::InitElem(VMFrame &f, uint32_t last)
if (rref.isMagic(JS_ARRAY_HOLE)) {
JS_ASSERT(obj->isArray());
JS_ASSERT(JSID_IS_INT(id));
JS_ASSERT(unsigned(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
if (last && !js_SetLengthProperty(cx, obj, (unsigned) (JSID_TO_INT(id) + 1)))
JS_ASSERT(uint32_t(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
if (last && !js_SetLengthProperty(cx, obj, (uint32_t) (JSID_TO_INT(id) + 1)))
THROW();
} else {
if (!obj->defineGeneric(cx, id, rref, NULL, NULL, JSPROP_ENUMERATE))
@ -1584,7 +1584,7 @@ stubs::TableSwitch(VMFrame &f, jsbytecode *origPc)
pc += JUMP_OFFSET_LEN;
tableIdx -= low;
if ((unsigned) tableIdx < (unsigned)(high - low + 1)) {
if ((uint32_t) tableIdx < (uint32_t)(high - low + 1)) {
pc += JUMP_OFFSET_LEN * tableIdx;
if (uint32_t candidateOffset = GET_JUMP_OFFSET(pc))
jumpOffset = candidateOffset;

View File

@ -532,7 +532,7 @@ ReferenceFinder::addReferrer(jsval referrer, Path *path)
JS_ASSERT(JS_IsArrayObject(context, array));
/* Append our referrer to this array. */
unsigned length;
uint32_t length;
return JS_GetArrayLength(context, array, &length) &&
JS_SetElement(context, array, length, &referrer);
}

View File

@ -1214,7 +1214,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
// Iterate over symbols array, installing symbols on targetObj:
unsigned symbolCount = 0;
uint32_t symbolCount = 0;
if (!JS_GetArrayLength(mContext, symbolsObj, &symbolCount)) {
return ReportOnCaller(cxhelper, ERROR_GETTING_ARRAY_LENGTH,
PromiseFlatCString(aLocation).get());
@ -1224,7 +1224,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
nsCAutoString logBuffer;
#endif
for (unsigned i = 0; i < symbolCount; ++i) {
for (uint32_t i = 0; i < symbolCount; ++i) {
jsval val;
jsid symbolId;

View File

@ -190,7 +190,7 @@ private:
public:
static JSBool GetTypeForArray(XPCCallContext& ccx, JSObject* array,
unsigned length,
uint32_t length,
nsXPTType* resultType, nsID* resultID);
};
@ -215,7 +215,7 @@ XPCArrayHomogenizer::StateTable[tTypeCount][tTypeCount-1] = {
// static
JSBool
XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
unsigned length,
uint32_t length,
nsXPTType* resultType, nsID* resultID)
{
Type state = tUnk;

View File

@ -607,7 +607,7 @@ GetArrayIndexFromId(JSContext *cx, jsid id)
if (NS_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z'))
return -1;
unsigned i;
uint32_t i;
JSLinearString *str = js::AtomToLinearString(JSID_TO_ATOM(id));
return js::StringIsArrayIndex(str, &i) ? i : -1;
}

View File

@ -359,7 +359,7 @@ GetHistogramCounts(const char *testmsg, JSContext *cx, jsval *counts)
nsresult
CompareCountArrays(JSContext *cx, JSObject *before, JSObject *after)
{
unsigned before_size, after_size;
uint32_t before_size, after_size;
if (!(JS_GetArrayLength(cx, before, &before_size)
&& JS_GetArrayLength(cx, after, &after_size))) {
return NS_ERROR_UNEXPECTED;
@ -369,7 +369,7 @@ CompareCountArrays(JSContext *cx, JSObject *before, JSObject *after)
return NS_ERROR_UNEXPECTED;
}
for (unsigned i = 0; i < before_size; ++i) {
for (uint32_t i = 0; i < before_size; ++i) {
jsval before_num, after_num;
if (!(JS_GetElement(cx, before, i, &before_num)

View File

@ -318,7 +318,7 @@ GetIntFromJSObject(JSContext* aCtx,
nsresult
GetJSObjectFromArray(JSContext* aCtx,
JSObject* aArray,
unsigned aIndex,
uint32_t aIndex,
JSObject** _rooter)
{
NS_PRECONDITION(JS_IsArrayObject(aCtx, aArray),
@ -2104,7 +2104,7 @@ History::UpdatePlaces(const jsval& aPlaceInfos,
NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aPlaceInfos), NS_ERROR_INVALID_ARG);
unsigned infosLength = 1;
uint32_t infosLength = 1;
JSObject* infos;
if (JS_IsArrayObject(aCtx, JSVAL_TO_OBJECT(aPlaceInfos))) {
infos = JSVAL_TO_OBJECT(aPlaceInfos);
@ -2122,7 +2122,7 @@ History::UpdatePlaces(const jsval& aPlaceInfos,
}
nsTArray<VisitData> visitData;
for (unsigned i = 0; i < infosLength; i++) {
for (uint32_t i = 0; i < infosLength; i++) {
JSObject* info;
nsresult rv = GetJSObjectFromArray(aCtx, infos, i, &info);
NS_ENSURE_SUCCESS(rv, rv);
@ -2168,7 +2168,7 @@ History::UpdatePlaces(const jsval& aPlaceInfos,
}
NS_ENSURE_ARG(visits);
unsigned visitsLength = 0;
uint32_t visitsLength = 0;
if (visits) {
(void)JS_GetArrayLength(aCtx, visits, &visitsLength);
}
@ -2176,7 +2176,7 @@ History::UpdatePlaces(const jsval& aPlaceInfos,
// Check each visit, and build our array of VisitData objects.
visitData.SetCapacity(visitData.Length() + visitsLength);
for (unsigned j = 0; j < visitsLength; j++) {
for (uint32_t j = 0; j < visitsLength; j++) {
JSObject* visit;
rv = GetJSObjectFromArray(aCtx, visits, j, &visit);
NS_ENSURE_SUCCESS(rv, rv);