Skip to main content

JS_NewCModule

Function JS_NewCModule 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_NewCModule( ctx: *mut JsContext, name_str: *const c_char, func: ModuleInitFunc, ) -> *mut JsModuleDef
Expand description

JS_NewCModule: create a module and remember how to fill it in.

The init function is not called here — it runs when the module is instantiated, which is after every JS_AddModuleExport has declared the names. Answers a null pointer only when ctx is null or name_str is null; allocation failure is not observable at this level because the definition is a plain Rust allocation.

§Safety

ctx must be a live context and name_str a NUL-terminated string. func must be a valid JSModuleInitFunc.