mozjs/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#![crate_name = "mozjs"]
6#![crate_type = "rlib"]
7#![allow(
8    non_upper_case_globals,
9    non_camel_case_types,
10    non_snake_case,
11    improper_ctypes
12)]
13#![cfg_attr(feature = "crown", feature(register_tool))]
14#![cfg_attr(feature = "crown", register_tool(crown))]
15
16//!
17//! This crate contains Rust bindings to the [SpiderMonkey Javascript engine][1]
18//! developed by Mozilla.
19//!
20//! These bindings are designed to be a fairly straightforward translation to the C++ API, while
21//! taking advantage of Rust's memory safety. For more about the Spidermonkey API, see the
22//! [embedding examples][2] on GitHub.
23//!
24//! The code from User Guide sections [A minimal example](https://github.com/servo/mozjs/blob/main/mozjs/examples/minimal.rs) and
25//! [Running scripts](https://github.com/servo/mozjs/blob/main/mozjs/examples/eval.rs) are also included.
26//!
27//! [1]: https://firefox-source-docs.mozilla.org/js/index.html
28//! [2]: https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/
29//!
30
31pub mod jsapi {
32    // Resolve ambiguous imports
33    pub use mozjs_sys::jsapi::js::detail;
34    pub use mozjs_sys::jsapi::JS::{FrontendContext, MemoryUse};
35
36    pub use mozjs_sys::jsapi::glue::*;
37    pub use mozjs_sys::jsapi::js::detail::*;
38    pub use mozjs_sys::jsapi::js::*;
39    pub use mozjs_sys::jsapi::mozilla::MallocSizeOf;
40    pub use mozjs_sys::jsapi::JS::detail::*;
41    pub use mozjs_sys::jsapi::JS::shadow::Object;
42    pub use mozjs_sys::jsapi::JS::Scalar::Type;
43    pub use mozjs_sys::jsapi::JS::*;
44    pub use mozjs_sys::jsapi::*;
45}
46
47#[macro_use]
48pub mod rust;
49
50mod consts;
51pub mod conversions;
52pub mod error;
53pub mod gc;
54pub mod panic;
55pub mod typedarray;
56
57pub use crate::consts::*;
58pub use mozjs_sys::glue;
59pub use mozjs_sys::jsid;
60pub use mozjs_sys::jsval;
61
62pub use crate::jsval::JS_ARGV;
63pub use crate::jsval::JS_CALLEE;