junrushao opened a new pull request, #664:
URL: https://github.com/apache/tvm-ffi/pull/664
Architecture:
- Replace separate enum-entry and attribute columns with one EnumState object
containing ordered entries, canonical indexes, and extensible attributes.
- Introduce native IntEnum and StrEnum bases and route lookup, conversion,
copy,
and serialization through a single canonical singleton registry.
- Reuse the dataclass reflection path for payload fields while preserving
enum
identity as a unique-instance structural kind.
Public Interfaces:
- Add EnumState, IntEnum, and StrEnum native object/reference types.
- Replace EnumObj _value/_name storage and Get lookup with canonical
_int_index/_str_index fields and typed index lookup helpers.
- Consolidate enum reflection metadata under the __ffi_enum__ state attribute
and require explicit signed integer indexes for native integer enums.
UI/UX:
- None.
Behavioral Changes:
- Enum copies and JSON graph round trips resolve to registered singletons.
- Payload enums normalize reflected fields and containers without allocating
replacement enum objects.
- Enum subclasses use singleton structural equality by default.
Docs:
- Document payload fields, singleton identity, serialization, and enum
structural
equality in the dataclass and structural comparison guides.
- Low-level C++ migration details for renamed canonical fields and helpers
remain
in API comments and this commit's breaking-change note rather than a new
guide.
Tests:
- Clean editable C++/Cython build completed successfully.
- Fresh Debug tvm_ffi_tests build completed successfully.
- 599 focused enum, dataclass-copy, class, and stub-generation tests passed.
- Any.Enum and three enum serialization CTests passed (4 of 4).
- Scoped pre-commit hooks passed for all files in this boundary.
Untested Edge Cases:
- Rust bindings, Windows/MSVC, and the full cross-platform test matrix were
not
run for this intermediate boundary.
- Stub regeneration still exposes pre-existing mutable-container annotation
drift, so those unrelated generated edits are deferred.
BREAKING CHANGE: enum reflection now uses one __ffi_enum__ state with
canonical
integer and string indexes. Native callers using _value, _name, Get, or the
old
enum entry/attribute columns must migrate to _int_index, _str_index, typed
index
lookup, and EnumState, then rebuild their extensions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]