@@ -242,8 +242,22 @@ fn handle_type<'a, T: TypeHandler<'a>>(
242
242
#into_type
243
243
} ) )
244
244
}
245
+ fn is_c_style_enum ( data : & DataEnum ) -> bool {
246
+ /*
247
+ * TODO: Should the following be considered a 'c-style' enum?
248
+ * enum Test {
249
+ * One,
250
+ * Two { },
251
+ * Three( )
252
+ * }
253
+ *
254
+ * Right now it *is*, because `fields.is_empty`,
255
+ * although we could require them all to be unit-variants (like `One`)
256
+ */
257
+ data. variants . iter ( ) . all ( |var| var. fields . is_empty ( ) )
258
+ }
245
259
fn enum_static_type ( data : & DataEnum , name : & Ident ) -> Result < TokenStream , syn:: Error > {
246
- if data . variants . iter ( ) . all ( |var| var . fields . is_empty ( ) ) {
260
+ if is_c_style_enum ( data ) {
247
261
// C-style enum
248
262
// TODO: Strict typing
249
263
// TODO: Should we always assume that we're unsigned?
@@ -451,11 +465,11 @@ impl<'a> TypeHandler<'a> for UnionTypeHandler<'a> {
451
465
}
452
466
453
467
fn type_def_type ( ) -> TokenStream {
454
- quote ! ( static_reflect:: types:: UnionDef )
468
+ quote ! ( static_reflect:: types:: UntaggedUnionDef )
455
469
}
456
470
457
471
fn def_into_type ( def_ref : TokenStream ) -> TokenStream {
458
- quote ! ( static_reflect:: types:: TypeInfo :: Union ( #def_ref) )
472
+ quote ! ( static_reflect:: types:: TypeInfo :: UntaggedUnion ( #def_ref) )
459
473
}
460
474
461
475
fn handle_fields < F : FnMut ( FieldInfo < ' a > ) > ( & mut self , mut handler : F ) -> syn:: Result < ( ) > {
@@ -498,7 +512,7 @@ impl<'a> TypeHandler<'a> for UnionTypeHandler<'a> {
498
512
quote ! ( {
499
513
use std:: mem:: { size_of, align_of} ;
500
514
#header
501
- let def = UnionDef {
515
+ let def = UntaggedUnionDef {
502
516
name: stringify!( #name) ,
503
517
fields: _FIELDS,
504
518
size: size_of:: <#name>( ) ,
0 commit comments