1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Implements C-API support for the Wasmi WebAssembly interpreter.
//!
//! Namely implements the Wasm C-API proposal found here: <https://github.com/WebAssembly/wasm-c-api/>
//!
//! # Crate features
//!
//! ## The `prefix-symbols` feature
//! Adds a `wasmi_` prefix to all the public symbols. This means that, for example, the function `wasm_store_delete`
//! will be given the public (not mangled) symbol `wasmi_wasm_store_delete`.
//!
//! ### Rationale
//! This feature allows users that need to separate multiple C-API implementers to segregate wasmi's C-API symbols,
//! avoiding symbol clashes.
//!
//! ### Note
//! It's important to notice that when the `prefix-symbols` feature is enabled, the symbols declared in the C-API header
//! are not given the prefix, introducing - by design, in order to keep the C-API header same as the actual
//! specification - an asymmetry. For example, Rust users that want to enable this feature, can use `bindgen` to
//! generate correct C-to-Rust interop code:
//!
//! ```ignore
//! #[derive(Debug)]
//! struct WasmiRenamer {}
//!
//! impl ParseCallbacks for WasmiRenamer {
//! /// This function will run for every extern variable and function. The returned value determines
//! /// the link name in the bindings.
//! fn generated_link_name_override(
//! &self,
//! item_info: bindgen::callbacks::ItemInfo<'_>,
//! ) -> Option<String> {
//! if item_info.name.starts_with("wasm") {
//! let new_name = if cfg!(any(target_os = "macos", target_os = "ios")) {
//! format!("_wasmi_{}", item_info.name)
//! } else {
//! format!("wasmi_{}", item_info.name)
//! };
//!
//! Some(new_name)
//! } else {
//! None
//! }
//! }
//! }
//!
//! let bindings = bindgen::Builder::default()
//! .header(
//! PathBuf::from(std::env::var("DEP_WASMI_C_API_INCLUDE").unwrap())
//! .join("wasm.h")
//! .to_string_lossy(),
//! )
//! .derive_default(true)
//! .derive_debug(true)
//! .parse_callbacks(Box::new(WasmiRenamer {}))
//! .generate()
//! .expect("Unable to generate bindings for `wasmi`!");
//! ```
extern crate alloc;
extern crate std;
pub use wasmi;
use *;
pub use ;