forked from bytecodealliance/component-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.rs
166 lines (148 loc) · 4.4 KB
/
bindings.rs
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Generated by `wit-bindgen` 0.24.0. DO NOT EDIT!
// Options used:
#[allow(dead_code)]
pub mod exports {
#[allow(dead_code)]
pub mod component_book {
#[allow(dead_code)]
pub mod adder {
#[allow(dead_code, clippy::all)]
pub mod add {
#[used]
#[doc(hidden)]
#[cfg(target_arch = "wasm32")]
static __FORCE_SECTION_REF: fn() =
super::super::super::super::__link_custom_section_describing_imports;
use super::super::super::super::_rt;
#[doc(hidden)]
#[allow(non_snake_case)]
pub unsafe fn _export_add_cabi<T: Guest>(arg0: i32, arg1: i32) -> i32 {
#[cfg(target_arch = "wasm32")]
_rt::run_ctors_once();
let result0 = T::add(arg0 as u32, arg1 as u32);
_rt::as_i32(result0)
}
pub trait Guest {
fn add(a: u32, b: u32) -> u32;
}
#[doc(hidden)]
macro_rules! __export_component_book_adder_add_0_1_0_cabi{
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {
#[export_name = "component-book:adder/[email protected]#add"]
unsafe extern "C" fn export_add(arg0: i32,arg1: i32,) -> i32 {
$($path_to_types)*::_export_add_cabi::<$ty>(arg0, arg1)
}
};);
}
#[doc(hidden)]
pub(crate) use __export_component_book_adder_add_0_1_0_cabi;
}
}
}
}
mod _rt {
#[cfg(target_arch = "wasm32")]
pub fn run_ctors_once() {
wit_bindgen_rt::run_ctors_once();
}
pub fn as_i32<T: AsI32>(t: T) -> i32 {
t.as_i32()
}
pub trait AsI32 {
fn as_i32(self) -> i32;
}
impl<'a, T: Copy + AsI32> AsI32 for &'a T {
fn as_i32(self) -> i32 {
(*self).as_i32()
}
}
impl AsI32 for i32 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u32 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for i16 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u16 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for i8 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u8 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for char {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for usize {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
}
/// Generates `#[no_mangle]` functions to export the specified type as the
/// root implementation of all generated traits.
///
/// For more information see the documentation of `wit_bindgen::generate!`.
///
/// ```rust
/// # macro_rules! export{ ($($t:tt)*) => (); }
/// # trait Guest {}
/// struct MyType;
///
/// impl Guest for MyType {
/// // ...
/// }
///
/// export!(MyType);
/// ```
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! __export_adder_impl {
($ty:ident) => (self::export!($ty with_types_in self););
($ty:ident with_types_in $($path_to_types_root:tt)*) => (
$($path_to_types_root)*::exports::component_book::adder::add::__export_component_book_adder_add_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component_book::adder::add);
)
}
#[doc(inline)]
pub(crate) use __export_adder_impl as export;
#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:wit-bindgen:0.24.0:adder:encoded world"]
#[doc(hidden)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 223] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07d\x01A\x02\x01A\x02\x01\
B\x02\x01@\x02\x01ay\x01by\0y\x04\0\x03add\x01\0\x04\x01\x1ecomponent-book:adder\
/[email protected]\x05\0\x04\x01\x20component-book:adder/[email protected]\x04\0\x0b\x0b\x01\0\
\x05adder\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.\
202.0\x10wit-bindgen-rust\x060.24.0";
#[inline(never)]
#[doc(hidden)]
#[cfg(target_arch = "wasm32")]
pub fn __link_custom_section_describing_imports() {
wit_bindgen_rt::maybe_link_cabi_realloc();
}