dlopen_derive/
lib.rs

1#![recursion_limit="128"]
2
3extern crate proc_macro;
4#[macro_use]
5extern crate syn;
6#[macro_use]
7extern crate quote;
8
9mod api;
10mod multi_api;
11mod wrapper;
12mod common;
13
14
15
16use proc_macro::TokenStream;
17use api::impl_library_api;
18use wrapper::impl_wrapper_api;
19use multi_api::impl_wrapper_multi_api;
20use syn::{DeriveInput};
21
22#[proc_macro_derive(WrapperApi, attributes(dlopen_name, dlopen_allow_null))]
23pub fn wrapper_api(input: TokenStream) -> TokenStream {
24    // Parse the string representation
25    let ast = parse_macro_input!(input as DeriveInput);
26
27    // Build the impl
28    let gen = impl_wrapper_api(&ast);
29
30    // Return the generated impl
31    TokenStream::from(gen)
32}
33
34#[proc_macro_derive(WrapperMultiApi)]
35pub fn wrapper_multi_api(input: TokenStream) -> TokenStream {
36    // Parse the string representation
37    let ast = parse_macro_input!(input as DeriveInput);
38
39    // Build the impl
40    let gen = impl_wrapper_multi_api(&ast);
41
42    // Return the generated impl
43    TokenStream::from(gen)
44}
45
46#[proc_macro_derive(SymBorApi, attributes(dlopen_name))]
47pub fn library_api(input: TokenStream) -> TokenStream {
48    // Parse the string representation
49    let ast = parse_macro_input!(input as DeriveInput);
50
51    // Build the impl
52    let gen = impl_library_api(&ast);
53
54    // Return the generated impl
55    TokenStream::from(gen)
56}