11use super :: * ;
22
33#[ derive( Default , Clone ) ]
4- pub struct Cfg < ' a > {
5- pub types : BTreeMap < & ' a str , BTreeSet < TypeDef > > ,
4+ pub struct Cfg {
5+ pub types : BTreeMap < & ' static str , BTreeSet < TypeDef > > ,
66 pub core_types : BTreeSet < Type > ,
77 pub arches : BTreeSet < & ' static str > ,
88 pub implement : bool ,
99}
1010
11- impl < ' a > Cfg < ' a > {
12- pub fn add_feature ( & mut self , feature : & ' a str ) {
11+ impl Cfg {
12+ pub fn add_feature ( & mut self , feature : & ' static str ) {
1313 self . types . entry ( feature) . or_default ( ) ;
1414 }
1515 pub fn union ( & self , other : & Self ) -> Self {
@@ -30,63 +30,63 @@ impl<'a> Cfg<'a> {
3030 }
3131}
3232
33- pub fn field_cfg ( reader : & Reader , row : Field ) -> Cfg {
33+ pub fn field_cfg ( row : Field ) -> Cfg {
3434 let mut cfg = Cfg :: default ( ) ;
35- field_cfg_combine ( reader , row, None , & mut cfg) ;
35+ field_cfg_combine ( row, None , & mut cfg) ;
3636 cfg
3737}
38- fn field_cfg_combine < ' a > ( reader : & ' a Reader , row : Field , enclosing : Option < TypeDef > , cfg : & mut Cfg < ' a > ) {
39- type_cfg_combine ( reader , & row. ty ( enclosing) , cfg)
38+ fn field_cfg_combine ( row : Field , enclosing : Option < TypeDef > , cfg : & mut Cfg ) {
39+ type_cfg_combine ( & row. ty ( enclosing) , cfg)
4040}
4141
42- pub fn type_def_cfg < ' a > ( reader : & ' a Reader , row : TypeDef , generics : & [ Type ] ) -> Cfg < ' a > {
42+ pub fn type_def_cfg ( row : TypeDef , generics : & [ Type ] ) -> Cfg {
4343 let mut cfg = Cfg :: default ( ) ;
44- type_def_cfg_combine ( reader , row, generics, & mut cfg) ;
44+ type_def_cfg_combine ( row, generics, & mut cfg) ;
4545 cfg_add_attributes ( & mut cfg, row) ;
4646 cfg
4747}
48- pub fn type_def_cfg_impl < ' a > ( reader : & ' a Reader , def : TypeDef , generics : & [ Type ] ) -> Cfg < ' a > {
48+ pub fn type_def_cfg_impl ( def : TypeDef , generics : & [ Type ] ) -> Cfg {
4949 let mut cfg = Cfg { implement : true , ..Default :: default ( ) } ;
5050
51- fn combine < ' a > ( reader : & ' a Reader , def : TypeDef , generics : & [ Type ] , cfg : & mut Cfg < ' a > ) {
52- type_def_cfg_combine ( reader , def, generics, cfg) ;
51+ fn combine ( def : TypeDef , generics : & [ Type ] , cfg : & mut Cfg ) {
52+ type_def_cfg_combine ( def, generics, cfg) ;
5353
5454 for method in def. methods ( ) {
55- signature_cfg_combine ( reader , & method. signature ( generics) , cfg) ;
55+ signature_cfg_combine ( & method. signature ( generics) , cfg) ;
5656 }
5757 }
5858
59- combine ( reader , def, generics, & mut cfg) ;
59+ combine ( def, generics, & mut cfg) ;
6060
6161 for def in type_def_vtables ( def) {
6262 if let Type :: TypeDef ( def, generics) = def {
63- combine ( reader , def, & generics, & mut cfg) ;
63+ combine ( def, & generics, & mut cfg) ;
6464 }
6565 }
6666
6767 if def. flags ( ) . contains ( TypeAttributes :: WindowsRuntime ) {
6868 for interface in type_def_interfaces ( def, generics) {
6969 if let Type :: TypeDef ( def, generics) = interface {
70- combine ( reader , def, & generics, & mut cfg) ;
70+ combine ( def, & generics, & mut cfg) ;
7171 }
7272 }
7373 }
7474
7575 cfg_add_attributes ( & mut cfg, def) ;
7676 cfg
7777}
78- pub fn type_def_cfg_combine < ' a > ( reader : & ' a Reader , row : TypeDef , generics : & [ Type ] , cfg : & mut Cfg < ' a > ) {
78+ pub fn type_def_cfg_combine ( row : TypeDef , generics : & [ Type ] , cfg : & mut Cfg ) {
7979 let type_name = row. type_name ( ) ;
8080
8181 for generic in generics {
82- type_cfg_combine ( reader , generic, cfg) ;
82+ type_cfg_combine ( generic, cfg) ;
8383 }
8484
8585 if cfg. types . entry ( type_name. namespace ) . or_default ( ) . insert ( row) {
8686 match row. kind ( ) {
8787 TypeKind :: Class => {
8888 if let Some ( default_interface) = type_def_default_interface ( row) {
89- type_cfg_combine ( reader , & default_interface, cfg) ;
89+ type_cfg_combine ( & default_interface, cfg) ;
9090 }
9191 }
9292 TypeKind :: Interface => {
@@ -99,30 +99,30 @@ pub fn type_def_cfg_combine<'a>(reader: &'a Reader, row: TypeDef, generics: &[Ty
9999 }
100100 }
101101 TypeKind :: Struct => {
102- row. fields ( ) . for_each ( |field| field_cfg_combine ( reader , field, Some ( row) , cfg) ) ;
102+ row. fields ( ) . for_each ( |field| field_cfg_combine ( field, Some ( row) , cfg) ) ;
103103 if !type_name. namespace . is_empty ( ) {
104- for def in reader. get_type_def ( type_name. namespace , type_name. name ) {
104+ for def in row . reader ( ) . get_type_def ( type_name. namespace , type_name. name ) {
105105 if def != row {
106- type_def_cfg_combine ( reader , def, & [ ] , cfg) ;
106+ type_def_cfg_combine ( def, & [ ] , cfg) ;
107107 }
108108 }
109109 }
110110 }
111- TypeKind :: Delegate => signature_cfg_combine ( reader , & type_def_invoke_method ( row) . signature ( generics) , cfg) ,
111+ TypeKind :: Delegate => signature_cfg_combine ( & type_def_invoke_method ( row) . signature ( generics) , cfg) ,
112112 _ => { }
113113 }
114114 }
115115}
116116
117- pub fn signature_cfg ( reader : & Reader , method : MethodDef ) -> Cfg {
117+ pub fn signature_cfg ( method : MethodDef ) -> Cfg {
118118 let mut cfg = Cfg :: default ( ) ;
119- signature_cfg_combine ( reader , & method. signature ( & [ ] ) , & mut cfg) ;
119+ signature_cfg_combine ( & method. signature ( & [ ] ) , & mut cfg) ;
120120 cfg_add_attributes ( & mut cfg, method) ;
121121 cfg
122122}
123- fn signature_cfg_combine < ' a > ( reader : & ' a Reader , signature : & MethodDefSig , cfg : & mut Cfg < ' a > ) {
124- type_cfg_combine ( reader , & signature. return_type , cfg) ;
125- signature. params . iter ( ) . for_each ( |param| type_cfg_combine ( reader , param, cfg) ) ;
123+ fn signature_cfg_combine ( signature : & MethodDefSig , cfg : & mut Cfg ) {
124+ type_cfg_combine ( & signature. return_type , cfg) ;
125+ signature. params . iter ( ) . for_each ( |param| type_cfg_combine ( param, cfg) ) ;
126126}
127127
128128fn cfg_add_attributes < R : AsRow + Into < HasAttribute > > ( cfg : & mut Cfg , row : R ) {
@@ -151,19 +151,19 @@ fn cfg_add_attributes<R: AsRow + Into<HasAttribute>>(cfg: &mut Cfg, row: R) {
151151 }
152152}
153153
154- pub fn type_cfg < ' a > ( reader : & ' a Reader , ty : & Type ) -> Cfg < ' a > {
154+ pub fn type_cfg ( ty : & Type ) -> Cfg {
155155 let mut cfg = Cfg :: default ( ) ;
156- type_cfg_combine ( reader , ty, & mut cfg) ;
156+ type_cfg_combine ( ty, & mut cfg) ;
157157 cfg
158158}
159- fn type_cfg_combine < ' a > ( reader : & ' a Reader , ty : & Type , cfg : & mut Cfg < ' a > ) {
159+ fn type_cfg_combine ( ty : & Type , cfg : & mut Cfg ) {
160160 match ty {
161- Type :: TypeDef ( row, generics) => type_def_cfg_combine ( reader , * row, generics, cfg) ,
162- Type :: Win32Array ( ty, _) => type_cfg_combine ( reader , ty, cfg) ,
163- Type :: ConstPtr ( ty, _) => type_cfg_combine ( reader , ty, cfg) ,
164- Type :: MutPtr ( ty, _) => type_cfg_combine ( reader , ty, cfg) ,
165- Type :: WinrtArray ( ty) => type_cfg_combine ( reader , ty, cfg) ,
166- Type :: WinrtArrayRef ( ty) => type_cfg_combine ( reader , ty, cfg) ,
161+ Type :: TypeDef ( row, generics) => type_def_cfg_combine ( * row, generics, cfg) ,
162+ Type :: Win32Array ( ty, _) => type_cfg_combine ( ty, cfg) ,
163+ Type :: ConstPtr ( ty, _) => type_cfg_combine ( ty, cfg) ,
164+ Type :: MutPtr ( ty, _) => type_cfg_combine ( ty, cfg) ,
165+ Type :: WinrtArray ( ty) => type_cfg_combine ( ty, cfg) ,
166+ Type :: WinrtArrayRef ( ty) => type_cfg_combine ( ty, cfg) ,
167167 ty => _ = cfg. core_types . insert ( ty. clone ( ) ) ,
168168 }
169169}
0 commit comments