Skip to content

Commit 1217d2d

Browse files
committed
options: Allow configuring the generation of constructors.
1 parent 9021854 commit 1217d2d

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

src/options.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ pub fn builder_from_flags<I>
111111
Arg::with_name("generate")
112112
.long("generate")
113113
.help("Generate a given kind of items, split by commas. \
114-
Valid values are \"functions\",\"types\", \"vars\" and \
115-
\"methods\".")
114+
Valid values are \"functions\",\"types\", \"vars\", \
115+
\"methods\" and \"constructors\".")
116116
.takes_value(true),
117117
Arg::with_name("ignore-methods")
118118
.long("ignore-methods")
@@ -268,6 +268,7 @@ pub fn builder_from_flags<I>
268268
"types" => config.types = true,
269269
"vars" => config.vars = true,
270270
"methods" => config.methods = true,
271+
"constructors" => config.constructors = true,
271272
_ => {
272273
return Err(Error::new(ErrorKind::Other,
273274
"Unknown generate item"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Default, Copy)]
9+
pub struct Foo {
10+
pub _address: u8,
11+
}
12+
#[test]
13+
fn bindgen_test_layout_Foo() {
14+
assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
15+
"Size of: " , stringify ! ( Foo ) ));
16+
assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
17+
"Alignment of " , stringify ! ( Foo ) ));
18+
}
19+
impl Clone for Foo {
20+
fn clone(&self) -> Self { *self }
21+
}
22+
impl Foo {
23+
#[inline]
24+
pub unsafe fn new(a: ::std::os::raw::c_int) -> Self {
25+
let mut __bindgen_tmp = ::std::mem::uninitialized();
26+
Foo_Foo(&mut __bindgen_tmp, a);
27+
__bindgen_tmp
28+
}
29+
}

tests/headers/gen-constructors.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// bindgen-flags: --generate types,constructors
2+
3+
class Foo {
4+
public:
5+
Foo(int a);
6+
};

0 commit comments

Comments
 (0)