swig, generator: unify accessor annotations and add custom-access groundwork#3315
Merged
igaw merged 2 commits intolinux-nvme:masterfrom Apr 27, 2026
Merged
Conversation
igaw
reviewed
Apr 24, 2026
igaw
reviewed
Apr 24, 2026
Author
|
If it helps, we could also consider making I can make that change if you'd like. |
290e916 to
1a0ccef
Compare
Author
|
By setting the struct-level defaults I was able to reduce the number of member-level overrides. BTW, we may need to revisit the member annotations. I'm not sure that we need accessors for all of them For example, we are generating accessors for |
igaw
reviewed
Apr 27, 2026
igaw
reviewed
Apr 27, 2026
added 2 commits
April 27, 2026 09:13
Rename the member-level annotation prefix from !accessors: to !access: to decouple it from the !generate-accessors struct-level annotation. Until now, the !accessors:<value> member annotation was consumed only by the accessor generator, and its name reflected that — it read as a natural companion to the struct-level !generate-accessors annotation. That one-to-one relationship is about to change. An upcoming !generate-python struct-level annotation will also need to read the same member annotations, both to drive the generated SWIG layer and to validate consistency between the C and Python sides. The annotation is no longer the private concern of the accessor generator. Signed-off-by: Martin Belanger <Martin.Belanger@dell.com> Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
Replace the single-mode !access:<value> annotation with an orthogonal two-axis spec: !access:read=<mode>,write=<mode> where read and write are independent and each takes one of: generated (generator emits the accessor), custom (hand-written accessor in the public API, generator emits nothing), or none (no accessor exists). The same spec is accepted at the struct level via !generate-accessors:read=<mode>,write=<mode>, with per-axis inheritance from the struct-level default to member-level overrides. The new model lets downstream consumers (the Python-binding generator, the nvme.i consistency check) distinguish "no accessor" from "hand-written accessor", and cleanly expresses mixed cases such as "generated getter + hand-written setter" that the old one-dimensional annotation could not name. This is a clean break: the old :none / :readonly / :writeonly / :readwrite tokens are no longer recognised. Signed-off-by: Martin Belanger <Martin.Belanger@dell.com> Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
1a0ccef to
91ab6a9
Compare
Collaborator
|
I've just trimmed the very verbose commit message. Rest looks good. Let's fix the the comments I had on top of them. Thanks! |
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.
Summary
This PR contains two small, incremental patches that prepare the codebase for upcoming work on Python/SWIG binding generation.
The goal is to make accessor semantics explicit and machine-readable so downstream tooling can reason about read/write behavior and custom implementations.
Patch 1: Rename annotation
!accessors:*→!access:*Patch 2: Explicit access model + custom support
Introduce a unified annotation model:
!access:read=<mode>,write=<mode>!generate-accessors:read=<mode>,write=<mode>Modes:
generated,custom,noneStruct-level annotations define defaults; member-level overrides per axis
Add support in the generator
Update documentation
Annotate existing fields that already rely on custom accessors
Rationale
The previous annotation scheme could not clearly express:
This becomes important for:
These changes establish a clear and extensible model without altering existing runtime behavior.
Notes
Feedback welcome before building on top of this.