Skip to content

Commit b060505

Browse files
committed
merge from main
Signed-off-by: Delan Azabani <[email protected]>
2 parents abce95f + 6c2b02f commit b060505

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ jobs:
248248
runs-on: ubuntu-latest
249249
steps:
250250
- uses: actions/checkout@v4
251+
with:
252+
fetch-depth: 1
251253
- uses: dtolnay/rust-toolchain@stable
252254
- name: Check Rust formatting
253255
run: cargo fmt --check
@@ -271,6 +273,30 @@ jobs:
271273
# check diff with `--staged`.
272274
run: |
273275
git diff --staged --no-ext-diff --quiet --exit-code
276+
- name: Detect need for mozjs-sys version bump
277+
if: ${{ github.event_name == 'pull_request' }}
278+
id: changes
279+
uses: dorny/paths-filter@v3
280+
with:
281+
filters: |
282+
needs_mozjs_sys_bump:
283+
- 'mozjs-sys/src/*.cpp'
284+
- 'mozjs-sys/mozjs/**'
285+
- 'mozjs-sys/*'
286+
287+
- name: Ensure mozjs-sys version is bumped
288+
if: ${{ github.event_name == 'pull_request' && steps.changes.outputs.needs_mozjs_sys_bump == 'true' }}
289+
run: |
290+
git fetch origin main
291+
CHANGED=$(git diff origin/main -- mozjs-sys/Cargo.toml | grep '^+\s*version\s*=' || true)
292+
if [ -n "$CHANGED" ]; then
293+
echo "✅ mozjs-sys version bumped: $CHANGED"
294+
exit 0
295+
else
296+
echo "❌ No mozjs-sys version bump found."
297+
echo "Please bump mozjs-sys version to trigger publishing new artifacts on landing."
298+
exit 1
299+
fi
274300
275301
publish-release:
276302
name: Check version and publish release

mozjs/src/rust.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::glue::{CreateRootedIdVector, CreateRootedObjectVector};
2828
use crate::glue::{
2929
DeleteCompileOptions, DeleteRootedObjectVector, DescribeScriptedCaller, DestroyRootedIdVector,
3030
};
31+
use crate::glue::{DeleteJSAutoStructuredCloneBuffer, NewJSAutoStructuredCloneBuffer};
3132
use crate::glue::{
3233
GetIdVectorAddress, GetObjectVectorAddress, NewCompileOptions, SliceRootedIdVector,
3334
};
@@ -47,6 +48,7 @@ use crate::jsapi::{InitSelfHostedCode, IsWindowSlow};
4748
use crate::jsapi::{
4849
JSAutoRealm, JS_SetGCParameter, JS_SetNativeStackQuota, JS_WrapObject, JS_WrapValue,
4950
};
51+
use crate::jsapi::{JSAutoStructuredCloneBuffer, JSStructuredCloneCallbacks, StructuredCloneScope};
5052
use crate::jsapi::{JSClass, JSClassOps, JSContext, Realm, JSCLASS_RESERVED_SLOTS_SHIFT};
5153
use crate::jsapi::{JSErrorReport, JSFunctionSpec, JSGCParamKey};
5254
use crate::jsapi::{JSObject, JSPropertySpec, JSRuntime};
@@ -532,6 +534,34 @@ impl Drop for CompileOptionsWrapper {
532534
}
533535
}
534536

537+
pub struct JSAutoStructuredCloneBufferWrapper {
538+
ptr: NonNull<JSAutoStructuredCloneBuffer>,
539+
}
540+
541+
impl JSAutoStructuredCloneBufferWrapper {
542+
pub unsafe fn new(
543+
scope: StructuredCloneScope,
544+
callbacks: *const JSStructuredCloneCallbacks,
545+
) -> Self {
546+
let raw_ptr = NewJSAutoStructuredCloneBuffer(scope, callbacks);
547+
Self {
548+
ptr: NonNull::new(raw_ptr).unwrap(),
549+
}
550+
}
551+
552+
pub fn as_raw_ptr(&self) -> *mut JSAutoStructuredCloneBuffer {
553+
self.ptr.as_ptr()
554+
}
555+
}
556+
557+
impl Drop for JSAutoStructuredCloneBufferWrapper {
558+
fn drop(&mut self) {
559+
unsafe {
560+
DeleteJSAutoStructuredCloneBuffer(self.ptr.as_ptr());
561+
}
562+
}
563+
}
564+
535565
pub struct Stencil {
536566
inner: already_AddRefed<CompilationStencil>,
537567
}

0 commit comments

Comments
 (0)