Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use path_for_whitelisting instead of canonical_path when matching #1893

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions bindgen-integration/build.rs
@@ -1,8 +1,8 @@
extern crate bindgen;
extern crate cc;

use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks, IntKind};
use bindgen::Builder;
use bindgen::callbacks::{IntKind, MacroParsingBehavior, ParseCallbacks};
use bindgen::{Builder, EnumVariation};
use std::collections::HashSet;
use std::env;
use std::path::PathBuf;
Expand Down Expand Up @@ -50,9 +50,9 @@ impl ParseCallbacks for MacroCallback {
assert_eq!(value, b"string");
*self.seen_hellos.lock().unwrap() += 1;
}
"TESTMACRO_STRING_EXPANDED" |
"TESTMACRO_STRING" |
"TESTMACRO_INTEGER" => {
"TESTMACRO_STRING_EXPANDED"
| "TESTMACRO_STRING"
| "TESTMACRO_INTEGER" => {
johnmave126 marked this conversation as resolved.
Show resolved Hide resolved
// The integer test macro is, actually, not expected to show up here at all -- but
// should produce an error if it does.
assert_eq!(
Expand Down Expand Up @@ -147,7 +147,9 @@ fn main() {
let bindings = Builder::default()
.rustfmt_bindings(false)
.enable_cxx_namespaces()
.rustified_enum(".*")
.default_enum_style(EnumVariation::Rust {
non_exhaustive: false,
})
.raw_line("pub use self::root::*;")
.raw_line("extern { fn my_prefixed_function_to_remove(i: i32); }")
.module_raw_line("root::testing", "pub type Bar = i32;")
Expand All @@ -159,6 +161,8 @@ fn main() {
seen_funcs: Mutex::new(0),
}))
.blacklist_function("my_prefixed_function_to_remove")
.constified_enum("my_prefixed_enum_to_be_constified")
.opaque_type("my_prefixed_templated_foo<my_prefixed_baz>")
.generate()
.expect("Unable to generate bindings");

Expand Down
2 changes: 1 addition & 1 deletion bindgen-integration/cpp/Test.cc
Expand Up @@ -134,4 +134,4 @@ Seventh::assert(bool first,

int my_prefixed_function_name() {
return 4;
}
}
17 changes: 17 additions & 0 deletions bindgen-integration/cpp/Test.h
Expand Up @@ -210,4 +210,21 @@ struct my_prefixed_foo {
my_prefixed_bar member;
};

enum my_prefixed_enum_to_be_constified {
ONE = 1,
TWO,
THREE,
};

struct my_prefixed_baz {
char foo[30];
};

template<typename T>
struct my_prefixed_templated_foo {
T member;
};

my_prefixed_templated_foo<my_prefixed_baz> TEMPLATED_CONST_VALUE;

void my_prefixed_function_to_remove();
6 changes: 6 additions & 0 deletions bindgen-integration/src/lib.rs
Expand Up @@ -245,6 +245,12 @@ fn test_item_rename() {
};
}

#[test]
fn test_matching_with_rename() {
assert_eq!(bindings::enum_to_be_constified_THREE, 3);
assert_eq!(unsafe { bindings::TEMPLATED_CONST_VALUE.len() }, 30);
}

#[test]
fn test_macro_customintkind_path() {
let v: &std::any::Any = &bindings::TESTMACRO_CUSTOMINTKIND_PATH;
Expand Down