mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
gstreamer: Implement FromValue
for mini object references
This commit is contained in:
parent
b66a00ed07
commit
eecce101da
1 changed files with 13 additions and 0 deletions
|
@ -477,6 +477,19 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a> $crate::glib::value::FromValue<'a> for &'a $name {
|
||||
type Checker = $crate::glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
unsafe fn from_value(value: &'a $crate::glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert_eq!(std::mem::size_of::<$name>(), std::mem::size_of::<$crate::glib::ffi::gpointer>());
|
||||
let value = &*(value as *const $crate::glib::Value as *const $crate::glib::gobject_ffi::GValue);
|
||||
let ptr = &value.data[0].v_pointer as *const $crate::glib::ffi::gpointer as *const *const $ffi_name;
|
||||
assert!(!(*ptr).is_null());
|
||||
&*(ptr as *const $name)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::value::ToValue for $name {
|
||||
fn to_value(&self) -> $crate::glib::Value {
|
||||
let mut value = $crate::glib::Value::for_value_type::<Self>();
|
||||
|
|
Loading…
Reference in a new issue