tvm_ffi::reflection

Function unsafe_init

Source
pub unsafe fn unsafe_init<T: UnsafeInit>() -> ObjectRef
Expand description

An object of T with every field undefined, as C++ make_object<T>(UnsafeInit{}) makes one, for reflection to set the fields through their setters.

The ObjectRef views only the object’s header, which is valid all along.

§Safety

Each field that all-zero bytes leave undefined (AnyCompatible::is_undefined) is set before the object is viewed as a T (by a cast of the reference) or the field is read as its type. Until then, only the reflection’s field setters and getters reach the fields.