@@ -22,6 +22,14 @@ impl From<i32> for anon_0 {
2222 }
2323}
2424libcc2rs:: impl_enum_inc_dec!( anon_0) ;
25+ impl ByteRepr for anon_0 {
26+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
27+ ( * self as i32 ) . to_bytes ( buf) ;
28+ }
29+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
30+ <anon_0 >:: from ( i32:: from_bytes ( buf) )
31+ }
32+ }
2533#[ derive( Clone , Copy , PartialEq , Debug , Default ) ]
2634enum anon_1 {
2735 #[ default]
@@ -38,6 +46,14 @@ impl From<i32> for anon_1 {
3846 }
3947}
4048libcc2rs:: impl_enum_inc_dec!( anon_1) ;
49+ impl ByteRepr for anon_1 {
50+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
51+ ( * self as i32 ) . to_bytes ( buf) ;
52+ }
53+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
54+ <anon_1 >:: from ( i32:: from_bytes ( buf) )
55+ }
56+ }
4157#[ derive( Default ) ]
4258pub struct S {
4359 pub a : Value < i32 > ,
@@ -76,6 +92,14 @@ impl From<i32> for TdEnum {
7692 }
7793}
7894libcc2rs:: impl_enum_inc_dec!( TdEnum ) ;
95+ impl ByteRepr for TdEnum {
96+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
97+ ( * self as i32 ) . to_bytes ( buf) ;
98+ }
99+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
100+ <TdEnum >:: from ( i32:: from_bytes ( buf) )
101+ }
102+ }
79103#[ derive( Clone , Copy , PartialEq , Debug , Default ) ]
80104enum anon_2 {
81105 #[ default]
@@ -92,6 +116,14 @@ impl From<i32> for anon_2 {
92116 }
93117}
94118libcc2rs:: impl_enum_inc_dec!( anon_2) ;
119+ impl ByteRepr for anon_2 {
120+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
121+ ( * self as i32 ) . to_bytes ( buf) ;
122+ }
123+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
124+ <anon_2 >:: from ( i32:: from_bytes ( buf) )
125+ }
126+ }
95127#[ derive( Default ) ]
96128pub struct WithAnonField {
97129 pub a : Value < i32 > ,
@@ -106,7 +138,18 @@ impl Clone for WithAnonField {
106138 this
107139 }
108140}
109- impl ByteRepr for WithAnonField { }
141+ impl ByteRepr for WithAnonField {
142+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
143+ ( * self . a . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
144+ ( * self . field . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
145+ }
146+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
147+ Self {
148+ a : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
149+ field : Rc :: new ( RefCell :: new ( <anon_2 >:: from_bytes ( & buf[ 4 ..8 ] ) ) ) ,
150+ }
151+ }
152+ }
110153pub fn main ( ) {
111154 std:: process:: exit ( main_0 ( ) ) ;
112155}
@@ -127,6 +170,14 @@ fn main_0() -> i32 {
127170 }
128171 }
129172 libcc2rs:: impl_enum_inc_dec!( anon_3) ;
173+ impl ByteRepr for anon_3 {
174+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
175+ ( * self as i32 ) . to_bytes ( buf) ;
176+ }
177+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
178+ <anon_3 >:: from ( i32:: from_bytes ( buf) )
179+ }
180+ } ;
130181 assert ! ( ( ( anon_0:: FIRST_A as i32 ) != ( anon_0:: FIRST_B as i32 ) ) ) ;
131182 assert ! ( ( ( anon_1:: SECOND_A as i32 ) != ( anon_1:: SECOND_B as i32 ) ) ) ;
132183 assert ! ( ( ( anon_3:: THIRD_A as i32 ) != ( anon_3:: THIRD_B as i32 ) ) ) ;
0 commit comments