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

The Refactor #46

Closed
ryankurte opened this Issue Mar 6, 2018 · 10 comments

Comments

Projects
None yet
3 participants
@ryankurte
Copy link
Collaborator

ryankurte commented Mar 6, 2018

We have a few outstanding issues that to move forward with could use a refactor of the existing codebase.

Issues:

Proposal

Things to do and PRs to accept. I'll update this list from any discussion in this issue to reflect our plan and progress.

Project Level

  1. Introduce Error types for svd decoding (@Emilgardis?)
  2. Introduce Encode and Decode traits for svd objects (@ryankurte?)
  3. Refactor all svd objects (anyone and everyone)

Once we've defined Error types and Encode/Decode traits the refactoring part should be reasonably simple, and we can accept a PR for each to avoid nightmare refactoring.

For each SVD object (ie. object implementing an SVD element)

  1. Move from src/lib.rs to srv/svd/object.rs and add pub mod object; to src/svd/mod.rs
  2. Update decode method to match Decode trait (and add error handling)
  3. Create encode method to match Encode trait (svd#37 has many pre-written)
  4. Add tests for encoding and decoding each variant for an object.

I propose that we put a freeze on changes to master while undertaking this and make these changes against a refactor branch until we reach stability again, then merge back to master in what is bound to be a spectacularly breaking change.

@Emilgardis

This comment has been minimized.

Copy link
Collaborator

Emilgardis commented Mar 6, 2018

Looks good, I have some thoughts however.
First, I don't think a new branch is needed for refactoring.

I also believe making the structure of the project src/svd/object.rs is a better idea than having loose files in src/

Also, just to be clear, when you say SVD object, you mean the structs in lib.rs relating to elements in the SVD spec right?


I'll make a pr on my branch to help advance this, I do agree that this is what needs to happen.

@ryankurte

This comment has been minimized.

Copy link
Collaborator Author

ryankurte commented Mar 6, 2018

On thinking more it's probably simpler to interleave PRs without having a new branch, so I agree.
Also totally happy with that layout, and yep though I'm not sure how to put that more succinctly right now? Can easily add an example for clarity though.

@Emilgardis

This comment has been minimized.

Copy link
Collaborator

Emilgardis commented Mar 17, 2018

Work on this is now done on https://github.com/japaric/svd/tree/refactor

@musitdev

This comment has been minimized.

Copy link

musitdev commented Mar 27, 2018

I can help to do the refactor when error and Encode/Decode task is done.

@ryankurte

This comment has been minimized.

Copy link
Collaborator Author

ryankurte commented Mar 30, 2018

Finished splitting the modules out into separate files and throwing the interfaces together.
Also moved the get_ methods to ElementExt as discussed on IRC (better @Emilgardis?).

There's also the issue of some types returning arrays of objects, for which we could either introduce an EncodeArray trait or add a merge(&self, e: &Element) function to ElementExt that adds the children of the provided element to self?

Still need Encode implementations along with tests for a number of the SVD objects and to clean out the last of the assert! macros, and would be happy to accept any PRs towards this @musitdev!.

@Emilgardis

This comment has been minimized.

Copy link
Collaborator

Emilgardis commented May 30, 2018

ping @ryankurte are you still working on this?

I can probably pick this up again this weekend, I'm not 100% however on what exactly is left to do.

@ryankurte

This comment has been minimized.

Copy link
Collaborator Author

ryankurte commented Jun 1, 2018

I haven't had a chance recently, but still hoping to. Definitely not this weekend though.

Outstanding as far as I can remember:

  • a decision about how to encode objects that are just a set of attributes and/or vectors of objects
    • we could have additional traits to unify it, or just implement methods for now and update them later
  • a bunch of Encode implementations are missing implementations
  • a bunch of objects are missing encode/decode tests.

I just had a skim through and added TODO where there are bits missing, so find all should highlight everything that's left.

@ryankurte

This comment has been minimized.

Copy link
Collaborator Author

ryankurte commented Aug 23, 2018

I've done most of the refactoring bits, but a lot of encode work to do still.

How would y'all feel about putting encode behind an unproven feature gate so we can get back to master / a state we can release from, and work on encoding and testing bit by bit?

@Emilgardis

This comment has been minimized.

Copy link
Collaborator

Emilgardis commented Aug 27, 2018

I would be okay with that approach. Having the error handling and getting rust-embedded/svd2rust#193 implemented is something we've been waiting on for a while.

@Emilgardis

This comment has been minimized.

Copy link
Collaborator

Emilgardis commented Sep 4, 2018

#53 is merged 🎉 , closing issue.

@Emilgardis Emilgardis closed this Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.