summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-01-19 09:40:30 -0800
committerGitHub <noreply@github.com>2017-01-19 09:40:30 -0800
commit4ac39de18b96bd9488a17cf2650994a3584d440c (patch)
treede6ba17b4d0431f9b480d56f1080137a4a435759
parentbe53b94cae2618653f885290956edcf1e5545078 (diff)
parentb743ab0d5fa222c8d4e7a59a7d3952d042eb2e5d (diff)
Auto merge of #403 - emilio:variadic-fn, r=fitzgen
codegen: Don't implement variadic methods. Fixes #402 r? @fitzgen
-rw-r--r--libbindgen/src/codegen/mod.rs6
-rw-r--r--libbindgen/tests/expectations/tests/variadic-method.rs27
-rw-r--r--libbindgen/tests/headers/variadic-method.hpp6
3 files changed, 39 insertions, 0 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index 932e2b75..7451dd11 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -1319,6 +1319,12 @@ impl MethodCodegen for Method {
_ => panic!("How in the world?"),
};
+ // Do not generate variadic methods, since rust does not allow
+ // implementing them, and we don't do a good job at it anyway.
+ if signature.is_variadic() {
+ return;
+ }
+
let count = {
let mut count = method_names.entry(name.clone())
.or_insert(0);
diff --git a/libbindgen/tests/expectations/tests/variadic-method.rs b/libbindgen/tests/expectations/tests/variadic-method.rs
new file mode 100644
index 00000000..34301069
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/variadic-method.rs
@@ -0,0 +1,27 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "_Z3fooPKcz"]
+ pub fn foo(fmt: *const ::std::os::raw::c_char, ...);
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Bar {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(::std::mem::size_of::<Bar>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Bar>() , 1usize);
+}
+extern "C" {
+ #[link_name = "_ZN3Bar3fooEPKcz"]
+ pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...);
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/headers/variadic-method.hpp b/libbindgen/tests/headers/variadic-method.hpp
new file mode 100644
index 00000000..78a8eb45
--- /dev/null
+++ b/libbindgen/tests/headers/variadic-method.hpp
@@ -0,0 +1,6 @@
+
+void foo(const char* fmt, ...);
+
+struct Bar {
+ void foo(const char* fmt, ...);
+};