On Tue, Sep 16, 2025 at 01:13:28PM +0300, Manos Pitsidianakis wrote:
> Date: Tue, 16 Sep 2025 13:13:28 +0300
> From: Manos Pitsidianakis <[email protected]>
> Subject: Re: [PATCH 08/12] rust/qdev: Support property info for more common
> types
>
> On Tue, Sep 16, 2025 at 11:34 AM Zhao Liu <[email protected]> wrote:
> >
> > Add a helper macro to implement QDevProp trait for u8/u16/u32/usize/i32
> > /i64.
> >
> > Signed-off-by: Zhao Liu <[email protected]>
> > ---
>
> Reviewed-by: Manos Pitsidianakis <[email protected]>
Thanks!
> You can do something like this btw:
>
> macro_rules! impl_qdev_prop {
> ($($type:ty => $info:ident),*$(,)?) => {
> $(unsafe impl $crate::qdev::QDevProp for $type {
> const BASE_INFO: *const $crate::bindings::PropertyInfo =
> addr_of!($crate::bindings::$info);
> })*
> };
> }
>
> impl_qdev_prop!(
> bool => qdev_prop_bool,
> u8 => qdev_prop_uint8,
> ...
> );
>
Yes, this can work! But a benefit of non-repetitive macro is that it
can also be exposed for use by other crates if necessary.
Regards,
Zhao