mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1602882 - Move array operations to a new js/Array.h header. r=sfink,bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D56595 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
60e3f6a6e1
commit
62a130ba0a
@ -9,6 +9,7 @@
|
||||
#include <google/protobuf/io/gzip_stream.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/Debug.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/UbiNodeBreadthFirst.h"
|
||||
@ -631,7 +632,7 @@ void HeapSnapshot::ComputeShortestPaths(JSContext* cx, uint64_t start,
|
||||
}
|
||||
}
|
||||
|
||||
RootedObject pathObj(cx, JS_NewArrayObject(cx, pathValues));
|
||||
RootedObject pathObj(cx, JS::NewArrayObject(cx, pathValues));
|
||||
return pathObj && paths.append(ObjectValue(*pathObj));
|
||||
});
|
||||
|
||||
@ -640,7 +641,7 @@ void HeapSnapshot::ComputeShortestPaths(JSContext* cx, uint64_t start,
|
||||
return;
|
||||
}
|
||||
|
||||
JS::RootedObject pathsArray(cx, JS_NewArrayObject(cx, paths));
|
||||
JS::RootedObject pathsArray(cx, JS::NewArrayObject(cx, paths));
|
||||
if (NS_WARN_IF(!pathsArray)) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "imgRequestProxy.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{GetArrayBufferData,IsArrayBufferObject,NewArrayBuffer}
|
||||
#include "js/JSON.h"
|
||||
#include "js/RegExp.h" // JS::ExecuteRegExpNoStatics, JS::NewUCRegExpObject, JS::RegExpFlags
|
||||
@ -9561,7 +9562,7 @@ nsresult nsContentUtils::CreateJSValueFromSequenceOfObject(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aTransfer.Length()));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, aTransfer.Length()));
|
||||
if (!array) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "xpcpublic.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/PropertySpec.h"
|
||||
#include "js/SliceBudget.h"
|
||||
#include "js/Wrapper.h"
|
||||
@ -728,7 +729,7 @@ nsresult nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget,
|
||||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> array(cx, ::JS_NewArrayObject(cx, args));
|
||||
JS::Rooted<JSObject*> array(cx, JS::NewArrayObject(cx, args));
|
||||
if (!array) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1135,14 +1135,17 @@ class CGHeaders(CGWrapper):
|
||||
headerSet = declareIncludes
|
||||
else:
|
||||
headerSet = bindingHeaders
|
||||
# Strip off outer layers and add headers they might (conservatively:
|
||||
# only nullable non-pointer types need Nullable.h, and only
|
||||
# sequences outside unions require ForOfIterator.h) require.
|
||||
# Strip off outer layers and add headers they might require. (This
|
||||
# is conservative: only nullable non-pointer types need Nullable.h;
|
||||
# only sequences outside unions need ForOfIterator.h; only functions
|
||||
# that return, and attributes that are, sequences in interfaces need
|
||||
# Array.h, &c.)
|
||||
unrolled = t
|
||||
while True:
|
||||
if unrolled.nullable():
|
||||
headerSet.add("mozilla/dom/Nullable.h")
|
||||
elif unrolled.isSequence():
|
||||
bindingHeaders.add("js/Array.h")
|
||||
bindingHeaders.add("js/ForOfIterator.h")
|
||||
else:
|
||||
break
|
||||
@ -6861,7 +6864,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
"""
|
||||
|
||||
uint32_t length = ${result}.Length();
|
||||
JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
|
||||
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
|
||||
if (!returnArray) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWrapperCache.h"
|
||||
@ -362,7 +363,7 @@ MOZ_MUST_USE bool ToJSValue(JSContext* aCx, T* aArguments, size_t aLength,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
JSObject* arrayObj = JS_NewArrayObject(aCx, v);
|
||||
JSObject* arrayObj = JS::NewArrayObject(aCx, v);
|
||||
if (!arrayObj) {
|
||||
return false;
|
||||
}
|
||||
|
5
dom/cache/Cache.cpp
vendored
5
dom/cache/Cache.cpp
vendored
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/dom/cache/Cache.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "mozilla/dom/Headers.h"
|
||||
#include "mozilla/dom/InternalResponse.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
@ -128,7 +129,7 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
|
||||
responseList.SetCapacity(mRequestList.Length());
|
||||
|
||||
bool isArray;
|
||||
if (NS_WARN_IF(!JS_IsArrayObject(aCx, aValue, &isArray) || !isArray)) {
|
||||
if (NS_WARN_IF(!JS::IsArrayObject(aCx, aValue, &isArray) || !isArray)) {
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
@ -136,7 +137,7 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
||||
|
||||
uint32_t length;
|
||||
if (NS_WARN_IF(!JS_GetArrayLength(aCx, obj, &length))) {
|
||||
if (NS_WARN_IF(!JS::GetArrayLength(aCx, obj, &length))) {
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "js/Conversions.h"
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/Warnings.h" // JS::WarnASCII
|
||||
@ -1899,7 +1900,7 @@ static void MatrixToJSObject(JSContext* aCx, const Matrix& aMatrix,
|
||||
static bool ObjectToMatrix(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
Matrix& aMatrix, ErrorResult& aError) {
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(aCx, aObj, &length) || length != 6) {
|
||||
if (!JS::GetArrayLength(aCx, aObj, &length) || length != 6) {
|
||||
// Not an array-like thing or wrong size
|
||||
aError.Throw(NS_ERROR_INVALID_ARG);
|
||||
return false;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
@ -121,7 +122,7 @@ nsresult JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
|
||||
if (!patternArray.isPrimitive()) {
|
||||
JS::Rooted<JSObject*> obj(cx, patternArray.toObjectOrNull());
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(cx, obj, &length)) {
|
||||
if (!JS::GetArrayLength(cx, obj, &length)) {
|
||||
// Not an array-like thing
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
} else if (length > MAX_NUM_DASHES) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "WebGL2Context.h"
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "WebGLBuffer.h"
|
||||
@ -165,7 +166,7 @@ void WebGL2Context::GetActiveUniforms(
|
||||
|
||||
const auto& count = uniformIndices.Length();
|
||||
|
||||
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
|
||||
JS::Rooted<JSObject*> array(cx, JS::NewArrayObject(cx, count));
|
||||
UniquePtr<GLint[]> samples(new GLint[count]);
|
||||
if (!array || !samples) {
|
||||
ErrorOutOfMemory("Failed to allocate buffers.");
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/dom/ConsoleBinding.h"
|
||||
#include "ConsoleCommon.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::NewArrayObject
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
@ -342,7 +343,7 @@ class ConsoleRunnable : public StructuredCloneHolderBase {
|
||||
ConsoleCommon::ClearException ce(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> arguments(
|
||||
aCx, JS_NewArrayObject(aCx, aCallData->mCopiedArguments.Length()));
|
||||
aCx, JS::NewArrayObject(aCx, aCallData->mCopiedArguments.Length()));
|
||||
if (NS_WARN_IF(!arguments)) {
|
||||
return false;
|
||||
}
|
||||
@ -381,7 +382,7 @@ class ConsoleRunnable : public StructuredCloneHolderBase {
|
||||
JS::Rooted<JSObject*> argumentsObj(aCx, &argumentsValue.toObject());
|
||||
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(aCx, argumentsObj, &length)) {
|
||||
if (!JS::GetArrayLength(aCx, argumentsObj, &length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -421,7 +422,7 @@ class ConsoleRunnable : public StructuredCloneHolderBase {
|
||||
ConsoleCommon::ClearException ce(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> arguments(
|
||||
aCx, JS_NewArrayObject(aCx, aArguments.Length()));
|
||||
aCx, JS::NewArrayObject(aCx, aArguments.Length()));
|
||||
if (NS_WARN_IF(!arguments)) {
|
||||
return false;
|
||||
}
|
||||
@ -465,7 +466,7 @@ class ConsoleRunnable : public StructuredCloneHolderBase {
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(aCx, argumentsObj, &length)) {
|
||||
if (!JS::GetArrayLength(aCx, argumentsObj, &length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "FileSystemDirectoryReader.h"
|
||||
#include "CallbackRunnables.h"
|
||||
#include "FileSystemFileEntry.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/dom/FileBinding.h"
|
||||
#include "mozilla/dom/FileSystemUtils.h"
|
||||
#include "mozilla/dom/Directory.h"
|
||||
@ -46,7 +47,7 @@ class PromiseHandler final : public PromiseNativeHandler {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
||||
|
||||
uint32_t length;
|
||||
if (NS_WARN_IF(!JS_GetArrayLength(aCx, obj, &length))) {
|
||||
if (NS_WARN_IF(!JS::GetArrayLength(aCx, obj, &length))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "IDBTransaction.h"
|
||||
#include "IndexedDatabase.h"
|
||||
#include "IndexedDatabaseInlines.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject, JS::SetArrayLength
|
||||
#include <mozIIPCBlobInputStream.h>
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
@ -401,7 +402,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
|
||||
nsresult GetResult(JSContext* aCx,
|
||||
const nsTArray<StructuredCloneReadInfo>* aCloneInfos,
|
||||
JS::MutableHandle<JS::Value> aResult) {
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (NS_WARN_IF(!array)) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
@ -410,7 +411,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
|
||||
if (!aCloneInfos->IsEmpty()) {
|
||||
const uint32_t count = aCloneInfos->Length();
|
||||
|
||||
if (NS_WARN_IF(!JS_SetArrayLength(aCx, array, count))) {
|
||||
if (NS_WARN_IF(!JS::SetArrayLength(aCx, array, count))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
@ -449,7 +450,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
|
||||
|
||||
nsresult GetResult(JSContext* aCx, const nsTArray<Key>* aKeys,
|
||||
JS::MutableHandle<JS::Value> aResult) {
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (NS_WARN_IF(!array)) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
@ -458,7 +459,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
|
||||
if (!aKeys->IsEmpty()) {
|
||||
const uint32_t count = aKeys->Length();
|
||||
|
||||
if (NS_WARN_IF(!JS_SetArrayLength(aCx, array, count))) {
|
||||
if (NS_WARN_IF(!JS::SetArrayLength(aCx, array, count))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "IndexedDatabase.h"
|
||||
#include "IndexedDatabaseInlines.h"
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/Class.h"
|
||||
#include "js/Date.h"
|
||||
#include "js/StructuredClone.h"
|
||||
@ -963,7 +964,7 @@ void IDBObjectStore::AppendIndexUpdateInfo(
|
||||
}
|
||||
|
||||
bool isArray;
|
||||
if (NS_WARN_IF(!JS_IsArrayObject(aCx, val, &isArray))) {
|
||||
if (NS_WARN_IF(!JS::IsArrayObject(aCx, val, &isArray))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
aRv->Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
@ -971,7 +972,7 @@ void IDBObjectStore::AppendIndexUpdateInfo(
|
||||
if (isArray) {
|
||||
JS::Rooted<JSObject*> array(aCx, &val.toObject());
|
||||
uint32_t arrayLength;
|
||||
if (NS_WARN_IF(!JS_GetArrayLength(aCx, array, &arrayLength))) {
|
||||
if (NS_WARN_IF(!JS::GetArrayLength(aCx, array, &arrayLength))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
aRv->Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <algorithm>
|
||||
#include <stdint.h> // for UINT32_MAX, uintptr_t
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{IsArrayBufferObject,NewArrayBuffer{,WithContents},GetArrayBufferLengthAndData}
|
||||
#include "js/Date.h"
|
||||
#include "js/MemoryFunctions.h"
|
||||
@ -392,7 +393,7 @@ nsresult Key::DecodeJSValInternal(const EncodedDataType*& aPos,
|
||||
}
|
||||
|
||||
if (*aPos - aTypeOffset >= eArray) {
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!array) {
|
||||
NS_WARNING("Failed to make array!");
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBResult.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "js/RootingAPI.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
@ -195,7 +196,7 @@ class Key {
|
||||
ArrayConversionPolicy&& aPolicy, ErrorResult& aRv) {
|
||||
// 1. Let `len` be ? ToLength( ? Get(`input`, "length")).
|
||||
uint32_t len;
|
||||
if (!JS_GetArrayLength(aCx, aObject, &len)) {
|
||||
if (!JS::GetArrayLength(aCx, aObject, &len)) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return Exception;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsPrintfCString.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/Blob.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
@ -373,7 +374,7 @@ nsresult KeyPath::ExtractKeyAsJSVal(JSContext* aCx, const JS::Value& aValue,
|
||||
}
|
||||
|
||||
const uint32_t len = mStrings.Length();
|
||||
JS::Rooted<JSObject*> arrayObj(aCx, JS_NewArrayObject(aCx, len));
|
||||
JS::Rooted<JSObject*> arrayObj(aCx, JS::NewArrayObject(aCx, len));
|
||||
if (!arrayObj) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -488,7 +489,7 @@ nsresult 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));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, len));
|
||||
if (!array) {
|
||||
IDB_WARNING("Failed to make array!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/dom/indexedDB/Key.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h"
|
||||
|
||||
// TODO: This PrintTo overload is defined in dom/media/gtest/TestGroupId.cpp.
|
||||
@ -108,7 +109,7 @@ static JSObject& ExpectArrayObject(JSContext* const aContext,
|
||||
EXPECT_TRUE(aValue.get().isObject());
|
||||
auto&& value = JS::RootedValue(aContext, aValue.get());
|
||||
bool rv;
|
||||
EXPECT_TRUE(JS_IsArrayObject(aContext, value, &rv));
|
||||
EXPECT_TRUE(JS::IsArrayObject(aContext, value, &rv));
|
||||
EXPECT_TRUE(rv);
|
||||
return value.toObject();
|
||||
}
|
||||
@ -294,7 +295,7 @@ static void CheckArray(JSContext* const context,
|
||||
JS::RootedObject(context, &ExpectArrayObject(context, arrayValue));
|
||||
|
||||
uint32_t actualLength;
|
||||
EXPECT_TRUE(JS_GetArrayLength(context, actualArray, &actualLength));
|
||||
EXPECT_TRUE(JS::GetArrayLength(context, actualArray, &actualLength));
|
||||
EXPECT_EQ(expectedLength, actualLength);
|
||||
for (size_t i = 0; i < expectedLength; ++i) {
|
||||
JS::RootedValue element(static_cast<JSContext*>(context));
|
||||
@ -306,7 +307,7 @@ static void CheckArray(JSContext* const context,
|
||||
|
||||
static JS::RootedValue CreateArrayBufferArray(
|
||||
JSContext* const context, const std::vector<nsCString>& elements) {
|
||||
auto* const array = JS_NewArrayObject(context, elements.size());
|
||||
auto* const array = JS::NewArrayObject(context, elements.size());
|
||||
auto&& arrayObject = JS::RootedObject{context, array};
|
||||
|
||||
for (size_t i = 0; i < elements.size(); ++i) {
|
||||
@ -358,7 +359,7 @@ static JS::RootedValue CreateStringValue(JSContext* const context,
|
||||
|
||||
static JS::RootedValue CreateStringArray(
|
||||
JSContext* const context, const std::vector<nsString>& elements) {
|
||||
auto* const array = JS_NewArrayObject(context, elements.size());
|
||||
auto* const array = JS::NewArrayObject(context, elements.size());
|
||||
auto&& arrayObject = JS::RootedObject{context, array};
|
||||
|
||||
for (size_t i = 0; i < elements.size(); ++i) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "AudioNodeTrack.h"
|
||||
#include "AudioWorkletImpl.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "mozilla/dom/AudioWorkletGlobalScopeBinding.h"
|
||||
#include "mozilla/dom/AudioWorkletProcessor.h"
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
@ -153,8 +154,8 @@ void AudioWorkletGlobalScope::RegisterProcessor(
|
||||
* TypeError and abort these steps.
|
||||
*/
|
||||
bool isArray = false;
|
||||
if (!JS_IsArrayObject(aCx, descriptors, &isArray)) {
|
||||
// I would assume isArray won't be set to true if JS_IsArrayObject
|
||||
if (!JS::IsArrayObject(aCx, descriptors, &isArray)) {
|
||||
// I would assume isArray won't be set to true if JS::IsArrayObject
|
||||
// failed, but just in case, force it to false
|
||||
isArray = false;
|
||||
JS_ClearPendingException(aCx);
|
||||
@ -233,7 +234,7 @@ AudioParamDescriptorMap AudioWorkletGlobalScope::DescriptorsFromJS(
|
||||
|
||||
JS::Rooted<JSObject*> aDescriptorsArray(aCx, &aDescriptors.toObject());
|
||||
uint32_t length = 0;
|
||||
if (!JS_GetArrayLength(aCx, aDescriptorsArray, &length)) {
|
||||
if (!JS::GetArrayLength(aCx, aDescriptorsArray, &length)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return AudioParamDescriptorMap();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "AudioWorkletNode.h"
|
||||
|
||||
#include "AudioParamMap.h"
|
||||
#include "js/Array.h" // JS::{Get,Set}ArrayLength, JS::NewArrayLength
|
||||
#include "mozilla/dom/AudioWorkletNodeBinding.h"
|
||||
#include "mozilla/dom/MessageChannel.h"
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
@ -184,15 +185,15 @@ static bool PrepareArray(JSContext* aCx, const T& aElements,
|
||||
if (aArray) {
|
||||
// Attempt to reuse.
|
||||
uint32_t oldLength;
|
||||
if (JS_GetArrayLength(aCx, aArray, &oldLength) &&
|
||||
(oldLength == length || JS_SetArrayLength(aCx, aArray, length)) &&
|
||||
if (JS::GetArrayLength(aCx, aArray, &oldLength) &&
|
||||
(oldLength == length || JS::SetArrayLength(aCx, aArray, length)) &&
|
||||
SetArrayElements(aCx, aElements, aArray)) {
|
||||
return true;
|
||||
}
|
||||
// Script may have frozen the array. Try again with a new Array.
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
JSObject* array = JS_NewArrayObject(aCx, length);
|
||||
JSObject* array = JS::NewArrayObject(aCx, length);
|
||||
if (NS_WARN_IF(!array)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/dom/ReportingHeader.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/JSON.h"
|
||||
#include "mozilla/dom/ReportingBinding.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
@ -272,13 +273,13 @@ void ReportingHeader::ReportingFromChannel(nsIHttpChannel* aChannel) {
|
||||
MOZ_ASSERT(endpoints);
|
||||
|
||||
bool isArray = false;
|
||||
if (!JS_IsArrayObject(cx, endpoints, &isArray) || !isArray) {
|
||||
if (!JS::IsArrayObject(cx, endpoints, &isArray) || !isArray) {
|
||||
LogToConsoleIncompleteItem(aChannel, aURI, groupName);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t endpointsLength;
|
||||
if (!JS_GetArrayLength(cx, endpoints, &endpointsLength) ||
|
||||
if (!JS::GetArrayLength(cx, endpoints, &endpointsLength) ||
|
||||
endpointsLength == 0) {
|
||||
LogToConsoleIncompleteItem(aChannel, aURI, groupName);
|
||||
continue;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "prsystem.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/MemoryFunctions.h"
|
||||
#include "js/Modules.h" // JS::FinishDynamicModuleImport, JS::{G,S}etModuleResolveHook, JS::Get{ModulePrivate,ModuleScript,RequestedModule{s,Specifier,SourcePos}}, JS::SetModule{DynamicImport,Metadata}Hook
|
||||
@ -670,7 +671,7 @@ static nsresult ResolveRequestedModules(ModuleLoadRequest* aRequest,
|
||||
MOZ_ASSERT(requestedModules);
|
||||
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(cx, requestedModules, &length)) {
|
||||
if (!JS::GetArrayLength(cx, requestedModules, &length)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
# include <wininet.h>
|
||||
#endif
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/StaticPrefs_extensions.h"
|
||||
@ -82,7 +83,7 @@ nsresult RegexEval(const nsAString& aPattern, const nsAString& aString,
|
||||
// Now we know we have a result, and we need to extract it so we can read it.
|
||||
uint32_t length;
|
||||
JS::RootedObject regexResultObj(cx, ®exResult.toObject());
|
||||
if (!JS_GetArrayLength(cx, regexResultObj, &length)) {
|
||||
if (!JS::GetArrayLength(cx, regexResultObj, &length)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
MOZ_LOG(sCSMLog, LogLevel::Verbose, ("Regex Matched %i strings", length));
|
||||
@ -792,4 +793,4 @@ bool nsContentSecurityUtils::ValidateScriptFilename(const char* aFilename,
|
||||
// we're only reporting Telemetry. In the future we will assert in debug
|
||||
// builds and return false to prevent execution in non-debug builds.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ServiceWorkerScriptCache.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "mozilla/SystemGroup.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/CacheBinding.h"
|
||||
@ -390,7 +392,7 @@ class CompareManager final : public PromiseNativeHandler {
|
||||
}
|
||||
|
||||
uint32_t len = 0;
|
||||
if (!JS_GetArrayLength(aCx, obj, &len)) {
|
||||
if (!JS::GetArrayLength(aCx, obj, &len)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
121
js/public/Array.h
Normal file
121
js/public/Array.h
Normal file
@ -0,0 +1,121 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* Array-related operations. */
|
||||
|
||||
#ifndef js_Array_h
|
||||
#define js_Array_h
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
#include <stdint.h> // uint32_t
|
||||
|
||||
#include "jstypes.h" // JS_PUBLIC_API
|
||||
|
||||
#include "js/RootingAPI.h" // JS::Handle
|
||||
#include "js/Value.h" // JS::Value
|
||||
|
||||
struct JS_PUBLIC_API JSContext;
|
||||
class JS_PUBLIC_API JSObject;
|
||||
|
||||
namespace JS {
|
||||
|
||||
class HandleValueArray;
|
||||
|
||||
/**
|
||||
* Create an Array from the current realm with the given contents.
|
||||
*/
|
||||
extern JS_PUBLIC_API JSObject* NewArrayObject(JSContext* cx,
|
||||
const HandleValueArray& contents);
|
||||
|
||||
/**
|
||||
* Create an Array from the current realm with the given length and allocate
|
||||
* memory for all its elements. (The elements nonetheless will not exist as
|
||||
* properties on the returned array until values have been assigned to them.)
|
||||
*/
|
||||
extern JS_PUBLIC_API JSObject* NewArrayObject(JSContext* cx, size_t length);
|
||||
|
||||
/**
|
||||
* Determine whether |value| is an Array object or a wrapper around one. (An
|
||||
* ES6 proxy whose target is an Array object, e.g.
|
||||
* |var target = [], handler = {}; Proxy.revocable(target, handler).proxy|, is
|
||||
* not considered to be an Array.)
|
||||
*
|
||||
* On success set |*isArray| accordingly and return true; on failure return
|
||||
* false.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArrayObject(JSContext* cx, Handle<Value> value,
|
||||
bool* isArray);
|
||||
|
||||
/**
|
||||
* Determine whether |obj| is an Array object or a wrapper around one. (An
|
||||
* ES6 proxy whose target is an Array object, e.g.
|
||||
* |var target = [], handler = {}; Proxy.revocable(target, handler).proxy|, is
|
||||
* not considered to be an Array.)
|
||||
*
|
||||
* On success set |*isArray| accordingly and return true; on failure return
|
||||
* false.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArrayObject(JSContext* cx, Handle<JSObject*> obj,
|
||||
bool* isArray);
|
||||
|
||||
/**
|
||||
* Store |*lengthp = ToLength(obj.length)| and return true on success, else
|
||||
* return false.
|
||||
*
|
||||
* |ToLength| converts its input to an integer usable to index an
|
||||
* array-like object.
|
||||
*
|
||||
* If |obj| is an Array, this overall operation is the same as getting
|
||||
* |obj.length|.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool GetArrayLength(JSContext* cx, Handle<JSObject*> obj,
|
||||
uint32_t* lengthp);
|
||||
|
||||
/**
|
||||
* Perform |obj.length = length| as if in strict mode code, with a fast path for
|
||||
* the case where |obj| is an Array.
|
||||
*
|
||||
* This operation is exactly and only assigning to a "length" property. In
|
||||
* general, it can invoke an existing "length" setter, throw if the property is
|
||||
* non-writable, or do anything else a property-set operation might do.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool SetArrayLength(JSContext* cx, Handle<JSObject*> obj,
|
||||
uint32_t length);
|
||||
|
||||
/**
|
||||
* The answer to a successful query as to whether an object is an Array per
|
||||
* ES6's internal |IsArray| operation (as exposed by |Array.isArray|).
|
||||
*/
|
||||
enum class IsArrayAnswer { Array, NotArray, RevokedProxy };
|
||||
|
||||
/**
|
||||
* ES6 7.2.2.
|
||||
*
|
||||
* Returns false on failure, otherwise returns true and sets |*isArray|
|
||||
* indicating whether the object passes ECMAScript's IsArray test. This is the
|
||||
* same test performed by |Array.isArray|.
|
||||
*
|
||||
* This is NOT the same as asking whether |obj| is an Array or a wrapper around
|
||||
* one. If |obj| is a proxy created by |Proxy.revocable()| and has been
|
||||
* revoked, or if |obj| is a proxy whose target (at any number of hops) is a
|
||||
* revoked proxy, this method throws a TypeError and returns false.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArray(JSContext* cx, Handle<JSObject*> obj,
|
||||
bool* isArray);
|
||||
|
||||
/**
|
||||
* Identical to IsArray above, but the nature of the object (if successfully
|
||||
* determined) is communicated via |*answer|. In particular this method
|
||||
* returns true and sets |*answer = IsArrayAnswer::RevokedProxy| when called on
|
||||
* a revoked proxy.
|
||||
*
|
||||
* Most users will want the overload above, not this one.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArray(JSContext* cx, Handle<JSObject*> obj,
|
||||
IsArrayAnswer* answer);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // js_Array_h
|
@ -39,38 +39,6 @@ extern JS_FRIEND_DATA const JSClass* const FunctionClassPtr;
|
||||
|
||||
namespace JS {
|
||||
|
||||
/**
|
||||
* The answer to a successful query as to whether an object is an Array per
|
||||
* ES6's internal |IsArray| operation (as exposed by |Array.isArray|).
|
||||
*/
|
||||
enum class IsArrayAnswer { Array, NotArray, RevokedProxy };
|
||||
|
||||
/**
|
||||
* ES6 7.2.2.
|
||||
*
|
||||
* Returns false on failure, otherwise returns true and sets |*isArray|
|
||||
* indicating whether the object passes ECMAScript's IsArray test. This is the
|
||||
* same test performed by |Array.isArray|.
|
||||
*
|
||||
* This is NOT the same as asking whether |obj| is an Array or a wrapper around
|
||||
* one. If |obj| is a proxy created by |Proxy.revocable()| and has been
|
||||
* revoked, or if |obj| is a proxy whose target (at any number of hops) is a
|
||||
* revoked proxy, this method throws a TypeError and returns false.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArray(JSContext* cx, HandleObject obj,
|
||||
bool* isArray);
|
||||
|
||||
/**
|
||||
* Identical to IsArray above, but the nature of the object (if successfully
|
||||
* determined) is communicated via |*answer|. In particular this method
|
||||
* returns true and sets |*answer = IsArrayAnswer::RevokedProxy| when called on
|
||||
* a revoked proxy.
|
||||
*
|
||||
* Most users will want the overload above, not this one.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool IsArray(JSContext* cx, HandleObject obj,
|
||||
IsArrayAnswer* answer);
|
||||
|
||||
/**
|
||||
* Per ES6, the [[DefineOwnProperty]] internal method has three different
|
||||
* possible outcomes:
|
||||
|
@ -149,7 +149,7 @@ extern JS_PUBLIC_API bool ModuleEvaluate(JSContext* cx,
|
||||
* record to request importation of modules.
|
||||
*
|
||||
* The result is a JavaScript array of object values. To extract the individual
|
||||
* values use only JS_GetArrayLength and JS_GetElement with indices 0 to length
|
||||
* values use only JS::GetArrayLength and JS_GetElement with indices 0 to length
|
||||
* - 1.
|
||||
*
|
||||
* The element values are objects with the following properties:
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "js/Array.h" // JS::IsArrayAnswer
|
||||
#include "js/CallNonGenericMethod.h"
|
||||
#include "js/Class.h"
|
||||
|
||||
|
@ -359,7 +359,7 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
||||
"JS_GlobalObjectTraceHook",
|
||||
"JS::HideScriptedCaller",
|
||||
"JS::InitRealmStandardClasses",
|
||||
"JS_IsArrayObject",
|
||||
"JS::IsArrayObject",
|
||||
"JS_IsExceptionPending",
|
||||
"JS_IsGlobalObject",
|
||||
"JS::IsCallable",
|
||||
@ -367,7 +367,7 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
||||
"JS_LinkConstructorAndPrototype",
|
||||
"JS_MayResolveStandardClass",
|
||||
"JS::NewArrayBuffer",
|
||||
"JS_NewArrayObject",
|
||||
"JS::NewArrayObject",
|
||||
"JS_NewContext",
|
||||
"JS_NewFloat32Array",
|
||||
"JS_NewFloat64Array",
|
||||
|
@ -13,6 +13,7 @@ typedef uint32_t HashNumber;
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h"
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/CompileOptions.h"
|
||||
|
@ -614,7 +614,7 @@ impl<T: FromJSValConvertible> FromJSValConvertible for Option<T> {
|
||||
impl<T: ToJSValConvertible> ToJSValConvertible for Vec<T> {
|
||||
#[inline]
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: JS::MutableHandleValue) {
|
||||
rooted!(in(cx) let js_array = JS_NewArrayObject1(cx, self.len() as libc::size_t));
|
||||
rooted!(in(cx) let js_array = JS::NewArrayObject1(cx, self.len() as libc::size_t));
|
||||
assert!(!js_array.handle().is_null());
|
||||
|
||||
rooted!(in(cx) let mut val = UndefinedValue());
|
||||
|
@ -23,7 +23,7 @@ fn assert_is_array(cx: *mut js::jsapi::root::JSContext,
|
||||
val: js::jsapi::root::JS::HandleValue) {
|
||||
let mut is_array = false;
|
||||
assert!(unsafe {
|
||||
js::jsapi::root::JS_IsArrayObject(cx, val, &mut is_array as *mut _)
|
||||
js::jsapi::root::JS::IsArrayObject(cx, val, &mut is_array as *mut _)
|
||||
});
|
||||
assert!(is_array);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "vm/Caches-inl.h"
|
||||
#include "vm/GeckoProfiler-inl.h"
|
||||
#include "vm/Interpreter-inl.h"
|
||||
#include "vm/IsGivenTypeObject-inl.h"
|
||||
#include "vm/JSAtom-inl.h"
|
||||
#include "vm/NativeObject-inl.h"
|
||||
|
||||
@ -4519,3 +4520,55 @@ bool js::ArraySpeciesLookup::tryOptimizeArray(JSContext* cx,
|
||||
MOZ_ASSERT(JSID_IS_ATOM(shape->propidRaw(), cx->names().length));
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewArrayObject(JSContext* cx,
|
||||
const HandleValueArray& contents) {
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(contents);
|
||||
|
||||
return NewDenseCopiedArray(cx, contents.length(), contents.begin());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewArrayObject(JSContext* cx, size_t length) {
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
|
||||
return NewDenseFullyAllocatedArray(cx, length);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::IsArrayObject(JSContext* cx, Handle<JSObject*> obj,
|
||||
bool* isArray) {
|
||||
return IsGivenTypeObject(cx, obj, ESClass::Array, isArray);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::IsArrayObject(JSContext* cx, Handle<Value> value,
|
||||
bool* isArray) {
|
||||
if (!value.isObject()) {
|
||||
*isArray = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Rooted<JSObject*> obj(cx, &value.toObject());
|
||||
return IsArrayObject(cx, obj, isArray);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::GetArrayLength(JSContext* cx, Handle<JSObject*> obj,
|
||||
uint32_t* lengthp) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(obj);
|
||||
|
||||
return GetLengthProperty(cx, obj, lengthp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::SetArrayLength(JSContext* cx, Handle<JSObject*> obj,
|
||||
uint32_t length) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(obj);
|
||||
|
||||
return SetLengthProperty(cx, obj, length);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "jit/BaselineJIT.h"
|
||||
#include "jit/InlinableNatives.h"
|
||||
#include "jit/JitRealm.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{DetachArrayBuffer,GetArrayBufferLengthAndData,NewArrayBufferWithContents}
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
@ -904,7 +905,7 @@ static bool WasmTextToBinary(JSContext* cx, unsigned argc, Value* vp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject jsOffsets(cx, JS_NewArrayObject(cx, offsets.length()));
|
||||
RootedObject jsOffsets(cx, JS::NewArrayObject(cx, offsets.length()));
|
||||
if (!jsOffsets) {
|
||||
return false;
|
||||
}
|
||||
@ -2002,7 +2003,7 @@ static bool EnsureLinearString(JSContext* cx, unsigned argc, Value* vp) {
|
||||
static bool RepresentativeStringArray(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
RootedObject array(cx, JS_NewArrayObject(cx, 0));
|
||||
RootedObject array(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -4746,7 +4747,7 @@ static bool GetMarkQueue(JSContext* cx, unsigned argc, Value* vp) {
|
||||
|
||||
auto& queue = cx->runtime()->gc.marker.markQueue.get();
|
||||
|
||||
RootedObject result(cx, JS_NewArrayObject(cx, queue.length()));
|
||||
RootedObject result(cx, JS::NewArrayObject(cx, queue.length()));
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
@ -5029,7 +5030,7 @@ static JSObject* ConvertRegExpTreeToObject(JSContext* cx, LifoAlloc& alloc,
|
||||
JSContext* cx, HandleObject obj, const char* name,
|
||||
const irregexp::RegExpTreeVector& nodes) {
|
||||
size_t len = nodes.length();
|
||||
RootedObject array(cx, JS_NewArrayObject(cx, len));
|
||||
RootedObject array(cx, JS::NewArrayObject(cx, len));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -5052,7 +5053,7 @@ static JSObject* ConvertRegExpTreeToObject(JSContext* cx, LifoAlloc& alloc,
|
||||
JSContext* cx, HandleObject obj, const char* name,
|
||||
const irregexp::CharacterRangeVector& ranges) {
|
||||
size_t len = ranges.length();
|
||||
RootedObject array(cx, JS_NewArrayObject(cx, len));
|
||||
RootedObject array(cx, JS::NewArrayObject(cx, len));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -5093,7 +5094,7 @@ static JSObject* ConvertRegExpTreeToObject(JSContext* cx, LifoAlloc& alloc,
|
||||
JSContext* cx, HandleObject obj, const char* name,
|
||||
const irregexp::TextElementVector& elements) {
|
||||
size_t len = elements.length();
|
||||
RootedObject array(cx, JS_NewArrayObject(cx, len));
|
||||
RootedObject array(cx, JS::NewArrayObject(cx, len));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "gc/FreeOp.h"
|
||||
#include "gc/Policy.h"
|
||||
#include "jit/AtomicOperations.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{IsArrayBufferObject,GetArrayBufferData,GetArrayBuffer{ByteLength,Data}}
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/PropertySpec.h"
|
||||
@ -3504,7 +3505,7 @@ static bool ImplicitConvert(JSContext* cx, HandleValue val,
|
||||
if (cls == ESClass::Array) {
|
||||
// Convert each element of the array by calling ImplicitConvert.
|
||||
uint32_t sourceLength;
|
||||
if (!JS_GetArrayLength(cx, valObj, &sourceLength) ||
|
||||
if (!JS::GetArrayLength(cx, valObj, &sourceLength) ||
|
||||
targetLength != size_t(sourceLength)) {
|
||||
MOZ_ASSERT(!funObj);
|
||||
return ArrayLengthMismatch(cx, targetLength, targetType,
|
||||
@ -5791,7 +5792,7 @@ bool StructType::Create(JSContext* cx, unsigned argc, Value* vp) {
|
||||
if (!arr) {
|
||||
isArray = false;
|
||||
} else {
|
||||
if (!JS_IsArrayObject(cx, arr, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, arr, &isArray)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -5815,7 +5816,7 @@ bool StructType::DefineInternal(JSContext* cx, JSObject* typeObj_,
|
||||
RootedObject fieldsObj(cx, fieldsObj_);
|
||||
|
||||
uint32_t len;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(cx, fieldsObj, &len));
|
||||
MOZ_ALWAYS_TRUE(JS::GetArrayLength(cx, fieldsObj, &len));
|
||||
|
||||
// Get the common prototype for CData objects of this type from
|
||||
// ctypes.CType.prototype.
|
||||
@ -6070,7 +6071,7 @@ bool StructType::Define(JSContext* cx, unsigned argc, Value* vp) {
|
||||
if (!arg.isObject()) {
|
||||
isArray = false;
|
||||
} else {
|
||||
if (!JS_IsArrayObject(cx, arg, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, arg, &isArray)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -6211,7 +6212,7 @@ JSObject* StructType::BuildFieldsArray(JSContext* cx, JSObject* obj) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RootedObject fieldsProp(cx, JS_NewArrayObject(cx, fieldsVec));
|
||||
RootedObject fieldsProp(cx, JS::NewArrayObject(cx, fieldsVec));
|
||||
if (!fieldsProp) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -6729,7 +6730,7 @@ bool FunctionType::Create(JSContext* cx, unsigned argc, Value* vp) {
|
||||
if (!args[2].isObject()) {
|
||||
isArray = false;
|
||||
} else {
|
||||
if (!JS_IsArrayObject(cx, args[2], &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, args[2], &isArray)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -6741,7 +6742,7 @@ bool FunctionType::Create(JSContext* cx, unsigned argc, Value* vp) {
|
||||
arrayObj = &args[2].toObject();
|
||||
|
||||
uint32_t len;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(cx, arrayObj, &len));
|
||||
MOZ_ALWAYS_TRUE(JS::GetArrayLength(cx, arrayObj, &len));
|
||||
|
||||
if (!argTypes.resize(len)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
@ -7092,7 +7093,7 @@ bool FunctionType::ArgTypesGetter(JSContext* cx, const JS::CallArgs& args) {
|
||||
vec[i].setObject(*fninfo->mArgTypes[i]);
|
||||
}
|
||||
|
||||
argTypes = JS_NewArrayObject(cx, vec);
|
||||
argTypes = JS::NewArrayObject(cx, vec);
|
||||
if (!argTypes) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "gc/Barrier.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "vm/JSFunction.h"
|
||||
|
||||
FRAGMENT(Root, null) {
|
||||
@ -31,7 +32,7 @@ FRAGMENT(Root, HeapSlot) {
|
||||
JS::Rooted<JS::Value> plinth(
|
||||
cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth")));
|
||||
JS::Rooted<JSObject*> array(
|
||||
cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth)));
|
||||
cx, JS::NewArrayObject(cx, JS::HandleValueArray(plinth)));
|
||||
|
||||
breakpoint();
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
static int callCount = 0;
|
||||
@ -33,7 +34,7 @@ BEGIN_TEST(testAddPropertyHook) {
|
||||
JS_InitClass(cx, global, obj, &AddPropertyClass, nullptr, 0, nullptr, nullptr,
|
||||
nullptr, nullptr);
|
||||
|
||||
obj = JS_NewArrayObject(cx, 0);
|
||||
obj = JS::NewArrayObject(cx, 0);
|
||||
CHECK(obj);
|
||||
JS::RootedValue arr(cx, JS::ObjectValue(*obj));
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "builtin/TestingFunctions.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{GetArrayBuffer{ByteLength,Data},IsArrayBufferObject,NewArrayBuffer{,WithContents},StealArrayBufferContents}
|
||||
#include "js/MemoryFunctions.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
@ -260,7 +261,7 @@ BEGIN_TEST(testArrayBuffer_serializeExternal) {
|
||||
|
||||
JS::RootedValue v(cx, JS::ObjectValue(*externalBuffer));
|
||||
JS::RootedObject transferMap(cx,
|
||||
JS_NewArrayObject(cx, JS::HandleValueArray(v)));
|
||||
JS::NewArrayObject(cx, JS::HandleValueArray(v)));
|
||||
CHECK(transferMap);
|
||||
|
||||
JS::AutoValueArray<2> args(cx);
|
||||
|
@ -5,6 +5,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/Symbol.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
@ -12,7 +13,7 @@ BEGIN_TEST(testInformalValueTypeName) {
|
||||
JS::RootedValue v1(cx, JS::ObjectOrNullValue(JS_NewPlainObject(cx)));
|
||||
CHECK(strcmp(JS::InformalValueTypeName(v1), "Object") == 0);
|
||||
|
||||
JS::RootedValue v2(cx, JS::ObjectOrNullValue(JS_NewArrayObject(cx, 0)));
|
||||
JS::RootedValue v2(cx, JS::ObjectOrNullValue(JS::NewArrayObject(cx, 0)));
|
||||
CHECK(strcmp(JS::InformalValueTypeName(v2), "Array") == 0);
|
||||
|
||||
JS::RootedValue v3(cx, JS::StringValue(JS_GetEmptyString(cx)));
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{{Create,Release}MappedArrayBufferContents,DetachArrayBuffer,GetArrayBuffer{ByteLength,Data},Is{,Detached,Mapped}ArrayBufferObject,NewMappedArrayBufferWithContents,StealArrayBufferContents}
|
||||
#include "js/StructuredClone.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
@ -167,7 +168,7 @@ bool TestTransferObject() {
|
||||
}
|
||||
|
||||
JS::RootedObject obj(
|
||||
cx, JS_NewArrayObject(cx, JS::HandleValueArray::subarray(argv, 0, 1)));
|
||||
cx, JS::NewArrayObject(cx, JS::HandleValueArray::subarray(argv, 0, 1)));
|
||||
CHECK(obj);
|
||||
JS::RootedValue transferable(cx, JS::ObjectValue(*obj));
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
static bool constructHook(JSContext* cx, unsigned argc, JS::Value* vp) {
|
||||
@ -66,10 +67,10 @@ BEGIN_TEST(testNewObject_1) {
|
||||
JS::RootedObject obj(cx, JS_New(cx, Array, JS::HandleValueArray::empty()));
|
||||
CHECK(obj);
|
||||
JS::RootedValue rt(cx, JS::ObjectValue(*obj));
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(isArray);
|
||||
uint32_t len;
|
||||
CHECK(JS_GetArrayLength(cx, obj, &len));
|
||||
CHECK(JS::GetArrayLength(cx, obj, &len));
|
||||
CHECK_EQUAL(len, 0u);
|
||||
|
||||
// With one argument.
|
||||
@ -77,9 +78,9 @@ BEGIN_TEST(testNewObject_1) {
|
||||
obj = JS_New(cx, Array, JS::HandleValueArray::subarray(argv, 0, 1));
|
||||
CHECK(obj);
|
||||
rt = JS::ObjectValue(*obj);
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(isArray);
|
||||
CHECK(JS_GetArrayLength(cx, obj, &len));
|
||||
CHECK(JS::GetArrayLength(cx, obj, &len));
|
||||
CHECK_EQUAL(len, 4u);
|
||||
|
||||
// With N arguments.
|
||||
@ -89,9 +90,9 @@ BEGIN_TEST(testNewObject_1) {
|
||||
obj = JS_New(cx, Array, JS::HandleValueArray::subarray(argv, 0, N));
|
||||
CHECK(obj);
|
||||
rt = JS::ObjectValue(*obj);
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(isArray);
|
||||
CHECK(JS_GetArrayLength(cx, obj, &len));
|
||||
CHECK(JS::GetArrayLength(cx, obj, &len));
|
||||
CHECK_EQUAL(len, N);
|
||||
CHECK(JS_GetElement(cx, obj, N - 1, &v));
|
||||
CHECK(v.isInt32(N - 1));
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <limits>
|
||||
#include <string.h>
|
||||
|
||||
#include "js/Array.h" // JS::IsArrayObject
|
||||
#include "js/JSON.h"
|
||||
#include "js/MemoryFunctions.h"
|
||||
#include "js/Printf.h"
|
||||
@ -118,7 +119,7 @@ BEGIN_TEST(testParseJSON_success) {
|
||||
CHECK(Parse(cx, "[]", &v));
|
||||
CHECK(v.isObject());
|
||||
obj = &v.toObject();
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(isArray);
|
||||
CHECK(JS_GetProperty(cx, obj, "length", &v2));
|
||||
CHECK(v2.isInt32(0));
|
||||
@ -126,7 +127,7 @@ BEGIN_TEST(testParseJSON_success) {
|
||||
CHECK(Parse(cx, "[1]", &v));
|
||||
CHECK(v.isObject());
|
||||
obj = &v.toObject();
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(isArray);
|
||||
CHECK(JS_GetProperty(cx, obj, "0", &v2));
|
||||
CHECK(v2.isInt32(1));
|
||||
@ -137,13 +138,13 @@ BEGIN_TEST(testParseJSON_success) {
|
||||
CHECK(Parse(cx, "{}", &v));
|
||||
CHECK(v.isObject());
|
||||
obj = &v.toObject();
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(!isArray);
|
||||
|
||||
CHECK(Parse(cx, "{ \"f\": 17 }", &v));
|
||||
CHECK(v.isObject());
|
||||
obj = &v.toObject();
|
||||
CHECK(JS_IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(JS::IsArrayObject(cx, obj, &isArray));
|
||||
CHECK(!isArray);
|
||||
CHECK(JS_GetProperty(cx, obj, "f", &v2));
|
||||
CHECK(v2.isInt32(17));
|
||||
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gc/Zone.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "jsapi-tests/tests.h"
|
||||
#include "vm/Realm.h"
|
||||
|
||||
@ -53,7 +54,7 @@ bool checkSize(JS::HandleObject map, uint32_t expected) {
|
||||
CHECK(JS_NondeterministicGetWeakMapKeys(cx, map, &keys));
|
||||
|
||||
uint32_t length;
|
||||
CHECK(JS_GetArrayLength(cx, keys, &length));
|
||||
CHECK(JS::GetArrayLength(cx, keys, &length));
|
||||
CHECK(length == expected);
|
||||
|
||||
return true;
|
||||
@ -235,7 +236,7 @@ bool checkSize(JS::HandleObject map, uint32_t expected) {
|
||||
CHECK(JS_NondeterministicGetWeakMapKeys(cx, map, &keys));
|
||||
|
||||
uint32_t length;
|
||||
CHECK(JS_GetArrayLength(cx, keys, &length));
|
||||
CHECK(JS::GetArrayLength(cx, keys, &length));
|
||||
CHECK(length == expected);
|
||||
|
||||
return true;
|
||||
|
@ -100,6 +100,7 @@
|
||||
#include "debugger/DebugAPI-inl.h"
|
||||
#include "vm/Compartment-inl.h"
|
||||
#include "vm/Interpreter-inl.h"
|
||||
#include "vm/IsGivenTypeObject-inl.h" // js::IsGivenTypeObject
|
||||
#include "vm/JSAtom-inl.h"
|
||||
#include "vm/JSFunction-inl.h"
|
||||
#include "vm/JSScript-inl.h"
|
||||
@ -3130,69 +3131,6 @@ JS_PUBLIC_API void JS_InitPrivate(JSObject* obj, void* data, size_t nbytes,
|
||||
InitObjectPrivate(&obj->as<NativeObject>(), data, nbytes, js::MemoryUse(use));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS_NewArrayObject(
|
||||
JSContext* cx, const JS::HandleValueArray& contents) {
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
|
||||
cx->check(contents);
|
||||
return NewDenseCopiedArray(cx, contents.length(), contents.begin());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS_NewArrayObject(JSContext* cx, size_t length) {
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
|
||||
return NewDenseFullyAllocatedArray(cx, length);
|
||||
}
|
||||
|
||||
inline bool IsGivenTypeObject(JSContext* cx, JS::HandleObject obj,
|
||||
const ESClass& typeClass, bool* isType) {
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*isType = cls == typeClass;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_IsArrayObject(JSContext* cx, JS::HandleObject obj,
|
||||
bool* isArray) {
|
||||
return IsGivenTypeObject(cx, obj, ESClass::Array, isArray);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_IsArrayObject(JSContext* cx, JS::HandleValue value,
|
||||
bool* isArray) {
|
||||
if (!value.isObject()) {
|
||||
*isArray = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, &value.toObject());
|
||||
return JS_IsArrayObject(cx, obj, isArray);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_GetArrayLength(JSContext* cx, HandleObject obj,
|
||||
uint32_t* lengthp) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(obj);
|
||||
return GetLengthProperty(cx, obj, lengthp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_SetArrayLength(JSContext* cx, HandleObject obj,
|
||||
uint32_t length) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(obj);
|
||||
return SetLengthProperty(cx, obj, length);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::IsMapObject(JSContext* cx, JS::HandleObject obj,
|
||||
bool* isMap) {
|
||||
return IsGivenTypeObject(cx, obj, ESClass::Map, isMap);
|
||||
|
@ -1605,41 +1605,6 @@ extern JS_PUBLIC_API bool JS_AlreadyHasOwnElement(JSContext* cx,
|
||||
JS::HandleObject obj,
|
||||
uint32_t index, bool* foundp);
|
||||
|
||||
extern JS_PUBLIC_API JSObject* JS_NewArrayObject(
|
||||
JSContext* cx, const JS::HandleValueArray& contents);
|
||||
|
||||
extern JS_PUBLIC_API JSObject* JS_NewArrayObject(JSContext* cx, size_t length);
|
||||
|
||||
/**
|
||||
* On success, returns true, setting |*isArray| to true if |value| is an Array
|
||||
* object or a wrapper around one, or to false if not. Returns false on
|
||||
* failure.
|
||||
*
|
||||
* This method returns true with |*isArray == false| when passed an ES6 proxy
|
||||
* whose target is an Array, or when passed a revoked proxy.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool JS_IsArrayObject(JSContext* cx, JS::HandleValue value,
|
||||
bool* isArray);
|
||||
|
||||
/**
|
||||
* On success, returns true, setting |*isArray| to true if |obj| is an Array
|
||||
* object or a wrapper around one, or to false if not. Returns false on
|
||||
* failure.
|
||||
*
|
||||
* This method returns true with |*isArray == false| when passed an ES6 proxy
|
||||
* whose target is an Array, or when passed a revoked proxy.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool JS_IsArrayObject(JSContext* cx, JS::HandleObject obj,
|
||||
bool* isArray);
|
||||
|
||||
extern JS_PUBLIC_API bool JS_GetArrayLength(JSContext* cx,
|
||||
JS::Handle<JSObject*> obj,
|
||||
uint32_t* lengthp);
|
||||
|
||||
extern JS_PUBLIC_API bool JS_SetArrayLength(JSContext* cx,
|
||||
JS::Handle<JSObject*> obj,
|
||||
uint32_t length);
|
||||
|
||||
namespace JS {
|
||||
|
||||
/**
|
||||
|
@ -123,6 +123,7 @@ EXPORTS += [
|
||||
EXPORTS.js += [
|
||||
'../public/AllocationRecording.h',
|
||||
'../public/AllocPolicy.h',
|
||||
'../public/Array.h',
|
||||
'../public/ArrayBuffer.h',
|
||||
'../public/BinASTFormat.h',
|
||||
'../public/BuildId.h',
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "NamespaceImports.h"
|
||||
|
||||
#include "js/Array.h" // JS::IsArrayAnswer
|
||||
#include "js/Class.h"
|
||||
|
||||
namespace js {
|
||||
|
@ -86,6 +86,7 @@
|
||||
#include "jit/JitcodeMap.h"
|
||||
#include "jit/JitRealm.h"
|
||||
#include "jit/shared/CodeGenerator-shared.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{CreateMappedArrayBufferContents,NewMappedArrayBufferWithContents,IsArrayBufferObject,GetArrayBufferLengthAndData}
|
||||
#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
|
||||
#include "js/CharacterEncoding.h"
|
||||
@ -6698,7 +6699,7 @@ static bool DisableSingleStepProfiling(JSContext* cx, unsigned argc,
|
||||
}
|
||||
}
|
||||
|
||||
JSObject* array = JS_NewArrayObject(cx, elems);
|
||||
JSObject* array = JS::NewArrayObject(cx, elems);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -7955,7 +7956,7 @@ class ShellAutoEntryMonitor : JS::dbg::AutoEntryMonitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject result(cx, JS_NewArrayObject(cx, log.length()));
|
||||
RootedObject result(cx, JS::NewArrayObject(cx, log.length()));
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
@ -10097,7 +10098,7 @@ static bool BindScriptArgs(JSContext* cx, OptionParser* op) {
|
||||
|
||||
MultiStringRange msr = op->getMultiStringArg("scriptArgs");
|
||||
RootedObject scriptArgs(cx);
|
||||
scriptArgs = JS_NewArrayObject(cx, 0);
|
||||
scriptArgs = JS::NewArrayObject(cx, 0);
|
||||
if (!scriptArgs) {
|
||||
return false;
|
||||
}
|
||||
|
32
js/src/vm/IsGivenTypeObject-inl.h
Normal file
32
js/src/vm/IsGivenTypeObject-inl.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef vm_IsGivenTypeObject_inl_h
|
||||
#define vm_IsGivenTypeObject_inl_h
|
||||
|
||||
#include "js/Class.h" // js::ESClass
|
||||
#include "js/RootingAPI.h" // JS::Handle
|
||||
|
||||
#include "vm/JSContext-inl.h" // JSContext::check
|
||||
|
||||
namespace js {
|
||||
|
||||
inline bool IsGivenTypeObject(JSContext* cx, JS::Handle<JSObject*> obj,
|
||||
const ESClass& typeClass, bool* isType) {
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*isType = cls == typeClass;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif // vm_IsGivenTypeObject_inl_h
|
@ -44,6 +44,7 @@
|
||||
|
||||
#include "builtin/DataViewObject.h"
|
||||
#include "builtin/MapObject.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{ArrayBufferHasData,DetachArrayBuffer,IsArrayBufferObject,New{,Mapped}ArrayBufferWithContents,ReleaseMappedArrayBufferContents}
|
||||
#include "js/Date.h"
|
||||
#include "js/GCHashTable.h"
|
||||
@ -1027,7 +1028,7 @@ bool JSStructuredCloneWriter::parseTransferable() {
|
||||
JSContext* cx = context();
|
||||
RootedObject array(cx, &transferable.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, array, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, array, &isArray)) {
|
||||
return false;
|
||||
}
|
||||
if (!isArray) {
|
||||
@ -1035,7 +1036,7 @@ bool JSStructuredCloneWriter::parseTransferable() {
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(cx, array, &length)) {
|
||||
if (!JS::GetArrayLength(cx, array, &length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1438,7 +1439,7 @@ bool JSStructuredCloneWriter::traverseObject(HandleObject obj, ESClass cls) {
|
||||
// Write the header for obj.
|
||||
if (cls == ESClass::Array) {
|
||||
uint32_t length = 0;
|
||||
if (!JS_GetArrayLength(context(), obj, &length)) {
|
||||
if (!JS::GetArrayLength(context(), obj, &length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/Printf.h"
|
||||
@ -1178,7 +1179,7 @@ nsresult mozJSComponentLoader::ExtractExports(
|
||||
}
|
||||
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, symbols, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, symbols, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
@ -1190,7 +1191,7 @@ nsresult mozJSComponentLoader::ExtractExports(
|
||||
// Iterate over symbols array, installing symbols on targetObj:
|
||||
|
||||
uint32_t symbolCount = 0;
|
||||
if (!JS_GetArrayLength(cx, symbolsObj, &symbolCount)) {
|
||||
if (!JS::GetArrayLength(cx, symbolsObj, &symbolCount)) {
|
||||
return ReportOnCallerUTF8(cxhelper, ERROR_GETTING_ARRAY_LENGTH, aInfo);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "AccessCheck.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/PropertySpec.h"
|
||||
@ -810,7 +811,7 @@ bool SandboxProxyHandler::enumerate(JSContext* cx, JS::Handle<JSObject*> proxy,
|
||||
|
||||
bool xpc::GlobalProperties::Parse(JSContext* cx, JS::HandleObject obj) {
|
||||
uint32_t length;
|
||||
bool ok = JS_GetArrayLength(cx, obj, &length);
|
||||
bool ok = JS::GetArrayLength(cx, obj, &length);
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
RootedValue nameValue(cx);
|
||||
@ -1371,7 +1372,7 @@ static bool GetExpandedPrincipal(JSContext* cx, HandleObject arrayObj,
|
||||
MOZ_ASSERT(out);
|
||||
uint32_t length;
|
||||
|
||||
if (!JS_GetArrayLength(cx, arrayObj, &length)) {
|
||||
if (!JS::GetArrayLength(cx, arrayObj, &length)) {
|
||||
return false;
|
||||
}
|
||||
if (!length) {
|
||||
@ -1702,7 +1703,7 @@ bool SandboxOptions::ParseGlobalProperties() {
|
||||
|
||||
RootedObject ctors(mCx, &value.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(mCx, ctors, &isArray)) {
|
||||
if (!JS::IsArrayObject(mCx, ctors, &isArray)) {
|
||||
return false;
|
||||
}
|
||||
if (!isArray) {
|
||||
@ -1829,7 +1830,7 @@ nsresult nsXPCComponents_utils_Sandbox::CallOrConstruct(
|
||||
} else if (args[0].isObject()) {
|
||||
RootedObject obj(cx, &args[0].toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, obj, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, obj, &isArray)) {
|
||||
ok = false;
|
||||
} else if (isArray) {
|
||||
if (options.userContextId != 0) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::IsArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/ContextOptions.h"
|
||||
#include "js/SavedFrameAPI.h"
|
||||
@ -1582,7 +1583,7 @@ nsXPCComponents_Utils::ImportGlobalProperties(HandleValue aPropertyList,
|
||||
|
||||
RootedObject propertyList(cx, &aPropertyList.toObject());
|
||||
bool isArray;
|
||||
if (NS_WARN_IF(!JS_IsArrayObject(cx, propertyList, &isArray))) {
|
||||
if (NS_WARN_IF(!JS::IsArrayObject(cx, propertyList, &isArray))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_WARN_IF(!isArray)) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/MemoryFunctions.h"
|
||||
|
||||
@ -1380,7 +1381,7 @@ bool XPCConvert::NativeArray2JS(JSContext* cx, MutableHandleValue d,
|
||||
nsresult* pErr) {
|
||||
MOZ_ASSERT(buf || count == 0, "Must have buf or 0 elements");
|
||||
|
||||
RootedObject array(cx, JS_NewArrayObject(cx, count));
|
||||
RootedObject array(cx, JS::NewArrayObject(cx, count));
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -1511,8 +1512,8 @@ bool XPCConvert::JSArray2Native(JSContext* cx, JS::HandleValue aJSVal,
|
||||
// If jsarray is not a TypedArrayObject, check for an Array object.
|
||||
uint32_t length = 0;
|
||||
bool isArray = false;
|
||||
if (!JS_IsArrayObject(cx, jsarray, &isArray) || !isArray ||
|
||||
!JS_GetArrayLength(cx, jsarray, &length)) {
|
||||
if (!JS::IsArrayObject(cx, jsarray, &isArray) || !isArray ||
|
||||
!JS::GetArrayLength(cx, jsarray, &length)) {
|
||||
if (pErr) {
|
||||
*pErr = NS_ERROR_XPC_CANT_CONVERT_OBJECT_TO_ARRAY;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Evaluate
|
||||
#include "js/ContextOptions.h"
|
||||
@ -931,7 +932,7 @@ static bool ProcessArgs(AutoJSAPI& jsapi, char** argv, int argc,
|
||||
* 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);
|
||||
argsObj = JS::NewArrayObject(cx, 0);
|
||||
if (!argsObj) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "xpcprivate.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/Wrapper.h"
|
||||
|
||||
using namespace JS;
|
||||
@ -188,7 +189,7 @@ bool XPCArrayHomogenizer::GetTypeForArray(JSContext* cx, HandleObject array,
|
||||
jsobj = &val.toObject();
|
||||
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, jsobj, &isArray)) {
|
||||
if (!JS::IsArrayObject(cx, jsobj, &isArray)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -318,8 +319,8 @@ bool XPCVariant::InitializeData(JSContext* cx) {
|
||||
uint32_t len;
|
||||
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, jsobj, &isArray) ||
|
||||
(isArray && !JS_GetArrayLength(cx, jsobj, &len))) {
|
||||
if (!JS::IsArrayObject(cx, jsobj, &isArray) ||
|
||||
(isArray && !JS::GetArrayLength(cx, jsobj, &len))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -650,7 +651,7 @@ bool XPCVariant::VariantDataToJS(JSContext* cx, nsIVariant* variant,
|
||||
return success;
|
||||
}
|
||||
case nsIDataType::VTYPE_EMPTY_ARRAY: {
|
||||
JSObject* array = JS_NewArrayObject(cx, 0);
|
||||
JSObject* array = JS::NewArrayObject(cx, 0);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "XPCLog.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/MemoryFunctions.h"
|
||||
#include "js/Printf.h"
|
||||
#include "jsfriendapi.h"
|
||||
@ -1231,8 +1232,8 @@ bool CallMethodHelper::GetArraySizeFromParam(const nsXPTType& type,
|
||||
|
||||
bool isArray;
|
||||
bool ok = false;
|
||||
if (JS_IsArrayObject(mCallContext, maybeArray, &isArray) && isArray) {
|
||||
ok = JS_GetArrayLength(mCallContext, arrayOrNull, lengthp);
|
||||
if (JS::IsArrayObject(mCallContext, maybeArray, &isArray) && isArray) {
|
||||
ok = JS::GetArrayLength(mCallContext, arrayOrNull, lengthp);
|
||||
} else if (JS_IsTypedArrayObject(&maybeArray.toObject())) {
|
||||
*lengthp = JS_GetTypedArrayLength(&maybeArray.toObject());
|
||||
ok = true;
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "mozilla/dom/FontFaceSetIterator.h"
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -61,7 +63,7 @@ void FontFaceSetIterator::Next(JSContext* aCx,
|
||||
values[1].set(value);
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx);
|
||||
array = JS_NewArrayObject(aCx, values);
|
||||
array = JS::NewArrayObject(aCx, values);
|
||||
if (array) {
|
||||
aResult.mValue.setObject(*array);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "JavaBuiltins.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "nsIURI.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
@ -395,7 +396,7 @@ class GetVisitedCallback final : public nsIAndroidEventCallback {
|
||||
return true;
|
||||
}
|
||||
bool isArray = false;
|
||||
if (NS_WARN_IF(!JS_IsArrayObject(aCx, aData, &isArray))) {
|
||||
if (NS_WARN_IF(!JS::IsArrayObject(aCx, aData, &isArray))) {
|
||||
return false;
|
||||
}
|
||||
if (NS_WARN_IF(!isArray)) {
|
||||
@ -403,7 +404,7 @@ class GetVisitedCallback final : public nsIAndroidEventCallback {
|
||||
}
|
||||
JS::Rooted<JSObject*> visited(aCx, &aData.toObject());
|
||||
uint32_t length = 0;
|
||||
if (NS_WARN_IF(!JS_GetArrayLength(aCx, visited, &length))) {
|
||||
if (NS_WARN_IF(!JS::GetArrayLength(aCx, visited, &length))) {
|
||||
return false;
|
||||
}
|
||||
if (NS_WARN_IF(length != mURIs.Length())) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/ExpandedPrincipal.h"
|
||||
#include "mozilla/dom/ClientIPCTypes.h"
|
||||
@ -1149,7 +1150,8 @@ LoadInfo::AppendRedirectHistoryEntry(nsIRedirectHistoryEntry* aEntry,
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetRedirects(JSContext* aCx, JS::MutableHandle<JS::Value> aRedirects,
|
||||
const RedirectHistoryArray& aArray) {
|
||||
JS::Rooted<JSObject*> redirects(aCx, JS_NewArrayObject(aCx, aArray.Length()));
|
||||
JS::Rooted<JSObject*> redirects(aCx,
|
||||
JS::NewArrayObject(aCx, aArray.Length()));
|
||||
NS_ENSURE_TRUE(redirects, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mozStorageStatement.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
|
||||
#include "xpc_make_class.h"
|
||||
|
||||
@ -98,7 +99,7 @@ void StatementRow::NamedGetter(JSContext* aCx, const nsAString& aName,
|
||||
uint32_t length;
|
||||
const uint8_t* blob = static_cast<mozIStorageStatement*>(mStatement)
|
||||
->AsSharedBlob(idx, &length);
|
||||
JS::Rooted<JSObject*> obj(aCx, ::JS_NewArrayObject(aCx, length));
|
||||
JS::Rooted<JSObject*> obj(aCx, JS::NewArrayObject(aCx, length));
|
||||
if (!obj) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "HangDetails.h"
|
||||
#include "nsIHangDetails.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/gfx/GPUParent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h" // For RemoteTypePrefix
|
||||
@ -110,7 +111,7 @@ NS_IMETHODIMP
|
||||
nsHangDetails::GetStack(JSContext* aCx, JS::MutableHandleValue aStack) {
|
||||
auto& stack = mDetails.stack();
|
||||
uint32_t length = stack.stack().Length();
|
||||
JS::RootedObject ret(aCx, JS_NewArrayObject(aCx, length));
|
||||
JS::RootedObject ret(aCx, JS::NewArrayObject(aCx, length));
|
||||
if (!ret) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -153,7 +154,7 @@ nsHangDetails::GetStack(JSContext* aCx, JS::MutableHandleValue aStack) {
|
||||
case HangEntry::THangEntryModOffset: {
|
||||
const HangEntryModOffset& mo = entry.get_HangEntryModOffset();
|
||||
|
||||
JS::RootedObject jsFrame(aCx, JS_NewArrayObject(aCx, 2));
|
||||
JS::RootedObject jsFrame(aCx, JS::NewArrayObject(aCx, 2));
|
||||
if (!jsFrame) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -217,14 +218,14 @@ NS_IMETHODIMP
|
||||
nsHangDetails::GetModules(JSContext* aCx, JS::MutableHandleValue aVal) {
|
||||
auto& modules = mDetails.stack().modules();
|
||||
size_t length = modules.Length();
|
||||
JS::RootedObject retObj(aCx, JS_NewArrayObject(aCx, length));
|
||||
JS::RootedObject retObj(aCx, JS::NewArrayObject(aCx, length));
|
||||
if (!retObj) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
const HangModule& module = modules[i];
|
||||
JS::RootedObject jsModule(aCx, JS_NewArrayObject(aCx, 2));
|
||||
JS::RootedObject jsModule(aCx, JS::NewArrayObject(aCx, 2));
|
||||
if (!jsModule) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/dom/ContentProcessMessageManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
@ -187,12 +188,12 @@ nsresult GetJSArrayFromJSValue(JS::Handle<JS::Value> aValue, JSContext* aCtx,
|
||||
if (aValue.isObjectOrNull()) {
|
||||
JS::Rooted<JSObject*> val(aCtx, aValue.toObjectOrNull());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCtx, val, &isArray)) {
|
||||
if (!JS::IsArrayObject(aCtx, val, &isArray)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (isArray) {
|
||||
_array.set(val);
|
||||
(void)JS_GetArrayLength(aCtx, _array, _arrayLength);
|
||||
(void)JS::GetArrayLength(aCtx, _array, _arrayLength);
|
||||
NS_ENSURE_ARG(*_arrayLength > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -201,7 +202,7 @@ nsresult GetJSArrayFromJSValue(JS::Handle<JS::Value> aValue, JSContext* aCtx,
|
||||
// Build a temporary array to store this one item so the code below can
|
||||
// just loop.
|
||||
*_arrayLength = 1;
|
||||
_array.set(JS_NewArrayObject(aCtx, 0));
|
||||
_array.set(JS::NewArrayObject(aCtx, 0));
|
||||
NS_ENSURE_TRUE(_array, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
bool rc = JS_DefineElement(aCtx, _array, 0, aValue, 0);
|
||||
@ -2092,7 +2093,7 @@ History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
|
||||
if (!visitsVal.isPrimitive()) {
|
||||
visits = visitsVal.toObjectOrNull();
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCtx, visits, &isArray)) {
|
||||
if (!JS::IsArrayObject(aCtx, visits, &isArray)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (!isArray) {
|
||||
@ -2104,7 +2105,7 @@ History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
|
||||
|
||||
uint32_t visitsLength = 0;
|
||||
if (visits) {
|
||||
(void)JS_GetArrayLength(aCtx, visits, &visitsLength);
|
||||
(void)JS::GetArrayLength(aCtx, visits, &visitsLength);
|
||||
}
|
||||
NS_ENSURE_ARG(visitsLength > 0);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
|
||||
namespace mozilla {
|
||||
namespace places {
|
||||
@ -86,7 +87,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));
|
||||
JS::Rooted<JSObject*> visits(aContext, JS::NewArrayObject(aContext, 0));
|
||||
NS_ENSURE_TRUE(visits, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));
|
||||
|
@ -2,6 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/JSON.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
@ -903,13 +904,13 @@ static void SetElementAsObject(JSContext* aCx, Element* aElement,
|
||||
|
||||
// For Multiple Selects Element
|
||||
bool isArray = false;
|
||||
JS_IsArrayObject(aCx, aObject, &isArray);
|
||||
JS::IsArrayObject(aCx, aObject, &isArray);
|
||||
if (!isArray) {
|
||||
return;
|
||||
}
|
||||
JS::Rooted<JSObject*> arrayObj(aCx, &aObject.toObject());
|
||||
uint32_t arrayLength = 0;
|
||||
if (!JS_GetArrayLength(aCx, arrayObj, &arrayLength)) {
|
||||
if (!JS::GetArrayLength(aCx, arrayObj, &arrayLength)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ipc/TelemetryIPCAccumulator.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/GCAPI.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
@ -544,7 +545,7 @@ bool TelemetryImpl::ReflectSQL(const SlowSQLEntryType* entry, const Stat* stat,
|
||||
|
||||
const nsACString& sql = entry->GetKey();
|
||||
|
||||
JS::Rooted<JSObject*> arrayObj(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::Rooted<JSObject*> arrayObj(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!arrayObj) {
|
||||
return false;
|
||||
}
|
||||
@ -741,7 +742,7 @@ class GetLoadedModulesResultRunnable final : public Runnable {
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::RootedObject moduleArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject moduleArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!moduleArray) {
|
||||
mPromise->MaybeReject(NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
@ -1828,7 +1829,7 @@ TelemetryImpl::GetAllStores(JSContext* aCx, JS::MutableHandleValue aResult) {
|
||||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> rarray(aCx, JS_NewArrayObject(aCx, allStores));
|
||||
JS::Rooted<JSObject*> rarray(aCx, JS::NewArrayObject(aCx, allStores));
|
||||
if (rarray == nullptr) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <limits>
|
||||
#include "ipc/TelemetryIPCAccumulator.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Pair.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -574,7 +575,7 @@ nsresult SerializeEventsArray(const EventRecordArray& events, JSContext* cx,
|
||||
JS::MutableHandleObject result,
|
||||
unsigned int dataset) {
|
||||
// We serialize the events to a JS array.
|
||||
JS::RootedObject eventsArray(cx, JS_NewArrayObject(cx, events.Length()));
|
||||
JS::RootedObject eventsArray(cx, JS::NewArrayObject(cx, events.Length()));
|
||||
if (!eventsArray) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -660,7 +661,7 @@ nsresult SerializeEventsArray(const EventRecordArray& events, JSContext* cx,
|
||||
}
|
||||
|
||||
// Add the record to the events array.
|
||||
JS::RootedObject itemsArray(cx, JS_NewArrayObject(cx, items));
|
||||
JS::RootedObject itemsArray(cx, JS::NewArrayObject(cx, items));
|
||||
if (!JS_DefineElement(cx, eventsArray, i, itemsArray, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1007,7 +1008,7 @@ static bool GetArrayPropertyValues(JSContext* cx, JS::HandleObject obj,
|
||||
}
|
||||
|
||||
bool isArray = false;
|
||||
if (!JS_IsArrayObject(cx, value, &isArray) || !isArray) {
|
||||
if (!JS::IsArrayObject(cx, value, &isArray) || !isArray) {
|
||||
JS_ReportErrorASCII(cx, R"(Property "%s" for event should be an array)",
|
||||
property);
|
||||
return false;
|
||||
@ -1015,7 +1016,7 @@ static bool GetArrayPropertyValues(JSContext* cx, JS::HandleObject obj,
|
||||
|
||||
JS::RootedObject arrayObj(cx, &value.toObject());
|
||||
uint32_t arrayLength;
|
||||
if (!JS_GetArrayLength(cx, arrayObj, &arrayLength)) {
|
||||
if (!JS::GetArrayLength(cx, arrayObj, &arrayLength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "ipc/TelemetryIPCAccumulator.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/GCAPI.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
@ -800,7 +801,7 @@ nsresult internal_ReflectHistogramAndSamples(
|
||||
"The number of buckets and the number of counts must match.");
|
||||
|
||||
// Create the "range" property and add it to the final object.
|
||||
JS::Rooted<JSObject*> rarray(cx, JS_NewArrayObject(cx, 2));
|
||||
JS::Rooted<JSObject*> rarray(cx, JS::NewArrayObject(cx, 2));
|
||||
if (rarray == nullptr ||
|
||||
!JS_DefineProperty(cx, obj, "range", rarray, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1744,7 +1745,7 @@ bool internal_JSHistogram_GetValueArray(JSContext* aCx, JS::CallArgs& args,
|
||||
JS::Rooted<JSObject*> arrayObj(aCx, &args[firstArgIndex].toObject());
|
||||
|
||||
bool isArray = false;
|
||||
JS_IsArrayObject(aCx, arrayObj, &isArray);
|
||||
JS::IsArrayObject(aCx, arrayObj, &isArray);
|
||||
|
||||
if (!isArray) {
|
||||
LogToBrowserConsole(
|
||||
@ -1755,7 +1756,7 @@ bool internal_JSHistogram_GetValueArray(JSContext* aCx, JS::CallArgs& args,
|
||||
}
|
||||
|
||||
uint32_t arrayLength = 0;
|
||||
if (!JS_GetArrayLength(aCx, arrayObj, &arrayLength)) {
|
||||
if (!JS::GetArrayLength(aCx, arrayObj, &arrayLength)) {
|
||||
LogToBrowserConsole(
|
||||
nsIScriptError::errorFlag,
|
||||
NS_LITERAL_STRING("Failed while trying to get array length"));
|
||||
@ -2282,7 +2283,7 @@ bool internal_JSKeyedHistogram_Keys(JSContext* cx, unsigned argc,
|
||||
}
|
||||
}
|
||||
|
||||
JS::RootedObject jsKeys(cx, JS_NewArrayObject(cx, autoKeys));
|
||||
JS::RootedObject jsKeys(cx, JS::NewArrayObject(cx, autoKeys));
|
||||
if (!jsKeys) {
|
||||
return false;
|
||||
}
|
||||
@ -3098,7 +3099,7 @@ nsresult internal_ParseHistogramData(
|
||||
JS::RootedValue countsArray(aCx);
|
||||
bool countsIsArray = false;
|
||||
if (!JS_GetProperty(aCx, histogramObj, "counts", &countsArray) ||
|
||||
!JS_IsArrayObject(aCx, countsArray, &countsIsArray)) {
|
||||
!JS::IsArrayObject(aCx, countsArray, &countsIsArray)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3112,7 +3113,7 @@ nsresult internal_ParseHistogramData(
|
||||
// Get the length of the array.
|
||||
uint32_t countsLen = 0;
|
||||
JS::RootedObject countsArrayObj(aCx, &countsArray.toObject());
|
||||
if (!JS_GetArrayLength(aCx, countsArrayObj, &countsLen)) {
|
||||
if (!JS::GetArrayLength(aCx, countsArrayObj, &countsLen)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "TelemetryCommon.h"
|
||||
#include "TelemetryOriginEnums.h"
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/dom/PrioEncoder.h"
|
||||
@ -541,7 +542,7 @@ nsresult TelemetryOrigin::GetEncodedOriginSnapshot(
|
||||
// }, ...]
|
||||
|
||||
JS::RootedObject prioDataArray(aCx,
|
||||
JS_NewArrayObject(aCx, prioData.Length()));
|
||||
JS::NewArrayObject(aCx, prioData.Length()));
|
||||
if (NS_WARN_IF(!prioDataArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "geckoview/streaming/GeckoViewStreamingTelemetry.h"
|
||||
#include "ipc/TelemetryComms.h"
|
||||
#include "ipc/TelemetryIPCAccumulator.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/PContent.h"
|
||||
#include "mozilla/JSONWriter.h"
|
||||
@ -3423,7 +3424,7 @@ nsresult TelemetryScalar::RegisterScalars(const nsACString& aCategoryName,
|
||||
if (JS_HasProperty(cx, scalarDef, "stores", &hasProperty) && hasProperty) {
|
||||
bool isArray = false;
|
||||
if (!JS_GetProperty(cx, scalarDef, "stores", &value) ||
|
||||
!JS_IsArrayObject(cx, value, &isArray) || !isArray) {
|
||||
!JS::IsArrayObject(cx, value, &isArray) || !isArray) {
|
||||
JS_ReportErrorASCII(cx, "Invalid 'stores' for scalar %s.",
|
||||
PromiseFlatCString(fullName).get());
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -3431,7 +3432,7 @@ nsresult TelemetryScalar::RegisterScalars(const nsACString& aCategoryName,
|
||||
|
||||
JS::RootedObject arrayObj(cx, &value.toObject());
|
||||
uint32_t storesLength = 0;
|
||||
if (!JS_GetArrayLength(cx, arrayObj, &storesLength)) {
|
||||
if (!JS::GetArrayLength(cx, arrayObj, &storesLength)) {
|
||||
JS_ReportErrorASCII(cx,
|
||||
"Can't get 'stores' array length for scalar %s.",
|
||||
PromiseFlatCString(fullName).get());
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "CombinedStacks.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/HangAnnotations.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -131,7 +132,7 @@ JSObject* CreateJSStackObject(JSContext* cx, const CombinedStacks& stacks) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> moduleArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::Rooted<JSObject*> moduleArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!moduleArray) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -147,7 +148,7 @@ JSObject* CreateJSStackObject(JSContext* cx, const CombinedStacks& stacks) {
|
||||
const Telemetry::ProcessedStack::Module& module =
|
||||
stacks.GetModule(moduleIndex);
|
||||
|
||||
JS::Rooted<JSObject*> moduleInfoArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::Rooted<JSObject*> moduleInfoArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!moduleInfoArray) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -174,7 +175,7 @@ JSObject* CreateJSStackObject(JSContext* cx, const CombinedStacks& stacks) {
|
||||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> reportArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::Rooted<JSObject*> reportArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!reportArray) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -186,7 +187,7 @@ JSObject* 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));
|
||||
JS::Rooted<JSObject*> pcArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!pcArray) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -199,7 +200,7 @@ JSObject* 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));
|
||||
JS::Rooted<JSObject*> framePair(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!framePair) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "KeyedStackCapturer.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/StackWalk.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "ProcessedStack.h"
|
||||
@ -112,7 +113,7 @@ KeyedStackCapturer::ReflectCapturedStacks(JSContext* cx,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::RootedObject keysArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject keysArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!keysArray) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -128,7 +129,7 @@ KeyedStackCapturer::ReflectCapturedStacks(JSContext* cx,
|
||||
iter.Next(), ++keyIndex) {
|
||||
const StackFrequencyInfo* info = iter.Data();
|
||||
|
||||
JS::RootedObject infoArray(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject infoArray(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!keysArray) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "TelemetryIOInterposeObserver.h"
|
||||
#include "core/TelemetryCommon.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
|
||||
namespace mozilla {
|
||||
namespace Telemetry {
|
||||
@ -127,7 +128,7 @@ bool TelemetryIOInterposeObserver::ReflectFileStats(FileIOEntryType* entry,
|
||||
stats[5].setNumber(fileStats.stats);
|
||||
|
||||
// Create jsStats as array of elements above
|
||||
JS::RootedObject jsStats(cx, JS_NewArrayObject(cx, stats));
|
||||
JS::RootedObject jsStats(cx, JS::NewArrayObject(cx, stats));
|
||||
if (!jsStats) {
|
||||
continue;
|
||||
}
|
||||
@ -135,7 +136,7 @@ bool TelemetryIOInterposeObserver::ReflectFileStats(FileIOEntryType* entry,
|
||||
stages[s].setObject(*jsStats);
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> jsEntry(cx, JS_NewArrayObject(cx, stages));
|
||||
JS::Rooted<JSObject*> jsEntry(cx, JS::NewArrayObject(cx, stages));
|
||||
if (!jsEntry) {
|
||||
return false;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "UntrustedModules.h"
|
||||
|
||||
#include "core/TelemetryCommon.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/RDDChild.h"
|
||||
@ -122,7 +123,7 @@ template <typename T, size_t N, typename AllocPolicy, typename Converter,
|
||||
static bool VectorToJSArray(JSContext* cx, JS::MutableHandleObject aRet,
|
||||
const Vector<T, N, AllocPolicy>& aContainer,
|
||||
Converter&& aElementConverter, Args&&... aArgs) {
|
||||
JS::RootedObject arr(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject arr(cx, JS::NewArrayObject(cx, 0));
|
||||
if (!arr) {
|
||||
return false;
|
||||
}
|
||||
@ -393,7 +394,7 @@ static nsresult GetUntrustedModuleLoadEventsJSValue(
|
||||
IndexMap indexMap;
|
||||
uint32_t curModulesArrayIdx = 0;
|
||||
|
||||
JS::RootedObject modulesArray(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::RootedObject modulesArray(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!modulesArray) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "core/TelemetryCommon.h"
|
||||
#include "core/TelemetryOrigin.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsPrintfCString.h"
|
||||
@ -111,11 +112,11 @@ bool EventPresent(JSContext* aCx, const JS::RootedValue& aSnapshot,
|
||||
EXPECT_FALSE(aSnapshot.isNullOrUndefined())
|
||||
<< "Event snapshot must not be null/undefined.";
|
||||
bool isArray = false;
|
||||
EXPECT_TRUE(JS_IsArrayObject(aCx, aSnapshot, &isArray) && isArray)
|
||||
EXPECT_TRUE(JS::IsArrayObject(aCx, aSnapshot, &isArray) && isArray)
|
||||
<< "The snapshot must be an array.";
|
||||
JS::RootedObject arrayObj(aCx, &aSnapshot.toObject());
|
||||
uint32_t arrayLength = 0;
|
||||
EXPECT_TRUE(JS_GetArrayLength(aCx, arrayObj, &arrayLength))
|
||||
EXPECT_TRUE(JS::GetArrayLength(aCx, arrayObj, &arrayLength))
|
||||
<< "Array must have a length.";
|
||||
EXPECT_TRUE(arrayLength > 0) << "Array must have at least one element.";
|
||||
|
||||
@ -123,11 +124,11 @@ bool EventPresent(JSContext* aCx, const JS::RootedValue& aSnapshot,
|
||||
JS::Rooted<JS::Value> element(aCx);
|
||||
EXPECT_TRUE(JS_GetElement(aCx, arrayObj, arrayIdx, &element))
|
||||
<< "Must be able to get element.";
|
||||
EXPECT_TRUE(JS_IsArrayObject(aCx, element, &isArray) && isArray)
|
||||
EXPECT_TRUE(JS::IsArrayObject(aCx, element, &isArray) && isArray)
|
||||
<< "Element must be an array.";
|
||||
JS::RootedObject eventArray(aCx, &element.toObject());
|
||||
uint32_t eventLength;
|
||||
EXPECT_TRUE(JS_GetArrayLength(aCx, eventArray, &eventLength))
|
||||
EXPECT_TRUE(JS::GetArrayLength(aCx, eventArray, &eventLength))
|
||||
<< "Event array must have a length.";
|
||||
EXPECT_TRUE(eventLength >= 4)
|
||||
<< "Event array must have at least 4 elements (timestamp, category, "
|
||||
@ -211,11 +212,11 @@ void GetEncodedOriginStrings(
|
||||
|
||||
JS::RootedObject prioDataObj(aCx, &snapshot.toObject());
|
||||
bool isArray = false;
|
||||
ASSERT_TRUE(JS_IsArrayObject(aCx, prioDataObj, &isArray) && isArray)
|
||||
ASSERT_TRUE(JS::IsArrayObject(aCx, prioDataObj, &isArray) && isArray)
|
||||
<< "The metric's origins must be in an array.";
|
||||
|
||||
uint32_t length = 0;
|
||||
ASSERT_TRUE(JS_GetArrayLength(aCx, prioDataObj, &length));
|
||||
ASSERT_TRUE(JS::GetArrayLength(aCx, prioDataObj, &length));
|
||||
ASSERT_TRUE(length > 0)
|
||||
<< "Length of returned array must greater than 0";
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "core/TelemetryEvent.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/Unused.h"
|
||||
@ -93,7 +94,7 @@ TEST_F(TelemetryTestFixture, RecordEventNative) {
|
||||
<< "Must be able to get record.";
|
||||
JS::RootedObject recordArray(aCx, &eventRecord.toObject());
|
||||
uint32_t recordLength;
|
||||
ASSERT_TRUE(JS_GetArrayLength(aCx, recordArray, &recordLength))
|
||||
ASSERT_TRUE(JS::GetArrayLength(aCx, recordArray, &recordLength))
|
||||
<< "Event record array must have length.";
|
||||
ASSERT_TRUE(recordLength == 6)
|
||||
<< "Event record must have 6 elements.";
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define AddonManagerStartup_inlines_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
@ -190,12 +191,12 @@ class MOZ_STACK_CLASS ArrayIter : public BaseIter<ArrayIter, ArrayIterElem> {
|
||||
ArrayIter(JSContext* cx, JS::HandleObject object)
|
||||
: BaseIter(cx, object), mLength(0) {
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, object, &isArray) || !isArray) {
|
||||
if (!JS::IsArrayObject(cx, object, &isArray) || !isArray) {
|
||||
JS_ClearPendingException(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!JS_GetArrayLength(cx, object, &mLength)) {
|
||||
if (!JS::GetArrayLength(cx, object, &mLength)) {
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Array.h" // JS::IsArrayObject
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "js/JSON.h"
|
||||
#include "js/TracingAPI.h"
|
||||
@ -779,7 +780,7 @@ AddonManagerStartup::RegisterChrome(nsIURI* manifestURI,
|
||||
nsIJSRAIIHelper** result) {
|
||||
auto IsArray = [cx](JS::HandleValue val) -> bool {
|
||||
bool isArray;
|
||||
return JS_IsArrayObject(cx, val, &isArray) && isArray;
|
||||
return JS::IsArrayObject(cx, val, &isArray) && isArray;
|
||||
};
|
||||
|
||||
NS_ENSURE_ARG_POINTER(manifestURI);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/Conversions.h"
|
||||
#include "js/JSON.h"
|
||||
@ -1273,7 +1274,7 @@ static bool RecordReplay_FindScriptHits(JSContext* aCx, unsigned aArgc,
|
||||
chunk = chunk->mPrevious;
|
||||
}
|
||||
|
||||
JSObject* array = JS_NewArrayObject(aCx, values);
|
||||
JSObject* array = JS::NewArrayObject(aCx, values);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
@ -1353,7 +1354,7 @@ static bool RecordReplay_FindChangeFrames(JSContext* aCx, unsigned aArgc,
|
||||
}
|
||||
}
|
||||
|
||||
JSObject* array = JS_NewArrayObject(aCx, values);
|
||||
JSObject* array = JS::NewArrayObject(aCx, values);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "platform.h"
|
||||
#include "ProfilerParent.h"
|
||||
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/JSON.h"
|
||||
#include "js/Value.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
@ -662,7 +663,7 @@ nsProfiler::GetSymbolTable(const nsACString& aDebugPath,
|
||||
aSymbolTable.mBuffer.Elements()));
|
||||
|
||||
if (addrsArray && indexArray && bufferArray) {
|
||||
JS::RootedObject tuple(cx, JS_NewArrayObject(cx, 3));
|
||||
JS::RootedObject tuple(cx, JS::NewArrayObject(cx, 3));
|
||||
JS_SetElement(cx, tuple, 0, addrsArray);
|
||||
JS_SetElement(cx, tuple, 1, indexArray);
|
||||
JS_SetElement(cx, tuple, 2, bufferArray);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "GfxInfoBase.h"
|
||||
|
||||
#include "GfxDriverInfo.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::NewArrayObject
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsString.h"
|
||||
@ -1240,7 +1241,7 @@ nsresult GfxInfoBase::FindMonitors(JSContext* aCx, JS::HandleObject aOutArray) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult) {
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
|
||||
nsresult rv = FindMonitors(aCx, array);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -1267,7 +1268,7 @@ template <typename T>
|
||||
static inline bool AppendJSElement(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
const T& aValue) {
|
||||
uint32_t index;
|
||||
if (!JS_GetArrayLength(aCx, aObj, &index)) {
|
||||
if (!JS::GetArrayLength(aCx, aObj, &index)) {
|
||||
return false;
|
||||
}
|
||||
return JS_SetElement(aCx, aObj, index, aValue);
|
||||
@ -1305,7 +1306,7 @@ nsresult GfxInfoBase::GetFeatureLog(JSContext* aCx,
|
||||
}
|
||||
aOut.setObject(*containerObj);
|
||||
|
||||
JS::Rooted<JSObject*> featureArray(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> featureArray(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!featureArray) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -1337,7 +1338,7 @@ nsresult GfxInfoBase::GetFeatureLog(JSContext* aCx,
|
||||
}
|
||||
});
|
||||
|
||||
JS::Rooted<JSObject*> fallbackArray(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> fallbackArray(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!fallbackArray) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -1374,7 +1375,7 @@ nsresult GfxInfoBase::GetFeatureLog(JSContext* aCx,
|
||||
bool GfxInfoBase::BuildFeatureStateLog(JSContext* aCx,
|
||||
const FeatureState& aFeature,
|
||||
JS::MutableHandle<JS::Value> aOut) {
|
||||
JS::Rooted<JSObject*> log(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> log(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!log) {
|
||||
return false;
|
||||
}
|
||||
@ -1458,7 +1459,7 @@ bool GfxInfoBase::InitFeatureObject(JSContext* aCx,
|
||||
|
||||
nsresult GfxInfoBase::GetActiveCrashGuards(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aOut) {
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
if (!array) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "JavaBuiltins.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject, JS::NewArrayObject
|
||||
#include "js/Warnings.h" // JS::WarnUTF8
|
||||
#include "xpcpublic.h"
|
||||
|
||||
@ -127,7 +128,7 @@ nsresult BoxArrayObject(JSContext* aCx, JS::HandleObject aData,
|
||||
nsresult BoxArray(JSContext* aCx, JS::HandleObject aData,
|
||||
jni::Object::LocalRef& aOut) {
|
||||
uint32_t length = 0;
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS_GetArrayLength(aCx, aData, &length)),
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS::GetArrayLength(aCx, aData, &length)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
if (!length) {
|
||||
@ -184,7 +185,7 @@ nsresult BoxArray(JSContext* aCx, JS::HandleObject aData,
|
||||
bool array = false;
|
||||
JS::RootedObject obj(aCx, &val.toObject());
|
||||
// We don't support array of arrays.
|
||||
return CheckJS(aCx, JS_IsArrayObject(aCx, obj, &array)) && !array;
|
||||
return CheckJS(aCx, JS::IsArrayObject(aCx, obj, &array)) && !array;
|
||||
};
|
||||
|
||||
if (element.isNullOrUndefined() || isObject(element)) {
|
||||
@ -212,7 +213,7 @@ nsresult BoxObject(JSContext* aCx, JS::HandleValue aData,
|
||||
JS::RootedObject obj(aCx, &aData.toObject());
|
||||
|
||||
bool isArray = false;
|
||||
if (CheckJS(aCx, JS_IsArrayObject(aCx, obj, &isArray)) && isArray) {
|
||||
if (CheckJS(aCx, JS::IsArrayObject(aCx, obj, &isArray)) && isArray) {
|
||||
return BoxArray(aCx, obj, aOut);
|
||||
}
|
||||
|
||||
@ -424,7 +425,7 @@ nsresult UnboxArrayPrimitive(JSContext* aCx, const jni::Object::LocalRef& aData,
|
||||
}
|
||||
|
||||
JS::RootedObject obj(aCx,
|
||||
JS_NewArrayObject(aCx, JS::HandleValueArray(elements)));
|
||||
JS::NewArrayObject(aCx, JS::HandleValueArray(elements)));
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, !!obj), NS_ERROR_FAILURE);
|
||||
|
||||
aOut.setObject(*obj);
|
||||
@ -449,7 +450,7 @@ nsresult UnboxArrayObject(JSContext* aCx, const jni::Object::LocalRef& aData,
|
||||
jni::ObjectArray::LocalRef array(aData.Env(),
|
||||
jni::ObjectArray::Ref::From(aData));
|
||||
const size_t len = array->Length();
|
||||
JS::RootedObject obj(aCx, JS_NewArrayObject(aCx, len));
|
||||
JS::RootedObject obj(aCx, JS::NewArrayObject(aCx, len));
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, !!obj), NS_ERROR_FAILURE);
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
@ -841,13 +842,13 @@ nsresult EventDispatcher::IterateEvents(JSContext* aCx, JS::HandleValue aEvents,
|
||||
|
||||
bool isArray = false;
|
||||
NS_ENSURE_TRUE(aEvents.isObject(), NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS_IsArrayObject(aCx, aEvents, &isArray)),
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS::IsArrayObject(aCx, aEvents, &isArray)),
|
||||
NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(isArray, NS_ERROR_INVALID_ARG);
|
||||
|
||||
JS::RootedObject events(aCx, &aEvents.toObject());
|
||||
uint32_t length = 0;
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS_GetArrayLength(aCx, events, &length)),
|
||||
NS_ENSURE_TRUE(CheckJS(aCx, JS::GetArrayLength(aCx, events, &length)),
|
||||
NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsMacSharingService.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "nsCocoaUtils.h"
|
||||
#include "mozilla/MacStringHelpers.h"
|
||||
|
||||
@ -99,7 +100,7 @@ nsresult nsMacSharingService::GetSharingProviders(const nsAString& aPageUrl, JSC
|
||||
JS::MutableHandleValue aResult) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
NSURL* url = [NSURL URLWithString:nsCocoaUtils::ToNSString(aPageUrl)];
|
||||
|
||||
NSArray* sharingService =
|
||||
|
Loading…
Reference in New Issue
Block a user