diff options
-rw-r--r-- | src/options.rs | 5 | ||||
-rw-r--r-- | tests/expectations/tests/gen-constructors.rs | 33 | ||||
-rw-r--r-- | tests/headers/gen-constructors.hpp | 6 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/options.rs b/src/options.rs index f1c8479a..9f229f66 100644 --- a/src/options.rs +++ b/src/options.rs @@ -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") @@ -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")); diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs new file mode 100644 index 00000000..72c2fc53 --- /dev/null +++ b/tests/expectations/tests/gen-constructors.rs @@ -0,0 +1,33 @@ +/* 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 ) )); +} +extern "C" { + #[link_name = "_ZN3FooC1Ei"] + pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int); +} +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 + } +} diff --git a/tests/headers/gen-constructors.hpp b/tests/headers/gen-constructors.hpp new file mode 100644 index 00000000..809d6ef9 --- /dev/null +++ b/tests/headers/gen-constructors.hpp @@ -0,0 +1,6 @@ +// bindgen-flags: --generate types,constructors,functions + +class Foo { + public: + Foo(int a); +}; |