Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mozjs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mozjs_sys"
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
repository.workspace = true
version = "0.128.3-1"
version = "0.128.3-2"
authors = ["Mozilla"]
links = "mozjs"
build = "build.rs"
Expand Down
4 changes: 3 additions & 1 deletion mozjs-sys/src/jsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include "js/ScalarType.h"
#include "js/SharedArrayBuffer.h"
#include "js/SourceText.h"
#include "js/Stream.h"
#ifdef MOZ_JS_STREAMS
# include "js/Stream.h"
#endif
#include "js/String.h"
#include "js/StructuredClone.h"
#include "js/Symbol.h"
Expand Down
8 changes: 7 additions & 1 deletion mozjs-sys/src/jsglue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include "js/Proxy.h"
#include "js/RegExp.h"
#include "js/ScalarType.h"
#include "js/Stream.h"
#ifdef MOZ_JS_STREAMS
# include "js/Stream.h"
#endif
#include "js/StructuredClone.h"
#include "js/Wrapper.h"
#include "js/experimental/JSStencil.h"
Expand Down Expand Up @@ -86,6 +88,7 @@ class RustJobQueue : public JS::JobQueue {
}
};

#ifdef MOZ_JS_STREAMS
struct ReadableStreamUnderlyingSourceTraps {
void (*requestData)(const void* source, JSContext* cx,
JS::HandleObject stream, size_t desiredSize);
Expand Down Expand Up @@ -142,6 +145,7 @@ class RustReadableStreamUnderlyingSource

virtual void finalize() { return mTraps.finalize(this); }
};
#endif

struct JSExternalStringCallbacksTraps {
void (*latin1Finalize)(const void* privateData, JS::Latin1Char* chars);
Expand Down Expand Up @@ -1075,6 +1079,7 @@ JS::JobQueue* CreateJobQueue(const JobQueueTraps* aTraps, const void* aQueue) {

void DeleteJobQueue(JS::JobQueue* queue) { delete queue; }

#ifdef MOZ_JS_STREAMS
JS::ReadableStreamUnderlyingSource* CreateReadableStreamUnderlyingSource(
const ReadableStreamUnderlyingSourceTraps* aTraps, const void* aSource) {
return new RustReadableStreamUnderlyingSource(*aTraps, aSource);
Expand All @@ -1084,6 +1089,7 @@ void DeleteReadableStreamUnderlyingSource(
JS::ReadableStreamUnderlyingSource* source) {
delete source;
}
#endif

JSExternalStringCallbacks* CreateJSExternalStringCallbacks(
const JSExternalStringCallbacksTraps* aTraps, void* privateData) {
Expand Down
2 changes: 2 additions & 0 deletions mozjs/src/generate_wrappers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ find_latest_version_of_file_and_parse() {

# parse reformated file
grep_heur "target/wrap_$1" | $gsed 's/\(.*\)/wrap!('"$2"': \1);/g' > "mozjs/src/$2_wrappers.in"
$gsed -i '/Readable/i \
#[cfg(feature = "streams")]' "mozjs/src/$2_wrappers.in"
}

find_latest_version_of_file_and_parse jsapi.rs jsapi
Expand Down
19 changes: 19 additions & 0 deletions mozjs/src/jsapi_wrappers.in
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,43 @@ wrap!(jsapi: pub fn GetSavedFrameAsyncCause(cx: *mut JSContext, principals: *mut
wrap!(jsapi: pub fn GetSavedFrameAsyncParent(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, asyncParentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult);
wrap!(jsapi: pub fn GetSavedFrameParent(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, parentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult);
wrap!(jsapi: pub fn ConvertSavedFrameToPlainObject(cx: *mut JSContext, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn NewReadableDefaultStreamObject(cx: *mut JSContext, underlyingSource: HandleObject, size: HandleFunction, highWaterMark: f64, proto: HandleObject) -> *mut JSObject);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn NewReadableExternalSourceStreamObject(cx: *mut JSContext, underlyingSource: *mut ReadableStreamUnderlyingSource, nsISupportsObject_alreadyAddreffed: *mut ::std::os::raw::c_void, proto: HandleObject) -> *mut JSObject);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamGetExternalUnderlyingSource(cx: *mut JSContext, stream: HandleObject, source: *mut *mut ReadableStreamUnderlyingSource) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamReleaseExternalUnderlyingSource(cx: *mut JSContext, stream: HandleObject) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamUpdateDataAvailableFromSource(cx: *mut JSContext, stream: HandleObject, availableData: u32) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamGetMode(cx: *mut JSContext, stream: HandleObject, mode: *mut ReadableStreamMode) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamIsReadable(cx: *mut JSContext, stream: HandleObject, result: *mut bool) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamIsLocked(cx: *mut JSContext, stream: HandleObject, result: *mut bool) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamIsDisturbed(cx: *mut JSContext, stream: HandleObject, result: *mut bool) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamCancel(cx: *mut JSContext, stream: HandleObject, reason: HandleValue) -> *mut JSObject);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamGetReader(cx: *mut JSContext, stream: HandleObject, mode: ReadableStreamReaderMode) -> *mut JSObject);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamTee(cx: *mut JSContext, stream: HandleObject, branch1Stream: MutableHandleObject, branch2Stream: MutableHandleObject) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamClose(cx: *mut JSContext, stream: HandleObject) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamReaderIsClosed(cx: *mut JSContext, reader: HandleObject, result: *mut bool) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamEnqueue(cx: *mut JSContext, stream: HandleObject, chunk: HandleValue) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamError(cx: *mut JSContext, stream: HandleObject, error: HandleValue) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamReaderCancel(cx: *mut JSContext, reader: HandleObject, reason: HandleValue) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamReaderReleaseLock(cx: *mut JSContext, reader: HandleObject) -> bool);
#[cfg(feature = "streams")]
wrap!(jsapi: pub fn ReadableStreamDefaultReaderRead(cx: *mut JSContext, reader: HandleObject) -> *mut JSObject);
wrap!(jsapi: pub fn IsWasmModuleObject(obj: HandleObject) -> bool);
wrap!(jsapi: pub fn GetWasmModule(obj: HandleObject) -> RefPtr<WasmModule>);
Expand Down
6 changes: 6 additions & 0 deletions mozjs/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,11 @@ pub mod wrappers {
use crate::jsapi::PromiseState;
use crate::jsapi::PromiseUserInputEventHandlingState;
use crate::jsapi::ReadOnlyCompileOptions;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamMode;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamReaderMode;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamUnderlyingSource;
use crate::jsapi::Realm;
use crate::jsapi::RefPtr;
Expand Down Expand Up @@ -1313,8 +1316,11 @@ pub mod jsapi_wrapped {
use crate::jsapi::PromiseUserInputEventHandlingState;
use crate::jsapi::PropertyKey;
use crate::jsapi::ReadOnlyCompileOptions;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamMode;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamReaderMode;
#[cfg(feature = "streams")]
use crate::jsapi::ReadableStreamUnderlyingSource;
use crate::jsapi::Realm;
use crate::jsapi::RefPtr;
Expand Down