junrushao commented on code in PR #670: URL: https://github.com/apache/tvm-ffi/pull/670#discussion_r3592633277
########## include/tvm/ffi/object.h: ########## @@ -546,6 +546,19 @@ inline constexpr bool is_qualified_object_v = } // namespace details +/*! + * \brief Mark a forward-declared type as an Object subclass. + * + * Invoke this macro at global namespace scope after forward declaring Type. + * Generated ABI headers use it so recursive container fields can instantiate + * ObjectPtr traits before the pointee type's definition is complete. + * + * \param Type The fully qualified Object subclass. + */ +#define TVM_FFI_DECLARE_OBJECT_SUBCLASS(Type) \ + template <> \ + inline constexpr bool tvm::ffi::details::is_object_subclass_v<Type> = true Review Comment: Addressed in `02d4f312`. `is_object_subclass_v` now lives in `tvm::ffi`, and `TypeTraits<ObjectPtr<TObject>>` uses that public trait directly. I removed `TVM_FFI_DECLARE_OBJECT_SUBCLASS`; generated headers now emit the two-line inline specialization immediately after each forward declaration. I also made the recursive requirement explicit in `test_abi_object.cc`: only the still-incomplete `RecursiveObj` is specialized, its `ObjectPtr` storage trait is asserted before the class definition, and the class then declares `List<ObjectPtr<RecursiveObj>>`. The mutual-recursion coverage remains in `test_object_ptr.cc`. A compiler probe confirms that omitting the specialization fails in `std::is_base_of_v<Object, NodeObj>` while the direct specialization compiles. Full CTest (451 enabled), generator tests on Python 3.9 and the dev interpreter, pre-commit, and targeted clang-tidy all pass. ########## include/tvm/ffi/object.h: ########## @@ -546,6 +546,19 @@ inline constexpr bool is_qualified_object_v = } // namespace details +/*! + * \brief Mark a forward-declared type as an Object subclass. + * + * Invoke this macro at global namespace scope after forward declaring Type. + * Generated ABI headers use it so recursive container fields can instantiate + * ObjectPtr traits before the pointee type's definition is complete. + * + * \param Type The fully qualified Object subclass. + */ +#define TVM_FFI_DECLARE_OBJECT_SUBCLASS(Type) \ + template <> \ + inline constexpr bool tvm::ffi::details::is_object_subclass_v<Type> = true Review Comment: Addressed in `02d4f312`: the trait is now `tvm::ffi::is_object_subclass_v<Type>` rather than an implementation detail, and the `ObjectPtr` traits plus generated explicit specializations all use that public name. -- 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]
