Skip to content

Commit

Permalink
Added test for forward declared complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilshagri committed Jan 26, 2017
1 parent 8eb9e3f commit 78aaa32
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/expectations/tests/forward_declared_complex_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
#[derive(Debug, Copy)]
pub struct Foo_empty {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Foo_empty() {
assert_eq!(::std::mem::size_of::<Foo_empty>() , 1usize);
assert_eq!(::std::mem::align_of::<Foo_empty>() , 1usize);
}
impl Clone for Foo_empty {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
pub struct Foo([u8; 0]);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Bar {
pub f: *mut Foo,
}
#[test]
fn bindgen_test_layout_Bar() {
assert_eq!(::std::mem::size_of::<Bar>() , 8usize);
assert_eq!(::std::mem::align_of::<Bar>() , 8usize);
}
impl Clone for Bar {
fn clone(&self) -> Self { *self }
}
extern "C" {
#[link_name = "_Z10baz_structP3Foo"]
pub fn baz_struct(f: *mut Foo);
}
#[repr(C)]
pub struct Union([u8; 0]);
extern "C" {
#[link_name = "_Z9baz_unionP5Union"]
pub fn baz_union(u: *mut Union);
}
#[repr(C)]
pub struct Quux([u8; 0]);
extern "C" {
#[link_name = "_Z9baz_classP4Quux"]
pub fn baz_class(q: *mut Quux);
}
16 changes: 16 additions & 0 deletions tests/headers/forward_declared_complex_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
struct Foo_empty {};
struct Foo;

struct Bar {
Foo *f;
};

void baz_struct(Foo* f);

union Union;

void baz_union(Union* u);

class Quux;

void baz_class(Quux* q);

0 comments on commit 78aaa32

Please sign in to comment.