in src/bindgen/utilities.rs [81:133]
fn is_skip_item_attr(attr: &syn::Meta) -> bool {
match *attr {
syn::Meta::Path(ref path) => {
// TODO(emilio): It'd be great if rustc allowed us to use a syntax
// like `#[cbindgen::ignore]` or such.
path.is_ident("test")
}
syn::Meta::List(ref list) => {
if !list.path.is_ident("cfg") {
return false;
}
// Remove commas of the question by parsing
let parser = syn::punctuated::Punctuated::<proc_macro2::TokenStream, syn::Token![,]>::parse_terminated;
let Ok(tokens) = list.parse_args_with(parser) else {
// cfg attr is a list separated by comma, if that fails, that is probably a malformed cfg attribute
return false;
};
for token in tokens {
let Ok(path) = syn::parse2::<syn::Path>(token) else {
// we are looking for `test`, that should always happen only as path
return false;
};
if path.is_ident("test") {
return true;
}
}
false
// list.nested.iter().any(|nested| match *nested {
// syn::NestedMeta::Meta(ref meta) => is_skip_item_attr(meta),
// syn::NestedMeta::Lit(..) => false,
// })
}
syn::Meta::NameValue(ref name_value) => {
if name_value.path.is_ident("doc") {
if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(ref content),
..
}) = name_value.value
{
// FIXME(emilio): Maybe should use the general annotation
// mechanism, but it seems overkill for this.
if content.value().trim() == "cbindgen:ignore" {
return true;
}
}
}
false
}
}
}