Skip to main content

JS_Eval

Function JS_Eval 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_Eval( ctx: *mut JsContext, input: *const c_char, input_len: usize, filename: *const c_char, eval_flags: c_int, ) -> JsValue
Expand description

JS_Eval: compile and run input as global (or module) code.

The thrown value travels through the pending-exception slot rather than being turned into text, which is the whole point: JS_GetException then hands C the object the script threw, with its message, its stack and any property a host put on it.

Module evaluation needs a module loader, which is S4’s dlopen work; a module eval here reports a TypeError instead of pretending to have run.

§Safety

ctx must be a live context, and input must point at input_len readable bytes; filename may be null or a NUL-terminated string.