Use repr(transparent) where it is more correct and get rid of some unneeded repr(C)

This commit is contained in:
Sebastian Dröge 2020-10-24 20:06:59 +03:00
parent 5f63ee9912
commit 8c4ebdec1e
30 changed files with 37 additions and 41 deletions

View file

@ -19,7 +19,7 @@ mod custom_meta {
use std::ptr; use std::ptr;
// Public Rust type for the custom meta. // Public Rust type for the custom meta.
#[repr(C)] #[repr(transparent)]
pub struct CustomMeta(imp::CustomMeta); pub struct CustomMeta(imp::CustomMeta);
// Metas must be Send+Sync. // Metas must be Send+Sync.

View file

@ -4,7 +4,6 @@
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
mod runloop { mod runloop {
use std::os::raw::c_void; use std::os::raw::c_void;
#[repr(C)]
pub struct CFRunLoop(*mut c_void); pub struct CFRunLoop(*mut c_void);
#[link(name = "foundation", kind = "framework")] #[link(name = "foundation", kind = "framework")]

View file

@ -21,7 +21,7 @@ use gst;
use gst::prelude::*; use gst::prelude::*;
use gst_audio_sys; use gst_audio_sys;
#[repr(C)] #[repr(transparent)]
pub struct AudioClippingMeta(gst_audio_sys::GstAudioClippingMeta); pub struct AudioClippingMeta(gst_audio_sys::GstAudioClippingMeta);
unsafe impl Send for AudioClippingMeta {} unsafe impl Send for AudioClippingMeta {}
@ -76,7 +76,7 @@ impl fmt::Debug for AudioClippingMeta {
} }
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[repr(C)] #[repr(transparent)]
pub struct AudioMeta(gst_audio_sys::GstAudioMeta); pub struct AudioMeta(gst_audio_sys::GstAudioMeta);
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]

View file

@ -7,7 +7,7 @@ use AudioRingBufferFormatType;
use std::fmt; use std::fmt;
#[repr(C)] #[repr(transparent)]
pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec); pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec);
impl AudioRingBufferSpec { impl AudioRingBufferSpec {

View file

@ -8,7 +8,7 @@ use gst_gl_sys;
use GLContext; use GLContext;
#[repr(C)] #[repr(transparent)]
pub struct GLSyncMeta(gst_gl_sys::GstGLSyncMeta); pub struct GLSyncMeta(gst_gl_sys::GstGLSyncMeta);
unsafe impl Send for GLSyncMeta {} unsafe impl Send for GLSyncMeta {}

View file

@ -7,7 +7,7 @@ use gst;
use gst::prelude::*; use gst::prelude::*;
use gst_net_sys; use gst_net_sys;
#[repr(C)] #[repr(transparent)]
pub struct NetAddressMeta(gst_net_sys::GstNetAddressMeta); pub struct NetAddressMeta(gst_net_sys::GstNetAddressMeta);
unsafe impl Send for NetAddressMeta {} unsafe impl Send for NetAddressMeta {}

View file

@ -13,7 +13,7 @@ use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPAttribute(pub(crate) gst_sdp_sys::GstSDPAttribute); pub struct SDPAttribute(pub(crate) gst_sdp_sys::GstSDPAttribute);
unsafe impl Send for SDPAttribute {} unsafe impl Send for SDPAttribute {}

View file

@ -13,7 +13,7 @@ use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPBandwidth(pub(crate) gst_sdp_sys::GstSDPBandwidth); pub struct SDPBandwidth(pub(crate) gst_sdp_sys::GstSDPBandwidth);
unsafe impl Send for SDPBandwidth {} unsafe impl Send for SDPBandwidth {}

View file

@ -13,7 +13,7 @@ use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPConnection(pub(crate) gst_sdp_sys::GstSDPConnection); pub struct SDPConnection(pub(crate) gst_sdp_sys::GstSDPConnection);
unsafe impl Send for SDPConnection {} unsafe impl Send for SDPConnection {}

View file

@ -11,7 +11,7 @@ use std::fmt;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPKey(gst_sdp_sys::GstSDPKey); pub struct SDPKey(gst_sdp_sys::GstSDPKey);
unsafe impl Send for SDPKey {} unsafe impl Send for SDPKey {}

View file

@ -85,7 +85,7 @@ impl fmt::Display for SDPMedia {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct SDPMediaRef(gst_sdp_sys::GstSDPMedia); pub struct SDPMediaRef(gst_sdp_sys::GstSDPMedia);
impl fmt::Debug for SDPMediaRef { impl fmt::Debug for SDPMediaRef {

View file

@ -119,7 +119,7 @@ impl SDPMessage {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct SDPMessageRef(gst_sdp_sys::GstSDPMessage); pub struct SDPMessageRef(gst_sdp_sys::GstSDPMessage);
impl fmt::Debug for SDPMessageRef { impl fmt::Debug for SDPMessageRef {

View file

@ -11,7 +11,7 @@ use std::fmt;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPOrigin(pub(crate) gst_sdp_sys::GstSDPOrigin); pub struct SDPOrigin(pub(crate) gst_sdp_sys::GstSDPOrigin);
unsafe impl Send for SDPOrigin {} unsafe impl Send for SDPOrigin {}

View file

@ -15,7 +15,7 @@ use std::ptr;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPTime(pub(crate) gst_sdp_sys::GstSDPTime); pub struct SDPTime(pub(crate) gst_sdp_sys::GstSDPTime);
unsafe impl Send for SDPTime {} unsafe impl Send for SDPTime {}

View file

@ -13,7 +13,7 @@ use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys; use gst_sdp_sys;
#[repr(C)] #[repr(transparent)]
pub struct SDPZone(pub(crate) gst_sdp_sys::GstSDPZone); pub struct SDPZone(pub(crate) gst_sdp_sys::GstSDPZone);
unsafe impl Send for SDPZone {} unsafe impl Send for SDPZone {}

View file

@ -16,7 +16,7 @@ use gst::prelude::*;
use gst_sys; use gst_sys;
use gst_video_sys; use gst_video_sys;
#[repr(C)] #[repr(transparent)]
pub struct VideoMeta(gst_video_sys::GstVideoMeta); pub struct VideoMeta(gst_video_sys::GstVideoMeta);
unsafe impl Send for VideoMeta {} unsafe impl Send for VideoMeta {}
@ -176,7 +176,7 @@ impl fmt::Debug for VideoMeta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct VideoCropMeta(gst_video_sys::GstVideoCropMeta); pub struct VideoCropMeta(gst_video_sys::GstVideoCropMeta);
unsafe impl Send for VideoCropMeta {} unsafe impl Send for VideoCropMeta {}
@ -235,7 +235,7 @@ impl fmt::Debug for VideoCropMeta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct VideoRegionOfInterestMeta(gst_video_sys::GstVideoRegionOfInterestMeta); pub struct VideoRegionOfInterestMeta(gst_video_sys::GstVideoRegionOfInterestMeta);
unsafe impl Send for VideoRegionOfInterestMeta {} unsafe impl Send for VideoRegionOfInterestMeta {}
@ -367,7 +367,7 @@ impl fmt::Debug for VideoRegionOfInterestMeta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct VideoAffineTransformationMeta(gst_video_sys::GstVideoAffineTransformationMeta); pub struct VideoAffineTransformationMeta(gst_video_sys::GstVideoAffineTransformationMeta);
unsafe impl Send for VideoAffineTransformationMeta {} unsafe impl Send for VideoAffineTransformationMeta {}
@ -426,7 +426,7 @@ impl fmt::Debug for VideoAffineTransformationMeta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct VideoOverlayCompositionMeta(gst_video_sys::GstVideoOverlayCompositionMeta); pub struct VideoOverlayCompositionMeta(gst_video_sys::GstVideoOverlayCompositionMeta);
unsafe impl Send for VideoOverlayCompositionMeta {} unsafe impl Send for VideoOverlayCompositionMeta {}
@ -482,7 +482,7 @@ impl fmt::Debug for VideoOverlayCompositionMeta {
} }
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[repr(C)] #[repr(transparent)]
pub struct VideoCaptionMeta(gst_video_sys::GstVideoCaptionMeta); pub struct VideoCaptionMeta(gst_video_sys::GstVideoCaptionMeta);
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
@ -544,7 +544,7 @@ impl fmt::Debug for VideoCaptionMeta {
} }
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[repr(C)] #[repr(transparent)]
pub struct VideoAFDMeta(gst_video_sys::GstVideoAFDMeta); pub struct VideoAFDMeta(gst_video_sys::GstVideoAFDMeta);
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
@ -608,7 +608,7 @@ impl fmt::Debug for VideoAFDMeta {
} }
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[repr(C)] #[repr(transparent)]
pub struct VideoBarMeta(gst_video_sys::GstVideoBarMeta); pub struct VideoBarMeta(gst_video_sys::GstVideoBarMeta);
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]

View file

@ -525,7 +525,7 @@ impl From<ValidVideoTimeCode> for VideoTimeCode {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct VideoTimeCodeMeta(gst_video_sys::GstVideoTimeCodeMeta); pub struct VideoTimeCodeMeta(gst_video_sys::GstVideoTimeCodeMeta);
unsafe impl Send for VideoTimeCodeMeta {} unsafe impl Send for VideoTimeCodeMeta {}

View file

@ -251,7 +251,7 @@ impl GlibPtrDefault for CapsFeatures {
type GlibType = *mut gst_sys::GstCapsFeatures; type GlibType = *mut gst_sys::GstCapsFeatures;
} }
#[repr(C)] #[repr(transparent)]
pub struct CapsFeaturesRef(gst_sys::GstCapsFeatures); pub struct CapsFeaturesRef(gst_sys::GstCapsFeatures);
impl CapsFeaturesRef { impl CapsFeaturesRef {

View file

@ -175,7 +175,7 @@ impl ClockId {
} }
} }
#[repr(C)] #[repr(transparent)]
#[derive(Debug)] #[derive(Debug)]
pub struct AtomicClockReturn(AtomicI32); pub struct AtomicClockReturn(AtomicI32);

View file

@ -227,7 +227,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct Meta(gst_sys::GstMeta); pub struct Meta(gst_sys::GstMeta);
unsafe impl Send for Meta {} unsafe impl Send for Meta {}
@ -255,7 +255,7 @@ impl fmt::Debug for Meta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta); pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta);
unsafe impl Send for ParentBufferMeta {} unsafe impl Send for ParentBufferMeta {}
@ -299,7 +299,7 @@ impl fmt::Debug for ParentBufferMeta {
} }
} }
#[repr(C)] #[repr(transparent)]
pub struct ProtectionMeta(gst_sys::GstProtectionMeta); pub struct ProtectionMeta(gst_sys::GstProtectionMeta);
unsafe impl Send for ProtectionMeta {} unsafe impl Send for ProtectionMeta {}
@ -342,7 +342,7 @@ impl fmt::Debug for ProtectionMeta {
} }
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]
#[repr(C)] #[repr(transparent)]
pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta); pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta);
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]

View file

@ -13,7 +13,7 @@ macro_rules! gst_define_mini_object_wrapper(
obj: ::std::ptr::NonNull<$ref_name>, obj: ::std::ptr::NonNull<$ref_name>,
} }
#[repr(C)] #[repr(transparent)]
pub struct $ref_name($gst_sys_name); pub struct $ref_name($gst_sys_name);
impl $name { impl $name {

View file

@ -22,7 +22,7 @@ use SeekFlags;
use SeekType; use SeekType;
pub type Segment = FormattedSegment<GenericFormattedValue>; pub type Segment = FormattedSegment<GenericFormattedValue>;
#[repr(C)] #[repr(transparent)]
pub struct FormattedSegment<T: FormattedValue>(gst_sys::GstSegment, PhantomData<T>); pub struct FormattedSegment<T: FormattedValue>(gst_sys::GstSegment, PhantomData<T>);
impl Segment { impl Segment {

View file

@ -19,7 +19,6 @@ use std::ffi::CStr;
use std::fmt; use std::fmt;
use std::ptr; use std::ptr;
#[repr(C)]
pub struct StaticCaps(ptr::NonNull<gst_sys::GstStaticCaps>); pub struct StaticCaps(ptr::NonNull<gst_sys::GstStaticCaps>);
impl StaticCaps { impl StaticCaps {

View file

@ -20,7 +20,6 @@ use std::ffi::CStr;
use std::fmt; use std::fmt;
use std::ptr; use std::ptr;
#[repr(C)]
pub struct StaticPadTemplate(ptr::NonNull<gst_sys::GstStaticPadTemplate>); pub struct StaticPadTemplate(ptr::NonNull<gst_sys::GstStaticPadTemplate>);
impl StaticPadTemplate { impl StaticPadTemplate {

View file

@ -319,7 +319,7 @@ impl GlibPtrDefault for Structure {
type GlibType = *mut gst_sys::GstStructure; type GlibType = *mut gst_sys::GstStructure;
} }
#[repr(C)] #[repr(transparent)]
pub struct StructureRef(gst_sys::GstStructure); pub struct StructureRef(gst_sys::GstStructure);
unsafe impl Send for StructureRef {} unsafe impl Send for StructureRef {}

View file

@ -23,7 +23,7 @@ macro_rules! gst_plugin_define(
pub mod plugin_desc { pub mod plugin_desc {
use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib}; use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib};
#[repr(C)] #[repr(transparent)]
pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc);
unsafe impl Send for GstPluginDesc {} unsafe impl Send for GstPluginDesc {}
unsafe impl Sync for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {}

View file

@ -23,7 +23,7 @@ macro_rules! gst_plugin_define(
pub mod plugin_desc { pub mod plugin_desc {
use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib}; use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib};
#[repr(C)] #[repr(transparent)]
pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc);
unsafe impl Send for GstPluginDesc {} unsafe impl Send for GstPluginDesc {}
unsafe impl Sync for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {}

View file

@ -19,7 +19,7 @@ use glib_sys;
use std::ptr; use std::ptr;
use std::slice; use std::slice;
#[repr(C)] #[repr(transparent)]
#[derive(Debug)] #[derive(Debug)]
pub struct TypeFind(gst_sys::GstTypeFind); pub struct TypeFind(gst_sys::GstTypeFind);

View file

@ -140,7 +140,7 @@ macro_rules! ser_value (
); );
); );
#[repr(C)] #[repr(transparent)]
pub(crate) struct SendValue(glib::SendValue); pub(crate) struct SendValue(glib::SendValue);
impl SendValue { impl SendValue {
pub(crate) fn from(send_value: glib::SendValue) -> Self { pub(crate) fn from(send_value: glib::SendValue) -> Self {

View file

@ -4,7 +4,6 @@
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
mod runloop { mod runloop {
use std::os::raw::c_void; use std::os::raw::c_void;
#[repr(C)]
pub struct CFRunLoop(*mut c_void); pub struct CFRunLoop(*mut c_void);
#[link(name = "foundation", kind = "framework")] #[link(name = "foundation", kind = "framework")]