]> git.ipfire.org Git - thirdparty/qemu.git/commit
rust: qom: put class_init together from multiple ClassInitImpl<>
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 Nov 2024 14:19:23 +0000 (15:19 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 19 Dec 2024 18:36:37 +0000 (19:36 +0100)
commit6dd818fbbbe3efc63889e7d811ac6b70e788c629
tree505c2bd4d37efaa56db693a6e9ee1f6e627b44cb
parentb1987a2547c8e32fd3c32f504fe8d4bc58b7f961
rust: qom: put class_init together from multiple ClassInitImpl<>

Parameterize the implementation of ClassInitImpl so that it is
possible to call up the chain of implementations, one superclass at
a time starting at ClassInitImpl<Self::Class>.

In order to avoid having to implement (for example)
ClassInitImpl<PL011Class>, also remove the dummy PL011Class and
PL011LuminaryClass structs and specify the same ObjectType::Class as
the superclass.  In the future this default behavior can be handled by
a procedural macro, by looking at the first field in the struct.

Note that the new trait is safe: the calls are started by
rust_class_init<>(), which is not public and can convert the class
pointer to a Rust reference.

Since CLASS_BASE_INIT applies to the type that is being defined,
and only to it, move it to ObjectImpl.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/qemu-api/src/definitions.rs
rust/qemu-api/src/device_class.rs
rust/qemu-api/src/sysbus.rs
rust/qemu-api/tests/tests.rs