Skip to content

Commit ed8577a

Browse files
author
bors-servo
authored
Auto merge of #606 - emilio:gen-constructors, r=emilio
options: Allow configuring the generation of constructors. Fixes #556 Sorry for the delay fixing this btw.
2 parents d4fce37 + 1217d2d commit ed8577a

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")
@@ -271,6 +271,7 @@ pub fn builder_from_flags<I>
271271
"types" => config.types = true,
272272
"vars" => config.vars = true,
273273
"methods" => config.methods = true,
274+
"constructors" => config.constructors = true,
274275
_ => {
275276
return Err(Error::new(ErrorKind::Other,
276277
"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)