Skip to content

Commit f4d10c3

Browse files
johnmave126emilio
authored andcommitted
Add integration test for name matching
1 parent f221479 commit f4d10c3

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

bindgen-integration/build.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate bindgen;
22
extern crate cc;
33

4-
use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks, IntKind};
5-
use bindgen::Builder;
4+
use bindgen::callbacks::{IntKind, MacroParsingBehavior, ParseCallbacks};
5+
use bindgen::{Builder, EnumVariation};
66
use std::collections::HashSet;
77
use std::env;
88
use std::path::PathBuf;
@@ -147,7 +147,9 @@ fn main() {
147147
let bindings = Builder::default()
148148
.rustfmt_bindings(false)
149149
.enable_cxx_namespaces()
150-
.rustified_enum(".*")
150+
.default_enum_style(EnumVariation::Rust {
151+
non_exhaustive: false,
152+
})
151153
.raw_line("pub use self::root::*;")
152154
.raw_line("extern { fn my_prefixed_function_to_remove(i: i32); }")
153155
.module_raw_line("root::testing", "pub type Bar = i32;")
@@ -159,6 +161,8 @@ fn main() {
159161
seen_funcs: Mutex::new(0),
160162
}))
161163
.blacklist_function("my_prefixed_function_to_remove")
164+
.constified_enum("my_prefixed_enum_to_be_constified")
165+
.opaque_type("my_prefixed_templated_foo<my_prefixed_baz>")
162166
.generate()
163167
.expect("Unable to generate bindings");
164168

bindgen-integration/cpp/Test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ Seventh::assert(bool first,
134134

135135
int my_prefixed_function_name() {
136136
return 4;
137-
}
137+
}

bindgen-integration/cpp/Test.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,21 @@ struct my_prefixed_foo {
210210
my_prefixed_bar member;
211211
};
212212

213+
enum my_prefixed_enum_to_be_constified {
214+
ONE = 1,
215+
TWO,
216+
THREE,
217+
};
218+
219+
struct my_prefixed_baz {
220+
char foo[30];
221+
};
222+
223+
template<typename T>
224+
struct my_prefixed_templated_foo {
225+
T member;
226+
};
227+
228+
my_prefixed_templated_foo<my_prefixed_baz> TEMPLATED_CONST_VALUE;
229+
213230
void my_prefixed_function_to_remove();

bindgen-integration/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ fn test_item_rename() {
245245
};
246246
}
247247

248+
#[test]
249+
fn test_matching_with_rename() {
250+
assert_eq!(bindings::enum_to_be_constified_THREE, 3);
251+
assert_eq!(unsafe { bindings::TEMPLATED_CONST_VALUE.len() }, 30);
252+
}
253+
248254
#[test]
249255
fn test_macro_customintkind_path() {
250256
let v: &std::any::Any = &bindings::TESTMACRO_CUSTOMINTKIND_PATH;

0 commit comments

Comments
 (0)