omp_codegen/lib.rs
1//! codgen crate that gives proc macros to generate exported functions and FFI related code automatically
2use proc_macro::TokenStream;
3
4mod callbacks;
5mod entrypoint;
6mod natives;
7
8/// Creates a callback function for the component to call
9#[proc_macro]
10pub fn callback(args: TokenStream) -> TokenStream {
11 callbacks::create_callback(args)
12}
13
14/// Creates an entry point function for the component to call when it loads
15/// Entry point function is necessary, all the function address is calculated and initialised here
16#[proc_macro_attribute]
17pub fn main(args: TokenStream, input: TokenStream) -> TokenStream {
18 entrypoint::create_main(args, input)
19}
20
21/// Creates a userfunction that calls the native function in component
22/// str - for string data
23/// struct - for open.mp object pointers
24#[proc_macro]
25pub fn native(args: TokenStream) -> TokenStream {
26 natives::create_native(args)
27}