Skip to content

Fix nesting derivedfrom peripherals#100

Closed
Jegeva wants to merge 6 commits intocmsis-svd:mainfrom
Jegeva:fix_nesting_derivedfrom_peripherals
Closed

Fix nesting derivedfrom peripherals#100
Jegeva wants to merge 6 commits intocmsis-svd:mainfrom
Jegeva:fix_nesting_derivedfrom_peripherals

Conversation

@Jegeva
Copy link
Copy Markdown

@Jegeva Jegeva commented Mar 2, 2020

Paul

fixed for peripherals (for which i had a test case),

while i was in : also fixed for registers, register clusters and register cluster arrays
BUT there is no test case for this, do you have something ?

you weren't accounting for nesting so i recursed a bit

@Jegeva
Copy link
Copy Markdown
Author

Jegeva commented Mar 2, 2020

sorry for the slightly chaotic commit history, it's midnight here


def _lookup_possibly_derived_attribute(self, attr):
derived_from = self.get_derived_from()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove superfluous whitespace.

if(f.get_derived_from() == None):
return f
else:
return f.get_derived_from()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is, this will raise a different exception in the case that would have previously raised a KeyError. I suggest the following as an alternative that maintains the existing behavior. This also avoid multiple calls to get_derived_from() which might recurse on that path (not expecting that performance would be worth concerning ourself with too much but it exists):

        for field in self.parent.fields:
            if field.name == self.derived_from:
                next_level_derive = field.get_derived_from()
                return next_level_derive if next_level_derive else field

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello paul, as i just ran it on the whole corpus of data as-is and it doesn't raise any exception for me, on which file do you have that ?

@posborne
Copy link
Copy Markdown
Collaborator

posborne commented Mar 3, 2020

Logic of change looks good; if you agree please incorporate the proposed simplification and then squash your commits down to clean up the history. Two commits are fine with the first being the failing test addition followed by the changes to support derivative recursion.

@posborne posborne mentioned this pull request Mar 3, 2020
@Jegeva
Copy link
Copy Markdown
Author

Jegeva commented Mar 19, 2020

just saw your answer, will take care of that tomorrow

@pengi
Copy link
Copy Markdown

pengi commented May 9, 2023

How's the progress of this PR?

I ran in to the problem of register clusters not being propagated through derivedFrom, and was thinking of fixing it and making a PR myself when I found this one.

@posborne
Copy link
Copy Markdown
Collaborator

posborne commented Oct 6, 2023

Closing in favor of #172

@posborne posborne closed this Oct 6, 2023
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 this pull request may close these issues.

3 participants