[WIP] Adding encode functions to SVD elements#37
[WIP] Adding encode functions to SVD elements#37ryankurte wants to merge 26 commits intorust-embedded:masterfrom
Conversation
src/enumeratedvalue.rs
Outdated
| pub value: Option<u32>, | ||
| pub is_default: Option<bool>, | ||
| // Reserve the right to add more fields to this struct | ||
| pub _extensible: (), |
There was a problem hiding this comment.
making _extensible field public kinda defeats the purpose.
There was a problem hiding this comment.
Hey, thanks for the review!
Ahh, yeah. I couldn't work out how to initialise an object with private fields / didn't find anything with wild googling.
The best solution I came up with was to create new constructors for each object, is that the best way to keep it hidden?
|
Sorry, i don't know the best solution here. btw, thank you for working on this, i'd be happy to go back to the upstream library when it gets serialization support. |
Should probably consider how to have a more common set of tests for each module
|
Running out of steam, but, almost there... A few of notes. I have split out and implemented encoding + tests for pretty much everything now, there are rather a lot of changes :-/ This could (in future) be lossless so that encode == decode, for now the encoding is opinionated based on the file I was looking at at the time. This also might be nicer because all our processed files would then follow the same output standard. I haven't yet gone through and written default constructors to fix the There's a repeated custom Types now all implement |
…ences in vendor formatting for files but apart from that seems to be working
Added derivedFrom attribute to peripheral outputs
|
☔ The latest upstream changes (presumably cd5aefa) made this pull request unmergeable. Please resolve the merge conflicts. |
|
That's uhh, more than a small merge conflict :-/ I have removed and re-added the changes because it's so heavily diverged, and it almost builds again except for an equality (and uh, recursion?) issue I am not sure about. It also has no tests / doesn't encode the new types. Would you be willing to merge a partial WIP once it's building again (even into a develop branch or something)? I guess it's deserved for opening such a big PR, but I /really/ don't want to have to do anything like this again. |
|
@ryankurte thanks for working on this. I've been wanting to rewrite / refactor this crate for a while since it's kind of a mess and it's lacking proper error handling. Regarding
|
|
Proper error handling is definitely a need, i'm not totally sure I follow your example, but bubbling errors up seems like it shouldn't be super difficult / mostly requires the addition of result to the parse / encode types. I implemented the parse/encode traits with an eye to the possibility of moving it over to a serde custom serialisation, which would take care of a bunch of the error handling stuff and reduce the amount of code I think. There is an XML implementation, but it's missing a bunch of the features we need (like attributes) atm. Both are things I would be happy to try / work on down the track, but, I really don't want to keep growing this PR. That last merge back from master was a bit ghastly 😂 I ripped try! out into a separate file for now so it's not duplicated everywhere, presumably we can drop it when we push error handling through. Constructors / builders seem reasonable, I can add that / it should clean up some of the internal logic too I think. The Uint struct is an experiment relating to a decision that needs to be made about whether encoding / decoding is lossless or not. If we want parse/encode to output the same file, we need to keep track of the underlying value formats in the xml files. I was trying not to / don't think I have broken the API, but, given the previous one had no tests I can't really say that I didn't :-/ So my TODOs to get this merged are:
Anything missing from that list? |
|
Added a test and tried to rebuild svd2rust but it's broken with the latest version because of the PR that was conflicting with this :-/ |
|
☔ The latest upstream changes (presumably #42) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Bump. The things implemented here are:
This PR is probably way too out of date to rebase with all the changes that've made it in ahead, but, if we still want components of this I can rework them and open separate PRs? My proposal would be that each component gets a PR that:
That way any collisions will only be with one source file at a time, and refactoring around it should be less of a nightmare. Any thoughts @japaric @pftbest @Emilgardis? |
|
I'll think this is a good idea. I do however suggest that we in between 1 and 2 (or maybe even before) squeeze in error handling. I have a branch where I'm testing this. |
|
Seems sensible, though we could just apply your error handling branch prior to doing this work? |
Work in progress, adding encode functions to SVD elements to allow exporting of optimised / modified SVD files. Also probably worth neatening up some of the parse/encode functions.
This is a step towards svd2rust#96.
@japaric do you have any thoughts / are you happy with an approach like this?