File tree 4 files changed +27
-1
lines changed 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,14 @@ fn gen_mod(mut ctx: &mut GenCtx,
376
376
}
377
377
}
378
378
379
+ // XXX: Replace the name-based lookup, or do it at parse-time,
380
+ // to keep all the mess in the same place.
379
381
fn type_opaque ( ctx : & GenCtx , ty : & Type ) -> bool {
382
+ match * ty {
383
+ TComp ( ref ci) if ci. borrow ( ) . opaque => return true ,
384
+ _ => { }
385
+ }
386
+
380
387
let ty_name = ty. name ( ) ;
381
388
382
389
match ty_name {
@@ -389,6 +396,12 @@ fn type_opaque(ctx: &GenCtx, ty: &Type) -> bool {
389
396
fn global_opaque ( ctx : & GenCtx , global : & Global ) -> bool {
390
397
let global_name = global. name ( ) ;
391
398
399
+ match * global {
400
+ GCompDecl ( ref ci) |
401
+ GComp ( ref ci) if ci. borrow ( ) . opaque => return true ,
402
+ _ => { }
403
+ }
404
+
392
405
// Can't make an opaque type without layout
393
406
global. layout ( ) . is_some ( ) &&
394
407
ctx. options . opaque_types . iter ( ) . any ( |name| * name == global_name)
Original file line number Diff line number Diff line change @@ -902,7 +902,7 @@ fn visit_top(cursor: &Cursor,
902
902
visit_composite ( c, p, ctx_, & mut ci_)
903
903
} ) ;
904
904
if anno. opaque {
905
- ci. borrow_mut ( ) . members = vec ! ( ) ;
905
+ ci. borrow_mut ( ) . opaque = true ;
906
906
}
907
907
if anno. hide {
908
908
ci. borrow_mut ( ) . hide = true ;
Original file line number Diff line number Diff line change @@ -308,6 +308,11 @@ pub struct CompInfo {
308
308
pub has_destructor : bool ,
309
309
pub has_nonempty_base : bool ,
310
310
pub hide : bool ,
311
+ /// If this struct should be replaced by an opaque blob.
312
+ ///
313
+ /// This is useful if for some reason we can't generate
314
+ /// the correct layout.
315
+ pub opaque : bool ,
311
316
pub base_members : usize ,
312
317
pub layout : Layout ,
313
318
/// Typedef'd types names, that we'll resolve early to avoid name conflicts
@@ -347,6 +352,7 @@ impl CompInfo {
347
352
has_destructor : false ,
348
353
has_nonempty_base : false ,
349
354
hide : false ,
355
+ opaque : false ,
350
356
base_members : 0 ,
351
357
layout : layout,
352
358
typedefs : vec ! ( ) ,
Original file line number Diff line number Diff line change 3
3
* <div rustbindgen="true" hide="true"></div>
4
4
*/
5
5
struct C ;
6
+
7
+ /* *
8
+ * <div rustbindgen opaque></div>
9
+ */
10
+ struct D {
11
+ int a;
12
+ };
You can’t perform that action at this time.
0 commit comments