diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gen.rs | 13 | ||||
-rw-r--r-- | src/parser.rs | 2 | ||||
-rw-r--r-- | src/types.rs | 6 |
3 files changed, 20 insertions, 1 deletions
@@ -376,7 +376,14 @@ fn gen_mod(mut ctx: &mut GenCtx, } } +// XXX: Replace the name-based lookup, or do it at parse-time, +// to keep all the mess in the same place. fn type_opaque(ctx: &GenCtx, ty: &Type) -> bool { + match *ty { + TComp(ref ci) if ci.borrow().opaque => return true, + _ => {} + } + let ty_name = ty.name(); match ty_name { @@ -389,6 +396,12 @@ fn type_opaque(ctx: &GenCtx, ty: &Type) -> bool { fn global_opaque(ctx: &GenCtx, global: &Global) -> bool { let global_name = global.name(); + match *global { + GCompDecl(ref ci) | + GComp(ref ci) if ci.borrow().opaque => return true, + _ => {} + } + // Can't make an opaque type without layout global.layout().is_some() && ctx.options.opaque_types.iter().any(|name| *name == global_name) diff --git a/src/parser.rs b/src/parser.rs index 50cf4d90..0f659d6e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -902,7 +902,7 @@ fn visit_top(cursor: &Cursor, visit_composite(c, p, ctx_, &mut ci_) }); if anno.opaque { - ci.borrow_mut().members = vec!(); + ci.borrow_mut().opaque = true; } if anno.hide { ci.borrow_mut().hide = true; diff --git a/src/types.rs b/src/types.rs index 54fce61c..0578d883 100644 --- a/src/types.rs +++ b/src/types.rs @@ -308,6 +308,11 @@ pub struct CompInfo { pub has_destructor: bool, pub has_nonempty_base: bool, pub hide: bool, + /// If this struct should be replaced by an opaque blob. + /// + /// This is useful if for some reason we can't generate + /// the correct layout. + pub opaque: bool, pub base_members: usize, pub layout: Layout, /// Typedef'd types names, that we'll resolve early to avoid name conflicts @@ -347,6 +352,7 @@ impl CompInfo { has_destructor: false, has_nonempty_base: false, hide: false, + opaque: false, base_members: 0, layout: layout, typedefs: vec!(), |