tqchen opened a new pull request, #639: URL: https://github.com/apache/tvm-ffi/pull/639
This PR refactors strict ObjectRef casting to use the Any TypeTraits strict-check path and adds strict throwing APIs.\n\nChanges:\n- Add ref-qualified ObjectRef::as<T>() and ObjectRef::as_or_throw<T>() overloads for const and rvalue receivers.\n- Add Any::as_or_throw<T>() const/rvalue helpers.\n- Keep ObjectRef null handling explicit while using temporary TVMFFIAny views for rich TypeTraits checks and mismatch messages.\n- Add focused tests for const and move variants of as<T>() and as_or_throw<T>().\n- Update TVM_FFI_UNSAFE_ASSUME lowering to be more robust for GCC.\n\nValidation:\n- cmake --build build/cpp_tests -j2 --target tvm_ffi_tests\n- ctest --test-dir build/cpp_tests --output-on-failure -R '^(Any\.AsOrThrow|ObjectRef\.(as|AsUsesTypeTraitsCheckAnyStrict|AsOrThrow)|Expected\..*)$' (29/29 tests)\n- pre-commit run --files include/tvm/ffi/any.h include/tvm/ffi/object.h tests/cpp/test_any.cc tests/cpp/test_object.cc\n- Reconfirmed GCC/Clang assembly for ObjectRef::as<TInt>() an d as_or_throw<TInt>() const/rvalue probes: hot paths use direct object-header loads/type-index comparisons; temporary TVMFFIAny views are optimized away. -- 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]
