mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 06:08:29 +00:00
chore(c-api) Move cbindgen:ignore from functions/types to modules.
This patch removes the amount of `cbindgen:ignore` instructions by moving this instruction onto the parent module.
This commit is contained in:
@@ -4,18 +4,15 @@ use wasmer::Engine;
|
|||||||
|
|
||||||
/// this can be a wasmer-specific type with wasmer-specific functions for manipulating it
|
/// this can be a wasmer-specific type with wasmer-specific functions for manipulating it
|
||||||
///
|
///
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_config_t {}
|
pub struct wasm_config_t {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_config_new() -> *mut wasm_config_t {
|
pub extern "C" fn wasm_config_new() -> *mut wasm_config_t {
|
||||||
todo!("wasm_config_new")
|
todo!("wasm_config_new")
|
||||||
//ptr::null_mut()
|
//ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_engine_t {
|
pub struct wasm_engine_t {
|
||||||
pub(crate) inner: Arc<dyn Engine + Send + Sync>,
|
pub(crate) inner: Arc<dyn Engine + Send + Sync>,
|
||||||
@@ -41,7 +38,6 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||||
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
|
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
|
||||||
@@ -51,7 +47,6 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
else if #[cfg(feature = "jit")] {
|
else if #[cfg(feature = "jit")] {
|
||||||
// Headless JIT
|
// Headless JIT
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||||
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(JIT::headless().engine());
|
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(JIT::headless().engine());
|
||||||
@@ -59,7 +54,6 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||||
unimplemented!("The JITEngine is not attached");
|
unimplemented!("The JITEngine is not attached");
|
||||||
@@ -67,11 +61,9 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_engine_delete(_wasm_engine_address: Option<Box<wasm_engine_t>>) {}
|
pub unsafe extern "C" fn wasm_engine_delete(_wasm_engine_address: Option<Box<wasm_engine_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new_with_config(
|
pub extern "C" fn wasm_engine_new_with_config(
|
||||||
_config_ptr: *mut wasm_config_t,
|
_config_ptr: *mut wasm_config_t,
|
||||||
|
|||||||
10
lib/c-api/src/wasm_c_api/externals/function.rs
vendored
10
lib/c-api/src/wasm_c_api/externals/function.rs
vendored
@@ -8,7 +8,6 @@ use std::ptr::NonNull;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer::{Function, Instance, RuntimeError, Store, Val};
|
use wasmer::{Function, Instance, RuntimeError, Store, Val};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_func_t {
|
pub struct wasm_func_t {
|
||||||
pub(crate) inner: Function,
|
pub(crate) inner: Function,
|
||||||
@@ -16,12 +15,10 @@ pub struct wasm_func_t {
|
|||||||
pub(crate) instance: Option<Arc<Instance>>,
|
pub(crate) instance: Option<Arc<Instance>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_func_callback_t =
|
pub type wasm_func_callback_t =
|
||||||
unsafe extern "C" fn(args: *const wasm_val_t, results: *mut wasm_val_t) -> *mut wasm_trap_t;
|
unsafe extern "C" fn(args: *const wasm_val_t, results: *mut wasm_val_t) -> *mut wasm_trap_t;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_func_callback_with_env_t = unsafe extern "C" fn(
|
pub type wasm_func_callback_with_env_t = unsafe extern "C" fn(
|
||||||
*mut c_void,
|
*mut c_void,
|
||||||
@@ -29,11 +26,9 @@ pub type wasm_func_callback_with_env_t = unsafe extern "C" fn(
|
|||||||
results: *mut wasm_val_t,
|
results: *mut wasm_val_t,
|
||||||
) -> *mut wasm_trap_t;
|
) -> *mut wasm_trap_t;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_env_finalizer_t = unsafe extern "C" fn(c_void);
|
pub type wasm_env_finalizer_t = unsafe extern "C" fn(c_void);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_new(
|
pub unsafe extern "C" fn wasm_func_new(
|
||||||
store: Option<NonNull<wasm_store_t>>,
|
store: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -80,7 +75,6 @@ pub unsafe extern "C" fn wasm_func_new(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_new_with_env(
|
pub unsafe extern "C" fn wasm_func_new_with_env(
|
||||||
store: Option<NonNull<wasm_store_t>>,
|
store: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -127,11 +121,9 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_delete(_func: Option<Box<wasm_func_t>>) {}
|
pub unsafe extern "C" fn wasm_func_delete(_func: Option<Box<wasm_func_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_call(
|
pub unsafe extern "C" fn wasm_func_call(
|
||||||
func: &wasm_func_t,
|
func: &wasm_func_t,
|
||||||
@@ -156,13 +148,11 @@ pub unsafe extern "C" fn wasm_func_call(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_param_arity(func: &wasm_func_t) -> usize {
|
pub unsafe extern "C" fn wasm_func_param_arity(func: &wasm_func_t) -> usize {
|
||||||
func.inner.ty().params().len()
|
func.inner.ty().params().len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_result_arity(func: &wasm_func_t) -> usize {
|
pub unsafe extern "C" fn wasm_func_result_arity(func: &wasm_func_t) -> usize {
|
||||||
func.inner.ty().results().len()
|
func.inner.ty().results().len()
|
||||||
|
|||||||
7
lib/c-api/src/wasm_c_api/externals/global.rs
vendored
7
lib/c-api/src/wasm_c_api/externals/global.rs
vendored
@@ -5,14 +5,12 @@ use std::convert::TryInto;
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::{Global, Store, Val};
|
use wasmer::{Global, Store, Val};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_global_t {
|
pub struct wasm_global_t {
|
||||||
// maybe needs to hold onto instance
|
// maybe needs to hold onto instance
|
||||||
pub(crate) inner: Global,
|
pub(crate) inner: Global,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_new(
|
pub unsafe extern "C" fn wasm_global_new(
|
||||||
store_ptr: Option<NonNull<wasm_store_t>>,
|
store_ptr: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -32,12 +30,10 @@ pub unsafe extern "C" fn wasm_global_new(
|
|||||||
Some(Box::new(wasm_global_t { inner: global }))
|
Some(Box::new(wasm_global_t { inner: global }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_delete(_global: Option<Box<wasm_global_t>>) {}
|
pub unsafe extern "C" fn wasm_global_delete(_global: Option<Box<wasm_global_t>>) {}
|
||||||
|
|
||||||
// TODO: figure out if these should be deep or shallow copies
|
// TODO: figure out if these should be deep or shallow copies
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_copy(wasm_global: &wasm_global_t) -> Box<wasm_global_t> {
|
pub unsafe extern "C" fn wasm_global_copy(wasm_global: &wasm_global_t) -> Box<wasm_global_t> {
|
||||||
// do shallow copy
|
// do shallow copy
|
||||||
@@ -46,21 +42,18 @@ pub unsafe extern "C" fn wasm_global_copy(wasm_global: &wasm_global_t) -> Box<wa
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_get(wasm_global: &wasm_global_t, out: &mut wasm_val_t) {
|
pub unsafe extern "C" fn wasm_global_get(wasm_global: &wasm_global_t, out: &mut wasm_val_t) {
|
||||||
let value = wasm_global.inner.get();
|
let value = wasm_global.inner.get();
|
||||||
*out = value.try_into().unwrap();
|
*out = value.try_into().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_set(wasm_global: &mut wasm_global_t, val: &wasm_val_t) {
|
pub unsafe extern "C" fn wasm_global_set(wasm_global: &mut wasm_global_t, val: &wasm_val_t) {
|
||||||
let value: Val = val.try_into().unwrap();
|
let value: Val = val.try_into().unwrap();
|
||||||
wasm_global.inner.set(value);
|
wasm_global.inner.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_same(
|
pub unsafe extern "C" fn wasm_global_same(
|
||||||
wasm_global1: &wasm_global_t,
|
wasm_global1: &wasm_global_t,
|
||||||
|
|||||||
10
lib/c-api/src/wasm_c_api/externals/memory.rs
vendored
10
lib/c-api/src/wasm_c_api/externals/memory.rs
vendored
@@ -4,14 +4,12 @@ use std::mem;
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::{Memory, Pages, Store};
|
use wasmer::{Memory, Pages, Store};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_memory_t {
|
pub struct wasm_memory_t {
|
||||||
// maybe needs to hold onto instance
|
// maybe needs to hold onto instance
|
||||||
pub(crate) inner: Memory,
|
pub(crate) inner: Memory,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_new(
|
pub unsafe extern "C" fn wasm_memory_new(
|
||||||
store_ptr: Option<NonNull<wasm_store_t>>,
|
store_ptr: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -25,12 +23,10 @@ pub unsafe extern "C" fn wasm_memory_new(
|
|||||||
Some(Box::new(wasm_memory_t { inner: memory }))
|
Some(Box::new(wasm_memory_t { inner: memory }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_delete(_memory: Option<Box<wasm_memory_t>>) {}
|
pub unsafe extern "C" fn wasm_memory_delete(_memory: Option<Box<wasm_memory_t>>) {}
|
||||||
|
|
||||||
// TODO: figure out if these should be deep or shallow copies
|
// TODO: figure out if these should be deep or shallow copies
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_copy(wasm_memory: &wasm_memory_t) -> Box<wasm_memory_t> {
|
pub unsafe extern "C" fn wasm_memory_copy(wasm_memory: &wasm_memory_t) -> Box<wasm_memory_t> {
|
||||||
// do shallow copy
|
// do shallow copy
|
||||||
@@ -39,14 +35,12 @@ pub unsafe extern "C" fn wasm_memory_copy(wasm_memory: &wasm_memory_t) -> Box<wa
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_type(_memory_ptr: &wasm_memory_t) -> *mut wasm_memorytype_t {
|
pub unsafe extern "C" fn wasm_memory_type(_memory_ptr: &wasm_memory_t) -> *mut wasm_memorytype_t {
|
||||||
todo!("wasm_memory_type")
|
todo!("wasm_memory_type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a raw pointer into bytes
|
// get a raw pointer into bytes
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_data(memory: &mut wasm_memory_t) -> *mut u8 {
|
pub unsafe extern "C" fn wasm_memory_data(memory: &mut wasm_memory_t) -> *mut u8 {
|
||||||
mem::transmute::<&[std::cell::Cell<u8>], &[u8]>(&memory.inner.view()[..]) as *const [u8]
|
mem::transmute::<&[std::cell::Cell<u8>], &[u8]>(&memory.inner.view()[..]) as *const [u8]
|
||||||
@@ -54,27 +48,23 @@ pub unsafe extern "C" fn wasm_memory_data(memory: &mut wasm_memory_t) -> *mut u8
|
|||||||
}
|
}
|
||||||
|
|
||||||
// size in bytes
|
// size in bytes
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_data_size(memory: &wasm_memory_t) -> usize {
|
pub unsafe extern "C" fn wasm_memory_data_size(memory: &wasm_memory_t) -> usize {
|
||||||
memory.inner.size().bytes().0
|
memory.inner.size().bytes().0
|
||||||
}
|
}
|
||||||
|
|
||||||
// size in pages
|
// size in pages
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_size(memory: &wasm_memory_t) -> u32 {
|
pub unsafe extern "C" fn wasm_memory_size(memory: &wasm_memory_t) -> u32 {
|
||||||
memory.inner.size().0 as _
|
memory.inner.size().0 as _
|
||||||
}
|
}
|
||||||
|
|
||||||
// delta is in pages
|
// delta is in pages
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_grow(memory: &mut wasm_memory_t, delta: u32) -> bool {
|
pub unsafe extern "C" fn wasm_memory_grow(memory: &mut wasm_memory_t, delta: u32) -> bool {
|
||||||
memory.inner.grow(Pages(delta)).is_ok()
|
memory.inner.grow(Pages(delta)).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_same(
|
pub unsafe extern "C" fn wasm_memory_same(
|
||||||
wasm_memory1: &wasm_memory_t,
|
wasm_memory1: &wasm_memory_t,
|
||||||
|
|||||||
9
lib/c-api/src/wasm_c_api/externals/mod.rs
vendored
9
lib/c-api/src/wasm_c_api/externals/mod.rs
vendored
@@ -11,7 +11,6 @@ use std::sync::Arc;
|
|||||||
pub use table::*;
|
pub use table::*;
|
||||||
use wasmer::{Extern, Instance};
|
use wasmer::{Extern, Instance};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_extern_t {
|
pub struct wasm_extern_t {
|
||||||
// this is how we ensure the instance stays alive
|
// this is how we ensure the instance stays alive
|
||||||
@@ -21,7 +20,6 @@ pub struct wasm_extern_t {
|
|||||||
|
|
||||||
wasm_declare_boxed_vec!(extern);
|
wasm_declare_boxed_vec!(extern);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_func_as_extern(
|
pub unsafe extern "C" fn wasm_func_as_extern(
|
||||||
func_ptr: Option<NonNull<wasm_func_t>>,
|
func_ptr: Option<NonNull<wasm_func_t>>,
|
||||||
@@ -35,7 +33,6 @@ pub unsafe extern "C" fn wasm_func_as_extern(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_global_as_extern(
|
pub unsafe extern "C" fn wasm_global_as_extern(
|
||||||
global_ptr: Option<NonNull<wasm_global_t>>,
|
global_ptr: Option<NonNull<wasm_global_t>>,
|
||||||
@@ -50,7 +47,6 @@ pub unsafe extern "C" fn wasm_global_as_extern(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_as_extern(
|
pub unsafe extern "C" fn wasm_memory_as_extern(
|
||||||
memory_ptr: Option<NonNull<wasm_memory_t>>,
|
memory_ptr: Option<NonNull<wasm_memory_t>>,
|
||||||
@@ -65,7 +61,6 @@ pub unsafe extern "C" fn wasm_memory_as_extern(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_as_extern(
|
pub unsafe extern "C" fn wasm_table_as_extern(
|
||||||
table_ptr: Option<NonNull<wasm_table_t>>,
|
table_ptr: Option<NonNull<wasm_table_t>>,
|
||||||
@@ -80,7 +75,6 @@ pub unsafe extern "C" fn wasm_table_as_extern(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_as_func(
|
pub unsafe extern "C" fn wasm_extern_as_func(
|
||||||
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
||||||
@@ -97,7 +91,6 @@ pub unsafe extern "C" fn wasm_extern_as_func(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_as_global(
|
pub unsafe extern "C" fn wasm_extern_as_global(
|
||||||
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
||||||
@@ -111,7 +104,6 @@ pub unsafe extern "C" fn wasm_extern_as_global(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_as_memory(
|
pub unsafe extern "C" fn wasm_extern_as_memory(
|
||||||
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
||||||
@@ -125,7 +117,6 @@ pub unsafe extern "C" fn wasm_extern_as_memory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_as_table(
|
pub unsafe extern "C" fn wasm_extern_as_table(
|
||||||
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
extern_ptr: Option<NonNull<wasm_extern_t>>,
|
||||||
|
|||||||
7
lib/c-api/src/wasm_c_api/externals/table.rs
vendored
7
lib/c-api/src/wasm_c_api/externals/table.rs
vendored
@@ -3,14 +3,12 @@ use super::super::types::{wasm_ref_t, wasm_table_size_t, wasm_tabletype_t};
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::{Store, Table};
|
use wasmer::{Store, Table};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_table_t {
|
pub struct wasm_table_t {
|
||||||
// maybe needs to hold onto instance
|
// maybe needs to hold onto instance
|
||||||
pub(crate) inner: Table,
|
pub(crate) inner: Table,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_new(
|
pub unsafe extern "C" fn wasm_table_new(
|
||||||
store_ptr: Option<NonNull<wasm_store_t>>,
|
store_ptr: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -27,11 +25,9 @@ pub unsafe extern "C" fn wasm_table_new(
|
|||||||
Some(Box::new(wasm_table_t { inner: table }))
|
Some(Box::new(wasm_table_t { inner: table }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_delete(_table: Option<Box<wasm_table_t>>) {}
|
pub unsafe extern "C" fn wasm_table_delete(_table: Option<Box<wasm_table_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_copy(wasm_table: &wasm_table_t) -> Box<wasm_table_t> {
|
pub unsafe extern "C" fn wasm_table_copy(wasm_table: &wasm_table_t) -> Box<wasm_table_t> {
|
||||||
// do shallow copy
|
// do shallow copy
|
||||||
@@ -40,7 +36,6 @@ pub unsafe extern "C" fn wasm_table_copy(wasm_table: &wasm_table_t) -> Box<wasm_
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_same(
|
pub unsafe extern "C" fn wasm_table_same(
|
||||||
wasm_table1: &wasm_table_t,
|
wasm_table1: &wasm_table_t,
|
||||||
@@ -49,13 +44,11 @@ pub unsafe extern "C" fn wasm_table_same(
|
|||||||
wasm_table1.inner.same(&wasm_table2.inner)
|
wasm_table1.inner.same(&wasm_table2.inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_size(wasm_table: &wasm_table_t) -> usize {
|
pub unsafe extern "C" fn wasm_table_size(wasm_table: &wasm_table_t) -> usize {
|
||||||
wasm_table.inner.size() as _
|
wasm_table.inner.size() as _
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_grow(
|
pub unsafe extern "C" fn wasm_table_grow(
|
||||||
_wasm_table: &mut wasm_table_t,
|
_wasm_table: &mut wasm_table_t,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use std::ptr::NonNull;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer::{Extern, Instance};
|
use wasmer::{Extern, Instance};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_instance_t {
|
pub struct wasm_instance_t {
|
||||||
pub(crate) inner: Arc<Instance>,
|
pub(crate) inner: Arc<Instance>,
|
||||||
@@ -51,7 +50,6 @@ unsafe fn argument_import_iter(
|
|||||||
.unwrap_or_else(|| Box::new(std::iter::empty()) as _)
|
.unwrap_or_else(|| Box::new(std::iter::empty()) as _)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_instance_new(
|
pub unsafe extern "C" fn wasm_instance_new(
|
||||||
store: Option<NonNull<wasm_store_t>>,
|
store: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -74,11 +72,9 @@ pub unsafe extern "C" fn wasm_instance_new(
|
|||||||
Some(Box::new(wasm_instance_t { inner: instance }))
|
Some(Box::new(wasm_instance_t { inner: instance }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_instance_delete(_instance: Option<Box<wasm_instance_t>>) {}
|
pub unsafe extern "C" fn wasm_instance_delete(_instance: Option<Box<wasm_instance_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_instance_exports(
|
pub unsafe extern "C" fn wasm_instance_exports(
|
||||||
instance: &wasm_instance_t,
|
instance: &wasm_instance_t,
|
||||||
|
|||||||
@@ -3,14 +3,12 @@
|
|||||||
macro_rules! wasm_declare_vec_inner {
|
macro_rules! wasm_declare_vec_inner {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new_empty>](out: *mut [<wasm_ $name _vec_t>]) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new_empty>](out: *mut [<wasm_ $name _vec_t>]) {
|
||||||
// TODO: actually implement this
|
// TODO: actually implement this
|
||||||
[<wasm_ $name _vec_new_uninitialized>](out, 0);
|
[<wasm_ $name _vec_new_uninitialized>](out, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_delete>](ptr: *mut [<wasm_ $name _vec_t>]) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_delete>](ptr: *mut [<wasm_ $name _vec_t>]) {
|
||||||
let vec = &mut *ptr;
|
let vec = &mut *ptr;
|
||||||
@@ -29,7 +27,6 @@ macro_rules! wasm_declare_vec_inner {
|
|||||||
macro_rules! wasm_declare_vec {
|
macro_rules! wasm_declare_vec {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct [<wasm_ $name _vec_t>] {
|
pub struct [<wasm_ $name _vec_t>] {
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
@@ -78,7 +75,6 @@ macro_rules! wasm_declare_vec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: investigate possible memory leak on `init` (owned pointer)
|
// TODO: investigate possible memory leak on `init` (owned pointer)
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *mut [<wasm_ $name _t>]) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *mut [<wasm_ $name _t>]) {
|
||||||
let mut bytes: Vec<[<wasm_ $name _t>]> = Vec::with_capacity(length);
|
let mut bytes: Vec<[<wasm_ $name _t>]> = Vec::with_capacity(length);
|
||||||
@@ -92,7 +88,6 @@ macro_rules! wasm_declare_vec {
|
|||||||
::std::mem::forget(bytes);
|
::std::mem::forget(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new_uninitialized>](out: *mut [<wasm_ $name _vec_t>], length: usize) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new_uninitialized>](out: *mut [<wasm_ $name _vec_t>], length: usize) {
|
||||||
let mut bytes: Vec<[<wasm_ $name _t>]> = Vec::with_capacity(length);
|
let mut bytes: Vec<[<wasm_ $name _t>]> = Vec::with_capacity(length);
|
||||||
@@ -112,7 +107,6 @@ macro_rules! wasm_declare_vec {
|
|||||||
macro_rules! wasm_declare_boxed_vec {
|
macro_rules! wasm_declare_boxed_vec {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct [<wasm_ $name _vec_t>] {
|
pub struct [<wasm_ $name _vec_t>] {
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
@@ -131,7 +125,6 @@ macro_rules! wasm_declare_boxed_vec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: investigate possible memory leak on `init` (owned pointer)
|
// TODO: investigate possible memory leak on `init` (owned pointer)
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *const *mut [<wasm_ $name _t>]) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *const *mut [<wasm_ $name _t>]) {
|
||||||
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = Vec::with_capacity(length);
|
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = Vec::with_capacity(length);
|
||||||
@@ -145,7 +138,6 @@ macro_rules! wasm_declare_boxed_vec {
|
|||||||
::std::mem::forget(bytes);
|
::std::mem::forget(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new_uninitialized>](out: *mut [<wasm_ $name _vec_t>], length: usize) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new_uninitialized>](out: *mut [<wasm_ $name _vec_t>], length: usize) {
|
||||||
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = Vec::with_capacity(length);
|
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = Vec::with_capacity(length);
|
||||||
@@ -167,7 +159,6 @@ macro_rules! wasm_declare_ref_base {
|
|||||||
wasm_declare_own!($name);
|
wasm_declare_own!($name);
|
||||||
|
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn [<wasm_ $name _copy>](_arg: *const [<wasm_ $name _t>]) -> *mut [<wasm_ $name _t>] {
|
pub extern "C" fn [<wasm_ $name _copy>](_arg: *const [<wasm_ $name _t>]) -> *mut [<wasm_ $name _t>] {
|
||||||
todo!("in generated declare ref base");
|
todo!("in generated declare ref base");
|
||||||
@@ -185,11 +176,9 @@ macro_rules! wasm_declare_ref_base {
|
|||||||
macro_rules! wasm_declare_own {
|
macro_rules! wasm_declare_own {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// cbindgen:ignore
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct [<wasm_ $name _t>] {}
|
pub struct [<wasm_ $name _t>] {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn [<wasm_ $name _delete>](_arg: *mut [<wasm_ $name _t>]) {
|
pub extern "C" fn [<wasm_ $name _delete>](_arg: *mut [<wasm_ $name _t>]) {
|
||||||
todo!("in generated delete")
|
todo!("in generated delete")
|
||||||
|
|||||||
@@ -3,13 +3,28 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod engine;
|
pub mod engine;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod externals;
|
pub mod externals;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod instance;
|
pub mod instance;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod module;
|
pub mod module;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod store;
|
pub mod store;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod trap;
|
pub mod trap;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
/// cbindgen:ignore
|
||||||
pub mod value;
|
pub mod value;
|
||||||
|
|
||||||
#[cfg(feature = "wasi")]
|
#[cfg(feature = "wasi")]
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ use std::slice;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer::{Module, Store};
|
use wasmer::{Module, Store};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_module_t {
|
pub struct wasm_module_t {
|
||||||
pub(crate) inner: Arc<Module>,
|
pub(crate) inner: Arc<Module>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_new(
|
pub unsafe extern "C" fn wasm_module_new(
|
||||||
store_ptr: Option<NonNull<wasm_store_t>>,
|
store_ptr: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -32,11 +30,9 @@ pub unsafe extern "C" fn wasm_module_new(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_delete(_module: Option<Box<wasm_module_t>>) {}
|
pub unsafe extern "C" fn wasm_module_delete(_module: Option<Box<wasm_module_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_exports(
|
pub unsafe extern "C" fn wasm_module_exports(
|
||||||
module: &wasm_module_t,
|
module: &wasm_module_t,
|
||||||
@@ -56,7 +52,6 @@ pub unsafe extern "C" fn wasm_module_exports(
|
|||||||
mem::forget(exports);
|
mem::forget(exports);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_imports(
|
pub unsafe extern "C" fn wasm_module_imports(
|
||||||
module: &wasm_module_t,
|
module: &wasm_module_t,
|
||||||
@@ -76,7 +71,6 @@ pub unsafe extern "C" fn wasm_module_imports(
|
|||||||
mem::forget(imports);
|
mem::forget(imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_deserialize(
|
pub unsafe extern "C" fn wasm_module_deserialize(
|
||||||
store_ptr: Option<NonNull<wasm_store_t>>,
|
store_ptr: Option<NonNull<wasm_store_t>>,
|
||||||
@@ -102,7 +96,6 @@ pub unsafe extern "C" fn wasm_module_deserialize(
|
|||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_module_serialize(
|
pub unsafe extern "C" fn wasm_module_serialize(
|
||||||
module: &wasm_module_t,
|
module: &wasm_module_t,
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ use std::ptr::NonNull;
|
|||||||
use wasmer::Store;
|
use wasmer::Store;
|
||||||
|
|
||||||
/// Opaque wrapper around `Store`
|
/// Opaque wrapper around `Store`
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_store_t {}
|
pub struct wasm_store_t {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_store_new(
|
pub unsafe extern "C" fn wasm_store_new(
|
||||||
wasm_engine_ptr: Option<NonNull<wasm_engine_t>>,
|
wasm_engine_ptr: Option<NonNull<wasm_engine_t>>,
|
||||||
@@ -20,7 +18,6 @@ pub unsafe extern "C" fn wasm_store_new(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_store_delete(wasm_store: Option<NonNull<wasm_store_t>>) {
|
pub unsafe extern "C" fn wasm_store_delete(wasm_store: Option<NonNull<wasm_store_t>>) {
|
||||||
if let Some(s_inner) = wasm_store {
|
if let Some(s_inner) = wasm_store {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use super::types::{wasm_byte_vec_t, wasm_frame_t, wasm_frame_vec_t, wasm_message
|
|||||||
use wasmer::RuntimeError;
|
use wasmer::RuntimeError;
|
||||||
|
|
||||||
// opaque type which is a `RuntimeError`
|
// opaque type which is a `RuntimeError`
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_trap_t {
|
pub struct wasm_trap_t {
|
||||||
pub(crate) inner: RuntimeError,
|
pub(crate) inner: RuntimeError,
|
||||||
@@ -15,7 +14,6 @@ impl From<RuntimeError> for wasm_trap_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_trap_new(
|
pub unsafe extern "C" fn wasm_trap_new(
|
||||||
_store: &mut wasm_store_t,
|
_store: &mut wasm_store_t,
|
||||||
@@ -29,11 +27,9 @@ pub unsafe extern "C" fn wasm_trap_new(
|
|||||||
Some(Box::new(trap))
|
Some(Box::new(trap))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_trap_delete(_trap: Option<Box<wasm_trap_t>>) {}
|
pub unsafe extern "C" fn wasm_trap_delete(_trap: Option<Box<wasm_trap_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_trap_message(trap: &wasm_trap_t, out_ptr: &mut wasm_byte_vec_t) {
|
pub unsafe extern "C" fn wasm_trap_message(trap: &wasm_trap_t, out_ptr: &mut wasm_byte_vec_t) {
|
||||||
let message = trap.inner.message();
|
let message = trap.inner.message();
|
||||||
@@ -42,13 +38,11 @@ pub unsafe extern "C" fn wasm_trap_message(trap: &wasm_trap_t, out_ptr: &mut was
|
|||||||
out_ptr.data = byte_vec.data;
|
out_ptr.data = byte_vec.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_trap_origin(trap: &wasm_trap_t) -> Option<Box<wasm_frame_t>> {
|
pub unsafe extern "C" fn wasm_trap_origin(trap: &wasm_trap_t) -> Option<Box<wasm_frame_t>> {
|
||||||
trap.inner.trace().first().map(Into::into).map(Box::new)
|
trap.inner.trace().first().map(Into::into).map(Box::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_trap_trace(trap: &wasm_trap_t, out_ptr: &mut wasm_frame_vec_t) {
|
pub unsafe extern "C" fn wasm_trap_trace(trap: &wasm_trap_t, out_ptr: &mut wasm_frame_vec_t) {
|
||||||
let frames = trap.inner.trace();
|
let frames = trap.inner.trace();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use super::{wasm_externtype_t, wasm_name_t};
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::ExportType;
|
use wasmer::ExportType;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_exporttype_t {
|
pub struct wasm_exporttype_t {
|
||||||
name: NonNull<wasm_name_t>,
|
name: NonNull<wasm_name_t>,
|
||||||
@@ -11,7 +10,6 @@ pub struct wasm_exporttype_t {
|
|||||||
|
|
||||||
wasm_declare_boxed_vec!(exporttype);
|
wasm_declare_boxed_vec!(exporttype);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_exporttype_new(
|
pub extern "C" fn wasm_exporttype_new(
|
||||||
name: NonNull<wasm_name_t>,
|
name: NonNull<wasm_name_t>,
|
||||||
@@ -20,13 +18,11 @@ pub extern "C" fn wasm_exporttype_new(
|
|||||||
Box::new(wasm_exporttype_t { name, extern_type })
|
Box::new(wasm_exporttype_t { name, extern_type })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_exporttype_name(et: &'static wasm_exporttype_t) -> &'static wasm_name_t {
|
pub extern "C" fn wasm_exporttype_name(et: &'static wasm_exporttype_t) -> &'static wasm_name_t {
|
||||||
unsafe { et.name.as_ref() }
|
unsafe { et.name.as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_exporttype_type(
|
pub extern "C" fn wasm_exporttype_type(
|
||||||
et: &'static wasm_exporttype_t,
|
et: &'static wasm_exporttype_t,
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ use std::mem;
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmer::ExternType;
|
use wasmer::ExternType;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct wasm_externtype_t {
|
pub struct wasm_externtype_t {
|
||||||
pub(crate) inner: ExternType,
|
pub(crate) inner: ExternType,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externtype_t> {
|
pub unsafe extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externtype_t> {
|
||||||
Box::new(wasm_externtype_t {
|
Box::new(wasm_externtype_t {
|
||||||
@@ -20,7 +18,6 @@ pub unsafe extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externt
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_delete(_et: Option<Box<wasm_externtype_t>>) {}
|
pub unsafe extern "C" fn wasm_externtype_delete(_et: Option<Box<wasm_externtype_t>>) {}
|
||||||
|
|
||||||
@@ -36,11 +33,9 @@ impl From<&ExternType> for wasm_externtype_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
type wasm_externkind_t = u8;
|
type wasm_externkind_t = u8;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum wasm_externkind_enum {
|
pub enum wasm_externkind_enum {
|
||||||
@@ -50,7 +45,6 @@ pub enum wasm_externkind_enum {
|
|||||||
WASM_EXTERN_MEMORY = 3,
|
WASM_EXTERN_MEMORY = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
|
pub unsafe extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
|
||||||
wasm_externkind_enum::from(e.inner.ty()) as wasm_externkind_t
|
wasm_externkind_enum::from(e.inner.ty()) as wasm_externkind_t
|
||||||
@@ -72,7 +66,6 @@ impl From<&ExternType> for wasm_externkind_enum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_kind(et: &wasm_externtype_t) -> wasm_externkind_t {
|
pub unsafe extern "C" fn wasm_externtype_kind(et: &wasm_externtype_t) -> wasm_externkind_t {
|
||||||
wasm_externkind_enum::from(&et.inner) as wasm_externkind_t
|
wasm_externkind_enum::from(&et.inner) as wasm_externkind_t
|
||||||
@@ -136,7 +129,6 @@ impl TryFrom<&'static wasm_externtype_t> for &'static wasm_tabletype_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_functype_const(
|
pub unsafe extern "C" fn wasm_externtype_as_functype_const(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -144,7 +136,6 @@ pub unsafe extern "C" fn wasm_externtype_as_functype_const(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_functype(
|
pub unsafe extern "C" fn wasm_externtype_as_functype(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -152,7 +143,6 @@ pub unsafe extern "C" fn wasm_externtype_as_functype(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_as_externtype_const(
|
pub unsafe extern "C" fn wasm_functype_as_externtype_const(
|
||||||
ft: &'static wasm_functype_t,
|
ft: &'static wasm_functype_t,
|
||||||
@@ -160,7 +150,6 @@ pub unsafe extern "C" fn wasm_functype_as_externtype_const(
|
|||||||
&ft.extern_
|
&ft.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_as_externtype(
|
pub unsafe extern "C" fn wasm_functype_as_externtype(
|
||||||
ft: &'static wasm_functype_t,
|
ft: &'static wasm_functype_t,
|
||||||
@@ -168,7 +157,6 @@ pub unsafe extern "C" fn wasm_functype_as_externtype(
|
|||||||
&ft.extern_
|
&ft.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_memorytype_const(
|
pub unsafe extern "C" fn wasm_externtype_as_memorytype_const(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -176,7 +164,6 @@ pub unsafe extern "C" fn wasm_externtype_as_memorytype_const(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_memorytype(
|
pub unsafe extern "C" fn wasm_externtype_as_memorytype(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -184,7 +171,6 @@ pub unsafe extern "C" fn wasm_externtype_as_memorytype(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memorytype_as_externtype_const(
|
pub unsafe extern "C" fn wasm_memorytype_as_externtype_const(
|
||||||
mt: &'static wasm_memorytype_t,
|
mt: &'static wasm_memorytype_t,
|
||||||
@@ -192,7 +178,6 @@ pub unsafe extern "C" fn wasm_memorytype_as_externtype_const(
|
|||||||
&mt.extern_
|
&mt.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memorytype_as_externtype(
|
pub unsafe extern "C" fn wasm_memorytype_as_externtype(
|
||||||
mt: &'static wasm_memorytype_t,
|
mt: &'static wasm_memorytype_t,
|
||||||
@@ -200,7 +185,6 @@ pub unsafe extern "C" fn wasm_memorytype_as_externtype(
|
|||||||
&mt.extern_
|
&mt.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_globaltype_const(
|
pub unsafe extern "C" fn wasm_externtype_as_globaltype_const(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -208,7 +192,6 @@ pub unsafe extern "C" fn wasm_externtype_as_globaltype_const(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_globaltype(
|
pub unsafe extern "C" fn wasm_externtype_as_globaltype(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -216,7 +199,6 @@ pub unsafe extern "C" fn wasm_externtype_as_globaltype(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_as_externtype_const(
|
pub unsafe extern "C" fn wasm_globaltype_as_externtype_const(
|
||||||
gt: &'static wasm_globaltype_t,
|
gt: &'static wasm_globaltype_t,
|
||||||
@@ -224,7 +206,6 @@ pub unsafe extern "C" fn wasm_globaltype_as_externtype_const(
|
|||||||
>.extern_
|
>.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_as_externtype(
|
pub unsafe extern "C" fn wasm_globaltype_as_externtype(
|
||||||
gt: &'static wasm_globaltype_t,
|
gt: &'static wasm_globaltype_t,
|
||||||
@@ -232,7 +213,6 @@ pub unsafe extern "C" fn wasm_globaltype_as_externtype(
|
|||||||
>.extern_
|
>.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_tabletype_const(
|
pub unsafe extern "C" fn wasm_externtype_as_tabletype_const(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -240,7 +220,6 @@ pub unsafe extern "C" fn wasm_externtype_as_tabletype_const(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_externtype_as_tabletype(
|
pub unsafe extern "C" fn wasm_externtype_as_tabletype(
|
||||||
et: &'static wasm_externtype_t,
|
et: &'static wasm_externtype_t,
|
||||||
@@ -248,7 +227,6 @@ pub unsafe extern "C" fn wasm_externtype_as_tabletype(
|
|||||||
Some(c_try!(et.try_into()))
|
Some(c_try!(et.try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_as_externtype_const(
|
pub unsafe extern "C" fn wasm_tabletype_as_externtype_const(
|
||||||
tt: &'static wasm_tabletype_t,
|
tt: &'static wasm_tabletype_t,
|
||||||
@@ -256,7 +234,6 @@ pub unsafe extern "C" fn wasm_tabletype_as_externtype_const(
|
|||||||
&tt.extern_
|
&tt.extern_
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_as_externtype(
|
pub unsafe extern "C" fn wasm_tabletype_as_externtype(
|
||||||
tt: &'static wasm_tabletype_t,
|
tt: &'static wasm_tabletype_t,
|
||||||
|
|||||||
@@ -19,36 +19,30 @@ impl From<FrameInfo> for wasm_frame_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_copy(frame: &wasm_frame_t) -> Box<wasm_frame_t> {
|
pub unsafe extern "C" fn wasm_frame_copy(frame: &wasm_frame_t) -> Box<wasm_frame_t> {
|
||||||
Box::new(frame.clone())
|
Box::new(frame.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_delete(_frame: Option<Box<wasm_frame_t>>) {}
|
pub unsafe extern "C" fn wasm_frame_delete(_frame: Option<Box<wasm_frame_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_instance(frame: &wasm_frame_t) -> *const wasm_instance_t {
|
pub unsafe extern "C" fn wasm_frame_instance(frame: &wasm_frame_t) -> *const wasm_instance_t {
|
||||||
//todo!("wasm_frame_instance")
|
//todo!("wasm_frame_instance")
|
||||||
std::ptr::null()
|
std::ptr::null()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_func_index(frame: &wasm_frame_t) -> u32 {
|
pub unsafe extern "C" fn wasm_frame_func_index(frame: &wasm_frame_t) -> u32 {
|
||||||
frame.info.func_index()
|
frame.info.func_index()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_func_offset(frame: &wasm_frame_t) -> usize {
|
pub unsafe extern "C" fn wasm_frame_func_offset(frame: &wasm_frame_t) -> usize {
|
||||||
frame.info.func_offset()
|
frame.info.func_offset()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_frame_module_offset(frame: &wasm_frame_t) -> usize {
|
pub unsafe extern "C" fn wasm_frame_module_offset(frame: &wasm_frame_t) -> usize {
|
||||||
frame.info.module_offset()
|
frame.info.module_offset()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use std::mem;
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::{ExternType, FunctionType, ValType};
|
use wasmer::{ExternType, FunctionType, ValType};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct wasm_functype_t {
|
pub struct wasm_functype_t {
|
||||||
@@ -22,7 +21,6 @@ impl wasm_functype_t {
|
|||||||
|
|
||||||
wasm_declare_vec!(functype);
|
wasm_declare_vec!(functype);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_new(
|
pub unsafe extern "C" fn wasm_functype_new(
|
||||||
// own
|
// own
|
||||||
@@ -60,11 +58,9 @@ unsafe fn wasm_functype_new_inner(
|
|||||||
Some(Box::new(wasm_functype_t { extern_ }))
|
Some(Box::new(wasm_functype_t { extern_ }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_delete(_ft: Option<Box<wasm_functype_t>>) {}
|
pub unsafe extern "C" fn wasm_functype_delete(_ft: Option<Box<wasm_functype_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_copy(
|
pub unsafe extern "C" fn wasm_functype_copy(
|
||||||
arg: Option<NonNull<wasm_functype_t>>,
|
arg: Option<NonNull<wasm_functype_t>>,
|
||||||
@@ -75,7 +71,6 @@ pub unsafe extern "C" fn wasm_functype_copy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_params(ft: &wasm_functype_t) -> *const wasm_valtype_vec_t {
|
pub unsafe extern "C" fn wasm_functype_params(ft: &wasm_functype_t) -> *const wasm_valtype_vec_t {
|
||||||
let mut valtypes = ft
|
let mut valtypes = ft
|
||||||
@@ -96,7 +91,6 @@ pub unsafe extern "C" fn wasm_functype_params(ft: &wasm_functype_t) -> *const wa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_functype_results(ft: &wasm_functype_t) -> *const wasm_valtype_vec_t {
|
pub unsafe extern "C" fn wasm_functype_results(ft: &wasm_functype_t) -> *const wasm_valtype_vec_t {
|
||||||
let mut valtypes = ft
|
let mut valtypes = ft
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use super::{
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use wasmer::{ExternType, GlobalType};
|
use wasmer::{ExternType, GlobalType};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct wasm_globaltype_t {
|
pub struct wasm_globaltype_t {
|
||||||
@@ -25,7 +24,6 @@ impl wasm_globaltype_t {
|
|||||||
|
|
||||||
wasm_declare_vec!(globaltype);
|
wasm_declare_vec!(globaltype);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_new(
|
pub unsafe extern "C" fn wasm_globaltype_new(
|
||||||
// own
|
// own
|
||||||
@@ -35,7 +33,6 @@ pub unsafe extern "C" fn wasm_globaltype_new(
|
|||||||
wasm_globaltype_new_inner(valtype?, mutability)
|
wasm_globaltype_new_inner(valtype?, mutability)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_delete(_globaltype: Option<Box<wasm_globaltype_t>>) {}
|
pub unsafe extern "C" fn wasm_globaltype_delete(_globaltype: Option<Box<wasm_globaltype_t>>) {}
|
||||||
|
|
||||||
@@ -55,7 +52,6 @@ unsafe fn wasm_globaltype_new_inner(
|
|||||||
Some(gd)
|
Some(gd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_mutability(
|
pub unsafe extern "C" fn wasm_globaltype_mutability(
|
||||||
globaltype: &wasm_globaltype_t,
|
globaltype: &wasm_globaltype_t,
|
||||||
@@ -66,7 +62,6 @@ pub unsafe extern "C" fn wasm_globaltype_mutability(
|
|||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
// this function leaks memory because the returned limits pointer is not owned
|
// this function leaks memory because the returned limits pointer is not owned
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_globaltype_content(
|
pub unsafe extern "C" fn wasm_globaltype_content(
|
||||||
globaltype: &wasm_globaltype_t,
|
globaltype: &wasm_globaltype_t,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use std::ptr::NonNull;
|
|||||||
use wasmer::ImportType;
|
use wasmer::ImportType;
|
||||||
|
|
||||||
// TODO: improve ownership in `importtype_t` (can we safely use `Box<wasm_name_t>` here?)
|
// TODO: improve ownership in `importtype_t` (can we safely use `Box<wasm_name_t>` here?)
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_importtype_t {
|
pub struct wasm_importtype_t {
|
||||||
pub(crate) module: NonNull<wasm_name_t>,
|
pub(crate) module: NonNull<wasm_name_t>,
|
||||||
@@ -13,7 +12,6 @@ pub struct wasm_importtype_t {
|
|||||||
|
|
||||||
wasm_declare_boxed_vec!(importtype);
|
wasm_declare_boxed_vec!(importtype);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_importtype_new(
|
pub extern "C" fn wasm_importtype_new(
|
||||||
module: NonNull<wasm_name_t>,
|
module: NonNull<wasm_name_t>,
|
||||||
@@ -27,19 +25,16 @@ pub extern "C" fn wasm_importtype_new(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_importtype_module(et: &'static wasm_importtype_t) -> &'static wasm_name_t {
|
pub extern "C" fn wasm_importtype_module(et: &'static wasm_importtype_t) -> &'static wasm_name_t {
|
||||||
unsafe { et.module.as_ref() }
|
unsafe { et.module.as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_importtype_name(et: &'static wasm_importtype_t) -> &'static wasm_name_t {
|
pub extern "C" fn wasm_importtype_name(et: &'static wasm_importtype_t) -> &'static wasm_name_t {
|
||||||
unsafe { et.name.as_ref() }
|
unsafe { et.name.as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_importtype_type(
|
pub extern "C" fn wasm_importtype_type(
|
||||||
et: &'static wasm_importtype_t,
|
et: &'static wasm_importtype_t,
|
||||||
@@ -47,7 +42,6 @@ pub extern "C" fn wasm_importtype_type(
|
|||||||
unsafe { et.extern_type.as_ref() }
|
unsafe { et.extern_type.as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_importtype_delete(_importtype: Option<Box<wasm_importtype_t>>) {}
|
pub unsafe extern "C" fn wasm_importtype_delete(_importtype: Option<Box<wasm_importtype_t>>) {}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ use super::wasm_externtype_t;
|
|||||||
use wasmer::{ExternType, MemoryType, Pages};
|
use wasmer::{ExternType, MemoryType, Pages};
|
||||||
|
|
||||||
// opaque type wrapping `MemoryType`
|
// opaque type wrapping `MemoryType`
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct wasm_memorytype_t {
|
pub struct wasm_memorytype_t {
|
||||||
/// cbindgen:ignore
|
|
||||||
pub(crate) extern_: wasm_externtype_t,
|
pub(crate) extern_: wasm_externtype_t,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +22,6 @@ impl wasm_memorytype_t {
|
|||||||
|
|
||||||
wasm_declare_vec!(memorytype);
|
wasm_declare_vec!(memorytype);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct wasm_limits_t {
|
pub struct wasm_limits_t {
|
||||||
@@ -32,7 +29,6 @@ pub struct wasm_limits_t {
|
|||||||
pub(crate) max: u32,
|
pub(crate) max: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memorytype_new(limits: &wasm_limits_t) -> Box<wasm_memorytype_t> {
|
pub unsafe extern "C" fn wasm_memorytype_new(limits: &wasm_limits_t) -> Box<wasm_memorytype_t> {
|
||||||
let min_pages = Pages(limits.min as _);
|
let min_pages = Pages(limits.min as _);
|
||||||
@@ -49,13 +45,11 @@ pub unsafe extern "C" fn wasm_memorytype_new(limits: &wasm_limits_t) -> Box<wasm
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memorytype_delete(_memorytype: Option<Box<wasm_memorytype_t>>) {}
|
pub unsafe extern "C" fn wasm_memorytype_delete(_memorytype: Option<Box<wasm_memorytype_t>>) {}
|
||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
// this function leaks memory because the returned limits pointer is not owned
|
// this function leaks memory because the returned limits pointer is not owned
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memorytype_limits(mt: &wasm_memorytype_t) -> *const wasm_limits_t {
|
pub unsafe extern "C" fn wasm_memorytype_limits(mt: &wasm_memorytype_t) -> *const wasm_limits_t {
|
||||||
let md = mt.as_memorytype();
|
let md = mt.as_memorytype();
|
||||||
|
|||||||
@@ -25,15 +25,12 @@ pub type wasm_byte_t = u8;
|
|||||||
|
|
||||||
wasm_declare_vec!(byte);
|
wasm_declare_vec!(byte);
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_name_t = wasm_byte_vec_t;
|
pub type wasm_name_t = wasm_byte_vec_t;
|
||||||
|
|
||||||
// opaque type over `ExternRef`?
|
// opaque type over `ExternRef`?
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct wasm_ref_t;
|
pub struct wasm_ref_t;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_message_t = wasm_byte_vec_t;
|
pub type wasm_message_t = wasm_byte_vec_t;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use wasmer::Mutability;
|
use wasmer::Mutability;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_mutability_t = u8;
|
pub type wasm_mutability_t = u8;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
use super::{wasm_externtype_t, wasm_limits_t, wasm_valtype_delete, wasm_valtype_t};
|
use super::{wasm_externtype_t, wasm_limits_t, wasm_valtype_delete, wasm_valtype_t};
|
||||||
use wasmer::{ExternType, TableType};
|
use wasmer::{ExternType, TableType};
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_table_size_t = u32;
|
pub type wasm_table_size_t = u32;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct wasm_tabletype_t {
|
pub struct wasm_tabletype_t {
|
||||||
/// cbindgen:ignore
|
|
||||||
pub(crate) extern_: wasm_externtype_t,
|
pub(crate) extern_: wasm_externtype_t,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +25,6 @@ impl wasm_tabletype_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_new(
|
pub unsafe extern "C" fn wasm_tabletype_new(
|
||||||
// own
|
// own
|
||||||
@@ -57,7 +53,6 @@ pub unsafe extern "C" fn wasm_tabletype_new(
|
|||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
// this function leaks memory because the returned limits pointer is not owned
|
// this function leaks memory because the returned limits pointer is not owned
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_limits(
|
pub unsafe extern "C" fn wasm_tabletype_limits(
|
||||||
tabletype: &wasm_tabletype_t,
|
tabletype: &wasm_tabletype_t,
|
||||||
@@ -71,7 +66,6 @@ pub unsafe extern "C" fn wasm_tabletype_limits(
|
|||||||
|
|
||||||
// TODO: fix memory leak
|
// TODO: fix memory leak
|
||||||
// this function leaks memory because the returned limits pointer is not owned
|
// this function leaks memory because the returned limits pointer is not owned
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_element(
|
pub unsafe extern "C" fn wasm_tabletype_element(
|
||||||
tabletype: &wasm_tabletype_t,
|
tabletype: &wasm_tabletype_t,
|
||||||
@@ -81,6 +75,5 @@ pub unsafe extern "C" fn wasm_tabletype_element(
|
|||||||
Box::into_raw(Box::new(tt.ty.into()))
|
Box::into_raw(Box::new(tt.ty.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_tabletype_delete(_tabletype: Option<Box<wasm_tabletype_t>>) {}
|
pub unsafe extern "C" fn wasm_tabletype_delete(_tabletype: Option<Box<wasm_tabletype_t>>) {}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use super::super::value::wasm_valkind_t;
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use wasmer::ValType;
|
use wasmer::ValType;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
@@ -43,7 +42,6 @@ impl From<wasm_valkind_enum> for ValType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct wasm_valtype_t {
|
pub struct wasm_valtype_t {
|
||||||
@@ -74,7 +72,6 @@ impl From<ValType> for wasm_valtype_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_valtype_new(kind: wasm_valkind_t) -> Option<Box<wasm_valtype_t>> {
|
pub extern "C" fn wasm_valtype_new(kind: wasm_valkind_t) -> Option<Box<wasm_valtype_t>> {
|
||||||
let kind_enum = kind.try_into().ok()?;
|
let kind_enum = kind.try_into().ok()?;
|
||||||
@@ -82,11 +79,9 @@ pub extern "C" fn wasm_valtype_new(kind: wasm_valkind_t) -> Option<Box<wasm_valt
|
|||||||
Some(Box::new(valtype))
|
Some(Box::new(valtype))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_valtype_delete(_valtype: Option<Box<wasm_valtype_t>>) {}
|
pub unsafe extern "C" fn wasm_valtype_delete(_valtype: Option<Box<wasm_valtype_t>>) {}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_valtype_kind(valtype: *const wasm_valtype_t) -> wasm_valkind_t {
|
pub unsafe extern "C" fn wasm_valtype_kind(valtype: *const wasm_valtype_t) -> wasm_valkind_t {
|
||||||
if valtype.is_null() {
|
if valtype.is_null() {
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ use std::convert::{TryFrom, TryInto};
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer::Val;
|
use wasmer::Val;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type wasm_valkind_t = u8;
|
pub type wasm_valkind_t = u8;
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub union wasm_val_inner {
|
pub union wasm_val_inner {
|
||||||
@@ -18,7 +16,6 @@ pub union wasm_val_inner {
|
|||||||
pub(crate) wref: *mut wasm_ref_t,
|
pub(crate) wref: *mut wasm_ref_t,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct wasm_val_t {
|
pub struct wasm_val_t {
|
||||||
@@ -35,7 +32,6 @@ impl Clone for wasm_val_t {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_val_copy(out_ptr: *mut wasm_val_t, val: &wasm_val_t) {
|
pub unsafe extern "C" fn wasm_val_copy(out_ptr: *mut wasm_val_t, val: &wasm_val_t) {
|
||||||
(*out_ptr).kind = val.kind;
|
(*out_ptr).kind = val.kind;
|
||||||
@@ -51,7 +47,6 @@ pub unsafe extern "C" fn wasm_val_copy(out_ptr: *mut wasm_val_t, val: &wasm_val_
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cbindgen:ignore
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_val_delete(val: Option<NonNull<wasm_val_t>>) {
|
pub unsafe extern "C" fn wasm_val_delete(val: Option<NonNull<wasm_val_t>>) {
|
||||||
if let Some(v_inner) = val {
|
if let Some(v_inner) = val {
|
||||||
|
|||||||
Reference in New Issue
Block a user