@@ -24,12 +24,31 @@ impl From<i32> for widget_enum {
2424 }
2525}
2626libcc2rs:: impl_enum_inc_dec!( widget_enum) ;
27+ impl ByteRepr for widget_enum {
28+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
29+ ( * self as i32 ) . to_bytes ( buf) ;
30+ }
31+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
32+ <widget_enum >:: from ( i32:: from_bytes ( buf) )
33+ }
34+ }
2735#[ derive( Default ) ]
2836pub struct widget {
2937 pub id : Value < i32 > ,
3038 pub mode : Value < widget_enum > ,
3139}
32- impl ByteRepr for widget { }
40+ impl ByteRepr for widget {
41+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
42+ ( * self . id . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
43+ ( * self . mode . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
44+ }
45+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
46+ Self {
47+ id : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
48+ mode : Rc :: new ( RefCell :: new ( <widget_enum >:: from_bytes ( & buf[ 4 ..8 ] ) ) ) ,
49+ }
50+ }
51+ }
3352#[ derive( Default ) ]
3453pub struct point_struct {
3554 pub x : Value < i32 > ,
@@ -115,6 +134,14 @@ impl From<i32> for slot {
115134 }
116135}
117136libcc2rs:: impl_enum_inc_dec!( slot) ;
137+ impl ByteRepr for slot {
138+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
139+ ( * self as i32 ) . to_bytes ( buf) ;
140+ }
141+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
142+ <slot >:: from ( i32:: from_bytes ( buf) )
143+ }
144+ }
118145#[ derive( Default ) ]
119146pub struct Inner {
120147 pub tag_field : Value < i32 > ,
0 commit comments