small changes in module loading code

This commit is contained in:
Sebastian Moser
2024-12-01 11:05:31 +01:00
parent 27f3a69e85
commit c47403233e
5 changed files with 48 additions and 9 deletions

View File

@@ -52,13 +52,17 @@ macro_rules! console_log {
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
pub fn wasm_instance_init(instance: &mut Instance) -> MizeResult<()> {
console_log!("Hello world from wasm_instance_init!!!!!!!!!!");
Ok(())
}
pub fn load_module(instance: &mut Instance, name: &str, path: Option<String>) -> MizeResult<()> {
console_log!("loading module: {}", name);
Ok(())
}
#[wasm_bindgen]
pub struct JsInstance {
inner: NonNull<Instance>,
@@ -76,6 +80,8 @@ pub struct JsItemHandle {
impl JsInstance {
#[wasm_bindgen(constructor)]
pub fn new() -> JsInstance {
panic::set_hook(Box::new(console_error_panic_hook::hook));
let instance = match Instance::new() {
@@ -85,6 +91,8 @@ impl JsInstance {
panic!()
},
};
let mut js_instance = JsInstance { inner: NonNull::from(Box::leak(Box::new(instance))) };
return js_instance;
}