From a2854ebfea9ea00524f92d4081ab8fe7e172a278 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 1 Oct 2020 21:20:13 +0200 Subject: [PATCH] fix(c-api) Adjust cbindgen metadata for header files. --- lib/c-api/build.rs | 1 + lib/c-api/src/wasm_c_api/types/frame.rs | 7 ++++++- lib/c-api/src/wasm_c_api/wasi/mod.rs | 2 ++ lib/c-api/wasmer_wasm.h | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/c-api/build.rs b/lib/c-api/build.rs index af5f06fd2..6f6208f54 100644 --- a/lib/c-api/build.rs +++ b/lib/c-api/build.rs @@ -384,6 +384,7 @@ fn exclude_items_from_wasm_c_api(mut builder: Builder) -> Builder { .exclude_item("wasi_env_t") .exclude_item("wasi_get_imports") .exclude_item("wasi_get_imports_inner") + .exclude_item("wasi_get_start_function") .exclude_item("wasi_get_wasi_version") .exclude_item("wasi_version_t"); diff --git a/lib/c-api/src/wasm_c_api/types/frame.rs b/lib/c-api/src/wasm_c_api/types/frame.rs index 9fc841671..f85f57616 100644 --- a/lib/c-api/src/wasm_c_api/types/frame.rs +++ b/lib/c-api/src/wasm_c_api/types/frame.rs @@ -2,7 +2,6 @@ use super::super::instance::wasm_instance_t; use wasmer::FrameInfo; #[derive(Debug, Clone)] -#[repr(C)] pub struct wasm_frame_t { info: FrameInfo, } @@ -19,30 +18,36 @@ impl From for wasm_frame_t { } } +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_copy(frame: &wasm_frame_t) -> Box { Box::new(frame.clone()) } +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_delete(_frame: Option>) {} +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_instance(frame: &wasm_frame_t) -> *const wasm_instance_t { //todo!("wasm_frame_instance") std::ptr::null() } +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_func_index(frame: &wasm_frame_t) -> u32 { frame.info.func_index() } +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_func_offset(frame: &wasm_frame_t) -> usize { frame.info.func_offset() } +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_frame_module_offset(frame: &wasm_frame_t) -> usize { frame.info.module_offset() diff --git a/lib/c-api/src/wasm_c_api/wasi/mod.rs b/lib/c-api/src/wasm_c_api/wasi/mod.rs index 550d2ff04..86f8717d9 100644 --- a/lib/c-api/src/wasm_c_api/wasi/mod.rs +++ b/lib/c-api/src/wasm_c_api/wasi/mod.rs @@ -299,5 +299,7 @@ pub unsafe extern "C" fn wasi_get_start_function( } /// Delete a `wasm_extern_t` allocated by the API. +/// +/// cbindgen:ignore #[no_mangle] pub unsafe extern "C" fn wasm_extern_delete(_item: Option>) {} diff --git a/lib/c-api/wasmer_wasm.h b/lib/c-api/wasmer_wasm.h index 112f1d83c..f63ac73f7 100644 --- a/lib/c-api/wasmer_wasm.h +++ b/lib/c-api/wasmer_wasm.h @@ -124,6 +124,10 @@ bool wasi_get_imports(wasm_store_t *store, wasm_extern_t **imports); #endif +#if defined(WASMER_WASI_ENABLED) +wasm_func_t *wasi_get_start_function(wasm_instance_t *instance); +#endif + #if defined(WASMER_WASI_ENABLED) wasi_version_t wasi_get_wasi_version(const wasm_module_t *module); #endif