Skip to main content

wasm_wrapper_gen/
lib.rs

1#[macro_use]
2extern crate proc_macro_hack;
3
4#[allow(unused_imports)]
5#[macro_use]
6extern crate wasm_wrapper_gen_impl;
7#[doc(hidden)]
8pub use wasm_wrapper_gen_impl::*;
9
10proc_macro_item_decl! {
11    js_fn! => __js_fn_impl
12}
13
14#[doc(hidden)]
15pub mod _extern_definitions {
16    use std::mem;
17
18    #[allow(non_snake_case)]
19    #[no_mangle]
20    pub unsafe extern "C" fn __js_fn__builtin_alloc(len: usize) -> *mut u8 {
21        let memory = Vec::<u8>::with_capacity(len);
22
23        let ptr = memory.as_slice().as_ptr() as *mut u8;
24
25        mem::forget(memory);
26
27        ptr
28    }
29
30    #[allow(non_snake_case)]
31    #[no_mangle]
32    pub unsafe extern "C" fn __js_fn__builtin_dealloc(ptr: *mut u8, len: usize) {
33        if len == 0 {
34            return;
35        }
36        assert!(ptr as usize != 0);
37
38        Vec::<u8>::from_raw_parts(ptr, 0, len);
39    }
40}