From a6c8fe0c8ae8d340ec3562e341d6a8ec21c9e4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 24 Oct 2020 20:06:59 +0300 Subject: [PATCH] Use repr(transparent) where it is more correct and get rid of some unneeded repr(C) --- examples/src/bin/custom_meta.rs | 2 +- examples/src/examples-common.rs | 1 - gstreamer-audio/src/audio_meta.rs | 4 ++-- gstreamer-audio/src/audio_ring_buffer_spec.rs | 2 +- gstreamer-gl/src/gl_sync_meta.rs | 2 +- gstreamer-net/src/net_address_meta.rs | 2 +- gstreamer-sdp/src/sdp_attribute.rs | 2 +- gstreamer-sdp/src/sdp_bandwidth.rs | 2 +- gstreamer-sdp/src/sdp_connection.rs | 2 +- gstreamer-sdp/src/sdp_key.rs | 2 +- gstreamer-sdp/src/sdp_media.rs | 2 +- gstreamer-sdp/src/sdp_message.rs | 2 +- gstreamer-sdp/src/sdp_origin.rs | 2 +- gstreamer-sdp/src/sdp_time.rs | 2 +- gstreamer-sdp/src/sdp_zone.rs | 2 +- gstreamer-video/src/video_meta.rs | 16 ++++++++-------- gstreamer-video/src/video_time_code.rs | 2 +- gstreamer/src/caps_features.rs | 2 +- gstreamer/src/clock.rs | 2 +- gstreamer/src/meta.rs | 8 ++++---- gstreamer/src/miniobject.rs | 2 +- gstreamer/src/segment.rs | 2 +- gstreamer/src/static_caps.rs | 1 - gstreamer/src/static_pad_template.rs | 1 - gstreamer/src/structure.rs | 2 +- gstreamer/src/subclass/plugin_1_12.rs | 2 +- gstreamer/src/subclass/plugin_1_14.rs | 2 +- gstreamer/src/typefind.rs | 2 +- gstreamer/src/value_serde.rs | 2 +- tutorials/src/tutorials-common.rs | 1 - 30 files changed, 37 insertions(+), 41 deletions(-) diff --git a/examples/src/bin/custom_meta.rs b/examples/src/bin/custom_meta.rs index 904a83cd0..f25c32e3c 100644 --- a/examples/src/bin/custom_meta.rs +++ b/examples/src/bin/custom_meta.rs @@ -16,7 +16,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. diff --git a/examples/src/examples-common.rs b/examples/src/examples-common.rs index f22be66f2..353adb4c9 100644 --- a/examples/src/examples-common.rs +++ b/examples/src/examples-common.rs @@ -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")] diff --git a/gstreamer-audio/src/audio_meta.rs b/gstreamer-audio/src/audio_meta.rs index c3cd58837..1e73a6b60 100644 --- a/gstreamer-audio/src/audio_meta.rs +++ b/gstreamer-audio/src/audio_meta.rs @@ -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"))] diff --git a/gstreamer-audio/src/audio_ring_buffer_spec.rs b/gstreamer-audio/src/audio_ring_buffer_spec.rs index 47f7ebbbd..e1e3a7509 100644 --- a/gstreamer-audio/src/audio_ring_buffer_spec.rs +++ b/gstreamer-audio/src/audio_ring_buffer_spec.rs @@ -7,7 +7,7 @@ use AudioRingBufferFormatType; use std::fmt; -#[repr(C)] +#[repr(transparent)] pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec); impl AudioRingBufferSpec { diff --git a/gstreamer-gl/src/gl_sync_meta.rs b/gstreamer-gl/src/gl_sync_meta.rs index f491b1d18..1302f6018 100644 --- a/gstreamer-gl/src/gl_sync_meta.rs +++ b/gstreamer-gl/src/gl_sync_meta.rs @@ -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 {} diff --git a/gstreamer-net/src/net_address_meta.rs b/gstreamer-net/src/net_address_meta.rs index c0ff92164..ffd22144d 100644 --- a/gstreamer-net/src/net_address_meta.rs +++ b/gstreamer-net/src/net_address_meta.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_attribute.rs b/gstreamer-sdp/src/sdp_attribute.rs index af78855cf..8f16cb0a8 100644 --- a/gstreamer-sdp/src/sdp_attribute.rs +++ b/gstreamer-sdp/src/sdp_attribute.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_bandwidth.rs b/gstreamer-sdp/src/sdp_bandwidth.rs index f1e97c43d..699217362 100644 --- a/gstreamer-sdp/src/sdp_bandwidth.rs +++ b/gstreamer-sdp/src/sdp_bandwidth.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_connection.rs b/gstreamer-sdp/src/sdp_connection.rs index 55eacae42..2f20b3c43 100644 --- a/gstreamer-sdp/src/sdp_connection.rs +++ b/gstreamer-sdp/src/sdp_connection.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_key.rs b/gstreamer-sdp/src/sdp_key.rs index 737120fe6..ed717a4ec 100644 --- a/gstreamer-sdp/src/sdp_key.rs +++ b/gstreamer-sdp/src/sdp_key.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index c8200d976..89fc567fe 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -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 { diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index d8a2b20fb..cbc88472c 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -119,7 +119,7 @@ impl SDPMessage { } } -#[repr(C)] +#[repr(transparent)] pub struct SDPMessageRef(gst_sdp_sys::GstSDPMessage); impl fmt::Debug for SDPMessageRef { diff --git a/gstreamer-sdp/src/sdp_origin.rs b/gstreamer-sdp/src/sdp_origin.rs index d016eb525..30c698715 100644 --- a/gstreamer-sdp/src/sdp_origin.rs +++ b/gstreamer-sdp/src/sdp_origin.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_time.rs b/gstreamer-sdp/src/sdp_time.rs index 5fc5d436f..41fad78de 100644 --- a/gstreamer-sdp/src/sdp_time.rs +++ b/gstreamer-sdp/src/sdp_time.rs @@ -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 {} diff --git a/gstreamer-sdp/src/sdp_zone.rs b/gstreamer-sdp/src/sdp_zone.rs index 8868058df..5f6c9b14a 100644 --- a/gstreamer-sdp/src/sdp_zone.rs +++ b/gstreamer-sdp/src/sdp_zone.rs @@ -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 {} diff --git a/gstreamer-video/src/video_meta.rs b/gstreamer-video/src/video_meta.rs index b728a2d43..be3dfa866 100644 --- a/gstreamer-video/src/video_meta.rs +++ b/gstreamer-video/src/video_meta.rs @@ -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"))] diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index c037982cd..bf447ecdd 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -525,7 +525,7 @@ impl From for VideoTimeCode { } } -#[repr(C)] +#[repr(transparent)] pub struct VideoTimeCodeMeta(gst_video_sys::GstVideoTimeCodeMeta); unsafe impl Send for VideoTimeCodeMeta {} diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index 1ee2488f7..f3898312a 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -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 { diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 79afb9767..a2bd02502 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -309,7 +309,7 @@ impl PeriodicClockId { } } -#[repr(C)] +#[repr(transparent)] #[derive(Debug)] pub struct AtomicClockReturn(AtomicI32); diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index 1363a2620..877043aa7 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -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"))] diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index decef0252..99a2f88cd 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -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 { diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 1e9f39ae6..66becac06 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -22,7 +22,7 @@ use SeekFlags; use SeekType; pub type Segment = FormattedSegment; -#[repr(C)] +#[repr(transparent)] pub struct FormattedSegment(gst_sys::GstSegment, PhantomData); impl Segment { diff --git a/gstreamer/src/static_caps.rs b/gstreamer/src/static_caps.rs index b874dfbac..49f3b789e 100644 --- a/gstreamer/src/static_caps.rs +++ b/gstreamer/src/static_caps.rs @@ -19,7 +19,6 @@ use std::ffi::CStr; use std::fmt; use std::ptr; -#[repr(C)] pub struct StaticCaps(ptr::NonNull); impl StaticCaps { diff --git a/gstreamer/src/static_pad_template.rs b/gstreamer/src/static_pad_template.rs index 2d25e8eeb..97e33532e 100644 --- a/gstreamer/src/static_pad_template.rs +++ b/gstreamer/src/static_pad_template.rs @@ -20,7 +20,6 @@ use std::ffi::CStr; use std::fmt; use std::ptr; -#[repr(C)] pub struct StaticPadTemplate(ptr::NonNull); impl StaticPadTemplate { diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index c2fd3def0..f9cf9d8fe 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -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 {} diff --git a/gstreamer/src/subclass/plugin_1_12.rs b/gstreamer/src/subclass/plugin_1_12.rs index 95ca24eff..0dfebf143 100644 --- a/gstreamer/src/subclass/plugin_1_12.rs +++ b/gstreamer/src/subclass/plugin_1_12.rs @@ -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 {} diff --git a/gstreamer/src/subclass/plugin_1_14.rs b/gstreamer/src/subclass/plugin_1_14.rs index 3aa95186f..539590c17 100644 --- a/gstreamer/src/subclass/plugin_1_14.rs +++ b/gstreamer/src/subclass/plugin_1_14.rs @@ -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 {} diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 8a4f58de5..28028851b 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -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); diff --git a/gstreamer/src/value_serde.rs b/gstreamer/src/value_serde.rs index 5c0aac113..67f8313be 100644 --- a/gstreamer/src/value_serde.rs +++ b/gstreamer/src/value_serde.rs @@ -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 { diff --git a/tutorials/src/tutorials-common.rs b/tutorials/src/tutorials-common.rs index f22be66f2..353adb4c9 100644 --- a/tutorials/src/tutorials-common.rs +++ b/tutorials/src/tutorials-common.rs @@ -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")]