Skip to content

options: Allow configuring the generation of constructors. #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -268,6 +268,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);
};