forked from mirrors/gstreamer-rs
Remove unneeded PhantomData markers
And as a side-effect also get rid of the lifetime parameter of gst::TypeFind that was completely unused anyway.
This commit is contained in:
parent
d815e85440
commit
4c216bca3a
6 changed files with 34 additions and 89 deletions
|
@ -22,10 +22,7 @@ use std::ptr;
|
|||
use TestClock;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Harness(
|
||||
ptr::NonNull<gst_check_sys::GstHarness>,
|
||||
PhantomData<gst_check_sys::GstHarness>,
|
||||
);
|
||||
pub struct Harness(ptr::NonNull<gst_check_sys::GstHarness>);
|
||||
|
||||
impl Drop for Harness {
|
||||
fn drop(&mut self) {
|
||||
|
@ -567,7 +564,7 @@ impl Harness {
|
|||
unsafe fn from_glib_full(ptr: *mut gst_check_sys::GstHarness) -> Harness {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
Harness(ptr::NonNull::new_unchecked(ptr), PhantomData)
|
||||
Harness(ptr::NonNull::new_unchecked(ptr))
|
||||
}
|
||||
|
||||
pub fn new(element_name: &str) -> Harness {
|
||||
|
@ -728,10 +725,7 @@ impl Harness {
|
|||
None
|
||||
} else {
|
||||
Some(Ref(
|
||||
mem::ManuallyDrop::new(Harness(
|
||||
ptr::NonNull::new_unchecked(sink_harness),
|
||||
PhantomData,
|
||||
)),
|
||||
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))),
|
||||
PhantomData,
|
||||
))
|
||||
}
|
||||
|
@ -745,10 +739,7 @@ impl Harness {
|
|||
None
|
||||
} else {
|
||||
Some(Ref(
|
||||
mem::ManuallyDrop::new(Harness(
|
||||
ptr::NonNull::new_unchecked(src_harness),
|
||||
PhantomData,
|
||||
)),
|
||||
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))),
|
||||
PhantomData,
|
||||
))
|
||||
}
|
||||
|
@ -762,10 +753,7 @@ impl Harness {
|
|||
None
|
||||
} else {
|
||||
Some(RefMut(
|
||||
mem::ManuallyDrop::new(Harness(
|
||||
ptr::NonNull::new_unchecked(sink_harness),
|
||||
PhantomData,
|
||||
)),
|
||||
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))),
|
||||
PhantomData,
|
||||
))
|
||||
}
|
||||
|
@ -779,10 +767,7 @@ impl Harness {
|
|||
None
|
||||
} else {
|
||||
Some(RefMut(
|
||||
mem::ManuallyDrop::new(Harness(
|
||||
ptr::NonNull::new_unchecked(src_harness),
|
||||
PhantomData,
|
||||
)),
|
||||
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))),
|
||||
PhantomData,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ impl<'a> VideoCodecStateContext<'a> for Readable {
|
|||
pub struct VideoCodecState<'a, T: VideoCodecStateContext<'a>> {
|
||||
state: *mut gst_video_sys::GstVideoCodecState,
|
||||
pub(crate) context: T,
|
||||
/* FIXME: should not be needed because lifetime is actually used */
|
||||
phantom: PhantomData<&'a T>,
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
use std::borrow::{Borrow, BorrowMut, ToOwned};
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ptr;
|
||||
|
@ -26,7 +25,7 @@ use glib_sys::gpointer;
|
|||
use gobject_sys;
|
||||
use gst_sys;
|
||||
|
||||
pub struct CapsFeatures(ptr::NonNull<CapsFeaturesRef>, PhantomData<CapsFeaturesRef>);
|
||||
pub struct CapsFeatures(ptr::NonNull<CapsFeaturesRef>);
|
||||
unsafe impl Send for CapsFeatures {}
|
||||
unsafe impl Sync for CapsFeatures {}
|
||||
|
||||
|
@ -45,24 +44,18 @@ impl CapsFeatures {
|
|||
pub fn new_empty() -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(
|
||||
gst_sys::gst_caps_features_new_empty() as *mut CapsFeaturesRef
|
||||
),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(
|
||||
gst_sys::gst_caps_features_new_empty() as *mut CapsFeaturesRef,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_any() -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(
|
||||
gst_sys::gst_caps_features_new_any() as *mut CapsFeaturesRef
|
||||
),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(
|
||||
gst_sys::gst_caps_features_new_any() as *mut CapsFeaturesRef,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +96,7 @@ impl Clone for CapsFeatures {
|
|||
unsafe {
|
||||
let ptr = gst_sys::gst_caps_features_copy(&self.0.as_ref().0) as *mut CapsFeaturesRef;
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr), PhantomData)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,10 +136,9 @@ impl str::FromStr for CapsFeatures {
|
|||
));
|
||||
}
|
||||
|
||||
Ok(CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef),
|
||||
PhantomData,
|
||||
))
|
||||
Ok(CapsFeatures(ptr::NonNull::new_unchecked(
|
||||
ptr as *mut CapsFeaturesRef,
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,10 +198,7 @@ impl FromGlibPtrNone<*const gst_sys::GstCapsFeatures> for CapsFeatures {
|
|||
assert!(!ptr.is_null());
|
||||
let ptr = gst_sys::gst_caps_features_copy(ptr);
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,30 +207,21 @@ impl FromGlibPtrNone<*mut gst_sys::GstCapsFeatures> for CapsFeatures {
|
|||
assert!(!ptr.is_null());
|
||||
let ptr = gst_sys::gst_caps_features_copy(ptr);
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrFull<*const gst_sys::GstCapsFeatures> for CapsFeatures {
|
||||
unsafe fn from_glib_full(ptr: *const gst_sys::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut gst_sys::GstCapsFeatures> for CapsFeatures {
|
||||
unsafe fn from_glib_full(ptr: *mut gst_sys::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef),
|
||||
PhantomData,
|
||||
)
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ macro_rules! gst_define_mini_object_wrapper(
|
|||
($name:ident, $ref_name:ident, $gst_sys_name:path, $get_type:expr) => {
|
||||
pub struct $name {
|
||||
obj: ::std::ptr::NonNull<$ref_name>,
|
||||
phantom: ::std::marker::PhantomData<$ref_name>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -26,7 +25,6 @@ macro_rules! gst_define_mini_object_wrapper(
|
|||
|
||||
$name {
|
||||
obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name),
|
||||
phantom: ::std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +34,6 @@ macro_rules! gst_define_mini_object_wrapper(
|
|||
|
||||
$name {
|
||||
obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name),
|
||||
phantom: ::std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +43,6 @@ macro_rules! gst_define_mini_object_wrapper(
|
|||
|
||||
$crate::glib::translate::Borrowed::new($name {
|
||||
obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name),
|
||||
phantom: ::std::marker::PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
use std::borrow::{Borrow, BorrowMut, ToOwned};
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ptr;
|
||||
|
@ -56,7 +55,7 @@ impl<'name> GetError<'name> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Structure(ptr::NonNull<StructureRef>, PhantomData<StructureRef>);
|
||||
pub struct Structure(ptr::NonNull<StructureRef>);
|
||||
unsafe impl Send for Structure {}
|
||||
unsafe impl Sync for Structure {}
|
||||
|
||||
|
@ -71,7 +70,7 @@ impl Structure {
|
|||
unsafe {
|
||||
let ptr = gst_sys::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef;
|
||||
assert!(!ptr.is_null());
|
||||
Structure(ptr::NonNull::new_unchecked(ptr), PhantomData)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +142,7 @@ impl Clone for Structure {
|
|||
unsafe {
|
||||
let ptr = gst_sys::gst_structure_copy(&self.0.as_ref().0) as *mut StructureRef;
|
||||
assert!(!ptr.is_null());
|
||||
Structure(ptr::NonNull::new_unchecked(ptr), PhantomData)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,10 +191,9 @@ impl str::FromStr for Structure {
|
|||
if structure.is_null() {
|
||||
Err(glib_bool_error!("Failed to parse structure from string"))
|
||||
} else {
|
||||
Ok(Structure(
|
||||
ptr::NonNull::new_unchecked(structure as *mut StructureRef),
|
||||
PhantomData,
|
||||
))
|
||||
Ok(Structure(ptr::NonNull::new_unchecked(
|
||||
structure as *mut StructureRef,
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +218,7 @@ impl ToOwned for StructureRef {
|
|||
unsafe {
|
||||
let ptr = gst_sys::gst_structure_copy(&self.0) as *mut StructureRef;
|
||||
assert!(!ptr.is_null());
|
||||
Structure(ptr::NonNull::new_unchecked(ptr), PhantomData)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,10 +266,7 @@ impl FromGlibPtrNone<*const gst_sys::GstStructure> for Structure {
|
|||
assert!(!ptr.is_null());
|
||||
let ptr = gst_sys::gst_structure_copy(ptr);
|
||||
assert!(!ptr.is_null());
|
||||
Structure(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut StructureRef),
|
||||
PhantomData,
|
||||
)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,30 +275,21 @@ impl FromGlibPtrNone<*mut gst_sys::GstStructure> for Structure {
|
|||
assert!(!ptr.is_null());
|
||||
let ptr = gst_sys::gst_structure_copy(ptr);
|
||||
assert!(!ptr.is_null());
|
||||
Structure(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut StructureRef),
|
||||
PhantomData,
|
||||
)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrFull<*const gst_sys::GstStructure> for Structure {
|
||||
unsafe fn from_glib_full(ptr: *const gst_sys::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
Structure(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut StructureRef),
|
||||
PhantomData,
|
||||
)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut gst_sys::GstStructure> for Structure {
|
||||
unsafe fn from_glib_full(ptr: *mut gst_sys::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
Structure(
|
||||
ptr::NonNull::new_unchecked(ptr as *mut StructureRef),
|
||||
PhantomData,
|
||||
)
|
||||
Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,12 @@ use TypeFindProbability;
|
|||
use glib;
|
||||
use glib::translate::*;
|
||||
use glib_sys;
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct TypeFind<'a>(gst_sys::GstTypeFind, PhantomData<&'a ()>);
|
||||
pub struct TypeFind(gst_sys::GstTypeFind);
|
||||
|
||||
pub trait TypeFindImpl {
|
||||
fn peek(&mut self, offset: i64, size: u32) -> Option<&[u8]>;
|
||||
|
@ -32,7 +31,7 @@ pub trait TypeFindImpl {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> TypeFind<'a> {
|
||||
impl TypeFind {
|
||||
pub fn register<F>(
|
||||
plugin: Option<&Plugin>,
|
||||
name: &str,
|
||||
|
|
Loading…
Reference in a new issue