@@ -294,6 +294,10 @@ impl CodeGenerator for Item {
294
294
result : & mut CodegenResult < ' a > ,
295
295
whitelisted_items : & ItemSet ,
296
296
_extra : & ( ) ) {
297
+ if !self . is_enabled_for_codegen ( ctx) {
298
+ return ;
299
+ }
300
+
297
301
if self . is_hidden ( ctx) || result. seen ( self . id ( ) ) {
298
302
debug ! ( "<Item as CodeGenerator>::codegen: Ignoring hidden or seen: \
299
303
self = {:?}",
@@ -316,19 +320,13 @@ impl CodeGenerator for Item {
316
320
module. codegen ( ctx, result, whitelisted_items, self ) ;
317
321
}
318
322
ItemKind :: Function ( ref fun) => {
319
- if ctx. options ( ) . codegen_config . functions {
320
- fun. codegen ( ctx, result, whitelisted_items, self ) ;
321
- }
323
+ fun. codegen ( ctx, result, whitelisted_items, self ) ;
322
324
}
323
325
ItemKind :: Var ( ref var) => {
324
- if ctx. options ( ) . codegen_config . vars {
325
- var. codegen ( ctx, result, whitelisted_items, self ) ;
326
- }
326
+ var. codegen ( ctx, result, whitelisted_items, self ) ;
327
327
}
328
328
ItemKind :: Type ( ref ty) => {
329
- if ctx. options ( ) . codegen_config . types {
330
- ty. codegen ( ctx, result, whitelisted_items, self ) ;
331
- }
329
+ ty. codegen ( ctx, result, whitelisted_items, self ) ;
332
330
}
333
331
}
334
332
}
@@ -419,6 +417,7 @@ impl CodeGenerator for Var {
419
417
item : & Item ) {
420
418
use ir:: var:: VarType ;
421
419
debug ! ( "<Var as CodeGenerator>::codegen: item = {:?}" , item) ;
420
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
422
421
423
422
let canonical_name = item. canonical_name ( ctx) ;
424
423
@@ -522,6 +521,7 @@ impl CodeGenerator for Type {
522
521
whitelisted_items : & ItemSet ,
523
522
item : & Item ) {
524
523
debug ! ( "<Type as CodeGenerator>::codegen: item = {:?}" , item) ;
524
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
525
525
526
526
match * self . kind ( ) {
527
527
TypeKind :: Void |
@@ -705,6 +705,8 @@ impl<'a> CodeGenerator for Vtable<'a> {
705
705
_whitelisted_items : & ItemSet ,
706
706
item : & Item ) {
707
707
assert_eq ! ( item. id( ) , self . item_id) ;
708
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
709
+
708
710
// For now, generate an empty struct, later we should generate function
709
711
// pointers and whatnot.
710
712
let attributes = vec ! [ attributes:: repr( "C" ) ] ;
@@ -745,6 +747,8 @@ impl CodeGenerator for TemplateInstantiation {
745
747
result : & mut CodegenResult < ' a > ,
746
748
_whitelisted_items : & ItemSet ,
747
749
item : & Item ) {
750
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
751
+
748
752
// Although uses of instantiations don't need code generation, and are
749
753
// just converted to rust types in fields, vars, etc, we take this
750
754
// opportunity to generate tests for their layout here. If the
@@ -1376,6 +1380,7 @@ impl CodeGenerator for CompInfo {
1376
1380
whitelisted_items : & ItemSet ,
1377
1381
item : & Item ) {
1378
1382
debug ! ( "<CompInfo as CodeGenerator>::codegen: item = {:?}" , item) ;
1383
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
1379
1384
1380
1385
// Don't output classes with template parameters that aren't types, and
1381
1386
// also don't output template specializations, neither total or partial.
@@ -1897,6 +1902,18 @@ impl MethodCodegen for Method {
1897
1902
result : & mut CodegenResult < ' a > ,
1898
1903
whitelisted_items : & ItemSet ,
1899
1904
_parent : & CompInfo ) {
1905
+ assert ! ( {
1906
+ let cc = & ctx. options( ) . codegen_config;
1907
+ match self . kind( ) {
1908
+ MethodKind :: Constructor => cc. constructors,
1909
+ MethodKind :: Destructor => cc. destructors,
1910
+ MethodKind :: VirtualDestructor => cc. destructors,
1911
+ MethodKind :: Static |
1912
+ MethodKind :: Normal |
1913
+ MethodKind :: Virtual => cc. methods,
1914
+ }
1915
+ } ) ;
1916
+
1900
1917
if self . is_virtual ( ) {
1901
1918
return ; // FIXME
1902
1919
}
@@ -2287,6 +2304,7 @@ impl CodeGenerator for Enum {
2287
2304
_whitelisted_items : & ItemSet ,
2288
2305
item : & Item ) {
2289
2306
debug ! ( "<Enum as CodeGenerator>::codegen: item = {:?}" , item) ;
2307
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
2290
2308
2291
2309
let name = item. canonical_name ( ctx) ;
2292
2310
let enum_ty = item. expect_type ( ) ;
@@ -3026,6 +3044,7 @@ impl CodeGenerator for Function {
3026
3044
_whitelisted_items : & ItemSet ,
3027
3045
item : & Item ) {
3028
3046
debug ! ( "<Function as CodeGenerator>::codegen: item = {:?}" , item) ;
3047
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
3029
3048
3030
3049
// Similar to static member variables in a class template, we can't
3031
3050
// generate bindings to template functions, because the set of
@@ -3202,7 +3221,9 @@ impl CodeGenerator for ObjCInterface {
3202
3221
ctx : & BindgenContext ,
3203
3222
result : & mut CodegenResult < ' a > ,
3204
3223
_whitelisted_items : & ItemSet ,
3205
- _: & Item ) {
3224
+ item : & Item ) {
3225
+ debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
3226
+
3206
3227
let mut impl_items = vec ! [ ] ;
3207
3228
let mut trait_items = vec ! [ ] ;
3208
3229
0 commit comments