|
| 1 | +// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT! |
| 2 | +// Options used: |
| 3 | +// * runtime_path: "wit_bindgen_rt" |
| 4 | +#[doc(hidden)] |
| 5 | +#[allow(non_snake_case)] |
| 6 | +pub unsafe fn _export_hello_world_cabi<T: Guest>() -> *mut u8 { |
| 7 | + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); |
| 8 | + let result0 = T::hello_world(); |
| 9 | + let ptr1 = (&raw mut _RET_AREA.0).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(::core::mem::size_of::<*const u8>()).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(::core::mem::size_of::<*const u8>()).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 | +macro_rules! __export_world_example_cabi { |
| 30 | + ($ty:ident with_types_in $($path_to_types:tt)*) => { |
| 31 | + const _ : () = { #[unsafe (export_name = "hello-world")] unsafe extern "C" fn |
| 32 | + export_hello_world() -> * mut u8 { unsafe { $($path_to_types)*:: |
| 33 | + _export_hello_world_cabi::<$ty > () } } #[unsafe (export_name = |
| 34 | + "cabi_post_hello-world")] unsafe extern "C" fn _post_return_hello_world(arg0 : * |
| 35 | + mut u8,) { unsafe { $($path_to_types)*:: __post_return_hello_world::<$ty > (arg0) |
| 36 | + } } }; |
| 37 | + }; |
| 38 | +} |
| 39 | +#[doc(hidden)] |
| 40 | +pub(crate) use __export_world_example_cabi; |
| 41 | +#[cfg_attr(target_pointer_width = "64", repr(align(8)))] |
| 42 | +#[cfg_attr(target_pointer_width = "32", repr(align(4)))] |
| 43 | +struct _RetArea([::core::mem::MaybeUninit<u8>; 2 * ::core::mem::size_of::<*const u8>()]); |
| 44 | +static mut _RET_AREA: _RetArea = _RetArea( |
| 45 | + [::core::mem::MaybeUninit::uninit(); 2 * ::core::mem::size_of::<*const u8>()], |
| 46 | +); |
| 47 | +#[rustfmt::skip] |
| 48 | +mod _rt { |
| 49 | + #![allow(dead_code, clippy::all)] |
| 50 | + #[cfg(target_arch = "wasm32")] |
| 51 | + pub fn run_ctors_once() { |
| 52 | + wit_bindgen_rt::run_ctors_once(); |
| 53 | + } |
| 54 | + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { |
| 55 | + if size == 0 { |
| 56 | + return; |
| 57 | + } |
| 58 | + let layout = alloc::Layout::from_size_align_unchecked(size, align); |
| 59 | + alloc::dealloc(ptr, layout); |
| 60 | + } |
| 61 | + pub use alloc_crate::string::String; |
| 62 | + pub use alloc_crate::alloc; |
| 63 | + extern crate alloc as alloc_crate; |
| 64 | +} |
| 65 | +/// Generates `#[unsafe(no_mangle)]` functions to export the specified type as |
| 66 | +/// the root implementation of all generated traits. |
| 67 | +/// |
| 68 | +/// For more information see the documentation of `wit_bindgen::generate!`. |
| 69 | +/// |
| 70 | +/// ```rust |
| 71 | +/// # macro_rules! export{ ($($t:tt)*) => (); } |
| 72 | +/// # trait Guest {} |
| 73 | +/// struct MyType; |
| 74 | +/// |
| 75 | +/// impl Guest for MyType { |
| 76 | +/// // ... |
| 77 | +/// } |
| 78 | +/// |
| 79 | +/// export!(MyType); |
| 80 | +/// ``` |
| 81 | +#[allow(unused_macros)] |
| 82 | +#[doc(hidden)] |
| 83 | +macro_rules! __export_example_impl { |
| 84 | + ($ty:ident) => { |
| 85 | + self::export!($ty with_types_in self); |
| 86 | + }; |
| 87 | + ($ty:ident with_types_in $($path_to_types_root:tt)*) => { |
| 88 | + $($path_to_types_root)*:: __export_world_example_cabi!($ty with_types_in |
| 89 | + $($path_to_types_root)*); |
| 90 | + }; |
| 91 | +} |
| 92 | +#[doc(inline)] |
| 93 | +pub(crate) use __export_example_impl as export; |
| 94 | +#[cfg(target_arch = "wasm32")] |
| 95 | +#[unsafe( |
| 96 | + link_section = "component-type:wit-bindgen:0.41.0:component:websearch-bing:example:encoded world" |
| 97 | +)] |
| 98 | +#[doc(hidden)] |
| 99 | +#[allow(clippy::octal_escapes)] |
| 100 | +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 189] = *b"\ |
| 101 | +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07@\x01A\x02\x01A\x02\x01\ |
| 102 | +@\0\0s\x04\0\x0bhello-world\x01\0\x04\0\x20component:websearch-bing/example\x04\0\ |
| 103 | +\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit\ |
| 104 | +-component\x070.227.1\x10wit-bindgen-rust\x060.41.0"; |
| 105 | +#[inline(never)] |
| 106 | +#[doc(hidden)] |
| 107 | +pub fn __link_custom_section_describing_imports() { |
| 108 | + wit_bindgen_rt::maybe_link_cabi_realloc(); |
| 109 | +} |
0 commit comments