1#![allow(unused_extern_crates)]
6#![cfg_attr(feature = "crown", feature(register_tool))]
7#![cfg_attr(feature = "crown", register_tool(crown))]
8#![cfg_attr(feature = "oom_with_hook", feature(alloc_error_hook))]
9
10extern crate encoding_c;
12extern crate encoding_c_mem;
13extern crate icu_capi;
14#[cfg(feature = "libz-rs")]
15extern crate libz_rs_sys;
16#[cfg(feature = "libz-sys")]
17extern crate libz_sys;
18
19mod jsimpls;
21
22pub mod glue;
24pub mod jsgc;
25pub mod jsid;
26pub mod jsval;
27pub mod trace;
28
29pub use crate::generated::root as jsapi;
31
32#[doc(hidden)]
34#[allow(dead_code)]
35mod generated {
36 include!(concat!(env!("OUT_DIR"), "/build/jsapi.rs"));
37}
38
39#[no_mangle]
46pub extern "C" fn install_rust_hooks() {
47 #[cfg(feature = "oom_with_hook")]
49 oom_hook::install();
50}
51
52#[cfg(feature = "oom_with_hook")]
53mod oom_hook {
54 use std::alloc::{set_alloc_error_hook, Layout};
55
56 extern "C" {
57 pub fn RustHandleOOM(size: usize) -> !;
58 }
59
60 pub fn hook(layout: Layout) {
61 unsafe {
62 RustHandleOOM(layout.size());
63 }
64 }
65
66 pub fn install() {
67 set_alloc_error_hook(hook);
68 }
69}