diff options
-rw-r--r-- | src/ir/ty.rs | 7 | ||||
-rw-r--r-- | tests/expectations/complex.rs | 84 | ||||
-rw-r--r-- | tests/headers/complex.h | 13 |
3 files changed, 104 insertions, 0 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs index d74b1a0e..bf45b9fc 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -631,6 +631,13 @@ impl Type { .expect("Not able to resolve array element?"); TypeKind::Array(inner, ty.num_elements()) } + // A complex number is always a real and an imaginary part, so + // represent that as a two-item array. + CXType_Complex => { + let inner = Item::from_ty(&ty.elem_type(), location, parent_id, ctx) + .expect("Not able to resolve array element?"); + TypeKind::Array(inner, 2) + } #[cfg(not(feature="llvm_stable"))] CXType_Elaborated => { return Self::from_clang_ty(potential_id, &ty.named(), diff --git a/tests/expectations/complex.rs b/tests/expectations/complex.rs new file mode 100644 index 00000000..e11a049e --- /dev/null +++ b/tests/expectations/complex.rs @@ -0,0 +1,84 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Testdouble { + pub mMember: [f64; 2usize], +} +#[test] +fn bindgen_test_layout_Testdouble() { + assert_eq!(::std::mem::size_of::<Testdouble>() , 16usize); + assert_eq!(::std::mem::align_of::<Testdouble>() , 8usize); +} +impl Clone for Testdouble { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct TestdoublePtr { + pub mMember: *mut [f64; 2usize], +} +#[test] +fn bindgen_test_layout_TestdoublePtr() { + assert_eq!(::std::mem::size_of::<TestdoublePtr>() , 8usize); + assert_eq!(::std::mem::align_of::<TestdoublePtr>() , 8usize); +} +impl Clone for TestdoublePtr { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Testfloat { + pub mMember: [f32; 2usize], +} +#[test] +fn bindgen_test_layout_Testfloat() { + assert_eq!(::std::mem::size_of::<Testfloat>() , 8usize); + assert_eq!(::std::mem::align_of::<Testfloat>() , 4usize); +} +impl Clone for Testfloat { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct TestfloatPtr { + pub mMember: *mut [f32; 2usize], +} +#[test] +fn bindgen_test_layout_TestfloatPtr() { + assert_eq!(::std::mem::size_of::<TestfloatPtr>() , 8usize); + assert_eq!(::std::mem::align_of::<TestfloatPtr>() , 8usize); +} +impl Clone for TestfloatPtr { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Testint { + pub mMember: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout_Testint() { + assert_eq!(::std::mem::size_of::<Testint>() , 8usize); + assert_eq!(::std::mem::align_of::<Testint>() , 4usize); +} +impl Clone for Testint { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct TestintPtr { + pub mMember: *mut [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout_TestintPtr() { + assert_eq!(::std::mem::size_of::<TestintPtr>() , 8usize); + assert_eq!(::std::mem::align_of::<TestintPtr>() , 8usize); +} +impl Clone for TestintPtr { + fn clone(&self) -> Self { *self } +} diff --git a/tests/headers/complex.h b/tests/headers/complex.h new file mode 100644 index 00000000..ad7af59f --- /dev/null +++ b/tests/headers/complex.h @@ -0,0 +1,13 @@ + +#define COMPLEX_TEST(ty_) \ + struct Test##ty_ { \ + ty_ _Complex mMember; \ + \ + }; \ + struct Test##ty_##Ptr { \ + ty_ _Complex* mMember; \ + }; + +COMPLEX_TEST(double) +COMPLEX_TEST(float) +COMPLEX_TEST(int) |