Function mozjs_sys::jsapi::JS_Utf8BufferIsCompilableUnit

source ·
pub unsafe extern "C" fn JS_Utf8BufferIsCompilableUnit(
    cx: *mut JSContext,
    obj: Handle<*mut JSObject>,
    utf8: *const c_char,
    length: usize,
) -> bool
Expand description

Given a buffer, return false if the buffer might become a valid JavaScript script with the addition of more lines, or true if the validity of such a script is conclusively known (because it’s the prefix of a valid script – and possibly the entirety of such a script).

The intent of this function is to enable interactive compilation: accumulate lines in a buffer until JS_Utf8BufferIsCompilableUnit is true, then pass it to the compiler.

The provided buffer is interpreted as UTF-8 data. If a UTF-8 encoding error is encountered, reports an error to JSContext and returns true.