junrushao opened a new pull request, #662:
URL: https://github.com/apache/tvm-ffi/pull/662

   Architecture:
   - Make ObjectPtr<T> a first-class FFI value with retain/transfer semantics, 
runtime ancestry checks, and null-to-None encoding.
   - Normalize unqualified Object subclasses to ObjectPtr storage across Array, 
List, Map, Dict, Tuple, Optional, Variant, and Expected while preserving 
shorthand/explicit interoperability and ABI-aware covariance.
   - Add lookup-only ABI object traits, explicit logical upcasts, and 
gen_abi_cpp() to emit deterministic C++17 layout views with dependency closure 
and compile-time size, alignment, and offset validation.
   - Split py_class registration from per-owner annotation resolution so 
forward references, mixins, and mutually recursive classes resolve without 
merging inherited annotations.
   - Track reflected field alignment and static carrier metadata, match 
platform tail-padding rules, and placement-construct and destroy native object 
fields in Python-defined objects.
   - Move IntEnum and StrEnum payload storage and value lookup into native 
bases, with reflected type attributes providing conversion and JSON singleton 
restoration.
   
   Public Interfaces:
   - Add direct Any, reflected-field, parameter, and container support for 
ObjectPtr<T>. Qualified Object pointees remain unsupported, and 
Optional<ObjectPtr<T>> cannot distinguish absent from present-null over FFI.
   - Add ABIObjectTraits, abi_object_upcastable_v, upcast(), 
TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP, and TVM_FFI_DECLARE_ABI_OBJECT to the 
public C++ API.
   - Export tvm_ffi.dataclasses.gen_abi_cpp and tvm_ffi.utils.init_property.
   - Add ObjectDef::def_type_attr(), ObjectDef::def_convert<T>(), 
constant-valued TypeAttrDef::def(), and TypeAttrDef::def_convert<T>().
   - Change @py_class structural_eq from opt-in to "tree" by default; explicit 
None now opts out.
   - Make payload enum subclasses inherit ffi.IntEnum or ffi.StrEnum native 
storage and reject subclass-owned value fields.
   - Accept device strings in typed conversion, expose ancestor-aware type 
attribute lookup, and broaden generated List and Dict input annotations to 
Sequence and Mapping.
   - Keep the stable C ABI unchanged; the compatibility changes affect public 
C++ headers/templates, reflected layouts, and Python behavior.
   
   UI/UX:
   - none
   
   Behavioral Changes:
   - Preserve enum singleton identity through structural comparison, deep copy, 
JSON serialization, generated constructors, and reflected field assignment.
   - Compute init_property values once after FFI initialization, store them in 
reflected native memory, and exclude them from initialization and structural 
identity.
   - Route recognized __ffi_* hooks to type-attribute columns while allowing 
other marked FFI-prefixed and Python protocol methods.
   - Preserve nested __ffi_convert__ failures and field paths in conversion 
diagnostics, and accept internal Device and DataType carriers without wrapper 
assumptions.
   - Make FileLock report only contention as False, raise real filesystem 
errors, use explicit lock-file permissions, and measure timeouts monotonically.
   - Export ffi::Error on Windows and refine generated inline stubs and shared 
missing-value handling.
   
   Docs:
   - Document ObjectPtr ownership, container shorthand, qualifier limits, 
covariance, and null/optional semantics in the C++ language guide.
   - Document tree-by-default structural equality and explicit opt-out.
   - Document native payload-enum storage, singleton identity, deep-copy 
behavior, and scalar JSON round trips.
   - FileLock error semantics, reflection builder additions, init_property, and 
generated ABI views remain covered by API/source documentation and tests rather 
than dedicated guides.
   
   Tests:
   - Add C++ coverage for ObjectPtr ownership, conversion, reflection, 
containers, serialization, and generated ABI object views.
   - Add Python coverage for ABI header generation, py_class field resolution 
and layout, enums, structural behavior, conversion diagnostics, stubs, and 
FileLock failures and cleanup.
   - Executed for this history refactor: staged pre-commit hooks; Ruff on all 
changed Python files; ty check --error-on-warning; git diff --check.
   - Result: all executed checks passed.
   
   Untested Edge Cases:
   - The editable C++/Cython build and the C++, Python, and Rust unit suites 
were not rerun for this history-only split; the feature source tree is 
unchanged from the previously amended commit and full platform coverage remains 
a CI responsibility.
   - Windows/MSVC object layout, DLL export, and lock behavior and non-host 
architectures were not exercised locally.
   - Generated ABI views fail closed for unsupported native carriers, but 
malformed third-party reflection metadata or incorrect logical-ancestor 
declarations can still make reinterpret upcasts unsafe.
   - gen_abi_cpp targets the supported 64-bit object layout. Compile-time 
assertions detect drift, but 32-bit and exotic ABIs are not validated.
   
   BREAKING CHANGE: @py_class now uses structural_eq="tree" unless 
structural_eq=None is passed explicitly. IntEnum and StrEnum subclasses must 
stop declaring a value field and instead assign payloads through entry(value=) 
or variant literals. FileLock callers must handle RuntimeError for 
noncontention OS failures. Rebuild C++/Cython extensions and regenerate ABI 
headers so reflected offsets, enum ancestry, and native payload layout match 
the new metadata.


-- 
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]

Reply via email to