@@ -18,7 +18,7 @@ impl FromStr for InputFormat {
1818 "svd" | "SVD" | "xml" | "XML" => Ok ( Self :: Xml ) ,
1919 "yml" | "yaml" | "YAML" => Ok ( Self :: Yaml ) ,
2020 "json" | "JSON" => Ok ( Self :: Json ) ,
21- _ => return Err ( anyhow ! ( "Unknown input file format" ) ) ,
21+ _ => Err ( anyhow ! ( "Unknown input file format" ) ) ,
2222 }
2323 }
2424}
@@ -38,7 +38,7 @@ impl FromStr for OutputFormat {
3838 "svd" | "SVD" | "xml" | "XML" => Ok ( Self :: Xml ) ,
3939 "yml" | "yaml" | "YAML" => Ok ( Self :: Yaml ) ,
4040 "json" | "JSON" => Ok ( Self :: Json ) ,
41- _ => return Err ( anyhow ! ( "Unknown output file format" ) ) ,
41+ _ => Err ( anyhow ! ( "Unknown output file format" ) ) ,
4242 }
4343 }
4444}
@@ -61,14 +61,18 @@ impl FromStr for ConfigFormat {
6161 }
6262}
6363
64+ pub struct ParserConfig {
65+ pub expand : bool ,
66+ pub expand_properties : bool ,
67+ pub ignore_enums : bool ,
68+ }
69+
6470pub fn convert (
6571 in_path : & Path ,
6672 out_path : & Path ,
6773 input_format : Option < InputFormat > ,
6874 output_format : Option < OutputFormat > ,
69- expand : bool ,
70- expand_properties : bool ,
71- ignore_enums : bool ,
75+ parser_config : ParserConfig ,
7276 format_config : Option < & Path > ,
7377) -> Result < ( ) > {
7478 let input_format = match input_format {
@@ -92,15 +96,15 @@ pub fn convert(
9296 let mut device = match input_format {
9397 InputFormat :: Xml => svd_parser:: parse_with_config (
9498 & input,
95- & svd_parser:: Config :: default ( ) . ignore_enums ( ignore_enums) ,
99+ & svd_parser:: Config :: default ( ) . ignore_enums ( parser_config . ignore_enums ) ,
96100 ) ?,
97101 InputFormat :: Yaml => serde_yaml:: from_str ( & input) ?,
98102 InputFormat :: Json => serde_json:: from_str ( & input) ?,
99103 } ;
100- if expand_properties {
104+ if parser_config . expand_properties {
101105 svd_parser:: expand_properties ( & mut device) ;
102106 }
103- let device = if expand {
107+ let device = if parser_config . expand {
104108 svd_parser:: expand ( & device) ?
105109 } else {
106110 device
0 commit comments