@@ -24,7 +24,7 @@ pub struct RegisterInfo {
24
24
pub alternate_group : Option < String > ,
25
25
pub alternate_register : Option < String > ,
26
26
pub derived_from : Option < String > ,
27
- pub description : String ,
27
+ pub description : Option < String > ,
28
28
pub address_offset : u32 ,
29
29
pub size : Option < u32 > ,
30
30
pub access : Option < Access > ,
@@ -59,8 +59,8 @@ impl RegisterInfo {
59
59
name,
60
60
alternate_group : tree. get_child_text_opt ( "alternateGroup" ) ?,
61
61
alternate_register : tree. get_child_text_opt ( "alternateRegister" ) ?,
62
+ description : tree. get_child_text_opt ( "description" ) ?,
62
63
derived_from : tree. attributes . get ( "derivedFrom" ) . map ( |s| s. to_owned ( ) ) ,
63
- description : tree. get_child_text ( "description" ) ?,
64
64
address_offset : tree. get_child_u32 ( "addressOffset" ) ?,
65
65
size : parse:: optional :: < u32 > ( "size" , tree) ?,
66
66
access : parse:: optional :: < Access > ( "access" , tree) ?,
@@ -105,15 +105,22 @@ impl Encode for RegisterInfo {
105
105
attributes : HashMap :: new ( ) ,
106
106
children : vec ! [
107
107
new_element( "name" , Some ( self . name. clone( ) ) ) ,
108
- new_element( "description" , Some ( self . description. clone( ) ) ) ,
109
108
new_element(
110
109
"addressOffset" ,
111
110
Some ( format!( "0x{:x}" , self . address_offset) ) ,
112
111
) ,
113
112
] ,
114
113
text : None ,
115
114
} ;
116
-
115
+ match self . description {
116
+ Some ( ref v) => {
117
+ elem. children . push ( new_element (
118
+ "description" ,
119
+ Some ( v. clone ( ) ) ,
120
+ ) ) ;
121
+ }
122
+ None => ( ) ,
123
+ }
117
124
match self . alternate_group {
118
125
Some ( ref v) => {
119
126
elem. children . push ( new_element (
@@ -225,7 +232,7 @@ mod tests {
225
232
alternate_group: Some ( String :: from( "alternate group" ) ) ,
226
233
alternate_register: Some ( String :: from( "alternate register" ) ) ,
227
234
derived_from: Some ( String :: from( "derived from" ) ) ,
228
- description: String :: from( "Write Control Register" ) ,
235
+ description: Some ( String :: from( "Write Control Register" ) ) ,
229
236
address_offset: 8 ,
230
237
size: Some ( 32 ) ,
231
238
access: Some ( Access :: ReadWrite ) ,
0 commit comments