summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clang.rs13
-rw-r--r--src/codegen/mod.rs11
-rw-r--r--src/ir/context.rs57
-rw-r--r--src/ir/item.rs30
-rw-r--r--src/ir/ty.rs39
-rw-r--r--src/parse.rs5
-rw-r--r--tests/expectations/anon_enum.rs2
-rw-r--r--tests/expectations/anon_union.rs4
-rw-r--r--tests/expectations/blocks.rs9
-rw-r--r--tests/expectations/class_with_inner_struct.rs61
-rw-r--r--tests/expectations/func_ptr.rs7
-rw-r--r--tests/expectations/func_ptr_in_struct.rs6
-rw-r--r--tests/expectations/func_with_func_ptr_arg.rs2
-rw-r--r--tests/expectations/jsval_layout_opaque.rs38
-rw-r--r--tests/expectations/namespace.rs6
-rw-r--r--tests/expectations/struct_with_anon_struct_array.rs12
-rw-r--r--tests/expectations/struct_with_nesting.rs44
-rw-r--r--tests/expectations/template_typedefs.rs22
-rw-r--r--tests/expectations/typeref.rs4
-rw-r--r--tests/expectations/union_template.rs8
-rw-r--r--tests/expectations/union_with_anon_struct_bitfield.rs14
-rw-r--r--tests/expectations/union_with_anon_unnamed_struct.rs12
-rw-r--r--tests/expectations/union_with_anon_unnamed_union.rs12
-rw-r--r--tests/expectations/union_with_nesting.rs43
-rw-r--r--tests/expectations/what_is_going_on.rs5
-rw-r--r--tests/headers/blocks.h3
-rw-r--r--tests/headers/template_typedefs.hpp8
27 files changed, 280 insertions, 197 deletions
diff --git a/src/clang.rs b/src/clang.rs
index 5618007b..defdf547 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -17,14 +17,23 @@ pub struct Cursor {
impl fmt::Debug for Cursor {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "Cursor({} kind: {}, loc: {})",
- self.spelling(), kind_to_str(self.kind()), self.location())
+ write!(fmt, "Cursor({} kind: {}, loc: {}, usr: {:?})",
+ self.spelling(), kind_to_str(self.kind()), self.location(), self.usr())
}
}
pub type CursorVisitor<'s> = for<'a, 'b> FnMut(&'a Cursor, &'b Cursor) -> Enum_CXChildVisitResult + 's;
impl Cursor {
+ pub fn usr(&self) -> Option<String> {
+ let s = String_ { x: unsafe { clang_getCursorUSR(self.x) } }.to_string();
+ if s.is_empty() {
+ None
+ } else {
+ Some(s)
+ }
+ }
+
pub fn is_declaration(&self) -> bool {
unsafe { clang_isDeclaration(self.kind()) != 0 }
}
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 62cebf46..8d5f453f 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1380,7 +1380,16 @@ impl ToRustTy for Type {
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) => {
let inner = ctx.resolve_item(inner);
- inner.to_rust_ty(ctx).to_ptr(inner.expect_type().is_const(), ctx.span())
+ let inner_ty = inner.expect_type();
+ let ty = inner.to_rust_ty(ctx);
+
+ // Avoid the first function pointer level, since it's already
+ // represented in Rust.
+ if inner_ty.canonical_type(ctx).is_function() {
+ ty
+ } else {
+ ty.to_ptr(inner.expect_type().is_const(), ctx.span())
+ }
}
TypeKind::Named(..) => {
let name = item.canonical_name(ctx);
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 5ddedda0..4d5d88e4 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -33,11 +33,9 @@ pub struct BindgenContext<'ctx> {
/// output.
items: BTreeMap<ItemId, Item>,
- /// Clang cursor to type map. This is needed to be able to associate types
- /// with item ids during parsing.
- ///
- /// The cursor used for storage is the definition cursor.
- types: HashMap<Cursor, ItemId>,
+ /// Clang USR to type map. This is needed to be able to associate types with
+ /// item ids during parsing.
+ types: HashMap<String, ItemId>,
/// A cursor to module map. Similar reason than above.
modules: HashMap<Cursor, ItemId>,
@@ -135,17 +133,19 @@ impl<'ctx> BindgenContext<'ctx> {
assert!(old_item.is_none(), "Inserted type twice?");
if is_type && declaration.is_some() {
- let declaration = declaration.unwrap();
- debug_assert_eq!(declaration, declaration.canonical());
- if declaration.is_valid() {
- let old = self.types.insert(declaration, id);
- debug_assert_eq!(old, None);
- } else if location.is_some() &&
- (location.unwrap().kind() == CXCursor_ClassTemplate ||
- location.unwrap().kind() == CXCursor_ClassTemplatePartialSpecialization) {
- let old = self.types.insert(location.unwrap().canonical(), id);
- debug_assert_eq!(old, None);
- } else {
+ let mut declaration = declaration.unwrap();
+ if !declaration.is_valid() {
+ if let Some(location) = location {
+ if location.kind() == CXCursor_ClassTemplate ||
+ location.kind() == CXCursor_ClassTemplatePartialSpecialization {
+ declaration = location;
+ }
+ }
+ }
+ declaration = declaration.canonical();
+
+
+ if !declaration.is_valid() {
// This could happen, for example, with types like `int*` or
// similar.
//
@@ -153,6 +153,14 @@ impl<'ctx> BindgenContext<'ctx> {
// duplicated, so we can just ignore them.
debug!("Invalid declaration {:?} found for type {:?}",
declaration, self.items.get(&id).unwrap().kind().expect_type());
+ return;
+ }
+
+ if let Some(usr) = declaration.usr() {
+ let old = self.types.insert(usr, id);
+ debug_assert_eq!(old, None);
+ } else {
+ error!("Valid declaration with no USR: {:?}, {:?}", declaration, location);
}
}
}
@@ -206,7 +214,7 @@ impl<'ctx> BindgenContext<'ctx> {
self.collected_typerefs
}
- fn collect_typerefs(&mut self) -> Vec<(ItemId, clang::Type, Option<clang::Cursor>)> {
+ fn collect_typerefs(&mut self) -> Vec<(ItemId, clang::Type, Option<clang::Cursor>, Option<ItemId>)> {
debug_assert!(!self.collected_typerefs);
self.collected_typerefs = true;
let mut typerefs = vec![];
@@ -218,8 +226,8 @@ impl<'ctx> BindgenContext<'ctx> {
};
match *ty.kind() {
- TypeKind::UnresolvedTypeRef(ref ty, loc) => {
- typerefs.push((*id, ty.clone(), loc));
+ TypeKind::UnresolvedTypeRef(ref ty, loc, parent_id) => {
+ typerefs.push((*id, ty.clone(), loc, parent_id));
}
_ => {},
};
@@ -230,9 +238,9 @@ impl<'ctx> BindgenContext<'ctx> {
fn resolve_typerefs(&mut self) {
let typerefs = self.collect_typerefs();
- for (id, ty, loc) in typerefs {
+ for (id, ty, loc, parent_id) in typerefs {
let _resolved = {
- let resolved = Item::from_ty(&ty, loc, None, self)
+ let resolved = Item::from_ty(&ty, loc, parent_id, self)
.expect("What happened?");
let mut item = self.items.get_mut(&id).unwrap();
@@ -494,8 +502,11 @@ impl<'ctx> BindgenContext<'ctx> {
}
let canonical_declaration = declaration.canonical();
if canonical_declaration.is_valid() {
- // First lookup to see if we already have it resolved.
- let id = self.types.get(&canonical_declaration).map(|id| *id);
+ let id =
+ canonical_declaration
+ .usr()
+ .and_then(|usr| self.types.get(&usr))
+ .map(|id| *id);
if let Some(id) = id {
debug!("Already resolved ty {:?}, {:?}, {:?} {:?}",
id, declaration, ty, location);
diff --git a/src/ir/item.rs b/src/ir/item.rs
index c9ac71a4..75c3b857 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -191,10 +191,19 @@ impl Item {
TypeKind::Array(inner, _) |
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) |
- TypeKind::Alias(_, inner) |
TypeKind::ResolvedTypeRef(inner) => {
ctx.resolve_item(inner).applicable_template_args(ctx)
}
+ TypeKind::Alias(_, inner) => {
+ let parent_args = ctx.resolve_item(self.parent_id())
+ .applicable_template_args(ctx);
+ let inner = ctx.resolve_type(inner);
+ // Avoid unused type parameters, sigh.
+ parent_args.iter().cloned().filter(|arg| {
+ let arg = ctx.resolve_type(*arg);
+ arg.is_named() && inner.signature_contains_named_type(ctx, arg)
+ }).collect()
+ }
// XXX Is this completely correct? Partial template specialization
// is hard anyways, sigh...
TypeKind::TemplateRef(_, ref args) => {
@@ -436,11 +445,19 @@ impl ClangItemParser for Item {
location: Option<clang::Cursor>,
parent_id: Option<ItemId>,
context: &mut BindgenContext) -> ItemId {
- debug!("from_ty_or_ref: {:?}, {:?}, {:?}", ty, location, parent_id);
+ Self::from_ty_or_ref_with_id(ItemId::next(), ty, location, parent_id, context)
+ }
+
+ fn from_ty_or_ref_with_id(potential_id: ItemId,
+ ty: clang::Type,
+ location: Option<clang::Cursor>,
+ parent_id: Option<ItemId>,
+ context: &mut BindgenContext) -> ItemId {
+ debug!("from_ty_or_ref_with_id: {:?} {:?}, {:?}, {:?}", potential_id, ty, location, parent_id);
if context.collected_typerefs() {
debug!("refs already collected, resolving directly");
- return Self::from_ty(&ty, location, parent_id, context)
+ return Self::from_ty_with_id(potential_id, &ty, location, parent_id, context)
.expect("Unable to resolve type");
}
@@ -452,15 +469,14 @@ impl ClangItemParser for Item {
debug!("New unresolved type reference: {:?}, {:?}", ty, location);
let is_const = ty.is_const();
- let kind = TypeKind::UnresolvedTypeRef(ty, location);
- let id = ItemId::next();
+ let kind = TypeKind::UnresolvedTypeRef(ty, location, parent_id);
let current_module = context.current_module();
- context.add_item(Item::new(id, None, None,
+ context.add_item(Item::new(potential_id, None, None,
parent_id.unwrap_or(current_module),
ItemKind::Type(Type::new(None, None, kind, is_const))),
Some(clang::Cursor::null()),
None);
- id
+ potential_id
}
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b0448437..b0bf9bf6 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -75,6 +75,13 @@ impl Type {
}
}
+ pub fn is_function(&self) -> bool {
+ match self.kind {
+ TypeKind::Function(..) => true,
+ _ => false,
+ }
+ }
+
pub fn is_builtin_or_named(&self) -> bool {
match self.kind {
TypeKind::Void |
@@ -243,9 +250,18 @@ impl Type {
=> this_name == name,
TypeKind::ResolvedTypeRef(t) |
TypeKind::Array(t, _) |
- TypeKind::Pointer(t)
+ TypeKind::Pointer(t) |
+ TypeKind::Alias(_, t)
=> type_resolver.resolve_type(t)
.signature_contains_named_type(type_resolver, ty),
+ TypeKind::Function(ref sig) => {
+ sig.argument_types().iter().any(|&(_, arg)| {
+ type_resolver.resolve_type(arg)
+ .signature_contains_named_type(type_resolver, ty)
+ }) ||
+ type_resolver.resolve_type(sig.return_type())
+ .signature_contains_named_type(type_resolver, ty)
+ },
TypeKind::TemplateRef(_inner, ref template_args) => {
template_args.iter().any(|arg| {
type_resolver.resolve_type(*arg)
@@ -332,7 +348,7 @@ pub enum TypeKind {
/// already known types, and are converted to ResolvedTypeRef.
///
/// see tests/headers/typeref.hpp to see somewhere where this is a problem.
- UnresolvedTypeRef(clang::Type, Option<clang::Cursor>),
+ UnresolvedTypeRef(clang::Type, Option<clang::Cursor>, /* parent_id */ Option<ItemId>),
ResolvedTypeRef(ItemId),
/// A named type, that is, a template parameter, with an optional default
@@ -427,18 +443,18 @@ impl Type {
let referenced = location.referenced();
return Self::from_clang_ty(potential_id,
&referenced.cur_type(),
- Some(referenced),
+ Some(referenced.cur_type().declaration()),
parent_id,
ctx);
}
CXCursor_TypeRef => {
let referenced = location.referenced();
- // FIXME: use potential id?
return Ok(ParseResult::AlreadyResolved(
- Item::from_ty_or_ref(referenced.cur_type(),
- Some(referenced),
- parent_id,
- ctx)));
+ Item::from_ty_or_ref_with_id(potential_id,
+ referenced.cur_type(),
+ Some(referenced.cur_type().declaration()),
+ parent_id,
+ ctx)));
}
_ => {
if ty.kind() == CXType_Unexposed {
@@ -469,9 +485,11 @@ impl Type {
// We might need to, though, if the context is already in the
// process of resolving them.
CXType_MemberPointer |
+ CXType_BlockPointer |
CXType_Pointer => {
let inner =
- Item::from_ty_or_ref(ty.pointee_type(), Some(ty.pointee_type().declaration()), parent_id, ctx);
+ Item::from_ty_or_ref(ty.pointee_type(), location,
+ parent_id, ctx);
TypeKind::Pointer(inner)
}
// XXX: RValueReference is most likely wrong, but I don't think we
@@ -479,7 +497,8 @@ impl Type {
CXType_RValueReference |
CXType_LValueReference => {
let inner =
- Item::from_ty_or_ref(ty.pointee_type(), Some(ty.pointee_type().declaration()), parent_id, ctx);
+ Item::from_ty_or_ref(ty.pointee_type(), location,
+ parent_id, ctx);
TypeKind::Reference(inner)
}
// XXX DependentSizedArray is wrong
diff --git a/src/parse.rs b/src/parse.rs
index 39d2644a..d6c36aa4 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -29,6 +29,11 @@ pub trait ClangItemParser: Sized {
location: Option<clang::Cursor>,
parent_id: Option<ItemId>,
context: &mut BindgenContext) -> ItemId;
+ fn from_ty_or_ref_with_id(potential_id: ItemId,
+ ty: clang::Type,
+ location: Option<clang::Cursor>,
+ parent_id: Option<ItemId>,
+ context: &mut BindgenContext) -> ItemId;
fn from_ty_with_id(id: ItemId,
ty: &clang::Type,
location: Option<clang::Cursor>,
diff --git a/tests/expectations/anon_enum.rs b/tests/expectations/anon_enum.rs
index 6b8688e1..b06585b1 100644
--- a/tests/expectations/anon_enum.rs
+++ b/tests/expectations/anon_enum.rs
@@ -12,7 +12,7 @@ pub struct Test {
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum Test__bindgen_ty_bindgen_id_4 { T_NONE = 0, }
+pub enum Test__bindgen_ty_bindgen_id_6 { T_NONE = 0, }
#[test]
fn bindgen_test_layout_Test() {
assert_eq!(::std::mem::size_of::<Test>() , 8usize);
diff --git a/tests/expectations/anon_union.rs b/tests/expectations/anon_union.rs
index 66963f40..731d1dd9 100644
--- a/tests/expectations/anon_union.rs
+++ b/tests/expectations/anon_union.rs
@@ -28,7 +28,7 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy, Clone)]
pub struct TErrorResult<T> {
pub mResult: ::std::os::raw::c_int,
- pub __bindgen_anon_1: TErrorResult__bindgen_ty_bindgen_id_9<T>,
+ pub __bindgen_anon_1: TErrorResult__bindgen_ty_bindgen_id_10<T>,
pub mMightHaveUnreported: bool,
pub mUnionState: TErrorResult_UnionState,
pub _phantom_0: ::std::marker::PhantomData<T>,
@@ -52,7 +52,7 @@ pub struct TErrorResult_DOMExceptionInfo<T> {
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct TErrorResult__bindgen_ty_bindgen_id_9<T> {
+pub struct TErrorResult__bindgen_ty_bindgen_id_10<T> {
pub mMessage: __BindgenUnionField<*mut TErrorResult_Message<T>>,
pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo<T>>,
pub bindgen_union_field: u64,
diff --git a/tests/expectations/blocks.rs b/tests/expectations/blocks.rs
new file mode 100644
index 00000000..88a797e2
--- /dev/null
+++ b/tests/expectations/blocks.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn atexit_b(arg1: ::std::option::Option<unsafe extern "C" fn()>);
+}
diff --git a/tests/expectations/class_with_inner_struct.rs b/tests/expectations/class_with_inner_struct.rs
index 464c622d..98c0505a 100644
--- a/tests/expectations/class_with_inner_struct.rs
+++ b/tests/expectations/class_with_inner_struct.rs
@@ -28,8 +28,8 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct A {
pub c: ::std::os::raw::c_uint,
- pub named_union: A__bindgen_ty_bindgen_id_6,
- pub __bindgen_anon_1: A__bindgen_ty_bindgen_id_9,
+ pub named_union: A__bindgen_ty_bindgen_id_9,
+ pub __bindgen_anon_1: A__bindgen_ty_bindgen_id_14,
}
#[repr(C)]
#[derive(Debug, Copy)]
@@ -47,30 +47,31 @@ impl Clone for A_Segment {
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct A__bindgen_ty_bindgen_id_6 {
+pub struct A__bindgen_ty_bindgen_id_9 {
pub f: __BindgenUnionField<::std::os::raw::c_int>,
pub bindgen_union_field: u32,
}
#[test]
-fn bindgen_test_layout_A__bindgen_ty_bindgen_id_6() {
- assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_6>() , 4usize);
- assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_6>() , 4usize);
+fn bindgen_test_layout_A__bindgen_ty_bindgen_id_9() {
+ assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_9>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_9>() , 4usize);
}
-impl Clone for A__bindgen_ty_bindgen_id_6 {
+impl Clone for A__bindgen_ty_bindgen_id_9 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct A__bindgen_ty_bindgen_id_9 {
+pub struct A__bindgen_ty_bindgen_id_14 {
pub d: __BindgenUnionField<::std::os::raw::c_int>,
pub bindgen_union_field: u32,
}
#[test]
-fn bindgen_test_layout_A__bindgen_ty_bindgen_id_9() {
- assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_9>() , 4usize);
- assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_9>() , 4usize);
+fn bindgen_test_layout_A__bindgen_ty_bindgen_id_14() {
+ assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_14>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_14>() ,
+ 4usize);
}
-impl Clone for A__bindgen_ty_bindgen_id_9 {
+impl Clone for A__bindgen_ty_bindgen_id_14 {
fn clone(&self) -> Self { *self }
}
#[test]
@@ -120,57 +121,57 @@ pub enum StepSyntax {
#[derive(Debug, Copy)]
pub struct C {
pub d: ::std::os::raw::c_uint,
- pub __bindgen_anon_1: C__bindgen_ty_bindgen_id_21,
+ pub __bindgen_anon_1: C__bindgen_ty_bindgen_id_31,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct C__bindgen_ty_bindgen_id_21 {
- pub mFunc: __BindgenUnionField<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>,
- pub __bindgen_anon_1: __BindgenUnionField<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>,
+pub struct C__bindgen_ty_bindgen_id_31 {
+ pub mFunc: __BindgenUnionField<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32>,
+ pub __bindgen_anon_1: __BindgenUnionField<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43>,
pub bindgen_union_field: [u32; 4usize],
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22 {
+pub struct C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32 {
pub mX1: f32,
pub mY1: f32,
pub mX2: f32,
pub mY2: f32,
}
#[test]
-fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22() {
- assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>()
+fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32>()
, 16usize);
- assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>()
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32>()
, 4usize);
}
-impl Clone for C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22 {
+impl Clone for C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28 {
+pub struct C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43 {
pub mStepSyntax: StepSyntax,
pub mSteps: ::std::os::raw::c_uint,
}
#[test]
-fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28() {
- assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>()
+fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43>()
, 8usize);
- assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>()
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43>()
, 4usize);
}
-impl Clone for C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28 {
+impl Clone for C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43 {
fn clone(&self) -> Self { *self }
}
#[test]
-fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21() {
- assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21>() ,
+fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_31>() ,
16usize);
- assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21>() ,
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_31>() ,
4usize);
}
-impl Clone for C__bindgen_ty_bindgen_id_21 {
+impl Clone for C__bindgen_ty_bindgen_id_31 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
diff --git a/tests/expectations/func_ptr.rs b/tests/expectations/func_ptr.rs
index c62e532d..87ec3e3d 100644
--- a/tests/expectations/func_ptr.rs
+++ b/tests/expectations/func_ptr.rs
@@ -7,6 +7,9 @@
extern "C" {
#[link_name = "foo"]
pub static mut foo:
- *mut ::std::option::Option<unsafe extern "C" fn()
- -> ::std::os::raw::c_int>;
+ ::std::option::Option<unsafe extern "C" fn(x:
+ ::std::os::raw::c_int,
+ y:
+ ::std::os::raw::c_int)
+ -> ::std::os::raw::c_int>;
}
diff --git a/tests/expectations/func_ptr_in_struct.rs b/tests/expectations/func_ptr_in_struct.rs
index 0d4ccdbf..dcae771b 100644
--- a/tests/expectations/func_ptr_in_struct.rs
+++ b/tests/expectations/func_ptr_in_struct.rs
@@ -9,7 +9,11 @@ pub enum baz { }
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Foo {
- pub bar: *mut ::std::option::Option<unsafe extern "C" fn() -> baz>,
+ pub bar: ::std::option::Option<unsafe extern "C" fn(x:
+ ::std::os::raw::c_int,
+ y:
+ ::std::os::raw::c_int)
+ -> baz>,
}
#[test]
fn bindgen_test_layout_Foo() {
diff --git a/tests/expectations/func_with_func_ptr_arg.rs b/tests/expectations/func_with_func_ptr_arg.rs
index b6e345f6..4ac25286 100644
--- a/tests/expectations/func_with_func_ptr_arg.rs
+++ b/tests/expectations/func_with_func_ptr_arg.rs
@@ -5,5 +5,5 @@
extern "C" {
- pub fn foo(bar: *mut ::std::option::Option<unsafe extern "C" fn()>);
+ pub fn foo(bar: ::std::option::Option<unsafe extern "C" fn()>);
}
diff --git a/tests/expectations/jsval_layout_opaque.rs b/tests/expectations/jsval_layout_opaque.rs
index 69fe54dc..dd432232 100644
--- a/tests/expectations/jsval_layout_opaque.rs
+++ b/tests/expectations/jsval_layout_opaque.rs
@@ -93,8 +93,8 @@ pub enum JSWhyMagic {
#[derive(Debug, Copy)]
pub struct jsval_layout {
pub asBits: __BindgenUnionField<u64>,
- pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_81>,
- pub s: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_85>,
+ pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_89>,
+ pub s: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_96>,
pub asDouble: __BindgenUnionField<f64>,
pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>,
pub asWord: __BindgenUnionField<usize>,
@@ -103,20 +103,20 @@ pub struct jsval_layout {
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct jsval_layout__bindgen_ty_bindgen_id_81 {
+pub struct jsval_layout__bindgen_ty_bindgen_id_89 {
pub _bitfield_1: u64,
}
#[test]
-fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_81() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_81>()
+fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_89() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_89>()
, 8usize);
- assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_81>()
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_89>()
, 8usize);
}
-impl Clone for jsval_layout__bindgen_ty_bindgen_id_81 {
+impl Clone for jsval_layout__bindgen_ty_bindgen_id_89 {
fn clone(&self) -> Self { *self }
}
-impl jsval_layout__bindgen_ty_bindgen_id_81 {
+impl jsval_layout__bindgen_ty_bindgen_id_89 {
#[inline]
pub fn payload47(&self) -> u64 {
unsafe {
@@ -149,36 +149,36 @@ impl jsval_layout__bindgen_ty_bindgen_id_81 {
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct jsval_layout__bindgen_ty_bindgen_id_85 {
- pub payload: jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86,
+pub struct jsval_layout__bindgen_ty_bindgen_id_96 {
+ pub payload: jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86 {
+pub struct jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97 {
pub i32: __BindgenUnionField<i32>,
pub u32: __BindgenUnionField<u32>,
pub why: __BindgenUnionField<JSWhyMagic>,
pub bindgen_union_field: u32,
}
#[test]
-fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86>()
+fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97>()
, 4usize);
- assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86>()
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97>()
, 4usize);
}
impl Clone for
- jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86 {
+ jsval_layout__bindgen_ty_bindgen_id_96__bindgen_ty_bindgen_id_97 {
fn clone(&self) -> Self { *self }
}
#[test]
-fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_85() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_85>()
+fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_96() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_96>()
, 4usize);
- assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_85>()
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_96>()
, 4usize);
}
-impl Clone for jsval_layout__bindgen_ty_bindgen_id_85 {
+impl Clone for jsval_layout__bindgen_ty_bindgen_id_96 {
fn clone(&self) -> Self { *self }
}
impl Clone for jsval_layout {
diff --git a/tests/expectations/namespace.rs b/tests/expectations/namespace.rs
index 0bd6e8e0..ed0ca603 100644
--- a/tests/expectations/namespace.rs
+++ b/tests/expectations/namespace.rs
@@ -18,7 +18,7 @@ pub mod root {
pub fn in_whatever();
}
}
- pub mod _bindgen_mod_bindgen_id_12 {
+ pub mod _bindgen_mod_bindgen_id_13 {
use root;
pub mod empty {
use root;
@@ -44,7 +44,7 @@ pub mod root {
#[repr(C)]
#[derive(Debug)]
pub struct C<T> {
- pub _base: root::_bindgen_mod_bindgen_id_12::A,
+ pub _base: root::_bindgen_mod_bindgen_id_13::A,
pub m_c: T,
pub m_c_ptr: *mut T,
pub m_c_arr: [T; 10usize],
@@ -78,7 +78,7 @@ extern "C" {
#[repr(C)]
#[derive(Debug)]
pub struct C<T> {
- pub _base: root::_bindgen_mod_bindgen_id_12::A,
+ pub _base: root::_bindgen_mod_bindgen_id_13::A,
pub m_c: T,
pub m_c_ptr: *mut T,
pub m_c_arr: [T; 10usize],
diff --git a/tests/expectations/struct_with_anon_struct_array.rs b/tests/expectations/struct_with_anon_struct_array.rs
index 48cc71d2..c87605de 100644
--- a/tests/expectations/struct_with_anon_struct_array.rs
+++ b/tests/expectations/struct_with_anon_struct_array.rs
@@ -8,7 +8,7 @@
#[derive(Debug, Copy)]
pub struct foo {
pub bar: [foo__bindgen_ty_bindgen_id_2; 2usize],
- pub baz: [[[foo__bindgen_ty_bindgen_id_6; 4usize]; 3usize]; 2usize],
+ pub baz: [[[foo__bindgen_ty_bindgen_id_8; 4usize]; 3usize]; 2usize],
}
#[repr(C)]
#[derive(Debug, Copy)]
@@ -28,18 +28,18 @@ impl Clone for foo__bindgen_ty_bindgen_id_2 {
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_6 {
+pub struct foo__bindgen_ty_bindgen_id_8 {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_6() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_6>() ,
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_8() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_8>() ,
8usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_6>() ,
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_8>() ,
4usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_6 {
+impl Clone for foo__bindgen_ty_bindgen_id_8 {
fn clone(&self) -> Self { *self }
}
#[test]
diff --git a/tests/expectations/struct_with_nesting.rs b/tests/expectations/struct_with_nesting.rs
index ca5ec09e..75cfecec 100644
--- a/tests/expectations/struct_with_nesting.rs
+++ b/tests/expectations/struct_with_nesting.rs
@@ -28,58 +28,40 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct foo {
pub a: ::std::os::raw::c_uint,
- pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_3,
+ pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_4,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3 {
+pub struct foo__bindgen_ty_bindgen_id_4 {
pub b: __BindgenUnionField<::std::os::raw::c_uint>,
- pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>,
- pub __bindgen_anon_2: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7>,
+ pub __bindgen_anon_2: __BindgenUnionField<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7>,
pub bindgen_union_field: u32,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5 {
+pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7 {
pub c1: ::std::os::raw::c_ushort,
pub c2: ::std::os::raw::c_ushort,
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>()
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7>()
, 4usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>()
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7>()
, 2usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5 {
- fn clone(&self) -> Self { *self }
-}
-#[repr(C)]
-#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8 {
- pub d1: ::std::os::raw::c_uchar,
- pub d2: ::std::os::raw::c_uchar,
- pub d3: ::std::os::raw::c_uchar,
- pub d4: ::std::os::raw::c_uchar,
-}
-#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>()
- , 4usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>()
- , 1usize);
-}
-impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8 {
+impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7 {
fn clone(&self) -> Self { *self }
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() ,
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4>() ,
4usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() ,
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4>() ,
4usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3 {
+impl Clone for foo__bindgen_ty_bindgen_id_4 {
fn clone(&self) -> Self { *self }
}
#[test]
diff --git a/tests/expectations/template_typedefs.rs b/tests/expectations/template_typedefs.rs
new file mode 100644
index 00000000..5f0d80b9
--- /dev/null
+++ b/tests/expectations/template_typedefs.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type foo =
+ ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int)>;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Foo<T, U> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+ pub _phantom_1: ::std::marker::PhantomData<U>,
+}
+pub type Foo_Char<T> = T;
+pub type Foo_FooPtrTypedef<T> = *mut Foo_Char<T>;
+pub type Foo_nsCOMArrayEnumFunc<T> =
+ ::std::option::Option<unsafe extern "C" fn(aElement: *mut T,
+ aData:
+ *mut ::std::os::raw::c_void)
+ -> bool>;
diff --git a/tests/expectations/typeref.rs b/tests/expectations/typeref.rs
index 35a873c9..50795077 100644
--- a/tests/expectations/typeref.rs
+++ b/tests/expectations/typeref.rs
@@ -79,12 +79,12 @@ impl Clone for Bar {
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct StyleShapeSource<ReferenceBox> {
- pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_bindgen_id_13<ReferenceBox>,
+ pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_bindgen_id_14<ReferenceBox>,
pub _phantom_0: ::std::marker::PhantomData<ReferenceBox>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct StyleShapeSource__bindgen_ty_bindgen_id_13<ReferenceBox> {
+pub struct StyleShapeSource__bindgen_ty_bindgen_id_14<ReferenceBox> {
pub mPosition: __BindgenUnionField<*mut Position>,
pub mFragmentOrURL: __BindgenUnionField<*mut FragmentOrURL>,
pub bindgen_union_field: u64,
diff --git a/tests/expectations/union_template.rs b/tests/expectations/union_template.rs
index f07087de..1e3cf17e 100644
--- a/tests/expectations/union_template.rs
+++ b/tests/expectations/union_template.rs
@@ -28,13 +28,13 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy, Clone)]
pub struct NastyStruct<T> {
pub mIsSome: bool,
- pub mStorage: NastyStruct__bindgen_ty_bindgen_id_5<T>,
- pub __bindgen_anon_1: NastyStruct__bindgen_ty_bindgen_id_9<T>,
+ pub mStorage: NastyStruct__bindgen_ty_bindgen_id_6<T>,
+ pub __bindgen_anon_1: NastyStruct__bindgen_ty_bindgen_id_12<T>,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct NastyStruct__bindgen_ty_bindgen_id_5<T> {
+pub struct NastyStruct__bindgen_ty_bindgen_id_6<T> {
pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>,
pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>,
pub bindgen_union_field: u64,
@@ -42,7 +42,7 @@ pub struct NastyStruct__bindgen_ty_bindgen_id_5<T> {
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct NastyStruct__bindgen_ty_bindgen_id_9<T> {
+pub struct NastyStruct__bindgen_ty_bindgen_id_12<T> {
pub wat: __BindgenUnionField<::std::os::raw::c_short>,
pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>,
pub bindgen_union_field: u64,
diff --git a/tests/expectations/union_with_anon_struct_bitfield.rs b/tests/expectations/union_with_anon_struct_bitfield.rs
index 80be0e55..1332d92e 100644
--- a/tests/expectations/union_with_anon_struct_bitfield.rs
+++ b/tests/expectations/union_with_anon_struct_bitfield.rs
@@ -28,25 +28,25 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct foo {
pub a: __BindgenUnionField<::std::os::raw::c_int>,
- pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_4>,
pub bindgen_union_field: u32,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3 {
+pub struct foo__bindgen_ty_bindgen_id_4 {
pub _bitfield_1: u32,
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() ,
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4>() ,
4usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() ,
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4>() ,
4usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3 {
+impl Clone for foo__bindgen_ty_bindgen_id_4 {
fn clone(&self) -> Self { *self }
}
-impl foo__bindgen_ty_bindgen_id_3 {
+impl foo__bindgen_ty_bindgen_id_4 {
#[inline]
pub fn b(&self) -> ::std::os::raw::c_int {
unsafe {
diff --git a/tests/expectations/union_with_anon_unnamed_struct.rs b/tests/expectations/union_with_anon_unnamed_struct.rs
index 80b3e97a..defbe66b 100644
--- a/tests/expectations/union_with_anon_unnamed_struct.rs
+++ b/tests/expectations/union_with_anon_unnamed_struct.rs
@@ -28,25 +28,25 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct pixel {
pub rgba: __BindgenUnionField<::std::os::raw::c_uint>,
- pub __bindgen_anon_1: __BindgenUnionField<pixel__bindgen_ty_bindgen_id_3>,
+ pub __bindgen_anon_1: __BindgenUnionField<pixel__bindgen_ty_bindgen_id_4>,
pub bindgen_union_field: u32,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct pixel__bindgen_ty_bindgen_id_3 {
+pub struct pixel__bindgen_ty_bindgen_id_4 {
pub r: ::std::os::raw::c_uchar,
pub g: ::std::os::raw::c_uchar,
pub b: ::std::os::raw::c_uchar,
pub a: ::std::os::raw::c_uchar,
}
#[test]
-fn bindgen_test_layout_pixel__bindgen_ty_bindgen_id_3() {
- assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_bindgen_id_3>() ,
+fn bindgen_test_layout_pixel__bindgen_ty_bindgen_id_4() {
+ assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_bindgen_id_4>() ,
4usize);
- assert_eq!(::std::mem::align_of::<pixel__bindgen_ty_bindgen_id_3>() ,
+ assert_eq!(::std::mem::align_of::<pixel__bindgen_ty_bindgen_id_4>() ,
1usize);
}
-impl Clone for pixel__bindgen_ty_bindgen_id_3 {
+impl Clone for pixel__bindgen_ty_bindgen_id_4 {
fn clone(&self) -> Self { *self }
}
#[test]
diff --git a/tests/expectations/union_with_anon_unnamed_union.rs b/tests/expectations/union_with_anon_unnamed_union.rs
index 3ddea69e..519bf619 100644
--- a/tests/expectations/union_with_anon_unnamed_union.rs
+++ b/tests/expectations/union_with_anon_unnamed_union.rs
@@ -28,24 +28,24 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct foo {
pub a: __BindgenUnionField<::std::os::raw::c_uint>,
- pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_4>,
pub bindgen_union_field: u32,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3 {
+pub struct foo__bindgen_ty_bindgen_id_4 {
pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
pub c: __BindgenUnionField<::std::os::raw::c_uchar>,
pub bindgen_union_field: u16,
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() ,
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4>() ,
2usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() ,
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4>() ,
2usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3 {
+impl Clone for foo__bindgen_ty_bindgen_id_4 {
fn clone(&self) -> Self { *self }
}
#[test]
diff --git a/tests/expectations/union_with_nesting.rs b/tests/expectations/union_with_nesting.rs
index 6b8d318d..7534cf81 100644
--- a/tests/expectations/union_with_nesting.rs
+++ b/tests/expectations/union_with_nesting.rs
@@ -28,57 +28,40 @@ impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
#[derive(Debug, Copy)]
pub struct foo {
pub a: __BindgenUnionField<::std::os::raw::c_uint>,
- pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_4>,
pub bindgen_union_field: u32,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3 {
- pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4,
- pub __bindgen_anon_2: foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7,
+pub struct foo__bindgen_ty_bindgen_id_4 {
+ pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5,
+ pub __bindgen_anon_2: foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5,
}
#[repr(C)]
#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4 {
+pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5 {
pub b1: __BindgenUnionField<::std::os::raw::c_ushort>,
pub b2: __BindgenUnionField<::std::os::raw::c_ushort>,
pub bindgen_union_field: u16,
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4>()
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5>()
, 2usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4>()
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5>()
, 2usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4 {
- fn clone(&self) -> Self { *self }
-}
-#[repr(C)]
-#[derive(Debug, Copy)]
-pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7 {
- pub c1: __BindgenUnionField<::std::os::raw::c_ushort>,
- pub c2: __BindgenUnionField<::std::os::raw::c_ushort>,
- pub bindgen_union_field: u16,
-}
-#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7>()
- , 2usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7>()
- , 2usize);
-}
-impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7 {
+impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5 {
fn clone(&self) -> Self { *self }
}
#[test]
-fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() ,
+fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_4>() ,
4usize);
- assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() ,
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_4>() ,
2usize);
}
-impl Clone for foo__bindgen_ty_bindgen_id_3 {
+impl Clone for foo__bindgen_ty_bindgen_id_4 {
fn clone(&self) -> Self { *self }
}
#[test]
diff --git a/tests/expectations/what_is_going_on.rs b/tests/expectations/what_is_going_on.rs
index b6a5c86a..6f1998d1 100644
--- a/tests/expectations/what_is_going_on.rs
+++ b/tests/expectations/what_is_going_on.rs
@@ -21,9 +21,8 @@ pub type Float = f32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct PointTyped<units, F> {
- pub x: Float,
- pub y: Float,
+ pub x: F,
+ pub y: F,
pub _phantom_0: ::std::marker::PhantomData<units>,
- pub _phantom_1: ::std::marker::PhantomData<F>,
}
pub type IntPoint = PointTyped<UnknownUnits, f32>;
diff --git a/tests/headers/blocks.h b/tests/headers/blocks.h
new file mode 100644
index 00000000..80420e6e
--- /dev/null
+++ b/tests/headers/blocks.h
@@ -0,0 +1,3 @@
+// bindgen-flags: -- -fblocks
+
+void atexit_b(void (^)(void));
diff --git a/tests/headers/template_typedefs.hpp b/tests/headers/template_typedefs.hpp
new file mode 100644
index 00000000..5e13dcd8
--- /dev/null
+++ b/tests/headers/template_typedefs.hpp
@@ -0,0 +1,8 @@
+typedef void (*foo)(int);
+
+template<typename T, typename U>
+class Foo {
+ typedef T Char;
+ typedef Char* FooPtrTypedef;
+ typedef bool (*nsCOMArrayEnumFunc)(T* aElement, void* aData);
+};