Skip to content

Commit

Permalink
Auto merge of #606 - emilio:gen-constructors, r=emilio
Browse files Browse the repository at this point in the history
options: Allow configuring the generation of constructors.

Fixes #556

Sorry for the delay fixing this btw.
  • Loading branch information
bors-servo authored Apr 3, 2017
2 parents d4fce37 + 1217d2d commit ed8577a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ pub fn builder_from_flags<I>
Arg::with_name("generate")
.long("generate")
.help("Generate a given kind of items, split by commas. \
Valid values are \"functions\",\"types\", \"vars\" and \
\"methods\".")
Valid values are \"functions\",\"types\", \"vars\", \
\"methods\" and \"constructors\".")
.takes_value(true),
Arg::with_name("ignore-methods")
.long("ignore-methods")
Expand Down Expand Up @@ -271,6 +271,7 @@ pub fn builder_from_flags<I>
"types" => config.types = true,
"vars" => config.vars = true,
"methods" => config.methods = true,
"constructors" => config.constructors = true,
_ => {
return Err(Error::new(ErrorKind::Other,
"Unknown generate item"));
Expand Down
29 changes: 29 additions & 0 deletions tests/expectations/tests/gen-constructors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
#[derive(Debug, Default, Copy)]
pub struct Foo {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
"Size of: " , stringify ! ( Foo ) ));
assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
"Alignment of " , stringify ! ( Foo ) ));
}
impl Clone for Foo {
fn clone(&self) -> Self { *self }
}
impl Foo {
#[inline]
pub unsafe fn new(a: ::std::os::raw::c_int) -> Self {
let mut __bindgen_tmp = ::std::mem::uninitialized();
Foo_Foo(&mut __bindgen_tmp, a);
__bindgen_tmp
}
}
6 changes: 6 additions & 0 deletions tests/headers/gen-constructors.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// bindgen-flags: --generate types,constructors

class Foo {
public:
Foo(int a);
};

0 comments on commit ed8577a

Please sign in to comment.