-
Notifications
You must be signed in to change notification settings - Fork 15
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
Relative parsing navigation in fdt_rs::base #10
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR - I appreciate all the included documentation! I took a quick glance and my initial thought is that I’ll probably request we create a separate ‘heavier’ iterator to handle this logic and leave the current one as super simple/lightweight one. But I’ll take time to actually review this weekend. |
Okay I took an in-depth look. I'm definitely really happy with the intent behind the extension. Thanks a bunch for contributing it! =) I agree that all the filters seem incredibly useful and the current implementation lacks necessary filters. However, I don't love the idea of modifying the base iterator to include the filters baked it. To me it seems bloat the responsibility of what ideally would be a relatively simple iterator. On the external side, it may be a little confusing to users as the type doesn't indicate what limits are associated with its iteration pattern. Additionally, since nodes rely on a copy of this iterator in order to implement their own methods. Unexpected issues could arise. E.g. I believe the I believe we could add similar functionality by creating a wrapper iterator (or collection of them) which includes all the added fields and simply uses the current implementation of |
You make a very good point. I'll try to move the complex filtering logic into separate iterators. |
This will be useful for implementing relative navigation over nodes.
I've been thinking about how to implement this with additional iterator types. But when trying out concrete ideas, it always seems to me like I need to either break API, make the APIs of the new types inconsistent to the current APIs or write a bunch of boilerplate code. The thing is, Thinking about the type-specific iterators in the context of introducing new scope-specific iterators opens up a combinatorial explosion. Because now we also need However, I don't think that paremetrization is possible without breaking API or introducing weird type aliases for backwards-compatibility. Note that While not a combinatorial explosion, implementing the four scope-specific iterators also seems like it would generate a lot of boilerplate, since we'd have to write an implementation of I guess an API compatible solution might exist, by moving the logic currently in Would you be willing to accept API breaking changes for this? If not, which of the options seems best to you, to keep API compatibility? Or maybe you have some different ideas altogether? |
c8754d7
to
299723b
Compare
Ok, I just pushed new version of my changes using new iterator types as you suggested. Feel free to ignore my previous comment about the change being complicated. I think in some regards I was overthinking things. Some points to note about the new design:
|
Pull Request Test Coverage Report for Build 3307211367Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
299723b
to
246df12
Compare
246df12
to
e79fcdd
Compare
Currently
fdt_rs::base
only allows you to extract nodes themselves and their properties, but not to interrogate the tree structure between those node.This creates a slightly awkward situation when searching for memory nodes to set up dynamic allocations. I would like to use structural information for this, because at this stage I'm only interested in memory nodes directly below the root. Not any that might be lingering around deeper into the structure. I wouldn't want to use
fdt_rs::index
, because I can't make dynamic allocations yet and creating some kind of static allocation would require me to make more assumptions about the memory layout before I can actually parse it. This can all be worked around, but I think we can do better.This branch beefs up
DevTreeIter
a little, so we can instruct it to only return nodes and props in certain scopes relative to the current position. This is used byDevTreeNode
to implement functions that can return iterators overIt's slightly awkward that we can only return siblings from the current node onward and not previous siblings. But I don't see a way to do this efficiently without allocations, as we'd have to be able to remember and jump back to an arbitrary number of points along the parsed stream.
There's another slightly awkward limitation, that we have
siblings_and_descendants
which includes the current node's descendants, but no variant of that that excludes the current nodes descendants and only returns those of the siblings. This doesn't seem straightforward to implement without introducing another state parsing flag for just this use case. Since I don't have a practical use case for this at the moment, I didn't bother too much to implement it. If desired, the missing behavior can be emulated by callingnext_sibling
on a node and then callingsiblings_and_descendants
on that.