polkavm_derive_impl_macro/
lib.rs1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3
4extern crate proc_macro;
5
6use proc_macro::TokenStream;
7
8#[allow(non_snake_case)]
9#[proc_macro_attribute]
10pub fn __PRIVATE_DO_NOT_USE_polkavm_import(args: TokenStream, input: TokenStream) -> TokenStream {
11 let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::ImportBlockAttributes);
12 let input = syn::parse_macro_input!(input as syn::ItemForeignMod);
13 match polkavm_derive_impl::polkavm_import(attributes, input) {
14 Ok(result) => result.into(),
15 Err(error) => error.into_compile_error().into(),
16 }
17}
18
19#[allow(non_snake_case)]
20#[proc_macro_attribute]
21pub fn __PRIVATE_DO_NOT_USE_polkavm_export(args: TokenStream, input: TokenStream) -> TokenStream {
22 let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::ExportBlockAttributes);
23 let input = syn::parse_macro_input!(input as syn::ItemFn);
24 match polkavm_derive_impl::polkavm_export(attributes, input) {
25 Ok(result) => result.into(),
26 Err(error) => error.into_compile_error().into(),
27 }
28}
29
30#[allow(non_snake_case)]
31#[proc_macro_attribute]
32pub fn __PRIVATE_DO_NOT_USE_polkavm_define_abi(args: TokenStream, input: TokenStream) -> TokenStream {
33 let attributes = syn::parse_macro_input!(args as polkavm_derive_impl::AbiSupportAttributes);
34 let input = syn::parse_macro_input!(input as syn::ItemMod);
35 match polkavm_derive_impl::polkavm_define_abi(attributes, input) {
36 Ok(result) => result.into(),
37 Err(error) => error.into_compile_error().into(),
38 }
39}
40
41#[allow(non_snake_case)]
42#[proc_macro]
43pub fn __PRIVATE_DO_NOT_USE_polkavm_impl_abi_support(input: TokenStream) -> TokenStream {
44 let attributes = syn::parse_macro_input!(input as polkavm_derive_impl::AbiSupportAttributes);
45 polkavm_derive_impl::polkavm_impl_abi_support(attributes).into()
46}