/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* 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/. */
// https://streams.spec.whatwg.org/#transfer-array-buffer // As some parts of the specifcation want to use the abrupt completion value, // this function may leave a pending exception if it returns nullptr.
JSObject* TransferArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aObject) {
MOZ_ASSERT(JS::IsArrayBufferObject(aObject));
// https://streams.spec.whatwg.org/#can-transfer-array-buffer bool CanTransferArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aObject,
ErrorResult& aRv) { // Step 1. Assert: Type(O) is Object. (Implicit in types) // Step 2. Assert: O has an [[ArrayBufferData]] internal slot.
MOZ_ASSERT(JS::IsArrayBufferObject(aObject));
// Step 3. If ! IsDetachedBuffer(O) is true, return false. if (JS::IsDetachedArrayBufferObject(aObject)) { returnfalse;
}
// Step 4. If SameValue(O.[[ArrayBufferDetachKey]], undefined) is false, // return false. // Step 5. Return true. // Note: WASM memories are the only buffers that would qualify // as having an [[ArrayBufferDetachKey]] which is not undefined. bool hasDefinedArrayBufferDetachKey = false; if (!JS::HasDefinedArrayBufferDetachKey(aCx, aObject,
&hasDefinedArrayBufferDetachKey)) {
aRv.StealExceptionFromJSContext(aCx); returnfalse;
} return !hasDefinedArrayBufferDetachKey;
}
// https://streams.spec.whatwg.org/#abstract-opdef-cloneasuint8array
JSObject* CloneAsUint8Array(JSContext* aCx, JS::Handle<JSObject*> aObject) { // Step 1. Assert: Type(O) is Object. Implicit. // Step 2. Assert: O has an [[ViewedArrayBuffer]] internal slot.
MOZ_ASSERT(JS_IsArrayBufferViewObject(aObject));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.