Skip to content

Commit

Permalink
Add option to skip an entire struct
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 11, 2015
1 parent c124f81 commit 07fe948
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct TestGenerator {
skip_const: Box<Fn(&str) -> bool>,
skip_signededness: Box<Fn(&str) -> bool>,
skip_type: Box<Fn(&str) -> bool>,
skip_struct: Box<Fn(&str) -> bool>,
field_name: Box<Fn(&str, &str) -> String>,
type_name: Box<Fn(&str, bool) -> String>,
}
Expand Down Expand Up @@ -74,6 +75,7 @@ impl TestGenerator {
skip_const: Box::new(|_| false),
skip_signededness: Box::new(|_| false),
skip_type: Box::new(|_| false),
skip_struct: Box::new(|_| false),
field_name: Box::new(|_, f| f.to_string()),
skip_field: Box::new(|_, _| false),
skip_field_type: Box::new(|_, _| false),
Expand Down Expand Up @@ -176,6 +178,13 @@ impl TestGenerator {
self
}

pub fn skip_struct<F>(&mut self, f: F) -> &mut TestGenerator
where F: Fn(&str) -> bool + 'static
{
self.skip_struct = Box::new(f);
self
}

pub fn generate<P: AsRef<Path>>(&mut self, krate: P, out_file: &str) {
self._generate(krate.as_ref(), out_file)
}
Expand Down Expand Up @@ -441,6 +450,10 @@ impl<'a> Generator<'a> {
}

fn test_struct(&mut self, ty: &str, s: &ast::VariantData) {
if (self.opts.skip_struct)(ty) {
return
}

let cty = self.rust_ty_to_c_ty(ty);
self.test_size_align(ty, &cty);

Expand Down

0 comments on commit 07fe948

Please sign in to comment.