use syn::{Attribute, Ident};
use crate::conversion::convert_error::ErrorContext;
use super::{convert_error::ConvertErrorWithContext, ConvertError};
pub(crate) mod abstract_types;
pub(crate) mod ctypes;
pub(crate) mod fun;
pub(crate) mod gc;
mod name_check;
pub(crate) mod pod; pub(crate) mod remove_ignored;
pub(crate) mod tdef;
mod type_converter;
pub(crate) use name_check::check_names;
fn remove_bindgen_attrs(
attrs: &mut Vec<Attribute>,
id: Ident,
) -> Result<(), ConvertErrorWithContext> {
if has_attr(attrs, "bindgen_unused_template_param") {
return Err(ConvertErrorWithContext(
ConvertError::UnusedTemplateParam,
Some(ErrorContext::Item(id)),
));
}
fn is_bindgen_attr(attr: &Attribute) -> bool {
let segments = &attr.path.segments;
segments.len() == 1
&& segments
.first()
.unwrap()
.ident
.to_string()
.starts_with("bindgen_")
}
attrs.retain(|a| !is_bindgen_attr(a));
Ok(())
}
fn has_attr(attrs: &[Attribute], attr_name: &str) -> bool {
attrs.iter().any(|at| at.path.is_ident(attr_name))
}