diff --git a/crates/c-api/src/linker.rs b/crates/c-api/src/linker.rs index b712e4a9b8..d5ad429fdd 100644 --- a/crates/c-api/src/linker.rs +++ b/crates/c-api/src/linker.rs @@ -12,6 +12,8 @@ pub struct wasmtime_linker_t { linker: Linker, } +wasmtime_c_api_macros::declare_own!(wasmtime_linker_t); + #[no_mangle] pub extern "C" fn wasmtime_linker_new(engine: &wasm_engine_t) -> Box { Box::new(wasmtime_linker_t { @@ -27,9 +29,6 @@ pub extern "C" fn wasmtime_linker_allow_shadowing( linker.linker.allow_shadowing(allow_shadowing); } -#[no_mangle] -pub extern "C" fn wasmtime_linker_delete(_linker: Box) {} - macro_rules! to_str { ($ptr:expr, $len:expr) => { match str::from_utf8(crate::slice_from_raw_parts($ptr, $len)) { diff --git a/crates/c-api/src/module.rs b/crates/c-api/src/module.rs index 1efa1abbd5..a1dce26493 100644 --- a/crates/c-api/src/module.rs +++ b/crates/c-api/src/module.rs @@ -127,6 +127,8 @@ pub struct wasmtime_module_t { pub(crate) module: Module, } +wasmtime_c_api_macros::declare_own!(wasmtime_module_t); + #[no_mangle] pub unsafe extern "C" fn wasmtime_module_new( engine: &wasm_engine_t, @@ -142,9 +144,6 @@ pub unsafe extern "C" fn wasmtime_module_new( ) } -#[no_mangle] -pub extern "C" fn wasmtime_module_delete(_module: Box) {} - #[no_mangle] pub extern "C" fn wasmtime_module_clone(module: &wasmtime_module_t) -> Box { Box::new(module.clone()) diff --git a/crates/c-api/src/ref.rs b/crates/c-api/src/ref.rs index f6be82acaf..7e1d3912b5 100644 --- a/crates/c-api/src/ref.rs +++ b/crates/c-api/src/ref.rs @@ -195,49 +195,9 @@ pub extern "C" fn wasm_ref_as_trap_const(_ref: Option<&wasm_ref_t>) -> Option<&c #[repr(C)] pub struct wasm_foreign_t {} +wasmtime_c_api_macros::declare_ref!(wasm_foreign_t); + #[no_mangle] pub extern "C" fn wasm_foreign_new(_store: &crate::wasm_store_t) -> Box { abort("wasm_foreign_new") } - -#[no_mangle] -pub extern "C" fn wasm_foreign_delete(_foreign: Box) {} - -#[no_mangle] -pub extern "C" fn wasm_foreign_copy(r: &wasm_foreign_t) -> Box { - Box::new(r.clone()) -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_same(_a: &wasm_foreign_t, _b: &wasm_foreign_t) -> bool { - abort("wasm_foreign_same") -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_get_host_info(_foreign: &wasm_foreign_t) -> *mut c_void { - std::ptr::null_mut() -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_set_host_info(_foreign: &wasm_foreign_t, _info: *mut c_void) { - abort("wasm_foreign_set_host_info") -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_set_host_info_with_finalizer( - _foreign: &wasm_foreign_t, - _info: *mut c_void, - _finalizer: Option, -) { - abort("wasm_foreign_set_host_info_with_finalizer") -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_as_ref(_: &wasm_foreign_t) -> &wasm_ref_t { - abort("wasm_foreign_as_ref") -} - -#[no_mangle] -pub extern "C" fn wasm_foreign_as_ref_const(_: &wasm_foreign_t) -> Option<&wasm_ref_t> { - abort("wasm_foreign_as_ref_const") -} diff --git a/crates/c-api/src/store.rs b/crates/c-api/src/store.rs index 711eb1d9ad..cac07b0ca3 100644 --- a/crates/c-api/src/store.rs +++ b/crates/c-api/src/store.rs @@ -60,6 +60,8 @@ pub struct wasmtime_store_t { pub(crate) store: Store, } +wasmtime_c_api_macros::declare_own!(wasmtime_store_t); + pub type CStoreContext<'a> = StoreContext<'a, StoreData>; pub type CStoreContextMut<'a> = StoreContextMut<'a, StoreData>; @@ -77,9 +79,6 @@ pub struct StoreData { pub wasm_val_storage: Vec, } -#[no_mangle] -pub extern "C" fn wasmtime_store_delete(_: Box) {} - #[no_mangle] pub extern "C" fn wasmtime_store_new( engine: &wasm_engine_t, diff --git a/crates/c-api/src/wasi.rs b/crates/c-api/src/wasi.rs index ff6a2f110d..1d197473b3 100644 --- a/crates/c-api/src/wasi.rs +++ b/crates/c-api/src/wasi.rs @@ -40,6 +40,8 @@ pub struct wasi_config_t { inherit_stderr: bool, } +wasmtime_c_api_macros::declare_own!(wasi_config_t); + impl wasi_config_t { pub fn into_wasi_ctx(self) -> Result { let mut builder = WasiCtxBuilder::new(); @@ -100,9 +102,6 @@ pub extern "C" fn wasi_config_new() -> Box { Box::new(wasi_config_t::default()) } -#[no_mangle] -pub extern "C" fn wasi_config_delete(_config: Box) {} - #[no_mangle] pub unsafe extern "C" fn wasi_config_set_argv( config: &mut wasi_config_t,