tool(cleanup): add sdf_parse_attribute() functions to decrease duplication - #592
Open
midnightveil wants to merge 7 commits into
Open
tool(cleanup): add sdf_parse_attribute() functions to decrease duplication#592midnightveil wants to merge 7 commits into
sdf_parse_attribute() functions to decrease duplication#592midnightveil wants to merge 7 commits into
Conversation
Let's stop duplicating all the `sdf_parse_number` checks around everywhere. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Somehow this was missed, so this would instead fail at runtime. Add tests to check this. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Stop duplicating this logic everywhere. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Implement the IsNum trait via a macro to stop duplicating the same code so often. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Previously, this was using `::parse<i64>()` or `::parse<u64>()` which will panic with no nice error message. The code surrounding these should be refactored too, as the checks about "> 0" and range checks can be done as helpers. This is done as a later commit, for now, it is left as 'i64' and casts are done later. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This allows arbitrary types to work and be parsed without needing to duplicate the code for each type. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This means we can use the sdf_parse_attribute** functions for PCI devices, which cleans up some code. Not sure of the best way to deal with IommuDeviceIdentifier however in this framework. I think if I passed "config" to parse then it might make more sense, but that means I need an extra argument for all sdf_parse_attribute calls. Unless it forms a part of the SystemDescription struct which currently only contains a file, which might be a good idea. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please review commit by commit.
Fixes #537.
This removes a lot of the number/bool/etc parsing logic that exists in every single sdf file, instead separating out into helper functions.
Something that could be maybe done, but hasn't been, is adding support for parsing numbers in a valid range.