Skip to content

Commit 80eff06

Browse files
author
bors-servo
authored
Auto merge of rust-lang#991 - alexeyzab:add-builder-blacklist-type, r=fitzgen
Add a `Builder::blacklist_type` This deprecates `Builder::hide_type`. Related to rust-lang#984. - [x] Add Builder::blacklist_type, that does the same thing as hide_type - [x] Mark Builder::hide_type as #[deprecated = "Use blacklist_type instead"] - [x] Make hide_type delegate to blacklist_type - [x] Rename the BindgenOptions::hidden_types member to BindgenOptions::blacklisted_types - [x] Rename ir::context::BindgenContext::hidden_by_name to blacklisted_by_name - [x] Rename ir::item::Item::is_hidden to is_blacklisted r? @fitzgen
2 parents 169adb1 + 8285552 commit 80eff06

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl CodeGenerator for Item {
321321
return;
322322
}
323323

324-
if self.is_hidden(ctx) || result.seen(self.id()) {
324+
if self.is_blacklisted(ctx) || result.seen(self.id()) {
325325
debug!(
326326
"<Item as CodeGenerator>::codegen: Ignoring hidden or seen: \
327327
self = {:?}",

src/ir/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> {
270270
loop {
271271
match self.traversal.next() {
272272
None => return None,
273-
Some(id) if self.ctx.resolve_item(id).is_hidden(self.ctx) => {
273+
Some(id) if self.ctx.resolve_item(id).is_blacklisted(self.ctx) => {
274274
continue
275275
}
276276
Some(id) => return Some(id),
@@ -1103,7 +1103,7 @@ impl BindgenContext {
11031103
"We only compute template parameter usage as we enter codegen"
11041104
);
11051105

1106-
if self.resolve_item(item).is_hidden(self) {
1106+
if self.resolve_item(item).is_blacklisted(self) {
11071107
return true;
11081108
}
11091109

@@ -1765,14 +1765,14 @@ impl BindgenContext {
17651765
}
17661766
}
17671767

1768-
/// Is the item with the given `name` hidden? Or is the item with the given
1769-
/// `name` and `id` replaced by another type, and effectively hidden?
1770-
pub fn hidden_by_name(&self, path: &[String], id: ItemId) -> bool {
1768+
/// Is the item with the given `name` blacklisted? Or is the item with the given
1769+
/// `name` and `id` replaced by another type, and effectively blacklisted?
1770+
pub fn blacklisted_by_name(&self, path: &[String], id: ItemId) -> bool {
17711771
debug_assert!(
17721772
self.in_codegen_phase(),
17731773
"You're not supposed to call this yet"
17741774
);
1775-
self.options.hidden_types.matches(&path[1..].join("::")) ||
1775+
self.options.blacklisted_types.matches(&path[1..].join("::")) ||
17761776
self.is_replaced_type(path, id)
17771777
}
17781778

src/ir/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,16 @@ impl Item {
603603
&self.annotations
604604
}
605605

606-
/// Whether this item should be hidden.
606+
/// Whether this item should be blacklisted.
607607
///
608608
/// This may be due to either annotations or to other kind of configuration.
609-
pub fn is_hidden(&self, ctx: &BindgenContext) -> bool {
609+
pub fn is_blacklisted(&self, ctx: &BindgenContext) -> bool {
610610
debug_assert!(
611611
ctx.in_codegen_phase(),
612612
"You're not supposed to call this yet"
613613
);
614614
self.annotations.hide() ||
615-
ctx.hidden_by_name(&self.canonical_path(ctx), self.id)
615+
ctx.blacklisted_by_name(&self.canonical_path(ctx), self.id)
616616
}
617617

618618
/// Is this a reference to another type?

src/lib.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Builder {
225225
.count();
226226

227227
self.options
228-
.hidden_types
228+
.blacklisted_types
229229
.get_items()
230230
.iter()
231231
.map(|item| {
@@ -620,8 +620,15 @@ impl Builder {
620620

621621
/// Hide the given type from the generated bindings. Regular expressions are
622622
/// supported.
623-
pub fn hide_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
624-
self.options.hidden_types.insert(arg);
623+
#[deprecated = "Use blacklist_type instead"]
624+
pub fn hide_type<T: AsRef<str>>(self, arg: T) -> Builder {
625+
self.blacklist_type(arg)
626+
}
627+
628+
/// Hide the given type from the generated bindings. Regular expressions are
629+
/// supported.
630+
pub fn blacklist_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
631+
self.options.blacklisted_types.insert(arg);
625632
self
626633
}
627634

@@ -1093,7 +1100,7 @@ impl Builder {
10931100
pub struct BindgenOptions {
10941101
/// The set of types that have been blacklisted and should not appear
10951102
/// anywhere in the generated code.
1096-
pub hidden_types: RegexSet,
1103+
pub blacklisted_types: RegexSet,
10971104

10981105
/// The set of types that should be treated as opaque structures in the
10991106
/// generated code.
@@ -1269,7 +1276,7 @@ impl BindgenOptions {
12691276
self.whitelisted_vars.build();
12701277
self.whitelisted_types.build();
12711278
self.whitelisted_functions.build();
1272-
self.hidden_types.build();
1279+
self.blacklisted_types.build();
12731280
self.opaque_types.build();
12741281
self.bitfield_enums.build();
12751282
self.constified_enum_modules.build();
@@ -1302,7 +1309,7 @@ impl Default for BindgenOptions {
13021309
BindgenOptions {
13031310
rust_target: rust_target,
13041311
rust_features: rust_target.into(),
1305-
hidden_types: Default::default(),
1312+
blacklisted_types: Default::default(),
13061313
opaque_types: Default::default(),
13071314
whitelisted_types: Default::default(),
13081315
whitelisted_functions: Default::default(),

0 commit comments

Comments
 (0)