rust/qemu-api: Fix fragment-specifiers in define_property macro

For the matcher of macro, "expr" is used for expressions, while "ident"
is used for variable/function names, and "ty" matches types.

In define_property macro, $field is a member name of type $state, so it
should be defined as "ident", though offset_of! doesn't complain about
this. $type is the type of $field, since it is not used in the macro, so
that no type mismatch error is triggered either.

Fix fragment-specifiers of $field and $type.

Signed-off-by: Junjie Mao <junjie.mao@hotmail.com>
Co-developed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20241017143245.1248589-2-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Junjie Mao 2024-10-17 22:32:44 +08:00 committed by Paolo Bonzini
parent 8a88b55f69
commit a3057c52f4

View file

@ -27,7 +27,7 @@ macro_rules! device_class_init {
#[macro_export] #[macro_export]
macro_rules! define_property { macro_rules! define_property {
($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr, default = $defval:expr$(,)*) => { ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, default = $defval:expr$(,)*) => {
$crate::bindings::Property { $crate::bindings::Property {
// use associated function syntax for type checking // use associated function syntax for type checking
name: ::std::ffi::CStr::as_ptr($name), name: ::std::ffi::CStr::as_ptr($name),
@ -38,7 +38,7 @@ macro_rules! define_property {
..$crate::zeroable::Zeroable::ZERO ..$crate::zeroable::Zeroable::ZERO
} }
}; };
($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr$(,)*) => { ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty$(,)*) => {
$crate::bindings::Property { $crate::bindings::Property {
// use associated function syntax for type checking // use associated function syntax for type checking
name: ::std::ffi::CStr::as_ptr($name), name: ::std::ffi::CStr::as_ptr($name),