[PATCH 12/12] rust/qdev: Drop declare_properties & define_property macros

Zhao Liu posted 12 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH 12/12] rust/qdev: Drop declare_properties & define_property macros
Posted by Zhao Liu 1 week, 5 days ago
After HPET's #property conversion, there's no use case for
declare_properties & define_property. So get rid of them for now.

In future, if there's something that #property really cannot resolve,
they can be brought back.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 rust/hw/core/src/qdev.rs | 53 ----------------------------------------
 1 file changed, 53 deletions(-)

diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
index a8cd9e3c2fd5..a32ada4c175e 100644
--- a/rust/hw/core/src/qdev.rs
+++ b/rust/hw/core/src/qdev.rs
@@ -248,59 +248,6 @@ pub fn class_init<T: DeviceImpl>(&mut self) {
     }
 }
 
-#[macro_export]
-macro_rules! define_property {
-    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, bit = $bitnr:expr, default = $defval:expr$(,)*) => {
-        $crate::bindings::Property {
-            // use associated function syntax for type checking
-            name: ::std::ffi::CStr::as_ptr($name),
-            info: $prop,
-            offset: ::std::mem::offset_of!($state, $field) as isize,
-            bitnr: $bitnr,
-            set_default: true,
-            defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as u64 },
-            ..::common::zeroable::Zeroable::ZERO
-        }
-    };
-    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, default = $defval:expr$(,)*) => {
-        $crate::bindings::Property {
-            // use associated function syntax for type checking
-            name: ::std::ffi::CStr::as_ptr($name),
-            info: $prop,
-            offset: ::std::mem::offset_of!($state, $field) as isize,
-            set_default: true,
-            defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as u64 },
-            ..::common::zeroable::Zeroable::ZERO
-        }
-    };
-    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty$(,)*) => {
-        $crate::bindings::Property {
-            // use associated function syntax for type checking
-            name: ::std::ffi::CStr::as_ptr($name),
-            info: $prop,
-            offset: ::std::mem::offset_of!($state, $field) as isize,
-            set_default: false,
-            ..::common::zeroable::Zeroable::ZERO
-        }
-    };
-}
-
-#[macro_export]
-macro_rules! declare_properties {
-    ($ident:ident, $($prop:expr),*$(,)*) => {
-        pub static $ident: [$crate::bindings::Property; {
-            let mut len = 0;
-            $({
-                _ = stringify!($prop);
-                len += 1;
-            })*
-            len
-        }] = [
-            $($prop),*,
-        ];
-    };
-}
-
 unsafe impl ObjectType for DeviceState {
     type Class = DeviceClass;
     const TYPE_NAME: &'static CStr =
-- 
2.34.1
Re: [PATCH 12/12] rust/qdev: Drop declare_properties & define_property macros
Posted by Manos Pitsidianakis 1 week, 5 days ago
On Tue, Sep 16, 2025 at 11:34 AM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> After HPET's #property conversion, there's no use case for
> declare_properties & define_property. So get rid of them for now.
>
> In future, if there's something that #property really cannot resolve,
> they can be brought back.
>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

>  rust/hw/core/src/qdev.rs | 53 ----------------------------------------
>  1 file changed, 53 deletions(-)
>
> diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
> index a8cd9e3c2fd5..a32ada4c175e 100644
> --- a/rust/hw/core/src/qdev.rs
> +++ b/rust/hw/core/src/qdev.rs
> @@ -248,59 +248,6 @@ pub fn class_init<T: DeviceImpl>(&mut self) {
>      }
>  }
>
> -#[macro_export]
> -macro_rules! define_property {
> -    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, bit = $bitnr:expr, default = $defval:expr$(,)*) => {
> -        $crate::bindings::Property {
> -            // use associated function syntax for type checking
> -            name: ::std::ffi::CStr::as_ptr($name),
> -            info: $prop,
> -            offset: ::std::mem::offset_of!($state, $field) as isize,
> -            bitnr: $bitnr,
> -            set_default: true,
> -            defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as u64 },
> -            ..::common::zeroable::Zeroable::ZERO
> -        }
> -    };
> -    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, default = $defval:expr$(,)*) => {
> -        $crate::bindings::Property {
> -            // use associated function syntax for type checking
> -            name: ::std::ffi::CStr::as_ptr($name),
> -            info: $prop,
> -            offset: ::std::mem::offset_of!($state, $field) as isize,
> -            set_default: true,
> -            defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as u64 },
> -            ..::common::zeroable::Zeroable::ZERO
> -        }
> -    };
> -    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty$(,)*) => {
> -        $crate::bindings::Property {
> -            // use associated function syntax for type checking
> -            name: ::std::ffi::CStr::as_ptr($name),
> -            info: $prop,
> -            offset: ::std::mem::offset_of!($state, $field) as isize,
> -            set_default: false,
> -            ..::common::zeroable::Zeroable::ZERO
> -        }
> -    };
> -}
> -
> -#[macro_export]
> -macro_rules! declare_properties {
> -    ($ident:ident, $($prop:expr),*$(,)*) => {
> -        pub static $ident: [$crate::bindings::Property; {
> -            let mut len = 0;
> -            $({
> -                _ = stringify!($prop);
> -                len += 1;
> -            })*
> -            len
> -        }] = [
> -            $($prop),*,
> -        ];
> -    };
> -}
> -
>  unsafe impl ObjectType for DeviceState {
>      type Class = DeviceClass;
>      const TYPE_NAME: &'static CStr =
> --
> 2.34.1
>