1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! redjs — full-control Rust embedding layer over Bun's JavaScriptCore
//! prebuilt, for Rust hosts and — through a C ABI — any other embedder.
//!
//! Layers:
//! - [`glue`]: raw externs into our C++ glue (`cpp/glue.cpp`, JSC internal API).
//! - [`capi`]: raw externs into JSC's stable C API (the subset we use).
//! - [`trampoline`]: the platform host-function trampoline pool (C# entry).
//! - [`errors`]: the one funnel for exceptions no JS code will ever see —
//! pumped-callback throws, listener throws and unhandled promise rejections.
//! - [`context`]: a monotonic, never-reused id per context, and the one list
//! of per-context registries cleared when an address stops meaning its
//! context.
//! - [`ffi`]: the exported `redjs_*` C ABI for C# (csbindgen input).
//! - [`api`]: safe-ish Rust API over the same machinery (tests, tools, and
//! any Rust-side host logic).
//!
//! Values across every boundary are JSC `EncodedJSValue` bits (`u64`,
//! JSVALUE64 NaN-boxing). Numbers/bools/undefined/null en/decode without FFI
//! using the constants from [`ffi::RjsLayout`].
//!
//! # Lifetime & GC contract
//! A `u64` value held on the native stack while the thread is inside the VM
//! is protected by JSC's conservative stack scan. Anything stored on the heap
//! (C# fields, Rust collections) must be pinned with `redjs_protect` /
//! [`api::Context::protect`] and released with `redjs_unprotect`.
/// Declare a JSC host callback using the ABI of the compilation target.
pub use host_fn;