object_get_typename, object_new, object_ref, object_unref, TypeInfo,
},
cell::{bql_locked, Opaque},
+ impl_vmstate_pointer,
};
/// A safe wrapper around [`bindings::Object`].
impl<T> ObjectClassMethods for T where T: IsA<Object> {}
impl<R: ObjectDeref> ObjectMethods for R where R::Target: IsA<Object> {}
+
+impl_vmstate_pointer!(Owned<T> where T: VMState + ObjectType);
bindings::{self, VMStateFlags},
callbacks::FnCall,
errno::{into_neg_errno, Errno},
- prelude::*,
- qom::Owned,
zeroable::Zeroable,
};
/// * a transparent wrapper for any of the above (`Cell`, `UnsafeCell`,
/// [`BqlCell`], [`BqlRefCell`]
/// * a raw pointer to any of the above
-/// * a `NonNull` pointer, a `Box` or an [`Owned`] for any of the above
+/// * a `NonNull` pointer, a `Box` or an [`Owned`](crate::qom::Owned) for any of
+/// the above
/// * an array of any of the above
///
/// In order to support other types, the trait `VMState` must be implemented
// Note that references are not supported, though references to cells
// could be allowed.
+#[macro_export]
macro_rules! impl_vmstate_pointer {
($type:ty where $base:tt: VMState $($where:tt)*) => {
- unsafe impl<$base> VMState for $type where $base: VMState $($where)* {
- const BASE: VMStateField = <$base as VMState>::BASE.with_pointer_flag();
+ unsafe impl<$base> $crate::vmstate::VMState for $type where $base: $crate::vmstate::VMState $($where)* {
+ const BASE: $crate::vmstate::VMStateField = <$base as $crate::vmstate::VMState>::BASE.with_pointer_flag();
}
};
}
// Unlike C pointers, Box is always non-null therefore there is no need
// to specify VMS_ALLOC.
impl_vmstate_pointer!(Box<T> where T: VMState);
-impl_vmstate_pointer!(Owned<T> where T: VMState + ObjectType);
// Arrays using the underlying type's VMState plus
// VMS_ARRAY/VMS_ARRAY_OF_POINTER