1 //! This file defines the extern "C" API, which is compatible with the 2 //! [Wasm C API](https://github.com/WebAssembly/wasm-c-api). 3 4 #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] 5 6 // TODO complete the C API 7 8 mod config; 9 mod engine; 10 mod error; 11 mod r#extern; 12 mod func; 13 mod global; 14 mod instance; 15 mod linker; 16 mod memory; 17 mod module; 18 mod r#ref; 19 mod store; 20 mod table; 21 mod trap; 22 mod types; 23 mod val; 24 mod vec; 25 26 pub use crate::config::*; 27 pub use crate::engine::*; 28 pub use crate::error::*; 29 pub use crate::func::*; 30 pub use crate::global::*; 31 pub use crate::instance::*; 32 pub use crate::linker::*; 33 pub use crate::memory::*; 34 pub use crate::module::*; 35 pub use crate::r#extern::*; 36 pub use crate::r#ref::*; 37 pub use crate::store::*; 38 pub use crate::table::*; 39 pub use crate::trap::*; 40 pub use crate::types::*; 41 pub use crate::val::*; 42 pub use crate::vec::*; 43 44 #[cfg(feature = "wasi")] 45 mod wasi; 46 #[cfg(feature = "wasi")] 47 pub use crate::wasi::*; 48 49 #[cfg(feature = "wat")] 50 mod wat2wasm; 51 #[cfg(feature = "wat")] 52 pub use crate::wat2wasm::*; 53 54 #[repr(C)] 55 #[derive(Clone)] 56 pub struct wasm_foreign_t { 57 _unused: [u8; 0], 58 } 59 60 #[repr(C)] 61 #[derive(Clone)] 62 pub struct wasm_shared_module_t { 63 _unused: [u8; 0], 64 } 65 66 /// Initialize a `MaybeUninit<T>` 67 /// 68 /// TODO: Replace calls to this function with 69 /// https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.write 70 /// once it is stable. 71 pub(crate) fn initialize<T>(dst: &mut std::mem::MaybeUninit<T>, val: T) { 72 unsafe { 73 std::ptr::write(dst.as_mut_ptr(), val); 74 } 75 } 76