feat(c-api) Instruct cbindgen to ignore all functions and types defined in wasm.h.

This commit is contained in:
Ivan Enderlin
2020-09-28 14:49:44 +02:00
parent 40865799e6
commit 8f627d9834
24 changed files with 178 additions and 55 deletions

View File

@@ -3,13 +3,14 @@ use super::super::types::{wasm_ref_t, wasm_table_size_t, wasm_tabletype_t};
use std::ptr::NonNull;
use wasmer::{Store, Table};
#[repr(C)]
/// cbindgen:ignore
#[allow(non_camel_case_types)]
pub struct wasm_table_t {
/// cbindgen:ignore
// maybe needs to hold onto instance
pub(crate) inner: Table,
}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_new(
store_ptr: Option<NonNull<wasm_store_t>>,
@@ -26,9 +27,11 @@ pub unsafe extern "C" fn wasm_table_new(
Some(Box::new(wasm_table_t { inner: table }))
}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_delete(_table: Option<Box<wasm_table_t>>) {}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_copy(wasm_table: &wasm_table_t) -> Box<wasm_table_t> {
// do shallow copy
@@ -37,6 +40,7 @@ pub unsafe extern "C" fn wasm_table_copy(wasm_table: &wasm_table_t) -> Box<wasm_
})
}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_same(
wasm_table1: &wasm_table_t,
@@ -45,11 +49,13 @@ pub unsafe extern "C" fn wasm_table_same(
wasm_table1.inner.same(&wasm_table2.inner)
}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_size(wasm_table: &wasm_table_t) -> usize {
wasm_table.inner.size() as _
}
/// cbindgen:ignore
#[no_mangle]
pub unsafe extern "C" fn wasm_table_grow(
_wasm_table: &mut wasm_table_t,