зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a858e4411532 (bug 1566595) for causing Windows MinGW builds bustages CLOSED TREE
This commit is contained in:
Родитель
a32c854de2
Коммит
98278afa46
|
@ -6,6 +6,6 @@ function handleRequest(request, response)
|
|||
.createInstance(Components.interfaces.nsIBinaryOutputStream);
|
||||
bos.setOutputStream(response.bodyOutputStream);
|
||||
|
||||
bos.writeByteArray(body);
|
||||
bos.writeByteArray(body, body.length);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Span.h"
|
||||
|
||||
#include "DataTransfer.h"
|
||||
|
||||
|
@ -1105,12 +1104,8 @@ already_AddRefed<nsITransferable> DataTransfer::GetTransferable(
|
|||
totalCustomLength = 0;
|
||||
continue;
|
||||
}
|
||||
MOZ_ASSERT(formatLength.isValid() &&
|
||||
formatLength.value() ==
|
||||
type.Length() * sizeof(nsString::char_type),
|
||||
"Why is formatLength off?");
|
||||
rv = stream->WriteBytes(
|
||||
AsBytes(MakeSpan(type.get(), type.Length())));
|
||||
rv = stream->WriteBytes((const char*)type.get(),
|
||||
formatLength.value());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
totalCustomLength = 0;
|
||||
continue;
|
||||
|
@ -1120,13 +1115,7 @@ already_AddRefed<nsITransferable> DataTransfer::GetTransferable(
|
|||
totalCustomLength = 0;
|
||||
continue;
|
||||
}
|
||||
// XXXbz it's not obvious to me that lengthInBytes is the actual
|
||||
// length of "data" if the variant contained an nsISupportsString
|
||||
// as VTYPE_INTERFACE, say. We used lengthInBytes above for
|
||||
// sizing, so just keep doing that.
|
||||
rv = stream->WriteBytes(MakeSpan(
|
||||
reinterpret_cast<const uint8_t*>(data.get()), lengthInBytes));
|
||||
;
|
||||
rv = stream->WriteBytes((const char*)data.get(), lengthInBytes);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
totalCustomLength = 0;
|
||||
continue;
|
||||
|
|
|
@ -15,6 +15,6 @@ function handleRequest(request, response) {
|
|||
var bos = new BinaryOutputStream(response.bodyOutputStream);
|
||||
|
||||
response.processAsync();
|
||||
bos.writeByteArray(bodyBytes);
|
||||
bos.writeByteArray(bodyBytes, bodyBytes.length);
|
||||
response.finish();
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ function handleRequest(request, response) {
|
|||
.createInstance(Components.interfaces.nsIBinaryOutputStream);
|
||||
bos.setOutputStream(response.bodyOutputStream);
|
||||
|
||||
bos.writeByteArray(bytes);
|
||||
bos.writeByteArray(bytes, bytes.length);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ function handleRequest(request, response) {
|
|||
response.processAsync();
|
||||
|
||||
var part = bodyBytes.splice(0, 256);
|
||||
bos.writeByteArray(part);
|
||||
bos.writeByteArray(part, part.length);
|
||||
|
||||
response.timer1 = new Timer(function(timer) {
|
||||
bos.writeByteArray(bodyBytes);
|
||||
bos.writeByteArray(bodyBytes, bodyBytes.length);
|
||||
}, 1000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||
|
||||
response.timer2 = new Timer(function(timer) {
|
||||
|
|
|
@ -62,7 +62,7 @@ function handleRequest(request, response)
|
|||
response.setHeader("Content-Type", "image/png", false);
|
||||
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(IMAGE_DATA);
|
||||
stream.writeByteArray(IMAGE_DATA, IMAGE_DATA.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ function dumpToFile(aData) {
|
|||
);
|
||||
bos.setOutputStream(outputStream);
|
||||
|
||||
bos.writeByteArray(aData);
|
||||
bos.writeByteArray(aData, aData.length);
|
||||
|
||||
outputStream.close();
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ function test_cross_conversion()
|
|||
while ((av = fin.available()) > 0)
|
||||
{
|
||||
var data = fin.readByteArray(av);
|
||||
bos.writeByteArray(data);
|
||||
bos.writeByteArray(data, data.length);
|
||||
}
|
||||
fin.close();
|
||||
bos.close();
|
||||
|
|
|
@ -973,8 +973,7 @@ static nsresult WriteScriptOrFunction(nsIObjectOutputStream* stream,
|
|||
}
|
||||
rv = stream->Write32(size);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Ideally we could just pass "buffer" here. See bug 1566574.
|
||||
rv = stream->WriteBytes(MakeSpan(buffer.begin(), size));
|
||||
rv = stream->WriteBytes(reinterpret_cast<char*>(buffer.begin()), size);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -62,7 +62,7 @@ function handleRequest(request, response)
|
|||
response.setHeader("Content-Type", "image/png", false);
|
||||
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(IMAGE_DATA);
|
||||
stream.writeByteArray(IMAGE_DATA, IMAGE_DATA.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ function handleRequest(request, response) {
|
|||
|
||||
function imageWrite() {
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(IMAGE_DATA);
|
||||
stream.writeByteArray(IMAGE_DATA, IMAGE_DATA.length);
|
||||
}
|
||||
|
||||
// If there is no delay, we write the image and leave.
|
||||
|
|
|
@ -205,7 +205,7 @@ function handleRequest(request, response) {
|
|||
|
||||
function fontWrite(data) {
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(data);
|
||||
stream.writeByteArray(data, data.length);
|
||||
}
|
||||
|
||||
const nsITimer = Components.interfaces.nsITimer;
|
||||
|
|
|
@ -19,7 +19,7 @@ function handleRequest(request, response)
|
|||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(FONT_DATA);
|
||||
stream.writeByteArray(FONT_DATA, FONT_DATA.length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ function handleRequest(request, response) {
|
|||
|
||||
function fontWrite(data) {
|
||||
var stream = new BinaryOutputStream(response.bodyOutputStream);
|
||||
stream.writeByteArray(data);
|
||||
stream.writeByteArray(data, data.length);
|
||||
}
|
||||
|
||||
var f;
|
||||
|
|
|
@ -39,11 +39,11 @@ function handleRequest(request, response)
|
|||
if (query["q"] == "init") {
|
||||
log = "init"; // initialize the log, and return a PNG image
|
||||
response.setHeader("Content-Type", "image/png", false);
|
||||
stream.writeByteArray(RED_SQUARE);
|
||||
stream.writeByteArray(RED_SQUARE, RED_SQUARE.length);
|
||||
} else if (query["q"] == "image") {
|
||||
log = log + ";" + query["q"];
|
||||
response.setHeader("Content-Type", "image/png", false);
|
||||
stream.writeByteArray(RED_SQUARE);
|
||||
stream.writeByteArray(RED_SQUARE, RED_SQUARE.length);
|
||||
} else if (query["q"] == "font") {
|
||||
log = log + ";" + query["q"];
|
||||
// we don't provide a real font; that's ok, OTS will just reject it
|
||||
|
|
|
@ -1532,10 +1532,9 @@ RequestReader.prototype = {
|
|||
" excess=" +
|
||||
(data.length - count)
|
||||
);
|
||||
data.length = count;
|
||||
|
||||
var bos = new BinaryOutputStream(this._metadata._bodyOutputStream);
|
||||
bos.writeByteArray(data);
|
||||
bos.writeByteArray(data, count);
|
||||
this._contentLength -= count;
|
||||
}
|
||||
|
||||
|
@ -2862,7 +2861,7 @@ ServerHandler.prototype = {
|
|||
", expected " +
|
||||
chunkSize
|
||||
);
|
||||
output.writeByteArray(data);
|
||||
output.writeByteArray(data, data.length);
|
||||
if (count === 0) {
|
||||
fis.close();
|
||||
response.finish();
|
||||
|
|
|
@ -867,9 +867,19 @@ function CustomPipe(name) {
|
|||
//
|
||||
// see nsIBinaryOutputStream.writeByteArray
|
||||
//
|
||||
writeByteArray: function writeByteArray(bytes) {
|
||||
dumpn(`*** [${this.name}].writeByteArray([${bytes}])`);
|
||||
writeByteArray: function writeByteArray(bytes, length) {
|
||||
dumpn(
|
||||
"*** [" +
|
||||
this.name +
|
||||
"].writeByteArray" +
|
||||
"([" +
|
||||
bytes +
|
||||
"], " +
|
||||
length +
|
||||
")"
|
||||
);
|
||||
|
||||
Assert.equal(bytes.length, length, "sanity");
|
||||
if (!Components.isSuccessCode(self._status)) {
|
||||
throw self._status;
|
||||
}
|
||||
|
@ -880,12 +890,12 @@ function CustomPipe(name) {
|
|||
"writeByteArray can't support specified-length writes"
|
||||
);
|
||||
|
||||
if (this._writable < bytes.length) {
|
||||
if (this._writable < length) {
|
||||
throw Cr.NS_BASE_STREAM_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
self._data.push.apply(self._data, bytes);
|
||||
this._writable -= bytes.length;
|
||||
this._writable -= length;
|
||||
|
||||
if (
|
||||
input._readable === Infinity &&
|
||||
|
@ -1154,7 +1164,7 @@ CopyTest.prototype = {
|
|||
|
||||
try {
|
||||
self._copyableDataStream.makeWritable(bytes.length);
|
||||
self._copyableDataStream.writeByteArray(bytes);
|
||||
self._copyableDataStream.writeByteArray(bytes, bytes.length);
|
||||
} finally {
|
||||
self._stageNextTask();
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ function handleAsyncOrdering(request, response) {
|
|||
}
|
||||
|
||||
try {
|
||||
out.writeByteArray(data);
|
||||
out.writeByteArray(data, data.length);
|
||||
step();
|
||||
} catch (e) {
|
||||
try {
|
||||
|
|
|
@ -91,6 +91,6 @@ function handler(metadata, response) {
|
|||
bos.setOutputStream(response.bodyOutputStream);
|
||||
|
||||
response.processAsync();
|
||||
bos.writeByteArray(responseBody);
|
||||
bos.writeByteArray(responseBody, responseBody.length);
|
||||
response.finish();
|
||||
}
|
||||
|
|
|
@ -203,6 +203,6 @@ function handler(metadata, response) {
|
|||
bos.setOutputStream(response.bodyOutputStream);
|
||||
|
||||
response.processAsync();
|
||||
bos.writeByteArray(tests[index].body);
|
||||
bos.writeByteArray(tests[index].body, tests[index].body.length);
|
||||
response.finish();
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ function cachedHandler(metadata, response) {
|
|||
bos.setOutputStream(response.bodyOutputStream);
|
||||
|
||||
response.processAsync();
|
||||
bos.writeByteArray(body);
|
||||
bos.writeByteArray(body, body.length);
|
||||
response.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ function handler_4(metadata, response) {
|
|||
);
|
||||
bos.setOutputStream(response.bodyOutputStream);
|
||||
response.processAsync();
|
||||
bos.writeByteArray(body);
|
||||
bos.writeByteArray(body, body.length);
|
||||
response.finish();
|
||||
break;
|
||||
case 1:
|
||||
|
|
|
@ -129,7 +129,7 @@ function serverHandler_GZip(metadata, response) {
|
|||
Ci.nsIBinaryOutputStream
|
||||
);
|
||||
bos.setOutputStream(response.bodyOutputStream);
|
||||
bos.writeByteArray(httpbodyGZip);
|
||||
bos.writeByteArray(httpbodyGZip, httpbodyGZip.length);
|
||||
if (dbg) {
|
||||
print("============== serverHandler GZip: out");
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "mozilla/Span.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -1195,7 +1194,7 @@ nsNSSCertificate::Write(nsIObjectOutputStream* aStream) {
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return aStream->WriteBytes(AsBytes(MakeSpan(mCert->derCert.data, mCert->derCert.len)));
|
||||
return aStream->WriteByteArray(mCert->derCert.data, mCert->derCert.len);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1809,7 +1809,10 @@ add_task(async function test_with_content_encoding() {
|
|||
);
|
||||
|
||||
let bos = new BinaryOutputStream(aResponse.bodyOutputStream);
|
||||
bos.writeByteArray(TEST_DATA_SHORT_GZIP_ENCODED);
|
||||
bos.writeByteArray(
|
||||
TEST_DATA_SHORT_GZIP_ENCODED,
|
||||
TEST_DATA_SHORT_GZIP_ENCODED.length
|
||||
);
|
||||
});
|
||||
|
||||
let download = await promiseStartDownload(sourceUrl);
|
||||
|
@ -1846,7 +1849,10 @@ add_task(async function test_with_content_encoding_ignore_extension() {
|
|||
);
|
||||
|
||||
let bos = new BinaryOutputStream(aResponse.bodyOutputStream);
|
||||
bos.writeByteArray(TEST_DATA_SHORT_GZIP_ENCODED);
|
||||
bos.writeByteArray(
|
||||
TEST_DATA_SHORT_GZIP_ENCODED,
|
||||
TEST_DATA_SHORT_GZIP_ENCODED.length
|
||||
);
|
||||
});
|
||||
|
||||
let download = await promiseStartDownload(sourceUrl);
|
||||
|
|
|
@ -870,11 +870,17 @@ add_task(function test_common_initialize() {
|
|||
);
|
||||
|
||||
let bos = new BinaryOutputStream(aResponse.bodyOutputStream);
|
||||
bos.writeByteArray(TEST_DATA_SHORT_GZIP_ENCODED_FIRST);
|
||||
bos.writeByteArray(
|
||||
TEST_DATA_SHORT_GZIP_ENCODED_FIRST,
|
||||
TEST_DATA_SHORT_GZIP_ENCODED_FIRST.length
|
||||
);
|
||||
},
|
||||
function secondPart(aRequest, aResponse) {
|
||||
let bos = new BinaryOutputStream(aResponse.bodyOutputStream);
|
||||
bos.writeByteArray(TEST_DATA_SHORT_GZIP_ENCODED_SECOND);
|
||||
bos.writeByteArray(
|
||||
TEST_DATA_SHORT_GZIP_ENCODED_SECOND,
|
||||
TEST_DATA_SHORT_GZIP_ENCODED_SECOND.length
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ function handler(metadata, response) {
|
|||
response.setHeader("Content-Type", "", false);
|
||||
var body = getFileContents(do_get_file(tests[testRan].path));
|
||||
var bos = new BinaryOutputStream(response.bodyOutputStream);
|
||||
bos.writeByteArray(body);
|
||||
bos.writeByteArray(body, body.length);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
@ -49,13 +49,13 @@ function streamDefaultFavicon(uri, loadInfo, outputStream, originalChannel) {
|
|||
}
|
||||
}
|
||||
|
||||
function serveIcon(pipe, data) {
|
||||
function serveIcon(pipe, data, len) {
|
||||
// Pass the icon data to the output stream.
|
||||
let stream = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(
|
||||
Ci.nsIBinaryOutputStream
|
||||
);
|
||||
stream.setOutputStream(pipe.outputStream);
|
||||
stream.writeByteArray(data);
|
||||
stream.writeByteArray(data, len);
|
||||
stream.close();
|
||||
pipe.outputStream.close();
|
||||
}
|
||||
|
@ -109,10 +109,7 @@ PageIconProtocolHandler.prototype = {
|
|||
try {
|
||||
channel.contentType = mimeType;
|
||||
channel.contentLength = len;
|
||||
if (len != data.length) {
|
||||
throw new Error("Unexpected data length");
|
||||
}
|
||||
serveIcon(pipe, data);
|
||||
serveIcon(pipe, data, len);
|
||||
} catch (ex) {
|
||||
streamDefaultFavicon(uri, loadInfo, pipe.outputStream, channel);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ function write_string_to_file(file, contents) {
|
|||
bos.setOutputStream(ostream);
|
||||
|
||||
let utf8 = new TextEncoder("utf-8").encode(contents);
|
||||
bos.writeByteArray(utf8);
|
||||
bos.writeByteArray(utf8, utf8.length);
|
||||
ostream.QueryInterface(Ci.nsISafeOutputStream).finish();
|
||||
ostream.close();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "mozilla/EndianUtils.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Span.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
|
@ -42,11 +41,8 @@
|
|||
#include "js/RootingAPI.h" // JS::{Handle,Rooted}
|
||||
#include "js/Value.h" // JS::Value
|
||||
|
||||
using mozilla::AsBytes;
|
||||
using mozilla::MakeSpan;
|
||||
using mozilla::MakeUnique;
|
||||
using mozilla::PodCopy;
|
||||
using mozilla::Span;
|
||||
using mozilla::UniquePtr;
|
||||
|
||||
already_AddRefed<nsIObjectOutputStream> NS_NewObjectOutputStream(
|
||||
|
@ -210,8 +206,11 @@ nsBinaryOutputStream::WriteStringZ(const char* aString) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::WriteWStringZ(const char16_t* aString) {
|
||||
uint32_t length = NS_strlen(aString);
|
||||
nsresult rv = Write32(length);
|
||||
uint32_t length, byteCount;
|
||||
nsresult rv;
|
||||
|
||||
length = NS_strlen(aString);
|
||||
rv = Write32(length);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -219,9 +218,10 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString) {
|
|||
if (length == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
byteCount = length * sizeof(char16_t);
|
||||
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
rv = WriteBytes(AsBytes(MakeSpan(aString, length)));
|
||||
rv = WriteBytes(reinterpret_cast<const char*>(aString), byteCount);
|
||||
#else
|
||||
// XXX use WriteSegments here to avoid copy!
|
||||
char16_t* copy;
|
||||
|
@ -229,14 +229,14 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString) {
|
|||
if (length <= 64) {
|
||||
copy = temp;
|
||||
} else {
|
||||
copy = static_cast<char16_t*>(malloc(length * sizeof(char16_t)));
|
||||
copy = reinterpret_cast<char16_t*>(malloc(byteCount));
|
||||
if (!copy) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
NS_ASSERTION((uintptr_t(aString) & 0x1) == 0, "aString not properly aligned");
|
||||
mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
|
||||
rv = WriteBytes(AsBytes(MakeSpan(copy, length)));
|
||||
rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
|
||||
if (copy != temp) {
|
||||
free(copy);
|
||||
}
|
||||
|
@ -250,29 +250,24 @@ nsBinaryOutputStream::WriteUtf8Z(const char16_t* aString) {
|
|||
return WriteStringZ(NS_ConvertUTF16toUTF8(aString).get());
|
||||
}
|
||||
|
||||
nsresult nsBinaryOutputStream::WriteBytes(Span<const uint8_t> aBytes) {
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::WriteBytes(const char* aString, uint32_t aLength) {
|
||||
nsresult rv;
|
||||
uint32_t bytesWritten;
|
||||
|
||||
rv = Write(reinterpret_cast<const char*>(aBytes.Elements()), aBytes.Length(),
|
||||
&bytesWritten);
|
||||
rv = Write(aString, aLength, &bytesWritten);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (bytesWritten != aBytes.Length()) {
|
||||
if (bytesWritten != aLength) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::WriteBytesFromJS(const char* aString, uint32_t aLength) {
|
||||
return WriteBytes(AsBytes(MakeSpan(aString, aLength)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::WriteByteArray(const nsTArray<uint8_t>& aByteArray) {
|
||||
return WriteBytes(aByteArray);
|
||||
nsBinaryOutputStream::WriteByteArray(uint8_t* aBytes, uint32_t aLength) {
|
||||
return WriteBytes(reinterpret_cast<char*>(aBytes), aLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -345,7 +340,7 @@ nsBinaryOutputStream::WriteID(const nsIID& aIID) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = WriteBytes(aIID.m3);
|
||||
rv = WriteBytes(reinterpret_cast<const char*>(&aIID.m3[0]), sizeof(aIID.m3));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,6 @@
|
|||
|
||||
#include "nsIOutputStream.idl"
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
template<class ElementType, size_t Extent> class Span;
|
||||
}
|
||||
%}
|
||||
native Bytes(mozilla::Span<const uint8_t>);
|
||||
|
||||
/**
|
||||
* This interface allows writing of primitive data types (integers,
|
||||
* floating-point values, booleans, etc.) to a stream in a binary, untagged,
|
||||
|
@ -62,20 +55,15 @@ interface nsIBinaryOutputStream : nsIOutputStream {
|
|||
/**
|
||||
* Write an opaque byte array to the stream.
|
||||
*/
|
||||
[binaryname(WriteBytesFromJS)]
|
||||
void writeBytes([size_is(aLength)] in string aString,
|
||||
[optional] in uint32_t aLength);
|
||||
|
||||
/**
|
||||
* Non-scriptable and saner-signature version of the same.
|
||||
*/
|
||||
[noscript, nostdcall, binaryname(WriteBytes)]
|
||||
void writeBytesNative(in Bytes aBytes);
|
||||
|
||||
/**
|
||||
* Write an opaque byte array to the stream.
|
||||
*/
|
||||
void writeByteArray(in Array<uint8_t> aBytes);
|
||||
void writeByteArray([array, size_is(aLength)] in uint8_t aBytes,
|
||||
[optional] in uint32_t aLength);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -117,7 +117,7 @@ function test4() {
|
|||
);
|
||||
bos.setOutputStream(outStream);
|
||||
|
||||
bos.writeByteArray(bytes);
|
||||
bos.writeByteArray(bytes, bytes.length);
|
||||
bos.close();
|
||||
|
||||
var inp = ss.newInputStream(0);
|
||||
|
|
|
@ -67,13 +67,13 @@ function test_binary_streams() {
|
|||
Assert.equal(msg, HelloStr);
|
||||
msg = null;
|
||||
countObj.value = -1;
|
||||
os.writeByteArray(HelloArray);
|
||||
os.writeByteArray(HelloArray, HelloArray.length);
|
||||
Assert.equal(is.available(), HelloStr.length);
|
||||
msg = is.readByteArray(HelloStr.length);
|
||||
Assert.equal(typeof msg, typeof HelloArray);
|
||||
Assert.equal(msg.toSource(), HelloArray.toSource());
|
||||
Assert.equal(is.available(), 0);
|
||||
os.writeByteArray(HelloArray);
|
||||
os.writeByteArray(HelloArray, HelloArray.length);
|
||||
Assert.equal(
|
||||
is.readArrayBuffer(buffer.byteLength, buffer),
|
||||
HelloArray.length
|
||||
|
@ -96,7 +96,7 @@ function test_binary_streams() {
|
|||
os.writeStringZ("Mozilla");
|
||||
os.writeWStringZ("Gecko");
|
||||
os.writeBytes(HelloStr, HelloStr.length);
|
||||
os.writeByteArray(HelloArray);
|
||||
os.writeByteArray(HelloArray, HelloArray.length);
|
||||
// Available should not be zero after a long write like this.
|
||||
Assert.notEqual(is.available(), 0);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче