Bug 1501387 - Handlify Streams.h and avoid using const JSObject*. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D9566

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Orendorff 2018-10-23 19:02:04 +00:00
parent 5ec6faca84
commit a787b6a30c
2 changed files with 36 additions and 33 deletions

View File

@ -220,7 +220,7 @@ NewReadableExternalSourceStreamObject(JSContext* cx, void* underlyingSource,
* Asserts that the given stream has an embedding-provided underlying source.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamGetEmbeddingFlags(JSContext* cx, const JSObject* stream, uint8_t* flags);
ReadableStreamGetEmbeddingFlags(JSContext* cx, HandleObject stream, uint8_t* flags);
/**
* Returns the embedding-provided underlying source of the given |stream|.
@ -262,7 +262,7 @@ ReadableStreamGetExternalUnderlyingSource(JSContext* cx, HandleObject stream, vo
* Asserts that the stream has an embedding-provided underlying source.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamReleaseExternalUnderlyingSource(JSContext* cx, JSObject* stream);
ReadableStreamReleaseExternalUnderlyingSource(JSContext* cx, HandleObject stream);
/**
* Update the amount of data available at the underlying source of the given
@ -284,7 +284,7 @@ ReadableStreamUpdateDataAvailableFromSource(JSContext* cx, HandleObject stream,
* unwrappable wrapper for one, false otherwise.
*/
extern JS_PUBLIC_API(bool)
IsReadableStream(const JSObject* obj);
IsReadableStream(JSObject* obj);
/**
* Returns true if the given object is a ReadableStreamDefaultReader or
@ -292,14 +292,14 @@ IsReadableStream(const JSObject* obj);
* otherwise.
*/
extern JS_PUBLIC_API(bool)
IsReadableStreamReader(const JSObject* obj);
IsReadableStreamReader(JSObject* obj);
/**
* Returns true if the given object is a ReadableStreamDefaultReader object
* or an unwrappable wrapper for one, false otherwise.
*/
extern JS_PUBLIC_API(bool)
IsReadableStreamDefaultReader(const JSObject* obj);
IsReadableStreamDefaultReader(JSObject* obj);
enum class ReadableStreamMode {
Default,
@ -316,7 +316,7 @@ enum class ReadableStreamMode {
* for one.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamGetMode(JSContext* cx, const JSObject* stream, ReadableStreamMode* mode);
ReadableStreamGetMode(JSContext* cx, HandleObject stream, ReadableStreamMode* mode);
enum class ReadableStreamReaderMode {
Default
@ -329,7 +329,7 @@ enum class ReadableStreamReaderMode {
* for one.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamIsReadable(JSContext* cx, const JSObject* stream, bool* result);
ReadableStreamIsReadable(JSContext* cx, HandleObject stream, bool* result);
/**
* Returns true if the given ReadableStream is locked, false if not.
@ -338,7 +338,7 @@ ReadableStreamIsReadable(JSContext* cx, const JSObject* stream, bool* result);
* for one.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamIsLocked(JSContext* cx, const JSObject* stream, bool* result);
ReadableStreamIsLocked(JSContext* cx, HandleObject stream, bool* result);
/**
* Returns true if the given ReadableStream is disturbed, false if not.
@ -347,7 +347,7 @@ ReadableStreamIsLocked(JSContext* cx, const JSObject* stream, bool* result);
* for one.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamIsDisturbed(JSContext* cx, const JSObject* stream, bool* result);
ReadableStreamIsDisturbed(JSContext* cx, HandleObject stream, bool* result);
/**
* Cancels the given ReadableStream with the given reason and returns a
@ -422,7 +422,7 @@ ReadableStreamClose(JSContext* cx, HandleObject stream);
* ReadableStreamBYOBReader object or an unwrappable wrapper for one.
*/
extern JS_PUBLIC_API(bool)
ReadableStreamReaderIsClosed(JSContext* cx, const JSObject* reader, bool* result);
ReadableStreamReaderIsClosed(JSContext* cx, HandleObject reader, bool* result);
/**
* Enqueues the given chunk in the given ReadableStream.

View File

@ -4717,26 +4717,29 @@ JS::NewReadableExternalSourceStreamObject(JSContext* cx, void* underlyingSource,
}
JS_PUBLIC_API(bool)
JS::IsReadableStream(const JSObject* obj)
JS::IsReadableStream(JSObject* obj)
{
if (IsWrapper(const_cast<JSObject*>(obj)))
obj = CheckedUnwrap(const_cast<JSObject*>(obj));
if (IsWrapper(obj)) {
obj = CheckedUnwrap(obj);
}
return obj && obj->is<ReadableStream>();
}
JS_PUBLIC_API(bool)
JS::IsReadableStreamReader(const JSObject* obj)
JS::IsReadableStreamReader(JSObject* obj)
{
if (IsWrapper(const_cast<JSObject*>(obj)))
obj = CheckedUnwrap(const_cast<JSObject*>(obj));
if (IsWrapper(obj)) {
obj = CheckedUnwrap(obj);
}
return obj && obj->is<ReadableStreamDefaultReader>();
}
JS_PUBLIC_API(bool)
JS::IsReadableStreamDefaultReader(const JSObject* obj)
JS::IsReadableStreamDefaultReader(JSObject* obj)
{
if (IsWrapper(const_cast<JSObject*>(obj)))
obj = CheckedUnwrap(const_cast<JSObject*>(obj));
if (IsWrapper(obj)) {
obj = CheckedUnwrap(obj);
}
return obj && obj->is<ReadableStreamDefaultReader>();
}
@ -4756,9 +4759,9 @@ ToUnwrapped(JSContext* cx, JSObject* obj)
}
JS_PUBLIC_API(bool)
JS::ReadableStreamIsReadable(JSContext* cx, const JSObject* streamObj, bool* result)
JS::ReadableStreamIsReadable(JSContext* cx, HandleObject streamObj, bool* result)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4767,9 +4770,9 @@ JS::ReadableStreamIsReadable(JSContext* cx, const JSObject* streamObj, bool* res
}
JS_PUBLIC_API(bool)
JS::ReadableStreamIsLocked(JSContext* cx, const JSObject* streamObj, bool* result)
JS::ReadableStreamIsLocked(JSContext* cx, HandleObject streamObj, bool* result)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4778,9 +4781,9 @@ JS::ReadableStreamIsLocked(JSContext* cx, const JSObject* streamObj, bool* resul
}
JS_PUBLIC_API(bool)
JS::ReadableStreamIsDisturbed(JSContext* cx, const JSObject* streamObj, bool* result)
JS::ReadableStreamIsDisturbed(JSContext* cx, HandleObject streamObj, bool* result)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4789,9 +4792,9 @@ JS::ReadableStreamIsDisturbed(JSContext* cx, const JSObject* streamObj, bool* re
}
JS_PUBLIC_API(bool)
JS::ReadableStreamGetEmbeddingFlags(JSContext* cx, const JSObject* streamObj, uint8_t* flags)
JS::ReadableStreamGetEmbeddingFlags(JSContext* cx, HandleObject streamObj, uint8_t* flags)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4814,9 +4817,9 @@ JS::ReadableStreamCancel(JSContext* cx, HandleObject streamObj, HandleValue reas
}
JS_PUBLIC_API(bool)
JS::ReadableStreamGetMode(JSContext* cx, const JSObject* streamObj, JS::ReadableStreamMode* mode)
JS::ReadableStreamGetMode(JSContext* cx, HandleObject streamObj, JS::ReadableStreamMode* mode)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4853,9 +4856,9 @@ JS::ReadableStreamGetExternalUnderlyingSource(JSContext* cx, HandleObject stream
}
JS_PUBLIC_API(bool)
JS::ReadableStreamReleaseExternalUnderlyingSource(JSContext* cx, JSObject* streamObj)
JS::ReadableStreamReleaseExternalUnderlyingSource(JSContext* cx, HandleObject streamObj)
{
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, const_cast<JSObject*>(streamObj));
ReadableStream* stream = ToUnwrapped<ReadableStream>(cx, streamObj);
if (!stream)
return false;
@ -4960,9 +4963,9 @@ JS::ReadableStreamError(JSContext* cx, HandleObject streamObj, HandleValue error
}
JS_PUBLIC_API(bool)
JS::ReadableStreamReaderIsClosed(JSContext* cx, const JSObject* reader, bool* result)
JS::ReadableStreamReaderIsClosed(JSContext* cx, HandleObject readerObj, bool* result)
{
reader = ToUnwrapped<NativeObject>(cx, const_cast<JSObject*>(reader));
RootedObject reader(cx, ToUnwrapped<NativeObject>(cx, readerObj));
if (!reader)
return false;