Stream: general

Topic: Using Generic pointers in the C FFI


view this post on Zulip MarkJG (Apr 28 2021 at 00:55):

Hey, using the C ffi from C++. It's kind of annoying having a million deleters for every type, have you guys considered making a generic ptr type that boxes the real type alongside the dtor? Meaning you could call wasm_delete(any_wasm_c_type);
Like this:

#[repr(transparent)]
pub struct CWasmPtr {
    pub value: Box<dyn Any>,
}

view this post on Zulip MarkJG (Apr 28 2021 at 00:55):

Would also let you use unique ptr's with custom deleters from the cpp side, instead of raw pointers.

view this post on Zulip MarkJG (Apr 28 2021 at 00:57):

Also looking at https://docs.wasmtime.dev/examples-c-wasi.html, there's a wasm_instance_t that isn't used anywhere

view this post on Zulip MarkJG (Apr 28 2021 at 02:16):

nvm, just found out the C API is based off https://github.com/WebAssembly/wasm-c-api.

Wasm C API prototype. Contribute to WebAssembly/wasm-c-api development by creating an account on GitHub.

Last updated: Nov 22 2024 at 16:03 UTC