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;
// Public Rust type for the custom meta.
#[repr(C)]
#[repr(transparent)]
pub struct CustomMeta(imp::CustomMeta);
// Metas must be Send+Sync.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ use std::fmt;
use gst_sdp_sys;
#[repr(C)]
#[repr(transparent)]
pub struct SDPKey(gst_sdp_sys::GstSDPKey);
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);
impl fmt::Debug for SDPMediaRef {

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,7 @@ use gst::prelude::*;
use gst_sys;
use gst_video_sys;
#[repr(C)]
#[repr(transparent)]
pub struct VideoMeta(gst_video_sys::GstVideoMeta);
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);
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);
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);
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);
unsafe impl Send for VideoOverlayCompositionMeta {}
@ -482,7 +482,7 @@ impl fmt::Debug for VideoOverlayCompositionMeta {
}
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[repr(C)]
#[repr(transparent)]
pub struct VideoCaptionMeta(gst_video_sys::GstVideoCaptionMeta);
#[cfg(any(feature = "v1_16", feature = "dox"))]
@ -544,7 +544,7 @@ impl fmt::Debug for VideoCaptionMeta {
}
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[repr(C)]
#[repr(transparent)]
pub struct VideoAFDMeta(gst_video_sys::GstVideoAFDMeta);
#[cfg(any(feature = "v1_18", feature = "dox"))]
@ -608,7 +608,7 @@ impl fmt::Debug for VideoAFDMeta {
}
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[repr(C)]
#[repr(transparent)]
pub struct VideoBarMeta(gst_video_sys::GstVideoBarMeta);
#[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);
unsafe impl Send for VideoTimeCodeMeta {}

View file

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

View file

@ -175,7 +175,7 @@ impl ClockId {
}
}
#[repr(C)]
#[repr(transparent)]
#[derive(Debug)]
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);
unsafe impl Send for Meta {}
@ -255,7 +255,7 @@ impl fmt::Debug for Meta {
}
}
#[repr(C)]
#[repr(transparent)]
pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta);
unsafe impl Send for ParentBufferMeta {}
@ -299,7 +299,7 @@ impl fmt::Debug for ParentBufferMeta {
}
}
#[repr(C)]
#[repr(transparent)]
pub struct ProtectionMeta(gst_sys::GstProtectionMeta);
unsafe impl Send for ProtectionMeta {}
@ -342,7 +342,7 @@ impl fmt::Debug for ProtectionMeta {
}
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[repr(C)]
#[repr(transparent)]
pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta);
#[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>,
}
#[repr(C)]
#[repr(transparent)]
pub struct $ref_name($gst_sys_name);
impl $name {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,7 +19,7 @@ use glib_sys;
use std::ptr;
use std::slice;
#[repr(C)]
#[repr(transparent)]
#[derive(Debug)]
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);
impl SendValue {
pub(crate) fn from(send_value: glib::SendValue) -> Self {

View file

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