@@ -5,12 +5,15 @@ use std::path::PathBuf;
55
66#[ derive( Debug , Clone ) ]
77pub struct LoadSettings {
8+ pub add_backing_regions : bool ,
89 pub add_bitfields : bool ,
910 pub add_comments : bool ,
1011 pub auto_load_file : Option < PathBuf > ,
1112}
1213
1314impl LoadSettings {
15+ pub const ADD_BACKING_REGIONS_DEFAULT : bool = true ;
16+ pub const ADD_BACKING_REGIONS_SETTING : & ' static str = "analysis.svd.addBackingRegions" ;
1417 pub const ADD_BITFIELDS_DEFAULT : bool = true ;
1518 pub const ADD_BITFIELDS_SETTING : & ' static str = "analysis.svd.addBitfields" ;
1619 pub const ADD_COMMENTS_DEFAULT : bool = true ;
@@ -21,6 +24,15 @@ impl LoadSettings {
2124 pub fn register ( ) {
2225 let bn_settings = Settings :: new ( ) ;
2326
27+ let add_backing_region_props = json ! ( {
28+ "title" : "Add Backing Regions" ,
29+ "type" : "boolean" ,
30+ "default" : Self :: ADD_BACKING_REGIONS_DEFAULT ,
31+ "description" : "Whether to add backing regions. Backing regions allow you to write to the underlying memory of a view, but will take up space in the BNDB." ,
32+ } ) ;
33+ bn_settings
34+ . register_setting_json ( Self :: ADD_BACKING_REGIONS_SETTING , add_backing_region_props. to_string ( ) ) ;
35+
2436 let add_bitfields_props = json ! ( {
2537 "title" : "Add Bitfields" ,
2638 "type" : "boolean" ,
@@ -53,6 +65,10 @@ impl LoadSettings {
5365 let mut load_settings = LoadSettings :: default ( ) ;
5466 let settings = Settings :: new ( ) ;
5567 let mut query_opts = QueryOptions :: new_with_view ( view) ;
68+ if settings. contains ( Self :: ADD_BACKING_REGIONS_SETTING ) {
69+ load_settings. add_backing_regions =
70+ settings. get_bool_with_opts ( Self :: ADD_BACKING_REGIONS_SETTING , & mut query_opts) ;
71+ }
5672 if settings. contains ( Self :: ADD_BITFIELDS_SETTING ) {
5773 load_settings. add_bitfields =
5874 settings. get_bool_with_opts ( Self :: ADD_BITFIELDS_SETTING , & mut query_opts) ;
@@ -76,6 +92,7 @@ impl LoadSettings {
7692impl Default for LoadSettings {
7793 fn default ( ) -> Self {
7894 Self {
95+ add_backing_regions : Self :: ADD_BACKING_REGIONS_DEFAULT ,
7996 add_bitfields : Self :: ADD_BITFIELDS_DEFAULT ,
8097 add_comments : Self :: ADD_COMMENTS_DEFAULT ,
8198 auto_load_file : None ,
0 commit comments