polkavm_derive_impl_macro/
lib.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
#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]

extern crate proc_macro;

use proc_macro::TokenStream;

#[allow(non_snake_case)]
#[proc_macro_attribute]
pub fn __PRIVATE_DO_NOT_USE_polkavm_import(args: TokenStream, input: TokenStream) -> TokenStream {
    let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::ImportBlockAttributes);
    let input = syn::parse_macro_input!(input as syn::ItemForeignMod);
    match polkavm_derive_impl::polkavm_import(attributes, input) {
        Ok(result) => result.into(),
        Err(error) => error.into_compile_error().into(),
    }
}

#[allow(non_snake_case)]
#[proc_macro_attribute]
pub fn __PRIVATE_DO_NOT_USE_polkavm_export(args: TokenStream, input: TokenStream) -> TokenStream {
    let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::ExportBlockAttributes);
    let input = syn::parse_macro_input!(input as syn::ItemFn);
    match polkavm_derive_impl::polkavm_export(attributes, input) {
        Ok(result) => result.into(),
        Err(error) => error.into_compile_error().into(),
    }
}

#[allow(non_snake_case)]
#[proc_macro_attribute]
pub fn __PRIVATE_DO_NOT_USE_polkavm_define_abi(args: TokenStream, input: TokenStream) -> TokenStream {
    let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::AbiSupportAttributes);
    let input = syn::parse_macro_input!(input as syn::ItemMod);
    match polkavm_derive_impl::polkavm_define_abi(attributes, input) {
        Ok(result) => result.into(),
        Err(error) => error.into_compile_error().into(),
    }
}

#[allow(non_snake_case)]
#[proc_macro]
pub fn __PRIVATE_DO_NOT_USE_polkavm_impl_abi_support(input: TokenStream) -> TokenStream {
    let attributes = syn::parse_macro_input!(input as polkavm_derive_impl::AbiSupportAttributes);
    polkavm_derive_impl::polkavm_impl_abi_support(attributes).into()
}