@@ -218,20 +218,28 @@ macro_rules! e {
218
218
/// purpose is to calculate the correct enum values.
219
219
///
220
220
/// See <https://github.com/rust-lang/libc/issues/4419> for more.
221
- // FIXME(ctest): ctest doesn't like `?` kleenes, `literal` fragments, or `$crate`. See inline
222
- // comments for what eventually should be fixed.
223
221
macro_rules! c_enum {
222
+ (
223
+ $( #[ repr( $repr: ty) ] ) ?
224
+ $ty_name: ident {
225
+ $( $variant: ident $( = $value: expr) ?, ) +
226
+ }
227
+ ) => {
228
+ pub type $ty_name = c_enum!( @ty $( $repr) ?) ;
229
+ c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) ?, ) +) ;
230
+ } ;
231
+
224
232
// Matcher for a single variant
225
233
( @one; $_ty_name: ident; $_idx: expr; ) => { } ;
226
234
(
227
235
@one; $ty_name: ident; $default_val: expr;
228
- $variant: ident $( = $value: tt /* literal */ ) * /* ? */ ,
236
+ $variant: ident $( = $value: expr ) ? ,
229
237
$( $tail: tt) *
230
238
) => {
231
239
pub const $variant: $ty_name = {
232
240
#[ allow( unused_variables) ]
233
241
let r = $default_val;
234
- $( let r = $value; ) *
242
+ $( let r = $value; ) ?
235
243
r
236
244
} ;
237
245
@@ -241,17 +249,8 @@ macro_rules! c_enum {
241
249
} ;
242
250
243
251
// Use a specific type if provided, otherwise default to `c_uint`
244
- ( @_ty $repr: ty) => { $repr } ;
245
- ( @_ty) => { /* $crate */ crate :: c_uint } ;
246
- (
247
- $( #[ repr( $repr: ty) ] ) * /* ? */
248
- $ty_name: ident {
249
- $( $variant: ident $( = $value: tt /* literal */ ) * /* ? */ , ) +
250
- }
251
- ) => {
252
- pub type $ty_name = c_enum!( @_ty $( $repr) * ) ;
253
- c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) * , ) +) ;
254
- } ;
252
+ ( @ty $repr: ty) => { $repr } ;
253
+ ( @ty) => { $crate:: c_uint } ;
255
254
}
256
255
257
256
// This is a pretty horrible hack to allow us to conditionally mark some functions as 'const',
0 commit comments