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;
14extern crate libz_sys;
15
16mod jsimpls;
18
19pub mod glue;
21pub mod jsgc;
22pub mod jsid;
23pub mod jsval;
24pub mod trace;
25
26pub use crate::generated::root as jsapi;
28
29#[doc(hidden)]
31#[allow(dead_code)]
32mod generated {
33 include!(concat!(env!("OUT_DIR"), "/build/jsapi.rs"));
34}
35
36#[no_mangle]
43pub extern "C" fn install_rust_hooks() {
44 #[cfg(feature = "oom_with_hook")]
46 oom_hook::install();
47}
48
49#[cfg(feature = "oom_with_hook")]
50mod oom_hook {
51 use std::alloc::{set_alloc_error_hook, Layout};
52
53 extern "C" {
54 pub fn RustHandleOOM(size: usize) -> !;
55 }
56
57 pub fn hook(layout: Layout) {
58 unsafe {
59 RustHandleOOM(layout.size());
60 }
61 }
62
63 pub fn install() {
64 set_alloc_error_hook(hook);
65 }
66}