diff options
-rw-r--r-- | src/bin/bindgen.rs | 6 | ||||
-rw-r--r-- | src/gen.rs | 8 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/types.rs | 14 |
4 files changed, 29 insertions, 7 deletions
diff --git a/src/bin/bindgen.rs b/src/bin/bindgen.rs index f208d0ac..7c52c88d 100644 --- a/src/bin/bindgen.rs +++ b/src/bin/bindgen.rs @@ -94,11 +94,11 @@ fn parse_args(args: &[String]) -> ParseResult { options.match_pat.push(args[ix + 1].clone()); ix += 2; } - "-match-type" => { + "-blacklist-type" => { if ix + 1 >= args_len { - return ParseResult::ParseErr("Missing match type pattern".to_string()); + return ParseResult::ParseErr("Missing blacklist type pattern".to_string()); } - options.match_type.push(args[ix + 1].clone()); + options.blacklist_type.push(args[ix + 1].clone()); ix += 2; } "-builtins" => { @@ -389,7 +389,11 @@ fn gen_mod(mut ctx: &mut GenCtx, } } +fn type_blacklisted(ctx: &GenCtx, global: &Global) -> bool { + let global_name = global.name(); + ctx.options.blacklist_type.iter().all(|name| *name != global_name) +} fn gen_globals(mut ctx: &mut GenCtx, links: &[(String, LinkType)], @@ -427,6 +431,10 @@ fn gen_globals(mut ctx: &mut GenCtx, gs = remove_redundant_decl(gs); for g in gs.into_iter() { + if !type_blacklisted(ctx, &g) { + continue; + } + match g { GType(ti) => { let t = ti.borrow().clone(); @@ -51,8 +51,8 @@ impl<'a> Builder<'a> { self } - pub fn match_type<T: Into<String>>(&mut self, arg: T) -> &mut Self { - self.options.match_type.push(arg.into()); + pub fn blacklist_type<T: Into<String>>(&mut self, arg: T) -> &mut Self { + self.options.blacklist_type.push(arg.into()); self } @@ -119,7 +119,7 @@ impl<'a> Default for Builder<'a> { /// Deprecated - use a `Builder` instead pub struct BindgenOptions { pub match_pat: Vec<String>, - pub match_type: Vec<String>, + pub blacklist_type: Vec<String>, pub builtins: bool, pub rust_enums: bool, pub links: Vec<(String, LinkType)>, @@ -137,7 +137,7 @@ impl Default for BindgenOptions { fn default() -> BindgenOptions { BindgenOptions { match_pat: Vec::new(), - match_type: Vec::new(), + blacklist_type: Vec::new(), builtins: false, rust_enums: true, links: Vec::new(), diff --git a/src/types.rs b/src/types.rs index bd0786e1..1207d309 100644 --- a/src/types.rs +++ b/src/types.rs @@ -63,6 +63,20 @@ pub enum Global { } impl Global { + // XXX prevent this dumb to_owned()... didn't want to deal with the borrowed lifetime + pub fn name(&self) -> String { + match *self { + GType(ref info) => info.borrow().name.to_owned(), + GComp(ref info) + | GCompDecl(ref info) => info.borrow().name.to_owned(), + GEnum(ref info) + | GEnumDecl(ref info) => info.borrow().name.to_owned(), + GVar(ref info) + | GFunc(ref info) => info.borrow().name.to_owned(), + GOther => "".to_owned(), + } + } + pub fn compinfo(&self) -> Rc<RefCell<CompInfo>> { match *self { GComp(ref i) |