Skip to content

Order of replace_suffix and to_sanitized_snake_case #563

Closed
@duskmoon314

Description

@duskmoon314

Currently in the register.rs, replace_suffix is executed after to_sanitized_snake_case:

# line 443, 808
&util::replace_suffix(&f.name.to_sanitized_snake_case(), suffix),

Thus when facing an svd file like this will generate pX_pwr_mod_sel

<field>
  <dim>5</dim>
  <dimIncrement>1</dimIncrement>
  <dimIndex>C,D,E,F,G</dimIndex>
  <name>P%s_PWR_MOD_SEL</name>
  <description>PX_POWER POWER MODE Select</description>
  <bitRange>[2:2]</bitRange>
</field>
    #[doc = "Bit 2 - PX_POWER POWER MODE Select"]
    #[inline(always)]
    pub fn pC_pwr_mod_sel(&self) -> P_PWR_MOD_SEL_R {
        P_PWR_MOD_SEL_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 3 - PX_POWER POWER MODE Select"]
    #[inline(always)]
    pub fn pD_pwr_mod_sel(&self) -> P_PWR_MOD_SEL_R {
        P_PWR_MOD_SEL_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bit 4 - PX_POWER POWER MODE Select"]
    #[inline(always)]
    pub fn pE_pwr_mod_sel(&self) -> P_PWR_MOD_SEL_R {
        P_PWR_MOD_SEL_R::new(((self.bits >> 4) & 0x01) != 0)
    }
    #[doc = "Bit 5 - PX_POWER POWER MODE Select"]
    #[inline(always)]
    pub fn pF_pwr_mod_sel(&self) -> P_PWR_MOD_SEL_R {
        P_PWR_MOD_SEL_R::new(((self.bits >> 5) & 0x01) != 0)
    }
    #[doc = "Bit 6 - PX_POWER POWER MODE Select"]
    #[inline(always)]
    pub fn pG_pwr_mod_sel(&self) -> P_PWR_MOD_SEL_R {
        P_PWR_MOD_SEL_R::new(((self.bits >> 6) & 0x01) != 0)
    }

Should we replace the suffix before converting the name to snake case? Or have I made a mistake and this is exactly the desired behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions