Skip to content

Commit

Permalink
bug fixed, update test and expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
scovich authored and emilio committed May 7, 2024
1 parent 0c82a32 commit 10f32b0
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
10 changes: 8 additions & 2 deletions src/bindgen/parser.rs
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/bindgen/utilities.rs
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions tests/expectations/ignore.c
Expand Up @@ -3,4 +3,10 @@
#include <stdint.h>
#include <stdlib.h>

#define NO_IGNORE_CONST 0

#define NoIgnoreStructWithImpl_NO_IGNORE_INNER_CONST 0

void no_ignore_root(void);

void no_ignore_associated_method(void);
6 changes: 6 additions & 0 deletions tests/expectations/ignore.compat.c
Expand Up @@ -3,12 +3,18 @@
#include <stdint.h>
#include <stdlib.h>

#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
6 changes: 6 additions & 0 deletions tests/expectations/ignore.cpp
Expand Up @@ -4,8 +4,14 @@
#include <ostream>
#include <new>

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"
6 changes: 6 additions & 0 deletions tests/expectations/ignore.pyx
Expand Up @@ -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();
33 changes: 19 additions & 14 deletions tests/rust/ignore.rs
Expand Up @@ -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 {}

0 comments on commit 10f32b0

Please sign in to comment.