Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"bits" is a valid field name #92

Closed
japaric opened this issue May 22, 2017 · 3 comments · Fixed by #110
Closed

"bits" is a valid field name #92

japaric opened this issue May 22, 2017 · 3 comments · Fixed by #110
Milestone

Comments

@japaric
Copy link
Member

japaric commented May 22, 2017

In that case the method to access the bitfield proxy:

peripheral.register.read().bits() // BitsR
peripheral.register.read().bits().is_variant() // bool

is ambiguous with the register method to get its raw bits

peripheral.register.read().bits()  // e.g. u8

This happens in the SKEAZN84.svd file.

@japaric japaric added this to the cmsis-svd milestone May 25, 2017
@japaric
Copy link
Member Author

japaric commented May 25, 2017

Solution

Rename R.bits to something else. The question is what should be the new name. In principle any name we pick can cause a collision in the future as register names, per the SVD specification, are as, or more, free-from than Rust identifiers.

From the schema (register names have type dimableIdentifierType):

  <xs:simpleType name="dimableIdentifierType">
    <xs:restriction base="xs:string">
      <xs:pattern value="((%s)|(%s)[_A-Za-z]{1}[_A-Za-z0-9]*)|([_A-Za-z]{1}[_A-Za-z0-9]*(\[%s\])?)|([_A-Za-z]{1}[_A-Za-z0-9]*(%s)?[_A-Za-z0-9]*)"/>
    </xs:restriction>
  </xs:simpleType>

@zargony
Copy link

zargony commented May 26, 2017

Also happened to me with ATSAM3X8E.svd. My workaround was to rename the field rather than the method (which works, but also feels wrong)

@japaric
Copy link
Member Author

japaric commented Jun 6, 2017

We can use [@whitequark's idea]](#99 (comment)) of renaming the 'bits` variant (when the enumeratedValue is named BITS) iff it would cause a collision with R.bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants