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 e9fdc58f (commit)
      to deb6cb33 (tag)
 tagging e9fdc58fa4bf2e60ed701dacac48a01e41a3dc1f (commit)
 replaces v0.1.15
      by Yuchuan
      on Thu Oct 29 13:26:07 2026 -0400

- Log -----------------------------------------------------------------
[FEAT][Rust] Replace rs_class placeholders with an UnsafeInit creator 
([#886](https://github.com/apache/tvm-ffi/issues/886))

[apache/tvm-ffi#884](https://github.com/apache/tvm-ffi/issues/884) made a 
creator of an `rs_class` type start the object
from `tvm_ffi::Placeholder`
values: a Rust reference is never null, so a Rust object cannot start
empty as a C++ one does. That
needs a placeholder for the parent's object and for every field type,
builds a whole placeholder
object for each reference field, and still leaves each downstream
project to register `__ffi_new__`
and call `ffi._RegisterFFIInit` itself.

This PR removes `Placeholder` and the `placeholder` flag, and implements
C++ `UnsafeInit` in Rust
instead, without calling into C++ for it. Every `#[rs_class]` type now
registers a creator, as
`refl::ObjectDef` registers `ObjectCreatorUnsafeInit<T>`. The creator
allocates the object zeroed
and leaves its fields undefined for reflection to set. From it the type
registers `__ffi_new__` and,
unless the type defines its own, the `__ffi_init__` that
`ffi._RegisterFFIInit` generates. A type
needs no per-type code:

```rust
use tvm_ffi::object::ObjectRef;
use tvm_ffi::{def_object_ref, rs_class, Object};

pub struct PointObj {
    base: Object,
    pub x: i64,
    pub label: tvm_ffi::String,
}

def_object_ref!(pub Point, ObjectRef, PointObj);
```

```python
@tvm_ffi.register_object("my.Point")
class Point(tvm_ffi.Object):
    pass

point = Point(1, "p")  # the generated `__ffi_init__`
json = tvm_ffi.serialization.to_json_graph_str(point)
back = tvm_ffi.serialization.from_json_graph_str(json)  # the creator
```
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEkslwBtguEPTsW+HG9USfdrq0UGMFAmrjgbkACgkQ9USfdrq0
UGPY7hAAnd4uP4DaIqaQ1ml7WMb3lX0aIea9oQ0AA24NfiPGZ0a4/OY1gFW8B7QU
emSVYcFA6XmkEfJfD1wrvxfRjLqP59GBf95gyaWaZcrvTScPYb5dDMea203fCiqo
d24g8T7gtQ+MQsLEchHXx8RDTQy1OC4ntwTPQBx+JQBDKmozwjqYnkEe/yhyitl6
gQYZHH3j5RD8Wno4DxVnL43krOkzMbvFgA3B0d4lqeLdkb3zLqEjOR9hJrBf5fef
fMs4Wj7NGJp5O8+t0kY/Rod+Ec7R8W70KAVihIS13wQm6DFNxAQbcbjjKcE06lFY
Hmz9DfFUIwxXEgNUynhik1ikK5ozRSvFPMwq6nJiOCJV36oSCqoobX52v6R5Vxqf
eiKTRr7gY7zgjgJkc8vOwvMR8InJ9Ruxw1pgmxY8YOWTtcwwwY/N/HyQKWW4BV39
59/MHL2dySaY1pEaDr75/CtY60u6ZhrzAFrbaFn6t58K8zEFt2eLQrM27L3KrT6r
NjB74mZNNBhywTupoOQIV0JawSEUJsrX3yVUhCXOd2614v2pMB6/bETz/Ni8UWLA
9KOC5nBhok4JUcIqomwxDluwnfb9ZiyEdg4Wm+RwRYiR055TNMWuALORLDKKajjn
neFezH7HgHSJ/4ejCxb9XuhdtaPI9XgN/elCWLYZTAJIU0HxsFg=
=Uw3g
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------


No new revisions were added by this update.

Summary of changes:

Reply via email to