@@ -20,7 +20,6 @@ use super::BindgenOptions;
20
20
21
21
use crate :: ir:: analysis:: { HasVtable , Sizedness } ;
22
22
use crate :: ir:: annotations:: FieldAccessorKind ;
23
- use crate :: ir:: comment;
24
23
use crate :: ir:: comp:: {
25
24
Bitfield , BitfieldUnit , CompInfo , CompKind , Field , FieldData , FieldMethods ,
26
25
Method , MethodKind ,
@@ -1245,7 +1244,6 @@ trait FieldCodegen<'a> {
1245
1244
& self ,
1246
1245
ctx : & BindgenContext ,
1247
1246
fields_should_be_private : bool ,
1248
- codegen_depth : usize ,
1249
1247
accessor_kind : FieldAccessorKind ,
1250
1248
parent : & CompInfo ,
1251
1249
result : & mut CodegenResult ,
@@ -1265,7 +1263,6 @@ impl<'a> FieldCodegen<'a> for Field {
1265
1263
& self ,
1266
1264
ctx : & BindgenContext ,
1267
1265
fields_should_be_private : bool ,
1268
- codegen_depth : usize ,
1269
1266
accessor_kind : FieldAccessorKind ,
1270
1267
parent : & CompInfo ,
1271
1268
result : & mut CodegenResult ,
@@ -1282,7 +1279,6 @@ impl<'a> FieldCodegen<'a> for Field {
1282
1279
data. codegen (
1283
1280
ctx,
1284
1281
fields_should_be_private,
1285
- codegen_depth,
1286
1282
accessor_kind,
1287
1283
parent,
1288
1284
result,
@@ -1296,7 +1292,6 @@ impl<'a> FieldCodegen<'a> for Field {
1296
1292
unit. codegen (
1297
1293
ctx,
1298
1294
fields_should_be_private,
1299
- codegen_depth,
1300
1295
accessor_kind,
1301
1296
parent,
1302
1297
result,
@@ -1346,7 +1341,6 @@ impl<'a> FieldCodegen<'a> for FieldData {
1346
1341
& self ,
1347
1342
ctx : & BindgenContext ,
1348
1343
fields_should_be_private : bool ,
1349
- codegen_depth : usize ,
1350
1344
accessor_kind : FieldAccessorKind ,
1351
1345
parent : & CompInfo ,
1352
1346
result : & mut CodegenResult ,
@@ -1392,8 +1386,7 @@ impl<'a> FieldCodegen<'a> for FieldData {
1392
1386
let mut field = quote ! { } ;
1393
1387
if ctx. options ( ) . generate_comments {
1394
1388
if let Some ( raw_comment) = self . comment ( ) {
1395
- let comment =
1396
- comment:: preprocess ( raw_comment, codegen_depth + 1 ) ;
1389
+ let comment = ctx. options ( ) . process_comment ( raw_comment) ;
1397
1390
field = attributes:: doc ( comment) ;
1398
1391
}
1399
1392
}
@@ -1553,7 +1546,6 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
1553
1546
& self ,
1554
1547
ctx : & BindgenContext ,
1555
1548
fields_should_be_private : bool ,
1556
- codegen_depth : usize ,
1557
1549
accessor_kind : FieldAccessorKind ,
1558
1550
parent : & CompInfo ,
1559
1551
result : & mut CodegenResult ,
@@ -1630,7 +1622,6 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
1630
1622
bf. codegen (
1631
1623
ctx,
1632
1624
fields_should_be_private,
1633
- codegen_depth,
1634
1625
accessor_kind,
1635
1626
parent,
1636
1627
result,
@@ -1705,7 +1696,6 @@ impl<'a> FieldCodegen<'a> for Bitfield {
1705
1696
& self ,
1706
1697
ctx : & BindgenContext ,
1707
1698
fields_should_be_private : bool ,
1708
- _codegen_depth : usize ,
1709
1699
_accessor_kind : FieldAccessorKind ,
1710
1700
parent : & CompInfo ,
1711
1701
_result : & mut CodegenResult ,
@@ -1883,7 +1873,6 @@ impl CodeGenerator for CompInfo {
1883
1873
1884
1874
let mut methods = vec ! [ ] ;
1885
1875
if !is_opaque {
1886
- let codegen_depth = item. codegen_depth ( ctx) ;
1887
1876
let fields_should_be_private =
1888
1877
item. annotations ( ) . private_fields ( ) . unwrap_or ( false ) ;
1889
1878
let struct_accessor_kind = item
@@ -1894,7 +1883,6 @@ impl CodeGenerator for CompInfo {
1894
1883
field. codegen (
1895
1884
ctx,
1896
1885
fields_should_be_private,
1897
- codegen_depth,
1898
1886
struct_accessor_kind,
1899
1887
self ,
1900
1888
result,
@@ -2703,41 +2691,27 @@ impl std::str::FromStr for EnumVariation {
2703
2691
/// A helper type to construct different enum variations.
2704
2692
enum EnumBuilder < ' a > {
2705
2693
Rust {
2706
- codegen_depth : usize ,
2707
2694
attrs : Vec < proc_macro2:: TokenStream > ,
2708
2695
ident : Ident ,
2709
2696
tokens : proc_macro2:: TokenStream ,
2710
2697
emitted_any_variants : bool ,
2711
2698
} ,
2712
2699
NewType {
2713
- codegen_depth : usize ,
2714
2700
canonical_name : & ' a str ,
2715
2701
tokens : proc_macro2:: TokenStream ,
2716
2702
is_bitfield : bool ,
2717
2703
is_global : bool ,
2718
2704
} ,
2719
2705
Consts {
2720
2706
variants : Vec < proc_macro2:: TokenStream > ,
2721
- codegen_depth : usize ,
2722
2707
} ,
2723
2708
ModuleConsts {
2724
- codegen_depth : usize ,
2725
2709
module_name : & ' a str ,
2726
2710
module_items : Vec < proc_macro2:: TokenStream > ,
2727
2711
} ,
2728
2712
}
2729
2713
2730
2714
impl < ' a > EnumBuilder < ' a > {
2731
- /// Returns the depth of the code generation for a variant of this enum.
2732
- fn codegen_depth ( & self ) -> usize {
2733
- match * self {
2734
- EnumBuilder :: Rust { codegen_depth, .. } |
2735
- EnumBuilder :: NewType { codegen_depth, .. } |
2736
- EnumBuilder :: ModuleConsts { codegen_depth, .. } |
2737
- EnumBuilder :: Consts { codegen_depth, .. } => codegen_depth,
2738
- }
2739
- }
2740
-
2741
2715
/// Returns true if the builder is for a rustified enum.
2742
2716
fn is_rust_enum ( & self ) -> bool {
2743
2717
matches ! ( * self , EnumBuilder :: Rust { .. } )
@@ -2750,7 +2724,6 @@ impl<'a> EnumBuilder<'a> {
2750
2724
mut attrs : Vec < proc_macro2:: TokenStream > ,
2751
2725
repr : proc_macro2:: TokenStream ,
2752
2726
enum_variation : EnumVariation ,
2753
- enum_codegen_depth : usize ,
2754
2727
) -> Self {
2755
2728
let ident = Ident :: new ( name, Span :: call_site ( ) ) ;
2756
2729
@@ -2759,7 +2732,6 @@ impl<'a> EnumBuilder<'a> {
2759
2732
is_bitfield,
2760
2733
is_global,
2761
2734
} => EnumBuilder :: NewType {
2762
- codegen_depth : enum_codegen_depth,
2763
2735
canonical_name : name,
2764
2736
tokens : quote ! {
2765
2737
#( #attrs ) *
@@ -2774,7 +2746,6 @@ impl<'a> EnumBuilder<'a> {
2774
2746
attrs. insert ( 0 , quote ! { #[ repr( #repr ) ] } ) ;
2775
2747
let tokens = quote ! ( ) ;
2776
2748
EnumBuilder :: Rust {
2777
- codegen_depth : enum_codegen_depth + 1 ,
2778
2749
attrs,
2779
2750
ident,
2780
2751
tokens,
@@ -2790,10 +2761,7 @@ impl<'a> EnumBuilder<'a> {
2790
2761
pub type #ident = #repr;
2791
2762
} ) ;
2792
2763
2793
- EnumBuilder :: Consts {
2794
- variants,
2795
- codegen_depth : enum_codegen_depth,
2796
- }
2764
+ EnumBuilder :: Consts { variants }
2797
2765
}
2798
2766
2799
2767
EnumVariation :: ModuleConsts => {
@@ -2807,7 +2775,6 @@ impl<'a> EnumBuilder<'a> {
2807
2775
} ;
2808
2776
2809
2777
EnumBuilder :: ModuleConsts {
2810
- codegen_depth : enum_codegen_depth + 1 ,
2811
2778
module_name : name,
2812
2779
module_items : vec ! [ type_definition] ,
2813
2780
}
@@ -2839,8 +2806,7 @@ impl<'a> EnumBuilder<'a> {
2839
2806
let mut doc = quote ! { } ;
2840
2807
if ctx. options ( ) . generate_comments {
2841
2808
if let Some ( raw_comment) = variant. comment ( ) {
2842
- let comment =
2843
- comment:: preprocess ( raw_comment, self . codegen_depth ( ) ) ;
2809
+ let comment = ctx. options ( ) . process_comment ( raw_comment) ;
2844
2810
doc = attributes:: doc ( comment) ;
2845
2811
}
2846
2812
}
@@ -2851,13 +2817,11 @@ impl<'a> EnumBuilder<'a> {
2851
2817
ident,
2852
2818
tokens,
2853
2819
emitted_any_variants : _,
2854
- codegen_depth,
2855
2820
} => {
2856
2821
let name = ctx. rust_ident ( variant_name) ;
2857
2822
EnumBuilder :: Rust {
2858
2823
attrs,
2859
2824
ident,
2860
- codegen_depth,
2861
2825
tokens : quote ! {
2862
2826
#tokens
2863
2827
#doc
@@ -2918,7 +2882,6 @@ impl<'a> EnumBuilder<'a> {
2918
2882
self
2919
2883
}
2920
2884
EnumBuilder :: ModuleConsts {
2921
- codegen_depth,
2922
2885
module_name,
2923
2886
mut module_items,
2924
2887
} => {
@@ -2932,7 +2895,6 @@ impl<'a> EnumBuilder<'a> {
2932
2895
EnumBuilder :: ModuleConsts {
2933
2896
module_name,
2934
2897
module_items,
2935
- codegen_depth,
2936
2898
}
2937
2899
}
2938
2900
}
@@ -3211,13 +3173,7 @@ impl CodeGenerator for Enum {
3211
3173
3212
3174
let repr = repr. to_rust_ty_or_opaque ( ctx, item) ;
3213
3175
3214
- let mut builder = EnumBuilder :: new (
3215
- & name,
3216
- attrs,
3217
- repr,
3218
- variation,
3219
- item. codegen_depth ( ctx) ,
3220
- ) ;
3176
+ let mut builder = EnumBuilder :: new ( & name, attrs, repr, variation) ;
3221
3177
3222
3178
// A map where we keep a value -> variant relation.
3223
3179
let mut seen_values = HashMap :: < _ , Ident > :: default ( ) ;
0 commit comments