Skip to content

Commit 213cc35

Browse files
committed
remove ArrayProxy
1 parent 035150f commit 213cc35

File tree

8 files changed

+19
-105
lines changed

8 files changed

+19
-105
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- { rust: stable, vendor: Spansion, options: "--atomics" }
7676
- { rust: stable, vendor: STMicro, options: "" }
7777
- { rust: stable, vendor: STMicro, options: "--atomics" }
78-
- { rust: stable, vendor: STM32-patched, options: "--strict --array_proxy --pascal_enum_values --max_cluster_size --atomics --atomics_feature atomics" }
78+
- { rust: stable, vendor: STM32-patched, options: "--strict --pascal_enum_values --max_cluster_size --atomics --atomics_feature atomics" }
7979
- { rust: stable, vendor: Toshiba, options: all }
8080
- { rust: stable, vendor: Toshiba, options: "" }
8181
# Test MSRV

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Use methods to access any register or cluster
1011
- Remove all deny lints from generated crate
1112
- Add `reexport_core_peripherals` and `reexport_interrupt` features disabled by default
12-
- rename `const-generic` feature to `array_proxy`
13+
- ~~rename `const-generic` feature to `array_proxy`~~ remove `ArrayProxy`
1314
- `FieldWriter` takes offset as struct field instead of const generic.
1415
Improves SVD field array access
1516
Add `width`, `offset` methods

ci/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ main() {
3131

3232
case $OPTIONS in
3333
all)
34-
options="--array_proxy --strict --atomics"
34+
options="--strict --atomics"
3535
;;
3636
*)
3737
options=$OPTIONS

src/generate/array_proxy.rs

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/generate/device.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
138138

139139
let generic_file = include_str!("generic.rs");
140140
let generic_atomic_file = include_str!("generic_atomic.rs");
141-
let array_proxy = include_str!("array_proxy.rs");
142141
if config.generic_mod {
143142
let mut file = File::create(config.output_dir.join("generic.rs"))?;
144143
writeln!(file, "{generic_file}")?;
@@ -148,9 +147,6 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
148147
}
149148
writeln!(file, "\n{generic_atomic_file}")?;
150149
}
151-
if config.array_proxy {
152-
writeln!(file, "{array_proxy}")?;
153-
}
154150

155151
if !config.make_mod {
156152
out.extend(quote! {
@@ -168,9 +164,6 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
168164
}
169165
syn::parse_file(generic_atomic_file)?.to_tokens(&mut tokens);
170166
}
171-
if config.array_proxy {
172-
syn::parse_file(array_proxy)?.to_tokens(&mut tokens);
173-
}
174167

175168
out.extend(quote! {
176169
#[allow(unused_imports)]

src/generate/peripheral.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use quote::{quote, ToTokens};
1515
use syn::{punctuated::Punctuated, Token};
1616

1717
use crate::util::{
18-
self, array_proxy_type, name_to_ty, path_segment, type_path, unsuffixed, Config, FullName,
18+
self, name_to_ty, path_segment, type_path, unsuffixed, zst_type, Config, FullName,
1919
ToSanitizedCase, BITS_PER_BYTE,
2020
};
2121
use anyhow::{anyhow, bail, Context, Result};
@@ -1040,7 +1040,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
10401040

10411041
let array_convertible = sequential_addresses && convert_list;
10421042

1043-
if array_convertible || config.array_proxy {
1043+
if !convert_list {
10441044
let span = Span::call_site();
10451045
let nb_name_sc = if let Some(dim_name) = array_info.dim_name.as_ref() {
10461046
dim_name.to_snake_case_ident(span)
@@ -1095,15 +1095,12 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
10951095
);
10961096
}
10971097
}
1098-
let syn_field = if array_convertible {
1099-
let array_ty = new_syn_array(ty, array_info.dim);
1100-
new_syn_field(nb_name_sc, array_ty)
1098+
let array_ty = if array_convertible {
1099+
new_syn_array(ty, array_info.dim)
11011100
} else {
1102-
// Include a ZST ArrayProxy giving indexed access to the
1103-
// elements.
1104-
let ap_path = array_proxy_type(ty, array_info);
1105-
new_syn_field(ty_name.to_snake_case_ident(Span::call_site()), ap_path)
1101+
zst_type()
11061102
};
1103+
let syn_field = new_syn_field(nb_name_sc, array_ty);
11071104
cluster_expanded.push(RegisterBlockField {
11081105
syn_field,
11091106
offset: info.address_offset,
@@ -1226,7 +1223,7 @@ fn expand_register(
12261223
let array_proxy_convertible = ac && disjoint_sequential_addresses;
12271224
let ty = name_to_ty(&ty_name);
12281225

1229-
if array_convertible || (array_proxy_convertible && config.array_proxy) {
1226+
if array_convertible || array_proxy_convertible {
12301227
let span = Span::call_site();
12311228
let nb_name_sc = if let Some(dim_name) = array_info.dim_name.as_ref() {
12321229
util::fullname(dim_name, &info.alternate_group, config.ignore_groups)
@@ -1287,7 +1284,7 @@ fn expand_register(
12871284
let array_ty = if array_convertible {
12881285
new_syn_array(ty, array_info.dim)
12891286
} else {
1290-
array_proxy_type(ty, array_info)
1287+
zst_type()
12911288
};
12921289
let syn_field = new_syn_field(nb_name_sc, array_ty);
12931290
register_expanded.push(RegisterBlockField {

src/main.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ fn run() -> Result<()> {
7979
.action(ArgAction::Set)
8080
.value_name("FEATURE"),
8181
)
82-
.arg(
83-
Arg::new("array_proxy")
84-
.long("array_proxy")
85-
.action(ArgAction::SetTrue)
86-
.help(
87-
"Use ArrayProxy helper for non-sequential register arrays",
88-
),
89-
)
9082
.arg(
9183
Arg::new("ignore_groups")
9284
.long("ignore_groups")

src/util.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::borrow::Cow;
22

3-
use crate::svd::{Access, Device, DimElement, Field, RegisterInfo, RegisterProperties};
3+
use crate::svd::{Access, Device, Field, RegisterInfo, RegisterProperties};
44
use html_escape::encode_text_minimal;
55
use inflections::Inflect;
66
use proc_macro2::{Ident, Span, TokenStream};
@@ -10,8 +10,7 @@ use std::path::{Path, PathBuf};
1010
use svd_rs::{MaybeArray, Peripheral, PeripheralInfo};
1111

1212
use syn::{
13-
punctuated::Punctuated, token::PathSep, AngleBracketedGenericArguments, GenericArgument, Lit,
14-
LitInt, PathArguments, PathSegment, Token, Type, TypePath,
13+
punctuated::Punctuated, token::PathSep, Lit, LitInt, PathArguments, PathSegment, Type, TypePath,
1514
};
1615

1716
use anyhow::{anyhow, bail, Result};
@@ -36,8 +35,6 @@ pub struct Config {
3635
#[cfg_attr(feature = "serde", serde(default))]
3736
pub make_mod: bool,
3837
#[cfg_attr(feature = "serde", serde(default))]
39-
pub array_proxy: bool,
40-
#[cfg_attr(feature = "serde", serde(default))]
4138
pub ignore_groups: bool,
4239
#[cfg_attr(feature = "serde", serde(default))]
4340
pub keep_list: bool,
@@ -118,7 +115,6 @@ impl Default for Config {
118115
atomics_feature: None,
119116
generic_mod: false,
120117
make_mod: false,
121-
array_proxy: false,
122118
ignore_groups: false,
123119
keep_list: false,
124120
strict: false,
@@ -419,30 +415,11 @@ pub fn new_syn_u32(len: u32, span: Span) -> syn::Expr {
419415
})
420416
}
421417

422-
pub fn array_proxy_type(ty: Type, array_info: &DimElement) -> Type {
423-
let span = Span::call_site();
424-
let inner_path = GenericArgument::Type(ty);
425-
let mut args = Punctuated::new();
426-
args.push(inner_path);
427-
args.push(GenericArgument::Const(new_syn_u32(array_info.dim, span)));
428-
args.push(GenericArgument::Const(syn::Expr::Lit(syn::ExprLit {
429-
attrs: Vec::new(),
430-
lit: syn::Lit::Int(hex(array_info.dim_increment as u64)),
431-
})));
432-
let arguments = PathArguments::AngleBracketed(AngleBracketedGenericArguments {
433-
colon2_token: None,
434-
lt_token: Token![<](span),
435-
args,
436-
gt_token: Token![>](span),
437-
});
438-
439-
let mut segments = Punctuated::new();
440-
segments.push(path_segment(Ident::new("crate", span)));
441-
segments.push(PathSegment {
442-
ident: Ident::new("ArrayProxy", span),
443-
arguments,
444-
});
445-
Type::Path(type_path(segments))
418+
pub fn zst_type() -> Type {
419+
Type::Tuple(syn::TypeTuple {
420+
paren_token: syn::token::Paren::default(),
421+
elems: Punctuated::new(),
422+
})
446423
}
447424

448425
pub fn name_to_ty(name: &str) -> Type {

0 commit comments

Comments
 (0)