ul_next/
javascript.rs

1//! JavaScriptCore bindings for Ultralight.
2//!
3//! This module provides a high-level API for working with JavaScriptCore in
4//! Ultralight. It is a thin wrapper around the C API provided by JavaScriptCore.
5//!
6//! # Example
7//! ```rust,no_run
8//! # use ul_next::javascript::*;
9//! # let context: JSContext = unsafe {std::mem::zeroed()};
10//! # let lib: std::sync::Arc<ul_next::Library> = unsafe {std::mem::zeroed()};
11//!
12//! let object = context.global_object();
13//! let string = JSValue::new_string(&context, "Hello, world!");
14//! object.set_property("greeting", &string, JSPropertyAttributes::default());
15//!
16//! // this can be called from JavaScript
17//! let rust_callback = JSObject::new_function_with_callback(&context, |ctx, this, args| {
18//!     Ok(JSValue::new_string(ctx, "Hello from Rust!"))
19//! });
20//! object.set_property("rustCallback", &rust_callback, JSPropertyAttributes::default());
21//! ```
22
23mod class;
24mod context;
25mod object;
26mod string;
27mod typed_array;
28mod value;
29
30pub use context::JSContext;
31pub use object::{JSObject, JSPropertyAttributes, JSPropertyNameArray};
32pub use string::JSString;
33pub use typed_array::{JSTypedArray, JSTypedArrayType};
34pub use value::{AsJSValue, JSType, JSValue};