@@ -281,7 +281,7 @@ pub struct Enum {
281
281
282
282
impl Enum {
283
283
/// Name of the generated tag enum.
284
- fn enum_name ( & self ) -> & str {
284
+ fn tag_name ( & self ) -> & str {
285
285
self . tag . as_deref ( ) . unwrap_or_else ( || self . export_name ( ) )
286
286
}
287
287
@@ -598,7 +598,7 @@ impl Source for Enum {
598
598
let size = self . repr . ty . map ( |ty| ty. to_primitive ( ) . to_repr_c ( config) ) ;
599
599
let has_data = self . tag . is_some ( ) ;
600
600
let inline_tag_field = Self :: inline_tag_field ( & self . repr ) ;
601
- let enum_name = self . enum_name ( ) ;
601
+ let tag_name = self . tag_name ( ) ;
602
602
603
603
let condition = self . cfg . to_condition ( config) ;
604
604
condition. write_before ( config, out) ;
@@ -614,7 +614,7 @@ impl Source for Enum {
614
614
}
615
615
616
616
// Emit the tag enum and everything related to it.
617
- self . write_tag_enum ( config, out, size, has_data, inline_tag_field, enum_name ) ;
617
+ self . write_tag_enum ( config, out, size, has_data, inline_tag_field, tag_name ) ;
618
618
619
619
// If the enum has data, we need to emit structs for the variants and gather them together.
620
620
if has_data {
@@ -630,7 +630,7 @@ impl Source for Enum {
630
630
}
631
631
632
632
// Emit tag field that is separate from all variants.
633
- self . write_tag_field ( config, out, size, inline_tag_field, enum_name ) ;
633
+ self . write_tag_field ( config, out, size, inline_tag_field, tag_name ) ;
634
634
out. new_line ( ) ;
635
635
636
636
// Open union of all variants with data, only in the non-inline tag scenario.
@@ -653,7 +653,7 @@ impl Source for Enum {
653
653
}
654
654
655
655
// Emit convenience methods for the struct or enum for the data.
656
- self . write_derived_functions_data ( config, out, inline_tag_field, enum_name ) ;
656
+ self . write_derived_functions_data ( config, out, inline_tag_field, tag_name ) ;
657
657
658
658
// Emit the post_body section, if relevant.
659
659
if let Some ( body) = config. export . post_body ( & self . path ) {
@@ -685,15 +685,15 @@ impl Enum {
685
685
size : Option < & str > ,
686
686
has_data : bool ,
687
687
inline_tag_field : bool ,
688
- enum_name : & str ,
688
+ tag_name : & str ,
689
689
) {
690
690
// Open the tag enum.
691
691
match config. language {
692
692
Language :: C => {
693
693
if let Some ( prim) = size {
694
694
// If we need to specify size, then we have no choice but to create a typedef,
695
695
// so `config.style` is not respected.
696
- write ! ( out, "enum {}" , enum_name ) ;
696
+ write ! ( out, "enum {}" , tag_name ) ;
697
697
698
698
if config. cpp_compatible_c ( ) {
699
699
out. new_line ( ) ;
@@ -710,7 +710,7 @@ impl Enum {
710
710
}
711
711
out. write ( "enum" ) ;
712
712
if config. style . generate_tag ( ) {
713
- write ! ( out, " {}" , enum_name ) ;
713
+ write ! ( out, " {}" , tag_name ) ;
714
714
}
715
715
}
716
716
}
@@ -727,7 +727,7 @@ impl Enum {
727
727
}
728
728
}
729
729
730
- write ! ( out, " {}" , enum_name ) ;
730
+ write ! ( out, " {}" , tag_name ) ;
731
731
if let Some ( prim) = size {
732
732
write ! ( out, " : {}" , prim) ;
733
733
}
@@ -738,7 +738,7 @@ impl Enum {
738
738
// so `config.style` is not respected.
739
739
write ! ( out, "cdef enum" ) ;
740
740
} else {
741
- write ! ( out, "{}enum {}" , config. style. cython_def( ) , enum_name ) ;
741
+ write ! ( out, "{}enum {}" , config. style. cython_def( ) , tag_name ) ;
742
742
}
743
743
}
744
744
}
@@ -755,7 +755,7 @@ impl Enum {
755
755
// Close the tag enum.
756
756
if config. language == Language :: C && size. is_none ( ) && config. style . generate_typedef ( ) {
757
757
out. close_brace ( false ) ;
758
- write ! ( out, " {};" , enum_name ) ;
758
+ write ! ( out, " {};" , tag_name ) ;
759
759
} else {
760
760
out. close_brace ( true ) ;
761
761
}
@@ -771,7 +771,7 @@ impl Enum {
771
771
772
772
if config. language != Language :: Cxx {
773
773
out. new_line ( ) ;
774
- write ! ( out, "{} {} {};" , config. language. typedef( ) , prim, enum_name ) ;
774
+ write ! ( out, "{} {} {};" , config. language. typedef( ) , prim, tag_name ) ;
775
775
}
776
776
777
777
if config. cpp_compatible_c ( ) {
@@ -781,7 +781,7 @@ impl Enum {
781
781
}
782
782
783
783
// Emit convenience methods for the tag enum.
784
- self . write_derived_functions_enum ( config, out, has_data, inline_tag_field, enum_name ) ;
784
+ self . write_derived_functions_enum ( config, out, has_data, inline_tag_field, tag_name ) ;
785
785
}
786
786
787
787
/// The code here mirrors the beginning of `Struct::write` and `Union::write`.
@@ -847,7 +847,7 @@ impl Enum {
847
847
out : & mut SourceWriter < F > ,
848
848
size : Option < & str > ,
849
849
inline_tag_field : bool ,
850
- enum_name : & str ,
850
+ tag_name : & str ,
851
851
) {
852
852
// C++ allows accessing only common initial sequence of union
853
853
// fields so we have to wrap the tag field into an anonymous struct.
@@ -862,7 +862,7 @@ impl Enum {
862
862
out. write ( "enum " ) ;
863
863
}
864
864
865
- write ! ( out, "{} tag;" , enum_name ) ;
865
+ write ! ( out, "{} tag;" , tag_name ) ;
866
866
867
867
if wrap_tag {
868
868
out. close_brace ( true ) ;
@@ -902,7 +902,7 @@ impl Enum {
902
902
out : & mut SourceWriter < F > ,
903
903
has_data : bool ,
904
904
inline_tag_field : bool ,
905
- enum_name : & str ,
905
+ tag_name : & str ,
906
906
) {
907
907
if config. language != Language :: Cxx {
908
908
return ;
@@ -942,7 +942,7 @@ impl Enum {
942
942
"{} std::ostream& operator<<(std::ostream& {}, const {}& {})" ,
943
943
if has_data { "friend" } else { "inline" } ,
944
944
stream,
945
- enum_name ,
945
+ tag_name ,
946
946
instance,
947
947
) ;
948
948
@@ -952,9 +952,9 @@ impl Enum {
952
952
write ! (
953
953
out,
954
954
"using {} = {}::{};" ,
955
- enum_name ,
955
+ tag_name ,
956
956
self . export_name( ) ,
957
- enum_name
957
+ tag_name
958
958
) ;
959
959
out. new_line ( ) ;
960
960
}
@@ -966,7 +966,7 @@ impl Enum {
966
966
. map ( |x| {
967
967
format ! (
968
968
"case {}::{}: {} << \" {}\" ; break;" ,
969
- enum_name , x. export_name, stream, x. export_name
969
+ tag_name , x. export_name, stream, x. export_name
970
970
)
971
971
} )
972
972
. collect ( ) ;
@@ -996,9 +996,9 @@ impl Enum {
996
996
write ! (
997
997
out,
998
998
"using {} = {}::{};" ,
999
- enum_name ,
999
+ tag_name ,
1000
1000
self . export_name( ) ,
1001
- enum_name
1001
+ tag_name
1002
1002
) ;
1003
1003
out. new_line ( ) ;
1004
1004
@@ -1012,7 +1012,7 @@ impl Enum {
1012
1012
if let VariantBody :: Body { ref name, .. } = x. body {
1013
1013
format ! (
1014
1014
"case {}::{}: {} << {}{}{}.{}; break;" ,
1015
- enum_name ,
1015
+ tag_name ,
1016
1016
x. export_name,
1017
1017
stream,
1018
1018
if inline_tag_field { "" } else { & tag_str } ,
@@ -1023,7 +1023,7 @@ impl Enum {
1023
1023
} else {
1024
1024
format ! (
1025
1025
"case {}::{}: {} << {}; break;" ,
1026
- enum_name , x. export_name, stream, tag_str,
1026
+ tag_name , x. export_name, stream, tag_str,
1027
1027
)
1028
1028
}
1029
1029
} )
@@ -1044,7 +1044,7 @@ impl Enum {
1044
1044
config : & Config ,
1045
1045
out : & mut SourceWriter < F > ,
1046
1046
inline_tag_field : bool ,
1047
- enum_name : & str ,
1047
+ tag_name : & str ,
1048
1048
) {
1049
1049
if config. language != Language :: Cxx {
1050
1050
return ;
@@ -1133,7 +1133,7 @@ impl Enum {
1133
1133
}
1134
1134
1135
1135
out. new_line ( ) ;
1136
- write ! ( out, "result.tag = {}::{};" , enum_name , variant. export_name) ;
1136
+ write ! ( out, "result.tag = {}::{};" , tag_name , variant. export_name) ;
1137
1137
out. new_line ( ) ;
1138
1138
write ! ( out, "return result;" ) ;
1139
1139
out. close_brace ( false ) ;
@@ -1145,7 +1145,7 @@ impl Enum {
1145
1145
// FIXME: create a config for method case
1146
1146
write ! ( out, "bool Is{}() const" , variant. export_name) ;
1147
1147
out. open_brace ( ) ;
1148
- write ! ( out, "return tag == {}::{};" , enum_name , variant. export_name) ;
1148
+ write ! ( out, "return tag == {}::{};" , tag_name , variant. export_name) ;
1149
1149
out. close_brace ( false ) ;
1150
1150
1151
1151
let assert_name = match config. enumeration . cast_assert_name {
0 commit comments