The GitHub Actions job "CI" on 
tvm-ffi.git/junrushao/2026-03-22/py-class-ffi-dunder has succeeded.
Run started by GitHub user junrushao (triggered by junrushao).

Head commit for run:
9883aa6a7dd72551aca5da63682d7591d5b091b8 / Junru Shao <[email protected]>
feat(python): auto-register `__ffi_*` dunder methods in `@py_class` as 
TypeMethod

Extend `@py_class` to detect and register recognized FFI dunder methods
(e.g. `__ffi_repr__`, `__ffi_eq__`, `__s_equal__`) defined on Python
dataclasses, making them callable from C++ and other FFI languages.

Architecture:
- `_FFI_RECOGNIZED_METHODS` allowlist in `py_class.py` gates which
  `__ffi_*` / `__s_*` / `__data_*` dunders are collected
- `_collect_py_methods()` scans the class dict and returns matching
  callables wrapped as `Function`
- `TypeInfo._register_py_methods()` registers each collected method via
  the C API (`TVMFFITypeRegisterMethod` + `TVMFFITypeRegisterAttr`)
  directly from Cython, then unconditionally re-reads the full method
  table from C so that system-generated methods (`__ffi_init__`,
  `__ffi_shallow_copy__`) are always picked up
- `_register_py_methods` is always called (even when py_methods is None)
  so system methods are read back for every @py_class type
- `_register_fields` still calls `_read_back_methods()` for backward
  compat with direct callers like `_make_type`
- `TVMFFITypeRegisterMethod` declared in `base.pxi`

Recognized methods:
  __ffi_repr__, __ffi_hash__, __ffi_eq__, __ffi_compare__,
  __s_equal__, __s_hash__, __data_to_json__, __data_from_json__

No C++ changes — `dataclass.cc` is unmodified from upstream.

Cherry-picked from b4e7afef and adapted for upstream/main:
- Dropped `structure_kind`/`_STRUCTURE_KIND_MAP` (not yet in upstream)
- Dropped `_register_type_metadata` (not yet in upstream)
- Dropped `test_structural_py_class.py` tests (depend on structure= param)
- Fixed lint issues (missing `from __future__ import annotations`, `Any` import)

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

With regards,
GitHub Actions via GitBox


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

Reply via email to