diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation.rs b/gdk-pixbuf/src/subclass/pixbuf_animation.rs index ee5ff297496d..ae08ed4ede66 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation.rs @@ -15,6 +15,7 @@ use crate::{ffi, Pixbuf, PixbufAnimation, PixbufAnimationIter}; pub trait PixbufAnimationImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn is_static_image(&self) -> bool { @@ -36,6 +37,7 @@ where pub trait PixbufAnimationImplExt: ObjectSubclass + PixbufAnimationImpl where + ::Type: IsA, ::Type: IsA, { fn parent_is_static_image(&self) -> bool { @@ -117,13 +119,16 @@ where } } -impl PixbufAnimationImplExt for T where - ::Type: IsA +impl PixbufAnimationImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsSubclassable for PixbufAnimation where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -141,6 +146,7 @@ unsafe extern "C" fn animation_is_static_image( ptr: *mut ffi::GdkPixbufAnimation, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -154,6 +160,7 @@ unsafe extern "C" fn animation_get_size( width_ptr: *mut libc::c_int, height_ptr: *mut libc::c_int, ) where + ::Type: IsA, ::Type: IsA, { if width_ptr.is_null() && height_ptr.is_null() { @@ -176,6 +183,7 @@ unsafe extern "C" fn animation_get_static_image( ptr: *mut ffi::GdkPixbufAnimation, ) -> *mut ffi::GdkPixbuf where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -209,6 +217,7 @@ unsafe extern "C" fn animation_get_iter( start_time_ptr: *const glib::ffi::GTimeVal, ) -> *mut ffi::GdkPixbufAnimationIter where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs index 03e16a1db22c..d3a104a2e8b8 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs @@ -14,6 +14,7 @@ use crate::{ffi, Pixbuf, PixbufAnimationIter}; pub trait PixbufAnimationIterImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { // rustdoc-stripper-ignore-next @@ -37,6 +38,7 @@ where pub trait PixbufAnimationIterImplExt: ObjectSubclass + PixbufAnimationIterImpl where + ::Type: IsA, ::Type: IsA, { fn parent_delay_time(&self) -> Option { @@ -122,13 +124,16 @@ where } } -impl PixbufAnimationIterImplExt for T where - ::Type: IsA +impl PixbufAnimationIterImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsSubclassable for PixbufAnimationIter where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -146,6 +151,7 @@ unsafe extern "C" fn animation_iter_get_delay_time( ptr: *mut ffi::GdkPixbufAnimationIter, ) -> i32 where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -158,6 +164,7 @@ unsafe extern "C" fn animation_iter_get_pixbuf( ptr: *mut ffi::GdkPixbufAnimationIter, ) -> *mut ffi::GdkPixbuf where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -177,6 +184,7 @@ unsafe extern "C" fn animation_iter_on_currently_loading_frame glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -190,6 +198,7 @@ unsafe extern "C" fn animation_iter_advance( current_time_ptr: *const glib::ffi::GTimeVal, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gdk-pixbuf/src/subclass/pixbuf_loader.rs b/gdk-pixbuf/src/subclass/pixbuf_loader.rs index e99388644043..a1b7b0d12175 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_loader.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_loader.rs @@ -9,6 +9,7 @@ use crate::{ffi, PixbufLoader}; pub trait PixbufLoaderImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn size_prepared(&self, width: i32, height: i32) { @@ -30,6 +31,7 @@ where pub trait PixbufLoaderImplExt: ObjectSubclass + PixbufLoaderImpl where + ::Type: IsA, ::Type: IsA, { fn parent_size_prepared(&self, width: i32, height: i32) { @@ -97,13 +99,16 @@ where } } -impl PixbufLoaderImplExt for T where - ::Type: IsA +impl PixbufLoaderImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsSubclassable for PixbufLoader where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -122,6 +127,7 @@ unsafe extern "C" fn loader_size_prepared( width: i32, height: i32, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -132,6 +138,7 @@ unsafe extern "C" fn loader_size_prepared( unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -147,6 +154,7 @@ unsafe extern "C" fn loader_area_updated( width: i32, height: i32, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -157,6 +165,7 @@ unsafe extern "C" fn loader_area_updated( unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gio/src/subclass/action_group.rs b/gio/src/subclass/action_group.rs index ca895077889a..69fd5168ef65 100644 --- a/gio/src/subclass/action_group.rs +++ b/gio/src/subclass/action_group.rs @@ -8,6 +8,7 @@ use crate::{ffi, ActionGroup}; pub trait ActionGroupImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn action_added(&self, action_name: &str) { @@ -78,6 +79,7 @@ where pub trait ActionGroupImplExt: ObjectSubclass + ActionGroupImpl where + ::Type: IsA, ::Type: IsA, { fn parent_action_added(&self, action_name: &str) { @@ -342,11 +344,16 @@ where } } -impl ActionGroupImplExt for T where ::Type: IsA -{} +impl ActionGroupImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsImplementable for ActionGroup where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -374,6 +381,7 @@ unsafe extern "C" fn action_group_has_action( action_nameptr: *const libc::c_char, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -388,6 +396,7 @@ unsafe extern "C" fn action_group_get_action_enabled( action_nameptr: *const libc::c_char, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -412,6 +421,7 @@ unsafe extern "C" fn action_group_get_action_parameter_type( action_nameptr: *const libc::c_char, ) -> *const glib::ffi::GVariantType where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -444,6 +454,7 @@ unsafe extern "C" fn action_group_get_action_state_type( action_nameptr: *const libc::c_char, ) -> *const glib::ffi::GVariantType where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -476,6 +487,7 @@ unsafe extern "C" fn action_group_get_action_state_hint( action_nameptr: *const libc::c_char, ) -> *mut glib::ffi::GVariant where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -507,6 +519,7 @@ unsafe extern "C" fn action_group_get_action_state( action_nameptr: *const libc::c_char, ) -> *mut glib::ffi::GVariant where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -536,6 +549,7 @@ unsafe extern "C" fn action_group_change_action_state( action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -551,6 +565,7 @@ unsafe extern "C" fn action_group_activate_action( action_nameptr: *const libc::c_char, parameterptr: *mut glib::ffi::GVariant, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -565,6 +580,7 @@ unsafe extern "C" fn action_group_action_added( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -578,6 +594,7 @@ unsafe extern "C" fn action_group_action_removed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -592,6 +609,7 @@ unsafe extern "C" fn action_group_action_enabled_changed( action_nameptr: *const libc::c_char, enabled: glib::ffi::gboolean, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -606,6 +624,7 @@ unsafe extern "C" fn action_group_action_state_changed( action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -620,6 +639,7 @@ unsafe extern "C" fn action_group_list_actions( action_group: *mut ffi::GActionGroup, ) -> *mut *mut libc::c_char where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); @@ -649,6 +669,7 @@ unsafe extern "C" fn action_group_query_action( state: *mut *mut glib::ffi::GVariant, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_group as *mut T::Instance); diff --git a/gio/src/subclass/action_map.rs b/gio/src/subclass/action_map.rs index 13b21ca01afc..6a30d68ec107 100644 --- a/gio/src/subclass/action_map.rs +++ b/gio/src/subclass/action_map.rs @@ -8,6 +8,7 @@ use crate::{ffi, Action, ActionMap}; pub trait ActionMapImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn lookup_action(&self, action_name: &str) -> Option; @@ -17,6 +18,7 @@ where pub trait ActionMapImplExt: ObjectSubclass + ActionMapImpl where + ::Type: IsA, ::Type: IsA, { fn parent_lookup_action(&self, name: &str) -> Option { @@ -69,10 +71,16 @@ where } } -impl ActionMapImplExt for T where ::Type: IsA {} +impl ActionMapImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsImplementable for ActionMap where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -89,6 +97,7 @@ unsafe extern "C" fn action_map_lookup_action( action_nameptr: *const libc::c_char, ) -> *mut ffi::GAction where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_map as *mut T::Instance); @@ -121,6 +130,7 @@ unsafe extern "C" fn action_map_add_action( action_map: *mut ffi::GActionMap, actionptr: *mut ffi::GAction, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_map as *mut T::Instance); @@ -134,6 +144,7 @@ unsafe extern "C" fn action_map_remove_action( action_map: *mut ffi::GActionMap, action_nameptr: *const libc::c_char, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(action_map as *mut T::Instance); diff --git a/gio/src/subclass/application.rs b/gio/src/subclass/application.rs index b9962f15078d..bee49e117bed 100644 --- a/gio/src/subclass/application.rs +++ b/gio/src/subclass/application.rs @@ -66,6 +66,7 @@ impl From for Vec { pub trait ApplicationImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn activate(&self) { @@ -115,6 +116,7 @@ where pub trait ApplicationImplExt: ObjectSubclass + ApplicationImpl where + ::Type: IsA, ::Type: IsA, { fn parent_activate(&self) { @@ -272,11 +274,16 @@ where } } -impl ApplicationImplExt for T where ::Type: IsA -{} +impl ApplicationImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsSubclassable for Application where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -299,6 +306,7 @@ where unsafe extern "C" fn application_activate(ptr: *mut ffi::GApplication) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -311,6 +319,7 @@ unsafe extern "C" fn application_after_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -322,6 +331,7 @@ unsafe extern "C" fn application_before_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -334,6 +344,7 @@ unsafe extern "C" fn application_command_line( command_line: *mut ffi::GApplicationCommandLine, ) -> i32 where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -347,6 +358,7 @@ unsafe extern "C" fn application_local_command_line( exit_status: *mut i32, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -370,6 +382,7 @@ unsafe extern "C" fn application_open( num_files: i32, hint: *const c_char, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -380,6 +393,7 @@ unsafe extern "C" fn application_open( } unsafe extern "C" fn application_quit_mainloop(ptr: *mut ffi::GApplication) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -389,6 +403,7 @@ where } unsafe extern "C" fn application_run_mainloop(ptr: *mut ffi::GApplication) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -398,6 +413,7 @@ where } unsafe extern "C" fn application_shutdown(ptr: *mut ffi::GApplication) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -407,6 +423,7 @@ where } unsafe extern "C" fn application_startup(ptr: *mut ffi::GApplication) where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -420,6 +437,7 @@ unsafe extern "C" fn application_handle_local_options( options: *mut glib::ffi::GVariantDict, ) -> c_int where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gio/src/subclass/async_initable.rs b/gio/src/subclass/async_initable.rs index 433ae27ac68d..07e36151f943 100644 --- a/gio/src/subclass/async_initable.rs +++ b/gio/src/subclass/async_initable.rs @@ -10,6 +10,7 @@ use crate::{ pub trait AsyncInitableImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn init_future( @@ -22,6 +23,7 @@ where pub trait AsyncInitableImplExt: ObjectSubclass + AsyncInitableImpl where + ::Type: IsA, ::Type: IsA, { fn parent_init_future( @@ -43,6 +45,7 @@ where user_data: glib::ffi::gpointer, ) where T: AsyncInitableImpl, + ::Type: IsA, ::Type: IsA, { let type_data = T::type_data(); @@ -85,13 +88,16 @@ where } } -impl AsyncInitableImplExt for T where - ::Type: IsA +impl AsyncInitableImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsImplementable for AsyncInitable where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -108,6 +114,7 @@ unsafe extern "C" fn async_initable_init_async( callback: ffi::GAsyncReadyCallback, user_data: glib::ffi::gpointer, ) where + ::Type: IsA, ::Type: IsA, { let instance = &*(initable as *mut T::Instance); diff --git a/gio/src/subclass/initable.rs b/gio/src/subclass/initable.rs index 9ad33d9bd364..4c83a6a89667 100644 --- a/gio/src/subclass/initable.rs +++ b/gio/src/subclass/initable.rs @@ -8,6 +8,7 @@ use crate::{ffi, Cancellable, Initable}; pub trait InitableImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { @@ -17,6 +18,7 @@ where pub trait InitableImplExt: ObjectSubclass + InitableImpl where + ::Type: IsA, ::Type: IsA, { fn parent_init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { @@ -45,10 +47,16 @@ where } } -impl InitableImplExt for T where ::Type: IsA {} +impl InitableImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsImplementable for Initable where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -63,6 +71,7 @@ unsafe extern "C" fn initable_init( error: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(initable as *mut T::Instance); diff --git a/gio/src/subclass/input_stream.rs b/gio/src/subclass/input_stream.rs index 7d8f97c48722..67295120e520 100644 --- a/gio/src/subclass/input_stream.rs +++ b/gio/src/subclass/input_stream.rs @@ -8,6 +8,7 @@ use crate::{ffi, Cancellable, InputStream}; pub trait InputStreamImpl: ObjectImpl + Send where + ::Type: IsA, ::Type: IsA, { fn read(&self, buffer: &mut [u8], cancellable: Option<&Cancellable>) -> Result { @@ -25,6 +26,7 @@ where pub trait InputStreamImplExt: ObjectSubclass + InputStreamImpl where + ::Type: IsA, ::Type: IsA, { fn parent_read( @@ -104,11 +106,16 @@ where } } -impl InputStreamImplExt for T where ::Type: IsA -{} +impl InputStreamImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsSubclassable for InputStream where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -129,6 +136,7 @@ unsafe extern "C" fn stream_read( err: *mut *mut glib::ffi::GError, ) -> isize where + ::Type: IsA, ::Type: IsA, { debug_assert!(count <= isize::MAX as usize); @@ -166,6 +174,7 @@ unsafe extern "C" fn stream_close( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -193,6 +202,7 @@ unsafe extern "C" fn stream_skip( err: *mut *mut glib::ffi::GError, ) -> isize where + ::Type: IsA, ::Type: IsA, { debug_assert!(count <= isize::MAX as usize); diff --git a/gio/src/subclass/io_stream.rs b/gio/src/subclass/io_stream.rs index fed6b9aeb6ca..193ab49a979e 100644 --- a/gio/src/subclass/io_stream.rs +++ b/gio/src/subclass/io_stream.rs @@ -8,6 +8,7 @@ use crate::{ffi, Cancellable, IOStream, InputStream, OutputStream}; pub trait IOStreamImpl: ObjectImpl + Send where + ::Type: IsA, ::Type: IsA, { fn input_stream(&self) -> InputStream { @@ -25,6 +26,7 @@ where pub trait IOStreamImplExt: ObjectSubclass + IOStreamImpl where + ::Type: IsA, ::Type: IsA, { fn parent_input_stream(&self) -> InputStream { @@ -71,10 +73,16 @@ where } } -impl IOStreamImplExt for T where ::Type: IsA {} +impl IOStreamImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsSubclassable for IOStream where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -91,6 +99,7 @@ unsafe extern "C" fn stream_get_input_stream( ptr: *mut ffi::GIOStream, ) -> *mut ffi::GInputStream where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -121,6 +130,7 @@ unsafe extern "C" fn stream_get_output_stream( ptr: *mut ffi::GIOStream, ) -> *mut ffi::GOutputStream where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -153,6 +163,7 @@ unsafe extern "C" fn stream_close( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gio/src/subclass/list_model.rs b/gio/src/subclass/list_model.rs index 8223739d7a6e..ebe0d4b7f9f5 100644 --- a/gio/src/subclass/list_model.rs +++ b/gio/src/subclass/list_model.rs @@ -8,6 +8,7 @@ use crate::{ffi, ListModel}; pub trait ListModelImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { #[doc(alias = "get_item_type")] @@ -20,6 +21,7 @@ where pub trait ListModelImplExt: ObjectSubclass + ListModelImpl where + ::Type: IsA, ::Type: IsA, { fn parent_item_type(&self) -> glib::Type { @@ -67,10 +69,16 @@ where } } -impl ListModelImplExt for T where ::Type: IsA {} +impl ListModelImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsImplementable for ListModel where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -86,6 +94,7 @@ unsafe extern "C" fn list_model_get_item_type( list_model: *mut ffi::GListModel, ) -> glib::ffi::GType where + ::Type: IsA, ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); @@ -118,6 +127,7 @@ unsafe extern "C" fn list_model_get_n_items( list_model: *mut ffi::GListModel, ) -> u32 where + ::Type: IsA, ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); @@ -131,6 +141,7 @@ unsafe extern "C" fn list_model_get_item( position: u32, ) -> *mut glib::gobject_ffi::GObject where + ::Type: IsA, ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); diff --git a/gio/src/subclass/output_stream.rs b/gio/src/subclass/output_stream.rs index e3836fad748d..11e1de18b707 100644 --- a/gio/src/subclass/output_stream.rs +++ b/gio/src/subclass/output_stream.rs @@ -8,6 +8,7 @@ use crate::{ffi, Cancellable, InputStream, OutputStream, OutputStreamSpliceFlags pub trait OutputStreamImpl: ObjectImpl + Send where + ::Type: IsA, ::Type: IsA, { fn write(&self, buffer: &[u8], cancellable: Option<&Cancellable>) -> Result { @@ -34,6 +35,7 @@ where pub trait OutputStreamImplExt: ObjectSubclass + OutputStreamImpl where + ::Type: IsA, ::Type: IsA, { fn parent_write( @@ -151,13 +153,16 @@ where } } -impl OutputStreamImplExt for T where - ::Type: IsA +impl OutputStreamImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsSubclassable for OutputStream where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -179,6 +184,7 @@ unsafe extern "C" fn stream_write( err: *mut *mut glib::ffi::GError, ) -> isize where + ::Type: IsA, ::Type: IsA, { debug_assert!(count <= isize::MAX as usize); @@ -216,6 +222,7 @@ unsafe extern "C" fn stream_close( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -242,6 +249,7 @@ unsafe extern "C" fn stream_flush( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -270,6 +278,7 @@ unsafe extern "C" fn stream_splice( err: *mut *mut glib::ffi::GError, ) -> isize where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); diff --git a/gio/src/subclass/seekable.rs b/gio/src/subclass/seekable.rs index dd8a70f2ddeb..d713e20302c0 100644 --- a/gio/src/subclass/seekable.rs +++ b/gio/src/subclass/seekable.rs @@ -8,6 +8,7 @@ use crate::{ffi, Cancellable, Seekable}; pub trait SeekableImpl: ObjectImpl + Send where + ::Type: IsA, ::Type: IsA, { fn tell(&self) -> i64; @@ -24,6 +25,7 @@ where pub trait SeekableImplExt: ObjectSubclass + SeekableImpl where + ::Type: IsA, ::Type: IsA, { fn parent_tell(&self) -> i64 { @@ -126,10 +128,16 @@ where } } -impl SeekableImplExt for T where ::Type: IsA {} +impl SeekableImplExt for T +where + ::Type: IsA, + ::Type: IsA, +{ +} unsafe impl IsImplementable for Seekable where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { @@ -145,6 +153,7 @@ where unsafe extern "C" fn seekable_tell(seekable: *mut ffi::GSeekable) -> i64 where + ::Type: IsA, ::Type: IsA, { let instance = &*(seekable as *mut T::Instance); @@ -157,6 +166,7 @@ unsafe extern "C" fn seekable_can_seek( seekable: *mut ffi::GSeekable, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(seekable as *mut T::Instance); @@ -173,6 +183,7 @@ unsafe extern "C" fn seekable_seek( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(seekable as *mut T::Instance); @@ -199,6 +210,7 @@ unsafe extern "C" fn seekable_can_truncate( seekable: *mut ffi::GSeekable, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(seekable as *mut T::Instance); @@ -214,6 +226,7 @@ unsafe extern "C" fn seekable_truncate( err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(seekable as *mut T::Instance); diff --git a/gio/src/subclass/socket_control_message.rs b/gio/src/subclass/socket_control_message.rs index 6eed7637fb7a..230604e08a47 100644 --- a/gio/src/subclass/socket_control_message.rs +++ b/gio/src/subclass/socket_control_message.rs @@ -6,6 +6,7 @@ use crate::{ffi, SocketControlMessage}; pub trait SocketControlMessageImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn level(&self) -> i32 { @@ -31,6 +32,7 @@ where pub trait SocketControlMessageImplExt: ObjectSubclass + SocketControlMessageImpl where + ::Type: IsA, ::Type: IsA, { fn parent_level(&self) -> i32 { @@ -114,13 +116,16 @@ where } } -impl SocketControlMessageImplExt for T where - ::Type: IsA +impl SocketControlMessageImplExt for T +where + ::Type: IsA, + ::Type: IsA, { } unsafe impl IsSubclassable for SocketControlMessage where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut ::glib::Class) { @@ -139,6 +144,7 @@ unsafe extern "C" fn socket_control_message_get_level i32 where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -151,6 +157,7 @@ unsafe extern "C" fn socket_control_message_get_type i32 where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -163,6 +170,7 @@ unsafe extern "C" fn socket_control_message_get_size usize where + ::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -175,6 +183,7 @@ unsafe extern "C" fn socket_control_message_serialize::Type: IsA, ::Type: IsA, { let instance = &*(ptr as *mut T::Instance); @@ -192,6 +201,7 @@ unsafe extern "C" fn socket_control_message_deserialize *mut ffi::GSocketControlMessage where + ::Type: IsA, ::Type: IsA, { let data = std::slice::from_raw_parts(data as *mut u8, size); diff --git a/glib-macros/tests/object_subclass_dynamic.rs b/glib-macros/tests/object_subclass_dynamic.rs index 31ad917d215c..2b5a0bae9d8c 100644 --- a/glib-macros/tests/object_subclass_dynamic.rs +++ b/glib-macros/tests/object_subclass_dynamic.rs @@ -28,7 +28,12 @@ mod static_ { type Interface = MyStaticInterfaceClass; } - pub trait MyStaticInterfaceImpl: ObjectImpl + ObjectSubclass {} + pub trait MyStaticInterfaceImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + ::Type: IsA, + { + } // impl for an object subclass to register as a static type and that implements `MyStaticInterface`. #[derive(Default)] @@ -45,7 +50,12 @@ mod static_ { impl MyStaticInterfaceImpl for MyStaticType {} - pub trait MyStaticTypeImpl: ObjectImpl + ObjectSubclass {} + pub trait MyStaticTypeImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + ::Type: IsA, + { + } } // an object interface to register as a static type. @@ -53,14 +63,24 @@ mod static_ { pub struct MyStaticInterface(ObjectInterface); } - unsafe impl IsImplementable for MyStaticInterface {} + unsafe impl IsImplementable for MyStaticInterface + where + ::Type: IsA, + ::Type: IsA, + { + } // an object subclass to register as a static type and that implements `MyStaticInterface`. glib::wrapper! { pub struct MyStaticType(ObjectSubclass) @implements MyStaticInterface; } - unsafe impl IsSubclassable for MyStaticType {} + unsafe impl IsSubclassable for MyStaticType + where + ::Type: IsA, + ::Type: IsA, + { + } } use static_::{ @@ -95,7 +115,11 @@ mod module { type Interface = MyModuleInterfaceClass; } - pub trait MyModuleInterfaceImpl: ObjectImpl + ObjectSubclass {} + pub trait MyModuleInterfaceImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + { + } // impl for an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyModuleInterface`. #[derive(Default)] @@ -139,7 +163,12 @@ mod module { type Interface = MyModuleInterfaceLazyClass; } - pub trait MyModuleInterfaceLazyImpl: ObjectImpl + ObjectSubclass {} + pub trait MyModuleInterfaceLazyImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + ::Type: IsA, + { + } // impl for an object subclass to lazy register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyModuleInterfaceLazy`. #[derive(Default)] @@ -206,7 +235,12 @@ mod module { pub struct MyModuleInterface(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyModuleInterface {} + unsafe impl IsImplementable for MyModuleInterface + where + ::Type: IsA, + ::Type: IsA, + { + } // an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyModuleInterface`. glib::wrapper! { @@ -218,7 +252,12 @@ mod module { pub struct MyModuleInterfaceLazy(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyModuleInterfaceLazy {} + unsafe impl IsImplementable for MyModuleInterfaceLazy + where + ::Type: IsA, + ::Type: IsA, + { + } // an object subclass to lazy register as a dynamic type and that extends `MyStaticType` that implements `MyStaticInterface` and `MyModuleInterfaceLazy`. glib::wrapper! { @@ -335,7 +374,12 @@ pub mod plugin { type Interface = MyPluginInterfaceClass; } - pub trait MyPluginInterfaceImpl: ObjectImpl + ObjectSubclass {} + pub trait MyPluginInterfaceImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + ::Type: IsA, + { + } // impl for an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyPluginInterface`. #[derive(Default)] @@ -379,7 +423,12 @@ pub mod plugin { type Interface = MyPluginInterfaceLazyClass; } - pub trait MyPluginInterfaceLazyImpl: ObjectImpl + ObjectSubclass {} + pub trait MyPluginInterfaceLazyImpl: ObjectImpl + ObjectSubclass + where + ::Type: IsA, + ::Type: IsA, + { + } // impl for an object subclass to lazy register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyPluginInterfaceLazy`. #[derive(Default)] @@ -400,7 +449,10 @@ pub mod plugin { impl MyStaticInterfaceImpl for MyPluginTypeLazy {} - impl MyPluginInterfaceLazyImpl for MyPluginTypeLazy {} + impl MyPluginInterfaceLazyImpl for MyPluginTypeLazy where + ::Type: IsA + { + } // impl for a type plugin (must implement `glib::TypePlugin`). #[derive(Default)] @@ -549,11 +601,16 @@ pub mod plugin { pub struct MyPluginInterface(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyPluginInterface {} + unsafe impl IsImplementable for MyPluginInterface + where + ::Type: IsA, + ::Type: IsA, + { + } // an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyPluginInterface`. glib::wrapper! { - pub struct MyPluginType(ObjectSubclass) @implements MyPluginInterface; + pub struct MyPluginType(ObjectSubclass) @extends MyStaticType, @implements MyPluginInterface, MyStaticInterface; } // an object interface to lazy register as a dynamic type and that extends `MyStaticInterface`. @@ -561,11 +618,16 @@ pub mod plugin { pub struct MyPluginInterfaceLazy(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyPluginInterfaceLazy {} + unsafe impl IsImplementable for MyPluginInterfaceLazy + where + ::Type: IsA, + ::Type: IsA, + { + } // an object subclass to lazy register as a dynamic type and that extends `MyStaticType` that implements `MyStaticInterface` and `MyPluginInterfaceLazy`. glib::wrapper! { - pub struct MyPluginTypeLazy(ObjectSubclass) @implements MyPluginInterfaceLazy; + pub struct MyPluginTypeLazy(ObjectSubclass) @extends MyStaticType, @implements MyPluginInterfaceLazy, MyStaticInterface; } // a plugin (must implement `glib::TypePlugin`). diff --git a/glib-macros/tests/properties.rs b/glib-macros/tests/properties.rs index e4ca1da704bd..80d5fb43e913 100644 --- a/glib-macros/tests/properties.rs +++ b/glib-macros/tests/properties.rs @@ -42,7 +42,10 @@ mod base { pub struct Base(ObjectSubclass); } - unsafe impl IsSubclassable for Base {} + unsafe impl IsSubclassable for Base where + ::Type: IsA + { + } } #[cfg(test)] diff --git a/glib/src/gobject/dynamic_object.rs b/glib/src/gobject/dynamic_object.rs index 8736aa8ec580..36648b5af720 100644 --- a/glib/src/gobject/dynamic_object.rs +++ b/glib/src/gobject/dynamic_object.rs @@ -4,7 +4,7 @@ use crate::{ enums::{EnumValues, FlagsValues}, prelude::*, subclass::prelude::*, - InterfaceInfo, TypeFlags, TypeInfo, TypeModule, TypePlugin, + InterfaceInfo, Object, TypeFlags, TypeInfo, TypeModule, TypePlugin, }; mod sealed { @@ -44,6 +44,7 @@ pub trait DynamicObjectRegisterExt: AsRef + sealed::Sealed + 'static impl + ObjectSubclassIsExt> DynamicObjectRegisterExt for O where O::Subclass: TypePluginRegisterImpl, + ::Type: IsA, ::Type: IsA, { fn add_dynamic_interface( diff --git a/glib/src/subclass/object.rs b/glib/src/subclass/object.rs index fc4b42b6cff7..95f2cbf5f258 100644 --- a/glib/src/subclass/object.rs +++ b/glib/src/subclass/object.rs @@ -19,7 +19,10 @@ use crate::{ /// /// This allows overriding the virtual methods of `glib::Object`. Except for /// `finalize` as implementing `Drop` would allow the same behavior. -pub trait ObjectImpl: ObjectSubclass { +pub trait ObjectImpl: ObjectSubclass +where + ::Type: IsA, +{ // rustdoc-stripper-ignore-next /// Properties installed for this type. fn properties() -> &'static [ParamSpec] { @@ -92,7 +95,9 @@ unsafe extern "C" fn property( id: u32, value: *mut gobject_ffi::GValue, pspec: *mut gobject_ffi::GParamSpec, -) { +) where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -116,7 +121,9 @@ unsafe extern "C" fn set_property( id: u32, value: *mut gobject_ffi::GValue, pspec: *mut gobject_ffi::GParamSpec, -) { +) where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.set_property( @@ -126,7 +133,10 @@ unsafe extern "C" fn set_property( ); } -unsafe extern "C" fn constructed(obj: *mut gobject_ffi::GObject) { +unsafe extern "C" fn constructed(obj: *mut gobject_ffi::GObject) +where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -136,7 +146,9 @@ unsafe extern "C" fn constructed(obj: *mut gobject_ffi::GObject) unsafe extern "C" fn notify( obj: *mut gobject_ffi::GObject, pspec: *mut gobject_ffi::GParamSpec, -) { +) where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.notify(&from_glib_borrow(pspec)); @@ -146,13 +158,18 @@ unsafe extern "C" fn dispatch_properties_changed( obj: *mut gobject_ffi::GObject, n_pspecs: u32, pspecs: *mut *mut gobject_ffi::GParamSpec, -) { +) where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.dispatch_properties_changed(Slice::from_glib_borrow_num(pspecs, n_pspecs as _)); } -unsafe extern "C" fn dispose(obj: *mut gobject_ffi::GObject) { +unsafe extern "C" fn dispose(obj: *mut gobject_ffi::GObject) +where + ::Type: IsA, +{ let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -213,7 +230,10 @@ pub unsafe trait ObjectClassSubclassExt: Sized + 'static { unsafe impl ObjectClassSubclassExt for crate::Class {} -unsafe impl IsSubclassable for Object { +unsafe impl IsSubclassable for Object +where + ::Type: IsA, +{ fn class_init(class: &mut crate::Class) { let klass = class.as_mut(); klass.set_property = Some(set_property::); @@ -253,7 +273,10 @@ unsafe impl IsSubclassable for Object { fn instance_init(_instance: &mut super::InitializingObject) {} } -pub trait ObjectImplExt: ObjectSubclass + ObjectImpl { +pub trait ObjectImplExt: ObjectSubclass + ObjectImpl +where + ::Type: IsA, +{ // rustdoc-stripper-ignore-next /// Chain up to the parent class' implementation of `glib::Object::constructed()`. #[inline] @@ -316,7 +339,7 @@ pub trait ObjectImplExt: ObjectSubclass + ObjectImpl { } } -impl ObjectImplExt for T {} +impl ObjectImplExt for T where ::Type: IsA {} #[cfg(test)] mod test { diff --git a/glib/src/subclass/type_module.rs b/glib/src/subclass/type_module.rs index cd78adade1ab..7382957df4ab 100644 --- a/glib/src/subclass/type_module.rs +++ b/glib/src/subclass/type_module.rs @@ -1,9 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{ffi, gobject_ffi, prelude::*, subclass::prelude::*, translate::*, TypeModule}; +use crate::{ffi, gobject_ffi, prelude::*, subclass::prelude::*, translate::*, Object, TypeModule}; pub trait TypeModuleImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { // rustdoc-stripper-ignore-next @@ -26,6 +27,7 @@ where pub trait TypeModuleImplExt: ObjectSubclass + TypeModuleImpl where + ::Type: IsA, ::Type: IsA, { fn parent_load(&self) -> bool; @@ -34,6 +36,7 @@ where impl TypeModuleImplExt for T where + ::Type: IsA, ::Type: IsA, { fn parent_load(&self) -> bool { @@ -69,6 +72,7 @@ where unsafe impl IsSubclassable for TypeModule where + ::Type: IsA, ::Type: IsA, { fn class_init(class: &mut crate::Class) { @@ -84,6 +88,7 @@ unsafe extern "C" fn load( type_module: *mut gobject_ffi::GTypeModule, ) -> ffi::gboolean where + ::Type: IsA, ::Type: IsA, { let instance = &*(type_module as *mut T::Instance); @@ -107,6 +112,7 @@ where unsafe extern "C" fn unload(type_module: *mut gobject_ffi::GTypeModule) where + ::Type: IsA, ::Type: IsA, { let instance = &*(type_module as *mut T::Instance); diff --git a/glib/src/subclass/type_plugin.rs b/glib/src/subclass/type_plugin.rs index 9e8ab6908b0a..04fd1bb4035d 100644 --- a/glib/src/subclass/type_plugin.rs +++ b/glib/src/subclass/type_plugin.rs @@ -3,11 +3,12 @@ use crate::enums::{EnumValues, FlagsValues}; use crate::{ ffi, gobject_ffi, prelude::*, subclass::prelude::*, translate::*, Interface, InterfaceInfo, - Type, TypeFlags, TypeInfo, TypePlugin, TypeValueTable, + Object, Type, TypeFlags, TypeInfo, TypePlugin, TypeValueTable, }; pub trait TypePluginImpl: ObjectImpl where + ::Type: IsA, ::Type: IsA, { fn use_plugin(&self) { @@ -29,6 +30,7 @@ where pub trait TypePluginImplExt: ObjectSubclass + TypePluginImpl where + ::Type: IsA, ::Type: IsA, { fn parent_use_plugin(&self); @@ -43,6 +45,7 @@ where impl TypePluginImplExt for T where + ::Type: IsA, ::Type: IsA, { fn parent_use_plugin(&self) { @@ -124,6 +127,7 @@ where unsafe impl IsImplementable for TypePlugin where + ::Type: IsA, ::Type: IsA, { fn interface_init(iface: &mut Interface) { @@ -138,6 +142,7 @@ where unsafe extern "C" fn use_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) where + ::Type: IsA, ::Type: IsA, { let instance = &*(type_plugin as *mut T::Instance); @@ -148,6 +153,7 @@ where unsafe extern "C" fn unuse_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) where + ::Type: IsA, ::Type: IsA, { let instance = &*(type_plugin as *mut T::Instance); @@ -162,6 +168,7 @@ unsafe extern "C" fn complete_type_info( info_ptr: *mut gobject_ffi::GTypeInfo, value_table_ptr: *mut gobject_ffi::GTypeValueTable, ) where + ::Type: IsA, ::Type: IsA, { assert!(!info_ptr.is_null()); @@ -184,6 +191,7 @@ unsafe extern "C" fn complete_interface_info( interface_gtype: ffi::GType, info_ptr: *mut gobject_ffi::GInterfaceInfo, ) where + ::Type: IsA, ::Type: IsA, { assert!(!info_ptr.is_null()); @@ -199,6 +207,7 @@ unsafe extern "C" fn complete_interface_info( pub trait TypePluginRegisterImpl: ObjectImpl + TypePluginImpl where + ::Type: IsA, ::Type: IsA, { fn add_dynamic_interface(