Simplify IsSubclassable::override_vfunc() implementations

This commit is contained in:
Sebastian Dröge 2020-11-05 19:07:31 +02:00 committed by Sebastian Dröge
parent 99fbbc32cb
commit b91123d298
27 changed files with 273 additions and 337 deletions

View file

@ -515,8 +515,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioDecoderClass);
let klass = klass.as_mut();
klass.open = Some(audio_decoder_open::<T>);
klass.close = Some(audio_decoder_close::<T>);
klass.start = Some(audio_decoder_start::<T>);
@ -536,7 +535,6 @@ where
klass.decide_allocation = Some(audio_decoder_decide_allocation::<T>);
}
}
}
unsafe extern "C" fn audio_decoder_open<T: AudioDecoderImpl>(
ptr: *mut gst_audio_sys::GstAudioDecoder,

View file

@ -464,8 +464,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioEncoderClass);
let klass = klass.as_mut();
klass.open = Some(audio_encoder_open::<T>);
klass.close = Some(audio_encoder_close::<T>);
klass.start = Some(audio_encoder_start::<T>);
@ -484,7 +483,6 @@ where
klass.decide_allocation = Some(audio_encoder_decide_allocation::<T>);
}
}
}
unsafe extern "C" fn audio_encoder_open<T: AudioEncoderImpl>(
ptr: *mut gst_audio_sys::GstAudioEncoder,

View file

@ -190,8 +190,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst_base::BaseSink as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioSinkClass);
let klass = klass.as_mut();
klass.close = Some(audiosink_close::<T>);
klass.delay = Some(audiosink_delay::<T>);
klass.open = Some(audiosink_open::<T>);
@ -201,7 +200,6 @@ where
klass.reset = Some(audiosink_reset::<T>);
}
}
}
unsafe extern "C" fn audiosink_close<T: AudioSinkImpl>(
ptr: *mut gst_audio_sys::GstAudioSink,

View file

@ -206,8 +206,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst_base::BaseSrc as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioSrcClass);
let klass = klass.as_mut();
klass.close = Some(audiosrc_close::<T>);
klass.delay = Some(audiosrc_delay::<T>);
klass.open = Some(audiosrc_open::<T>);
@ -217,7 +216,6 @@ where
klass.reset = Some(audiosrc_reset::<T>);
}
}
}
unsafe extern "C" fn audiosrc_close<T: AudioSrcImpl>(
ptr: *mut gst_audio_sys::GstAudioSrc,

View file

@ -678,8 +678,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstAggregatorClass);
let klass = klass.as_mut();
klass.flush = Some(aggregator_flush::<T>);
klass.clip = Some(aggregator_clip::<T>);
klass.finish_buffer = Some(aggregator_finish_buffer::<T>);
@ -706,7 +705,6 @@ where
}
}
}
}
unsafe extern "C" fn aggregator_flush<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,

View file

@ -102,13 +102,11 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
unsafe impl<T: AggregatorPadImpl> IsSubclassable<T> for AggregatorPad {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Pad as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstAggregatorPadClass);
let klass = klass.as_mut();
klass.flush = Some(aggregator_pad_flush::<T>);
klass.skip_buffer = Some(aggregator_pad_skip_buffer::<T>);
}
}
}
unsafe extern "C" fn aggregator_pad_flush<T: AggregatorPadImpl>(
ptr: *mut gst_base_sys::GstAggregatorPad,

View file

@ -220,8 +220,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseParseClass);
let klass = klass.as_mut();
klass.start = Some(base_parse_start::<T>);
klass.stop = Some(base_parse_stop::<T>);
klass.set_sink_caps = Some(base_parse_set_sink_caps::<T>);
@ -229,7 +228,6 @@ where
klass.convert = Some(base_parse_convert::<T>);
}
}
}
unsafe extern "C" fn base_parse_start<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,

View file

@ -386,8 +386,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseSinkClass);
let klass = klass.as_mut();
klass.start = Some(base_sink_start::<T>);
klass.stop = Some(base_sink_stop::<T>);
klass.render = Some(base_sink_render::<T>);
@ -403,7 +402,6 @@ where
klass.unlock_stop = Some(base_sink_unlock_stop::<T>);
}
}
}
unsafe extern "C" fn base_sink_start<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,

View file

@ -575,8 +575,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseSrcClass);
let klass = klass.as_mut();
klass.start = Some(base_src_start::<T>);
klass.stop = Some(base_src_stop::<T>);
klass.is_seekable = Some(base_src_is_seekable::<T>);
@ -596,7 +595,6 @@ where
klass.unlock_stop = Some(base_src_unlock_stop::<T>);
}
}
}
unsafe extern "C" fn base_src_start<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,

View file

@ -832,8 +832,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseTransformClass);
let klass = klass.as_mut();
klass.start = Some(base_transform_start::<T>);
klass.stop = Some(base_transform_stop::<T>);
klass.transform_caps = Some(base_transform_transform_caps::<T>);
@ -853,7 +852,6 @@ where
klass.generate_output = Some(base_transform_generate_output::<T>);
}
}
}
pub unsafe trait BaseTransformClassSubclassExt: Sized + 'static {
fn configure<T: BaseTransformImpl>(

View file

@ -119,14 +119,12 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::BaseSrc as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstPushSrcClass);
let klass = klass.as_mut();
klass.fill = Some(push_src_fill::<T>);
klass.alloc = Some(push_src_alloc::<T>);
klass.create = Some(push_src_create::<T>);
}
}
}
unsafe extern "C" fn push_src_fill<T: PushSrcImpl>(
ptr: *mut gst_base_sys::GstPushSrc,

View file

@ -795,8 +795,7 @@ impl<T: RTSPClientImpl> RTSPClientImplExt for T {
unsafe impl<T: RTSPClientImpl> IsSubclassable<T> for RTSPClient {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPClientClass);
let klass = klass.as_mut();
klass.create_sdp = Some(client_create_sdp::<T>);
klass.configure_client_media = Some(client_configure_client_media::<T>);
klass.params_set = Some(client_params_set::<T>);
@ -829,7 +828,6 @@ unsafe impl<T: RTSPClientImpl> IsSubclassable<T> for RTSPClient {
klass.pre_record_request = Some(client_pre_record_request::<T>);
}
}
}
unsafe extern "C" fn client_create_sdp<T: RTSPClientImpl>(
ptr: *mut gst_rtsp_server_sys::GstRTSPClient,

View file

@ -451,8 +451,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
unsafe impl<T: RTSPMediaImpl> IsSubclassable<T> for RTSPMedia {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPMediaClass);
let klass = klass.as_mut();
klass.handle_message = Some(media_handle_message::<T>);
klass.prepare = Some(media_prepare::<T>);
klass.unprepare = Some(media_unprepare::<T>);
@ -472,7 +471,6 @@ unsafe impl<T: RTSPMediaImpl> IsSubclassable<T> for RTSPMedia {
klass.handle_sdp = Some(media_handle_sdp::<T>);
}
}
}
unsafe extern "C" fn media_handle_message<T: RTSPMediaImpl>(
ptr: *mut gst_rtsp_server_sys::GstRTSPMedia,

View file

@ -204,9 +204,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
unsafe impl<T: RTSPMediaFactoryImpl> IsSubclassable<T> for RTSPMediaFactory {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass =
&mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass);
let klass = klass.as_mut();
klass.gen_key = Some(factory_gen_key::<T>);
klass.create_element = Some(factory_create_element::<T>);
klass.construct = Some(factory_construct::<T>);
@ -216,7 +214,6 @@ unsafe impl<T: RTSPMediaFactoryImpl> IsSubclassable<T> for RTSPMediaFactory {
klass.media_configure = Some(factory_media_configure::<T>);
}
}
}
unsafe extern "C" fn factory_gen_key<T: RTSPMediaFactoryImpl>(
ptr: *mut gst_rtsp_server_sys::GstRTSPMediaFactory,

View file

@ -56,13 +56,11 @@ impl<T: RTSPServerImpl> RTSPServerImplExt for T {
unsafe impl<T: RTSPServerImpl> IsSubclassable<T> for RTSPServer {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPServerClass);
let klass = klass.as_mut();
klass.create_client = Some(server_create_client::<T>);
klass.client_connected = Some(server_client_connected::<T>);
}
}
}
unsafe extern "C" fn server_create_client<T: RTSPServerImpl>(
ptr: *mut gst_rtsp_server_sys::GstRTSPServer,

View file

@ -504,8 +504,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoDecoderClass);
let klass = klass.as_mut();
klass.open = Some(video_decoder_open::<T>);
klass.close = Some(video_decoder_close::<T>);
klass.start = Some(video_decoder_start::<T>);
@ -526,7 +525,6 @@ where
klass.decide_allocation = Some(video_decoder_decide_allocation::<T>);
}
}
}
unsafe extern "C" fn video_decoder_open<T: VideoDecoderImpl>(
ptr: *mut gst_video_sys::GstVideoDecoder,

View file

@ -440,8 +440,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoEncoderClass);
let klass = klass.as_mut();
klass.open = Some(video_encoder_open::<T>);
klass.close = Some(video_encoder_close::<T>);
klass.start = Some(video_encoder_start::<T>);
@ -460,7 +459,6 @@ where
klass.decide_allocation = Some(video_encoder_decide_allocation::<T>);
}
}
}
unsafe extern "C" fn video_encoder_open<T: VideoEncoderImpl>(
ptr: *mut gst_video_sys::GstVideoEncoder,

View file

@ -63,12 +63,10 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<gst_base::BaseSink as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoSinkClass);
let klass = klass.as_mut();
klass.show_frame = Some(video_sink_show_frame::<T>);
}
}
}
unsafe extern "C" fn video_sink_show_frame<T: VideoSinkImpl>(
ptr: *mut gst_video_sys::GstVideoSink,

View file

@ -92,14 +92,12 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::Element as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstBinClass);
let klass = klass.as_mut();
klass.add_element = Some(bin_add_element::<T>);
klass.remove_element = Some(bin_remove_element::<T>);
klass.handle_message = Some(bin_handle_message::<T>);
}
}
}
unsafe extern "C" fn bin_add_element<T: BinImpl>(
ptr: *mut gst_sys::GstBin,

View file

@ -235,9 +235,7 @@ impl<T: ClockImpl> ClockImplExt for T {
unsafe impl<T: ClockImpl> IsSubclassable<T> for Clock {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstClockClass);
let klass = klass.as_mut();
klass.change_resolution = Some(clock_change_resolution::<T>);
klass.get_resolution = Some(clock_get_resolution::<T>);
klass.get_internal_time = Some(clock_get_internal_time::<T>);
@ -246,7 +244,6 @@ unsafe impl<T: ClockImpl> IsSubclassable<T> for Clock {
klass.unschedule = Some(clock_unschedule::<T>);
}
}
}
unsafe extern "C" fn clock_change_resolution<T: ClockImpl>(
ptr: *mut gst_sys::GstClock,

View file

@ -101,13 +101,11 @@ impl<T: DeviceImpl> DeviceImplExt for T {
unsafe impl<T: DeviceImpl> IsSubclassable<T> for Device {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstDeviceClass);
let klass = klass.as_mut();
klass.create_element = Some(device_create_element::<T>);
klass.reconfigure_element = Some(device_reconfigure_element::<T>);
}
}
}
unsafe extern "C" fn device_create_element<T: DeviceImpl>(
ptr: *mut gst_sys::GstDevice,

View file

@ -117,14 +117,12 @@ unsafe impl DeviceProviderClassSubclassExt for DeviceProviderClass {}
unsafe impl<T: DeviceProviderImpl> IsSubclassable<T> for DeviceProvider {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstDeviceProviderClass);
let klass = klass.as_mut();
klass.probe = Some(device_provider_probe::<T>);
klass.start = Some(device_provider_start::<T>);
klass.stop = Some(device_provider_stop::<T>);
}
}
}
unsafe extern "C" fn device_provider_probe<T: DeviceProviderImpl>(
ptr: *mut gst_sys::GstDeviceProvider,

View file

@ -344,9 +344,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstElementClass);
let klass = klass.as_mut();
klass.change_state = Some(element_change_state::<T>);
klass.request_new_pad = Some(element_request_new_pad::<T>);
klass.release_pad = Some(element_release_pad::<T>);
@ -358,7 +356,6 @@ where
klass.post_message = Some(element_post_message::<T>);
}
}
}
unsafe extern "C" fn element_change_state<T: ElementImpl>(
ptr: *mut gst_sys::GstElement,

View file

@ -6,8 +6,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use gst_sys;
use super::prelude::*;
use glib::subclass::prelude::*;
@ -18,9 +16,7 @@ pub trait GhostPadImpl: PadImpl {}
unsafe impl<T: GhostPadImpl> IsSubclassable<T> for GhostPad {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::Pad as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstGhostPadClass);
let _klass = klass.as_mut();
// Nothing to do here
}
}
}

View file

@ -60,14 +60,11 @@ impl<T: PadImpl> PadImplExt for T {
unsafe impl<T: PadImpl> IsSubclassable<T> for Pad {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let klass = &mut *(klass.as_mut() as *mut gst_sys::GstPadClass);
let klass = klass.as_mut();
klass.linked = Some(pad_linked::<T>);
klass.unlinked = Some(pad_unlinked::<T>);
}
}
}
unsafe extern "C" fn pad_linked<T: PadImpl>(ptr: *mut gst_sys::GstPad, peer: *mut gst_sys::GstPad) {
let instance = &*(ptr as *mut T::Instance);

View file

@ -6,8 +6,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use gst_sys;
use super::prelude::*;
use glib::subclass::prelude::*;
@ -21,9 +19,7 @@ where
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::Bin as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstPipelineClass);
let _klass = klass.as_mut();
// Nothing to do here
}
}
}

View file

@ -6,8 +6,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use gst_sys;
use super::prelude::*;
use glib::subclass::prelude::*;
@ -18,9 +16,7 @@ pub trait SystemClockImpl: ClockImpl {}
unsafe impl<T: SystemClockImpl> IsSubclassable<T> for SystemClock {
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::Clock as IsSubclassable<T>>::override_vfuncs(klass);
unsafe {
let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstSystemClockClass);
let _klass = klass.as_mut();
// Nothing to do here
}
}
}