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
47
48
49
50
51
52
53
54
55
56
#[macro_use]
extern crate quote;
use proc_macro2::TokenStream;
#[macro_use]
pub mod error;
pub mod ast;
pub mod codegen;
#[cfg(feature = "type-def")]
pub mod typegen;
pub use ast::*;
pub use codegen::*;
pub use error::{BindgenResult, Diagnostic};
#[cfg(feature = "type-def")]
pub use typegen::*;
#[derive(Debug)]
pub struct Napi {
pub item: NapiItem,
}
macro_rules! napi_ast_impl {
( $( ($v:ident, $ast:ident), )* ) => {
#[derive(Debug)]
pub enum NapiItem {
$($v($ast)),*
}
impl TryToTokens for Napi {
fn try_to_tokens(&self, tokens: &mut TokenStream) -> BindgenResult<()> {
match self.item {
$( NapiItem::$v(ref ast) => ast.try_to_tokens(tokens) ),*
}
}
}
#[cfg(feature = "type-def")]
impl ToTypeDef for Napi {
fn to_type_def(&self) -> Option<TypeDef> {
match self.item {
$( NapiItem::$v(ref ast) => ast.to_type_def() ),*
}
}
}
};
}
napi_ast_impl! {
(Fn, NapiFn),
(Struct, NapiStruct),
(Impl, NapiImpl),
(Enum, NapiEnum),
(Const, NapiConst),
}