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
#![cfg_attr(rustfmt, rustfmt::skip)]

use super::*;

mod const_;
mod fn_;
mod static_;
mod type_;

#[allow(unused_macros)]
macro_rules! emit {( $($tt:tt)* ) => ( $($tt)* )}

pub(in super)
fn ffi_export (
    args: TokenStream2,
    input: TokenStream2,
) -> Result<TokenStream2>
{
    use ::proc_macro2::*;

    match parse2::<Item>(input)? {
        | Item::Struct(struct_) => type_::handle(
            parse2(args)?,
            &struct_.ident,
            &struct_.generics,
            &struct_,
        ),
        | Item::Enum(enum_) => type_::handle(
            parse2(args)?,
            &enum_.ident,
            &enum_.generics,
            &enum_,
        ),
        | Item::Fn(fn_) => fn_::handle(parse2(args)?, fn_),
        | Item::Const(const_) => const_::handle(parse2(args)?, const_),
        | Item::Static(static_) => static_::handle(parse2(args)?, static_),
        | _otherwise => bail!("unsupported item type"),
    }
}