|
| 1 | +// Generated by `wit-bindgen` 0.24.0. DO NOT EDIT! |
| 2 | +// Options used: |
| 3 | +#[doc(hidden)] |
| 4 | +#[allow(non_snake_case)] |
| 5 | +pub unsafe fn _export_hello_world_cabi<T: Guest>() -> *mut u8 { |
| 6 | + #[cfg(target_arch = "wasm32")] |
| 7 | + _rt::run_ctors_once(); |
| 8 | + let result0 = T::hello_world(); |
| 9 | + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>(); |
| 10 | + let vec2 = (result0.into_bytes()).into_boxed_slice(); |
| 11 | + let ptr2 = vec2.as_ptr().cast::<u8>(); |
| 12 | + let len2 = vec2.len(); |
| 13 | + ::core::mem::forget(vec2); |
| 14 | + *ptr1.add(4).cast::<usize>() = len2; |
| 15 | + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); |
| 16 | + ptr1 |
| 17 | +} |
| 18 | +#[doc(hidden)] |
| 19 | +#[allow(non_snake_case)] |
| 20 | +pub unsafe fn __post_return_hello_world<T: Guest>(arg0: *mut u8) { |
| 21 | + let l0 = *arg0.add(0).cast::<*mut u8>(); |
| 22 | + let l1 = *arg0.add(4).cast::<usize>(); |
| 23 | + _rt::cabi_dealloc(l0, l1, 1); |
| 24 | +} |
| 25 | +pub trait Guest { |
| 26 | + fn hello_world() -> _rt::String; |
| 27 | +} |
| 28 | +#[doc(hidden)] |
| 29 | + |
| 30 | +macro_rules! __export_world_example_cabi{ |
| 31 | + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { |
| 32 | + |
| 33 | + #[export_name = "hello-world"] |
| 34 | + unsafe extern "C" fn export_hello_world() -> *mut u8 { |
| 35 | + $($path_to_types)*::_export_hello_world_cabi::<$ty>() |
| 36 | + } |
| 37 | + #[export_name = "cabi_post_hello-world"] |
| 38 | + unsafe extern "C" fn _post_return_hello_world(arg0: *mut u8,) { |
| 39 | + $($path_to_types)*::__post_return_hello_world::<$ty>(arg0) |
| 40 | + } |
| 41 | + };); |
| 42 | +} |
| 43 | +#[doc(hidden)] |
| 44 | +pub(crate) use __export_world_example_cabi; |
| 45 | +#[repr(align(4))] |
| 46 | +struct _RetArea([::core::mem::MaybeUninit<u8>; 8]); |
| 47 | +static mut _RET_AREA: _RetArea = |
| 48 | + _RetArea([::core::mem::MaybeUninit::uninit(); 8]); |
| 49 | +mod _rt { |
| 50 | + |
| 51 | + #[cfg(target_arch = "wasm32")] |
| 52 | + pub fn run_ctors_once() { |
| 53 | + wit_bindgen_rt::run_ctors_once(); |
| 54 | + } |
| 55 | + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { |
| 56 | + if size == 0 { |
| 57 | + return; |
| 58 | + } |
| 59 | + let layout = alloc::Layout::from_size_align_unchecked(size, align); |
| 60 | + alloc::dealloc(ptr as *mut u8, layout); |
| 61 | + } |
| 62 | + pub use alloc_crate::alloc; |
| 63 | + pub use alloc_crate::string::String; |
| 64 | + extern crate alloc as alloc_crate; |
| 65 | +} |
| 66 | + |
| 67 | +/// Generates `#[no_mangle]` functions to export the specified type as the |
| 68 | +/// root implementation of all generated traits. |
| 69 | +/// |
| 70 | +/// For more information see the documentation of `wit_bindgen::generate!`. |
| 71 | +/// |
| 72 | +/// ```rust |
| 73 | +/// # macro_rules! export{ ($($t:tt)*) => (); } |
| 74 | +/// # trait Guest {} |
| 75 | +/// struct MyType; |
| 76 | +/// |
| 77 | +/// impl Guest for MyType { |
| 78 | +/// // ... |
| 79 | +/// } |
| 80 | +/// |
| 81 | +/// export!(MyType); |
| 82 | +/// ``` |
| 83 | +#[allow(unused_macros)] |
| 84 | +#[doc(hidden)] |
| 85 | + |
| 86 | +macro_rules! __export_example_impl { |
| 87 | + ($ty:ident) => (self::export!($ty with_types_in self);); |
| 88 | + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( |
| 89 | + $($path_to_types_root)*::__export_world_example_cabi!($ty with_types_in $($path_to_types_root)*); |
| 90 | + ) |
| 91 | +} |
| 92 | +#[doc(inline)] |
| 93 | +pub(crate) use __export_example_impl as export; |
| 94 | + |
| 95 | +#[cfg(target_arch = "wasm32")] |
| 96 | +#[link_section = "component-type:wit-bindgen:0.24.0:example:encoded world"] |
| 97 | +#[doc(hidden)] |
| 98 | +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 194] = *b"\ |
| 99 | +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07E\x01A\x02\x01A\x02\x01\ |
| 100 | +@\0\0s\x04\0\x0bhello-world\x01\0\x04\x01%component:test-wasi-component/example\x04\ |
| 101 | +\0\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dw\ |
| 102 | +it-component\x070.202.0\x10wit-bindgen-rust\x060.24.0"; |
| 103 | + |
| 104 | +#[inline(never)] |
| 105 | +#[doc(hidden)] |
| 106 | +#[cfg(target_arch = "wasm32")] |
| 107 | +pub fn __link_custom_section_describing_imports() { |
| 108 | + wit_bindgen_rt::maybe_link_cabi_realloc(); |
| 109 | +} |
0 commit comments