Update for additional translation trait impls in gtk-rs-core

This commit is contained in:
Sebastian Dröge 2022-10-08 15:35:37 +03:00
parent 3cd902513d
commit dac3cf67f4
3 changed files with 24 additions and 14 deletions

View file

@ -88,7 +88,7 @@ impl ClockId {
#[doc(alias = "GST_CLOCK_ENTRY_TYPE")] #[doc(alias = "GST_CLOCK_ENTRY_TYPE")]
pub fn type_(&self) -> ClockEntryType { pub fn type_(&self) -> ClockEntryType {
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; let ptr = self.as_ptr() as *mut ffi::GstClockEntry;
from_glib((*ptr).type_) from_glib((*ptr).type_)
} }
} }
@ -97,7 +97,7 @@ impl ClockId {
#[doc(alias = "GST_CLOCK_ENTRY_STATUS")] #[doc(alias = "GST_CLOCK_ENTRY_STATUS")]
pub fn status(&self) -> &AtomicClockReturn { pub fn status(&self) -> &AtomicClockReturn {
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; let ptr = self.as_ptr() as *mut ffi::GstClockEntry;
&*((&(*ptr).status) as *const i32 as *const AtomicClockReturn) &*((&(*ptr).status) as *const i32 as *const AtomicClockReturn)
} }
} }
@ -249,7 +249,7 @@ impl PeriodicClockId {
#[doc(alias = "GST_CLOCK_ENTRY_INTERVAL")] #[doc(alias = "GST_CLOCK_ENTRY_INTERVAL")]
pub fn interval(&self) -> ClockTime { pub fn interval(&self) -> ClockTime {
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; let ptr = self.as_ptr() as *mut ffi::GstClockEntry;
try_from_glib((*ptr).interval).expect("undefined interval") try_from_glib((*ptr).interval).expect("undefined interval")
} }
} }

View file

@ -72,7 +72,7 @@ impl ParamSpecFraction {
pub fn minimum(&self) -> crate::Fraction { pub fn minimum(&self) -> crate::Fraction {
unsafe { unsafe {
let ptr = self.to_glib_none().0; let ptr = self.as_ptr();
crate::Fraction::new((*ptr).min_num, (*ptr).min_den) crate::Fraction::new((*ptr).min_num, (*ptr).min_den)
} }
@ -80,7 +80,7 @@ impl ParamSpecFraction {
pub fn maximum(&self) -> crate::Fraction { pub fn maximum(&self) -> crate::Fraction {
unsafe { unsafe {
let ptr = self.to_glib_none().0; let ptr = self.as_ptr();
crate::Fraction::new((*ptr).max_num, (*ptr).max_den) crate::Fraction::new((*ptr).max_num, (*ptr).max_den)
} }
@ -88,14 +88,19 @@ impl ParamSpecFraction {
pub fn default_value(&self) -> crate::Fraction { pub fn default_value(&self) -> crate::Fraction {
unsafe { unsafe {
let ptr = self.to_glib_none().0; let ptr = self.as_ptr();
crate::Fraction::new((*ptr).def_num, (*ptr).def_den) crate::Fraction::new((*ptr).def_num, (*ptr).def_den)
} }
} }
pub fn upcast(self) -> ParamSpec { pub fn upcast(self) -> ParamSpec {
unsafe { from_glib_full(self.to_glib_full() as *mut gobject_ffi::GParamSpec) } unsafe {
from_glib_full(
IntoGlibPtr::<*mut ffi::GstParamSpecFraction>::into_glib_ptr(self)
as *mut gobject_ffi::GParamSpec,
)
}
} }
pub fn upcast_ref(&self) -> &ParamSpec { pub fn upcast_ref(&self) -> &ParamSpec {
@ -238,14 +243,19 @@ impl ParamSpecArray {
pub fn element_spec(&self) -> Option<ParamSpec> { pub fn element_spec(&self) -> Option<ParamSpec> {
unsafe { unsafe {
let ptr = self.to_glib_none().0; let ptr = self.as_ptr();
from_glib_none((*ptr).element_spec) from_glib_none((*ptr).element_spec)
} }
} }
pub fn upcast(self) -> ParamSpec { pub fn upcast(self) -> ParamSpec {
unsafe { from_glib_full(self.to_glib_full() as *mut gobject_ffi::GParamSpec) } unsafe {
from_glib_full(
IntoGlibPtr::<*mut ffi::GstParamSpecArray>::into_glib_ptr(self)
as *mut gobject_ffi::GParamSpec,
)
}
} }
pub fn upcast_ref(&self) -> &ParamSpec { pub fn upcast_ref(&self) -> &ParamSpec {

View file

@ -151,7 +151,7 @@ impl<T: ClockImpl> ClockImplExt for T {
.map(|f| { .map(|f| {
f( f(
clock.unsafe_cast_ref::<Clock>().to_glib_none().0, clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
id.to_glib_none().0 as *mut ffi::GstClockEntry, id.as_ptr() as *mut ffi::GstClockEntry,
&mut jitter, &mut jitter,
) )
}) })
@ -176,7 +176,7 @@ impl<T: ClockImpl> ClockImplExt for T {
.map(|f| { .map(|f| {
f( f(
clock.unsafe_cast_ref::<Clock>().to_glib_none().0, clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
id.to_glib_none().0 as *mut ffi::GstClockEntry, id.as_ptr() as *mut ffi::GstClockEntry,
) )
}) })
.unwrap_or(ffi::GST_CLOCK_UNSUPPORTED), .unwrap_or(ffi::GST_CLOCK_UNSUPPORTED),
@ -191,7 +191,7 @@ impl<T: ClockImpl> ClockImplExt for T {
if let Some(func) = (*parent_class).unschedule { if let Some(func) = (*parent_class).unschedule {
func( func(
clock.unsafe_cast_ref::<Clock>().to_glib_none().0, clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
id.to_glib_none().0 as *mut ffi::GstClockEntry, id.as_ptr() as *mut ffi::GstClockEntry,
); );
} }
} }
@ -209,14 +209,14 @@ impl<T: ClockImpl> ClockImplExt for T {
assert!(id.uses_clock(&clock)); assert!(id.uses_clock(&clock));
} else { } else {
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = id.to_glib_none().0 as *mut _; let ptr = id.as_ptr() as *mut ffi::GstClockEntry;
assert_eq!((*ptr).clock, clock.as_ref().to_glib_none().0); assert_eq!((*ptr).clock, clock.as_ref().to_glib_none().0);
} }
} }
} }
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = id.to_glib_none().0 as *mut _; let ptr = id.as_ptr() as *mut ffi::GstClockEntry;
if let Some(func) = (*ptr).func { if let Some(func) = (*ptr).func {
func( func(
clock.as_ref().to_glib_none().0, clock.as_ref().to_glib_none().0,