Bug 969812 - Convert JS_NewArrayObject to use HandleValueArray r=terrence r=bz

This commit is contained in:
Jon Coppeard 2014-02-12 10:50:46 +00:00
parent de96d4b77d
commit 25c1a75044
44 changed files with 136 additions and 106 deletions

View File

@ -457,7 +457,7 @@ nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::MutableHandle<
return NS_ERROR_NOT_IMPLEMENTED;
}
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, mPendingScripts.Length(), nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, mPendingScripts.Length()));
NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JSString*> url(aCx);
@ -466,10 +466,11 @@ nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::MutableHandle<
url = JS_NewUCStringCopyN(aCx, mPendingScripts[i].get(), mPendingScripts[i].Length());
NS_ENSURE_TRUE(url, NS_ERROR_OUT_OF_MEMORY);
JS::Value pairElts[] = { JS::StringValue(url),
JS::BooleanValue(mPendingScriptsGlobalStates[i]) };
JS::AutoValueArray<2> pairElts(aCx);
pairElts[0].setString(url);
pairElts[1].setBoolean(mPendingScriptsGlobalStates[i]);
pair = JS_NewArrayObject(aCx, 2, pairElts);
pair = JS_NewArrayObject(aCx, pairElts);
NS_ENSURE_TRUE(pair, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(JS_SetElement(aCx, array, i, pair),
@ -598,7 +599,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
}
uint32_t len = retval.Length();
JS::Rooted<JSObject*> dataArray(aCx, JS_NewArrayObject(aCx, len, nullptr));
JS::Rooted<JSObject*> dataArray(aCx, JS_NewArrayObject(aCx, len));
NS_ENSURE_TRUE(dataArray, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < len; ++i) {

View File

@ -1245,14 +1245,13 @@ CanvasRenderingContext2D::SetTransform(double m11, double m12,
JSObject*
MatrixToJSObject(JSContext* cx, const Matrix& matrix, ErrorResult& error)
{
JS::Value elts[] = {
DOUBLE_TO_JSVAL(matrix._11), DOUBLE_TO_JSVAL(matrix._12),
DOUBLE_TO_JSVAL(matrix._21), DOUBLE_TO_JSVAL(matrix._22),
DOUBLE_TO_JSVAL(matrix._31), DOUBLE_TO_JSVAL(matrix._32)
};
JS::AutoValueArray<6> elts(cx);
elts[0].setDouble(matrix._11); elts[1].setDouble(matrix._12);
elts[2].setDouble(matrix._21); elts[3].setDouble(matrix._22);
elts[4].setDouble(matrix._31); elts[5].setDouble(matrix._32);
// XXX Should we enter GetWrapper()'s compartment?
JSObject* obj = JS_NewArrayObject(cx, 6, elts);
JSObject* obj = JS_NewArrayObject(cx, elts);
if (!obj) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
}

View File

@ -158,7 +158,7 @@ DashArrayToJSVal(FallibleTArray<T>& dashes,
return JSVAL_NULL;
}
JS::Rooted<JSObject*> obj(cx,
JS_NewArrayObject(cx, dashes.Length(), nullptr));
JS_NewArrayObject(cx, dashes.Length()));
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JSVAL_NULL;

View File

@ -1907,10 +1907,10 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
if (unitSize == 1) {
return JS::BooleanValue(iv[0] ? true : false);
} else {
JS::Value uv[16];
JS::AutoValueArray<16> uv(cx);
for (int k = 0; k < unitSize; k++)
uv[k] = JS::BooleanValue(iv[k] ? true : false);
JSObject* obj = JS_NewArrayObject(cx, unitSize, uv);
uv[k].setBoolean(iv[k]);
JSObject* obj = JS_NewArrayObject(cx, JS::HandleValueArray::subarray(uv, 0, unitSize));
if (!obj) {
ErrorOutOfMemory("getUniform: out of memory");
return JS::NullValue();

View File

@ -423,11 +423,12 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
{
realGLboolean gl_bv[4] = { 0 };
gl->fGetBooleanv(pname, gl_bv);
JS::Value vals[4] = { JS::BooleanValue(bool(gl_bv[0])),
JS::BooleanValue(bool(gl_bv[1])),
JS::BooleanValue(bool(gl_bv[2])),
JS::BooleanValue(bool(gl_bv[3])) };
JSObject* obj = JS_NewArrayObject(cx, 4, vals);
JS::AutoValueArray<4> vals(cx);
vals[0].setBoolean(gl_bv[0]);
vals[1].setBoolean(gl_bv[1]);
vals[2].setBoolean(gl_bv[2]);
vals[3].setBoolean(gl_bv[3]);
JSObject* obj = JS_NewArrayObject(cx, vals);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -372,9 +372,15 @@ MessagePort::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
JS::Rooted<JS::Value> transferable(aCx, JS::UndefinedValue());
if (aTransferable.WasPassed()) {
const Sequence<JS::Value>& realTransferable = aTransferable.Value();
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(realTransferable.Length(),
realTransferable.Elements());
JSObject* array =
JS_NewArrayObject(aCx, realTransferable.Length(),
const_cast<JS::Value*>(realTransferable.Elements()));
JS_NewArrayObject(aCx, elements);
if (!array) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;

View File

@ -7940,9 +7940,13 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
if (aTransfer.WasPassed()) {
const Sequence<JS::Value >& values = aTransfer.Value();
transferArray = JS::ObjectOrNullValue(JS_NewArrayObject(aCx,
values.Length(),
const_cast<JS::Value*>(values.Elements())));
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(values.Length(), values.Elements());
transferArray = JS::ObjectOrNullValue(JS_NewArrayObject(aCx, elements));
if (transferArray.isNull()) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return;

View File

@ -1169,7 +1169,7 @@ nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, n
}
}
JSObject* array = ::JS_NewArrayObject(mContext, args.length(), args.begin());
JSObject* array = ::JS_NewArrayObject(mContext, args);
if (!array) {
return NS_ERROR_FAILURE;
}

View File

@ -4428,7 +4428,7 @@ if (%s.IsNull()) {
innerTemplate = CGIndenter(CGGeneric(innerTemplate), 6).define()
return (("""
uint32_t length = %s.Length();
JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length, nullptr));
JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
if (!returnArray) {
%s
}

View File

@ -146,7 +146,7 @@ CameraControlImpl::Get(JSContext* aCx, uint32_t aKey, JS::Value* aValue)
GetParameter(aKey, regionArray);
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
if (!array) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -121,7 +121,7 @@ DOMCameraCapabilities::ParameterListToNewArray(JSContext* aCx,
return NS_OK;
}
aArray.set(JS_NewArrayObject(aCx, 0, nullptr));
aArray.set(JS_NewArrayObject(aCx, 0));
if (!aArray) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -378,7 +378,7 @@ DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::MutableHandle<JS::Value>
return NS_OK;
}
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, 0));
if (!array) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -174,7 +174,7 @@ ArchiveRequest::GetFilenamesResult(JSContext* aCx,
JS::Value* aValue,
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList)
{
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aFileList.Length(), nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aFileList.Length()));
nsresult rv;
if (!array) {
@ -232,7 +232,7 @@ ArchiveRequest::GetFilesResult(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue,
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList)
{
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aFileList.Length(), nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aFileList.Length()));
if (!array) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -58,7 +58,7 @@ ConvertCloneReadInfosToArrayInternal(
nsTArray<StructuredCloneReadInfo>& aReadInfos,
JS::MutableHandle<JS::Value> aResult)
{
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
if (!array) {
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;

View File

@ -1447,7 +1447,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
nsTArray<Key> keys;
mKeys.SwapElements(keys);
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
if (!array) {
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;

View File

@ -4931,7 +4931,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
nsTArray<Key> keys;
mKeys.SwapElements(keys);
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
if (!array) {
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;

View File

@ -191,7 +191,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
if (*aPos - aTypeOffset >= eArray) {
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_REPORT_INTERNAL_ERR();

View File

@ -389,7 +389,7 @@ KeyPath::ExtractKeyAsJSVal(JSContext* aCx, const JS::Value& aValue,
}
const uint32_t len = mStrings.Length();
JS::Rooted<JSObject*> arrayObj(aCx, JS_NewArrayObject(aCx, len, nullptr));
JS::Rooted<JSObject*> arrayObj(aCx, JS_NewArrayObject(aCx, len));
if (!arrayObj) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -501,7 +501,7 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle<JS::Value> aValue) const
{
if (IsArray()) {
uint32_t len = mStrings.Length();
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, len, nullptr));
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, len));
if (!array) {
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;

View File

@ -483,7 +483,7 @@ MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDelive
}
JS::Rooted<JSObject*> deliveryInfo(
aCx, JS_NewArrayObject(aCx, length, nullptr));
aCx, JS_NewArrayObject(aCx, length));
NS_ENSURE_TRUE(deliveryInfo, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < length; ++i) {
@ -614,7 +614,7 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachm
uint32_t length = mAttachments.Length();
JS::Rooted<JSObject*> attachments(
aCx, JS_NewArrayObject(aCx, length, nullptr));
aCx, JS_NewArrayObject(aCx, length));
NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < length; ++i) {

View File

@ -167,7 +167,7 @@ MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize)
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JS::Rooted<JSObject*> deleteArrayObj(cx,
JS_NewArrayObject(cx, aSize, nullptr));
JS_NewArrayObject(cx, aSize));
for (uint32_t i = 0; i < aSize; i++) {
JS_SetElement(cx, deleteArrayObj, i, aDeleted[i]);
}

View File

@ -241,7 +241,7 @@ MobileMessageManager::Send(JS::Handle<JS::Value> aNumber,
}
JS::Rooted<JSObject*> obj(aCx);
obj = JS_NewArrayObject(aCx, requests.length(), requests.begin());
obj = JS_NewArrayObject(aCx, requests);
if (!obj) {
return NS_ERROR_FAILURE;
}

View File

@ -145,7 +145,7 @@ SmsFilter::GetNumbers(JSContext* aCx, JS::MutableHandle<JS::Value> aNumbers)
numbers[i].setString(str);
}
JSObject* obj = JS_NewArrayObject(aCx, numbers.length(), numbers.begin());
JSObject* obj = JS_NewArrayObject(aCx, numbers);
if (!obj) {
return NS_ERROR_FAILURE;
}

View File

@ -115,8 +115,7 @@ GetParamsFromSendMmsMessageRequest(JSContext* aCx,
// attachments
JS::Rooted<JSObject*> attachmentArray(aCx, JS_NewArrayObject(aCx,
aRequest.attachments().Length(),
nullptr));
aRequest.attachments().Length()));
for (uint32_t i = 0; i < aRequest.attachments().Length(); i++) {
JS::Rooted<JSObject*> obj(aCx,
MmsAttachmentDataToJSObject(aCx, aRequest.attachments().ElementAt(i)));

View File

@ -608,7 +608,7 @@ public:
MOZ_ASSERT(aCountdown != 0);
JSContext* cx = aGlobal.GetContext();
JSAutoCompartment ac(cx, aGlobal.Get());
mValues = JS_NewArrayObject(cx, aCountdown, nullptr);
mValues = JS_NewArrayObject(cx, aCountdown);
mozilla::HoldJSObjects(this);
}
@ -731,7 +731,7 @@ Promise::All(const GlobalObject& aGlobal, JSContext* aCx,
}
if (aIterable.Length() == 0) {
JS::Rooted<JSObject*> empty(aCx, JS_NewArrayObject(aCx, 0, nullptr));
JS::Rooted<JSObject*> empty(aCx, JS_NewArrayObject(aCx, 0));
if (!empty) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;

View File

@ -48,7 +48,7 @@ public:
MOZ_ASSERT(aPromise);
JSContext* cx = aGlobal.GetContext();
JSAutoCompartment ac(cx, mGlobal);
mNotifications = JS_NewArrayObject(cx, 0, nullptr);
mNotifications = JS_NewArrayObject(cx, 0);
HoldData();
}

View File

@ -292,7 +292,7 @@ private:
JS::Rooted<JS::Value> stackValue(cx);
{
JS::Rooted<JSObject*> stackObj(cx,
JS_NewArrayObject(cx, mStackData.Length(), nullptr));
JS_NewArrayObject(cx, mStackData.Length()));
if (!stackObj) {
return;
}
@ -447,8 +447,7 @@ WorkerConsole::Method(JSContext* aCx, const char* aMethodName,
stack.swap(caller);
}
JS::Rooted<JSObject*> arguments(aCx,
JS_NewArrayObject(aCx, aData.Length(), nullptr));
JS::Rooted<JSObject*> arguments(aCx, JS_NewArrayObject(aCx, aData.Length()));
if (!arguments) {
return;
}

View File

@ -2707,9 +2707,15 @@ WorkerPrivateParent<Derived>::PostMessageInternal(
JS::Rooted<JS::Value> transferable(aCx, JS::UndefinedValue());
if (aTransferable.WasPassed()) {
const Sequence<JS::Value>& realTransferable = aTransferable.Value();
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(realTransferable.Length(),
realTransferable.Elements());
JSObject* array =
JS_NewArrayObject(aCx, realTransferable.Length(),
const_cast<JS::Value*>(realTransferable.Elements()));
JS_NewArrayObject(aCx, elements);
if (!array) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
@ -4923,9 +4929,14 @@ WorkerPrivate::PostMessageToParentInternal(
JS::Rooted<JS::Value> transferable(aCx, JS::UndefinedValue());
if (aTransferable.WasPassed()) {
const Sequence<JS::Value>& realTransferable = aTransferable.Value();
JSObject* array =
JS_NewArrayObject(aCx, realTransferable.Length(),
const_cast<jsval*>(realTransferable.Elements()));
// The input sequence only comes from the generated bindings code, which
// ensures it is rooted.
JS::HandleValueArray elements =
JS::HandleValueArray::fromMarkedLocation(realTransferable.Length(),
realTransferable.Elements());
JSObject* array = JS_NewArrayObject(aCx, elements);
if (!array) {
aRv = NS_ERROR_OUT_OF_MEMORY;
return;

View File

@ -136,7 +136,7 @@ NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::MutableHandle<JS:
return NS_OK;
}
JS::Rooted<JSObject*> destArray(aCx, JS_NewArrayObject(aCx, numRects * 4, nullptr));
JS::Rooted<JSObject*> destArray(aCx, JS_NewArrayObject(aCx, numRects * 4));
if (!destArray) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -5138,7 +5138,7 @@ StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
return nullptr;
}
RootedObject fieldsProp(cx, JS_NewArrayObject(cx, len, fieldsVec.begin()));
RootedObject fieldsProp(cx, JS_NewArrayObject(cx, fieldsVec));
if (!fieldsProp)
return nullptr;
@ -5946,7 +5946,7 @@ FunctionType::ArgTypesGetter(JSContext* cx, JS::CallArgs args)
for (size_t i = 0; i < len; ++i)
vec[i] = JS::ObjectValue(*fninfo->mArgTypes[i]);
argTypes = JS_NewArrayObject(cx, len, vec.begin());
argTypes = JS_NewArrayObject(cx, vec);
if (!argTypes)
return false;
}

View File

@ -25,7 +25,7 @@ FRAGMENT(Root, handle) {
FRAGMENT(Root, HeapSlot) {
JS::Rooted<jsval> plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth")));
JS::Rooted<JSObject *> array(cx, JS_NewArrayObject(cx, 1, plinth.address()));
JS::Rooted<JSObject *> array(cx, JS_NewArrayObject(cx, plinth));
breakpoint();

View File

@ -42,7 +42,7 @@ BEGIN_TEST(testAddPropertyHook)
JS_InitClass(cx, global, obj, &AddPropertyClass, nullptr, 0, nullptr, nullptr, nullptr,
nullptr);
obj = JS_NewArrayObject(cx, 0, nullptr);
obj = JS_NewArrayObject(cx, 0);
CHECK(obj);
JS::RootedValue arr(cx, OBJECT_TO_JSVAL(obj));

View File

@ -3774,16 +3774,24 @@ JS_SetReservedSlot(JSObject *obj, uint32_t index, Value value)
}
JS_PUBLIC_API(JSObject *)
JS_NewArrayObject(JSContext *cx, int length, jsval *vector)
JS_NewArrayObject(JSContext *cx, const JS::HandleValueArray& contents)
{
AutoArrayRooter tvr(cx, length, vector);
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, JSValueArray(vector, vector ? (uint32_t)length : 0));
return NewDenseCopiedArray(cx, (uint32_t)length, vector);
assertSameCompartment(cx, contents);
return NewDenseCopiedArray(cx, contents.length(), contents.begin());
}
JS_PUBLIC_API(JSObject *)
JS_NewArrayObject(JSContext *cx, size_t length)
{
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
return NewDenseAllocatedArray(cx, length);
}
JS_PUBLIC_API(bool)

View File

@ -626,7 +626,7 @@ class HandleValueArray
return HandleValueArray(len, elements);
}
static HandleValueArray subarray(const AutoValueVector& values, size_t startIndex, size_t len) {
static HandleValueArray subarray(const HandleValueArray& values, size_t startIndex, size_t len) {
JS_ASSERT(startIndex + len <= values.length());
return HandleValueArray(len, values.begin() + startIndex);
}
@ -3070,7 +3070,10 @@ JS_DeleteUCProperty2(JSContext *cx, JS::HandleObject obj, const jschar *name, si
bool *succeeded);
extern JS_PUBLIC_API(JSObject *)
JS_NewArrayObject(JSContext *cx, int length, jsval *vector);
JS_NewArrayObject(JSContext *cx, const JS::HandleValueArray& contents);
extern JS_PUBLIC_API(JSObject *)
JS_NewArrayObject(JSContext *cx, size_t length);
extern JS_PUBLIC_API(bool)
JS_IsArrayObject(JSContext *cx, JS::HandleValue value);

View File

@ -2336,7 +2336,7 @@ GetPDA(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
RootedObject aobj(cx, JS_NewArrayObject(cx, 0, nullptr));
RootedObject aobj(cx, JS_NewArrayObject(cx, 0));
if (!aobj)
return false;
args.rval().setObject(*aobj);
@ -5397,7 +5397,7 @@ BindScriptArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
MultiStringRange msr = op->getMultiStringArg("scriptArgs");
RootedObject scriptArgs(cx);
scriptArgs = JS_NewArrayObject(cx, 0, nullptr);
scriptArgs = JS_NewArrayObject(cx, 0);
if (!scriptArgs)
return false;

View File

@ -511,7 +511,7 @@ ReferenceFinder::addReferrer(jsval referrerArg, Path *path)
return false;
if (v.isUndefined()) {
/* Create an array to accumulate referents under this path. */
JSObject *array = JS_NewArrayObject(context, 1, referrer.address());
JSObject *array = JS_NewArrayObject(context, referrer);
if (!array)
return false;
v.setObject(*array);

View File

@ -17,7 +17,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
MOZ_ASSERT(aCx);
JS::Rooted<JSObject*> arrayObj(aCx,
JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr));
JS_NewArrayObject(aCx, aSourceArray.Length()));
if (!arrayObj) {
NS_WARNING("JS_NewArrayObject failed!");
return NS_ERROR_OUT_OF_MEMORY;
@ -59,7 +59,7 @@ nsTArrayToJSArray<nsString>(JSContext* aCx,
MOZ_ASSERT(aCx);
JS::Rooted<JSObject*> arrayObj(aCx,
JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr));
JS_NewArrayObject(aCx, aSourceArray.Length()));
if (!arrayObj) {
NS_WARNING("JS_NewArrayObject failed!");
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -3041,7 +3041,7 @@ nsXPCComponents_Utils::CreateArrayIn(HandleValue vobj, JSContext *cx,
RootedObject obj(cx);
{
JSAutoCompartment ac(cx, scope);
obj = JS_NewArrayObject(cx, 0, nullptr);
obj = JS_NewArrayObject(cx, 0);
if (!obj)
return NS_ERROR_FAILURE;
}

View File

@ -1362,7 +1362,7 @@ XPCConvert::NativeArray2JS(MutableHandleValue d, const void** s,
// XXX add support to indicate *which* array element was not convertable
RootedObject array(cx, JS_NewArrayObject(cx, count, nullptr));
RootedObject array(cx, JS_NewArrayObject(cx, count));
if (!array)
return false;

View File

@ -1093,7 +1093,7 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
* Create arguments early and define it to root it, so it's safe from any
* GC calls nested below, and so it is available to -f <file> arguments.
*/
argsObj = JS_NewArrayObject(cx, 0, nullptr);
argsObj = JS_NewArrayObject(cx, 0);
if (!argsObj)
return 1;
if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj),

View File

@ -641,7 +641,7 @@ VARIANT_DONE:
}
case nsIDataType::VTYPE_EMPTY_ARRAY:
{
JSObject* array = JS_NewArrayObject(cx, 0, nullptr);
JSObject* array = JS_NewArrayObject(cx, 0);
if (!array)
return false;
pJSVal.setObject(*array);

View File

@ -86,7 +86,7 @@ StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper,
uint32_t length;
const uint8_t *blob = static_cast<mozIStorageStatement *>(mStatement)->
AsSharedBlob(idx, &length);
JSObject *obj = ::JS_NewArrayObject(aCtx, length, nullptr);
JSObject *obj = ::JS_NewArrayObject(aCtx, length);
if (!obj) {
*_retval = false;
return NS_OK;

View File

@ -248,7 +248,7 @@ GetJSArrayFromJSValue(JS::Handle<JS::Value> aValue,
// Build a temporary array to store this one item so the code below can
// just loop.
*_arrayLength = 1;
_array.set(JS_NewArrayObject(aCtx, 0, nullptr));
_array.set(JS_NewArrayObject(aCtx, 0));
NS_ENSURE_TRUE(_array, NS_ERROR_OUT_OF_MEMORY);
bool rc = JS_DefineElement(aCtx, _array, 0, aValue, nullptr, nullptr, 0);

View File

@ -101,7 +101,7 @@ PlaceInfo::GetVisits(JSContext* aContext,
// TODO bug 625913 when we use this in situations that have more than one
// visit here, we will likely want to make this cache the value.
JS::Rooted<JSObject*> visits(aContext,
JS_NewArrayObject(aContext, 0, nullptr));
JS_NewArrayObject(aContext, 0));
NS_ENSURE_TRUE(visits, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));

View File

@ -458,17 +458,16 @@ bool TelemetryIOInterposeObserver::ReflectFileStats(FileIOEntryType* entry,
}
// Array we want to report
jsval stats[] = {
JS_NumberValue(entry->mData.totalTime),
UINT_TO_JSVAL(entry->mData.creates),
UINT_TO_JSVAL(entry->mData.reads),
UINT_TO_JSVAL(entry->mData.writes),
UINT_TO_JSVAL(entry->mData.fsyncs),
UINT_TO_JSVAL(entry->mData.stats)
};
JS::AutoValueArray<6> stats(cx);
stats[0].setNumber(entry->mData.totalTime);
stats[1].setNumber(entry->mData.creates);
stats[2].setNumber(entry->mData.reads);
stats[3].setNumber(entry->mData.writes);
stats[4].setNumber(entry->mData.fsyncs);
stats[5].setNumber(entry->mData.stats);
// Create jsEntry as array of elements above
JS::RootedObject jsEntry(cx, JS_NewArrayObject(cx, ArrayLength(stats), stats));
JS::RootedObject jsEntry(cx, JS_NewArrayObject(cx, stats));
if (!jsEntry) {
return false;
}
@ -804,7 +803,7 @@ ReflectHistogramAndSamples(JSContext *cx, JS::Handle<JSObject*> obj, Histogram *
}
const size_t count = h->bucket_count();
JS::Rooted<JSObject*> rarray(cx, JS_NewArrayObject(cx, count, nullptr));
JS::Rooted<JSObject*> rarray(cx, JS_NewArrayObject(cx, count));
if (!rarray) {
return REFLECT_FAILURE;
}
@ -814,7 +813,7 @@ ReflectHistogramAndSamples(JSContext *cx, JS::Handle<JSObject*> obj, Histogram *
return REFLECT_FAILURE;
}
JS::Rooted<JSObject*> counts_array(cx, JS_NewArrayObject(cx, count, nullptr));
JS::Rooted<JSObject*> counts_array(cx, JS_NewArrayObject(cx, count));
if (!counts_array) {
return REFLECT_FAILURE;
}
@ -1245,7 +1244,7 @@ TelemetryImpl::ReflectSQL(const SlowSQLEntryType *entry,
const nsACString &sql = entry->GetKey();
JS::Rooted<JSObject*> arrayObj(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> arrayObj(cx, JS_NewArrayObject(cx, 0));
if (!arrayObj) {
return false;
}
@ -1739,9 +1738,9 @@ TelemetryImpl::GetChromeHangs(JSContext *cx, JS::MutableHandle<JS::Value> ret)
ret.setObject(*fullReportObj);
JS::Rooted<JSObject*> durationArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> systemUptimeArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> firefoxUptimeArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> durationArray(cx, JS_NewArrayObject(cx, 0));
JS::Rooted<JSObject*> systemUptimeArray(cx, JS_NewArrayObject(cx, 0));
JS::Rooted<JSObject*> firefoxUptimeArray(cx, JS_NewArrayObject(cx, 0));
if (!durationArray || !systemUptimeArray || !firefoxUptimeArray) {
return NS_ERROR_FAILURE;
}
@ -1790,7 +1789,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
return nullptr;
}
JS::Rooted<JSObject*> moduleArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> moduleArray(cx, JS_NewArrayObject(cx, 0));
if (!moduleArray) {
return nullptr;
}
@ -1807,7 +1806,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
const Telemetry::ProcessedStack::Module& module =
stacks.GetModule(moduleIndex);
JS::Rooted<JSObject*> moduleInfoArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> moduleInfoArray(cx, JS_NewArrayObject(cx, 0));
if (!moduleInfoArray) {
return nullptr;
}
@ -1836,7 +1835,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
}
}
JS::Rooted<JSObject*> reportArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> reportArray(cx, JS_NewArrayObject(cx, 0));
if (!reportArray) {
return nullptr;
}
@ -1850,7 +1849,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
const size_t length = stacks.GetStackCount();
for (size_t i = 0; i < length; ++i) {
// Represent call stack PCs as (module index, offset) pairs.
JS::Rooted<JSObject*> pcArray(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> pcArray(cx, JS_NewArrayObject(cx, 0));
if (!pcArray) {
return nullptr;
}
@ -1863,7 +1862,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
const uint32_t pcCount = stack.size();
for (size_t pcIndex = 0; pcIndex < pcCount; ++pcIndex) {
const Telemetry::ProcessedStack::Frame& frame = stack[pcIndex];
JS::Rooted<JSObject*> framePair(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::Rooted<JSObject*> framePair(cx, JS_NewArrayObject(cx, 0));
if (!framePair) {
return nullptr;
}
@ -2005,9 +2004,9 @@ CreateJSTimeHistogram(JSContext* cx, const Telemetry::TimeHistogram& time)
}
JS::RootedObject ranges(
cx, JS_NewArrayObject(cx, ArrayLength(time) + 1, nullptr));
cx, JS_NewArrayObject(cx, ArrayLength(time) + 1));
JS::RootedObject counts(
cx, JS_NewArrayObject(cx, ArrayLength(time) + 1, nullptr));
cx, JS_NewArrayObject(cx, ArrayLength(time) + 1));
if (!ranges || !counts) {
return nullptr;
}
@ -2042,7 +2041,7 @@ CreateJSHangHistogram(JSContext* cx, const Telemetry::HangHistogram& hang)
const Telemetry::HangHistogram::Stack& hangStack = hang.GetStack();
JS::RootedObject stack(cx,
JS_NewArrayObject(cx, hangStack.length(), nullptr));
JS_NewArrayObject(cx, hangStack.length()));
if (!ret) {
return nullptr;
}
@ -2085,7 +2084,7 @@ CreateJSThreadHangStats(JSContext* cx, const Telemetry::ThreadHangStats& thread)
return nullptr;
}
JS::RootedObject hangs(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::RootedObject hangs(cx, JS_NewArrayObject(cx, 0));
if (!hangs) {
return nullptr;
}
@ -2105,7 +2104,7 @@ CreateJSThreadHangStats(JSContext* cx, const Telemetry::ThreadHangStats& thread)
NS_IMETHODIMP
TelemetryImpl::GetThreadHangStats(JSContext* cx, JS::MutableHandle<JS::Value> ret)
{
JS::RootedObject retObj(cx, JS_NewArrayObject(cx, 0, nullptr));
JS::RootedObject retObj(cx, JS_NewArrayObject(cx, 0));
if (!retObj) {
return NS_ERROR_FAILURE;
}

View File

@ -127,7 +127,7 @@ JSObjectBuilder::ArrayPush(JS::HandleObject aArray, JS::HandleObject aObject)
JSObject*
JSObjectBuilder::CreateArray() {
JSObject *array = JS_NewArrayObject(mCx, 0, nullptr);
JSObject *array = JS_NewArrayObject(mCx, 0);
if (!array)
mOk = false;