1#![doc(html_root_url = "https://docs.rs/cxx-gen/0.7.188")]
11#![deny(missing_docs)]
12#![expect(dead_code)]
13#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
14#![allow(
15 clippy::cast_sign_loss,
16 clippy::default_trait_access,
17 clippy::elidable_lifetime_names,
18 clippy::enum_glob_use,
19 clippy::expl_impl_clone_on_copy, clippy::inherent_to_string,
21 clippy::items_after_statements,
22 clippy::match_bool,
23 clippy::match_like_matches_macro,
24 clippy::match_same_arms,
25 clippy::missing_errors_doc,
26 clippy::must_use_candidate,
27 clippy::needless_continue,
28 clippy::needless_lifetimes,
29 clippy::needless_pass_by_value,
30 clippy::nonminimal_bool,
31 clippy::precedence,
32 clippy::redundant_else,
33 clippy::ref_option,
34 clippy::similar_names,
35 clippy::single_match_else,
36 clippy::struct_excessive_bools,
37 clippy::struct_field_names,
38 clippy::too_many_arguments,
39 clippy::too_many_lines,
40 clippy::toplevel_ref_arg,
41 clippy::uninlined_format_args
42)]
43#![allow(unknown_lints, mismatched_lifetime_syntaxes)]
44
45mod error;
46mod gen;
47mod syntax;
48
49pub use crate::error::Error;
50pub use crate::gen::include::{Include, HEADER};
51pub use crate::gen::{CfgEvaluator, CfgResult, GeneratedCode, Opt};
52pub use crate::syntax::IncludeKind;
53use proc_macro2::TokenStream;
54
55pub fn generate_header_and_cc(rust_source: TokenStream, opt: &Opt) -> Result<GeneratedCode, Error> {
58 let syntax = syn::parse2(rust_source)
59 .map_err(crate::gen::Error::from)
60 .map_err(Error::from)?;
61 gen::generate(syntax, opt).map_err(Error::from)
62}