Commit e75d2c22 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add GValue support to GstRc/MiniObject

parent 27d191f8
......@@ -11,8 +11,11 @@ use std::mem;
use std::marker::PhantomData;
use ffi;
use glib::translate::{from_glib, Stash, StashMut, ToGlibPtr, ToGlibPtrMut, FromGlibPtrNone,
FromGlibPtrFull, FromGlibPtrBorrow};
use glib_ffi::gpointer;
use gobject_ffi;
use glib::translate::{from_glib, from_glib_none, Stash, StashMut, ToGlibPtr, ToGlibPtrMut,
FromGlibPtrNone, FromGlibPtrFull, FromGlibPtrBorrow};
use glib;
#[derive(Hash, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct GstRc<T: MiniObject> {
......@@ -253,3 +256,22 @@ impl<T: MiniObject + 'static> FromGlibPtrBorrow<*mut T::GstType> for GstRc<T> {
Self::from_glib_borrow(ptr)
}
}
impl<T: MiniObject + glib::StaticType> glib::StaticType for GstRc<T> {
fn static_type() -> glib::types::Type {
T::static_type()
}
}
impl<'a, T: MiniObject + glib::StaticType + 'static> glib::value::FromValueOptional<'a> for GstRc<T> {
unsafe fn from_value_optional(v: &'a glib::Value) -> Option<Self> {
let ptr = gobject_ffi::g_value_get_boxed(v.to_glib_none().0);
from_glib_none(ptr as *const T::GstType)
}
}
impl<T: MiniObject + glib::StaticType> glib::value::SetValue for GstRc<T> {
unsafe fn set_value(v: &mut glib::Value, s: &Self) {
gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.as_ptr() as gpointer);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment