@@ -5,16 +5,16 @@ use super::*;
5
5
use std:: marker:: PhantomData ;
6
6
use std:: sync:: atomic:: AtomicU32 ;
7
7
8
- macro_rules! define_handles {
8
+ macro_rules! define_client_handles {
9
9
(
10
10
' owned: $( $oty: ident, ) *
11
11
' interned: $( $ity: ident, ) *
12
12
) => {
13
13
#[ repr( C ) ]
14
14
#[ allow( non_snake_case) ]
15
- pub struct HandleCounters {
16
- $( $oty: AtomicU32 , ) *
17
- $( $ity: AtomicU32 , ) *
15
+ pub ( super ) struct HandleCounters {
16
+ $( pub ( super ) $oty: AtomicU32 , ) *
17
+ $( pub ( super ) $ity: AtomicU32 , ) *
18
18
}
19
19
20
20
impl HandleCounters {
@@ -29,22 +29,6 @@ macro_rules! define_handles {
29
29
}
30
30
}
31
31
32
- // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
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
32
$(
49
33
pub ( crate ) struct $oty {
50
34
handle: handle:: Handle ,
@@ -72,53 +56,18 @@ macro_rules! define_handles {
72
56
}
73
57
}
74
58
75
- impl <S : server:: Types > DecodeMut <' _, ' _, HandleStore <server:: MarkedTypes <S >>>
76
- for Marked <S :: $oty, $oty>
77
- {
78
- fn decode( r: & mut Reader <' _>, s: & mut HandleStore <server:: MarkedTypes <S >>) -> Self {
79
- s. $oty. take( handle:: Handle :: decode( r, & mut ( ) ) )
80
- }
81
- }
82
-
83
59
impl <S > Encode <S > for & $oty {
84
60
fn encode( self , w: & mut Writer , s: & mut S ) {
85
61
self . handle. encode( w, s) ;
86
62
}
87
63
}
88
64
89
- impl <' s, S : server:: Types > Decode <' _, ' s, HandleStore <server:: MarkedTypes <S >>>
90
- for & ' s Marked <S :: $oty, $oty>
91
- {
92
- fn decode( r: & mut Reader <' _>, s: & ' s HandleStore <server:: MarkedTypes <S >>) -> Self {
93
- & s. $oty[ handle:: Handle :: decode( r, & mut ( ) ) ]
94
- }
95
- }
96
-
97
65
impl <S > Encode <S > for & mut $oty {
98
66
fn encode( self , w: & mut Writer , s: & mut S ) {
99
67
self . handle. encode( w, s) ;
100
68
}
101
69
}
102
70
103
- impl <' s, S : server:: Types > DecodeMut <' _, ' s, HandleStore <server:: MarkedTypes <S >>>
104
- for & ' s mut Marked <S :: $oty, $oty>
105
- {
106
- fn decode(
107
- r: & mut Reader <' _>,
108
- s: & ' s mut HandleStore <server:: MarkedTypes <S >>
109
- ) -> Self {
110
- & mut s. $oty[ handle:: Handle :: decode( r, & mut ( ) ) ]
111
- }
112
- }
113
-
114
- impl <S : server:: Types > Encode <HandleStore <server:: MarkedTypes <S >>>
115
- for Marked <S :: $oty, $oty>
116
- {
117
- fn encode( self , w: & mut Writer , s: & mut HandleStore <server:: MarkedTypes <S >>) {
118
- s. $oty. alloc( self ) . encode( w, s) ;
119
- }
120
- }
121
-
122
71
impl <S > DecodeMut <' _, ' _, S > for $oty {
123
72
fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
124
73
$oty {
@@ -145,22 +94,6 @@ macro_rules! define_handles {
145
94
}
146
95
}
147
96
148
- impl <S : server:: Types > DecodeMut <' _, ' _, HandleStore <server:: MarkedTypes <S >>>
149
- for Marked <S :: $ity, $ity>
150
- {
151
- fn decode( r: & mut Reader <' _>, s: & mut HandleStore <server:: MarkedTypes <S >>) -> Self {
152
- s. $ity. copy( handle:: Handle :: decode( r, & mut ( ) ) )
153
- }
154
- }
155
-
156
- impl <S : server:: Types > Encode <HandleStore <server:: MarkedTypes <S >>>
157
- for Marked <S :: $ity, $ity>
158
- {
159
- fn encode( self , w: & mut Writer , s: & mut HandleStore <server:: MarkedTypes <S >>) {
160
- s. $ity. alloc( self ) . encode( w, s) ;
161
- }
162
- }
163
-
164
97
impl <S > DecodeMut <' _, ' _, S > for $ity {
165
98
fn decode( r: & mut Reader <' _>, s: & mut S ) -> Self {
166
99
$ity {
@@ -172,15 +105,7 @@ macro_rules! define_handles {
172
105
) *
173
106
}
174
107
}
175
- define_handles ! {
176
- ' owned:
177
- FreeFunctions ,
178
- TokenStream ,
179
- SourceFile ,
180
-
181
- ' interned:
182
- Span ,
183
- }
108
+ with_api_handle_types ! ( define_client_handles) ;
184
109
185
110
// FIXME(eddyb) generate these impls by pattern-matching on the
186
111
// names of methods - also could use the presence of `fn drop`
0 commit comments