qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 16/26] rust: qom: change the parent type to an associated typ


From: Zhao Liu
Subject: Re: [PATCH 16/26] rust: qom: change the parent type to an associated type
Date: Wed, 11 Dec 2024 16:47:36 +0800

On Mon, Dec 09, 2024 at 01:37:07PM +0100, Paolo Bonzini wrote:
> Date: Mon,  9 Dec 2024 13:37:07 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 16/26] rust: qom: change the parent type to an associated
>  type
> X-Mailer: git-send-email 2.47.1
> 
> Avoid duplicated code to retrieve the QOM type strings from the
> Rust type.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  rust/hw/char/pl011/src/device.rs | 6 ++++--
>  rust/qemu-api/src/definitions.rs | 8 ++------
>  rust/qemu-api/tests/tests.rs     | 3 +--
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 

...
> @@ -76,11 +76,7 @@ pub trait ObjectImpl: ObjectType + ClassInitImpl {
>  
>      const TYPE_INFO: TypeInfo = TypeInfo {
>          name: Self::TYPE_NAME.as_ptr(),
> -        parent: if let Some(pname) = Self::PARENT_TYPE_NAME {
> -            pname.as_ptr()
> -        } else {
> -            core::ptr::null_mut()
> -        },
> +        parent: Self::ParentType::TYPE_NAME.as_ptr(),

Object is implemented at C side, so at leaset the ParentType should be
TYPE_OBJECT.

>          instance_size: core::mem::size_of::<Self>(),
>          instance_align: core::mem::align_of::<Self>(),
>          instance_init: match Self::INSTANCE_INIT {

Great!

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]