summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-15 08:15:41 -0800
committerGitHub <noreply@github.com>2016-12-15 08:15:41 -0800
commit3289e9392eaad0a00bc180089a119976ad6c488f (patch)
tree933b9a7a0879d80ff879a250436256390ddfef08
parent59a52563f835034542786ea11867e0fd51a5c218 (diff)
parent31bd2d3a1ffa47e15b0701761966fc836c9da99d (diff)
Auto merge of #344 - emilio:fix-dtors, r=fitzgen
Properly mangle method names, don't generate destructors. r? @fitzgen Fixes a few issues seen in #342
-rw-r--r--libbindgen/src/codegen/mod.rs2
-rw-r--r--libbindgen/src/ir/function.rs2
-rw-r--r--libbindgen/tests/expectations/tests/method-mangling.rs29
-rw-r--r--libbindgen/tests/expectations/tests/public-dtor.rs16
-rw-r--r--libbindgen/tests/headers/method-mangling.hpp5
-rw-r--r--libbindgen/tests/headers/public-dtor.hpp15
6 files changed, 67 insertions, 2 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index bf516cd2..9ab264c6 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -1404,7 +1404,7 @@ impl MethodCodegen for Method {
let item = ast::ImplItem {
id: ast::DUMMY_NODE_ID,
- ident: ctx.ext_cx().ident_of(&name),
+ ident: ctx.rust_ident(&name),
vis: ast::Visibility::Public,
attrs: attrs,
node: ast::ImplItemKind::Method(sig, P(block)),
diff --git a/libbindgen/src/ir/function.rs b/libbindgen/src/ir/function.rs
index a068097d..76576dbd 100644
--- a/libbindgen/src/ir/function.rs
+++ b/libbindgen/src/ir/function.rs
@@ -242,9 +242,9 @@ impl ClangSubItemParser for Function {
-> Result<ParseResult<Self>, ParseError> {
use clang_sys::*;
match cursor.kind() {
+ // FIXME(emilio): Generate destructors properly.
CXCursor_FunctionDecl |
CXCursor_Constructor |
- CXCursor_Destructor |
CXCursor_CXXMethod => {}
_ => return Err(ParseError::Continue),
};
diff --git a/libbindgen/tests/expectations/tests/method-mangling.rs b/libbindgen/tests/expectations/tests/method-mangling.rs
new file mode 100644
index 00000000..3b5107a8
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/method-mangling.rs
@@ -0,0 +1,29 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 1usize);
+}
+extern "C" {
+ #[link_name = "_ZN3Foo4typeEv"]
+ pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int;
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
+impl Foo {
+ #[inline]
+ pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int {
+ Foo_type(&mut *self)
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/public-dtor.rs b/libbindgen/tests/expectations/tests/public-dtor.rs
new file mode 100644
index 00000000..851857ee
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/public-dtor.rs
@@ -0,0 +1,16 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct cv_String {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_cv_String() {
+ assert_eq!(::std::mem::size_of::<cv_String>() , 1usize);
+ assert_eq!(::std::mem::align_of::<cv_String>() , 1usize);
+}
diff --git a/libbindgen/tests/headers/method-mangling.hpp b/libbindgen/tests/headers/method-mangling.hpp
new file mode 100644
index 00000000..0dac4975
--- /dev/null
+++ b/libbindgen/tests/headers/method-mangling.hpp
@@ -0,0 +1,5 @@
+
+class Foo {
+public:
+ int type();
+};
diff --git a/libbindgen/tests/headers/public-dtor.hpp b/libbindgen/tests/headers/public-dtor.hpp
new file mode 100644
index 00000000..5d4fb592
--- /dev/null
+++ b/libbindgen/tests/headers/public-dtor.hpp
@@ -0,0 +1,15 @@
+
+
+namespace cv {
+class String {
+public:
+ ~String();
+};
+
+
+inline
+String::~String()
+{
+}
+
+}