diff --git a/src/bindgen/parser.rs b/src/bindgen/parser.rs index 5245fad5d..22719c9ac 100644 --- a/src/bindgen/parser.rs +++ b/src/bindgen/parser.rs @@ -541,7 +541,9 @@ impl Parse { if let syn::Type::Path(ref path) = *item_impl.self_ty { if let Some(type_name) = path.path.get_ident() { for method in item_impl.items.iter().filter_map(|item| match item { - syn::ImplItem::Method(method) => Some(method), + syn::ImplItem::Method(method) if !method.should_skip_parsing() => { + Some(method) + } _ => None, }) { self.load_syn_method( @@ -580,7 +582,11 @@ impl Parse { item_impl: &syn::ItemImpl, ) { let associated_constants = item_impl.items.iter().filter_map(|item| match item { - syn::ImplItem::Const(ref associated_constant) => Some(associated_constant), + syn::ImplItem::Const(ref associated_constant) + if !associated_constant.should_skip_parsing() => + { + Some(associated_constant) + } _ => None, }); self.load_syn_assoc_consts( diff --git a/src/bindgen/utilities.rs b/src/bindgen/utilities.rs index 64cdfb995..a5d566a24 100644 --- a/src/bindgen/utilities.rs +++ b/src/bindgen/utilities.rs @@ -282,6 +282,7 @@ impl_syn_item_helper!(syn::ItemUse); impl_syn_item_helper!(syn::ItemStatic); impl_syn_item_helper!(syn::ItemConst); impl_syn_item_helper!(syn::ItemFn); +impl_syn_item_helper!(syn::ImplItemConst); impl_syn_item_helper!(syn::ImplItemMethod); impl_syn_item_helper!(syn::ItemMod); impl_syn_item_helper!(syn::ItemForeignMod); diff --git a/tests/expectations/ignore.c b/tests/expectations/ignore.c index 8e7da96c0..a2d72a8e4 100644 --- a/tests/expectations/ignore.c +++ b/tests/expectations/ignore.c @@ -3,4 +3,10 @@ #include #include +#define NO_IGNORE_CONST 0 + +#define NoIgnoreStructWithImpl_NO_IGNORE_INNER_CONST 0 + void no_ignore_root(void); + +void no_ignore_associated_method(void); diff --git a/tests/expectations/ignore.compat.c b/tests/expectations/ignore.compat.c index e8539fe4f..8cc867998 100644 --- a/tests/expectations/ignore.compat.c +++ b/tests/expectations/ignore.compat.c @@ -3,12 +3,18 @@ #include #include +#define NO_IGNORE_CONST 0 + +#define NoIgnoreStructWithImpl_NO_IGNORE_INNER_CONST 0 + #ifdef __cplusplus extern "C" { #endif // __cplusplus void no_ignore_root(void); +void no_ignore_associated_method(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/ignore.cpp b/tests/expectations/ignore.cpp index 57ecfdfb1..fc21bddf9 100644 --- a/tests/expectations/ignore.cpp +++ b/tests/expectations/ignore.cpp @@ -4,8 +4,14 @@ #include #include +constexpr static const uint32_t NO_IGNORE_CONST = 0; + +constexpr static const uint32_t NoIgnoreStructWithImpl_NO_IGNORE_INNER_CONST = 0; + extern "C" { void no_ignore_root(); +void no_ignore_associated_method(); + } // extern "C" diff --git a/tests/expectations/ignore.pyx b/tests/expectations/ignore.pyx index 97162bd47..d6ff83acc 100644 --- a/tests/expectations/ignore.pyx +++ b/tests/expectations/ignore.pyx @@ -6,4 +6,10 @@ cdef extern from *: cdef extern from *: + const uint32_t NO_IGNORE_CONST # = 0 + + const uint32_t NoIgnoreStructWithImpl_NO_IGNORE_INNER_CONST # = 0 + void no_ignore_root(); + + void no_ignore_associated_method(); diff --git a/tests/rust/ignore.rs b/tests/rust/ignore.rs index 21480a2d3..b05131724 100644 --- a/tests/rust/ignore.rs +++ b/tests/rust/ignore.rs @@ -13,35 +13,40 @@ pub extern "C" fn no_ignore_root() {} /// cbindgen:ignore #[repr(C)] -pub struct IgnoredStruct {} +pub struct IgnoreStruct {} -pub struct IgnoredStructImpl; +pub struct IgnoreStructWithImpl; /// cbindgen:ignore -impl IgnoredStructImpl {} +impl IgnoreStructWithImpl { + #[no_mangle] + pub extern "C" fn ignore_associated_method() {} + + pub const IGNORE_INNER_CONST: u32 = 0; +} /// cbindgen:ignore -pub const IGNORED_CONST: u32 = 0; +pub const IGNORE_CONST: u32 = 0; -pub const NOT_IGNORED_CONST: u32 = 0; +pub const NO_IGNORE_CONST: u32 = 0; -pub struct StructWithIgnoredImplMembers; +pub struct NoIgnoreStructWithImpl; -impl StructWithIgnoredImplMembers { - /// XXX associated method cbindgen:ignore +impl NoIgnoreStructWithImpl { + /// cbindgen:ignore #[no_mangle] - pub extern "C" fn ignored_associated_method() {} + pub extern "C" fn ignore_associated_method() {} #[no_mangle] pub extern "C" fn no_ignore_associated_method() {} - /// XXX associated constant cbindgen:ignore - pub const IGNORED_INNER_CONST: u32 = 0; + /// cbindgen:ignore + pub const IGNORE_INNER_CONST: u32 = 0; - pub const NOT_IGNORED_INNER_CONST: u32 = 0; + pub const NO_IGNORE_INNER_CONST: u32 = 0; } /// cbindgen:ignore -enum IgnoredEnum {} +enum IgnoreEnum {} -enum NotIgnoredEnum {} +enum NoIgnoreEnum {}