This is an automated email from the ASF dual-hosted git repository.
Seven-Streams pushed a change to annotated tag v0.1.15-post2
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
*** WARNING: tag v0.1.15-post2 was modified! ***
from 277e7b45 (commit)
to 315fe897 (tag)
tagging 277e7b452bafd77fa6725cd47f3937409208b43b (commit)
replaces v0.1.15
by Yuchuan
on Thu Oct 29 12:59:57 2026 -0400
- Log -----------------------------------------------------------------
[FEAT][Rust] Generate placeholders of rs_class objects with `placeholder`
([#884](https://github.com/apache/tvm-ffi/issues/884))
Reflection builds some objects field by field: a JSON graph read back,
and the `__ffi_init__`
that `ffi._RegisterFFIInit` generates both make an empty object with the
type's creator, then set
each field. A C++ type gets its creator from `refl::ObjectDef`, whose
object can start empty
because its references may be null; a Python `py_class` allocates zeroed
memory. A Rust object
cannot start empty, since its references are never null, so a downstream
project that registers a
creator (`__ffi_new__`) for an `rs_class` type has to make the object
from valid placeholder
values, which reflection then overwrites.
TVM TIRx does this to let Python construct, JSON graphs hold, and
TVMScript parse the IR types an
extension defines in Rust. It carries its own `Placeholder` trait for
it, and every type writes
the same impl by hand:
```rust
impl Placeholder for PairTypeObj {
fn placeholder() -> Self {
Self::new(TypeObj::placeholder(), Type::placeholder(),
Type::placeholder())
}
}
```
The impl only repeats the struct: the parent's placeholder, then each
field's, in order. This PR
adds the trait here as `tvm_ffi::Placeholder` and lets `#[rs_class]`
write the impl when asked:
```rust
use tvm_ffi::object::ObjectRef;
use tvm_ffi::{def_object_ref, rs_class, Object, Placeholder};
pub struct PointObj {
base: Object,
pub x: i64,
pub label: tvm_ffi::String,
}
def_object_ref!(pub Point, ObjectRef, PointObj);
let point = Point::from(PointObj::placeholder());
assert_eq!((point.x, point.label.as_str()), (0, ""));
```
Signed-off-by: Yuchuan <[email protected]>
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEkslwBtguEPTsW+HG9USfdrq0UGMFAmrje5EACgkQ9USfdrq0
UGOKZhAAz3NP6iLZWA84RT5hBnrdyZEX9FFkFhAsb72S33ss/7jck+g+SmWuTISG
X1/jNo2PwNiA2UhcMsl3XVW5/DsOlLlUgKg8kx3bbKeXjEbwCJagh6OPACt1RKGH
jGJIBV2gc/yfqSvagTqlp+dxYzhiikghu9nBtlYrP97q2KoZN19wNFbRpGLzC74C
jK9rvjfq+mOrjyywTCilJ3YM2MYz+t03zXJckFA4oa2Vzx5Uq2Paz7pGLZ34ZLRg
krSo62fuoUd3gtyfs7tEuxXOKIOEdGT1BtS+CMv7Xy+7k8U6ZFe2WOuB1GRLNYLK
XNlU3QbD54t7FjDPkR6QraxIx8/qdR7Qfju25k2mniUEFFnMn+zDK8gpgSsLEdZ+
F6tdEAwU83UHllj9V4r/uIqThZvzRDnSrI+lbutmEdCM1gpCqdq0041LbJzT4lxr
OKpsWMJd8tArwdPyoVOmGNfqYkDaylt5R+4PTebcipMRCCYt7L/5QI4vwiLx4Te6
s3BKYmXxGE3U9n++5CSwyhBXRRVArM2jz3qd+sNpRgp4wFuI2ERnt9npxr1E2r49
3ebUwl4jbuG6uG/VmVnyPN+WVNsz8hr65jWrZpXt7ZE6fz1+4ybe8fhJYNxFNl5T
VKlaPBNrTUUBJthaWKKkGatTI3ymPtea1ZrI4fs3Ho5WNb8pCTw=
=XzKX
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
No new revisions were added by this update.
Summary of changes: