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
#![allow(dead_code)]
#![allow(
clippy::inherent_to_string,
clippy::new_without_default,
clippy::nonminimal_bool,
clippy::or_fun_call,
clippy::too_many_arguments,
clippy::toplevel_ref_arg
)]
mod error;
mod gen;
mod syntax;
pub use crate::error::Error;
pub use crate::gen::include::{Include, HEADER};
pub use crate::gen::{GeneratedCode, Opt};
pub use crate::syntax::IncludeKind;
use proc_macro2::TokenStream;
pub fn generate_header_and_cc(rust_source: TokenStream, opt: &Opt) -> Result<GeneratedCode, Error> {
let syntax = syn::parse2(rust_source)
.map_err(crate::gen::Error::from)
.map_err(Error::from)?;
gen::generate(syntax, opt).map_err(Error::from)
}