Add `Position() int64` to the Firmware interface
Does this have something to do with the offset I calculated for the layout-table visitor ?
If so this would make the visitor easier, but all visitors that modify the firmware will have to update the fields behind that interface (probably the assemble visitor can do it for them)
@rjoleary :
Out of curiosity: why int64 (not uint64)? Do we expect negative values here?
@JulienVdG :
If so this would make the visitor easier, but all visitors that modify the firmware will have to update the fields behind that interface (probably the assemble visitor can do it for them)
Am I understand correctly it means: it will be enough to calculate the absolute offsets, store them within uefi.Firmware implementations and update only in visitors.Assemble?
@xaionaro I think so:
- an element cannot know it's own offset, it needs to get it from it's parent, so it's probably easier to store it
- the offset can be calculated when parsing, each container knowing the rules to compute the offsets (if you look at the table visitor you will see that it's not trivial).
- most visitor that modify the firmware do a call to the assemble visitor, so ensuring assemble updates the offsets could be enough
@JulienVdG : Just to keep tracking the progress:
After some discussions in Slack, we haven't reach any consensus. However the approach we are going to try is to use your code of layout-table to implement a visitor to update offsets. It seems to be less invasive than modify all the constructor functions for this one feature. It's nice when a piece logic is isolated and does not require to change other logic. And it also might essentially simplify the 3rd step (to update offsets on assemble), since it would require a visitor-y implementation anyway.