libnvme: replace accessor generator with Python and add in-source ann…#3196
Merged
igaw merged 1 commit intolinux-nvme:masterfrom Mar 18, 2026
Merged
Conversation
…otations
The generate-accessors tool has been rewritten in Python
(generate-accessors.py) and the mechanism for controlling which structs
and members get accessors has moved from separate list files to in-source
annotations in the header files themselves.
Struct inclusion is now opt-in via an annotation on the opening brace:
struct nvme_ctrl { /*!generate-accessors*/
Members can be excluded or made read-only via per-member annotations:
char *state; //!accessors:none
char *firmware; //!accessors:readonly
Both /* */ and // comment styles are accepted for all annotations.
This replaces the generate-accessors-include.list and
generate-accessors-exclude.list files, which are no longer needed.
The annotations are co-located with the struct definitions, making it
immediately visible from the header which structs and members are
covered and why.
The Python rewrite is significantly shorter (~350 lines vs ~2100) and
handles the annotation-before-comment-stripping requirement naturally,
whereas the C implementation would have required keeping a raw copy of
each struct body in parallel with the comment-masked version.
private.h is updated with the equivalent annotations that were
previously expressed through the now-deleted list files.
meson.build and update-accessors.sh are updated accordingly.
The --incl and --excl CLI options are removed as they are superseded
by annotations.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
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.
…otations
The generate-accessors tool has been rewritten in Python (generate-accessors.py) and the mechanism for controlling which structs and members get accessors has moved from separate list files to in-source annotations in the header files themselves.
Struct inclusion is now opt-in via an annotation on the opening brace:
Members can be excluded or made read-only via per-member annotations:
Both /* */ and // comment styles are accepted for all annotations.
This replaces the generate-accessors-include.list and generate-accessors-exclude.list files, which are no longer needed. The annotations are co-located with the struct definitions, making it immediately visible from the header which structs and members are covered and why.
The Python rewrite is significantly shorter (~350 lines vs ~2100) and handles the annotation-before-comment-stripping requirement naturally, whereas the C implementation would have required keeping a raw copy of each struct body in parallel with the comment-masked version.
private.h is updated with the equivalent annotations that were previously expressed through the now-deleted list files.
meson.build and update-accessors.sh are updated accordingly. The --incl and --excl CLI options are removed as they are superseded by annotations.