Skip to content

docs: add plans/ directory for design and implementation plans#3317

Open
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
martin-belanger:add-plans
Open

docs: add plans/ directory for design and implementation plans#3317
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
martin-belanger:add-plans

Conversation

@martin-belanger
Copy link
Copy Markdown

@martin-belanger martin-belanger commented Apr 24, 2026

Add initial design plan (v10) under plans/

This adds the current design/implementation plan for the Python bindings + accessor refactor under plans/.

@dwsuse - You previously reviewed an earlier version (v6). This update reflects a few targeted refinements rather than a redesign:


Key changes from v6 → v10

1) SWIG Access model (main change)

  • v6: all access via accessors
  • v10: per-field access
    • generated → direct struct access (p->member)
    • custom → accessor function
    • none → no access

Rationale: generated accessors are trivial; custom accessors handle the real logic.


2) Removed !access:nested

  • No longer needed
  • Nested structs accessed directly (e.g. &fctx->cfg)

3) Generated setter semantics (updated)

  • write=generated is allowed for all supported types
  • Behavior is type-aware:
    • scalar → direct assignment
    • char *free + strdup

Rationale: allows safe generation while keeping special cases in custom when needed.


4) Lifecycle annotation (new)

  • Added struct-level lifecycle control:

    • !generate-lifecycle=generated
    • !generate-lifecycle=custom
    • (absence ⇒ no lifecycle)
  • Generated lifecycle:

    • constructor: alloc + init + apply defaults
    • destructor: free owned members (e.g. char *) + struct

Rationale: makes ownership and allocation explicit and generator-driven.


5) Generator + typemap alignment

  • Direct access for generated
  • Accessors only for custom
  • %immutable for write=none

6) Invariants clarified
A field is exposable if it has a usable access path:
read != none or write != none


Everything else (dict-based API, callbacks, lifetime model, generator structure, etc.) remains unchanged.


The goal of these changes is to simplify the bindings, reduce unnecessary indirection, and make the generator behavior more explicit and predictable.


Happy to adjust anything if you think this is going in the wrong direction.

Introduce a new top-level `plans/` directory to host design and
implementation plans for larger refactoring efforts.

These documents capture the rationale, architecture, and step-by-step
implementation strategy for non-trivial changes before code is written.

Many of these plans are developed with the assistance of AI tools
(e.g. ChatGPT for prompt refinement/review and Claude for code analysis
and plan drafting), and then reviewed/edited by maintainers.

The goal is to:
- make design intent explicit and reviewable
- reduce iteration during implementation
- provide a reference for future contributors
- allow the flexibility of having one person draft a plan
  and pass it on to another to execute it.

No functional changes.

Signed-off-by: Martin Belanger <[email protected]>
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.

1 participant