Skip to content

Commit

Permalink
forming to pass rustfmt check.
Browse files Browse the repository at this point in the history
  • Loading branch information
seisyuu-hantatsushi committed Feb 11, 2024
1 parent c7f632c commit bdc5d2f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ pub fn fields(
// if this is an enumeratedValues not derived from base, generate the enum structure
// and implement functions for each value in enumeration.
if let Some((evs, None)) = lookup_filter(&lookup_results, Usage::Read) {

// we have enumeration for read, record this. If the enumeration for write operation
// later on is the same as the read enumeration, we reuse and do not generate again.
evs_r = Some(evs);
Expand Down Expand Up @@ -872,7 +871,6 @@ pub fn fields(
// `type` code for alias of base value
// if necessary.
if let Some((evs, Some(base))) = lookup_filter(&lookup_results, Usage::Read) {

// preserve value; if read type equals write type, writer would not generate value type again
evs_r = Some(evs);

Expand Down Expand Up @@ -1428,34 +1426,36 @@ fn add_from_variants<'a>(
}
}

fn add_variant_alias(mod_items: &mut TokenStream, evs: &EnumeratedValues, base: &EnumPath, desc: &str){
let base_name = util::replace_suffix(&base.name,"");
fn add_variant_alias(
mod_items: &mut TokenStream,
evs: &EnumeratedValues,
base: &EnumPath,
desc: &str,
) {
let base_name = util::replace_suffix(&base.name, "");
let derived_name = if let Some(ref name) = &evs.name {
if let Some(ref usage) = &evs.usage {
match usage {
Usage::Read => Some(name.to_owned() + "R"),
Usage::Read => Some(name.to_owned() + "R"),
Usage::Write => Some(name.to_owned() + "W"),
Usage::ReadWrite => Some(name.to_owned()),
}
}
else {
} else {
Some(name.to_owned())
}
}
else {
} else {
None
};

if let Some(ref derived_name) = derived_name {
let span = Span::call_site();
let basetype = Ident::new(&base_name, span);
let span = Span::call_site();
let basetype = Ident::new(&base_name, span);
let derivedtype = Ident::new(&derived_name, span);
mod_items.extend(quote! {
#[doc = #desc]
pub type #derivedtype = #basetype;
});
}

}

fn calculate_offset(increment: u32, offset: u64, with_parentheses: bool) -> TokenStream {
Expand Down

0 comments on commit bdc5d2f

Please sign in to comment.