Skip to content

tool(cleanup): add sdf_parse_attribute() functions to decrease duplication - #592

Open
midnightveil wants to merge 7 commits into
mainfrom
julia/parsing-cleanup
Open

tool(cleanup): add sdf_parse_attribute() functions to decrease duplication#592
midnightveil wants to merge 7 commits into
mainfrom
julia/parsing-cleanup

Conversation

@midnightveil

@midnightveil midnightveil commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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.

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>
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.

sdf parsing should be consistent with integer parsing

1 participant