@@ -11,9 +11,9 @@ macro_rules! define_handles {
11
11
) => {
12
12
#[ repr( C ) ]
13
13
#[ allow( non_snake_case) ]
14
- pub struct HandleCounters {
15
- $( $oty: AtomicUsize , ) *
16
- $( $ity: AtomicUsize , ) *
14
+ pub ( super ) struct HandleCounters {
15
+ $( pub ( super ) $oty: AtomicUsize , ) *
16
+ $( pub ( super ) $ity: AtomicUsize , ) *
17
17
}
18
18
19
19
impl HandleCounters {
@@ -28,23 +28,6 @@ macro_rules! define_handles {
28
28
}
29
29
}
30
30
31
- // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
32
- #[ repr( C ) ]
33
- #[ allow( non_snake_case) ]
34
- pub ( super ) struct HandleStore <S : server:: Types > {
35
- $( $oty: handle:: OwnedStore <S :: $oty>, ) *
36
- $( $ity: handle:: InternedStore <S :: $ity>, ) *
37
- }
38
-
39
- impl <S : server:: Types > HandleStore <S > {
40
- pub ( super ) fn new( handle_counters: & ' static HandleCounters ) -> Self {
41
- HandleStore {
42
- $( $oty: handle:: OwnedStore :: new( & handle_counters. $oty) , ) *
43
- $( $ity: handle:: InternedStore :: new( & handle_counters. $ity) , ) *
44
- }
45
- }
46
- }
47
-
48
31
$(
49
32
#[ repr( C ) ]
50
33
pub ( crate ) struct $oty {
@@ -73,53 +56,18 @@ macro_rules! define_handles {
73
56
}
74
57
}
75
58
76
- impl <S : server:: Types > DecodeMut <' _, ' _, HandleStore <server:: MarkedTypes <S >>>
77
- for Marked <S :: $oty, $oty>
78
- {
79
- fn decode( r: & mut Reader <' _>, s: & mut HandleStore <server:: MarkedTypes <S >>) -> Self {
80
- s. $oty. take( handle:: Handle :: decode( r, & mut ( ) ) )
81
- }
82
- }
83
-
84
59
impl <S > Encode <S > for & $oty {
85
60
fn encode( self , w: & mut Writer , s: & mut S ) {
86
61
self . handle. encode( w, s) ;
87
62
}
88
63
}
89
64
90
- impl <' s, S : server:: Types > Decode <' _, ' s, HandleStore <server:: MarkedTypes <S >>>
91
- for & ' s Marked <S :: $oty, $oty>
92
- {
93
- fn decode( r: & mut Reader <' _>, s: & ' s HandleStore <server:: MarkedTypes <S >>) -> Self {
94
- & s. $oty[ handle:: Handle :: decode( r, & mut ( ) ) ]
95
- }
96
- }
97
-
98
65
impl <S > Encode <S > for & mut $oty {
99
66
fn encode( self , w: & mut Writer , s: & mut S ) {
100
67
self . handle. encode( w, s) ;
101
68
}
102
69
}
103
70
104
- impl <' s, S : server:: Types > DecodeMut <' _, ' s, HandleStore <server:: MarkedTypes <S >>>
105
- for & ' s mut Marked <S :: $oty, $oty>
106
- {
107
- fn decode(
108
- r: & mut Reader <' _>,
109
- s: & ' s mut HandleStore <server:: MarkedTypes <S >>
110
- ) -> Self {
111
- & mut s. $oty[ handle:: Handle :: decode( r, & mut ( ) ) ]
112
- }
113
- }
114
-
115
- impl <S : server:: Types > Encode <HandleStore <server:: MarkedTypes <S >>>
116
- for Marked <S :: $oty, $oty>
117
- {
118
- fn encode( self , w: & mut Writer , s: & mut HandleStore <server:: MarkedTypes <S >>) {
119
- s. $oty. alloc( self ) . encode( w, s) ;
120
- }
121
- }
122
-
123
71
impl <S > DecodeMut <' _, ' _, S > for $oty {
124
72
fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
125
73
$oty {
@@ -147,22 +95,6 @@ macro_rules! define_handles {
147
95
}
148
96
}
149
97
150
- impl <S : server:: Types > DecodeMut <' _, ' _, HandleStore <server:: MarkedTypes <S >>>
151
- for Marked <S :: $ity, $ity>
152
- {
153
- fn decode( r: & mut Reader <' _>, s: & mut HandleStore <server:: MarkedTypes <S >>) -> Self {
154
- s. $ity. copy( handle:: Handle :: decode( r, & mut ( ) ) )
155
- }
156
- }
157
-
158
- impl <S : server:: Types > Encode <HandleStore <server:: MarkedTypes <S >>>
159
- for Marked <S :: $ity, $ity>
160
- {
161
- fn encode( self , w: & mut Writer , s: & mut HandleStore <server:: MarkedTypes <S >>) {
162
- s. $ity. alloc( self ) . encode( w, s) ;
163
- }
164
- }
165
-
166
98
impl <S > DecodeMut <' _, ' _, S > for $ity {
167
99
fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
168
100
$ity {
@@ -174,23 +106,7 @@ macro_rules! define_handles {
174
106
) *
175
107
}
176
108
}
177
- define_handles ! {
178
- ' owned:
179
- FreeFunctions ,
180
- TokenStream ,
181
- TokenStreamBuilder ,
182
- TokenStreamIter ,
183
- Group ,
184
- Literal ,
185
- SourceFile ,
186
- MultiSpan ,
187
- Diagnostic ,
188
-
189
- ' interned:
190
- Punct ,
191
- Ident ,
192
- Span ,
193
- }
109
+ with_api_types ! ( define_handles) ;
194
110
195
111
// FIXME(eddyb) generate these impls by pattern-matching on the
196
112
// names of methods - also could use the presence of `fn drop`
0 commit comments