@@ -11,9 +11,9 @@ macro_rules! define_handles {
1111 ) => {
1212 #[ repr( C ) ]
1313 #[ 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 , ) *
1717 }
1818
1919 impl HandleCounters {
@@ -28,23 +28,6 @@ macro_rules! define_handles {
2828 }
2929 }
3030
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-
4831 $(
4932 #[ repr( C ) ]
5033 pub ( crate ) struct $oty {
@@ -73,53 +56,18 @@ macro_rules! define_handles {
7356 }
7457 }
7558
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-
8459 impl <S > Encode <S > for & $oty {
8560 fn encode( self , w: & mut Writer , s: & mut S ) {
8661 self . handle. encode( w, s) ;
8762 }
8863 }
8964
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-
9865 impl <S > Encode <S > for & mut $oty {
9966 fn encode( self , w: & mut Writer , s: & mut S ) {
10067 self . handle. encode( w, s) ;
10168 }
10269 }
10370
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-
12371 impl <S > DecodeMut <' _, ' _, S > for $oty {
12472 fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
12573 $oty {
@@ -147,22 +95,6 @@ macro_rules! define_handles {
14795 }
14896 }
14997
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-
16698 impl <S > DecodeMut <' _, ' _, S > for $ity {
16799 fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
168100 $ity {
@@ -174,23 +106,7 @@ macro_rules! define_handles {
174106 ) *
175107 }
176108}
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) ;
194110
195111// FIXME(eddyb) generate these impls by pattern-matching on the
196112// names of methods - also could use the presence of `fn drop`
0 commit comments