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;
13#[cfg(feature = "intl")]
14extern crate icu_capi;
15#[cfg(feature = "libz-rs")]
16extern crate libz_rs_sys;
17#[cfg(feature = "libz-sys")]
18extern crate libz_sys;
19
20mod jsimpls;
22
23pub mod glue;
25pub mod jsgc;
26pub mod jsid;
27pub mod jsval;
28pub mod trace;
29
30pub use crate::generated::root as jsapi;
32
33#[doc(hidden)]
35#[allow(dead_code)]
36mod generated {
37 include!(concat!(env!("OUT_DIR"), "/build/jsapi.rs"));
38}
39
40#[no_mangle]
47pub extern "C" fn install_rust_hooks() {
48 #[cfg(feature = "oom_with_hook")]
50 oom_hook::install();
51}
52
53#[cfg(feature = "oom_with_hook")]
54mod oom_hook {
55 use std::alloc::{set_alloc_error_hook, Layout};
56
57 extern "C" {
58 pub fn RustHandleOOM(size: usize) -> !;
59 }
60
61 pub fn hook(layout: Layout) {
62 unsafe {
63 RustHandleOOM(layout.size());
64 }
65 }
66
67 pub fn install() {
68 set_alloc_error_hook(hook);
69 }
70}