The GitHub Actions job "mainline-only" on tvm-ffi.git/main has succeeded.
Run started by GitHub user junrushao (triggered by junrushao).

Head commit for run:
b2c7712d1fca9ac591dcaa93af6a2884bbaf6ff9 / Junru Shao <[email protected]>
feat(abi): generate layout-compatible C++ object declarations (#670)

## Summary

- Add `tvm_ffi.dataclasses.gen_abi_cpp` to generate self-contained,
lookup-only C++17 object declarations from registered reflection
metadata.
- Preserve reflected inheritance and layout across native,
Python-defined, recursive, and mutually recursive object types,
including `ObjectPtr<TObject>` container fields.
- Expose `tvm::ffi::is_object_subclass_v` as the shared complete-type
query and explicit specialization point for generated incomplete object
declarations.
- Extend reflection metadata and C++ lookup helpers enough to validate
carriers and emit compile-time size, alignment, and field-offset
assertions.
- Add frozen presentation support for C++-reflected dataclass fields and
keep generator regression fixtures collectable on Python 3.9.

## Architecture

- Expand exact or globbed type-key selectors through their dynamic
object ancestry, lower reflected fields to ABI-compatible C++ carriers,
and emit deterministically grouped namespaces and declarations.
- Generate lookup-only views that read existing registered objects
without registering types, allocating objects, or changing the C ABI.
- Add `TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP` for cached runtime type-index
lookup.
- Move `is_object_subclass_v` to public `tvm::ffi`, retain it as the
gate for `TypeTraits<ObjectPtr<T>>`, and have generated headers emit
direct inline explicit specializations after forward declarations.
- Specialize only genuinely incomplete recursive types in handwritten
compile tests; complete object types continue through the primary
`std::is_base_of_v` definition.
- Expose field alignment, static type indices, total size,
native-metadata availability, and schema subtype relationships through
Python reflection so generation can prove layout and inheritance
compatibility.
- Match derived-field placement to Microsoft and Itanium-family
tail-padding rules while preserving upstream `ObjectPtr`,
`WeakObjectPtr`, container, hashing, and subsumption behavior.

## Public Interfaces

- Export `tvm_ffi.dataclasses.gen_abi_cpp`, accepting an exact type key,
shell-style pattern, or sequence of selectors and returning C++17 header
source.
- Add `TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP` to the public C++ headers.
- Expose `tvm::ffi::is_object_subclass_v` as the public object-subclass
query and customization point for intentionally declared incomplete
`Object` types.
- Expose `TypeSchema.is_subtype_of`, `TypeField.alignment`,
`TypeField.field_static_type_index`, and `TypeInfo.total_size` in Python
reflection.
- Add the optional `frozen` parameter to `c_class` for read-only
presentation of C++-reflected fields.
- Preserve established `ObjectPtr<TBase>` construction and assignment
from `ObjectPtr<TSub>`.

## UI/UX

- None.

## Behavioral Changes

- Generate inheritance-preserving declarations with escaped non-C++
identifiers, opaque dependencies, deterministic namespace ordering, and
typed `ObjectPtr` carriers where reflection proves the object type.
- Emit direct inline `is_object_subclass_v` specializations for
generated forward declarations instead of a dedicated macro.
- Use erased `ObjectPtr<Object>` carriers for schema-less custom object
fields.
- Reject unsafe native aliases, ambiguous `Optional` or `Union`
carriers, unsupported static objects, unmatched selectors, and native
types without fixed size metadata.
- Place Python-defined subclass fields at ABI-correct tail-padding
offsets on Windows and Itanium-family platforms.
- Support reflection-based subtype checks and frozen reflected C++
fields with an explicit descriptor-level mutation escape hatch.
- Preserve backing-object identity across tested object-pointer
container covariance and erased-value round trips.
- Spell runtime-resolved generator test unions with `typing.Optional`
and `typing.Union` so Python 3.9 can collect the complete generator test
file.

## Breaking Changes

- None. The feature is additive and does not alter the C ABI, registered
object layout, or existing object-pointer conversion behavior.

## Docs

- Document `c_class(..., frozen=True)`, read-only reflected fields,
inheritance behavior, and the controlled descriptor `set` escape hatch
in the dataclass reflection guide.
- Document `gen_abi_cpp` selector, output, and non-mutating semantics in
its exported function docstring; no separate generator walkthrough is
included.
- Document the public `is_object_subclass_v` query and lookup-only
metadata macro inline in the C++ headers.

## Tests

- Compiler probe without incomplete-type specialization — failed on
`std::is_base_of` as expected.
- Compiler probe with explicit `is_object_subclass_v` specialization —
passed.
- C++ build and full CTest suite — build passed; all 451 enabled tests
passed and 2 remained disabled.
- Full generator test file under the normal development Python — 14
passed.
- Full generator test file under isolated Python 3.9 — 14 passed.
- Full Python unit suite before the review-driven specialization update
— 2,393 passed, 18 skipped, 3 xfailed.
- Pre-commit on all files — passed all hooks.
- Pinned clang-tidy 21.1.1 on `tests/cpp/test_abi_object.cc`,
`tests/cpp/test_object_ptr.cc`, and `tests/cpp/test_any.cc` — passed.
- `git diff --check` — passed.
- Rust tests were not run because Cargo and Rustup are unavailable
locally.

## Untested Edge Cases

- The complete Python suite was not rerun after the review-driven C++
specialization/output update; both development and Python 3.9 generator
suites cover the changed generated text and compilation path.
- Rust workspace tests remain unexecuted locally; no Rust source or
binding is modified.
- Linux and Windows compiler matrices remain CI-only. Local
generated-header compilation and platform-conditional layout tests cover
the paths available on macOS; CI supplies cross-platform ABI
confirmation.

Report URL: https://github.com/apache/tvm-ffi/actions/runs/29472268194

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to