summaryrefslogtreecommitdiff
path: root/libbindgen/tests
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-01-11 13:12:59 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-01-11 13:12:59 +0100
commit66447ff277181073d14bb04c7947eec805cd0623 (patch)
tree8155da9285d21e72a8510cdb0428d7763c0f566a /libbindgen/tests
parent2ad1b52277c960ffab05573a0ff6a30a3fa1d617 (diff)
Test opaque tracing through function arguments and pointer types.
Diffstat (limited to 'libbindgen/tests')
-rw-r--r--libbindgen/tests/expectations/tests/opaque-tracing.rs23
-rw-r--r--libbindgen/tests/headers/opaque-tracing.hpp21
2 files changed, 44 insertions, 0 deletions
diff --git a/libbindgen/tests/expectations/tests/opaque-tracing.rs b/libbindgen/tests/expectations/tests/opaque-tracing.rs
new file mode 100644
index 00000000..7dcc4eef
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/opaque-tracing.rs
@@ -0,0 +1,23 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Container {
+ pub _bindgen_opaque_blob: [u32; 2usize],
+}
+#[test]
+fn bindgen_test_layout_Container() {
+ assert_eq!(::std::mem::size_of::<Container>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Container>() , 4usize);
+}
+impl Clone for Container {
+ fn clone(&self) -> Self { *self }
+}
+extern "C" {
+ #[link_name = "_Z3fooP9Container"]
+ pub fn foo(c: *mut Container);
+}
diff --git a/libbindgen/tests/headers/opaque-tracing.hpp b/libbindgen/tests/headers/opaque-tracing.hpp
new file mode 100644
index 00000000..7356245e
--- /dev/null
+++ b/libbindgen/tests/headers/opaque-tracing.hpp
@@ -0,0 +1,21 @@
+// bindgen-flags: --opaque-type=.* --whitelist-function=foo
+
+class Container;
+
+// The whitelist tracing should reach the Container type, even though it's
+// marked as opaque.
+void foo(Container* c);
+
+template<typename T>
+class Wat {
+ T foo;
+};
+
+class OtherOpaque {
+ int bar;
+};
+
+class Container {
+ Wat<int> bar;
+ OtherOpaque baz;
+};