From d4bfd9fdceafdeaafe48105cc4353088f54b63b1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 16 Nov 2025 01:40:09 +0000 Subject: [PATCH 01/29] Regenerate with latest gir --- gdk-pixbuf/src/auto/mod.rs | 3 + gdk-pixbuf/src/auto/pixbuf_animation.rs | 19 + gdk-pixbuf/src/auto/pixbuf_simple_anim.rs | 10 + gdk-pixbuf/src/auto/versions.txt | 4 +- gdk-pixbuf/sys/versions.txt | 4 +- gio/src/auto/dbus_interface.rs | 2 +- gio/src/auto/desktop_app_info.rs | 285 ----------- gio/src/auto/enums.rs | 2 +- gio/src/auto/functions.rs | 29 -- gio/src/auto/mod.rs | 58 --- gio/src/auto/unix_fd_message.rs | 56 -- gio/src/auto/unix_input_stream.rs | 34 -- gio/src/auto/unix_mount_entry.rs | 200 -------- gio/src/auto/unix_mount_monitor.rs | 72 --- gio/src/auto/unix_mount_point.rs | 172 ------- gio/src/auto/unix_output_stream.rs | 34 -- gio/src/auto/versions.txt | 4 +- gio/sys/src/lib.rs | 590 +--------------------- gio/sys/tests/abi.rs | 69 +-- gio/sys/tests/constant.c | 1 - gio/sys/tests/layout.c | 9 - gio/sys/versions.txt | 4 +- gir | 2 +- gir-files | 2 +- glib/gobject-sys/versions.txt | 4 +- glib/src/auto/enums.rs | 20 + glib/src/auto/markup_parse_context.rs | 8 + glib/src/auto/versions.txt | 4 +- glib/sys/Cargo.toml | 4 + glib/sys/src/lib.rs | 21 +- glib/sys/tests/abi.rs | 5 + glib/sys/tests/constant.c | 5 + glib/sys/versions.txt | 4 +- graphene/src/auto/versions.txt | 4 +- graphene/sys/versions.txt | 4 +- pango/src/auto/versions.txt | 4 +- pango/sys/versions.txt | 4 +- pangocairo/src/auto/versions.txt | 4 +- pangocairo/sys/versions.txt | 4 +- 39 files changed, 132 insertions(+), 1632 deletions(-) delete mode 100644 gio/src/auto/desktop_app_info.rs delete mode 100644 gio/src/auto/unix_fd_message.rs delete mode 100644 gio/src/auto/unix_input_stream.rs delete mode 100644 gio/src/auto/unix_mount_entry.rs delete mode 100644 gio/src/auto/unix_mount_monitor.rs delete mode 100644 gio/src/auto/unix_mount_point.rs delete mode 100644 gio/src/auto/unix_output_stream.rs diff --git a/gdk-pixbuf/src/auto/mod.rs b/gdk-pixbuf/src/auto/mod.rs index 2edebd6f4372..cb97bea70bad 100644 --- a/gdk-pixbuf/src/auto/mod.rs +++ b/gdk-pixbuf/src/auto/mod.rs @@ -5,7 +5,9 @@ mod pixbuf; pub use self::pixbuf::Pixbuf; +#[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] mod pixbuf_animation; +#[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] pub use self::pixbuf_animation::PixbufAnimation; mod pixbuf_loader; @@ -32,6 +34,7 @@ mod flags; pub use self::flags::PixbufFormatFlags; pub(crate) mod traits { + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] pub use super::pixbuf_animation::PixbufAnimationExt; pub use super::pixbuf_loader::PixbufLoaderExt; } diff --git a/gdk-pixbuf/src/auto/pixbuf_animation.rs b/gdk-pixbuf/src/auto/pixbuf_animation.rs index 94f14d99f738..020714dd9164 100644 --- a/gdk-pixbuf/src/auto/pixbuf_animation.rs +++ b/gdk-pixbuf/src/auto/pixbuf_animation.rs @@ -1,6 +1,7 @@ // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +#![allow(deprecated)] use crate::{ffi, Pixbuf}; use glib::{prelude::*, translate::*}; @@ -18,6 +19,8 @@ glib::wrapper! { impl PixbufAnimation { pub const NONE: Option<&'static PixbufAnimation> = None; + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_new_from_file")] #[doc(alias = "new_from_file")] pub fn from_file( @@ -37,6 +40,8 @@ impl PixbufAnimation { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_new_from_resource")] #[doc(alias = "new_from_resource")] pub fn from_resource(resource_path: &str) -> Result { @@ -54,6 +59,8 @@ impl PixbufAnimation { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_new_from_stream")] #[doc(alias = "new_from_stream")] pub fn from_stream( @@ -75,6 +82,8 @@ impl PixbufAnimation { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_new_from_stream_async")] #[doc(alias = "new_from_stream_async")] pub fn from_stream_async) + 'static>( @@ -124,6 +133,8 @@ impl PixbufAnimation { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + pub fn from_stream_future( stream: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> @@ -138,12 +149,16 @@ impl PixbufAnimation { } pub trait PixbufAnimationExt: IsA + 'static { + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_get_height")] #[doc(alias = "get_height")] fn height(&self) -> i32 { unsafe { ffi::gdk_pixbuf_animation_get_height(self.as_ref().to_glib_none().0) } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_get_static_image")] #[doc(alias = "get_static_image")] fn static_image(&self) -> Option { @@ -154,12 +169,16 @@ pub trait PixbufAnimationExt: IsA + 'static { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_get_width")] #[doc(alias = "get_width")] fn width(&self) -> i32 { unsafe { ffi::gdk_pixbuf_animation_get_width(self.as_ref().to_glib_none().0) } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_animation_is_static_image")] fn is_static_image(&self) -> bool { unsafe { diff --git a/gdk-pixbuf/src/auto/pixbuf_simple_anim.rs b/gdk-pixbuf/src/auto/pixbuf_simple_anim.rs index 214a640b0e59..7449ada84539 100644 --- a/gdk-pixbuf/src/auto/pixbuf_simple_anim.rs +++ b/gdk-pixbuf/src/auto/pixbuf_simple_anim.rs @@ -1,6 +1,7 @@ // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +#![allow(deprecated)] use crate::{ffi, Pixbuf, PixbufAnimation}; use glib::{ @@ -20,11 +21,15 @@ glib::wrapper! { } impl PixbufSimpleAnim { + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_simple_anim_new")] pub fn new(width: i32, height: i32, rate: f32) -> PixbufSimpleAnim { unsafe { from_glib_full(ffi::gdk_pixbuf_simple_anim_new(width, height, rate)) } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_simple_anim_add_frame")] pub fn add_frame(&self, pixbuf: &Pixbuf) { unsafe { @@ -32,6 +37,8 @@ impl PixbufSimpleAnim { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_simple_anim_get_loop")] #[doc(alias = "get_loop")] #[doc(alias = "loop")] @@ -39,6 +46,8 @@ impl PixbufSimpleAnim { unsafe { from_glib(ffi::gdk_pixbuf_simple_anim_get_loop(self.to_glib_none().0)) } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] + #[allow(deprecated)] #[doc(alias = "gdk_pixbuf_simple_anim_set_loop")] #[doc(alias = "loop")] pub fn set_loop(&self, loop_: bool) { @@ -47,6 +56,7 @@ impl PixbufSimpleAnim { } } + #[cfg_attr(feature = "v2_44", deprecated = "Since 2.44")] #[doc(alias = "loop")] pub fn connect_loop_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_loop_trampoline( diff --git a/gdk-pixbuf/src/auto/versions.txt b/gdk-pixbuf/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/gdk-pixbuf/src/auto/versions.txt +++ b/gdk-pixbuf/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gdk-pixbuf/sys/versions.txt b/gdk-pixbuf/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/gdk-pixbuf/sys/versions.txt +++ b/gdk-pixbuf/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio/src/auto/dbus_interface.rs b/gio/src/auto/dbus_interface.rs index ff8d44c5eb0d..a598761e8dd5 100644 --- a/gio/src/auto/dbus_interface.rs +++ b/gio/src/auto/dbus_interface.rs @@ -31,7 +31,7 @@ pub trait DBusInterfaceExt: IsA + 'static { #[doc(alias = "g_dbus_interface_get_info")] #[doc(alias = "get_info")] - fn info(&self) -> DBusInterfaceInfo { + fn info(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_get_info( self.as_ref().to_glib_none().0, diff --git a/gio/src/auto/desktop_app_info.rs b/gio/src/auto/desktop_app_info.rs deleted file mode 100644 index 9d4de769ae32..000000000000 --- a/gio/src/auto/desktop_app_info.rs +++ /dev/null @@ -1,285 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, AppInfo, AppLaunchContext}; -use glib::{prelude::*, translate::*}; -use std::boxed::Box as Box_; - -glib::wrapper! { - #[doc(alias = "GDesktopAppInfo")] - pub struct DesktopAppInfo(Object) @implements AppInfo; - - match fn { - type_ => || ffi::g_desktop_app_info_get_type(), - } -} - -impl DesktopAppInfo { - #[doc(alias = "g_desktop_app_info_new")] - pub fn new(desktop_id: &str) -> Option { - unsafe { from_glib_full(ffi::g_desktop_app_info_new(desktop_id.to_glib_none().0)) } - } - - #[doc(alias = "g_desktop_app_info_new_from_filename")] - #[doc(alias = "new_from_filename")] - pub fn from_filename(filename: impl AsRef) -> Option { - unsafe { - from_glib_full(ffi::g_desktop_app_info_new_from_filename( - filename.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_new_from_keyfile")] - #[doc(alias = "new_from_keyfile")] - pub fn from_keyfile(key_file: &glib::KeyFile) -> Option { - unsafe { - from_glib_full(ffi::g_desktop_app_info_new_from_keyfile( - key_file.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_action_name")] - #[doc(alias = "get_action_name")] - pub fn action_name(&self, action_name: &str) -> glib::GString { - unsafe { - from_glib_full(ffi::g_desktop_app_info_get_action_name( - self.to_glib_none().0, - action_name.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_boolean")] - #[doc(alias = "get_boolean")] - pub fn boolean(&self, key: &str) -> bool { - unsafe { - from_glib(ffi::g_desktop_app_info_get_boolean( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_categories")] - #[doc(alias = "get_categories")] - pub fn categories(&self) -> Option { - unsafe { - from_glib_none(ffi::g_desktop_app_info_get_categories( - self.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_filename")] - #[doc(alias = "get_filename")] - pub fn filename(&self) -> Option { - unsafe { from_glib_none(ffi::g_desktop_app_info_get_filename(self.to_glib_none().0)) } - } - - #[doc(alias = "g_desktop_app_info_get_generic_name")] - #[doc(alias = "get_generic_name")] - pub fn generic_name(&self) -> Option { - unsafe { - from_glib_none(ffi::g_desktop_app_info_get_generic_name( - self.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_is_hidden")] - #[doc(alias = "get_is_hidden")] - pub fn is_hidden(&self) -> bool { - unsafe { from_glib(ffi::g_desktop_app_info_get_is_hidden(self.to_glib_none().0)) } - } - - #[doc(alias = "g_desktop_app_info_get_keywords")] - #[doc(alias = "get_keywords")] - pub fn keywords(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_get_keywords( - self.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_locale_string")] - #[doc(alias = "get_locale_string")] - pub fn locale_string(&self, key: &str) -> Option { - unsafe { - from_glib_full(ffi::g_desktop_app_info_get_locale_string( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_nodisplay")] - #[doc(alias = "get_nodisplay")] - pub fn is_nodisplay(&self) -> bool { - unsafe { from_glib(ffi::g_desktop_app_info_get_nodisplay(self.to_glib_none().0)) } - } - - #[doc(alias = "g_desktop_app_info_get_show_in")] - #[doc(alias = "get_show_in")] - pub fn shows_in(&self, desktop_env: Option<&str>) -> bool { - unsafe { - from_glib(ffi::g_desktop_app_info_get_show_in( - self.to_glib_none().0, - desktop_env.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_startup_wm_class")] - #[doc(alias = "get_startup_wm_class")] - pub fn startup_wm_class(&self) -> Option { - unsafe { - from_glib_none(ffi::g_desktop_app_info_get_startup_wm_class( - self.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_string")] - #[doc(alias = "get_string")] - pub fn string(&self, key: &str) -> Option { - unsafe { - from_glib_full(ffi::g_desktop_app_info_get_string( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - #[doc(alias = "g_desktop_app_info_get_string_list")] - #[doc(alias = "get_string_list")] - pub fn string_list(&self, key: &str) -> Vec { - unsafe { - let mut length = std::mem::MaybeUninit::uninit(); - let ret = FromGlibContainer::from_glib_full_num( - ffi::g_desktop_app_info_get_string_list( - self.to_glib_none().0, - key.to_glib_none().0, - length.as_mut_ptr(), - ), - length.assume_init() as _, - ); - ret - } - } - - #[doc(alias = "g_desktop_app_info_has_key")] - pub fn has_key(&self, key: &str) -> bool { - unsafe { - from_glib(ffi::g_desktop_app_info_has_key( - self.to_glib_none().0, - key.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_launch_action")] - pub fn launch_action( - &self, - action_name: &str, - launch_context: Option<&impl IsA>, - ) { - unsafe { - ffi::g_desktop_app_info_launch_action( - self.to_glib_none().0, - action_name.to_glib_none().0, - launch_context.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } - - #[doc(alias = "g_desktop_app_info_launch_uris_as_manager")] - pub fn launch_uris_as_manager( - &self, - uris: &[&str], - launch_context: Option<&impl IsA>, - spawn_flags: glib::SpawnFlags, - user_setup: Option>, - pid_callback: Option<&mut dyn FnMut(&DesktopAppInfo, glib::Pid)>, - ) -> Result<(), glib::Error> { - let user_setup_data: Box_>> = Box_::new(user_setup); - unsafe extern "C" fn user_setup_func(data: glib::ffi::gpointer) { - let callback = Box_::from_raw(data as *mut Option>); - let callback = (*callback).expect("cannot get closure..."); - callback() - } - let user_setup = if user_setup_data.is_some() { - Some(user_setup_func as _) - } else { - None - }; - let mut pid_callback_data: Option<&mut dyn FnMut(&DesktopAppInfo, glib::Pid)> = - pid_callback; - unsafe extern "C" fn pid_callback_func( - appinfo: *mut ffi::GDesktopAppInfo, - pid: glib::ffi::GPid, - user_data: glib::ffi::gpointer, - ) { - let appinfo = from_glib_borrow(appinfo); - let pid = from_glib(pid); - let callback = user_data as *mut Option<&mut dyn FnMut(&DesktopAppInfo, glib::Pid)>; - if let Some(ref mut callback) = *callback { - callback(&appinfo, pid) - } else { - panic!("cannot get closure...") - } - } - let pid_callback = if pid_callback_data.is_some() { - Some(pid_callback_func as _) - } else { - None - }; - let super_callback0: Box_>> = user_setup_data; - let super_callback1: &mut Option<&mut dyn FnMut(&DesktopAppInfo, glib::Pid)> = - &mut pid_callback_data; - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::g_desktop_app_info_launch_uris_as_manager( - self.to_glib_none().0, - uris.to_glib_none().0, - launch_context.map(|p| p.as_ref()).to_glib_none().0, - spawn_flags.into_glib(), - user_setup, - Box_::into_raw(super_callback0) as *mut _, - pid_callback, - super_callback1 as *mut _ as *mut _, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "g_desktop_app_info_list_actions")] - pub fn list_actions(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_list_actions( - self.to_glib_none().0, - )) - } - } - - #[doc(alias = "g_desktop_app_info_get_implementations")] - #[doc(alias = "get_implementations")] - pub fn implementations(interface: &str) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::g_desktop_app_info_get_implementations( - interface.to_glib_none().0, - )) - } - } -} diff --git a/gio/src/auto/enums.rs b/gio/src/auto/enums.rs index eb87b0b63a9c..baec67562163 100644 --- a/gio/src/auto/enums.rs +++ b/gio/src/auto/enums.rs @@ -466,7 +466,7 @@ impl DBusError { } //#[doc(alias = "g_dbus_error_register_error_domain")] - //pub fn register_error_domain(error_domain_quark_name: &str, quark_volatile: usize, entries: /*Ignored*/&[DBusErrorEntry]) { + //pub fn register_error_domain(error_domain_quark_name: &str, entries: /*Ignored*/&[DBusErrorEntry]) -> usize { // unsafe { TODO: call ffi:g_dbus_error_register_error_domain() } //} diff --git a/gio/src/auto/functions.rs b/gio/src/auto/functions.rs index 5a3df411f7dc..53c385f0a902 100644 --- a/gio/src/auto/functions.rs +++ b/gio/src/auto/functions.rs @@ -589,32 +589,3 @@ pub fn resources_unregister(resource: &Resource) { ffi::g_resources_unregister(resource.to_glib_none().0); } } - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -#[doc(alias = "g_unix_is_mount_path_system_internal")] -pub fn unix_is_mount_path_system_internal(mount_path: impl AsRef) -> bool { - unsafe { - from_glib(ffi::g_unix_is_mount_path_system_internal( - mount_path.as_ref().to_glib_none().0, - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -#[doc(alias = "g_unix_is_system_device_path")] -pub fn unix_is_system_device_path(device_path: impl AsRef) -> bool { - unsafe { - from_glib(ffi::g_unix_is_system_device_path( - device_path.as_ref().to_glib_none().0, - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -#[doc(alias = "g_unix_is_system_fs_type")] -pub fn unix_is_system_fs_type(fs_type: &str) -> bool { - unsafe { from_glib(ffi::g_unix_is_system_fs_type(fs_type.to_glib_none().0)) } -} diff --git a/gio/src/auto/mod.rs b/gio/src/auto/mod.rs index 96507da8639a..9276ad7edbce 100644 --- a/gio/src/auto/mod.rs +++ b/gio/src/auto/mod.rs @@ -130,13 +130,6 @@ mod debug_controller_dbus; #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use self::debug_controller_dbus::DebugControllerDBus; -#[cfg(all(not(windows), not(target_os = "macos")))] -#[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] -mod desktop_app_info; -#[cfg(all(not(windows), not(target_os = "macos")))] -#[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] -pub use self::desktop_app_info::DesktopAppInfo; - mod drive; pub use self::drive::Drive; @@ -430,34 +423,6 @@ mod unix_fd_list; #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_fd_list::UnixFDList; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_fd_message; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_fd_message::UnixFDMessage; - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_input_stream; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_input_stream::UnixInputStream; - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_mount_monitor; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_mount_monitor::UnixMountMonitor; - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_output_stream; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_output_stream::UnixOutputStream; - #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_socket_address; @@ -519,20 +484,6 @@ pub use self::settings_schema_source::SettingsSchemaSource; mod srv_target; pub use self::srv_target::SrvTarget; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_mount_entry; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_mount_entry::UnixMountEntry; - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -mod unix_mount_point; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub use self::unix_mount_point::UnixMountPoint; - mod enums; pub use self::enums::BusType; pub use self::enums::ConverterResult; @@ -926,15 +877,6 @@ pub(crate) mod traits { pub use super::unix_fd_list::UnixFDListExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] - pub use super::unix_fd_message::UnixFDMessageExt; - #[cfg(unix)] - #[cfg_attr(docsrs, doc(cfg(unix)))] - pub use super::unix_input_stream::UnixInputStreamExt; - #[cfg(unix)] - #[cfg_attr(docsrs, doc(cfg(unix)))] - pub use super::unix_output_stream::UnixOutputStreamExt; - #[cfg(unix)] - #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_socket_address::UnixSocketAddressExt; pub use super::vfs::VfsExt; pub use super::volume::VolumeExt; diff --git a/gio/src/auto/unix_fd_message.rs b/gio/src/auto/unix_fd_message.rs deleted file mode 100644 index 3d90f4a338af..000000000000 --- a/gio/src/auto/unix_fd_message.rs +++ /dev/null @@ -1,56 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, SocketControlMessage, UnixFDList}; -use glib::{prelude::*, translate::*}; - -glib::wrapper! { - #[doc(alias = "GUnixFDMessage")] - pub struct UnixFDMessage(Object) @extends SocketControlMessage; - - match fn { - type_ => || ffi::g_unix_fd_message_get_type(), - } -} - -impl UnixFDMessage { - pub const NONE: Option<&'static UnixFDMessage> = None; - - #[doc(alias = "g_unix_fd_message_new")] - pub fn new() -> UnixFDMessage { - unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast() } - } - - #[doc(alias = "g_unix_fd_message_new_with_fd_list")] - #[doc(alias = "new_with_fd_list")] - pub fn with_fd_list(fd_list: &impl IsA) -> UnixFDMessage { - unsafe { - SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list( - fd_list.as_ref().to_glib_none().0, - )) - .unsafe_cast() - } - } -} - -impl Default for UnixFDMessage { - fn default() -> Self { - Self::new() - } -} - -pub trait UnixFDMessageExt: IsA + 'static { - #[doc(alias = "g_unix_fd_message_get_fd_list")] - #[doc(alias = "get_fd_list")] - #[doc(alias = "fd-list")] - fn fd_list(&self) -> UnixFDList { - unsafe { - from_glib_none(ffi::g_unix_fd_message_get_fd_list( - self.as_ref().to_glib_none().0, - )) - } - } -} - -impl> UnixFDMessageExt for O {} diff --git a/gio/src/auto/unix_input_stream.rs b/gio/src/auto/unix_input_stream.rs deleted file mode 100644 index 43c455572ca7..000000000000 --- a/gio/src/auto/unix_input_stream.rs +++ /dev/null @@ -1,34 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, FileDescriptorBased, InputStream, PollableInputStream}; -use glib::{prelude::*, translate::*}; - -glib::wrapper! { - #[doc(alias = "GUnixInputStream")] - pub struct UnixInputStream(Object) @extends InputStream, @implements FileDescriptorBased, PollableInputStream; - - match fn { - type_ => || ffi::g_unix_input_stream_get_type(), - } -} - -impl UnixInputStream { - pub const NONE: Option<&'static UnixInputStream> = None; -} - -pub trait UnixInputStreamExt: IsA + 'static { - #[doc(alias = "g_unix_input_stream_get_close_fd")] - #[doc(alias = "get_close_fd")] - #[doc(alias = "close-fd")] - fn closes_fd(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_input_stream_get_close_fd( - self.as_ref().to_glib_none().0, - )) - } - } -} - -impl> UnixInputStreamExt for O {} diff --git a/gio/src/auto/unix_mount_entry.rs b/gio/src/auto/unix_mount_entry.rs deleted file mode 100644 index 641a32ea6428..000000000000 --- a/gio/src/auto/unix_mount_entry.rs +++ /dev/null @@ -1,200 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, Icon}; -use glib::translate::*; - -glib::wrapper! { - #[derive(Debug)] - pub struct UnixMountEntry(Boxed); - - match fn { - copy => |ptr| ffi::g_unix_mount_entry_copy(mut_override(ptr)), - free => |ptr| ffi::g_unix_mount_entry_free(ptr), - type_ => || ffi::g_unix_mount_entry_get_type(), - } -} - -impl UnixMountEntry { - #[doc(alias = "g_unix_mount_entry_compare")] - fn compare(&self, mount2: &UnixMountEntry) -> i32 { - unsafe { - ffi::g_unix_mount_entry_compare( - mut_override(self.to_glib_none().0), - mut_override(mount2.to_glib_none().0), - ) - } - } - - #[doc(alias = "g_unix_mount_entry_get_device_path")] - #[doc(alias = "get_device_path")] - pub fn device_path(&self) -> std::path::PathBuf { - unsafe { - from_glib_none(ffi::g_unix_mount_entry_get_device_path(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_get_fs_type")] - #[doc(alias = "get_fs_type")] - pub fn fs_type(&self) -> glib::GString { - unsafe { - from_glib_none(ffi::g_unix_mount_entry_get_fs_type(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_get_mount_path")] - #[doc(alias = "get_mount_path")] - pub fn mount_path(&self) -> std::path::PathBuf { - unsafe { - from_glib_none(ffi::g_unix_mount_entry_get_mount_path(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[cfg(feature = "v2_58")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] - #[doc(alias = "g_unix_mount_entry_get_options")] - #[doc(alias = "get_options")] - pub fn options(&self) -> Option { - unsafe { - from_glib_none(ffi::g_unix_mount_entry_get_options(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - #[doc(alias = "g_unix_mount_entry_get_root_path")] - #[doc(alias = "get_root_path")] - pub fn root_path(&self) -> Option { - unsafe { - from_glib_none(ffi::g_unix_mount_entry_get_root_path(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_guess_can_eject")] - pub fn guess_can_eject(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_entry_guess_can_eject(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_guess_icon")] - pub fn guess_icon(&self) -> Icon { - unsafe { - from_glib_full(ffi::g_unix_mount_entry_guess_icon(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_guess_name")] - pub fn guess_name(&self) -> glib::GString { - unsafe { - from_glib_full(ffi::g_unix_mount_entry_guess_name(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_guess_should_display")] - pub fn guess_should_display(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_entry_guess_should_display(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_guess_symbolic_icon")] - pub fn guess_symbolic_icon(&self) -> Icon { - unsafe { - from_glib_full(ffi::g_unix_mount_entry_guess_symbolic_icon(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_is_readonly")] - pub fn is_readonly(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_entry_is_readonly(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_is_system_internal")] - pub fn is_system_internal(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_entry_is_system_internal(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_entry_at")] - #[doc(alias = "at")] - pub fn for_mount_path( - mount_path: impl AsRef, - ) -> (Option, u64) { - unsafe { - let mut time_read = std::mem::MaybeUninit::uninit(); - let ret = from_glib_full(ffi::g_unix_mount_entry_at( - mount_path.as_ref().to_glib_none().0, - time_read.as_mut_ptr(), - )); - (ret, time_read.assume_init()) - } - } - - #[doc(alias = "g_unix_mount_entry_for")] - #[doc(alias = "for")] - pub fn for_file_path(file_path: impl AsRef) -> (Option, u64) { - unsafe { - let mut time_read = std::mem::MaybeUninit::uninit(); - let ret = from_glib_full(ffi::g_unix_mount_entry_for( - file_path.as_ref().to_glib_none().0, - time_read.as_mut_ptr(), - )); - (ret, time_read.assume_init()) - } - } -} - -impl PartialEq for UnixMountEntry { - #[inline] - fn eq(&self, other: &Self) -> bool { - self.compare(other) == 0 - } -} - -impl Eq for UnixMountEntry {} - -impl PartialOrd for UnixMountEntry { - #[inline] - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for UnixMountEntry { - #[inline] - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.compare(other).cmp(&0) - } -} - -unsafe impl Send for UnixMountEntry {} -unsafe impl Sync for UnixMountEntry {} diff --git a/gio/src/auto/unix_mount_monitor.rs b/gio/src/auto/unix_mount_monitor.rs deleted file mode 100644 index c08492b6ff90..000000000000 --- a/gio/src/auto/unix_mount_monitor.rs +++ /dev/null @@ -1,72 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::ffi; -use glib::{ - object::ObjectType as _, - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::boxed::Box as Box_; - -glib::wrapper! { - #[doc(alias = "GUnixMountMonitor")] - pub struct UnixMountMonitor(Object); - - match fn { - type_ => || ffi::g_unix_mount_monitor_get_type(), - } -} - -impl UnixMountMonitor { - #[doc(alias = "g_unix_mount_monitor_get")] - pub fn get() -> UnixMountMonitor { - unsafe { from_glib_full(ffi::g_unix_mount_monitor_get()) } - } - - #[doc(alias = "mountpoints-changed")] - pub fn connect_mountpoints_changed(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn mountpoints_changed_trampoline( - this: *mut ffi::GUnixMountMonitor, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(&from_glib_borrow(this)) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - c"mountpoints-changed".as_ptr() as *const _, - Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( - mountpoints_changed_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[doc(alias = "mounts-changed")] - pub fn connect_mounts_changed(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn mounts_changed_trampoline( - this: *mut ffi::GUnixMountMonitor, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(&from_glib_borrow(this)) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - c"mounts-changed".as_ptr() as *const _, - Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( - mounts_changed_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } -} diff --git a/gio/src/auto/unix_mount_point.rs b/gio/src/auto/unix_mount_point.rs deleted file mode 100644 index 2e85861f1705..000000000000 --- a/gio/src/auto/unix_mount_point.rs +++ /dev/null @@ -1,172 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, Icon}; -use glib::translate::*; - -glib::wrapper! { - #[derive(Debug)] - pub struct UnixMountPoint(Boxed); - - match fn { - copy => |ptr| ffi::g_unix_mount_point_copy(mut_override(ptr)), - free => |ptr| ffi::g_unix_mount_point_free(ptr), - type_ => || ffi::g_unix_mount_point_get_type(), - } -} - -impl UnixMountPoint { - #[doc(alias = "g_unix_mount_point_compare")] - fn compare(&self, mount2: &UnixMountPoint) -> i32 { - unsafe { - ffi::g_unix_mount_point_compare( - mut_override(self.to_glib_none().0), - mut_override(mount2.to_glib_none().0), - ) - } - } - - #[doc(alias = "g_unix_mount_point_get_device_path")] - #[doc(alias = "get_device_path")] - pub fn device_path(&self) -> std::path::PathBuf { - unsafe { - from_glib_none(ffi::g_unix_mount_point_get_device_path(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_get_fs_type")] - #[doc(alias = "get_fs_type")] - pub fn fs_type(&self) -> glib::GString { - unsafe { - from_glib_none(ffi::g_unix_mount_point_get_fs_type(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_get_mount_path")] - #[doc(alias = "get_mount_path")] - pub fn mount_path(&self) -> std::path::PathBuf { - unsafe { - from_glib_none(ffi::g_unix_mount_point_get_mount_path(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_get_options")] - #[doc(alias = "get_options")] - pub fn options(&self) -> Option { - unsafe { - from_glib_none(ffi::g_unix_mount_point_get_options(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_guess_can_eject")] - pub fn guess_can_eject(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_point_guess_can_eject(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_guess_icon")] - pub fn guess_icon(&self) -> Icon { - unsafe { - from_glib_full(ffi::g_unix_mount_point_guess_icon(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_guess_name")] - pub fn guess_name(&self) -> glib::GString { - unsafe { - from_glib_full(ffi::g_unix_mount_point_guess_name(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_guess_symbolic_icon")] - pub fn guess_symbolic_icon(&self) -> Icon { - unsafe { - from_glib_full(ffi::g_unix_mount_point_guess_symbolic_icon(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_is_loopback")] - pub fn is_loopback(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_point_is_loopback(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_is_readonly")] - pub fn is_readonly(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_point_is_readonly(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[doc(alias = "g_unix_mount_point_is_user_mountable")] - pub fn is_user_mountable(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_mount_point_is_user_mountable(mut_override( - self.to_glib_none().0, - ))) - } - } - - #[cfg(feature = "v2_66")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] - #[doc(alias = "g_unix_mount_point_at")] - pub fn at(mount_path: impl AsRef) -> (Option, u64) { - unsafe { - let mut time_read = std::mem::MaybeUninit::uninit(); - let ret = from_glib_full(ffi::g_unix_mount_point_at( - mount_path.as_ref().to_glib_none().0, - time_read.as_mut_ptr(), - )); - (ret, time_read.assume_init()) - } - } -} - -impl PartialEq for UnixMountPoint { - #[inline] - fn eq(&self, other: &Self) -> bool { - self.compare(other) == 0 - } -} - -impl Eq for UnixMountPoint {} - -impl PartialOrd for UnixMountPoint { - #[inline] - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for UnixMountPoint { - #[inline] - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.compare(other).cmp(&0) - } -} - -unsafe impl Send for UnixMountPoint {} -unsafe impl Sync for UnixMountPoint {} diff --git a/gio/src/auto/unix_output_stream.rs b/gio/src/auto/unix_output_stream.rs deleted file mode 100644 index f7cba6395d7b..000000000000 --- a/gio/src/auto/unix_output_stream.rs +++ /dev/null @@ -1,34 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/gtk-rs/gir-files) -// DO NOT EDIT - -use crate::{ffi, FileDescriptorBased, OutputStream, PollableOutputStream}; -use glib::{prelude::*, translate::*}; - -glib::wrapper! { - #[doc(alias = "GUnixOutputStream")] - pub struct UnixOutputStream(Object) @extends OutputStream, @implements FileDescriptorBased, PollableOutputStream; - - match fn { - type_ => || ffi::g_unix_output_stream_get_type(), - } -} - -impl UnixOutputStream { - pub const NONE: Option<&'static UnixOutputStream> = None; -} - -pub trait UnixOutputStreamExt: IsA + 'static { - #[doc(alias = "g_unix_output_stream_get_close_fd")] - #[doc(alias = "get_close_fd")] - #[doc(alias = "close-fd")] - fn closes_fd(&self) -> bool { - unsafe { - from_glib(ffi::g_unix_output_stream_get_close_fd( - self.as_ref().to_glib_none().0, - )) - } - } -} - -impl> UnixOutputStreamExt for O {} diff --git a/gio/src/auto/versions.txt b/gio/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/gio/src/auto/versions.txt +++ b/gio/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio/sys/src/lib.rs b/gio/sys/src/lib.rs index d25bdca7f7f4..bd6ea785c6a0 100644 --- a/gio/sys/src/lib.rs +++ b/gio/sys/src/lib.rs @@ -397,7 +397,6 @@ pub const G_ZLIB_COMPRESSOR_FORMAT_RAW: GZlibCompressorFormat = 2; pub const G_DBUS_METHOD_INVOCATION_HANDLED: gboolean = glib::GTRUE; pub const G_DBUS_METHOD_INVOCATION_UNHANDLED: gboolean = glib::GFALSE; pub const G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME: &[u8] = b"gio-debug-controller\0"; -pub const G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME: &[u8] = b"gio-desktop-app-info-lookup\0"; pub const G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE: &[u8] = b"unix-device\0"; pub const G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE: &[u8] = b"access::can-delete\0"; pub const G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE: &[u8] = b"access::can-execute\0"; @@ -862,8 +861,6 @@ pub type GDBusSubtreeIntrospectFunc = Option< >; pub type GDatagramBasedSourceFunc = Option gboolean>; -pub type GDesktopAppLaunchCallback = - Option; pub type GFileMeasureProgressCallback = Option; pub type GFileProgressCallback = Option; @@ -1690,7 +1687,16 @@ pub struct GDBusInterfaceSkeletonClass { pub get_properties: Option *mut glib::GVariant>, pub flush: Option, - pub vfunc_padding: [gpointer; 8], + pub method_dispatch: Option< + unsafe extern "C" fn( + *mut GDBusInterfaceSkeleton, + GDBusInterfaceMethodCallFunc, + *mut GDBusMethodInvocation, + GDBusInterfaceSkeletonFlags, + *mut GDBusObject, + ), + >, + pub vfunc_padding: [gpointer; 7], pub g_authorize_method: Option< unsafe extern "C" fn(*mut GDBusInterfaceSkeleton, *mut GDBusMethodInvocation) -> gboolean, >, @@ -1705,6 +1711,7 @@ impl ::std::fmt::Debug for GDBusInterfaceSkeletonClass { .field("get_vtable", &self.get_vtable) .field("get_properties", &self.get_properties) .field("flush", &self.flush) + .field("method_dispatch", &self.method_dispatch) .field("g_authorize_method", &self.g_authorize_method) .finish() } @@ -2225,40 +2232,6 @@ impl ::std::fmt::Debug for GDebugControllerInterface { } } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GDesktopAppInfoClass { - pub parent_class: gobject::GObjectClass, -} - -impl ::std::fmt::Debug for GDesktopAppInfoClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GDesktopAppInfoClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .finish() - } -} - -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GDesktopAppInfoLookupIface { - pub g_iface: gobject::GTypeInterface, - pub get_default_for_uri_scheme: - Option *mut GAppInfo>, -} - -impl ::std::fmt::Debug for GDesktopAppInfoLookupIface { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GDesktopAppInfoLookupIface @ {self:p}")) - .field("g_iface", &self.g_iface) - .field( - "get_default_for_uri_scheme", - &self.get_default_for_uri_scheme, - ) - .finish() - } -} - #[derive(Copy, Clone)] #[repr(C)] pub struct GDriveIface { @@ -2587,22 +2560,6 @@ impl ::std::fmt::Debug for GFileAttributeMatcher { } } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GFileDescriptorBasedIface { - pub g_iface: gobject::GTypeInterface, - pub get_fd: Option c_int>, -} - -impl ::std::fmt::Debug for GFileDescriptorBasedIface { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GFileDescriptorBasedIface @ {self:p}")) - .field("g_iface", &self.g_iface) - .field("get_fd", &self.get_fd) - .finish() - } -} - #[derive(Copy, Clone)] #[repr(C)] pub struct GFileEnumeratorClass { @@ -6858,136 +6815,6 @@ pub struct _GUnixFDListPrivate { pub type GUnixFDListPrivate = _GUnixFDListPrivate; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixFDMessageClass { - pub parent_class: GSocketControlMessageClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, -} - -impl ::std::fmt::Debug for GUnixFDMessageClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixFDMessageClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .finish() - } -} - -#[repr(C)] -#[allow(dead_code)] -pub struct _GUnixFDMessagePrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -pub type GUnixFDMessagePrivate = _GUnixFDMessagePrivate; - -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixInputStreamClass { - pub parent_class: GInputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, -} - -impl ::std::fmt::Debug for GUnixInputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixInputStreamClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } -} - -#[repr(C)] -#[allow(dead_code)] -pub struct _GUnixInputStreamPrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -pub type GUnixInputStreamPrivate = _GUnixInputStreamPrivate; - -#[repr(C)] -#[allow(dead_code)] -pub struct GUnixMountEntry { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GUnixMountEntry { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixMountEntry @ {self:p}")) - .finish() - } -} - -#[repr(C)] -#[allow(dead_code)] -pub struct _GUnixMountMonitorClass { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -pub type GUnixMountMonitorClass = _GUnixMountMonitorClass; - -#[repr(C)] -#[allow(dead_code)] -pub struct GUnixMountPoint { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GUnixMountPoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixMountPoint @ {self:p}")) - .finish() - } -} - -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixOutputStreamClass { - pub parent_class: GOutputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, -} - -impl ::std::fmt::Debug for GUnixOutputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixOutputStreamClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } -} - -#[repr(C)] -#[allow(dead_code)] -pub struct _GUnixOutputStreamPrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -pub type GUnixOutputStreamPrivate = _GUnixOutputStreamPrivate; - #[derive(Copy, Clone)] #[repr(C)] pub struct GUnixSocketAddressClass { @@ -7663,20 +7490,6 @@ impl ::std::fmt::Debug for GDebugControllerDBus { } } -#[repr(C)] -#[allow(dead_code)] -pub struct GDesktopAppInfo { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GDesktopAppInfo { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GDesktopAppInfo @ {self:p}")) - .finish() - } -} - #[repr(C)] #[allow(dead_code)] pub struct GEmblem { @@ -8728,66 +8541,6 @@ impl ::std::fmt::Debug for GUnixFDList { } } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixFDMessage { - pub parent_instance: GSocketControlMessage, - pub priv_: *mut GUnixFDMessagePrivate, -} - -impl ::std::fmt::Debug for GUnixFDMessage { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixFDMessage @ {self:p}")) - .field("parent_instance", &self.parent_instance) - .field("priv_", &self.priv_) - .finish() - } -} - -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixInputStream { - pub parent_instance: GInputStream, - pub priv_: *mut GUnixInputStreamPrivate, -} - -impl ::std::fmt::Debug for GUnixInputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixInputStream @ {self:p}")) - .field("parent_instance", &self.parent_instance) - .finish() - } -} - -#[repr(C)] -#[allow(dead_code)] -pub struct GUnixMountMonitor { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GUnixMountMonitor { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixMountMonitor @ {self:p}")) - .finish() - } -} - -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixOutputStream { - pub parent_instance: GOutputStream, - pub priv_: *mut GUnixOutputStreamPrivate, -} - -impl ::std::fmt::Debug for GUnixOutputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixOutputStream @ {self:p}")) - .field("parent_instance", &self.parent_instance) - .finish() - } -} - #[derive(Copy, Clone)] #[repr(C)] pub struct GUnixSocketAddress { @@ -9017,19 +8770,6 @@ impl ::std::fmt::Debug for GDebugController { } } -#[repr(C)] -#[allow(dead_code)] -pub struct GDesktopAppInfoLookup { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GDesktopAppInfoLookup { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f, "GDesktopAppInfoLookup @ {self:p}") - } -} - #[repr(C)] #[allow(dead_code)] pub struct GDrive { @@ -9095,19 +8835,6 @@ impl ::std::fmt::Debug for GFile { } } -#[repr(C)] -#[allow(dead_code)] -pub struct GFileDescriptorBased { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -impl ::std::fmt::Debug for GFileDescriptorBased { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f, "GFileDescriptorBased @ {self:p}") - } -} - #[repr(C)] #[allow(dead_code)] pub struct GIcon { @@ -10159,99 +9886,6 @@ extern "C" { pub fn g_static_resource_get_resource(static_resource: *mut GStaticResource) -> *mut GResource; pub fn g_static_resource_init(static_resource: *mut GStaticResource); - //========================================================================= - // GUnixMountEntry - //========================================================================= - pub fn g_unix_mount_entry_get_type() -> GType; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_compare( - mount1: *mut GUnixMountEntry, - mount2: *mut GUnixMountEntry, - ) -> c_int; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_copy(mount_entry: *mut GUnixMountEntry) -> *mut GUnixMountEntry; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry); - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_get_device_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_get_fs_type(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_get_mount_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_get_options(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_get_root_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_guess_can_eject(mount_entry: *mut GUnixMountEntry) -> gboolean; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_guess_should_display(mount_entry: *mut GUnixMountEntry) -> gboolean; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_guess_symbolic_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_is_system_internal(mount_entry: *mut GUnixMountEntry) -> gboolean; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_at( - mount_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entry_for( - file_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry; - - //========================================================================= - // GUnixMountPoint - //========================================================================= - pub fn g_unix_mount_point_get_type() -> GType; - pub fn g_unix_mount_point_compare( - mount1: *mut GUnixMountPoint, - mount2: *mut GUnixMountPoint, - ) -> c_int; - pub fn g_unix_mount_point_copy(mount_point: *mut GUnixMountPoint) -> *mut GUnixMountPoint; - pub fn g_unix_mount_point_free(mount_point: *mut GUnixMountPoint); - pub fn g_unix_mount_point_get_device_path(mount_point: *mut GUnixMountPoint) -> *const c_char; - pub fn g_unix_mount_point_get_fs_type(mount_point: *mut GUnixMountPoint) -> *const c_char; - pub fn g_unix_mount_point_get_mount_path(mount_point: *mut GUnixMountPoint) -> *const c_char; - pub fn g_unix_mount_point_get_options(mount_point: *mut GUnixMountPoint) -> *const c_char; - pub fn g_unix_mount_point_guess_can_eject(mount_point: *mut GUnixMountPoint) -> gboolean; - pub fn g_unix_mount_point_guess_icon(mount_point: *mut GUnixMountPoint) -> *mut GIcon; - pub fn g_unix_mount_point_guess_name(mount_point: *mut GUnixMountPoint) -> *mut c_char; - pub fn g_unix_mount_point_guess_symbolic_icon(mount_point: *mut GUnixMountPoint) -> *mut GIcon; - pub fn g_unix_mount_point_is_loopback(mount_point: *mut GUnixMountPoint) -> gboolean; - pub fn g_unix_mount_point_is_readonly(mount_point: *mut GUnixMountPoint) -> gboolean; - pub fn g_unix_mount_point_is_user_mountable(mount_point: *mut GUnixMountPoint) -> gboolean; - #[cfg(feature = "v2_66")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] - pub fn g_unix_mount_point_at( - mount_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountPoint; - //========================================================================= // GAppInfoMonitor //========================================================================= @@ -11694,87 +11328,6 @@ extern "C" { #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub fn g_debug_controller_dbus_stop(self_: *mut GDebugControllerDBus); - //========================================================================= - // GDesktopAppInfo - //========================================================================= - pub fn g_desktop_app_info_get_type() -> GType; - pub fn g_desktop_app_info_new(desktop_id: *const c_char) -> *mut GDesktopAppInfo; - pub fn g_desktop_app_info_new_from_filename(filename: *const c_char) -> *mut GDesktopAppInfo; - pub fn g_desktop_app_info_new_from_keyfile( - key_file: *mut glib::GKeyFile, - ) -> *mut GDesktopAppInfo; - pub fn g_desktop_app_info_get_implementations(interface: *const c_char) -> *mut glib::GList; - pub fn g_desktop_app_info_search(search_string: *const c_char) -> *mut *mut *mut c_char; - pub fn g_desktop_app_info_set_desktop_env(desktop_env: *const c_char); - pub fn g_desktop_app_info_get_action_name( - info: *mut GDesktopAppInfo, - action_name: *const c_char, - ) -> *mut c_char; - pub fn g_desktop_app_info_get_boolean( - info: *mut GDesktopAppInfo, - key: *const c_char, - ) -> gboolean; - pub fn g_desktop_app_info_get_categories(info: *mut GDesktopAppInfo) -> *const c_char; - pub fn g_desktop_app_info_get_filename(info: *mut GDesktopAppInfo) -> *const c_char; - pub fn g_desktop_app_info_get_generic_name(info: *mut GDesktopAppInfo) -> *const c_char; - pub fn g_desktop_app_info_get_is_hidden(info: *mut GDesktopAppInfo) -> gboolean; - pub fn g_desktop_app_info_get_keywords(info: *mut GDesktopAppInfo) -> *const *const c_char; - pub fn g_desktop_app_info_get_locale_string( - info: *mut GDesktopAppInfo, - key: *const c_char, - ) -> *mut c_char; - pub fn g_desktop_app_info_get_nodisplay(info: *mut GDesktopAppInfo) -> gboolean; - pub fn g_desktop_app_info_get_show_in( - info: *mut GDesktopAppInfo, - desktop_env: *const c_char, - ) -> gboolean; - pub fn g_desktop_app_info_get_startup_wm_class(info: *mut GDesktopAppInfo) -> *const c_char; - pub fn g_desktop_app_info_get_string( - info: *mut GDesktopAppInfo, - key: *const c_char, - ) -> *mut c_char; - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - pub fn g_desktop_app_info_get_string_list( - info: *mut GDesktopAppInfo, - key: *const c_char, - length: *mut size_t, - ) -> *mut *mut c_char; - pub fn g_desktop_app_info_has_key(info: *mut GDesktopAppInfo, key: *const c_char) -> gboolean; - pub fn g_desktop_app_info_launch_action( - info: *mut GDesktopAppInfo, - action_name: *const c_char, - launch_context: *mut GAppLaunchContext, - ); - pub fn g_desktop_app_info_launch_uris_as_manager( - appinfo: *mut GDesktopAppInfo, - uris: *mut glib::GList, - launch_context: *mut GAppLaunchContext, - spawn_flags: glib::GSpawnFlags, - user_setup: glib::GSpawnChildSetupFunc, - user_setup_data: gpointer, - pid_callback: GDesktopAppLaunchCallback, - pid_callback_data: gpointer, - error: *mut *mut glib::GError, - ) -> gboolean; - #[cfg(feature = "v2_58")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] - pub fn g_desktop_app_info_launch_uris_as_manager_with_fds( - appinfo: *mut GDesktopAppInfo, - uris: *mut glib::GList, - launch_context: *mut GAppLaunchContext, - spawn_flags: glib::GSpawnFlags, - user_setup: glib::GSpawnChildSetupFunc, - user_setup_data: gpointer, - pid_callback: GDesktopAppLaunchCallback, - pid_callback_data: gpointer, - stdin_fd: c_int, - stdout_fd: c_int, - stderr_fd: c_int, - error: *mut *mut glib::GError, - ) -> gboolean; - pub fn g_desktop_app_info_list_actions(info: *mut GDesktopAppInfo) -> *const *const c_char; - //========================================================================= // GEmblem //========================================================================= @@ -14932,54 +14485,6 @@ extern "C" { pub fn g_unix_fd_list_peek_fds(list: *mut GUnixFDList, length: *mut c_int) -> *const c_int; pub fn g_unix_fd_list_steal_fds(list: *mut GUnixFDList, length: *mut c_int) -> *mut c_int; - //========================================================================= - // GUnixFDMessage - //========================================================================= - pub fn g_unix_fd_message_get_type() -> GType; - pub fn g_unix_fd_message_new() -> *mut GSocketControlMessage; - pub fn g_unix_fd_message_new_with_fd_list( - fd_list: *mut GUnixFDList, - ) -> *mut GSocketControlMessage; - pub fn g_unix_fd_message_append_fd( - message: *mut GUnixFDMessage, - fd: c_int, - error: *mut *mut glib::GError, - ) -> gboolean; - pub fn g_unix_fd_message_get_fd_list(message: *mut GUnixFDMessage) -> *mut GUnixFDList; - pub fn g_unix_fd_message_steal_fds( - message: *mut GUnixFDMessage, - length: *mut c_int, - ) -> *mut c_int; - - //========================================================================= - // GUnixInputStream - //========================================================================= - pub fn g_unix_input_stream_get_type() -> GType; - pub fn g_unix_input_stream_new(fd: c_int, close_fd: gboolean) -> *mut GInputStream; - pub fn g_unix_input_stream_get_close_fd(stream: *mut GUnixInputStream) -> gboolean; - pub fn g_unix_input_stream_get_fd(stream: *mut GUnixInputStream) -> c_int; - pub fn g_unix_input_stream_set_close_fd(stream: *mut GUnixInputStream, close_fd: gboolean); - - //========================================================================= - // GUnixMountMonitor - //========================================================================= - pub fn g_unix_mount_monitor_get_type() -> GType; - pub fn g_unix_mount_monitor_new() -> *mut GUnixMountMonitor; - pub fn g_unix_mount_monitor_get() -> *mut GUnixMountMonitor; - pub fn g_unix_mount_monitor_set_rate_limit( - mount_monitor: *mut GUnixMountMonitor, - limit_msec: c_int, - ); - - //========================================================================= - // GUnixOutputStream - //========================================================================= - pub fn g_unix_output_stream_get_type() -> GType; - pub fn g_unix_output_stream_new(fd: c_int, close_fd: gboolean) -> *mut GOutputStream; - pub fn g_unix_output_stream_get_close_fd(stream: *mut GUnixOutputStream) -> gboolean; - pub fn g_unix_output_stream_get_fd(stream: *mut GUnixOutputStream) -> c_int; - pub fn g_unix_output_stream_set_close_fd(stream: *mut GUnixOutputStream, close_fd: gboolean); - //========================================================================= // GUnixSocketAddress //========================================================================= @@ -15491,15 +14996,6 @@ extern "C" { debug_enabled: gboolean, ); - //========================================================================= - // GDesktopAppInfoLookup - //========================================================================= - pub fn g_desktop_app_info_lookup_get_type() -> GType; - pub fn g_desktop_app_info_lookup_get_default_for_uri_scheme( - lookup: *mut GDesktopAppInfoLookup, - uri_scheme: *const c_char, - ) -> *mut GAppInfo; - //========================================================================= // GDrive //========================================================================= @@ -16594,12 +16090,6 @@ extern "C" { error: *mut *mut glib::GError, ) -> gboolean; - //========================================================================= - // GFileDescriptorBased - //========================================================================= - pub fn g_file_descriptor_based_get_type() -> GType; - pub fn g_file_descriptor_based_get_fd(fd_based: *mut GFileDescriptorBased) -> c_int; - //========================================================================= // GIcon //========================================================================= @@ -17385,63 +16875,5 @@ extern "C" { user_data: gpointer, error: *mut glib::GError, ); - pub fn g_unix_is_mount_path_system_internal(mount_path: *const c_char) -> gboolean; - pub fn g_unix_is_system_device_path(device_path: *const c_char) -> gboolean; - pub fn g_unix_is_system_fs_type(fs_type: *const c_char) -> gboolean; - pub fn g_unix_mount_at(mount_path: *const c_char, time_read: *mut u64) -> *mut GUnixMountEntry; - pub fn g_unix_mount_compare( - mount1: *mut GUnixMountEntry, - mount2: *mut GUnixMountEntry, - ) -> c_int; - pub fn g_unix_mount_copy(mount_entry: *mut GUnixMountEntry) -> *mut GUnixMountEntry; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entries_changed_since(time: u64) -> gboolean; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib::GList; - #[cfg(feature = "v2_84")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] - pub fn g_unix_mount_entries_get_from_file( - table_path: *const c_char, - time_read_out: *mut u64, - n_entries_out: *mut size_t, - ) -> *mut *mut GUnixMountEntry; - pub fn g_unix_mount_for(file_path: *const c_char, time_read: *mut u64) -> *mut GUnixMountEntry; - pub fn g_unix_mount_free(mount_entry: *mut GUnixMountEntry); - pub fn g_unix_mount_get_device_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - pub fn g_unix_mount_get_fs_type(mount_entry: *mut GUnixMountEntry) -> *const c_char; - pub fn g_unix_mount_get_mount_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_58")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] - pub fn g_unix_mount_get_options(mount_entry: *mut GUnixMountEntry) -> *const c_char; - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - pub fn g_unix_mount_get_root_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; - pub fn g_unix_mount_guess_can_eject(mount_entry: *mut GUnixMountEntry) -> gboolean; - pub fn g_unix_mount_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon; - pub fn g_unix_mount_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char; - pub fn g_unix_mount_guess_should_display(mount_entry: *mut GUnixMountEntry) -> gboolean; - pub fn g_unix_mount_guess_symbolic_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon; - pub fn g_unix_mount_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean; - pub fn g_unix_mount_is_system_internal(mount_entry: *mut GUnixMountEntry) -> gboolean; - pub fn g_unix_mount_points_changed_since(time: u64) -> gboolean; - pub fn g_unix_mount_points_get(time_read: *mut u64) -> *mut glib::GList; - #[cfg(feature = "v2_82")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] - pub fn g_unix_mount_points_get_from_file( - table_path: *const c_char, - time_read_out: *mut u64, - n_points_out: *mut size_t, - ) -> *mut *mut GUnixMountPoint; - pub fn g_unix_mounts_changed_since(time: u64) -> gboolean; - pub fn g_unix_mounts_get(time_read: *mut u64) -> *mut glib::GList; - #[cfg(feature = "v2_82")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] - pub fn g_unix_mounts_get_from_file( - table_path: *const c_char, - time_read_out: *mut u64, - n_entries_out: *mut size_t, - ) -> *mut *mut GUnixMountEntry; } diff --git a/gio/sys/tests/abi.rs b/gio/sys/tests/abi.rs index fd624564ba79..5b019541a2b7 100644 --- a/gio/sys/tests/abi.rs +++ b/gio/sys/tests/abi.rs @@ -14,7 +14,7 @@ use std::process::{Command, Stdio}; use std::str; use tempfile::Builder; -static PACKAGES: &[&str] = &["gio-2.0", "gio-unix-2.0"]; +static PACKAGES: &[&str] = &["gio-2.0"]; #[derive(Clone, Debug)] struct Compiler { @@ -796,20 +796,6 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[ alignment: align_of::(), }, ), - ( - "GDesktopAppInfoClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GDesktopAppInfoLookupIface", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), ( "GDriveIface", Layout { @@ -922,13 +908,6 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[ alignment: align_of::(), }, ), - ( - "GFileDescriptorBasedIface", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), ( "GFileEnumerator", Layout { @@ -2133,48 +2112,6 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[ alignment: align_of::(), }, ), - ( - "GUnixFDMessage", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GUnixFDMessageClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GUnixInputStream", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GUnixInputStreamClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GUnixOutputStream", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "GUnixOutputStreamClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), ( "GUnixSocketAddress", Layout { @@ -2458,10 +2395,6 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ "G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME", "gio-debug-controller", ), - ( - "G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME", - "gio-desktop-app-info-lookup", - ), ("G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE", "unix-device"), ("(guint) G_DRIVE_START_NONE", "0"), ("(gint) G_DRIVE_START_STOP_TYPE_MULTIDISK", "3"), diff --git a/gio/sys/tests/constant.c b/gio/sys/tests/constant.c index 5a013929b96c..7fea42930ea3 100644 --- a/gio/sys/tests/constant.c +++ b/gio/sys/tests/constant.c @@ -189,7 +189,6 @@ int main() { PRINT_CONSTANT((guint) G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES); PRINT_CONSTANT((guint) G_DBUS_SUBTREE_FLAGS_NONE); PRINT_CONSTANT(G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME); - PRINT_CONSTANT(G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME); PRINT_CONSTANT(G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE); PRINT_CONSTANT((guint) G_DRIVE_START_NONE); PRINT_CONSTANT((gint) G_DRIVE_START_STOP_TYPE_MULTIDISK); diff --git a/gio/sys/tests/layout.c b/gio/sys/tests/layout.c index 6f6a95ad4ced..d3544f3c1e40 100644 --- a/gio/sys/tests/layout.c +++ b/gio/sys/tests/layout.c @@ -92,8 +92,6 @@ int main() { printf("%s;%zu;%zu\n", "GDebugControllerDBus", sizeof(GDebugControllerDBus), alignof(GDebugControllerDBus)); printf("%s;%zu;%zu\n", "GDebugControllerDBusClass", sizeof(GDebugControllerDBusClass), alignof(GDebugControllerDBusClass)); printf("%s;%zu;%zu\n", "GDebugControllerInterface", sizeof(GDebugControllerInterface), alignof(GDebugControllerInterface)); - printf("%s;%zu;%zu\n", "GDesktopAppInfoClass", sizeof(GDesktopAppInfoClass), alignof(GDesktopAppInfoClass)); - printf("%s;%zu;%zu\n", "GDesktopAppInfoLookupIface", sizeof(GDesktopAppInfoLookupIface), alignof(GDesktopAppInfoLookupIface)); printf("%s;%zu;%zu\n", "GDriveIface", sizeof(GDriveIface), alignof(GDriveIface)); printf("%s;%zu;%zu\n", "GDriveStartFlags", sizeof(GDriveStartFlags), alignof(GDriveStartFlags)); printf("%s;%zu;%zu\n", "GDriveStartStopType", sizeof(GDriveStartStopType), alignof(GDriveStartStopType)); @@ -110,7 +108,6 @@ int main() { printf("%s;%zu;%zu\n", "GFileAttributeType", sizeof(GFileAttributeType), alignof(GFileAttributeType)); printf("%s;%zu;%zu\n", "GFileCopyFlags", sizeof(GFileCopyFlags), alignof(GFileCopyFlags)); printf("%s;%zu;%zu\n", "GFileCreateFlags", sizeof(GFileCreateFlags), alignof(GFileCreateFlags)); - printf("%s;%zu;%zu\n", "GFileDescriptorBasedIface", sizeof(GFileDescriptorBasedIface), alignof(GFileDescriptorBasedIface)); printf("%s;%zu;%zu\n", "GFileEnumerator", sizeof(GFileEnumerator), alignof(GFileEnumerator)); printf("%s;%zu;%zu\n", "GFileEnumeratorClass", sizeof(GFileEnumeratorClass), alignof(GFileEnumeratorClass)); printf("%s;%zu;%zu\n", "GFileIOStream", sizeof(GFileIOStream), alignof(GFileIOStream)); @@ -283,12 +280,6 @@ int main() { printf("%s;%zu;%zu\n", "GUnixCredentialsMessageClass", sizeof(GUnixCredentialsMessageClass), alignof(GUnixCredentialsMessageClass)); printf("%s;%zu;%zu\n", "GUnixFDList", sizeof(GUnixFDList), alignof(GUnixFDList)); printf("%s;%zu;%zu\n", "GUnixFDListClass", sizeof(GUnixFDListClass), alignof(GUnixFDListClass)); - printf("%s;%zu;%zu\n", "GUnixFDMessage", sizeof(GUnixFDMessage), alignof(GUnixFDMessage)); - printf("%s;%zu;%zu\n", "GUnixFDMessageClass", sizeof(GUnixFDMessageClass), alignof(GUnixFDMessageClass)); - printf("%s;%zu;%zu\n", "GUnixInputStream", sizeof(GUnixInputStream), alignof(GUnixInputStream)); - printf("%s;%zu;%zu\n", "GUnixInputStreamClass", sizeof(GUnixInputStreamClass), alignof(GUnixInputStreamClass)); - printf("%s;%zu;%zu\n", "GUnixOutputStream", sizeof(GUnixOutputStream), alignof(GUnixOutputStream)); - printf("%s;%zu;%zu\n", "GUnixOutputStreamClass", sizeof(GUnixOutputStreamClass), alignof(GUnixOutputStreamClass)); printf("%s;%zu;%zu\n", "GUnixSocketAddress", sizeof(GUnixSocketAddress), alignof(GUnixSocketAddress)); printf("%s;%zu;%zu\n", "GUnixSocketAddressClass", sizeof(GUnixSocketAddressClass), alignof(GUnixSocketAddressClass)); printf("%s;%zu;%zu\n", "GUnixSocketAddressType", sizeof(GUnixSocketAddressType), alignof(GUnixSocketAddressType)); diff --git a/gio/sys/versions.txt b/gio/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/gio/sys/versions.txt +++ b/gio/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gir b/gir index d9a99899e425..1d0088ebcb66 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit d9a99899e425a061e50baca3a19cc54f952e285d +Subproject commit 1d0088ebcb66e5324fc5f8efa7ee993eff45faaa diff --git a/gir-files b/gir-files index 1490bcc19dc8..3b05ae05a285 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 1490bcc19dc80accb62a7ebc5d75c2dd49c386d0 +Subproject commit 3b05ae05a28512e43194beceff147078da76e766 diff --git a/glib/gobject-sys/versions.txt b/glib/gobject-sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/glib/gobject-sys/versions.txt +++ b/glib/gobject-sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib/src/auto/enums.rs b/glib/src/auto/enums.rs index 32d9d49a56d2..adbd155be22e 100644 --- a/glib/src/auto/enums.rs +++ b/glib/src/auto/enums.rs @@ -978,6 +978,8 @@ pub enum UnicodeBreakType { #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "G_UNICODE_BREAK_VIRAMA")] Virama, + #[doc(alias = "G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN")] + UnambiguousHyphen, #[doc(hidden)] __Unknown(i32), } @@ -1041,6 +1043,7 @@ impl IntoGlib for UnicodeBreakType { Self::ViramaFinal => ffi::G_UNICODE_BREAK_VIRAMA_FINAL, #[cfg(feature = "v2_80")] Self::Virama => ffi::G_UNICODE_BREAK_VIRAMA, + Self::UnambiguousHyphen => ffi::G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN, Self::__Unknown(value) => value, } } @@ -1103,6 +1106,7 @@ impl FromGlib for UnicodeBreakType { ffi::G_UNICODE_BREAK_VIRAMA_FINAL => Self::ViramaFinal, #[cfg(feature = "v2_80")] ffi::G_UNICODE_BREAK_VIRAMA => Self::Virama, + ffi::G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN => Self::UnambiguousHyphen, value => Self::__Unknown(value), } } @@ -1542,6 +1546,14 @@ pub enum UnicodeScript { #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] #[doc(alias = "G_UNICODE_SCRIPT_OL_ONAL")] OlOnal, + #[doc(alias = "G_UNICODE_SCRIPT_SIDETIC")] + Sidetic, + #[doc(alias = "G_UNICODE_SCRIPT_TOLONG_SIKI")] + TolongSiki, + #[doc(alias = "G_UNICODE_SCRIPT_TAI_YO")] + TaiYo, + #[doc(alias = "G_UNICODE_SCRIPT_BERIA_ERFE")] + BeriaErfe, #[doc(hidden)] __Unknown(i32), } @@ -1752,6 +1764,10 @@ impl IntoGlib for UnicodeScript { Self::KiratRai => ffi::G_UNICODE_SCRIPT_KIRAT_RAI, #[cfg(feature = "v2_84")] Self::OlOnal => ffi::G_UNICODE_SCRIPT_OL_ONAL, + Self::Sidetic => ffi::G_UNICODE_SCRIPT_SIDETIC, + Self::TolongSiki => ffi::G_UNICODE_SCRIPT_TOLONG_SIKI, + Self::TaiYo => ffi::G_UNICODE_SCRIPT_TAI_YO, + Self::BeriaErfe => ffi::G_UNICODE_SCRIPT_BERIA_ERFE, Self::__Unknown(value) => value, } } @@ -1949,6 +1965,10 @@ impl FromGlib for UnicodeScript { ffi::G_UNICODE_SCRIPT_KIRAT_RAI => Self::KiratRai, #[cfg(feature = "v2_84")] ffi::G_UNICODE_SCRIPT_OL_ONAL => Self::OlOnal, + ffi::G_UNICODE_SCRIPT_SIDETIC => Self::Sidetic, + ffi::G_UNICODE_SCRIPT_TOLONG_SIKI => Self::TolongSiki, + ffi::G_UNICODE_SCRIPT_TAI_YO => Self::TaiYo, + ffi::G_UNICODE_SCRIPT_BERIA_ERFE => Self::BeriaErfe, value => Self::__Unknown(value), } } diff --git a/glib/src/auto/markup_parse_context.rs b/glib/src/auto/markup_parse_context.rs index 38d887f20119..21978dd0aea6 100644 --- a/glib/src/auto/markup_parse_context.rs +++ b/glib/src/auto/markup_parse_context.rs @@ -55,6 +55,14 @@ impl MarkupParseContext { } } + #[cfg(feature = "v2_88")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_88")))] + #[doc(alias = "g_markup_parse_context_get_offset")] + #[doc(alias = "get_offset")] + pub fn offset(&self) -> usize { + unsafe { ffi::g_markup_parse_context_get_offset(self.to_glib_none().0) } + } + #[doc(alias = "g_markup_parse_context_get_position")] #[doc(alias = "get_position")] pub fn position(&self) -> (i32, i32) { diff --git a/glib/src/auto/versions.txt b/glib/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/glib/src/auto/versions.txt +++ b/glib/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib/sys/Cargo.toml b/glib/sys/Cargo.toml index 8058eeed3186..73b18741ce0b 100644 --- a/glib/sys/Cargo.toml +++ b/glib/sys/Cargo.toml @@ -24,6 +24,7 @@ v2_80 = ["v2_78"] v2_82 = ["v2_80"] v2_84 = ["v2_82"] v2_86 = ["v2_84"] +v2_88 = ["v2_86"] [lib] name = "glib_sys" @@ -107,6 +108,9 @@ version = "2.84" [package.metadata.system-deps.glib_2_0.v2_86] version = "2.85" +[package.metadata.system-deps.glib_2_0.v2_88] +version = "2.88" + [package.metadata.system-deps.gobject_2_0] name = "gobject-2.0" version = "2.56" diff --git a/glib/sys/src/lib.rs b/glib/sys/src/lib.rs index bcd5b8e37781..c5d42d0a59af 100644 --- a/glib/sys/src/lib.rs +++ b/glib/sys/src/lib.rs @@ -439,6 +439,7 @@ pub const G_UNICODE_BREAK_AKSARA_PRE_BASE: GUnicodeBreakType = 44; pub const G_UNICODE_BREAK_AKSARA_START: GUnicodeBreakType = 45; pub const G_UNICODE_BREAK_VIRAMA_FINAL: GUnicodeBreakType = 46; pub const G_UNICODE_BREAK_VIRAMA: GUnicodeBreakType = 47; +pub const G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN: GUnicodeBreakType = 48; pub type GUnicodeScript = c_int; pub const G_UNICODE_SCRIPT_INVALID_CODE: GUnicodeScript = -1; @@ -614,6 +615,10 @@ pub const G_UNICODE_SCRIPT_SUNUWAR: GUnicodeScript = 168; pub const G_UNICODE_SCRIPT_GURUNG_KHEMA: GUnicodeScript = 169; pub const G_UNICODE_SCRIPT_KIRAT_RAI: GUnicodeScript = 170; pub const G_UNICODE_SCRIPT_OL_ONAL: GUnicodeScript = 171; +pub const G_UNICODE_SCRIPT_SIDETIC: GUnicodeScript = 172; +pub const G_UNICODE_SCRIPT_TOLONG_SIKI: GUnicodeScript = 173; +pub const G_UNICODE_SCRIPT_TAI_YO: GUnicodeScript = 174; +pub const G_UNICODE_SCRIPT_BERIA_ERFE: GUnicodeScript = 175; pub type GUnicodeType = c_int; pub const G_UNICODE_CONTROL: GUnicodeType = 0; @@ -3169,6 +3174,11 @@ extern "C" { //========================================================================= pub fn g_bytes_get_type() -> GType; pub fn g_bytes_new(data: gconstpointer, size: size_t) -> *mut GBytes; + pub fn g_bytes_new_from_bytes( + bytes: *mut GBytes, + offset: size_t, + length: size_t, + ) -> *mut GBytes; pub fn g_bytes_new_static(data: gconstpointer, size: size_t) -> *mut GBytes; pub fn g_bytes_new_take(data: gpointer, size: size_t) -> *mut GBytes; pub fn g_bytes_new_with_free_func( @@ -3190,11 +3200,6 @@ extern "C" { ) -> gconstpointer; pub fn g_bytes_get_size(bytes: *mut GBytes) -> size_t; pub fn g_bytes_hash(bytes: gconstpointer) -> c_uint; - pub fn g_bytes_new_from_bytes( - bytes: *mut GBytes, - offset: size_t, - length: size_t, - ) -> *mut GBytes; pub fn g_bytes_ref(bytes: *mut GBytes) -> *mut GBytes; pub fn g_bytes_unref(bytes: *mut GBytes); pub fn g_bytes_unref_to_array(bytes: *mut GBytes) -> *mut GByteArray; @@ -4248,6 +4253,9 @@ extern "C" { pub fn g_markup_parse_context_get_element_stack( context: *mut GMarkupParseContext, ) -> *const GSList; + #[cfg(feature = "v2_88")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_88")))] + pub fn g_markup_parse_context_get_offset(context: *mut GMarkupParseContext) -> size_t; pub fn g_markup_parse_context_get_position( context: *mut GMarkupParseContext, line_number: *mut c_int, @@ -7472,6 +7480,9 @@ extern "C" { user_data: gpointer, notify: GDestroyNotify, ) -> c_uint; + #[cfg(feature = "v2_88")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_88")))] + pub fn g_unix_fd_query_path(fd: c_int, error: *mut *mut GError) -> *mut c_char; pub fn g_unix_fd_source_new(fd: c_int, condition: GIOCondition) -> *mut GSource; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] diff --git a/glib/sys/tests/abi.rs b/glib/sys/tests/abi.rs index a108ec40fe20..4b5856264169 100644 --- a/glib/sys/tests/abi.rs +++ b/glib/sys/tests/abi.rs @@ -1589,6 +1589,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_BREAK_SPACE", "9"), ("(gint) G_UNICODE_BREAK_SURROGATE", "4"), ("(gint) G_UNICODE_BREAK_SYMBOL", "22"), + ("(gint) G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN", "48"), ("(gint) G_UNICODE_BREAK_UNKNOWN", "28"), ("(gint) G_UNICODE_BREAK_VIRAMA", "47"), ("(gint) G_UNICODE_BREAK_VIRAMA_FINAL", "46"), @@ -1630,6 +1631,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_SCRIPT_BASSA_VAH", "103"), ("(gint) G_UNICODE_SCRIPT_BATAK", "93"), ("(gint) G_UNICODE_SCRIPT_BENGALI", "4"), + ("(gint) G_UNICODE_SCRIPT_BERIA_ERFE", "175"), ("(gint) G_UNICODE_SCRIPT_BHAIKSUKI", "133"), ("(gint) G_UNICODE_SCRIPT_BOPOMOFO", "5"), ("(gint) G_UNICODE_SCRIPT_BRAHMI", "94"), @@ -1756,6 +1758,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_SCRIPT_SHARADA", "100"), ("(gint) G_UNICODE_SCRIPT_SHAVIAN", "50"), ("(gint) G_UNICODE_SCRIPT_SIDDHAM", "123"), + ("(gint) G_UNICODE_SCRIPT_SIDETIC", "172"), ("(gint) G_UNICODE_SCRIPT_SIGNWRITING", "131"), ("(gint) G_UNICODE_SCRIPT_SINHALA", "33"), ("(gint) G_UNICODE_SCRIPT_SOGDIAN", "148"), @@ -1770,6 +1773,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_SCRIPT_TAI_LE", "52"), ("(gint) G_UNICODE_SCRIPT_TAI_THAM", "91"), ("(gint) G_UNICODE_SCRIPT_TAI_VIET", "92"), + ("(gint) G_UNICODE_SCRIPT_TAI_YO", "174"), ("(gint) G_UNICODE_SCRIPT_TAKRI", "102"), ("(gint) G_UNICODE_SCRIPT_TAMIL", "35"), ("(gint) G_UNICODE_SCRIPT_TANGSA", "159"), @@ -1781,6 +1785,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_SCRIPT_TIFINAGH", "57"), ("(gint) G_UNICODE_SCRIPT_TIRHUTA", "124"), ("(gint) G_UNICODE_SCRIPT_TODHRI", "165"), + ("(gint) G_UNICODE_SCRIPT_TOLONG_SIKI", "173"), ("(gint) G_UNICODE_SCRIPT_TOTO", "160"), ("(gint) G_UNICODE_SCRIPT_TULU_TIGALARI", "167"), ("(gint) G_UNICODE_SCRIPT_UGARITIC", "53"), diff --git a/glib/sys/tests/constant.c b/glib/sys/tests/constant.c index b51a93536637..7e6edfac1bf0 100644 --- a/glib/sys/tests/constant.c +++ b/glib/sys/tests/constant.c @@ -570,6 +570,7 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_BREAK_SPACE); PRINT_CONSTANT((gint) G_UNICODE_BREAK_SURROGATE); PRINT_CONSTANT((gint) G_UNICODE_BREAK_SYMBOL); + PRINT_CONSTANT((gint) G_UNICODE_BREAK_UNAMBIGUOUS_HYPHEN); PRINT_CONSTANT((gint) G_UNICODE_BREAK_UNKNOWN); PRINT_CONSTANT((gint) G_UNICODE_BREAK_VIRAMA); PRINT_CONSTANT((gint) G_UNICODE_BREAK_VIRAMA_FINAL); @@ -611,6 +612,7 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BASSA_VAH); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BATAK); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BENGALI); + PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BERIA_ERFE); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BHAIKSUKI); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BOPOMOFO); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_BRAHMI); @@ -737,6 +739,7 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SHARADA); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SHAVIAN); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SIDDHAM); + PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SIDETIC); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SIGNWRITING); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SINHALA); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_SOGDIAN); @@ -751,6 +754,7 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAI_LE); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAI_THAM); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAI_VIET); + PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAI_YO); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAKRI); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TAMIL); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TANGSA); @@ -762,6 +766,7 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TIFINAGH); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TIRHUTA); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TODHRI); + PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TOLONG_SIKI); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TOTO); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_TULU_TIGALARI); PRINT_CONSTANT((gint) G_UNICODE_SCRIPT_UGARITIC); diff --git a/glib/sys/versions.txt b/glib/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/glib/sys/versions.txt +++ b/glib/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/graphene/src/auto/versions.txt b/graphene/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/graphene/src/auto/versions.txt +++ b/graphene/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/graphene/sys/versions.txt b/graphene/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/graphene/sys/versions.txt +++ b/graphene/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/pango/src/auto/versions.txt b/pango/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/pango/src/auto/versions.txt +++ b/pango/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/pango/sys/versions.txt b/pango/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/pango/sys/versions.txt +++ b/pango/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/pangocairo/src/auto/versions.txt b/pangocairo/src/auto/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/pangocairo/src/auto/versions.txt +++ b/pangocairo/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/pangocairo/sys/versions.txt b/pangocairo/sys/versions.txt index 95f4ec86d786..b47135b9caf9 100644 --- a/pangocairo/sys/versions.txt +++ b/pangocairo/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ d9a99899e425) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) From 9d3c6ada13418f9a8bb0180534a09b86636cba7c Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 01:25:37 +0100 Subject: [PATCH 02/29] Generate bindings for win32/unix GLib/Gio --- Cargo.lock | 97 ++- Cargo.toml | 33 + gio-unix/Cargo.toml | 37 ++ gio-unix/Gir.toml | 85 +++ gio-unix/src/auto/desktop_app_info.rs | 223 +++++++ gio-unix/src/auto/fd_message.rs | 88 +++ gio-unix/src/auto/file_descriptor_based.rs | 29 + gio-unix/src/auto/functions.rs | 29 + gio-unix/src/auto/input_stream.rs | 90 +++ gio-unix/src/auto/mod.rs | 40 ++ gio-unix/src/auto/mount_entry.rs | 190 ++++++ gio-unix/src/auto/mount_monitor.rs | 72 ++ gio-unix/src/auto/mount_point.rs | 169 +++++ gio-unix/src/auto/output_stream.rs | 93 +++ gio-unix/src/auto/versions.txt | 2 + {gio => gio-unix}/src/desktop_app_info.rs | 9 +- .../src/fd_message.rs | 9 +- .../src/file_descriptor_based.rs | 18 +- .../src/input_stream.rs | 24 +- gio-unix/src/lib.rs | 33 + .../src/mount_entry.rs | 16 +- .../src/mount_point.rs | 6 +- .../src/output_stream.rs | 21 +- gio-unix/sys/Cargo.toml | 66 ++ gio-unix/sys/Gir.toml | 28 + gio-unix/sys/build.rs | 15 + gio-unix/sys/src/lib.rs | 625 ++++++++++++++++++ gio-unix/sys/src/manual.rs | 135 ++++ gio-unix/sys/tests/abi.rs | 272 ++++++++ gio-unix/sys/tests/constant.c | 33 + gio-unix/sys/tests/layout.c | 20 + gio-unix/sys/tests/manual.h | 9 + gio-unix/sys/versions.txt | 2 + gio-win32/Cargo.toml | 37 ++ gio-win32/Gir.toml | 30 + gio-win32/src/auto/functions.rs | 19 + gio-win32/src/auto/input_stream.rs | 87 +++ gio-win32/src/auto/mod.rs | 16 + gio-win32/src/auto/output_stream.rs | 87 +++ gio-win32/src/auto/versions.txt | 2 + gio-win32/src/lib.rs | 14 + gio-win32/sys/Cargo.toml | 55 ++ gio-win32/sys/Gir.toml | 13 + gio-win32/sys/build.rs | 15 + gio-win32/sys/src/lib.rs | 213 ++++++ gio-win32/sys/src/manual.rs | 135 ++++ gio-win32/sys/tests/abi.rs | 248 +++++++ gio-win32/sys/tests/constant.c | 32 + gio-win32/sys/tests/layout.c | 17 + gio-win32/sys/tests/manual.h | 9 + gio-win32/sys/versions.txt | 2 + gio/Gir.toml | 18 - gio/src/lib.rs | 24 +- gio/src/prelude.rs | 16 - gio/src/unix_fd_list.rs | 84 --- gio/src/unix_socket_address.rs | 116 ---- gio/sys/Gir.toml | 3 - gio/sys/src/manual.rs | 256 +------ glib-unix/Cargo.toml | 33 + glib-unix/Gir.toml | 51 ++ glib-unix/src/auto/functions.rs | 22 + glib-unix/src/auto/mod.rs | 5 + glib-unix/src/auto/versions.txt | 2 + glib-unix/src/functions.rs | 503 ++++++++++++++ glib-unix/src/lib.rs | 9 + glib-unix/sys/Cargo.toml | 40 ++ glib-unix/sys/Gir.toml | 18 + glib-unix/sys/build.rs | 15 + glib-unix/sys/src/lib.rs | 131 ++++ glib-unix/sys/src/manual.rs | 11 + glib-unix/sys/tests/abi.rs | 223 +++++++ glib-unix/sys/tests/constant.c | 34 + glib-unix/sys/tests/layout.c | 13 + glib-unix/sys/tests/manual.h | 4 + glib-unix/sys/versions.txt | 2 + glib-win32/Cargo.toml | 31 + glib-win32/Gir.toml | 25 + glib-win32/src/auto/enums.rs | 48 ++ glib-win32/src/auto/functions.rs | 87 +++ glib-win32/src/auto/mod.rs | 8 + glib-win32/src/auto/versions.txt | 2 + glib-win32/src/functions.rs | 39 ++ glib-win32/src/lib.rs | 10 + glib-win32/sys/Cargo.toml | 33 + glib-win32/sys/Gir.toml | 11 + glib-win32/sys/build.rs | 15 + glib-win32/sys/src/lib.rs | 63 ++ glib-win32/sys/tests/abi.rs | 215 ++++++ glib-win32/sys/tests/constant.c | 35 + glib-win32/sys/tests/layout.c | 12 + glib-win32/sys/tests/manual.h | 3 + glib-win32/sys/versions.txt | 2 + glib/Cargo.toml | 1 + glib/Gir.toml | 23 +- glib/src/auto/functions.rs | 9 - glib/src/functions.rs | 20 +- glib/src/lib.rs | 6 - glib/src/source.rs | 395 ----------- glib/src/source_futures.rs | 60 -- glib/src/win32.rs | 118 ---- 100 files changed, 5342 insertions(+), 1211 deletions(-) create mode 100644 gio-unix/Cargo.toml create mode 100644 gio-unix/Gir.toml create mode 100644 gio-unix/src/auto/desktop_app_info.rs create mode 100644 gio-unix/src/auto/fd_message.rs create mode 100644 gio-unix/src/auto/file_descriptor_based.rs create mode 100644 gio-unix/src/auto/functions.rs create mode 100644 gio-unix/src/auto/input_stream.rs create mode 100644 gio-unix/src/auto/mod.rs create mode 100644 gio-unix/src/auto/mount_entry.rs create mode 100644 gio-unix/src/auto/mount_monitor.rs create mode 100644 gio-unix/src/auto/mount_point.rs create mode 100644 gio-unix/src/auto/output_stream.rs create mode 100644 gio-unix/src/auto/versions.txt rename {gio => gio-unix}/src/desktop_app_info.rs (93%) rename gio/src/unix_fd_message.rs => gio-unix/src/fd_message.rs (83%) rename {gio => gio-unix}/src/file_descriptor_based.rs (66%) rename gio/src/unix_input_stream.rs => gio-unix/src/input_stream.rs (70%) create mode 100644 gio-unix/src/lib.rs rename gio/src/unix_mount_entry.rs => gio-unix/src/mount_entry.rs (79%) rename gio/src/unix_mount_point.rs => gio-unix/src/mount_point.rs (86%) rename gio/src/unix_output_stream.rs => gio-unix/src/output_stream.rs (75%) create mode 100644 gio-unix/sys/Cargo.toml create mode 100644 gio-unix/sys/Gir.toml create mode 100644 gio-unix/sys/build.rs create mode 100644 gio-unix/sys/src/lib.rs create mode 100644 gio-unix/sys/src/manual.rs create mode 100644 gio-unix/sys/tests/abi.rs create mode 100644 gio-unix/sys/tests/constant.c create mode 100644 gio-unix/sys/tests/layout.c create mode 100644 gio-unix/sys/tests/manual.h create mode 100644 gio-unix/sys/versions.txt create mode 100644 gio-win32/Cargo.toml create mode 100644 gio-win32/Gir.toml create mode 100644 gio-win32/src/auto/functions.rs create mode 100644 gio-win32/src/auto/input_stream.rs create mode 100644 gio-win32/src/auto/mod.rs create mode 100644 gio-win32/src/auto/output_stream.rs create mode 100644 gio-win32/src/auto/versions.txt create mode 100644 gio-win32/src/lib.rs create mode 100644 gio-win32/sys/Cargo.toml create mode 100644 gio-win32/sys/Gir.toml create mode 100644 gio-win32/sys/build.rs create mode 100644 gio-win32/sys/src/lib.rs create mode 100644 gio-win32/sys/src/manual.rs create mode 100644 gio-win32/sys/tests/abi.rs create mode 100644 gio-win32/sys/tests/constant.c create mode 100644 gio-win32/sys/tests/layout.c create mode 100644 gio-win32/sys/tests/manual.h create mode 100644 gio-win32/sys/versions.txt delete mode 100644 gio/src/unix_fd_list.rs delete mode 100644 gio/src/unix_socket_address.rs create mode 100644 glib-unix/Cargo.toml create mode 100644 glib-unix/Gir.toml create mode 100644 glib-unix/src/auto/functions.rs create mode 100644 glib-unix/src/auto/mod.rs create mode 100644 glib-unix/src/auto/versions.txt create mode 100644 glib-unix/src/functions.rs create mode 100644 glib-unix/src/lib.rs create mode 100644 glib-unix/sys/Cargo.toml create mode 100644 glib-unix/sys/Gir.toml create mode 100644 glib-unix/sys/build.rs create mode 100644 glib-unix/sys/src/lib.rs create mode 100644 glib-unix/sys/src/manual.rs create mode 100644 glib-unix/sys/tests/abi.rs create mode 100644 glib-unix/sys/tests/constant.c create mode 100644 glib-unix/sys/tests/layout.c create mode 100644 glib-unix/sys/tests/manual.h create mode 100644 glib-unix/sys/versions.txt create mode 100644 glib-win32/Cargo.toml create mode 100644 glib-win32/Gir.toml create mode 100644 glib-win32/src/auto/enums.rs create mode 100644 glib-win32/src/auto/functions.rs create mode 100644 glib-win32/src/auto/mod.rs create mode 100644 glib-win32/src/auto/versions.txt create mode 100644 glib-win32/src/functions.rs create mode 100644 glib-win32/src/lib.rs create mode 100644 glib-win32/sys/Cargo.toml create mode 100644 glib-win32/sys/Gir.toml create mode 100644 glib-win32/sys/build.rs create mode 100644 glib-win32/sys/src/lib.rs create mode 100644 glib-win32/sys/tests/abi.rs create mode 100644 glib-win32/sys/tests/constant.c create mode 100644 glib-win32/sys/tests/layout.c create mode 100644 glib-win32/sys/tests/manual.h create mode 100644 glib-win32/sys/versions.txt delete mode 100644 glib/src/win32.rs diff --git a/Cargo.lock b/Cargo.lock index 10084cf2675f..1aae7cc7d183 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,7 +521,57 @@ dependencies = [ "shell-words", "system-deps", "tempfile", - "windows-sys 0.61.2", + "windows-sys 0.52.0", +] + +[[package]] +name = "gio-unix" +version = "0.22.0" +dependencies = [ + "gio", + "gio-unix-sys", + "gir-format-check", + "glib", + "libc", + "tempfile", +] + +[[package]] +name = "gio-unix-sys" +version = "0.22.0" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + +[[package]] +name = "gio-win32" +version = "0.22.0" +dependencies = [ + "gio", + "gio-win32-sys", + "gir-format-check", + "libc", + "tempfile", +] + +[[package]] +name = "gio-win32-sys" +version = "0.22.0" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", + "windows-sys 0.52.0", ] [[package]] @@ -584,6 +634,51 @@ dependencies = [ "tempfile", ] +[[package]] +name = "glib-unix" +version = "0.22.0" +dependencies = [ + "futures-core", + "gir-format-check", + "glib", + "glib-unix-sys", + "libc", + "tempfile", +] + +[[package]] +name = "glib-unix-sys" +version = "0.22.0" +dependencies = [ + "glib-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + +[[package]] +name = "glib-win32" +version = "0.22.0" +dependencies = [ + "gir-format-check", + "glib", + "glib-win32-sys", + "libc", + "tempfile", +] + +[[package]] +name = "glib-win32-sys" +version = "0.22.0" +dependencies = [ + "glib-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + [[package]] name = "glob" version = "0.3.3" diff --git a/Cargo.toml b/Cargo.toml index b5003e20835c..3ad149c5d18e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,31 @@ [workspace] resolver = "2" +default-members = [ + "cairo", + "cairo/sys", + "gdk-pixbuf", + "gdk-pixbuf/sys", + "gio", + "gio/sys", + "gio-unix", + "gio-unix/sys", + "glib-build-tools", + "glib", + "glib/gobject-sys", + "glib/sys", + "glib-macros", + "glib-unix", + "glib-unix/sys", + "graphene", + "graphene/sys", + "examples", + "pango", + "pango/sys", + "pangocairo", + "pangocairo/sys", +] + members = [ "cairo", "cairo/sys", @@ -8,11 +33,19 @@ members = [ "gdk-pixbuf/sys", "gio", "gio/sys", + "gio-unix", + "gio-unix/sys", + "gio-win32", + "gio-win32/sys", "glib-build-tools", "glib", "glib/gobject-sys", "glib/sys", "glib-macros", + "glib-unix", + "glib-unix/sys", + "glib-win32", + "glib-win32/sys", "graphene", "graphene/sys", "examples", diff --git a/gio-unix/Cargo.toml b/gio-unix/Cargo.toml new file mode 100644 index 000000000000..1ac134abe2f6 --- /dev/null +++ b/gio-unix/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "gio-unix" +documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio-unix/" +description = "Rust bindings for the GioUnix library" +readme = "README.md" +keywords = ["gio", "gtk-rs", "gnome", "GUI"] +authors.workspace = true +edition.workspace = true +exclude.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +ffi = { package = "gio-unix-sys", path = "./sys"} +libc.workspace = true +glib.workspace = true +gio.workspace = true + +[dev-dependencies] +tempfile = "3" +gir-format-check.workspace = true + +[features] +default = [] +v2_58 = ["ffi/v2_58", "gio/v2_58"] +v2_60 = ["v2_58", "ffi/v2_60", "gio/v2_60"] +v2_66 = ["v2_60", "ffi/v2_66", "gio/v2_66"] +v2_82 = ["v2_66", "ffi/v2_82", "gio/v2_82"] +v2_84 = ["v2_82", "ffi/v2_84", "gio/v2_84"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/gio-unix/Gir.toml b/gio-unix/Gir.toml new file mode 100644 index 000000000000..b0fa8dfefbc1 --- /dev/null +++ b/gio-unix/Gir.toml @@ -0,0 +1,85 @@ +[external_libraries] +Gio = {min_version = "2.56"} + +[options] +girs_directories = ["../gir-files"] +library = "GioUnix" +version = "2.0" +min_cfg_version = "2.56" +use_gi_docgen = true +target_path = "." +work_mode = "normal" +single_version_file = true +deprecate_by_min_version = true +trust_return_value_nullability = true + +generate = [ + "GioUnix.FDMessage", + "GioUnix.FileDescriptorBased", + "GioUnix.InputStream", + "GioUnix.MountMonitor", + "GioUnix.OutputStream", +] + +ignore = [ +] + +manual = [ + "Gio.AppInfo", + "Gio.AppLaunchContext", + "Gio.Icon", + "Gio.InputStream", + "Gio.OutputStream", + "Gio.PollableInputStream", + "Gio.PollableOutputStream", + "Gio.SocketControlMessage", + "Gio.UnixFDList", + "GLib.Error", + "GLib.KeyFile", + "GLib.SpawnFlags", +] + +[[object]] +name = "GioUnix.*" +status = "generate" + [[object.function]] + pattern = "mount_(at|compare|copy|entries_changed_since|entries_get|entries_get_from_file|for|free|get_device_path|get_fs_type|get_mount_path|get_options|get_root_path|guess_can_eject|guess_icon|guess_name|guess_should_display|guess_symbolic_icon|is_readonly|is_system_internal|points_changed_since|points_get|points_get_from_file)" + manual = true # Should be part of MountEntry + [[object.function]] + pattern = "mounts_(get|get_from_file|changed_since)" + manual = true # Should be part of MountEntry + +[[object]] +name = "GioUnix.DesktopAppInfo" +status = "generate" + [[object.function]] + name = "get_boolean" + # Retrieves the boolean value of a key + rename = "boolean" + [[object.function]] + name = "search" + # returns vec of string + manual = true + [[object.function]] + name = "launch_uris_as_manager_with_fds" + # has to use RawFd / SOCKET + manual = true + +[[object]] +name = "GioUnix.MountEntry" +status = "generate" +version = "2.84" + [[object.function]] + pattern = "*" + [[object.function.parameter]] + pattern = "(mount1|mount2|mount_entry)" + const = true + +[[object]] +name = "GioUnix.MountPoint" +status = "generate" + [[object.function]] + pattern = "*" + [[object.function.parameter]] + pattern = "(mount1|mount2|mount_point)" + const = true \ No newline at end of file diff --git a/gio-unix/src/auto/desktop_app_info.rs b/gio-unix/src/auto/desktop_app_info.rs new file mode 100644 index 000000000000..9c556ecb4a7f --- /dev/null +++ b/gio-unix/src/auto/desktop_app_info.rs @@ -0,0 +1,223 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GDesktopAppInfo")] + pub struct DesktopAppInfo(Object) @implements gio::AppInfo; + + match fn { + type_ => || ffi::g_desktop_app_info_get_type(), + } +} + +impl DesktopAppInfo { + #[doc(alias = "g_desktop_app_info_new")] + pub fn new(desktop_id: &str) -> Option { + unsafe { from_glib_full(ffi::g_desktop_app_info_new(desktop_id.to_glib_none().0)) } + } + + #[doc(alias = "g_desktop_app_info_new_from_filename")] + #[doc(alias = "new_from_filename")] + pub fn from_filename(filename: impl AsRef) -> Option { + unsafe { + from_glib_full(ffi::g_desktop_app_info_new_from_filename( + filename.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_new_from_keyfile")] + #[doc(alias = "new_from_keyfile")] + pub fn from_keyfile(key_file: &glib::KeyFile) -> Option { + unsafe { + from_glib_full(ffi::g_desktop_app_info_new_from_keyfile( + key_file.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_action_name")] + #[doc(alias = "get_action_name")] + pub fn action_name(&self, action_name: &str) -> glib::GString { + unsafe { + from_glib_full(ffi::g_desktop_app_info_get_action_name( + self.to_glib_none().0, + action_name.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_boolean")] + #[doc(alias = "get_boolean")] + pub fn boolean(&self, key: &str) -> bool { + unsafe { + from_glib(ffi::g_desktop_app_info_get_boolean( + self.to_glib_none().0, + key.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_categories")] + #[doc(alias = "get_categories")] + pub fn categories(&self) -> Option { + unsafe { + from_glib_none(ffi::g_desktop_app_info_get_categories( + self.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_filename")] + #[doc(alias = "get_filename")] + pub fn filename(&self) -> Option { + unsafe { from_glib_none(ffi::g_desktop_app_info_get_filename(self.to_glib_none().0)) } + } + + #[doc(alias = "g_desktop_app_info_get_generic_name")] + #[doc(alias = "get_generic_name")] + pub fn generic_name(&self) -> Option { + unsafe { + from_glib_none(ffi::g_desktop_app_info_get_generic_name( + self.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_is_hidden")] + #[doc(alias = "get_is_hidden")] + pub fn is_hidden(&self) -> bool { + unsafe { from_glib(ffi::g_desktop_app_info_get_is_hidden(self.to_glib_none().0)) } + } + + #[doc(alias = "g_desktop_app_info_get_keywords")] + #[doc(alias = "get_keywords")] + pub fn keywords(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_get_keywords( + self.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_locale_string")] + #[doc(alias = "get_locale_string")] + pub fn locale_string(&self, key: &str) -> Option { + unsafe { + from_glib_full(ffi::g_desktop_app_info_get_locale_string( + self.to_glib_none().0, + key.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_nodisplay")] + #[doc(alias = "get_nodisplay")] + pub fn is_nodisplay(&self) -> bool { + unsafe { from_glib(ffi::g_desktop_app_info_get_nodisplay(self.to_glib_none().0)) } + } + + #[doc(alias = "g_desktop_app_info_get_show_in")] + #[doc(alias = "get_show_in")] + pub fn shows_in(&self, desktop_env: Option<&str>) -> bool { + unsafe { + from_glib(ffi::g_desktop_app_info_get_show_in( + self.to_glib_none().0, + desktop_env.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_startup_wm_class")] + #[doc(alias = "get_startup_wm_class")] + pub fn startup_wm_class(&self) -> Option { + unsafe { + from_glib_none(ffi::g_desktop_app_info_get_startup_wm_class( + self.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_string")] + #[doc(alias = "get_string")] + pub fn string(&self, key: &str) -> Option { + unsafe { + from_glib_full(ffi::g_desktop_app_info_get_string( + self.to_glib_none().0, + key.to_glib_none().0, + )) + } + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "g_desktop_app_info_get_string_list")] + #[doc(alias = "get_string_list")] + pub fn string_list(&self, key: &str) -> Vec { + unsafe { + let mut length = std::mem::MaybeUninit::uninit(); + let ret = FromGlibContainer::from_glib_full_num( + ffi::g_desktop_app_info_get_string_list( + self.to_glib_none().0, + key.to_glib_none().0, + length.as_mut_ptr(), + ), + length.assume_init() as _, + ); + ret + } + } + + #[doc(alias = "g_desktop_app_info_has_key")] + pub fn has_key(&self, key: &str) -> bool { + unsafe { + from_glib(ffi::g_desktop_app_info_has_key( + self.to_glib_none().0, + key.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_launch_action")] + pub fn launch_action( + &self, + action_name: &str, + launch_context: Option<&impl IsA>, + ) { + unsafe { + ffi::g_desktop_app_info_launch_action( + self.to_glib_none().0, + action_name.to_glib_none().0, + launch_context.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + //#[doc(alias = "g_desktop_app_info_launch_uris_as_manager")] + //pub fn launch_uris_as_manager(&self, uris: &[&str], launch_context: Option<&impl IsA>, spawn_flags: glib::SpawnFlags, user_setup: Option>, pid_callback: /*Unimplemented*/FnMut(&DesktopAppInfo, /*Ignored*/glib::Pid), pid_callback_data: /*Unimplemented*/Option) -> Result<(), glib::Error> { + // unsafe { TODO: call ffi:g_desktop_app_info_launch_uris_as_manager() } + //} + + #[doc(alias = "g_desktop_app_info_list_actions")] + pub fn list_actions(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_list_actions( + self.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_desktop_app_info_get_implementations")] + #[doc(alias = "get_implementations")] + pub fn implementations(interface: &str) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::g_desktop_app_info_get_implementations( + interface.to_glib_none().0, + )) + } + } +} diff --git a/gio-unix/src/auto/fd_message.rs b/gio-unix/src/auto/fd_message.rs new file mode 100644 index 000000000000..8008faa7f0b3 --- /dev/null +++ b/gio-unix/src/auto/fd_message.rs @@ -0,0 +1,88 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GUnixFDMessage")] + pub struct FDMessage(Object) @extends gio::SocketControlMessage; + + match fn { + type_ => || ffi::g_unix_fd_message_get_type(), + } +} + +impl FDMessage { + pub const NONE: Option<&'static FDMessage> = None; + + #[doc(alias = "g_unix_fd_message_new")] + pub fn new() -> FDMessage { + unsafe { + gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast() + } + } + + #[doc(alias = "g_unix_fd_message_new_with_fd_list")] + #[doc(alias = "new_with_fd_list")] + pub fn with_fd_list(fd_list: &impl IsA) -> FDMessage { + unsafe { + gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list( + fd_list.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } +} + +impl Default for FDMessage { + fn default() -> Self { + Self::new() + } +} + +pub trait FDMessageExt: IsA + 'static { + #[doc(alias = "g_unix_fd_message_append_fd")] + fn append_fd(&self, fd: i32) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = + ffi::g_unix_fd_message_append_fd(self.as_ref().to_glib_none().0, fd, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_unix_fd_message_get_fd_list")] + #[doc(alias = "get_fd_list")] + #[doc(alias = "fd-list")] + fn fd_list(&self) -> gio::UnixFDList { + unsafe { + from_glib_none(ffi::g_unix_fd_message_get_fd_list( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_unix_fd_message_steal_fds")] + fn steal_fds(&self) -> Vec { + unsafe { + let mut length = std::mem::MaybeUninit::uninit(); + let ret = FromGlibContainer::from_glib_full_num( + ffi::g_unix_fd_message_steal_fds( + self.as_ref().to_glib_none().0, + length.as_mut_ptr(), + ), + length.assume_init() as _, + ); + ret + } + } +} + +impl> FDMessageExt for O {} diff --git a/gio-unix/src/auto/file_descriptor_based.rs b/gio-unix/src/auto/file_descriptor_based.rs new file mode 100644 index 000000000000..78c8fcb5821e --- /dev/null +++ b/gio-unix/src/auto/file_descriptor_based.rs @@ -0,0 +1,29 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GFileDescriptorBased")] + pub struct FileDescriptorBased(Interface); + + match fn { + type_ => || ffi::g_file_descriptor_based_get_type(), + } +} + +impl FileDescriptorBased { + pub const NONE: Option<&'static FileDescriptorBased> = None; +} + +pub trait FileDescriptorBasedExt: IsA + 'static { + #[doc(alias = "g_file_descriptor_based_get_fd")] + #[doc(alias = "get_fd")] + fn fd(&self) -> i32 { + unsafe { ffi::g_file_descriptor_based_get_fd(self.as_ref().to_glib_none().0) } + } +} + +impl> FileDescriptorBasedExt for O {} diff --git a/gio-unix/src/auto/functions.rs b/gio-unix/src/auto/functions.rs new file mode 100644 index 000000000000..22963ecefe0c --- /dev/null +++ b/gio-unix/src/auto/functions.rs @@ -0,0 +1,29 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::translate::*; + +#[doc(alias = "g_unix_is_mount_path_system_internal")] +pub fn is_mount_path_system_internal(mount_path: impl AsRef) -> bool { + unsafe { + from_glib(ffi::g_unix_is_mount_path_system_internal( + mount_path.as_ref().to_glib_none().0, + )) + } +} + +#[doc(alias = "g_unix_is_system_device_path")] +pub fn is_system_device_path(device_path: &str) -> bool { + unsafe { + from_glib(ffi::g_unix_is_system_device_path( + device_path.to_glib_none().0, + )) + } +} + +#[doc(alias = "g_unix_is_system_fs_type")] +pub fn is_system_fs_type(fs_type: &str) -> bool { + unsafe { from_glib(ffi::g_unix_is_system_fs_type(fs_type.to_glib_none().0)) } +} diff --git a/gio-unix/src/auto/input_stream.rs b/gio-unix/src/auto/input_stream.rs new file mode 100644 index 000000000000..2b21ec25ff79 --- /dev/null +++ b/gio-unix/src/auto/input_stream.rs @@ -0,0 +1,90 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, FileDescriptorBased}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GUnixInputStream")] + pub struct InputStream(Object) @extends gio::InputStream, @implements gio::PollableInputStream, FileDescriptorBased; + + match fn { + type_ => || ffi::g_unix_input_stream_get_type(), + } +} + +impl InputStream { + pub const NONE: Option<&'static InputStream> = None; + + #[doc(alias = "g_unix_input_stream_new")] + pub fn new(fd: i32, close_fd: bool) -> InputStream { + unsafe { + gio::InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd.into_glib())) + .unsafe_cast() + } + } +} + +pub trait InputStreamExt: IsA + 'static { + #[doc(alias = "g_unix_input_stream_get_close_fd")] + #[doc(alias = "get_close_fd")] + #[doc(alias = "close-fd")] + fn closes_fd(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_input_stream_get_close_fd( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_unix_input_stream_get_fd")] + #[doc(alias = "get_fd")] + fn fd(&self) -> i32 { + unsafe { ffi::g_unix_input_stream_get_fd(self.as_ref().to_glib_none().0) } + } + + #[doc(alias = "g_unix_input_stream_set_close_fd")] + #[doc(alias = "close-fd")] + fn set_close_fd(&self, close_fd: bool) { + unsafe { + ffi::g_unix_input_stream_set_close_fd( + self.as_ref().to_glib_none().0, + close_fd.into_glib(), + ); + } + } + + #[doc(alias = "close-fd")] + fn connect_close_fd_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_close_fd_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GUnixInputStream, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(InputStream::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::close-fd".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_close_fd_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> InputStreamExt for O {} diff --git a/gio-unix/src/auto/mod.rs b/gio-unix/src/auto/mod.rs new file mode 100644 index 000000000000..c9237ab761c3 --- /dev/null +++ b/gio-unix/src/auto/mod.rs @@ -0,0 +1,40 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +mod desktop_app_info; +pub use self::desktop_app_info::DesktopAppInfo; + +mod fd_message; +pub use self::fd_message::FDMessage; + +mod file_descriptor_based; +pub use self::file_descriptor_based::FileDescriptorBased; + +mod input_stream; +pub use self::input_stream::InputStream; + +mod mount_monitor; +pub use self::mount_monitor::MountMonitor; + +mod output_stream; +pub use self::output_stream::OutputStream; + +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +mod mount_entry; +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +pub use self::mount_entry::MountEntry; + +mod mount_point; +pub use self::mount_point::MountPoint; + +pub(crate) mod functions; + +pub(crate) mod traits { + pub use super::fd_message::FDMessageExt; + pub use super::file_descriptor_based::FileDescriptorBasedExt; + pub use super::input_stream::InputStreamExt; + pub use super::output_stream::OutputStreamExt; +} diff --git a/gio-unix/src/auto/mount_entry.rs b/gio-unix/src/auto/mount_entry.rs new file mode 100644 index 000000000000..cf7744c5e920 --- /dev/null +++ b/gio-unix/src/auto/mount_entry.rs @@ -0,0 +1,190 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::translate::*; + +glib::wrapper! { + #[derive(Debug, Hash)] + pub struct MountEntry(Boxed); + + match fn { + copy => |ptr| ffi::g_unix_mount_entry_copy(ptr), + free => |ptr| ffi::g_unix_mount_entry_free(ptr), + type_ => || ffi::g_unix_mount_entry_get_type(), + } +} + +impl MountEntry { + #[doc(alias = "g_unix_mount_entry_compare")] + fn compare(&self, mount2: &MountEntry) -> i32 { + unsafe { + ffi::g_unix_mount_entry_compare( + mut_override(self.to_glib_none().0), + mut_override(mount2.to_glib_none().0), + ) + } + } + + #[doc(alias = "g_unix_mount_entry_get_device_path")] + #[doc(alias = "get_device_path")] + pub fn device_path(&self) -> std::path::PathBuf { + unsafe { + from_glib_none(ffi::g_unix_mount_entry_get_device_path(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_get_fs_type")] + #[doc(alias = "get_fs_type")] + pub fn fs_type(&self) -> glib::GString { + unsafe { + from_glib_none(ffi::g_unix_mount_entry_get_fs_type(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_get_mount_path")] + #[doc(alias = "get_mount_path")] + pub fn mount_path(&self) -> std::path::PathBuf { + unsafe { + from_glib_none(ffi::g_unix_mount_entry_get_mount_path(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_get_options")] + #[doc(alias = "get_options")] + pub fn options(&self) -> Option { + unsafe { + from_glib_none(ffi::g_unix_mount_entry_get_options(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_get_root_path")] + #[doc(alias = "get_root_path")] + pub fn root_path(&self) -> Option { + unsafe { + from_glib_none(ffi::g_unix_mount_entry_get_root_path(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_guess_can_eject")] + pub fn guess_can_eject(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_entry_guess_can_eject(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_guess_icon")] + pub fn guess_icon(&self) -> gio::Icon { + unsafe { + from_glib_full(ffi::g_unix_mount_entry_guess_icon(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_guess_name")] + pub fn guess_name(&self) -> glib::GString { + unsafe { + from_glib_full(ffi::g_unix_mount_entry_guess_name(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_guess_should_display")] + pub fn guess_should_display(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_entry_guess_should_display(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_guess_symbolic_icon")] + pub fn guess_symbolic_icon(&self) -> gio::Icon { + unsafe { + from_glib_full(ffi::g_unix_mount_entry_guess_symbolic_icon(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_is_readonly")] + pub fn is_readonly(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_entry_is_readonly(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_is_system_internal")] + pub fn is_system_internal(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_entry_is_system_internal(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_entry_at")] + pub fn at(mount_path: impl AsRef) -> (Option, u64) { + unsafe { + let mut time_read = std::mem::MaybeUninit::uninit(); + let ret = from_glib_full(ffi::g_unix_mount_entry_at( + mount_path.as_ref().to_glib_none().0, + time_read.as_mut_ptr(), + )); + (ret, time_read.assume_init()) + } + } + + #[doc(alias = "g_unix_mount_entry_for")] + #[doc(alias = "for")] + pub fn for_(file_path: impl AsRef) -> (Option, u64) { + unsafe { + let mut time_read = std::mem::MaybeUninit::uninit(); + let ret = from_glib_full(ffi::g_unix_mount_entry_for( + file_path.as_ref().to_glib_none().0, + time_read.as_mut_ptr(), + )); + (ret, time_read.assume_init()) + } + } +} + +impl PartialEq for MountEntry { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.compare(other) == 0 + } +} + +impl Eq for MountEntry {} + +impl PartialOrd for MountEntry { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for MountEntry { + #[inline] + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.compare(other).cmp(&0) + } +} diff --git a/gio-unix/src/auto/mount_monitor.rs b/gio-unix/src/auto/mount_monitor.rs new file mode 100644 index 000000000000..86fc35ef82c9 --- /dev/null +++ b/gio-unix/src/auto/mount_monitor.rs @@ -0,0 +1,72 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{ + object::ObjectType as _, + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GUnixMountMonitor")] + pub struct MountMonitor(Object); + + match fn { + type_ => || ffi::g_unix_mount_monitor_get_type(), + } +} + +impl MountMonitor { + #[doc(alias = "g_unix_mount_monitor_get")] + pub fn get() -> MountMonitor { + unsafe { from_glib_full(ffi::g_unix_mount_monitor_get()) } + } + + #[doc(alias = "mountpoints-changed")] + pub fn connect_mountpoints_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn mountpoints_changed_trampoline( + this: *mut ffi::GUnixMountMonitor, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"mountpoints-changed".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + mountpoints_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "mounts-changed")] + pub fn connect_mounts_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn mounts_changed_trampoline( + this: *mut ffi::GUnixMountMonitor, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"mounts-changed".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + mounts_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} diff --git a/gio-unix/src/auto/mount_point.rs b/gio-unix/src/auto/mount_point.rs new file mode 100644 index 000000000000..e092e4c02824 --- /dev/null +++ b/gio-unix/src/auto/mount_point.rs @@ -0,0 +1,169 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::translate::*; + +glib::wrapper! { + #[derive(Debug, Hash)] + pub struct MountPoint(Boxed); + + match fn { + copy => |ptr| ffi::g_unix_mount_point_copy(ptr), + free => |ptr| ffi::g_unix_mount_point_free(ptr), + type_ => || ffi::g_unix_mount_point_get_type(), + } +} + +impl MountPoint { + #[doc(alias = "g_unix_mount_point_compare")] + fn compare(&self, mount2: &MountPoint) -> i32 { + unsafe { + ffi::g_unix_mount_point_compare( + mut_override(self.to_glib_none().0), + mut_override(mount2.to_glib_none().0), + ) + } + } + + #[doc(alias = "g_unix_mount_point_get_device_path")] + #[doc(alias = "get_device_path")] + pub fn device_path(&self) -> std::path::PathBuf { + unsafe { + from_glib_none(ffi::g_unix_mount_point_get_device_path(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_get_fs_type")] + #[doc(alias = "get_fs_type")] + pub fn fs_type(&self) -> glib::GString { + unsafe { + from_glib_none(ffi::g_unix_mount_point_get_fs_type(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_get_mount_path")] + #[doc(alias = "get_mount_path")] + pub fn mount_path(&self) -> std::path::PathBuf { + unsafe { + from_glib_none(ffi::g_unix_mount_point_get_mount_path(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_get_options")] + #[doc(alias = "get_options")] + pub fn options(&self) -> Option { + unsafe { + from_glib_none(ffi::g_unix_mount_point_get_options(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_guess_can_eject")] + pub fn guess_can_eject(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_point_guess_can_eject(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_guess_icon")] + pub fn guess_icon(&self) -> gio::Icon { + unsafe { + from_glib_full(ffi::g_unix_mount_point_guess_icon(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_guess_name")] + pub fn guess_name(&self) -> glib::GString { + unsafe { + from_glib_full(ffi::g_unix_mount_point_guess_name(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_guess_symbolic_icon")] + pub fn guess_symbolic_icon(&self) -> gio::Icon { + unsafe { + from_glib_full(ffi::g_unix_mount_point_guess_symbolic_icon(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_is_loopback")] + pub fn is_loopback(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_point_is_loopback(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_is_readonly")] + pub fn is_readonly(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_point_is_readonly(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[doc(alias = "g_unix_mount_point_is_user_mountable")] + pub fn is_user_mountable(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_mount_point_is_user_mountable(mut_override( + self.to_glib_none().0, + ))) + } + } + + #[cfg(feature = "v2_66")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] + #[doc(alias = "g_unix_mount_point_at")] + pub fn at(mount_path: impl AsRef) -> (Option, u64) { + unsafe { + let mut time_read = std::mem::MaybeUninit::uninit(); + let ret = from_glib_full(ffi::g_unix_mount_point_at( + mount_path.as_ref().to_glib_none().0, + time_read.as_mut_ptr(), + )); + (ret, time_read.assume_init()) + } + } +} + +impl PartialEq for MountPoint { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.compare(other) == 0 + } +} + +impl Eq for MountPoint {} + +impl PartialOrd for MountPoint { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for MountPoint { + #[inline] + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.compare(other).cmp(&0) + } +} diff --git a/gio-unix/src/auto/output_stream.rs b/gio-unix/src/auto/output_stream.rs new file mode 100644 index 000000000000..eb850ca78b6b --- /dev/null +++ b/gio-unix/src/auto/output_stream.rs @@ -0,0 +1,93 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, FileDescriptorBased}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GUnixOutputStream")] + pub struct OutputStream(Object) @extends gio::OutputStream, @implements gio::PollableOutputStream, FileDescriptorBased; + + match fn { + type_ => || ffi::g_unix_output_stream_get_type(), + } +} + +impl OutputStream { + pub const NONE: Option<&'static OutputStream> = None; + + #[doc(alias = "g_unix_output_stream_new")] + pub fn new(fd: i32, close_fd: bool) -> OutputStream { + unsafe { + gio::OutputStream::from_glib_full(ffi::g_unix_output_stream_new( + fd, + close_fd.into_glib(), + )) + .unsafe_cast() + } + } +} + +pub trait OutputStreamExt: IsA + 'static { + #[doc(alias = "g_unix_output_stream_get_close_fd")] + #[doc(alias = "get_close_fd")] + #[doc(alias = "close-fd")] + fn closes_fd(&self) -> bool { + unsafe { + from_glib(ffi::g_unix_output_stream_get_close_fd( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_unix_output_stream_get_fd")] + #[doc(alias = "get_fd")] + fn fd(&self) -> i32 { + unsafe { ffi::g_unix_output_stream_get_fd(self.as_ref().to_glib_none().0) } + } + + #[doc(alias = "g_unix_output_stream_set_close_fd")] + #[doc(alias = "close-fd")] + fn set_close_fd(&self, close_fd: bool) { + unsafe { + ffi::g_unix_output_stream_set_close_fd( + self.as_ref().to_glib_none().0, + close_fd.into_glib(), + ); + } + } + + #[doc(alias = "close-fd")] + fn connect_close_fd_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_close_fd_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GUnixOutputStream, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(OutputStream::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::close-fd".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_close_fd_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> OutputStreamExt for O {} diff --git a/gio-unix/src/auto/versions.txt b/gio-unix/src/auto/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/gio-unix/src/auto/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio/src/desktop_app_info.rs b/gio-unix/src/desktop_app_info.rs similarity index 93% rename from gio/src/desktop_app_info.rs rename to gio-unix/src/desktop_app_info.rs index b820bc005e52..e467618ff04c 100644 --- a/gio/src/desktop_app_info.rs +++ b/gio-unix/src/desktop_app_info.rs @@ -1,19 +1,14 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(all(unix, feature = "v2_58"))] use std::boxed::Box as Box_; -#[cfg(all(unix, feature = "v2_58"))] use std::os::unix::io::{AsFd, AsRawFd}; -#[cfg(all(unix, feature = "v2_58"))] use std::ptr; -#[cfg(all(feature = "v2_58", unix))] use glib::{prelude::*, Error}; use glib::{translate::*, GString}; -#[cfg(all(feature = "v2_58", unix))] -use crate::AppLaunchContext; use crate::{ffi, DesktopAppInfo}; +use gio::AppLaunchContext; impl DesktopAppInfo { #[doc(alias = "g_desktop_app_info_search")] @@ -44,7 +39,6 @@ impl DesktopAppInfo { } } -#[cfg(all(feature = "v2_58", unix))] pub trait DesktopAppInfoExtManual: IsA { #[cfg_attr(docsrs, doc(cfg(all(feature = "v2_58", unix))))] #[doc(alias = "g_desktop_app_info_launch_uris_as_manager_with_fds")] @@ -123,5 +117,4 @@ pub trait DesktopAppInfoExtManual: IsA { } } -#[cfg(all(feature = "v2_58", unix))] impl> DesktopAppInfoExtManual for O {} diff --git a/gio/src/unix_fd_message.rs b/gio-unix/src/fd_message.rs similarity index 83% rename from gio/src/unix_fd_message.rs rename to gio-unix/src/fd_message.rs index 48af5a7ce97f..584a3d21e631 100644 --- a/gio/src/unix_fd_message.rs +++ b/gio-unix/src/fd_message.rs @@ -1,16 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(unix)] use std::os::unix::io::{AsRawFd, RawFd}; use std::{mem, ptr}; use glib::{prelude::*, translate::*}; -#[cfg(all(not(unix), docsrs))] -use socket::{AsRawFd, RawFd}; -use crate::{ffi, UnixFDMessage}; +use crate::{ffi, FDMessage}; -pub trait UnixFDMessageExtManual: IsA + Sized { +pub trait FDMessageExtManual: IsA + Sized { #[doc(alias = "g_unix_fd_message_append_fd")] fn append_fd(&self, fd: T) -> Result<(), glib::Error> { unsafe { @@ -43,4 +40,4 @@ pub trait UnixFDMessageExtManual: IsA + Sized { } } -impl> UnixFDMessageExtManual for O {} +impl> FDMessageExtManual for O {} diff --git a/gio/src/file_descriptor_based.rs b/gio-unix/src/file_descriptor_based.rs similarity index 66% rename from gio/src/file_descriptor_based.rs rename to gio-unix/src/file_descriptor_based.rs index 074f14d66fc6..3ab4363d2d5f 100644 --- a/gio/src/file_descriptor_based.rs +++ b/gio-unix/src/file_descriptor_based.rs @@ -1,25 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(unix)] use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; -use crate::ffi; +use crate::{ffi, FileDescriptorBased}; use glib::{prelude::*, translate::*}; -#[cfg(all(not(unix), docsrs))] -use socket::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; - -glib::wrapper! { - #[doc(alias = "GFileDescriptorBased")] - pub struct FileDescriptorBased(Interface); - - match fn { - type_ => || ffi::g_file_descriptor_based_get_type(), - } -} - -impl FileDescriptorBased { - pub const NONE: Option<&'static FileDescriptorBased> = None; -} impl AsRawFd for FileDescriptorBased { fn as_raw_fd(&self) -> RawFd { diff --git a/gio/src/unix_input_stream.rs b/gio-unix/src/input_stream.rs similarity index 70% rename from gio/src/unix_input_stream.rs rename to gio-unix/src/input_stream.rs index a1f3e8769a8b..088711049160 100644 --- a/gio/src/unix_input_stream.rs +++ b/gio-unix/src/input_stream.rs @@ -1,23 +1,21 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(unix)] use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, IntoRawFd, OwnedFd, RawFd}; use glib::{prelude::*, translate::*}; -#[cfg(all(not(unix), docsrs))] -use socket::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::{ffi, InputStream, UnixInputStream}; +use crate::{ffi, InputStream}; -impl UnixInputStream { +impl InputStream { // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in fd. #[doc(alias = "g_unix_input_stream_new")] - pub fn take_fd(fd: OwnedFd) -> UnixInputStream { + pub fn take_fd(fd: OwnedFd) -> InputStream { let fd = fd.into_raw_fd(); let close_fd = true.into_glib(); unsafe { - InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() + gio::InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)) + .unsafe_cast() } } @@ -27,20 +25,20 @@ impl UnixInputStream { /// # Safety /// You may only close the fd if all references to this stream have been dropped. #[doc(alias = "g_unix_input_stream_new")] - pub unsafe fn with_fd(fd: T) -> UnixInputStream { + pub unsafe fn with_fd(fd: T) -> InputStream { let fd = fd.as_raw_fd(); let close_fd = false.into_glib(); - InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() + gio::InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() } } -impl AsRawFd for UnixInputStream { +impl AsRawFd for InputStream { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_unix_input_stream_get_fd(self.to_glib_none().0) as _ } } } -impl AsFd for UnixInputStream { +impl AsFd for InputStream { fn as_fd(&self) -> BorrowedFd<'_> { unsafe { let raw_fd = self.as_raw_fd(); @@ -49,7 +47,7 @@ impl AsFd for UnixInputStream { } } -pub trait UnixInputStreamExtManual: IsA + Sized { +pub trait InputStreamExtManual: IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// @@ -62,4 +60,4 @@ pub trait UnixInputStreamExtManual: IsA + Sized { } } -impl> UnixInputStreamExtManual for O {} +impl> InputStreamExtManual for O {} diff --git a/gio-unix/src/lib.rs b/gio-unix/src/lib.rs new file mode 100644 index 000000000000..44812abd0af6 --- /dev/null +++ b/gio-unix/src/lib.rs @@ -0,0 +1,33 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +pub use ffi; + +#[allow(unused_imports)] +mod auto; +pub use auto::*; + +#[cfg(feature = "v2_58")] +mod desktop_app_info; +mod fd_message; +mod file_descriptor_based; +mod input_stream; +#[cfg(feature = "v2_84")] +mod mount_entry; +mod mount_point; +mod output_stream; + +pub mod functions { + pub use super::auto::functions::*; +} + +pub mod prelude { + pub use super::auto::traits::*; + + #[cfg(feature = "v2_58")] + pub use crate::desktop_app_info::DesktopAppInfoExtManual; + + pub use crate::fd_message::FDMessageExtManual; + pub use crate::file_descriptor_based::FileDescriptorBasedExtManual; + pub use crate::input_stream::InputStreamExtManual; + pub use crate::output_stream::OutputStreamExtManual; +} diff --git a/gio/src/unix_mount_entry.rs b/gio-unix/src/mount_entry.rs similarity index 79% rename from gio/src/unix_mount_entry.rs rename to gio-unix/src/mount_entry.rs index 2b7a2f88b362..ea43b2c55360 100644 --- a/gio/src/unix_mount_entry.rs +++ b/gio-unix/src/mount_entry.rs @@ -4,13 +4,13 @@ use std::mem; use glib::translate::*; -use crate::{ffi, UnixMountEntry}; +use crate::{ffi, MountEntry}; -impl UnixMountEntry { +impl MountEntry { #[doc(alias = "g_unix_mounts_get")] #[doc(alias = "g_unix_mount_entries_get")] #[doc(alias = "get_mounts")] - pub fn mounts() -> (Vec, u64) { + pub fn mounts() -> (Vec, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mount_entries_get( @@ -21,12 +21,10 @@ impl UnixMountEntry { } } - #[cfg(feature = "v2_82")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] #[doc(alias = "g_unix_mounts_get")] #[doc(alias = "g_unix_mount_entries_get")] #[doc(alias = "get_mounts")] - pub fn mounts_from_file(table_path: impl AsRef) -> (Vec, u64) { + pub fn mounts_from_file(table_path: impl AsRef) -> (Vec, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let mut n_entries_out = mem::MaybeUninit::uninit(); @@ -42,12 +40,6 @@ impl UnixMountEntry { } } - #[doc(alias = "g_unix_mount_get_mount_path")] - #[deprecated = "Use `mount_path()`"] - pub fn unix_mount_get_mount_path(&self) -> std::path::PathBuf { - self.mount_path() - } - #[doc(alias = "g_unix_mounts_changed_since")] #[doc(alias = "g_unix_mount_entries_changed_since")] pub fn is_changed_since(time: u64) -> bool { diff --git a/gio/src/unix_mount_point.rs b/gio-unix/src/mount_point.rs similarity index 86% rename from gio/src/unix_mount_point.rs rename to gio-unix/src/mount_point.rs index cd24fc7be379..6e86ac54fbb7 100644 --- a/gio/src/unix_mount_point.rs +++ b/gio-unix/src/mount_point.rs @@ -4,13 +4,13 @@ use std::mem; use glib::translate::*; -use crate::{ffi, UnixMountPoint}; +use crate::{ffi, MountPoint}; -impl UnixMountPoint { +impl MountPoint { #[cfg(unix)] #[doc(alias = "g_unix_mount_points_get")] #[doc(alias = "get_mount_points")] - pub fn mount_points() -> (Vec, u64) { + pub fn mount_points() -> (Vec, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mount_points_get( diff --git a/gio/src/unix_output_stream.rs b/gio-unix/src/output_stream.rs similarity index 75% rename from gio/src/unix_output_stream.rs rename to gio-unix/src/output_stream.rs index acd30a22f510..a9de89f9a084 100644 --- a/gio/src/unix_output_stream.rs +++ b/gio-unix/src/output_stream.rs @@ -7,17 +7,18 @@ use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::{ffi, OutputStream, UnixOutputStream}; +use crate::{ffi, OutputStream}; -impl UnixOutputStream { +impl OutputStream { // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in fd. #[doc(alias = "g_unix_output_stream_new")] - pub fn take_fd(fd: OwnedFd) -> UnixOutputStream { + pub fn take_fd(fd: OwnedFd) -> OutputStream { let fd = fd.into_raw_fd(); let close_fd = true.into_glib(); unsafe { - OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() + gio::OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)) + .unsafe_cast() } } @@ -27,20 +28,20 @@ impl UnixOutputStream { /// # Safety /// You may only close the fd if all references to this stream have been dropped. #[doc(alias = "g_unix_output_stream_new")] - pub unsafe fn with_fd(fd: T) -> UnixOutputStream { + pub unsafe fn with_fd(fd: T) -> OutputStream { let fd = fd.as_raw_fd(); let close_fd = false.into_glib(); - OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() + gio::OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() } } -impl AsRawFd for UnixOutputStream { +impl AsRawFd for OutputStream { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_unix_output_stream_get_fd(self.to_glib_none().0) as _ } } } -impl AsFd for UnixOutputStream { +impl AsFd for OutputStream { fn as_fd(&self) -> BorrowedFd<'_> { unsafe { let raw_fd = self.as_raw_fd(); @@ -49,7 +50,7 @@ impl AsFd for UnixOutputStream { } } -pub trait UnixOutputStreamExtManual: IsA + Sized { +pub trait OutputStreamExtManual: IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// @@ -65,4 +66,4 @@ pub trait UnixOutputStreamExtManual: IsA + Sized { } } -impl> UnixOutputStreamExtManual for O {} +impl> OutputStreamExtManual for O {} diff --git a/gio-unix/sys/Cargo.toml b/gio-unix/sys/Cargo.toml new file mode 100644 index 000000000000..f3a660919e51 --- /dev/null +++ b/gio-unix/sys/Cargo.toml @@ -0,0 +1,66 @@ +[package] +name = "gio-unix-sys" +build = "build.rs" + +[package.version] +workspace = true + +[package.edition] +workspace = true + +[package.metadata.system-deps.glib_2_0] +name = "glib-2.0" +version = "2.56" + +[package.metadata.system-deps.gio_unix_2_0] +name = "gio-unix-2.0" +version = "2.56" + +[package.metadata.system-deps.gio_unix_2_0.v2_58] +version = "2.58" + +[package.metadata.system-deps.gio_unix_2_0.v2_60] +version = "2.60" + +[package.metadata.system-deps.gio_unix_2_0.v2_66] +version = "2.66" + +[package.metadata.system-deps.gio_unix_2_0.v2_82] +version = "2.82" + +[package.metadata.system-deps.gio_unix_2_0.v2_84] +version = "2.84" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true + +[lib] +name = "gio_unix_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gobject-sys] +workspace = true + +[dependencies.gio-sys] +workspace = true + +[build-dependencies] +system-deps = "7" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v2_58 = [] +v2_60 = ["v2_58"] +v2_66 = ["v2_60"] +v2_82 = ["v2_66"] +v2_84 = ["v2_82"] diff --git a/gio-unix/sys/Gir.toml b/gio-unix/sys/Gir.toml new file mode 100644 index 000000000000..5d550a271b64 --- /dev/null +++ b/gio-unix/sys/Gir.toml @@ -0,0 +1,28 @@ +[options] +work_mode = "sys" +library = "GioUnix" +version = "2.0" +min_cfg_version = "2.56" +single_version_file = "." +girs_directories = ["../../gir-files"] + +external_libraries = [ + "GLib", + "GObject", + "Gio", +] + +[[object]] +name = "GioUnix.MountEntry" +status = "generate" + [[object.function]] + name = "copy" + manual = true # Manual due to mutability issue + + +[[object]] +name = "GioUnix.MountPoint" +status = "generate" + [[object.function]] + name = "copy" + manual = true # Manual due to mutability issue \ No newline at end of file diff --git a/gio-unix/sys/build.rs b/gio-unix/sys/build.rs new file mode 100644 index 000000000000..7341ed1620c9 --- /dev/null +++ b/gio-unix/sys/build.rs @@ -0,0 +1,15 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +fn main() { + if std::env::var("DOCS_RS").is_ok() { + // prevent linking libraries to avoid documentation failure + return; + } + + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + std::process::exit(1); + } +} diff --git a/gio-unix/sys/src/lib.rs b/gio-unix/sys/src/lib.rs new file mode 100644 index 000000000000..981b4ae052a1 --- /dev/null +++ b/gio-unix/sys/src/lib.rs @@ -0,0 +1,625 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use gio_sys as gio; +use glib_sys as glib; +use gobject_sys as gobject; + +mod manual; + +pub use manual::*; + +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; +#[allow(unused_imports)] +use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE}; +#[allow(unused_imports)] +use std::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Constants +pub const G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME: &[u8] = b"gio-desktop-app-info-lookup\0"; + +// Callbacks +pub type GDesktopAppLaunchCallback = + Option; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GDesktopAppInfoClass { + pub parent_class: gobject::GObjectClass, +} + +impl ::std::fmt::Debug for GDesktopAppInfoClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GDesktopAppInfoClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GDesktopAppInfoLookupIface { + pub g_iface: gobject::GTypeInterface, + pub get_default_for_uri_scheme: Option< + unsafe extern "C" fn(*mut GDesktopAppInfoLookup, *const c_char) -> *mut gio::GAppInfo, + >, +} + +impl ::std::fmt::Debug for GDesktopAppInfoLookupIface { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GDesktopAppInfoLookupIface @ {self:p}")) + .field("g_iface", &self.g_iface) + .field( + "get_default_for_uri_scheme", + &self.get_default_for_uri_scheme, + ) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GFileDescriptorBasedIface { + pub g_iface: gobject::GTypeInterface, + pub get_fd: Option c_int>, +} + +impl ::std::fmt::Debug for GFileDescriptorBasedIface { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GFileDescriptorBasedIface @ {self:p}")) + .field("g_iface", &self.g_iface) + .field("get_fd", &self.get_fd) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixFDMessageClass { + pub parent_class: gio::GSocketControlMessageClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, +} + +impl ::std::fmt::Debug for GUnixFDMessageClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixFDMessageClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GUnixFDMessagePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GUnixFDMessagePrivate = _GUnixFDMessagePrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixInputStreamClass { + pub parent_class: gio::GInputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GUnixInputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixInputStreamClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GUnixInputStreamPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GUnixInputStreamPrivate = _GUnixInputStreamPrivate; + +#[repr(C)] +#[allow(dead_code)] +pub struct GUnixMountEntry { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GUnixMountEntry { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixMountEntry @ {self:p}")) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GUnixMountMonitorClass { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GUnixMountMonitorClass = _GUnixMountMonitorClass; + +#[repr(C)] +#[allow(dead_code)] +pub struct GUnixMountPoint { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GUnixMountPoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixMountPoint @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixOutputStreamClass { + pub parent_class: gio::GOutputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GUnixOutputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixOutputStreamClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GUnixOutputStreamPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GUnixOutputStreamPrivate = _GUnixOutputStreamPrivate; + +// Classes +#[repr(C)] +#[allow(dead_code)] +pub struct GDesktopAppInfo { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GDesktopAppInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GDesktopAppInfo @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixFDMessage { + pub parent_instance: gio::GSocketControlMessage, + pub priv_: *mut GUnixFDMessagePrivate, +} + +impl ::std::fmt::Debug for GUnixFDMessage { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixFDMessage @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .field("priv_", &self.priv_) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixInputStream { + pub parent_instance: gio::GInputStream, + pub priv_: *mut GUnixInputStreamPrivate, +} + +impl ::std::fmt::Debug for GUnixInputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixInputStream @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GUnixMountMonitor { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GUnixMountMonitor { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixMountMonitor @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixOutputStream { + pub parent_instance: gio::GOutputStream, + pub priv_: *mut GUnixOutputStreamPrivate, +} + +impl ::std::fmt::Debug for GUnixOutputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixOutputStream @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +// Interfaces +#[repr(C)] +#[allow(dead_code)] +pub struct GDesktopAppInfoLookup { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GDesktopAppInfoLookup { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "GDesktopAppInfoLookup @ {self:p}") + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GFileDescriptorBased { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GFileDescriptorBased { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "GFileDescriptorBased @ {self:p}") + } +} + +extern "C" { + + //========================================================================= + // GUnixMountEntry + //========================================================================= + pub fn g_unix_mount_entry_get_type() -> GType; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_compare( + mount1: *mut GUnixMountEntry, + mount2: *mut GUnixMountEntry, + ) -> c_int; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry); + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_get_device_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_get_fs_type(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_get_mount_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_get_options(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_get_root_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_guess_can_eject(mount_entry: *mut GUnixMountEntry) -> gboolean; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut gio::GIcon; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_guess_should_display(mount_entry: *mut GUnixMountEntry) -> gboolean; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_guess_symbolic_icon( + mount_entry: *mut GUnixMountEntry, + ) -> *mut gio::GIcon; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_is_system_internal(mount_entry: *mut GUnixMountEntry) -> gboolean; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_at( + mount_path: *const c_char, + time_read: *mut u64, + ) -> *mut GUnixMountEntry; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_for( + file_path: *const c_char, + time_read: *mut u64, + ) -> *mut GUnixMountEntry; + + //========================================================================= + // GUnixMountPoint + //========================================================================= + pub fn g_unix_mount_point_get_type() -> GType; + pub fn g_unix_mount_point_compare( + mount1: *mut GUnixMountPoint, + mount2: *mut GUnixMountPoint, + ) -> c_int; + pub fn g_unix_mount_point_free(mount_point: *mut GUnixMountPoint); + pub fn g_unix_mount_point_get_device_path(mount_point: *mut GUnixMountPoint) -> *const c_char; + pub fn g_unix_mount_point_get_fs_type(mount_point: *mut GUnixMountPoint) -> *const c_char; + pub fn g_unix_mount_point_get_mount_path(mount_point: *mut GUnixMountPoint) -> *const c_char; + pub fn g_unix_mount_point_get_options(mount_point: *mut GUnixMountPoint) -> *const c_char; + pub fn g_unix_mount_point_guess_can_eject(mount_point: *mut GUnixMountPoint) -> gboolean; + pub fn g_unix_mount_point_guess_icon(mount_point: *mut GUnixMountPoint) -> *mut gio::GIcon; + pub fn g_unix_mount_point_guess_name(mount_point: *mut GUnixMountPoint) -> *mut c_char; + pub fn g_unix_mount_point_guess_symbolic_icon( + mount_point: *mut GUnixMountPoint, + ) -> *mut gio::GIcon; + pub fn g_unix_mount_point_is_loopback(mount_point: *mut GUnixMountPoint) -> gboolean; + pub fn g_unix_mount_point_is_readonly(mount_point: *mut GUnixMountPoint) -> gboolean; + pub fn g_unix_mount_point_is_user_mountable(mount_point: *mut GUnixMountPoint) -> gboolean; + #[cfg(feature = "v2_66")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] + pub fn g_unix_mount_point_at( + mount_path: *const c_char, + time_read: *mut u64, + ) -> *mut GUnixMountPoint; + + //========================================================================= + // GDesktopAppInfo + //========================================================================= + pub fn g_desktop_app_info_get_type() -> GType; + pub fn g_desktop_app_info_new(desktop_id: *const c_char) -> *mut GDesktopAppInfo; + pub fn g_desktop_app_info_new_from_filename(filename: *const c_char) -> *mut GDesktopAppInfo; + pub fn g_desktop_app_info_new_from_keyfile( + key_file: *mut glib::GKeyFile, + ) -> *mut GDesktopAppInfo; + pub fn g_desktop_app_info_get_implementations(interface: *const c_char) -> *mut glib::GList; + pub fn g_desktop_app_info_search(search_string: *const c_char) -> *mut *mut *mut c_char; + pub fn g_desktop_app_info_set_desktop_env(desktop_env: *const c_char); + pub fn g_desktop_app_info_get_action_name( + info: *mut GDesktopAppInfo, + action_name: *const c_char, + ) -> *mut c_char; + pub fn g_desktop_app_info_get_boolean( + info: *mut GDesktopAppInfo, + key: *const c_char, + ) -> gboolean; + pub fn g_desktop_app_info_get_categories(info: *mut GDesktopAppInfo) -> *const c_char; + pub fn g_desktop_app_info_get_filename(info: *mut GDesktopAppInfo) -> *const c_char; + pub fn g_desktop_app_info_get_generic_name(info: *mut GDesktopAppInfo) -> *const c_char; + pub fn g_desktop_app_info_get_is_hidden(info: *mut GDesktopAppInfo) -> gboolean; + pub fn g_desktop_app_info_get_keywords(info: *mut GDesktopAppInfo) -> *const *const c_char; + pub fn g_desktop_app_info_get_locale_string( + info: *mut GDesktopAppInfo, + key: *const c_char, + ) -> *mut c_char; + pub fn g_desktop_app_info_get_nodisplay(info: *mut GDesktopAppInfo) -> gboolean; + pub fn g_desktop_app_info_get_show_in( + info: *mut GDesktopAppInfo, + desktop_env: *const c_char, + ) -> gboolean; + pub fn g_desktop_app_info_get_startup_wm_class(info: *mut GDesktopAppInfo) -> *const c_char; + pub fn g_desktop_app_info_get_string( + info: *mut GDesktopAppInfo, + key: *const c_char, + ) -> *mut c_char; + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + pub fn g_desktop_app_info_get_string_list( + info: *mut GDesktopAppInfo, + key: *const c_char, + length: *mut size_t, + ) -> *mut *mut c_char; + pub fn g_desktop_app_info_has_key(info: *mut GDesktopAppInfo, key: *const c_char) -> gboolean; + pub fn g_desktop_app_info_launch_action( + info: *mut GDesktopAppInfo, + action_name: *const c_char, + launch_context: *mut gio::GAppLaunchContext, + ); + pub fn g_desktop_app_info_launch_uris_as_manager( + appinfo: *mut GDesktopAppInfo, + uris: *mut glib::GList, + launch_context: *mut gio::GAppLaunchContext, + spawn_flags: glib::GSpawnFlags, + user_setup: glib::GSpawnChildSetupFunc, + user_setup_data: gpointer, + pid_callback: GDesktopAppLaunchCallback, + pid_callback_data: gpointer, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v2_58")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] + pub fn g_desktop_app_info_launch_uris_as_manager_with_fds( + appinfo: *mut GDesktopAppInfo, + uris: *mut glib::GList, + launch_context: *mut gio::GAppLaunchContext, + spawn_flags: glib::GSpawnFlags, + user_setup: glib::GSpawnChildSetupFunc, + user_setup_data: gpointer, + pid_callback: GDesktopAppLaunchCallback, + pid_callback_data: gpointer, + stdin_fd: c_int, + stdout_fd: c_int, + stderr_fd: c_int, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn g_desktop_app_info_list_actions(info: *mut GDesktopAppInfo) -> *const *const c_char; + + //========================================================================= + // GUnixFDMessage + //========================================================================= + pub fn g_unix_fd_message_get_type() -> GType; + pub fn g_unix_fd_message_new() -> *mut gio::GSocketControlMessage; + pub fn g_unix_fd_message_new_with_fd_list( + fd_list: *mut gio::GUnixFDList, + ) -> *mut gio::GSocketControlMessage; + pub fn g_unix_fd_message_append_fd( + message: *mut GUnixFDMessage, + fd: c_int, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn g_unix_fd_message_get_fd_list(message: *mut GUnixFDMessage) -> *mut gio::GUnixFDList; + pub fn g_unix_fd_message_steal_fds( + message: *mut GUnixFDMessage, + length: *mut c_int, + ) -> *mut c_int; + + //========================================================================= + // GUnixInputStream + //========================================================================= + pub fn g_unix_input_stream_get_type() -> GType; + pub fn g_unix_input_stream_new(fd: c_int, close_fd: gboolean) -> *mut gio::GInputStream; + pub fn g_unix_input_stream_get_close_fd(stream: *mut GUnixInputStream) -> gboolean; + pub fn g_unix_input_stream_get_fd(stream: *mut GUnixInputStream) -> c_int; + pub fn g_unix_input_stream_set_close_fd(stream: *mut GUnixInputStream, close_fd: gboolean); + + //========================================================================= + // GUnixMountMonitor + //========================================================================= + pub fn g_unix_mount_monitor_get_type() -> GType; + pub fn g_unix_mount_monitor_new() -> *mut GUnixMountMonitor; + pub fn g_unix_mount_monitor_get() -> *mut GUnixMountMonitor; + pub fn g_unix_mount_monitor_set_rate_limit( + mount_monitor: *mut GUnixMountMonitor, + limit_msec: c_int, + ); + + //========================================================================= + // GUnixOutputStream + //========================================================================= + pub fn g_unix_output_stream_get_type() -> GType; + pub fn g_unix_output_stream_new(fd: c_int, close_fd: gboolean) -> *mut gio::GOutputStream; + pub fn g_unix_output_stream_get_close_fd(stream: *mut GUnixOutputStream) -> gboolean; + pub fn g_unix_output_stream_get_fd(stream: *mut GUnixOutputStream) -> c_int; + pub fn g_unix_output_stream_set_close_fd(stream: *mut GUnixOutputStream, close_fd: gboolean); + + //========================================================================= + // GDesktopAppInfoLookup + //========================================================================= + pub fn g_desktop_app_info_lookup_get_type() -> GType; + pub fn g_desktop_app_info_lookup_get_default_for_uri_scheme( + lookup: *mut GDesktopAppInfoLookup, + uri_scheme: *const c_char, + ) -> *mut gio::GAppInfo; + + //========================================================================= + // GFileDescriptorBased + //========================================================================= + pub fn g_file_descriptor_based_get_type() -> GType; + pub fn g_file_descriptor_based_get_fd(fd_based: *mut GFileDescriptorBased) -> c_int; + + //========================================================================= + // Other functions + //========================================================================= + pub fn g_unix_is_mount_path_system_internal(mount_path: *const c_char) -> gboolean; + pub fn g_unix_is_system_device_path(device_path: *const c_char) -> gboolean; + pub fn g_unix_is_system_fs_type(fs_type: *const c_char) -> gboolean; + pub fn g_unix_mount_at(mount_path: *const c_char, time_read: *mut u64) -> *mut GUnixMountEntry; + pub fn g_unix_mount_compare( + mount1: *mut GUnixMountEntry, + mount2: *mut GUnixMountEntry, + ) -> c_int; + pub fn g_unix_mount_copy(mount_entry: *mut GUnixMountEntry) -> *mut GUnixMountEntry; + pub fn g_unix_mount_entries_changed_since(time: u64) -> gboolean; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib::GList; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entries_get_from_file( + table_path: *const c_char, + time_read_out: *mut u64, + n_entries_out: *mut size_t, + ) -> *mut *mut GUnixMountEntry; + pub fn g_unix_mount_for(file_path: *const c_char, time_read: *mut u64) -> *mut GUnixMountEntry; + pub fn g_unix_mount_free(mount_entry: *mut GUnixMountEntry); + pub fn g_unix_mount_get_device_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + pub fn g_unix_mount_get_fs_type(mount_entry: *mut GUnixMountEntry) -> *const c_char; + pub fn g_unix_mount_get_mount_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_58")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] + pub fn g_unix_mount_get_options(mount_entry: *mut GUnixMountEntry) -> *const c_char; + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + pub fn g_unix_mount_get_root_path(mount_entry: *mut GUnixMountEntry) -> *const c_char; + pub fn g_unix_mount_guess_can_eject(mount_entry: *mut GUnixMountEntry) -> gboolean; + pub fn g_unix_mount_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut gio::GIcon; + pub fn g_unix_mount_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char; + pub fn g_unix_mount_guess_should_display(mount_entry: *mut GUnixMountEntry) -> gboolean; + pub fn g_unix_mount_guess_symbolic_icon(mount_entry: *mut GUnixMountEntry) -> *mut gio::GIcon; + pub fn g_unix_mount_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean; + pub fn g_unix_mount_is_system_internal(mount_entry: *mut GUnixMountEntry) -> gboolean; + pub fn g_unix_mount_points_changed_since(time: u64) -> gboolean; + pub fn g_unix_mount_points_get(time_read: *mut u64) -> *mut glib::GList; + #[cfg(feature = "v2_82")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] + pub fn g_unix_mount_points_get_from_file( + table_path: *const c_char, + time_read_out: *mut u64, + n_points_out: *mut size_t, + ) -> *mut *mut GUnixMountPoint; + pub fn g_unix_mounts_changed_since(time: u64) -> gboolean; + pub fn g_unix_mounts_get(time_read: *mut u64) -> *mut glib::GList; + #[cfg(feature = "v2_82")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] + pub fn g_unix_mounts_get_from_file( + table_path: *const c_char, + time_read_out: *mut u64, + n_entries_out: *mut size_t, + ) -> *mut *mut GUnixMountEntry; + +} diff --git a/gio-unix/sys/src/manual.rs b/gio-unix/sys/src/manual.rs new file mode 100644 index 000000000000..cd9c46aa6ca1 --- /dev/null +++ b/gio-unix/sys/src/manual.rs @@ -0,0 +1,135 @@ +pub type GSocketFamily = libc::c_int; +pub type GSocketMsgFlags = libc::c_int; + +pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; +pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = libc::MSG_OOB; +pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK; +pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE; + +#[cfg(not(feature = "v2_84"))] +pub mod g_unix_fallback { + use crate::GUnixMountEntry; + use glib_sys::gboolean; + use libc::{c_char, c_int}; + + pub unsafe fn g_unix_mount_entry_compare( + mount1: *mut GUnixMountEntry, + mount2: *mut GUnixMountEntry, + ) -> c_int { + crate::g_unix_mount_compare(mount1, mount2) + } + pub unsafe fn g_unix_mount_entry_copy( + mount_entry: *mut GUnixMountEntry, + ) -> *mut GUnixMountEntry { + crate::g_unix_mount_copy(mount_entry) + } + pub unsafe fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry) { + crate::g_unix_mount_free(mount_entry); + } + pub unsafe fn g_unix_mount_entry_get_device_path( + mount_entry: *mut GUnixMountEntry, + ) -> *const c_char { + crate::g_unix_mount_get_device_path(mount_entry) + } + pub unsafe fn g_unix_mount_entry_get_fs_type( + mount_entry: *mut GUnixMountEntry, + ) -> *const c_char { + crate::g_unix_mount_get_fs_type(mount_entry) + } + pub unsafe fn g_unix_mount_entry_get_mount_path( + mount_entry: *mut GUnixMountEntry, + ) -> *const c_char { + crate::g_unix_mount_get_mount_path(mount_entry) + } + #[cfg(feature = "v2_58")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] + pub unsafe fn g_unix_mount_entry_get_options( + mount_entry: *mut GUnixMountEntry, + ) -> *const c_char { + crate::g_unix_mount_get_options(mount_entry) + } + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + pub unsafe fn g_unix_mount_entry_get_root_path( + mount_entry: *mut GUnixMountEntry, + ) -> *const c_char { + crate::g_unix_mount_get_root_path(mount_entry) + } + pub unsafe fn g_unix_mount_entry_guess_can_eject( + mount_entry: *mut GUnixMountEntry, + ) -> gboolean { + crate::g_unix_mount_guess_can_eject(mount_entry) + } + pub unsafe fn g_unix_mount_entry_guess_icon( + mount_entry: *mut GUnixMountEntry, + ) -> *mut gio_sys::GIcon { + crate::g_unix_mount_guess_icon(mount_entry) + } + pub unsafe fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char { + crate::g_unix_mount_guess_name(mount_entry) + } + pub unsafe fn g_unix_mount_entry_guess_should_display( + mount_entry: *mut GUnixMountEntry, + ) -> gboolean { + crate::g_unix_mount_guess_should_display(mount_entry) + } + pub unsafe fn g_unix_mount_entry_guess_symbolic_icon( + mount_entry: *mut GUnixMountEntry, + ) -> *mut gio_sys::GIcon { + crate::g_unix_mount_guess_symbolic_icon(mount_entry) + } + pub unsafe fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean { + crate::g_unix_mount_is_readonly(mount_entry) + } + pub unsafe fn g_unix_mount_entry_is_system_internal( + mount_entry: *mut GUnixMountEntry, + ) -> gboolean { + crate::g_unix_mount_is_system_internal(mount_entry) + } + pub unsafe fn g_unix_mount_entry_at( + mount_path: *const c_char, + time_read: *mut u64, + ) -> *mut GUnixMountEntry { + crate::g_unix_mount_at(mount_path, time_read) + } + pub unsafe fn g_unix_mount_entry_for( + file_path: *const c_char, + time_read: *mut u64, + ) -> *mut GUnixMountEntry { + crate::g_unix_mount_for(file_path, time_read) + } + + #[cfg(feature = "v2_82")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] + pub unsafe fn g_unix_mount_entries_get_from_file( + table_path: *const c_char, + time_read_out: *mut u64, + n_entries_out: *mut size_t, + ) -> *mut *mut GUnixMountEntry { + crate::g_unix_mounts_get_from_file(table_path, time_read_out, n_entries_out) + } + + pub unsafe fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib_sys::GList { + crate::g_unix_mounts_get(time_read) + } + + pub unsafe fn g_unix_mount_entries_changed_since(time: u64) -> gboolean { + crate::g_unix_mounts_changed_since(time) + } +} + +#[cfg(not(feature = "v2_84"))] +pub use g_unix_fallback::*; + +extern "C" { + + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_unix_mount_entry_copy( + mount_entry: *const crate::GUnixMountEntry, + ) -> *mut crate::GUnixMountEntry; + + pub fn g_unix_mount_point_copy( + mount_point: *const crate::GUnixMountPoint, + ) -> *mut crate::GUnixMountPoint; +} diff --git a/gio-unix/sys/tests/abi.rs b/gio-unix/sys/tests/abi.rs new file mode 100644 index 000000000000..1349df3ea840 --- /dev/null +++ b/gio-unix/sys/tests/abi.rs @@ -0,0 +1,272 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![cfg(unix)] + +use gio_unix_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gio-unix-2.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GDesktopAppInfoClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GDesktopAppInfoLookupIface", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GFileDescriptorBasedIface", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixFDMessage", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixFDMessageClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixInputStream", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixInputStreamClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixOutputStream", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixOutputStreamClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[( + "G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME", + "gio-desktop-app-info-lookup", +)]; diff --git a/gio-unix/sys/tests/constant.c b/gio-unix/sys/tests/constant.c new file mode 100644 index 000000000000..24ba40e61fa1 --- /dev/null +++ b/gio-unix/sys/tests/constant.c @@ -0,0 +1,33 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT(G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME); + return 0; +} diff --git a/gio-unix/sys/tests/layout.c b/gio-unix/sys/tests/layout.c new file mode 100644 index 000000000000..cbe496298e50 --- /dev/null +++ b/gio-unix/sys/tests/layout.c @@ -0,0 +1,20 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GDesktopAppInfoClass", sizeof(GDesktopAppInfoClass), alignof(GDesktopAppInfoClass)); + printf("%s;%zu;%zu\n", "GDesktopAppInfoLookupIface", sizeof(GDesktopAppInfoLookupIface), alignof(GDesktopAppInfoLookupIface)); + printf("%s;%zu;%zu\n", "GFileDescriptorBasedIface", sizeof(GFileDescriptorBasedIface), alignof(GFileDescriptorBasedIface)); + printf("%s;%zu;%zu\n", "GUnixFDMessage", sizeof(GUnixFDMessage), alignof(GUnixFDMessage)); + printf("%s;%zu;%zu\n", "GUnixFDMessageClass", sizeof(GUnixFDMessageClass), alignof(GUnixFDMessageClass)); + printf("%s;%zu;%zu\n", "GUnixInputStream", sizeof(GUnixInputStream), alignof(GUnixInputStream)); + printf("%s;%zu;%zu\n", "GUnixInputStreamClass", sizeof(GUnixInputStreamClass), alignof(GUnixInputStreamClass)); + printf("%s;%zu;%zu\n", "GUnixOutputStream", sizeof(GUnixOutputStream), alignof(GUnixOutputStream)); + printf("%s;%zu;%zu\n", "GUnixOutputStreamClass", sizeof(GUnixOutputStreamClass), alignof(GUnixOutputStreamClass)); + return 0; +} diff --git a/gio-unix/sys/tests/manual.h b/gio-unix/sys/tests/manual.h new file mode 100644 index 000000000000..f6df402f2e5c --- /dev/null +++ b/gio-unix/sys/tests/manual.h @@ -0,0 +1,9 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include +#include +#include +#include +#include +#include +#include diff --git a/gio-unix/sys/versions.txt b/gio-unix/sys/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/gio-unix/sys/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio-win32/Cargo.toml b/gio-win32/Cargo.toml new file mode 100644 index 000000000000..cc1fad766540 --- /dev/null +++ b/gio-win32/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "gio-win32" +documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio-win32/" +description = "Rust bindings for the GioWin32 library" +readme = "README.md" +keywords = ["gio", "gtk-rs", "gnome", "GUI"] +authors.workspace = true +edition.workspace = true +exclude.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + + +[dependencies] +ffi = { package = "gio-win32-sys", path = "./sys"} +libc.workspace = true +gio.workspace = true + +[dev-dependencies] +tempfile = "3" +gir-format-check.workspace = true + +[features] +default = [] +v2_58 = ["ffi/v2_82", "gio/v2_58"] +v2_60 = ["v2_58", "ffi/v2_60", "gio/v2_60"] +v2_66 = ["v2_60", "ffi/v2_66", "gio/v2_66"] +v2_82 = ["v2_66", "ffi/v2_82", "gio/v2_82"] +v2_84 = ["v2_82", "ffi/v2_84", "gio/v2_84"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/gio-win32/Gir.toml b/gio-win32/Gir.toml new file mode 100644 index 000000000000..cea44f8e6b8d --- /dev/null +++ b/gio-win32/Gir.toml @@ -0,0 +1,30 @@ +[options] +girs_directories = ["../gir-files"] +library = "GioWin32" +version = "2.0" +min_cfg_version = "2.56" +use_gi_docgen = true +target_path = "." +work_mode = "normal" +single_version_file = true +deprecate_by_min_version = true +trust_return_value_nullability = true + +generate = [ + "GioWin32.InputStream", + "GioWin32.OutputStream" + #"GioWin32.NetworkMonitor", +] + +ignore = [ +] + +manual = [ + "Gio.InputStream", + "Gio.OutputStream", + "Gio.SettingsBackend", +] + +[[object]] +name = "GioWin32.*" +status = "generate" diff --git a/gio-win32/src/auto/functions.rs b/gio-win32/src/auto/functions.rs new file mode 100644 index 000000000000..289f2e94259d --- /dev/null +++ b/gio-win32/src/auto/functions.rs @@ -0,0 +1,19 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#[cfg(feature = "v2_78")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] +use crate::ffi; +use glib::translate::*; + +#[cfg(feature = "v2_78")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] +#[doc(alias = "g_registry_settings_backend_new")] +pub fn registry_settings_backend_new(registry_key: Option<&str>) -> gio::SettingsBackend { + unsafe { + from_glib_full(ffi::g_registry_settings_backend_new( + registry_key.to_glib_none().0, + )) + } +} diff --git a/gio-win32/src/auto/input_stream.rs b/gio-win32/src/auto/input_stream.rs new file mode 100644 index 000000000000..db6d629de766 --- /dev/null +++ b/gio-win32/src/auto/input_stream.rs @@ -0,0 +1,87 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GWin32InputStream")] + pub struct InputStream(Object) @extends gio::InputStream; + + match fn { + type_ => || ffi::g_win32_input_stream_get_type(), + } +} + +impl InputStream { + pub const NONE: Option<&'static InputStream> = None; + + //#[doc(alias = "g_win32_input_stream_new")] + //pub fn new(handle: /*Unimplemented*/Option, close_handle: bool) -> InputStream { + // unsafe { TODO: call ffi:g_win32_input_stream_new() } + //} +} + +pub trait InputStreamExt: IsA + 'static { + #[doc(alias = "g_win32_input_stream_get_close_handle")] + #[doc(alias = "get_close_handle")] + #[doc(alias = "close-handle")] + fn closes_handle(&self) -> bool { + unsafe { + from_glib(ffi::g_win32_input_stream_get_close_handle( + self.as_ref().to_glib_none().0, + )) + } + } + + //#[doc(alias = "g_win32_input_stream_get_handle")] + //#[doc(alias = "get_handle")] + //fn handle(&self) -> /*Unimplemented*/Option { + // unsafe { TODO: call ffi:g_win32_input_stream_get_handle() } + //} + + #[doc(alias = "g_win32_input_stream_set_close_handle")] + #[doc(alias = "close-handle")] + fn set_close_handle(&self, close_handle: bool) { + unsafe { + ffi::g_win32_input_stream_set_close_handle( + self.as_ref().to_glib_none().0, + close_handle.into_glib(), + ); + } + } + + #[doc(alias = "close-handle")] + fn connect_close_handle_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_close_handle_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GWin32InputStream, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(InputStream::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::close-handle".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_close_handle_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> InputStreamExt for O {} diff --git a/gio-win32/src/auto/mod.rs b/gio-win32/src/auto/mod.rs new file mode 100644 index 000000000000..f04641004ea7 --- /dev/null +++ b/gio-win32/src/auto/mod.rs @@ -0,0 +1,16 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +mod input_stream; +pub use self::input_stream::InputStream; + +mod output_stream; +pub use self::output_stream::OutputStream; + +pub(crate) mod functions; + +pub(crate) mod traits { + pub use super::input_stream::InputStreamExt; + pub use super::output_stream::OutputStreamExt; +} diff --git a/gio-win32/src/auto/output_stream.rs b/gio-win32/src/auto/output_stream.rs new file mode 100644 index 000000000000..f01561183eec --- /dev/null +++ b/gio-win32/src/auto/output_stream.rs @@ -0,0 +1,87 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GWin32OutputStream")] + pub struct OutputStream(Object) @extends gio::OutputStream; + + match fn { + type_ => || ffi::g_win32_output_stream_get_type(), + } +} + +impl OutputStream { + pub const NONE: Option<&'static OutputStream> = None; + + //#[doc(alias = "g_win32_output_stream_new")] + //pub fn new(handle: /*Unimplemented*/Option, close_handle: bool) -> OutputStream { + // unsafe { TODO: call ffi:g_win32_output_stream_new() } + //} +} + +pub trait OutputStreamExt: IsA + 'static { + #[doc(alias = "g_win32_output_stream_get_close_handle")] + #[doc(alias = "get_close_handle")] + #[doc(alias = "close-handle")] + fn closes_handle(&self) -> bool { + unsafe { + from_glib(ffi::g_win32_output_stream_get_close_handle( + self.as_ref().to_glib_none().0, + )) + } + } + + //#[doc(alias = "g_win32_output_stream_get_handle")] + //#[doc(alias = "get_handle")] + //fn handle(&self) -> /*Unimplemented*/Option { + // unsafe { TODO: call ffi:g_win32_output_stream_get_handle() } + //} + + #[doc(alias = "g_win32_output_stream_set_close_handle")] + #[doc(alias = "close-handle")] + fn set_close_handle(&self, close_handle: bool) { + unsafe { + ffi::g_win32_output_stream_set_close_handle( + self.as_ref().to_glib_none().0, + close_handle.into_glib(), + ); + } + } + + #[doc(alias = "close-handle")] + fn connect_close_handle_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_close_handle_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GWin32OutputStream, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(OutputStream::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::close-handle".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_close_handle_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> OutputStreamExt for O {} diff --git a/gio-win32/src/auto/versions.txt b/gio-win32/src/auto/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/gio-win32/src/auto/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio-win32/src/lib.rs b/gio-win32/src/lib.rs new file mode 100644 index 000000000000..9ef6070874ac --- /dev/null +++ b/gio-win32/src/lib.rs @@ -0,0 +1,14 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +pub use ffi; + +mod auto; +pub use auto::*; + +pub mod functions { + pub use super::auto::functions::*; +} + +pub mod prelude { + pub use super::auto::traits::*; +} diff --git a/gio-win32/sys/Cargo.toml b/gio-win32/sys/Cargo.toml new file mode 100644 index 000000000000..1b2b901bd30e --- /dev/null +++ b/gio-win32/sys/Cargo.toml @@ -0,0 +1,55 @@ +[package] +name = "gio-win32-sys" +build = "build.rs" + +[package.version] +workspace = true + +[package.edition] +workspace = true + +[package.metadata.system-deps.gio_windows_2_0] +name = "gio-windows-2.0" +version = "2.56" + +[package.metadata.system-deps.gio_windows_2_0.v2_78] +version = "2.78" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true + +[lib] +name = "gio_win32_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gobject-sys] +workspace = true + +[dependencies.gio-sys] +workspace = true + +[target."cfg(windows)".dependencies.windows-sys] +version = ">=0.52, <=0.61" +features = ["Win32_Networking_WinSock"] + +[build-dependencies] +system-deps = "7" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v2_58 = [] +v2_60 = ["v2_58"] +v2_66 = ["v2_60"] +v2_82 = ["v2_66"] +v2_84 = ["v2_82"] +v2_78 = [] diff --git a/gio-win32/sys/Gir.toml b/gio-win32/sys/Gir.toml new file mode 100644 index 000000000000..2ebfb0a9b286 --- /dev/null +++ b/gio-win32/sys/Gir.toml @@ -0,0 +1,13 @@ +[options] +work_mode = "sys" +library = "GioWin32" +version = "2.0" +min_cfg_version = "2.56" +single_version_file = "." +girs_directories = ["../../gir-files"] + +external_libraries = [ + "GLib", + "GObject", + "Gio", +] diff --git a/gio-win32/sys/build.rs b/gio-win32/sys/build.rs new file mode 100644 index 000000000000..7341ed1620c9 --- /dev/null +++ b/gio-win32/sys/build.rs @@ -0,0 +1,15 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +fn main() { + if std::env::var("DOCS_RS").is_ok() { + // prevent linking libraries to avoid documentation failure + return; + } + + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + std::process::exit(1); + } +} diff --git a/gio-win32/sys/src/lib.rs b/gio-win32/sys/src/lib.rs new file mode 100644 index 000000000000..124a5fdcc387 --- /dev/null +++ b/gio-win32/sys/src/lib.rs @@ -0,0 +1,213 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use gio_sys as gio; +use glib_sys as glib; +use gobject_sys as gobject; + +mod manual; + +pub use manual::*; + +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; +#[allow(unused_imports)] +use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE}; +#[allow(unused_imports)] +use std::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32InputStreamClass { + pub parent_class: gio::GInputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GWin32InputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32InputStreamClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GWin32InputStreamPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GWin32InputStreamPrivate = _GWin32InputStreamPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32NetworkMonitor { + pub parent_instance: GNetworkMonitorBase, + pub priv_: *mut GWin32NetworkMonitorPrivate, +} + +impl ::std::fmt::Debug for GWin32NetworkMonitor { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32NetworkMonitor @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .field("priv_", &self.priv_) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32NetworkMonitorClass { + pub parent_class: GNetworkMonitorBaseClass, +} + +impl ::std::fmt::Debug for GWin32NetworkMonitorClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32NetworkMonitorClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GWin32NetworkMonitorPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GWin32NetworkMonitorPrivate = _GWin32NetworkMonitorPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32OutputStreamClass { + pub parent_class: gio::GOutputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GWin32OutputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32OutputStreamClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct _GWin32OutputStreamPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GWin32OutputStreamPrivate = _GWin32OutputStreamPrivate; + +// Classes +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32InputStream { + pub parent_instance: gio::GInputStream, + pub priv_: *mut GWin32InputStreamPrivate, +} + +impl ::std::fmt::Debug for GWin32InputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32InputStream @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GWin32OutputStream { + pub parent_instance: gio::GOutputStream, + pub priv_: *mut GWin32OutputStreamPrivate, +} + +impl ::std::fmt::Debug for GWin32OutputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32OutputStream @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +extern "C" { + + //========================================================================= + // GWin32InputStream + //========================================================================= + pub fn g_win32_input_stream_get_type() -> GType; + pub fn g_win32_input_stream_new( + handle: *mut c_void, + close_handle: gboolean, + ) -> *mut gio::GInputStream; + pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; + pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; + pub fn g_win32_input_stream_set_close_handle( + stream: *mut GWin32InputStream, + close_handle: gboolean, + ); + + //========================================================================= + // GWin32OutputStream + //========================================================================= + pub fn g_win32_output_stream_get_type() -> GType; + pub fn g_win32_output_stream_new( + handle: *mut c_void, + close_handle: gboolean, + ) -> *mut gio::GOutputStream; + pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; + pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; + pub fn g_win32_output_stream_set_close_handle( + stream: *mut GWin32OutputStream, + close_handle: gboolean, + ); + + //========================================================================= + // Other functions + //========================================================================= + #[cfg(feature = "v2_78")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] + pub fn g_registry_settings_backend_new( + registry_key: *const c_char, + ) -> *mut gio::GSettingsBackend; + +} diff --git a/gio-win32/sys/src/manual.rs b/gio-win32/sys/src/manual.rs new file mode 100644 index 000000000000..902551ba74e4 --- /dev/null +++ b/gio-win32/sys/src/manual.rs @@ -0,0 +1,135 @@ +use libc::c_void; + +pub type GSocketFamily = libc::c_int; +pub type GSocketMsgFlags = libc::c_int; + +use gio_sys::{GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass}; +use glib_sys::{gboolean, GType}; + +pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; +pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = + windows_sys::Win32::Networking::WinSock::MSG_OOB; +pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = + windows_sys::Win32::Networking::WinSock::MSG_PEEK; +pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = + windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE; + +extern "C" { + //========================================================================= + // GWin32InputStream + //========================================================================= + pub fn g_win32_input_stream_get_type() -> GType; + pub fn g_win32_input_stream_new( + handle: *mut c_void, + close_handle: gboolean, + ) -> *mut GInputStream; + pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; + pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; + pub fn g_win32_input_stream_set_close_handle( + stream: *mut GWin32InputStream, + close_handle: gboolean, + ); + + //========================================================================= + // GWin32OutputStream + //========================================================================= + pub fn g_win32_output_stream_get_type() -> GType; + pub fn g_win32_output_stream_new( + handle: *mut c_void, + close_handle: gboolean, + ) -> *mut GOutputStream; + pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; + pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; + pub fn g_win32_output_stream_set_close_handle( + stream: *mut GWin32OutputStream, + close_handle: gboolean, + ); +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GWin32InputStreamClass { + pub parent_class: GInputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GWin32InputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32InputStreamClass @ {:?}", self as *const _)) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +pub struct _GWin32InputStreamPrivate(c_void); + +pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GWin32InputStream { + pub parent_instance: GInputStream, + pub priv_: *mut GWin32InputStreamPrivate, +} + +impl ::std::fmt::Debug for GWin32InputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32InputStream @ {:?}", self as *const _)) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GWin32OutputStreamClass { + pub parent_class: GOutputStreamClass, + pub _g_reserved1: Option, + pub _g_reserved2: Option, + pub _g_reserved3: Option, + pub _g_reserved4: Option, + pub _g_reserved5: Option, +} + +impl ::std::fmt::Debug for GWin32OutputStreamClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}", self as *const _)) + .field("parent_class", &self.parent_class) + .field("_g_reserved1", &self._g_reserved1) + .field("_g_reserved2", &self._g_reserved2) + .field("_g_reserved3", &self._g_reserved3) + .field("_g_reserved4", &self._g_reserved4) + .field("_g_reserved5", &self._g_reserved5) + .finish() + } +} + +#[repr(C)] +pub struct _GWin32OutputStreamPrivate(c_void); + +pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GWin32OutputStream { + pub parent_instance: GOutputStream, + pub priv_: *mut GWin32OutputStreamPrivate, +} + +impl ::std::fmt::Debug for GWin32OutputStream { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GWin32OutputStream @ {:?}", self as *const _)) + .field("parent_instance", &self.parent_instance) + .finish() + } +} diff --git a/gio-win32/sys/tests/abi.rs b/gio-win32/sys/tests/abi.rs new file mode 100644 index 000000000000..71bd19712d39 --- /dev/null +++ b/gio-win32/sys/tests/abi.rs @@ -0,0 +1,248 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![cfg(unix)] + +use gio_win32_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gio-windows-2.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GWin32InputStream", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GWin32InputStreamClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GWin32NetworkMonitor", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GWin32NetworkMonitorClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GWin32OutputStream", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GWin32OutputStreamClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[]; diff --git a/gio-win32/sys/tests/constant.c b/gio-win32/sys/tests/constant.c new file mode 100644 index 000000000000..4c64076e59ce --- /dev/null +++ b/gio-win32/sys/tests/constant.c @@ -0,0 +1,32 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + return 0; +} diff --git a/gio-win32/sys/tests/layout.c b/gio-win32/sys/tests/layout.c new file mode 100644 index 000000000000..72018c38391b --- /dev/null +++ b/gio-win32/sys/tests/layout.c @@ -0,0 +1,17 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GWin32InputStream", sizeof(GWin32InputStream), alignof(GWin32InputStream)); + printf("%s;%zu;%zu\n", "GWin32InputStreamClass", sizeof(GWin32InputStreamClass), alignof(GWin32InputStreamClass)); + printf("%s;%zu;%zu\n", "GWin32NetworkMonitor", sizeof(GWin32NetworkMonitor), alignof(GWin32NetworkMonitor)); + printf("%s;%zu;%zu\n", "GWin32NetworkMonitorClass", sizeof(GWin32NetworkMonitorClass), alignof(GWin32NetworkMonitorClass)); + printf("%s;%zu;%zu\n", "GWin32OutputStream", sizeof(GWin32OutputStream), alignof(GWin32OutputStream)); + printf("%s;%zu;%zu\n", "GWin32OutputStreamClass", sizeof(GWin32OutputStreamClass), alignof(GWin32OutputStreamClass)); + return 0; +} diff --git a/gio-win32/sys/tests/manual.h b/gio-win32/sys/tests/manual.h new file mode 100644 index 000000000000..f6df402f2e5c --- /dev/null +++ b/gio-win32/sys/tests/manual.h @@ -0,0 +1,9 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include +#include +#include +#include +#include +#include +#include diff --git a/gio-win32/sys/versions.txt b/gio-win32/sys/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/gio-win32/sys/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/gio/Gir.toml b/gio/Gir.toml index dfa27fdf57e1..c8394312bdd9 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -770,24 +770,6 @@ manual_traits = ["DebugControllerDBusExtManual"] manual = true doc_trait_name = "DebugControllerDBusExtManual" -[[object]] -name = "Gio.DesktopAppInfo" -status = "generate" -manual_traits = ["DesktopAppInfoExtManual"] -cfg_condition = "all(not(windows),not(target_os = \"macos\"))" - [[object.function]] - name = "get_boolean" - # Retrieves the boolean value of a key - rename = "boolean" - [[object.function]] - name = "search" - # returns vec of string - manual = true - [[object.function]] - name = "launch_uris_as_manager_with_fds" - # has to use RawFd / SOCKET - manual = true - [[object]] name = "Gio.DtlsConnection" status = "generate" diff --git a/gio/src/lib.rs b/gio/src/lib.rs index 83eeb45f3f4a..3bd29f513c3f 100644 --- a/gio/src/lib.rs +++ b/gio/src/lib.rs @@ -42,8 +42,6 @@ mod dbus_node_info; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] mod debug_controller_dbus; -#[cfg(all(not(windows), not(target_os = "macos")))] -mod desktop_app_info; mod error; mod file; mod file_attribute_info; @@ -53,10 +51,6 @@ mod file_attribute_matcher; pub use crate::file_attribute_matcher::FileAttributematcherIter; mod file_attribute_value; pub use file_attribute_value::FileAttributeValue; -#[cfg(unix)] -mod file_descriptor_based; -#[cfg(unix)] -pub use file_descriptor_based::FileDescriptorBased; mod file_enumerator; pub use crate::file_enumerator::FileEnumeratorStream; mod file_info; @@ -88,28 +82,12 @@ pub use crate::settings::BindingBuilder; mod simple_proxy_resolver; mod socket; pub use socket::{InputMessage, InputVector, OutputMessage, OutputVector, SocketControlMessages}; +mod dbus_object_manager_client; mod socket_control_message; mod socket_listener; -mod socket_msg_flags; -pub use socket_msg_flags::SocketMsgFlags; -mod dbus_object_manager_client; mod subprocess; mod subprocess_launcher; mod threaded_socket_service; -#[cfg(unix)] -mod unix_fd_list; -#[cfg(unix)] -mod unix_fd_message; -#[cfg(unix)] -mod unix_input_stream; -#[cfg(unix)] -mod unix_mount_entry; -#[cfg(unix)] -mod unix_mount_point; -#[cfg(unix)] -mod unix_output_stream; -#[cfg(unix)] -mod unix_socket_address; #[cfg(test)] mod test_util; diff --git a/gio/src/prelude.rs b/gio/src/prelude.rs index edbe9ef35a7b..2f57968a45c1 100644 --- a/gio/src/prelude.rs +++ b/gio/src/prelude.rs @@ -11,22 +11,6 @@ pub use crate::app_info::AppInfoExtManual; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use crate::debug_controller_dbus::DebugControllerDBusExtManual; -#[cfg(feature = "v2_58")] -#[cfg(all(not(windows), not(target_os = "macos")))] -#[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] -pub use crate::desktop_app_info::DesktopAppInfoExtManual; -#[cfg(unix)] -pub use crate::file_descriptor_based::FileDescriptorBasedExtManual; -#[cfg(unix)] -pub use crate::unix_fd_list::UnixFDListExtManual; -#[cfg(unix)] -pub use crate::unix_fd_message::UnixFDMessageExtManual; -#[cfg(unix)] -pub use crate::unix_input_stream::UnixInputStreamExtManual; -#[cfg(unix)] -pub use crate::unix_output_stream::UnixOutputStreamExtManual; -#[cfg(unix)] -pub use crate::unix_socket_address::{UnixSocketAddressExtManual, UnixSocketAddressPath}; #[cfg(windows)] pub use crate::win32_input_stream::Win32InputStreamExt; #[cfg(windows)] diff --git a/gio/src/unix_fd_list.rs b/gio/src/unix_fd_list.rs deleted file mode 100644 index 06dd8cdc0a5e..000000000000 --- a/gio/src/unix_fd_list.rs +++ /dev/null @@ -1,84 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -#[cfg(unix)] -use std::os::unix::io::{AsFd, AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use std::{mem, ptr}; - -use glib::{prelude::*, translate::*}; -#[cfg(all(not(unix), docsrs))] -use socket::{AsFd, AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; - -use crate::{ffi, UnixFDList}; - -impl UnixFDList { - #[doc(alias = "g_unix_fd_list_new_from_array")] - pub fn from_array(fds: impl IntoIterator) -> UnixFDList { - let fds = fds.into_iter().map(|t| t.into_raw_fd()).collect::>(); - unsafe { - from_glib_full(ffi::g_unix_fd_list_new_from_array( - fds.to_glib_none().0, - fds.len() as i32, - )) - } - } -} - -pub trait UnixFDListExtManual: IsA + Sized { - #[doc(alias = "g_unix_fd_list_append")] - fn append(&self, fd: impl AsFd) -> Result { - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::g_unix_fd_list_append( - self.as_ref().to_glib_none().0, - fd.as_fd().as_raw_fd(), - &mut error, - ); - if error.is_null() { - Ok(ret) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "g_unix_fd_list_get")] - fn get(&self, index_: i32) -> Result { - unsafe { - let mut error = ptr::null_mut(); - let raw_fd = - ffi::g_unix_fd_list_get(self.as_ref().to_glib_none().0, index_, &mut error); - if error.is_null() { - let fd = OwnedFd::from_raw_fd(raw_fd); - Ok(fd) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "g_unix_fd_list_peek_fds")] - fn peek_fds(&self) -> Vec { - unsafe { - let mut length = mem::MaybeUninit::uninit(); - let ret = FromGlibContainer::from_glib_none_num( - ffi::g_unix_fd_list_peek_fds(self.as_ref().to_glib_none().0, length.as_mut_ptr()), - length.assume_init() as usize, - ); - ret - } - } - - #[doc(alias = "g_unix_fd_list_steal_fds")] - fn steal_fds(&self) -> Vec { - unsafe { - let mut length = mem::MaybeUninit::uninit(); - let ret = FromGlibContainer::from_glib_full_num( - ffi::g_unix_fd_list_steal_fds(self.as_ref().to_glib_none().0, length.as_mut_ptr()), - length.assume_init() as usize, - ); - ret - } - } -} - -impl> UnixFDListExtManual for O {} diff --git a/gio/src/unix_socket_address.rs b/gio/src/unix_socket_address.rs deleted file mode 100644 index 4ad618887dc2..000000000000 --- a/gio/src/unix_socket_address.rs +++ /dev/null @@ -1,116 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -#[cfg(not(docsrs))] -use std::ffi::OsStr; -#[cfg(unix)] -#[cfg(not(docsrs))] -use std::os::unix::ffi::OsStrExt; -use std::{path, ptr, slice}; - -use glib::translate::*; - -use crate::{ffi, prelude::*, SocketAddress, UnixSocketAddress, UnixSocketAddressType}; - -#[derive(Debug)] -pub enum UnixSocketAddressPath<'a> { - Path(&'a path::Path), - Anonymous, - Abstract(&'a [u8]), - AbstractPadded(&'a [u8]), -} - -impl UnixSocketAddressPath<'_> { - fn to_type(&self) -> UnixSocketAddressType { - use self::UnixSocketAddressPath::*; - - match *self { - Path(_) => UnixSocketAddressType::Path, - Anonymous => UnixSocketAddressType::Anonymous, - Abstract(_) => UnixSocketAddressType::Abstract, - AbstractPadded(_) => UnixSocketAddressType::AbstractPadded, - } - } -} - -impl UnixSocketAddress { - #[doc(alias = "g_unix_socket_address_new")] - pub fn new(path: &path::Path) -> UnixSocketAddress { - unsafe { - SocketAddress::from_glib_full(ffi::g_unix_socket_address_new(path.to_glib_none().0)) - .unsafe_cast() - } - } - - #[doc(alias = "g_unix_socket_address_new_with_type")] - pub fn with_type(address_type: UnixSocketAddressPath) -> Self { - use self::UnixSocketAddressPath::*; - - let type_ = address_type.to_type(); - let new = |ptr, len| unsafe { - SocketAddress::from_glib_full(ffi::g_unix_socket_address_new_with_type( - ptr, - len, - type_.into_glib(), - )) - .unsafe_cast() - }; - match address_type { - Path(path) => new(path.to_glib_none().0, -1), - Abstract(path) | AbstractPadded(path) => new( - path.to_glib_none().0 as *mut libc::c_char, - path.len() as i32, - ), - Anonymous => new(ptr::null_mut(), 0), - } - } -} - -pub trait UnixSocketAddressExtManual: IsA + 'static { - #[doc(alias = "g_unix_socket_address_get_path")] - #[doc(alias = "get_path")] - fn path(&self) -> Option> { - use self::UnixSocketAddressPath::*; - - let path = unsafe { - let path = ffi::g_unix_socket_address_get_path(self.as_ref().to_glib_none().0); - if path.is_null() || self.path_len() == 0 { - &[] - } else { - slice::from_raw_parts(path as *const u8, self.path_len()) - } - }; - match self.address_type() { - UnixSocketAddressType::Anonymous => Some(Anonymous), - #[cfg(not(docsrs))] - UnixSocketAddressType::Path => Some(Path(path::Path::new(OsStr::from_bytes(path)))), - #[cfg(docsrs)] - UnixSocketAddressType::Path => unreachable!(), - UnixSocketAddressType::Abstract => Some(Abstract(path)), - UnixSocketAddressType::AbstractPadded => Some(AbstractPadded(path)), - UnixSocketAddressType::Invalid | UnixSocketAddressType::__Unknown(_) => None, - } - } -} - -impl> UnixSocketAddressExtManual for O {} - -#[cfg(test)] -mod test { - use super::*; - - // Check the actual path and len are correct and are not the underlying OsString - #[test] - fn check_path() { - let mut os_string = std::ffi::OsString::with_capacity(100); - os_string.push("/tmp/foo"); - let path = os_string.as_ref(); - - let addr = UnixSocketAddress::new(path); - assert_eq!(addr.path_len(), 8); - assert_eq!(addr.path_as_array().unwrap().as_ref(), b"/tmp/foo"); - - let addr = UnixSocketAddress::with_type(UnixSocketAddressPath::Path(path)); - assert_eq!(addr.path_len(), 8); - assert_eq!(addr.path_as_array().unwrap().as_ref(), b"/tmp/foo"); - } -} diff --git a/gio/sys/Gir.toml b/gio/sys/Gir.toml index 480b357c1b9b..a616a4b95696 100644 --- a/gio/sys/Gir.toml +++ b/gio/sys/Gir.toml @@ -18,9 +18,6 @@ ignore = [ [[object]] name = "Gio.*" status = "generate" - [[object.function]] - name = "unix_mount_entries_changed_since" - version = "2.84" [[object]] name = "Gio.Credentials" diff --git a/gio/sys/src/manual.rs b/gio/sys/src/manual.rs index b679a6ee2c5d..96ed61cb01a8 100644 --- a/gio/sys/src/manual.rs +++ b/gio/sys/src/manual.rs @@ -1,10 +1,5 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(not(target_family = "windows"))] -pub use self::libc_constants::*; -#[cfg(target_family = "windows")] -pub use self::windows_constants::*; - pub type GSocketFamily = libc::c_int; pub type GSocketMsgFlags = libc::c_int; @@ -27,6 +22,8 @@ mod windows_constants { pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE; } +#[cfg(target_family = "windows")] +pub use windows_constants::*; #[cfg(not(target_family = "windows"))] mod libc_constants { @@ -40,250 +37,5 @@ mod libc_constants { pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK; pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE; } - -#[cfg(target_family = "windows")] -pub use self::windows_streams::*; - -#[cfg(target_family = "windows")] -mod windows_streams { - use libc::c_void; - - use crate::{ - gboolean, GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass, GType, - }; - - extern "C" { - //========================================================================= - // GWin32InputStream - //========================================================================= - pub fn g_win32_input_stream_get_type() -> GType; - pub fn g_win32_input_stream_new( - handle: *mut c_void, - close_handle: gboolean, - ) -> *mut GInputStream; - pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; - pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; - pub fn g_win32_input_stream_set_close_handle( - stream: *mut GWin32InputStream, - close_handle: gboolean, - ); - - //========================================================================= - // GWin32OutputStream - //========================================================================= - pub fn g_win32_output_stream_get_type() -> GType; - pub fn g_win32_output_stream_new( - handle: *mut c_void, - close_handle: gboolean, - ) -> *mut GOutputStream; - pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; - pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; - pub fn g_win32_output_stream_set_close_handle( - stream: *mut GWin32OutputStream, - close_handle: gboolean, - ); - } - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct GWin32InputStreamClass { - pub parent_class: GInputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, - } - - impl ::std::fmt::Debug for GWin32InputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32InputStreamClass @ {:?}", self as *const _)) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } - } - - #[repr(C)] - pub struct _GWin32InputStreamPrivate(c_void); - - pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct GWin32InputStream { - pub parent_instance: GInputStream, - pub priv_: *mut GWin32InputStreamPrivate, - } - - impl ::std::fmt::Debug for GWin32InputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32InputStream @ {:?}", self as *const _)) - .field("parent_instance", &self.parent_instance) - .finish() - } - } - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct GWin32OutputStreamClass { - pub parent_class: GOutputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, - } - - impl ::std::fmt::Debug for GWin32OutputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}", self as *const _)) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } - } - - #[repr(C)] - pub struct _GWin32OutputStreamPrivate(c_void); - - pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct GWin32OutputStream { - pub parent_instance: GOutputStream, - pub priv_: *mut GWin32OutputStreamPrivate, - } - - impl ::std::fmt::Debug for GWin32OutputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32OutputStream @ {:?}", self as *const _)) - .field("parent_instance", &self.parent_instance) - .finish() - } - } -} - -#[cfg(not(feature = "v2_84"))] -#[cfg(target_family = "unix")] -mod unix_mount_compat { - #![allow(clippy::missing_safety_doc)] - - use crate::*; - - pub unsafe fn g_unix_mount_entry_compare( - mount1: *mut GUnixMountEntry, - mount2: *mut GUnixMountEntry, - ) -> c_int { - g_unix_mount_compare(mount1, mount2) - } - pub unsafe fn g_unix_mount_entry_copy( - mount_entry: *mut GUnixMountEntry, - ) -> *mut GUnixMountEntry { - g_unix_mount_copy(mount_entry) - } - pub unsafe fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry) { - g_unix_mount_free(mount_entry); - } - pub unsafe fn g_unix_mount_entry_get_device_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - g_unix_mount_get_device_path(mount_entry) - } - pub unsafe fn g_unix_mount_entry_get_fs_type( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - g_unix_mount_get_fs_type(mount_entry) - } - pub unsafe fn g_unix_mount_entry_get_mount_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - g_unix_mount_get_mount_path(mount_entry) - } - #[cfg(feature = "v2_58")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] - pub unsafe fn g_unix_mount_entry_get_options( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - g_unix_mount_get_options(mount_entry) - } - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - pub unsafe fn g_unix_mount_entry_get_root_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - g_unix_mount_get_root_path(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_can_eject( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - g_unix_mount_guess_can_eject(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon { - g_unix_mount_guess_icon(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char { - g_unix_mount_guess_name(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_should_display( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - g_unix_mount_guess_should_display(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_symbolic_icon( - mount_entry: *mut GUnixMountEntry, - ) -> *mut GIcon { - g_unix_mount_guess_symbolic_icon(mount_entry) - } - pub unsafe fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean { - g_unix_mount_is_readonly(mount_entry) - } - pub unsafe fn g_unix_mount_entry_is_system_internal( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - g_unix_mount_is_system_internal(mount_entry) - } - pub unsafe fn g_unix_mount_entry_at( - mount_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry { - g_unix_mount_at(mount_path, time_read) - } - pub unsafe fn g_unix_mount_entry_for( - file_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry { - g_unix_mount_for(file_path, time_read) - } - - #[cfg(feature = "v2_82")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] - pub unsafe fn g_unix_mount_entries_get_from_file( - table_path: *const c_char, - time_read_out: *mut u64, - n_entries_out: *mut size_t, - ) -> *mut *mut GUnixMountEntry { - g_unix_mounts_get_from_file(table_path, time_read_out, n_entries_out) - } - - pub unsafe fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib::GList { - g_unix_mounts_get(time_read) - } - - pub unsafe fn g_unix_mount_entries_changed_since(time: u64) -> gboolean { - g_unix_mounts_changed_since(time) - } -} - -#[cfg(not(feature = "v2_84"))] -#[cfg(target_family = "unix")] -pub use unix_mount_compat::*; +#[cfg(not(target_family = "windows"))] +pub use libc_constants::*; diff --git a/glib-unix/Cargo.toml b/glib-unix/Cargo.toml new file mode 100644 index 000000000000..7c216bf3af70 --- /dev/null +++ b/glib-unix/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "glib-unix" +documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib-unix/" +description = "Rust bindings for the GLibUnix library" +readme = "README.md" +keywords = ["glib", "gtk-rs", "gnome", "GUI"] +authors.workspace = true +edition.workspace = true +exclude.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +ffi = { package = "glib-unix-sys", path = "./sys"} +libc.workspace = true +glib.workspace = true +futures-core = { version = "0.3", default-features = false } + +[dev-dependencies] +tempfile = "3" +gir-format-check.workspace = true + +[features] +default = [] +v2_80 = ["ffi/v2_80", "glib/v2_80"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/glib-unix/Gir.toml b/glib-unix/Gir.toml new file mode 100644 index 000000000000..5ed04f976c9f --- /dev/null +++ b/glib-unix/Gir.toml @@ -0,0 +1,51 @@ +[options] +girs_directories = ["../gir-files"] +library = "GLibUnix" +version = "2.0" +min_cfg_version = "2.56" +use_gi_docgen = true +target_path = "." +work_mode = "normal" +single_version_file = true +deprecate_by_min_version = true +trust_return_value_nullability = true + +generate = [ + #"GLibUnix.Pipe", + #"GLibUnix.PipeEnd" +] + +ignore = [ +] + +manual = [ + "GLib.Error", + "GLib.IOCondition", + "GLib.Quark", + "GLib.Source", +] + +[[object]] +name = "GLibUnix.*" +status = "generate" + [[object.function]] + name = "signal_add" + ignore = true + [[object.function]] + name = "signal_add_full" + ignore = true + [[object.function]] + name = "set_fd_nonblocking" + # Need manual binding for RawFd + ignore = true + [[object.function]] + pattern = "fd.*" + # Need manual binding for RawFd + ignore = true + [[object.function]] + name = "signal_source_new" + # Need manual bindings to be useful + ignore = true + [[object.function]] + name = "open_pipe" + manual = true diff --git a/glib-unix/src/auto/functions.rs b/glib-unix/src/auto/functions.rs new file mode 100644 index 000000000000..add83aef86b8 --- /dev/null +++ b/glib-unix/src/auto/functions.rs @@ -0,0 +1,22 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::translate::*; + +#[doc(alias = "g_closefrom")] +pub fn closefrom(lowfd: i32) -> i32 { + unsafe { ffi::g_closefrom(lowfd) } +} + +#[doc(alias = "g_unix_error_quark")] +pub fn error_quark() -> glib::Quark { + unsafe { from_glib(ffi::g_unix_error_quark()) } +} + +//#[doc(alias = "g_unix_get_passwd_entry")] +//#[doc(alias = "get_passwd_entry")] +//pub fn passwd_entry(user_name: &str) -> Result, glib::Error> { +// unsafe { TODO: call ffi:g_unix_get_passwd_entry() } +//} diff --git a/glib-unix/src/auto/mod.rs b/glib-unix/src/auto/mod.rs new file mode 100644 index 000000000000..fb248fa00210 --- /dev/null +++ b/glib-unix/src/auto/mod.rs @@ -0,0 +1,5 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +pub(crate) mod functions; diff --git a/glib-unix/src/auto/versions.txt b/glib-unix/src/auto/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/glib-unix/src/auto/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib-unix/src/functions.rs b/glib-unix/src/functions.rs new file mode 100644 index 000000000000..ea5b93f89f04 --- /dev/null +++ b/glib-unix/src/functions.rs @@ -0,0 +1,503 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use std::cell::RefCell; +use std::future::Future; +use std::mem::transmute; +use std::os::fd::{FromRawFd, RawFd}; +use std::pin::Pin; + +use glib::ffi::gpointer; +use glib::thread_guard::ThreadGuard; +use glib::translate::*; +use glib::{ControlFlow, IOCondition, Priority, Source, SourceFuture, SourceId, SourceStream}; + +use futures_core::stream::Stream; + +fn into_raw ControlFlow + Send + 'static>(func: F) -> gpointer { + let func: Box> = Box::new(RefCell::new(func)); + Box::into_raw(func) as gpointer +} + +fn into_raw_local ControlFlow + 'static>(func: F) -> gpointer { + let func: Box>> = Box::new(ThreadGuard::new(RefCell::new(func))); + Box::into_raw(func) as gpointer +} + +unsafe extern "C" fn trampoline ControlFlow + Send + 'static>( + func: gpointer, +) -> glib::ffi::gboolean { + let func: &RefCell = &*(func as *const RefCell); + (*func.borrow_mut())().into_glib() +} + +unsafe extern "C" fn trampoline_local ControlFlow + 'static>( + func: gpointer, +) -> glib::ffi::gboolean { + let func: &ThreadGuard> = &*(func as *const ThreadGuard>); + (*func.get_ref().borrow_mut())().into_glib() +} + +unsafe extern "C" fn destroy_closure ControlFlow + Send + 'static>(ptr: gpointer) { + let _ = Box::>::from_raw(ptr as *mut _); +} + +unsafe extern "C" fn destroy_closure_local ControlFlow + 'static>(ptr: gpointer) { + let _ = Box::>>::from_raw(ptr as *mut _); +} + +unsafe extern "C" fn trampoline_unix_fd< + F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, +>( + fd: i32, + condition: glib::ffi::GIOCondition, + func: gpointer, +) -> glib::ffi::gboolean { + let func: &RefCell = &*(func as *const RefCell); + (*func.borrow_mut())(fd, from_glib(condition)).into_glib() +} + +unsafe extern "C" fn trampoline_unix_fd_local< + F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, +>( + fd: i32, + condition: glib::ffi::GIOCondition, + func: gpointer, +) -> glib::ffi::gboolean { + let func: &ThreadGuard> = &*(func as *const ThreadGuard>); + (*func.get_ref().borrow_mut())(fd, from_glib(condition)).into_glib() +} + +unsafe extern "C" fn destroy_closure_unix_fd< + F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, +>( + ptr: gpointer, +) { + let _ = Box::>::from_raw(ptr as *mut _); +} + +unsafe extern "C" fn destroy_closure_unix_fd_local< + F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, +>( + ptr: gpointer, +) { + let _ = Box::>>::from_raw(ptr as *mut _); +} + +fn into_raw_unix_fd ControlFlow + Send + 'static>( + func: F, +) -> gpointer { + let func: Box> = Box::new(RefCell::new(func)); + Box::into_raw(func) as gpointer +} + +fn into_raw_unix_fd_local ControlFlow + 'static>( + func: F, +) -> gpointer { + let func: Box>> = Box::new(ThreadGuard::new(RefCell::new(func))); + Box::into_raw(func) as gpointer +} + +#[inline(always)] +fn fnmut_callback_wrapper( + func: impl FnOnce() + Send + 'static, +) -> impl FnMut() -> ControlFlow + Send + 'static { + let mut func = Some(func); + move || { + let func = func + .take() + .expect("GSource closure called after returning ControlFlow::Break"); + func(); + ControlFlow::Break + } +} + +#[inline(always)] +fn fnmut_callback_wrapper_local( + func: impl FnOnce() + 'static, +) -> impl FnMut() -> ControlFlow + 'static { + let mut func = Some(func); + move || { + let func = func + .take() + .expect("GSource closure called after returning glib::ControlFlow::Break"); + func(); + ControlFlow::Break + } +} + +#[doc(alias = "g_unix_open_pipe")] +pub fn unix_open_pipe(flags: i32) -> Result<(RawFd, RawFd), glib::Error> { + unsafe { + let mut fds = [0, 2]; + let mut error = std::ptr::null_mut(); + let _ = ffi::g_unix_open_pipe(&mut fds, flags, &mut error); + if error.is_null() { + Ok(( + FromRawFd::from_raw_fd(fds[0]), + FromRawFd::from_raw_fd(fds[1]), + )) + } else { + Err(from_glib_full(error)) + } + } +} + +// rustdoc-stripper-ignore-next +/// Create a `Stream` that will provide a value whenever the given UNIX signal is raised +/// +/// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. +pub fn signal_stream(signum: i32) -> Pin + Send + 'static>> { + signal_stream_with_priority(Priority::default(), signum) +} + +// rustdoc-stripper-ignore-next +/// Create a `Stream` that will provide a value whenever the given UNIX signal is raised +/// +/// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. +pub fn signal_stream_with_priority( + priority: Priority, + signum: i32, +) -> Pin + Send + 'static>> { + Box::pin(SourceStream::new(move |send| { + signal_source_new(signum, None, priority, move || { + if send.unbounded_send(()).is_err() { + ControlFlow::Break + } else { + ControlFlow::Continue + } + }) + })) +} + +// rustdoc-stripper-ignore-next +/// Create a `Future` that will resolve once the given UNIX signal is raised +/// +/// The `Future` must be spawned on an `Executor` backed by a `glib::MainContext`. +pub fn signal_future_with_priority( + priority: Priority, + signum: i32, +) -> Pin + Send + 'static>> { + Box::pin(SourceFuture::new(move |send| { + let mut send = Some(send); + signal_source_new(signum, None, priority, move || { + let _ = send.take().unwrap().send(()); + ControlFlow::Break + }) + })) +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX signal is raised. +/// +/// `func` will be called repeatedly every time `signum` is raised until it +/// returns `ControlFlow::Break`. +#[doc(alias = "g_unix_signal_source_new")] +pub fn signal_source_new( + signum: i32, + name: Option<&str>, + priority: Priority, + func: F, +) -> glib::Source +where + F: FnMut() -> glib::ControlFlow + Send + 'static, +{ + unsafe { + let source = ffi::g_unix_signal_source_new(signum); + glib::ffi::g_source_set_callback( + source, + Some(trampoline::), + into_raw(func), + Some(destroy_closure::), + ); + glib::ffi::g_source_set_priority(source, priority.into_glib()); + + if let Some(name) = name { + glib::ffi::g_source_set_name(source, name.to_glib_none().0); + } + + from_glib_full(source) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX file descriptor reaches the given IO condition. +/// +/// `func` will be called repeatedly while the file descriptor matches the given IO condition +/// until it returns `ControlFlow::Break`. +#[doc(alias = "g_unix_fd_source_new")] +pub fn fd_source_new( + fd: RawFd, + condition: IOCondition, + name: Option<&str>, + priority: Priority, + func: F, +) -> Source +where + F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, +{ + unsafe { + let source = ffi::g_unix_fd_source_new(fd, condition.into_glib()); + glib::ffi::g_source_set_callback( + source, + Some(transmute::< + *const (), + unsafe extern "C" fn(glib::ffi::gpointer) -> glib::ffi::gboolean, + >(trampoline_unix_fd:: as *const ())), + into_raw_unix_fd(func), + Some(destroy_closure_unix_fd::), + ); + glib::ffi::g_source_set_priority(source, priority.into_glib()); + + if let Some(name) = name { + glib::ffi::g_source_set_name(source, name.to_glib_none().0); + } + + from_glib_full(source) + } +} + +// rustdoc-stripper-ignore-next +/// Create a `Future` that will resolve once the given UNIX signal is raised +/// +/// The `Future` must be spawned on an `Executor` backed by a `glib::MainContext`. +pub fn signal_future(signum: i32) -> Pin + Send + 'static>> { + signal_future_with_priority(Priority::default(), signum) +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. +/// +/// `func` will be called repeatedly every time `signum` is raised until it +/// returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +#[doc(alias = "g_unix_signal_add_full")] +pub fn unix_signal_add(signum: i32, func: F) -> SourceId +where + F: FnMut() -> ControlFlow + Send + 'static, +{ + unsafe { + from_glib(ffi::g_unix_signal_add_full( + Priority::default().into_glib(), + signum, + Some(trampoline::), + into_raw(func), + Some(destroy_closure::), + )) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. +/// +/// `func` will be called repeatedly every time `signum` is raised until it +/// returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +/// +/// In comparison to `unix_signal_add()`, this only requires `func` to be +/// `FnOnce`, and will automatically return `ControlFlow::Break`. +#[doc(alias = "g_unix_signal_add_full")] +pub fn unix_signal_add_once(signum: i32, func: F) -> SourceId +where + F: FnOnce() + Send + 'static, +{ + unix_signal_add(signum, fnmut_callback_wrapper(func)) +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. +/// +/// `func` will be called repeatedly every time `signum` is raised until it +/// returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +/// +/// Different to `unix_signal_add()`, this does not require `func` to be +/// `Send` but can only be called from the thread that owns the main context. +/// +/// This function panics if called from a different thread than the one that +/// owns the main context. +#[doc(alias = "g_unix_signal_add_full")] +pub fn unix_signal_add_local(signum: i32, func: F) -> SourceId +where + F: FnMut() -> ControlFlow + 'static, +{ + unsafe { + let context = glib::MainContext::default(); + let _acquire = context + .acquire() + .expect("default main context already acquired by another thread"); + from_glib(ffi::g_unix_signal_add_full( + Priority::default().into_glib(), + signum, + Some(trampoline_local::), + into_raw_local(func), + Some(destroy_closure_local::), + )) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. +/// +/// `func` will be called repeatedly every time `signum` is raised until it +/// returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +/// +/// Different to `unix_signal_add()`, this does not require `func` to be +/// `Send` but can only be called from the thread that owns the main context. +/// +/// This function panics if called from a different thread than the one that +/// owns the main context. +/// +/// In comparison to `unix_signal_add_local()`, this only requires `func` to be +/// `FnOnce`, and will automatically return `ControlFlow::Break`. +#[doc(alias = "g_unix_signal_add_full")] +pub fn unix_signal_add_local_once(signum: i32, func: F) -> SourceId +where + F: FnOnce() + 'static, +{ + unix_signal_add_local(signum, fnmut_callback_wrapper_local(func)) +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX file descriptor reaches the given IO condition. +/// +/// `func` will be called repeatedly while the file descriptor matches the given IO condition +/// until it returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +#[doc(alias = "g_unix_fd_add_full")] +pub fn unix_fd_add(fd: RawFd, condition: IOCondition, func: F) -> SourceId +where + F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, +{ + unsafe { + from_glib(ffi::g_unix_fd_add_full( + Priority::default().into_glib(), + fd, + condition.into_glib(), + Some(trampoline_unix_fd::), + into_raw_unix_fd(func), + Some(destroy_closure_unix_fd::), + )) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX file descriptor reaches the given IO condition. +/// +/// `func` will be called repeatedly with `priority` while the file descriptor matches the given IO condition +/// until it returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +#[doc(alias = "g_unix_fd_add_full")] +pub fn unix_fd_add_full( + fd: RawFd, + priority: Priority, + condition: IOCondition, + func: F, +) -> SourceId +where + F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, +{ + unsafe { + from_glib(ffi::g_unix_fd_add_full( + priority.into_glib(), + fd, + condition.into_glib(), + Some(trampoline_unix_fd::), + into_raw_unix_fd(func), + Some(destroy_closure_unix_fd::), + )) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX file descriptor reaches the given IO condition. +/// +/// `func` will be called repeatedly while the file descriptor matches the given IO condition +/// until it returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +/// +/// Different to `unix_fd_add()`, this does not require `func` to be +/// `Send` but can only be called from the thread that owns the main context. +/// +/// This function panics if called from a different thread than the one that +/// owns the main context. +#[doc(alias = "g_unix_fd_add_full")] +pub fn unix_fd_add_local(fd: RawFd, condition: IOCondition, func: F) -> SourceId +where + F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, +{ + unsafe { + let context = glib::MainContext::default(); + let _acquire = context + .acquire() + .expect("default main context already acquired by another thread"); + from_glib(ffi::g_unix_fd_add_full( + Priority::default().into_glib(), + fd, + condition.into_glib(), + Some(trampoline_unix_fd_local::), + into_raw_unix_fd_local(func), + Some(destroy_closure_unix_fd_local::), + )) + } +} + +// rustdoc-stripper-ignore-next +/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a +/// UNIX file descriptor reaches the given IO condition. +/// +/// `func` will be called repeatedly with `priority` while the file descriptor matches the given IO condition +/// until it returns `ControlFlow::Break`. +/// +/// The default main loop almost always is the main loop of the main thread. +/// Thus, the closure is called on the main thread. +/// +/// Different to `unix_fd_add()`, this does not require `func` to be +/// `Send` but can only be called from the thread that owns the main context. +/// +/// This function panics if called from a different thread than the one that +/// owns the main context. +#[doc(alias = "g_unix_fd_add_full")] +pub fn unix_fd_add_local_full( + fd: RawFd, + priority: Priority, + condition: IOCondition, + func: F, +) -> SourceId +where + F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, +{ + unsafe { + let context = glib::MainContext::default(); + let _acquire = context + .acquire() + .expect("default main context already acquired by another thread"); + from_glib(ffi::g_unix_fd_add_full( + priority.into_glib(), + fd, + condition.into_glib(), + Some(trampoline_unix_fd_local::), + into_raw_unix_fd_local(func), + Some(destroy_closure_unix_fd_local::), + )) + } +} diff --git a/glib-unix/src/lib.rs b/glib-unix/src/lib.rs new file mode 100644 index 000000000000..b06f81315a81 --- /dev/null +++ b/glib-unix/src/lib.rs @@ -0,0 +1,9 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +pub use ffi; + +mod auto; +mod functions; + +pub use auto::functions::*; +pub use functions::*; diff --git a/glib-unix/sys/Cargo.toml b/glib-unix/sys/Cargo.toml new file mode 100644 index 000000000000..52e9a879feae --- /dev/null +++ b/glib-unix/sys/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "glib-unix-sys" +build = "build.rs" + +[package.version] +workspace = true + +[package.edition] +workspace = true + +[package.metadata.system-deps.glib_2_0] +name = "glib-2.0" +version = "2.56" + +[package.metadata.system-deps.glib_2_0.v2_80] +version = "2.80" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true + +[lib] +name = "glib_unix_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[build-dependencies] +system-deps = "7" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v2_80 = [] diff --git a/glib-unix/sys/Gir.toml b/glib-unix/sys/Gir.toml new file mode 100644 index 000000000000..9a430d833c01 --- /dev/null +++ b/glib-unix/sys/Gir.toml @@ -0,0 +1,18 @@ +[options] +work_mode = "sys" +library = "GLibUnix" +version = "2.0" +min_cfg_version = "2.56" +single_version_file = "." +girs_directories = ["../../gir-files"] + +external_libraries = [ + "GLib", +] + +[[object]] +name = "GLibUnix.*" +status = "generate" + [[object.function]] + name = "open_pipe" + manual = true # different fds annotations \ No newline at end of file diff --git a/glib-unix/sys/build.rs b/glib-unix/sys/build.rs new file mode 100644 index 000000000000..7341ed1620c9 --- /dev/null +++ b/glib-unix/sys/build.rs @@ -0,0 +1,15 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +fn main() { + if std::env::var("DOCS_RS").is_ok() { + // prevent linking libraries to avoid documentation failure + return; + } + + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + std::process::exit(1); + } +} diff --git a/glib-unix/sys/src/lib.rs b/glib-unix/sys/src/lib.rs new file mode 100644 index 000000000000..03780176751b --- /dev/null +++ b/glib-unix/sys/src/lib.rs @@ -0,0 +1,131 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; + +mod manual; + +pub use manual::*; + +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; +#[allow(unused_imports)] +use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE}; +#[allow(unused_imports)] +use std::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Enums +pub type GUnixPipeEnd = c_int; +pub const G_UNIX_PIPE_END_READ: GUnixPipeEnd = 0; +pub const G_UNIX_PIPE_END_WRITE: GUnixPipeEnd = 1; + +// Callbacks +pub type GUnixFDSourceFunc = + Option gboolean>; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GUnixPipe { + pub fds: [c_int; 2], +} + +impl ::std::fmt::Debug for GUnixPipe { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GUnixPipe @ {self:p}")) + .field("fds", &self.fds) + .finish() + } +} + +extern "C" { + + //========================================================================= + // GUnixPipe + //========================================================================= + #[cfg(feature = "v2_80")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] + pub fn g_unix_pipe_clear(self_: *mut glib::GUnixPipe); + #[cfg(feature = "v2_80")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] + pub fn g_unix_pipe_close( + self_: *mut glib::GUnixPipe, + end: glib::GUnixPipeEnd, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v2_80")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] + pub fn g_unix_pipe_get(self_: *mut glib::GUnixPipe, end: glib::GUnixPipeEnd) -> c_int; + #[cfg(feature = "v2_80")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] + pub fn g_unix_pipe_open( + self_: *mut glib::GUnixPipe, + flags: c_int, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v2_80")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] + pub fn g_unix_pipe_steal(self_: *mut glib::GUnixPipe, end: glib::GUnixPipeEnd) -> c_int; + + //========================================================================= + // Other functions + //========================================================================= + pub fn g_closefrom(lowfd: c_int) -> c_int; + pub fn g_unix_error_quark() -> glib::GQuark; + pub fn g_unix_fd_add( + fd: c_int, + condition: glib::GIOCondition, + function: glib::GUnixFDSourceFunc, + user_data: gpointer, + ) -> c_uint; + pub fn g_unix_fd_add_full( + priority: c_int, + fd: c_int, + condition: glib::GIOCondition, + function: glib::GUnixFDSourceFunc, + user_data: gpointer, + notify: glib::GDestroyNotify, + ) -> c_uint; + pub fn g_unix_fd_query_path(fd: c_int, error: *mut *mut glib::GError) -> *mut c_char; + pub fn g_unix_fd_source_new(fd: c_int, condition: glib::GIOCondition) -> *mut glib::GSource; + pub fn g_fdwalk_set_cloexec(lowfd: c_int) -> c_int; + pub fn g_unix_get_passwd_entry( + user_name: *const c_char, + error: *mut *mut glib::GError, + ) -> *mut passwd; + pub fn g_unix_set_fd_nonblocking( + fd: c_int, + nonblock: gboolean, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn g_unix_signal_add( + signum: c_int, + handler: glib::GSourceFunc, + user_data: gpointer, + ) -> c_uint; + pub fn g_unix_signal_add_full( + priority: c_int, + signum: c_int, + handler: glib::GSourceFunc, + user_data: gpointer, + notify: glib::GDestroyNotify, + ) -> c_uint; + pub fn g_unix_signal_source_new(signum: c_int) -> *mut glib::GSource; + +} diff --git a/glib-unix/sys/src/manual.rs b/glib-unix/sys/src/manual.rs new file mode 100644 index 000000000000..a599f7588377 --- /dev/null +++ b/glib-unix/sys/src/manual.rs @@ -0,0 +1,11 @@ +use glib_sys::{gboolean, GError}; +use libc::c_int; +pub use libc::passwd; + +extern "C" { + pub fn g_unix_open_pipe( + fds: *mut [c_int; 2], + flags: c_int, + error: *mut *mut GError, + ) -> gboolean; +} diff --git a/glib-unix/sys/tests/abi.rs b/glib-unix/sys/tests/abi.rs new file mode 100644 index 000000000000..48c18b38d6d5 --- /dev/null +++ b/glib-unix/sys/tests/abi.rs @@ -0,0 +1,223 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![cfg(unix)] + +use glib_unix_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["glib-2.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GUnixPipe", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GUnixPipeEnd", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("(gint) G_UNIX_PIPE_END_READ", "0"), + ("(gint) G_UNIX_PIPE_END_WRITE", "1"), +]; diff --git a/glib-unix/sys/tests/constant.c b/glib-unix/sys/tests/constant.c new file mode 100644 index 000000000000..467d72718c21 --- /dev/null +++ b/glib-unix/sys/tests/constant.c @@ -0,0 +1,34 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT((gint) G_UNIX_PIPE_END_READ); + PRINT_CONSTANT((gint) G_UNIX_PIPE_END_WRITE); + return 0; +} diff --git a/glib-unix/sys/tests/layout.c b/glib-unix/sys/tests/layout.c new file mode 100644 index 000000000000..89e88d0c38dc --- /dev/null +++ b/glib-unix/sys/tests/layout.c @@ -0,0 +1,13 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GUnixPipe", sizeof(GUnixPipe), alignof(GUnixPipe)); + printf("%s;%zu;%zu\n", "GUnixPipeEnd", sizeof(GUnixPipeEnd), alignof(GUnixPipeEnd)); + return 0; +} diff --git a/glib-unix/sys/tests/manual.h b/glib-unix/sys/tests/manual.h new file mode 100644 index 000000000000..b0afe3e7b733 --- /dev/null +++ b/glib-unix/sys/tests/manual.h @@ -0,0 +1,4 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include +#include diff --git a/glib-unix/sys/versions.txt b/glib-unix/sys/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/glib-unix/sys/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib-win32/Cargo.toml b/glib-win32/Cargo.toml new file mode 100644 index 000000000000..c3ad78898ae8 --- /dev/null +++ b/glib-win32/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "glib-win32" +documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib-win32/" +description = "Rust bindings for the GLibWin32 library" +readme = "README.md" +keywords = ["glib-win32", "gtk-rs", "gnome", "GUI"] +authors.workspace = true +edition.workspace = true +exclude.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +ffi = { package = "glib-win32-sys", path = "./sys"} +libc.workspace = true +glib.workspace = true + +[dev-dependencies] +tempfile = "3" +gir-format-check.workspace = true + +[features] +default = [] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/glib-win32/Gir.toml b/glib-win32/Gir.toml new file mode 100644 index 000000000000..1e0220251ade --- /dev/null +++ b/glib-win32/Gir.toml @@ -0,0 +1,25 @@ +[options] +girs_directories = ["../gir-files"] +library = "GLibWin32" +version = "2.0" +min_cfg_version = "2.56" +use_gi_docgen = true +target_path = "." +work_mode = "normal" +single_version_file = true +deprecate_by_min_version = true +trust_return_value_nullability = true + +generate = [ + "GLibWin32.OSType", +] + +ignore = [ +] + +manual = [ +] + +[[object]] +name = "GLibWin32.*" +status = "generate" diff --git a/glib-win32/src/auto/enums.rs b/glib-win32/src/auto/enums.rs new file mode 100644 index 000000000000..281d6840113d --- /dev/null +++ b/glib-win32/src/auto/enums.rs @@ -0,0 +1,48 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::translate::*; + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GWin32OSType")] +pub enum OSType { + #[doc(alias = "G_WIN32_OS_ANY")] + Any, + #[doc(alias = "G_WIN32_OS_WORKSTATION")] + Workstation, + #[doc(alias = "G_WIN32_OS_SERVER")] + Server, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for OSType { + type GlibType = ffi::GWin32OSType; + + #[inline] + fn into_glib(self) -> ffi::GWin32OSType { + match self { + Self::Any => ffi::G_WIN32_OS_ANY, + Self::Workstation => ffi::G_WIN32_OS_WORKSTATION, + Self::Server => ffi::G_WIN32_OS_SERVER, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for OSType { + #[inline] + unsafe fn from_glib(value: ffi::GWin32OSType) -> Self { + match value { + ffi::G_WIN32_OS_ANY => Self::Any, + ffi::G_WIN32_OS_WORKSTATION => Self::Workstation, + ffi::G_WIN32_OS_SERVER => Self::Server, + value => Self::__Unknown(value), + } + } +} diff --git a/glib-win32/src/auto/functions.rs b/glib-win32/src/auto/functions.rs new file mode 100644 index 000000000000..9d0d991ea133 --- /dev/null +++ b/glib-win32/src/auto/functions.rs @@ -0,0 +1,87 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, OSType}; +use glib::translate::*; + +#[doc(alias = "g_win32_check_windows_version")] +pub fn check_windows_version(major: i32, minor: i32, spver: i32, os_type: OSType) -> bool { + unsafe { + from_glib(ffi::g_win32_check_windows_version( + major, + minor, + spver, + os_type.into_glib(), + )) + } +} + +#[doc(alias = "g_win32_error_message")] +pub fn error_message(error: i32) -> glib::GString { + unsafe { from_glib_full(ffi::g_win32_error_message(error)) } +} + +#[doc(alias = "g_win32_ftruncate")] +pub fn ftruncate(f: i32, size: u32) -> i32 { + unsafe { ffi::g_win32_ftruncate(f, size) } +} + +#[doc(alias = "g_win32_get_command_line")] +#[doc(alias = "get_command_line")] +pub fn command_line() -> Vec { + unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_win32_get_command_line()) } +} + +#[doc(alias = "g_win32_get_package_installation_directory")] +#[doc(alias = "get_package_installation_directory")] +pub fn package_installation_directory(package: &str, dll_name: &str) -> glib::GString { + unsafe { + from_glib_full(ffi::g_win32_get_package_installation_directory( + package.to_glib_none().0, + dll_name.to_glib_none().0, + )) + } +} + +//#[doc(alias = "g_win32_get_package_installation_directory_of_module")] +//#[doc(alias = "get_package_installation_directory_of_module")] +//pub fn package_installation_directory_of_module(hmodule: /*Unimplemented*/Option) -> glib::GString { +// unsafe { TODO: call ffi:g_win32_get_package_installation_directory_of_module() } +//} + +#[doc(alias = "g_win32_get_package_installation_subdirectory")] +#[doc(alias = "get_package_installation_subdirectory")] +pub fn package_installation_subdirectory( + package: &str, + dll_name: &str, + subdir: &str, +) -> glib::GString { + unsafe { + from_glib_full(ffi::g_win32_get_package_installation_subdirectory( + package.to_glib_none().0, + dll_name.to_glib_none().0, + subdir.to_glib_none().0, + )) + } +} + +#[doc(alias = "g_win32_get_windows_version")] +#[doc(alias = "get_windows_version")] +pub fn windows_version() -> u32 { + unsafe { ffi::g_win32_get_windows_version() } +} + +#[doc(alias = "g_win32_getlocale")] +pub fn getlocale() -> glib::GString { + unsafe { from_glib_full(ffi::g_win32_getlocale()) } +} + +#[doc(alias = "g_win32_locale_filename_from_utf8")] +pub fn locale_filename_from_utf8(utf8filename: &str) -> glib::GString { + unsafe { + from_glib_full(ffi::g_win32_locale_filename_from_utf8( + utf8filename.to_glib_none().0, + )) + } +} diff --git a/glib-win32/src/auto/mod.rs b/glib-win32/src/auto/mod.rs new file mode 100644 index 000000000000..2dece6ba4672 --- /dev/null +++ b/glib-win32/src/auto/mod.rs @@ -0,0 +1,8 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +mod enums; +pub use self::enums::OSType; + +pub(crate) mod functions; diff --git a/glib-win32/src/auto/versions.txt b/glib-win32/src/auto/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/glib-win32/src/auto/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib-win32/src/functions.rs b/glib-win32/src/functions.rs new file mode 100644 index 000000000000..ed88838d16d9 --- /dev/null +++ b/glib-win32/src/functions.rs @@ -0,0 +1,39 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[doc(alias = "g_win32_get_package_installation_directory_of_module")] +#[doc(alias = "get_package_installation_directory_of_module")] +pub fn package_installation_directory_of_module( + hmodule: std::os::windows::raw::HANDLE, +) -> Result { + // # Safety + // The underlying `GetModuleFilenameW` function has three possible + // outcomes when a raw pointer get passed to it: + // - When the pointer is a valid HINSTANCE of a DLL (e.g. acquired + // through the `GetModuleHandleW`), it sets a file path to the + // assigned "out" buffer and sets the return value to be the length + // of said path string + // - When the pointer is null, it sets the full path of the process' + // executable binary to the assigned buffer and sets the return value + // to be the length of said string + // - Whenever the provided buffer size is too small, it will set a + // truncated version of the path and return the length of said string + // while also setting the thread-local last-error code to + // `ERROR_INSUFFICIENT_BUFFER` (evaluates to 0x7A) + // - When the pointer is not a valid HINSTANCE that isn't NULL (e.g. + // a pointer to some GKeyFile), it will return 0 and set the last-error + // code to `ERROR_MOD_NOT_FOUND` (evaluates to 0x7E) + // + // The `g_win32_get_package_installation_directory_of_module` already + // handles all of the outcomes gracefully by: + // - Preallocating a MAX_PATH-long array of wchar_t for the out buffer, + // so that outcome #3 can be safely assumed to never happen + // - Returning NULL when outcome #4 happens + match unsafe { + from_glib_full::<_, Option>( + ffi::g_win32_get_package_installation_directory_of_module(hmodule), + ) + } { + Some(pb) => Ok(pb), + None => Err(std::io::Error::last_os_error()), + } +} diff --git a/glib-win32/src/lib.rs b/glib-win32/src/lib.rs new file mode 100644 index 000000000000..2e49f777503d --- /dev/null +++ b/glib-win32/src/lib.rs @@ -0,0 +1,10 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +pub use ffi; + +mod auto; +pub use auto::*; +mod functions; + +pub use auto::functions::*; +pub use functions::*; diff --git a/glib-win32/sys/Cargo.toml b/glib-win32/sys/Cargo.toml new file mode 100644 index 000000000000..4fc09d56187d --- /dev/null +++ b/glib-win32/sys/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "glib-win32-sys" +build = "build.rs" + +[package.version] +workspace = true + +[package.edition] +workspace = true + +[package.metadata.system-deps.glib_2_0] +name = "glib-2.0" +version = "2.56" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[build-dependencies] +system-deps = "7" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] diff --git a/glib-win32/sys/Gir.toml b/glib-win32/sys/Gir.toml new file mode 100644 index 000000000000..1c04ff0e4961 --- /dev/null +++ b/glib-win32/sys/Gir.toml @@ -0,0 +1,11 @@ +[options] +work_mode = "sys" +library = "GLibWin32" +version = "2.0" +min_cfg_version = "2.56" +single_version_file = "." +girs_directories = ["../../gir-files"] + +external_libraries = [ + "GLib", +] diff --git a/glib-win32/sys/build.rs b/glib-win32/sys/build.rs new file mode 100644 index 000000000000..7341ed1620c9 --- /dev/null +++ b/glib-win32/sys/build.rs @@ -0,0 +1,15 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +fn main() { + if std::env::var("DOCS_RS").is_ok() { + // prevent linking libraries to avoid documentation failure + return; + } + + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + std::process::exit(1); + } +} diff --git a/glib-win32/sys/src/lib.rs b/glib-win32/sys/src/lib.rs new file mode 100644 index 000000000000..c7233eedbf9f --- /dev/null +++ b/glib-win32/sys/src/lib.rs @@ -0,0 +1,63 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; + +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; +#[allow(unused_imports)] +use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE}; +#[allow(unused_imports)] +use std::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Enums +pub type GWin32OSType = c_int; +pub const G_WIN32_OS_ANY: GWin32OSType = 0; +pub const G_WIN32_OS_WORKSTATION: GWin32OSType = 1; +pub const G_WIN32_OS_SERVER: GWin32OSType = 2; + +extern "C" { + + //========================================================================= + // Other functions + //========================================================================= + pub fn g_win32_check_windows_version( + major: c_int, + minor: c_int, + spver: c_int, + os_type: GWin32OSType, + ) -> gboolean; + pub fn g_win32_error_message(error: c_int) -> *mut c_char; + pub fn g_win32_ftruncate(f: c_int, size: c_uint) -> c_int; + pub fn g_win32_get_command_line() -> *mut *mut c_char; + pub fn g_win32_get_package_installation_directory( + package: *const c_char, + dll_name: *const c_char, + ) -> *mut c_char; + pub fn g_win32_get_package_installation_directory_of_module(hmodule: gpointer) -> *mut c_char; + pub fn g_win32_get_package_installation_subdirectory( + package: *const c_char, + dll_name: *const c_char, + subdir: *const c_char, + ) -> *mut c_char; + pub fn g_win32_get_windows_version() -> c_uint; + pub fn g_win32_getlocale() -> *mut c_char; + pub fn g_win32_locale_filename_from_utf8(utf8filename: *const c_char) -> *mut c_char; + +} diff --git a/glib-win32/sys/tests/abi.rs b/glib-win32/sys/tests/abi.rs new file mode 100644 index 000000000000..0bd40c2c8d7f --- /dev/null +++ b/glib-win32/sys/tests/abi.rs @@ -0,0 +1,215 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#![cfg(unix)] + +use glib_win32_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["glib-2.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[( + "GWin32OSType", + Layout { + size: size_of::(), + alignment: align_of::(), + }, +)]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("(gint) G_WIN32_OS_ANY", "0"), + ("(gint) G_WIN32_OS_SERVER", "2"), + ("(gint) G_WIN32_OS_WORKSTATION", "1"), +]; diff --git a/glib-win32/sys/tests/constant.c b/glib-win32/sys/tests/constant.c new file mode 100644 index 000000000000..130965d3ce08 --- /dev/null +++ b/glib-win32/sys/tests/constant.c @@ -0,0 +1,35 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT((gint) G_WIN32_OS_ANY); + PRINT_CONSTANT((gint) G_WIN32_OS_SERVER); + PRINT_CONSTANT((gint) G_WIN32_OS_WORKSTATION); + return 0; +} diff --git a/glib-win32/sys/tests/layout.c b/glib-win32/sys/tests/layout.c new file mode 100644 index 000000000000..d4c566d617cf --- /dev/null +++ b/glib-win32/sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GWin32OSType", sizeof(GWin32OSType), alignof(GWin32OSType)); + return 0; +} diff --git a/glib-win32/sys/tests/manual.h b/glib-win32/sys/tests/manual.h new file mode 100644 index 000000000000..a058119866cd --- /dev/null +++ b/glib-win32/sys/tests/manual.h @@ -0,0 +1,3 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include diff --git a/glib-win32/sys/versions.txt b/glib-win32/sys/versions.txt new file mode 100644 index 000000000000..b47135b9caf9 --- /dev/null +++ b/glib-win32/sys/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) +from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) diff --git a/glib/Cargo.toml b/glib/Cargo.toml index 9c3ab0fc5cdc..998c8277f57b 100644 --- a/glib/Cargo.toml +++ b/glib/Cargo.toml @@ -55,6 +55,7 @@ v2_80 = ["v2_78", "glib-sys/v2_80", "gobject-sys/v2_80"] v2_82 = ["v2_80", "glib-sys/v2_82", "gobject-sys/v2_82"] v2_84 = ["v2_82", "glib-sys/v2_84", "gobject-sys/v2_84"] v2_86 = ["v2_84", "glib-sys/v2_86", "gobject-sys/v2_86"] +v2_88 = ["v2_86", "glib-sys/v2_88"] log = ["rs-log"] log_kv = ["log", "rs-log/kv"] log_macros = ["log"] diff --git a/glib/Gir.toml b/glib/Gir.toml index f9bdbd0e8a0c..3c82f684d428 100644 --- a/glib/Gir.toml +++ b/glib/Gir.toml @@ -277,7 +277,7 @@ status = "generate" ignore = true [[object.function]] pattern = "unix_.+" - cfg_condition = "unix" + ignore = true # part of GLibUnix [[object.function]] name = "spawn_command_line_async" cfg_condition = "unix" @@ -285,9 +285,6 @@ status = "generate" name = "command_line" string_type = "os_string" [[object.function]] - name = "unix_open_pipe" - manual = true - [[object.function]] name = "convert_with_fallback" manual = true [[object.function]] @@ -330,14 +327,6 @@ status = "generate" # Need manual bindings to be useful ignore = true [[object.function]] - name = "unix_signal_source_new" - # Need manual bindings to be useful - ignore = true - [[object.function]] - pattern = "unix_fd.*" - # Need manual binding for RawFd - ignore = true - [[object.function]] name = "close" # Need manual binding for RawFd ignore = true @@ -350,10 +339,6 @@ status = "generate" # Need manual binding for RawFd ignore = true [[object.function]] - name = "unix_set_fd_nonblocking" - # Need manual binding for RawFd - ignore = true - [[object.function]] name = "environ_getenv" # manual input &[OsString] ignore = true @@ -438,12 +423,6 @@ status = "generate" name = "timeout_add_seconds_once" ignore = true # we have a manual impl already [[object.function]] - name = "unix_signal_add" - ignore = true - [[object.function]] - name = "unix_signal_add_full" - ignore = true - [[object.function]] pattern = "rc_box_.+" #need manual implementation ignore = true diff --git a/glib/src/auto/functions.rs b/glib/src/auto/functions.rs index 35a85b57e7bf..5abb80b099fb 100644 --- a/glib/src/auto/functions.rs +++ b/glib/src/auto/functions.rs @@ -826,15 +826,6 @@ pub fn spawn_command_line_async( // unsafe { TODO: call ffi:g_stat() } //} -//#[cfg(unix)] -//#[cfg_attr(docsrs, doc(cfg(unix)))] -//#[cfg(feature = "v2_64")] -//#[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] -//#[doc(alias = "g_unix_get_passwd_entry")] -//pub fn unix_get_passwd_entry(user_name: &str) -> Result, crate::Error> { -// unsafe { TODO: call ffi:g_unix_get_passwd_entry() } -//} - #[doc(alias = "g_unlink")] pub fn unlink(filename: impl AsRef) -> i32 { unsafe { ffi::g_unlink(filename.as_ref().to_glib_none().0) } diff --git a/glib/src/functions.rs b/glib/src/functions.rs index aaa7a0548270..8fe7fc81ba5e 100644 --- a/glib/src/functions.rs +++ b/glib/src/functions.rs @@ -9,7 +9,7 @@ use std::mem; #[cfg(feature = "v2_58")] use std::os::unix::io::{AsFd, AsRawFd}; #[cfg(not(windows))] -use std::os::unix::io::{FromRawFd, OwnedFd, RawFd}; +use std::os::unix::io::{FromRawFd, OwnedFd}; use std::ptr; // #[cfg(windows)] @@ -239,24 +239,6 @@ pub fn compute_checksum_for_string( }) } -#[cfg(unix)] -#[doc(alias = "g_unix_open_pipe")] -pub fn unix_open_pipe(flags: i32) -> Result<(RawFd, RawFd), Error> { - unsafe { - let mut fds = [0, 2]; - let mut error = ptr::null_mut(); - let _ = ffi::g_unix_open_pipe(&mut fds, flags, &mut error); - if error.is_null() { - Ok(( - FromRawFd::from_raw_fd(fds[0]), - FromRawFd::from_raw_fd(fds[1]), - )) - } else { - Err(from_glib_full(error)) - } - } -} - #[cfg(unix)] #[doc(alias = "g_file_open_tmp")] pub fn file_open_tmp( diff --git a/glib/src/lib.rs b/glib/src/lib.rs index e2a93064ae6b..1f25f157c2b3 100644 --- a/glib/src/lib.rs +++ b/glib/src/lib.rs @@ -255,9 +255,3 @@ pub mod thread_guard; /// logger (it prints to stdout by default), you can set your own logger using the corresponding /// `log` functions. pub const CLONE_MACRO_LOG_DOMAIN: &str = "glib-rs-clone"; - -#[cfg(target_family = "windows")] -mod win32; - -#[cfg(target_family = "windows")] -pub use self::win32::*; diff --git a/glib/src/source.rs b/glib/src/source.rs index b7702fa8d45a..ca83225d833a 100644 --- a/glib/src/source.rs +++ b/glib/src/source.rs @@ -1,15 +1,12 @@ // Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] -use std::os::unix::io::RawFd; use std::{cell::RefCell, mem::transmute, num::NonZeroU32, time::Duration}; use crate::ffi::{self, gboolean, gpointer}; #[cfg(all(not(unix), docsrs))] use libc::c_int as RawFd; -#[cfg(unix)] -use crate::IOCondition; use crate::{thread_guard::ThreadGuard, translate::*, ControlFlow, MainContext, Source}; // rustdoc-stripper-ignore-next @@ -151,70 +148,6 @@ fn into_raw_child_watch_local(func: F) -> gpointer Box::into_raw(func) as gpointer } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -unsafe extern "C" fn trampoline_unix_fd< - F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, ->( - fd: i32, - condition: ffi::GIOCondition, - func: gpointer, -) -> gboolean { - let func: &RefCell = &*(func as *const RefCell); - (*func.borrow_mut())(fd, from_glib(condition)).into_glib() -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -unsafe extern "C" fn trampoline_unix_fd_local< - F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, ->( - fd: i32, - condition: ffi::GIOCondition, - func: gpointer, -) -> gboolean { - let func: &ThreadGuard> = &*(func as *const ThreadGuard>); - (*func.get_ref().borrow_mut())(fd, from_glib(condition)).into_glib() -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -unsafe extern "C" fn destroy_closure_unix_fd< - F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, ->( - ptr: gpointer, -) { - let _ = Box::>::from_raw(ptr as *mut _); -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -unsafe extern "C" fn destroy_closure_unix_fd_local< - F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, ->( - ptr: gpointer, -) { - let _ = Box::>>::from_raw(ptr as *mut _); -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -fn into_raw_unix_fd ControlFlow + Send + 'static>( - func: F, -) -> gpointer { - let func: Box> = Box::new(RefCell::new(func)); - Box::into_raw(func) as gpointer -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -fn into_raw_unix_fd_local ControlFlow + 'static>( - func: F, -) -> gpointer { - let func: Box>> = Box::new(ThreadGuard::new(RefCell::new(func))); - Box::into_raw(func) as gpointer -} - // rustdoc-stripper-ignore-next /// Transform a generic FnOnce into a closure that can be used as callback in various glib methods /// @@ -750,258 +683,6 @@ where } } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. -/// -/// `func` will be called repeatedly every time `signum` is raised until it -/// returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -#[doc(alias = "g_unix_signal_add_full")] -pub fn unix_signal_add(signum: i32, func: F) -> SourceId -where - F: FnMut() -> ControlFlow + Send + 'static, -{ - unsafe { - from_glib(ffi::g_unix_signal_add_full( - ffi::G_PRIORITY_DEFAULT, - signum, - Some(trampoline::), - into_raw(func), - Some(destroy_closure::), - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. -/// -/// `func` will be called repeatedly every time `signum` is raised until it -/// returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -/// -/// In comparison to `unix_signal_add()`, this only requires `func` to be -/// `FnOnce`, and will automatically return `ControlFlow::Break`. -#[doc(alias = "g_unix_signal_add_full")] -pub fn unix_signal_add_once(signum: i32, func: F) -> SourceId -where - F: FnOnce() + Send + 'static, -{ - unix_signal_add(signum, fnmut_callback_wrapper(func)) -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. -/// -/// `func` will be called repeatedly every time `signum` is raised until it -/// returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -/// -/// Different to `unix_signal_add()`, this does not require `func` to be -/// `Send` but can only be called from the thread that owns the main context. -/// -/// This function panics if called from a different thread than the one that -/// owns the main context. -#[doc(alias = "g_unix_signal_add_full")] -pub fn unix_signal_add_local(signum: i32, func: F) -> SourceId -where - F: FnMut() -> ControlFlow + 'static, -{ - unsafe { - let context = MainContext::default(); - let _acquire = context - .acquire() - .expect("default main context already acquired by another thread"); - from_glib(ffi::g_unix_signal_add_full( - ffi::G_PRIORITY_DEFAULT, - signum, - Some(trampoline_local::), - into_raw_local(func), - Some(destroy_closure_local::), - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the default main loop whenever a UNIX signal is raised. -/// -/// `func` will be called repeatedly every time `signum` is raised until it -/// returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -/// -/// Different to `unix_signal_add()`, this does not require `func` to be -/// `Send` but can only be called from the thread that owns the main context. -/// -/// This function panics if called from a different thread than the one that -/// owns the main context. -/// -/// In comparison to `unix_signal_add_local()`, this only requires `func` to be -/// `FnOnce`, and will automatically return `ControlFlow::Break`. -#[doc(alias = "g_unix_signal_add_full")] -pub fn unix_signal_add_local_once(signum: i32, func: F) -> SourceId -where - F: FnOnce() + 'static, -{ - unix_signal_add_local(signum, fnmut_callback_wrapper_local(func)) -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX file descriptor reaches the given IO condition. -/// -/// `func` will be called repeatedly while the file descriptor matches the given IO condition -/// until it returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -#[doc(alias = "g_unix_fd_add_full")] -pub fn unix_fd_add(fd: RawFd, condition: IOCondition, func: F) -> SourceId -where - F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, -{ - unsafe { - from_glib(ffi::g_unix_fd_add_full( - ffi::G_PRIORITY_DEFAULT, - fd, - condition.into_glib(), - Some(trampoline_unix_fd::), - into_raw_unix_fd(func), - Some(destroy_closure_unix_fd::), - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX file descriptor reaches the given IO condition. -/// -/// `func` will be called repeatedly with `priority` while the file descriptor matches the given IO condition -/// until it returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -#[doc(alias = "g_unix_fd_add_full")] -pub fn unix_fd_add_full( - fd: RawFd, - priority: Priority, - condition: IOCondition, - func: F, -) -> SourceId -where - F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, -{ - unsafe { - from_glib(ffi::g_unix_fd_add_full( - priority.into_glib(), - fd, - condition.into_glib(), - Some(trampoline_unix_fd::), - into_raw_unix_fd(func), - Some(destroy_closure_unix_fd::), - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX file descriptor reaches the given IO condition. -/// -/// `func` will be called repeatedly while the file descriptor matches the given IO condition -/// until it returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -/// -/// Different to `unix_fd_add()`, this does not require `func` to be -/// `Send` but can only be called from the thread that owns the main context. -/// -/// This function panics if called from a different thread than the one that -/// owns the main context. -#[doc(alias = "g_unix_fd_add_full")] -pub fn unix_fd_add_local(fd: RawFd, condition: IOCondition, func: F) -> SourceId -where - F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, -{ - unsafe { - let context = MainContext::default(); - let _acquire = context - .acquire() - .expect("default main context already acquired by another thread"); - from_glib(ffi::g_unix_fd_add_full( - ffi::G_PRIORITY_DEFAULT, - fd, - condition.into_glib(), - Some(trampoline_unix_fd_local::), - into_raw_unix_fd_local(func), - Some(destroy_closure_unix_fd_local::), - )) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX file descriptor reaches the given IO condition. -/// -/// `func` will be called repeatedly with `priority` while the file descriptor matches the given IO condition -/// until it returns `ControlFlow::Break`. -/// -/// The default main loop almost always is the main loop of the main thread. -/// Thus, the closure is called on the main thread. -/// -/// Different to `unix_fd_add()`, this does not require `func` to be -/// `Send` but can only be called from the thread that owns the main context. -/// -/// This function panics if called from a different thread than the one that -/// owns the main context. -#[doc(alias = "g_unix_fd_add_full")] -pub fn unix_fd_add_local_full( - fd: RawFd, - priority: Priority, - condition: IOCondition, - func: F, -) -> SourceId -where - F: FnMut(RawFd, IOCondition) -> ControlFlow + 'static, -{ - unsafe { - let context = MainContext::default(); - let _acquire = context - .acquire() - .expect("default main context already acquired by another thread"); - from_glib(ffi::g_unix_fd_add_full( - priority.into_glib(), - fd, - condition.into_glib(), - Some(trampoline_unix_fd_local::), - into_raw_unix_fd_local(func), - Some(destroy_closure_unix_fd_local::), - )) - } -} - // rustdoc-stripper-ignore-next /// The priority of sources #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] @@ -1184,82 +865,6 @@ where } } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX signal is raised. -/// -/// `func` will be called repeatedly every time `signum` is raised until it -/// returns `ControlFlow::Break`. -#[doc(alias = "g_unix_signal_source_new")] -pub fn unix_signal_source_new( - signum: i32, - name: Option<&str>, - priority: Priority, - func: F, -) -> Source -where - F: FnMut() -> ControlFlow + Send + 'static, -{ - unsafe { - let source = ffi::g_unix_signal_source_new(signum); - ffi::g_source_set_callback( - source, - Some(trampoline::), - into_raw(func), - Some(destroy_closure::), - ); - ffi::g_source_set_priority(source, priority.into_glib()); - - if let Some(name) = name { - ffi::g_source_set_name(source, name.to_glib_none().0); - } - - from_glib_full(source) - } -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Adds a closure to be called by the main loop the returned `Source` is attached to whenever a -/// UNIX file descriptor reaches the given IO condition. -/// -/// `func` will be called repeatedly while the file descriptor matches the given IO condition -/// until it returns `ControlFlow::Break`. -#[doc(alias = "g_unix_fd_source_new")] -pub fn unix_fd_source_new( - fd: RawFd, - condition: IOCondition, - name: Option<&str>, - priority: Priority, - func: F, -) -> Source -where - F: FnMut(RawFd, IOCondition) -> ControlFlow + Send + 'static, -{ - unsafe { - let source = ffi::g_unix_fd_source_new(fd, condition.into_glib()); - ffi::g_source_set_callback( - source, - Some(transmute::< - *const (), - unsafe extern "C" fn(ffi::gpointer) -> ffi::gboolean, - >(trampoline_unix_fd:: as *const ())), - into_raw_unix_fd(func), - Some(destroy_closure_unix_fd::), - ); - ffi::g_source_set_priority(source, priority.into_glib()); - - if let Some(name) = name { - ffi::g_source_set_name(source, name.to_glib_none().0); - } - - from_glib_full(source) - } -} - impl Source { #[doc(alias = "g_source_attach")] pub fn attach(&self, context: Option<&MainContext>) -> SourceId { diff --git a/glib/src/source_futures.rs b/glib/src/source_futures.rs index dd719d84be6e..9b94b5ce12fa 100644 --- a/glib/src/source_futures.rs +++ b/glib/src/source_futures.rs @@ -194,35 +194,6 @@ pub fn child_watch_future_with_priority( })) } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Create a `Future` that will resolve once the given UNIX signal is raised -/// -/// The `Future` must be spawned on an `Executor` backed by a `glib::MainContext`. -pub fn unix_signal_future(signum: i32) -> Pin + Send + 'static>> { - unix_signal_future_with_priority(crate::Priority::default(), signum) -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Create a `Future` that will resolve once the given UNIX signal is raised -/// -/// The `Future` must be spawned on an `Executor` backed by a `glib::MainContext`. -pub fn unix_signal_future_with_priority( - priority: Priority, - signum: i32, -) -> Pin + Send + 'static>> { - Box::pin(SourceFuture::new(move |send| { - let mut send = Some(send); - crate::unix_signal_source_new(signum, None, priority, move || { - let _ = send.take().unwrap().send(()); - ControlFlow::Break - }) - })) -} - // rustdoc-stripper-ignore-next /// Represents a `Stream` around a `glib::Source`. The stream will /// be provide all values that are provided by the source @@ -380,37 +351,6 @@ pub fn interval_stream_seconds_with_priority( })) } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Create a `Stream` that will provide a value whenever the given UNIX signal is raised -/// -/// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. -pub fn unix_signal_stream(signum: i32) -> Pin + Send + 'static>> { - unix_signal_stream_with_priority(crate::Priority::default(), signum) -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -// rustdoc-stripper-ignore-next -/// Create a `Stream` that will provide a value whenever the given UNIX signal is raised -/// -/// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. -pub fn unix_signal_stream_with_priority( - priority: Priority, - signum: i32, -) -> Pin + Send + 'static>> { - Box::pin(SourceStream::new(move |send| { - crate::unix_signal_source_new(signum, None, priority, move || { - if send.unbounded_send(()).is_err() { - ControlFlow::Break - } else { - ControlFlow::Continue - } - }) - })) -} - #[cfg(test)] mod tests { use std::{thread, time::Duration}; diff --git a/glib/src/win32.rs b/glib/src/win32.rs deleted file mode 100644 index a913aa9e64d4..000000000000 --- a/glib/src/win32.rs +++ /dev/null @@ -1,118 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use std::path::PathBuf; - -use crate::{ffi, translate::*, GString, StrV}; - -#[doc(alias = "GWin32OSType")] -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -pub enum Win32OSType { - #[doc(alias = "G_WIN32_OS_ANY")] - Any, - #[doc(alias = "G_WIN32_OS_WORKSTATION")] - Workstation, - #[doc(alias = "G_WIN32_OS_SERVER")] - Server, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for Win32OSType { - type GlibType = ffi::GWin32OSType; - - #[inline] - fn into_glib(self) -> Self::GlibType { - match self { - Self::Any => ffi::G_WIN32_OS_ANY, - Self::Workstation => ffi::G_WIN32_OS_WORKSTATION, - Self::Server => ffi::G_WIN32_OS_SERVER, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for Win32OSType { - #[inline] - unsafe fn from_glib(value: ffi::GWin32OSType) -> Self { - match value { - ffi::G_WIN32_OS_ANY => Self::Any, - ffi::G_WIN32_OS_WORKSTATION => Self::Workstation, - ffi::G_WIN32_OS_SERVER => Self::Server, - value => Self::__Unknown(value), - } - } -} - -#[doc(alias = "g_win32_check_windows_version")] -pub fn win32_check_windows_version( - major: i32, - minor: i32, - spver: i32, - os_type: Win32OSType, -) -> bool { - unsafe { - from_glib(ffi::g_win32_check_windows_version( - major, - minor, - spver, - os_type.into_glib(), - )) - } -} - -#[doc(alias = "g_win32_get_command_line")] -#[doc(alias = "get_command_line")] -pub fn win32_command_line() -> StrV { - unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_win32_get_command_line()) } -} - -#[doc(alias = "g_win32_error_message")] -pub fn win32_error_message(error: i32) -> GString { - unsafe { from_glib_full(ffi::g_win32_error_message(error)) } -} - -#[doc(alias = "g_win32_getlocale")] -pub fn win32_getlocale() -> GString { - unsafe { from_glib_full(ffi::g_win32_getlocale()) } -} - -#[doc(alias = "g_win32_get_package_installation_directory_of_module")] -#[doc(alias = "get_package_installation_directory_of_module")] -pub fn win32_package_installation_directory_of_module( - hmodule: std::os::windows::raw::HANDLE, -) -> Result { - // # Safety - // The underlying `GetModuleFilenameW` function has three possible - // outcomes when a raw pointer get passed to it: - // - When the pointer is a valid HINSTANCE of a DLL (e.g. acquired - // through the `GetModuleHandleW`), it sets a file path to the - // assigned "out" buffer and sets the return value to be the length - // of said path string - // - When the pointer is null, it sets the full path of the process' - // executable binary to the assigned buffer and sets the return value - // to be the length of said string - // - Whenever the provided buffer size is too small, it will set a - // truncated version of the path and return the length of said string - // while also setting the thread-local last-error code to - // `ERROR_INSUFFICIENT_BUFFER` (evaluates to 0x7A) - // - When the pointer is not a valid HINSTANCE that isn't NULL (e.g. - // a pointer to some GKeyFile), it will return 0 and set the last-error - // code to `ERROR_MOD_NOT_FOUND` (evaluates to 0x7E) - // - // The `g_win32_get_package_installation_directory_of_module` already - // handles all of the outcomes gracefully by: - // - Preallocating a MAX_PATH-long array of wchar_t for the out buffer, - // so that outcome #3 can be safely assumed to never happen - // - Returning NULL when outcome #4 happens - match unsafe { - from_glib_full::<_, Option>( - ffi::g_win32_get_package_installation_directory_of_module(hmodule), - ) - } { - Some(pb) => Ok(pb), - None => Err(std::io::Error::last_os_error()), - } -} From 689e880283ed1c328fab9312d317bcdfbeeee20e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 12:36:26 +0100 Subject: [PATCH 03/29] Build new crates on CI --- .github/workflows/CI.yml | 2 ++ .github/workflows/docs.yml | 10 +++++++++- .github/workflows/windows.yml | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 800b46ec2928..e654dd3176cd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,9 @@ jobs: - { name: "cairo", features: "png,pdf,svg,ps,use_glib,v1_18,freetype,script,xcb,xlib,win32-surface", nightly: "--features 'png,pdf,svg,ps,use_glib,v1_18,freetype,script,xcb,xlib,win32-surface'", test_sys: true } - { name: "gdk-pixbuf", features: "v2_42", nightly: "--all-features", test_sys: true } - { name: "gio", features: "v2_84", nightly: "--all-features", test_sys: true } + - { name: "gio-unix", features: "v2_84", nightly: "--all-features", test_sys: true } - { name: "glib", features: "v2_84,log", nightly: "--all-features", test_sys: true } + - { name: "glib-unix", features: "v2_80", nightly: "--all-features", test_sys: true } - { name: "graphene", features: "v1_12", nightly: "", test_sys: true } - { name: "pango", features: "v1_56", nightly: "", test_sys: true } - { name: "pangocairo", features: "", nightly: "--all-features", test_sys: true } diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 31e70f01abec..50b2d8e39b9c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -50,9 +50,17 @@ jobs: -p gdk-pixbuf-sys -p gio -p gio-sys + -p gio-unix + -p gio-unix-sys + -p gio-win32 + -p gio-win32-sys -p glib - -p gobject-sys -p glib-sys + -p glib-unix + -p glib-unix-sys + -p glib-win32 + -p glib-win32-sys + -p gobject-sys -p glib-macros -p glib-build-tools -p graphene-rs diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6fc73b47ae23..bc4495c449fc 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -150,7 +150,9 @@ jobs: - { name: "cairo", test: true, args: "--features png,pdf,svg,ps,use_glib,v1_16,freetype,script,win32-surface" } - { name: "gdk-pixbuf", test: true, args: "--features v2_42" } - { name: "gio", test: true, args: "--features v2_80" } + - { name: "gio-win32", test: true, args: "--features v2_84" } - { name: "glib", test: true, args: "--features v2_80" } + - { name: "glib-win32", test: true } - { name: "glib-build-tools", test: false, args: "" } - { name: "graphene", test: false, args: "" } - { name: "pango", test: true, args: "--features v1_52" } From 0ead8457e459085a3ec6479144e4369b76bd3e54 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 12:40:47 +0100 Subject: [PATCH 04/29] gio/unix: Remove the manual fallback for MountEntry We require v2.84 for it nowadays anyways --- gio-unix/sys/src/manual.rs | 115 ------------------------------------- 1 file changed, 115 deletions(-) diff --git a/gio-unix/sys/src/manual.rs b/gio-unix/sys/src/manual.rs index cd9c46aa6ca1..50620b67d1a5 100644 --- a/gio-unix/sys/src/manual.rs +++ b/gio-unix/sys/src/manual.rs @@ -6,121 +6,6 @@ pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = libc::MSG_OOB; pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK; pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE; -#[cfg(not(feature = "v2_84"))] -pub mod g_unix_fallback { - use crate::GUnixMountEntry; - use glib_sys::gboolean; - use libc::{c_char, c_int}; - - pub unsafe fn g_unix_mount_entry_compare( - mount1: *mut GUnixMountEntry, - mount2: *mut GUnixMountEntry, - ) -> c_int { - crate::g_unix_mount_compare(mount1, mount2) - } - pub unsafe fn g_unix_mount_entry_copy( - mount_entry: *mut GUnixMountEntry, - ) -> *mut GUnixMountEntry { - crate::g_unix_mount_copy(mount_entry) - } - pub unsafe fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry) { - crate::g_unix_mount_free(mount_entry); - } - pub unsafe fn g_unix_mount_entry_get_device_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - crate::g_unix_mount_get_device_path(mount_entry) - } - pub unsafe fn g_unix_mount_entry_get_fs_type( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - crate::g_unix_mount_get_fs_type(mount_entry) - } - pub unsafe fn g_unix_mount_entry_get_mount_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - crate::g_unix_mount_get_mount_path(mount_entry) - } - #[cfg(feature = "v2_58")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] - pub unsafe fn g_unix_mount_entry_get_options( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - crate::g_unix_mount_get_options(mount_entry) - } - #[cfg(feature = "v2_60")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] - pub unsafe fn g_unix_mount_entry_get_root_path( - mount_entry: *mut GUnixMountEntry, - ) -> *const c_char { - crate::g_unix_mount_get_root_path(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_can_eject( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - crate::g_unix_mount_guess_can_eject(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_icon( - mount_entry: *mut GUnixMountEntry, - ) -> *mut gio_sys::GIcon { - crate::g_unix_mount_guess_icon(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char { - crate::g_unix_mount_guess_name(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_should_display( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - crate::g_unix_mount_guess_should_display(mount_entry) - } - pub unsafe fn g_unix_mount_entry_guess_symbolic_icon( - mount_entry: *mut GUnixMountEntry, - ) -> *mut gio_sys::GIcon { - crate::g_unix_mount_guess_symbolic_icon(mount_entry) - } - pub unsafe fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean { - crate::g_unix_mount_is_readonly(mount_entry) - } - pub unsafe fn g_unix_mount_entry_is_system_internal( - mount_entry: *mut GUnixMountEntry, - ) -> gboolean { - crate::g_unix_mount_is_system_internal(mount_entry) - } - pub unsafe fn g_unix_mount_entry_at( - mount_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry { - crate::g_unix_mount_at(mount_path, time_read) - } - pub unsafe fn g_unix_mount_entry_for( - file_path: *const c_char, - time_read: *mut u64, - ) -> *mut GUnixMountEntry { - crate::g_unix_mount_for(file_path, time_read) - } - - #[cfg(feature = "v2_82")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] - pub unsafe fn g_unix_mount_entries_get_from_file( - table_path: *const c_char, - time_read_out: *mut u64, - n_entries_out: *mut size_t, - ) -> *mut *mut GUnixMountEntry { - crate::g_unix_mounts_get_from_file(table_path, time_read_out, n_entries_out) - } - - pub unsafe fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib_sys::GList { - crate::g_unix_mounts_get(time_read) - } - - pub unsafe fn g_unix_mount_entries_changed_since(time: u64) -> gboolean { - crate::g_unix_mounts_changed_since(time) - } -} - -#[cfg(not(feature = "v2_84"))] -pub use g_unix_fallback::*; - extern "C" { #[cfg(feature = "v2_84")] From e96408c37f2f195fcb8003617dece9339d30221d Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 12:52:17 +0100 Subject: [PATCH 05/29] glib: Lower host dep requirement --- glib/sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/sys/Cargo.toml b/glib/sys/Cargo.toml index 73b18741ce0b..063300cb962b 100644 --- a/glib/sys/Cargo.toml +++ b/glib/sys/Cargo.toml @@ -109,7 +109,7 @@ version = "2.84" version = "2.85" [package.metadata.system-deps.glib_2_0.v2_88] -version = "2.88" +version = "2.87" [package.metadata.system-deps.gobject_2_0] name = "gobject-2.0" From f908147af1839b1162b8a6c6be81a38cba26f125 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 12:55:46 +0100 Subject: [PATCH 06/29] glib/unix: Add missing futures feature --- glib-unix/Cargo.toml | 5 +++-- glib-unix/src/functions.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/glib-unix/Cargo.toml b/glib-unix/Cargo.toml index 7c216bf3af70..61f5952853ea 100644 --- a/glib-unix/Cargo.toml +++ b/glib-unix/Cargo.toml @@ -17,14 +17,15 @@ version.workspace = true ffi = { package = "glib-unix-sys", path = "./sys"} libc.workspace = true glib.workspace = true -futures-core = { version = "0.3", default-features = false } +futures-core = { version = "0.3", default-features = false, optional = true} [dev-dependencies] tempfile = "3" gir-format-check.workspace = true [features] -default = [] +default = ["futures"] +futures = ["glib/futures", "dep:futures-core"] v2_80 = ["ffi/v2_80", "glib/v2_80"] [package.metadata.docs.rs] diff --git a/glib-unix/src/functions.rs b/glib-unix/src/functions.rs index ea5b93f89f04..b81e537d337c 100644 --- a/glib-unix/src/functions.rs +++ b/glib-unix/src/functions.rs @@ -9,8 +9,12 @@ use std::pin::Pin; use glib::ffi::gpointer; use glib::thread_guard::ThreadGuard; use glib::translate::*; -use glib::{ControlFlow, IOCondition, Priority, Source, SourceFuture, SourceId, SourceStream}; +use glib::{ControlFlow, IOCondition, Priority, Source, SourceId}; +#[cfg(feature = "futures")] +use glib::{SourceFuture, SourceStream}; + +#[cfg(feature = "futures")] use futures_core::stream::Stream; fn into_raw ControlFlow + Send + 'static>(func: F) -> gpointer { @@ -146,6 +150,7 @@ pub fn unix_open_pipe(flags: i32) -> Result<(RawFd, RawFd), glib::Error> { /// Create a `Stream` that will provide a value whenever the given UNIX signal is raised /// /// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. +#[cfg(feature = "futures")] pub fn signal_stream(signum: i32) -> Pin + Send + 'static>> { signal_stream_with_priority(Priority::default(), signum) } @@ -154,6 +159,7 @@ pub fn signal_stream(signum: i32) -> Pin + Send + 'sta /// Create a `Stream` that will provide a value whenever the given UNIX signal is raised /// /// The `Stream` must be spawned on an `Executor` backed by a `glib::MainContext`. +#[cfg(feature = "futures")] pub fn signal_stream_with_priority( priority: Priority, signum: i32, @@ -173,6 +179,7 @@ pub fn signal_stream_with_priority( /// Create a `Future` that will resolve once the given UNIX signal is raised /// /// The `Future` must be spawned on an `Executor` backed by a `glib::MainContext`. +#[cfg(feature = "futures")] pub fn signal_future_with_priority( priority: Priority, signum: i32, From a0f89d98f470d656f9fc22bfd94737e481d3859e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 12:57:47 +0100 Subject: [PATCH 07/29] gio/unix: Ignore a clippy lint --- gio-unix/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/gio-unix/src/lib.rs b/gio-unix/src/lib.rs index 44812abd0af6..d51692422ff2 100644 --- a/gio-unix/src/lib.rs +++ b/gio-unix/src/lib.rs @@ -3,6 +3,7 @@ pub use ffi; #[allow(unused_imports)] +#[allow(clippy::derived_hash_with_manual_eq)] mod auto; pub use auto::*; From d58ab6529674359a179ce58a999f621034d847e9 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 13:09:28 +0100 Subject: [PATCH 08/29] gio: Comment out a test & drop UnixFdMessage --- gio/Gir.toml | 16 ------ gio/src/socket.rs | 130 +++++++++++++++++++++++----------------------- 2 files changed, 66 insertions(+), 80 deletions(-) diff --git a/gio/Gir.toml b/gio/Gir.toml index c8394312bdd9..4b58cacbb4be 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -1605,22 +1605,6 @@ manual_traits = ["UnixFDListExtManual"] manual = true doc_trait_name = "UnixFDListExtManual" -[[object]] -name = "Gio.UnixFDMessage" -status = "generate" -cfg_condition = "unix" -manual_traits = ["UnixFDMessageExtManual"] - [[object.function]] - name = "append_fd" - # has to use RawFd - manual = true - doc_trait_name = "UnixFDMessageExtManual" - [[object.function]] - name = "steal_fds" - # has to use RawFd - manual = true - doc_trait_name = "UnixFDMessageExtManual" - [[object]] name = "Gio.UnixInputStream" status = "generate" diff --git a/gio/src/socket.rs b/gio/src/socket.rs index 738a6840bef8..494dd3743e1b 100644 --- a/gio/src/socket.rs +++ b/gio/src/socket.rs @@ -825,73 +825,75 @@ pub type RawSocket = *mut std::os::raw::c_void; #[cfg(test)] mod tests { - #[test] - #[cfg(unix)] - fn socket_messages() { - use std::{ - io, - os::unix::io::{AsRawFd, FromRawFd, OwnedFd}, - }; - - use super::Socket; - use crate::{prelude::*, Cancellable, UnixFDMessage}; - - let mut fds = [0 as libc::c_int; 2]; - let (out_sock, in_sock) = unsafe { - let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()); - if ret != 0 { - panic!("{}", io::Error::last_os_error()); - } - ( - Socket::from_fd(OwnedFd::from_raw_fd(fds[0])).unwrap(), - Socket::from_fd(OwnedFd::from_raw_fd(fds[1])).unwrap(), + /* + #[test] + #[cfg(unix)] + fn socket_messages() { + use std::{ + io, + os::unix::io::{AsRawFd, FromRawFd, OwnedFd}, + }; + + use super::Socket; + use crate::{prelude::*, Cancellable, UnixFDMessage}; + + let mut fds = [0 as libc::c_int; 2]; + let (out_sock, in_sock) = unsafe { + let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()); + if ret != 0 { + panic!("{}", io::Error::last_os_error()); + } + ( + Socket::from_fd(OwnedFd::from_raw_fd(fds[0])).unwrap(), + Socket::from_fd(OwnedFd::from_raw_fd(fds[1])).unwrap(), + ) + }; + + let fd_msg = UnixFDMessage::new(); + fd_msg.append_fd(out_sock.as_raw_fd()).unwrap(); + let vs = [super::OutputVector::new(&[0])]; + let ctrl_msgs = [fd_msg.upcast()]; + let mut out_msg = [super::OutputMessage::new( + crate::SocketAddress::NONE, + vs.as_slice(), + ctrl_msgs.as_slice(), + )]; + let written = super::SocketExtManual::send_messages( + &out_sock, + out_msg.as_mut_slice(), + 0, + Cancellable::NONE, ) - }; - - let fd_msg = UnixFDMessage::new(); - fd_msg.append_fd(out_sock.as_raw_fd()).unwrap(); - let vs = [super::OutputVector::new(&[0])]; - let ctrl_msgs = [fd_msg.upcast()]; - let mut out_msg = [super::OutputMessage::new( - crate::SocketAddress::NONE, - vs.as_slice(), - ctrl_msgs.as_slice(), - )]; - let written = super::SocketExtManual::send_messages( - &out_sock, - out_msg.as_mut_slice(), - 0, - Cancellable::NONE, - ) - .unwrap(); - assert_eq!(written, 1); - assert_eq!(out_msg[0].bytes_sent(), 1); + .unwrap(); + assert_eq!(written, 1); + assert_eq!(out_msg[0].bytes_sent(), 1); - let mut v = [0u8]; - let mut vs = [super::InputVector::new(v.as_mut_slice())]; - let mut ctrl_msgs = super::SocketControlMessages::new(); - let mut in_msg = [super::InputMessage::new( - None, - vs.as_mut_slice(), - Some(&mut ctrl_msgs), - )]; - let received = super::SocketExtManual::receive_messages( - &in_sock, - in_msg.as_mut_slice(), - 0, - Cancellable::NONE, - ) - .unwrap(); + let mut v = [0u8]; + let mut vs = [super::InputVector::new(v.as_mut_slice())]; + let mut ctrl_msgs = super::SocketControlMessages::new(); + let mut in_msg = [super::InputMessage::new( + None, + vs.as_mut_slice(), + Some(&mut ctrl_msgs), + )]; + let received = super::SocketExtManual::receive_messages( + &in_sock, + in_msg.as_mut_slice(), + 0, + Cancellable::NONE, + ) + .unwrap(); - assert_eq!(received, 1); - assert_eq!(in_msg[0].bytes_received(), 1); - assert_eq!(ctrl_msgs.len(), 1); - let fds = ctrl_msgs[0] - .downcast_ref::() - .unwrap() - .fd_list(); - assert_eq!(fds.length(), 1); - } + assert_eq!(received, 1); + assert_eq!(in_msg[0].bytes_received(), 1); + assert_eq!(ctrl_msgs.len(), 1); + let fds = ctrl_msgs[0] + .downcast_ref::() + .unwrap() + .fd_list(); + assert_eq!(fds.length(), 1); + } + */ #[test] #[cfg(unix)] fn dgram_socket_messages() { From 52fac07d12f13612596d677286006d11c7cae69a Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 13:36:48 +0100 Subject: [PATCH 09/29] gio/tests: Remove no longer useful headers --- gio-win32/sys/tests/manual.h | 6 ------ gio/sys/tests/manual.h | 10 ---------- 2 files changed, 16 deletions(-) diff --git a/gio-win32/sys/tests/manual.h b/gio-win32/sys/tests/manual.h index f6df402f2e5c..8a048dbad324 100644 --- a/gio-win32/sys/tests/manual.h +++ b/gio-win32/sys/tests/manual.h @@ -1,9 +1,3 @@ // Feel free to edit this file, it won't be regenerated by gir generator unless removed. -#include -#include #include -#include -#include -#include -#include diff --git a/gio/sys/tests/manual.h b/gio/sys/tests/manual.h index 2b8371ddcf9a..e4e8742503de 100644 --- a/gio/sys/tests/manual.h +++ b/gio/sys/tests/manual.h @@ -1,15 +1,5 @@ // Feel free to edit this file, it won't be regenerated by gir generator unless removed. -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #define G_SETTINGS_ENABLE_BACKEND 1 #include From ba6a27d9a807b3b68287e27f87ddcde4a2ec20ff Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 13:59:46 +0100 Subject: [PATCH 10/29] gio: Move various config options to gio-unix --- gio-unix/Gir.toml | 109 ++++++++++++++++- gio-unix/src/auto/file_descriptor_based.rs | 10 +- gio-unix/src/auto/input_stream.rs | 58 +-------- gio-unix/src/auto/mount_entry.rs | 10 +- gio-unix/src/auto/mount_point.rs | 5 +- gio-unix/src/auto/output_stream.rs | 61 +-------- gio/Gir.toml | 136 --------------------- 7 files changed, 119 insertions(+), 270 deletions(-) diff --git a/gio-unix/Gir.toml b/gio-unix/Gir.toml index b0fa8dfefbc1..3c8991d40b3e 100644 --- a/gio-unix/Gir.toml +++ b/gio-unix/Gir.toml @@ -14,11 +14,7 @@ deprecate_by_min_version = true trust_return_value_nullability = true generate = [ - "GioUnix.FDMessage", - "GioUnix.FileDescriptorBased", - "GioUnix.InputStream", "GioUnix.MountMonitor", - "GioUnix.OutputStream", ] ignore = [ @@ -52,6 +48,7 @@ status = "generate" [[object]] name = "GioUnix.DesktopAppInfo" status = "generate" +manual_traits = ["DesktopAppInfoExtManual"] [[object.function]] name = "get_boolean" # Retrieves the boolean value of a key @@ -65,21 +62,123 @@ status = "generate" # has to use RawFd / SOCKET manual = true +[[object]] +name = "GioUnix.FDMessage" +status = "generate" +manual_traits = ["FDMessageExtManual"] + +[[object]] +name = "GioUnix.FileDescriptorBased" +status = "generate" +manual_traits = ["FileDescriptorBasedExtManual"] + [[object.function]] + name = "get_fd" + manual = true + [[object]] name = "GioUnix.MountEntry" status = "generate" +concurrency = "send+sync" version = "2.84" [[object.function]] pattern = "*" [[object.function.parameter]] pattern = "(mount1|mount2|mount_entry)" const = true + [[object.derive]] + name = "Debug" + [[object.function]] + pattern = "compare|get_device_path|get_fs_type|get_mount_path|guess_can_eject|guess_name|guess_icon|guess_should_display|guess_symbolic_icon|is_readonly|is_system_internal" + [[object.function.parameter]] + pattern = ".+" + const = true + [[object.function]] + name = "get_options" + [[object.function.parameter]] + pattern = ".+" + const = true + [[object.function]] + name = "get_root_path" + [[object.function.parameter]] + pattern = ".+" + const = true + [[object.function]] + name = "at" + rename = "for_mount_path" + [[object.function]] + name = "for" + rename = "for_file_path" [[object]] name = "GioUnix.MountPoint" status = "generate" +concurrency = "send+sync" + [[object.derive]] + name = "Debug" [[object.function]] pattern = "*" [[object.function.parameter]] pattern = "(mount1|mount2|mount_point)" - const = true \ No newline at end of file + const = true + +[[object]] +name = "GioUnix.InputStream" +status = "generate" +manual_traits = ["InputStreamExtManual"] + [[object.function]] + name = "new" + # has to use RawFd + manual = true + generate_doc = false + + [[object.function]] + name = "set_close_fd" + # Can cause file descriptor leaks + manual = true + generate_doc = false + + [[object.function]] + name = "get_fd" + # conflicts with as FileDescriptorBased::fd + ignore = true + + [[object.property]] + name = "fd" + # has to use RawFd + ignore = true + + [[object.property]] + name = "close-fd" + ignore = true + + +[[object]] +name = "GioUnix.OutputStream" +status = "generate" +manual_traits = ["OutputStreamExtManual"] + [[object.function]] + name = "new" + # has to use RawFd + manual = true + generate_doc = false + + [[object.function]] + name = "set_close_fd" + # Can cause file descriptor leaks + manual = true + doc_trait_name = "OutputStreamExtManual" + generate_doc = false + + [[object.function]] + name = "get_fd" + # conflicts with as FileDescriptorBased::fd + ignore = true + + [[object.property]] + name = "fd" + # has to use RawFd + ignore = true + + [[object.property]] + name = "close-fd" + ignore = true \ No newline at end of file diff --git a/gio-unix/src/auto/file_descriptor_based.rs b/gio-unix/src/auto/file_descriptor_based.rs index 78c8fcb5821e..fc709d8d27b7 100644 --- a/gio-unix/src/auto/file_descriptor_based.rs +++ b/gio-unix/src/auto/file_descriptor_based.rs @@ -3,7 +3,7 @@ // DO NOT EDIT use crate::ffi; -use glib::{prelude::*, translate::*}; +use glib::prelude::*; glib::wrapper! { #[doc(alias = "GFileDescriptorBased")] @@ -18,12 +18,6 @@ impl FileDescriptorBased { pub const NONE: Option<&'static FileDescriptorBased> = None; } -pub trait FileDescriptorBasedExt: IsA + 'static { - #[doc(alias = "g_file_descriptor_based_get_fd")] - #[doc(alias = "get_fd")] - fn fd(&self) -> i32 { - unsafe { ffi::g_file_descriptor_based_get_fd(self.as_ref().to_glib_none().0) } - } -} +pub trait FileDescriptorBasedExt: IsA + 'static {} impl> FileDescriptorBasedExt for O {} diff --git a/gio-unix/src/auto/input_stream.rs b/gio-unix/src/auto/input_stream.rs index 2b21ec25ff79..b7a783825782 100644 --- a/gio-unix/src/auto/input_stream.rs +++ b/gio-unix/src/auto/input_stream.rs @@ -3,12 +3,7 @@ // DO NOT EDIT use crate::{ffi, FileDescriptorBased}; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::boxed::Box as Box_; +use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixInputStream")] @@ -21,14 +16,6 @@ glib::wrapper! { impl InputStream { pub const NONE: Option<&'static InputStream> = None; - - #[doc(alias = "g_unix_input_stream_new")] - pub fn new(fd: i32, close_fd: bool) -> InputStream { - unsafe { - gio::InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd.into_glib())) - .unsafe_cast() - } - } } pub trait InputStreamExt: IsA + 'static { @@ -42,49 +29,6 @@ pub trait InputStreamExt: IsA + 'static { )) } } - - #[doc(alias = "g_unix_input_stream_get_fd")] - #[doc(alias = "get_fd")] - fn fd(&self) -> i32 { - unsafe { ffi::g_unix_input_stream_get_fd(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "g_unix_input_stream_set_close_fd")] - #[doc(alias = "close-fd")] - fn set_close_fd(&self, close_fd: bool) { - unsafe { - ffi::g_unix_input_stream_set_close_fd( - self.as_ref().to_glib_none().0, - close_fd.into_glib(), - ); - } - } - - #[doc(alias = "close-fd")] - fn connect_close_fd_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_close_fd_trampoline< - P: IsA, - F: Fn(&P) + 'static, - >( - this: *mut ffi::GUnixInputStream, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(InputStream::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - c"notify::close-fd".as_ptr() as *const _, - Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( - notify_close_fd_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } } impl> InputStreamExt for O {} diff --git a/gio-unix/src/auto/mount_entry.rs b/gio-unix/src/auto/mount_entry.rs index cf7744c5e920..c86fdfb820f4 100644 --- a/gio-unix/src/auto/mount_entry.rs +++ b/gio-unix/src/auto/mount_entry.rs @@ -6,7 +6,7 @@ use crate::ffi; use glib::translate::*; glib::wrapper! { - #[derive(Debug, Hash)] + #[derive(Debug)] pub struct MountEntry(Boxed); match fn { @@ -141,7 +141,8 @@ impl MountEntry { } #[doc(alias = "g_unix_mount_entry_at")] - pub fn at(mount_path: impl AsRef) -> (Option, u64) { + #[doc(alias = "at")] + pub fn for_mount_path(mount_path: impl AsRef) -> (Option, u64) { unsafe { let mut time_read = std::mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_unix_mount_entry_at( @@ -154,7 +155,7 @@ impl MountEntry { #[doc(alias = "g_unix_mount_entry_for")] #[doc(alias = "for")] - pub fn for_(file_path: impl AsRef) -> (Option, u64) { + pub fn for_file_path(file_path: impl AsRef) -> (Option, u64) { unsafe { let mut time_read = std::mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_unix_mount_entry_for( @@ -188,3 +189,6 @@ impl Ord for MountEntry { self.compare(other).cmp(&0) } } + +unsafe impl Send for MountEntry {} +unsafe impl Sync for MountEntry {} diff --git a/gio-unix/src/auto/mount_point.rs b/gio-unix/src/auto/mount_point.rs index e092e4c02824..8dca073e868a 100644 --- a/gio-unix/src/auto/mount_point.rs +++ b/gio-unix/src/auto/mount_point.rs @@ -6,7 +6,7 @@ use crate::ffi; use glib::translate::*; glib::wrapper! { - #[derive(Debug, Hash)] + #[derive(Debug)] pub struct MountPoint(Boxed); match fn { @@ -167,3 +167,6 @@ impl Ord for MountPoint { self.compare(other).cmp(&0) } } + +unsafe impl Send for MountPoint {} +unsafe impl Sync for MountPoint {} diff --git a/gio-unix/src/auto/output_stream.rs b/gio-unix/src/auto/output_stream.rs index eb850ca78b6b..430412a39a60 100644 --- a/gio-unix/src/auto/output_stream.rs +++ b/gio-unix/src/auto/output_stream.rs @@ -3,12 +3,7 @@ // DO NOT EDIT use crate::{ffi, FileDescriptorBased}; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::boxed::Box as Box_; +use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixOutputStream")] @@ -21,17 +16,6 @@ glib::wrapper! { impl OutputStream { pub const NONE: Option<&'static OutputStream> = None; - - #[doc(alias = "g_unix_output_stream_new")] - pub fn new(fd: i32, close_fd: bool) -> OutputStream { - unsafe { - gio::OutputStream::from_glib_full(ffi::g_unix_output_stream_new( - fd, - close_fd.into_glib(), - )) - .unsafe_cast() - } - } } pub trait OutputStreamExt: IsA + 'static { @@ -45,49 +29,6 @@ pub trait OutputStreamExt: IsA + 'static { )) } } - - #[doc(alias = "g_unix_output_stream_get_fd")] - #[doc(alias = "get_fd")] - fn fd(&self) -> i32 { - unsafe { ffi::g_unix_output_stream_get_fd(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "g_unix_output_stream_set_close_fd")] - #[doc(alias = "close-fd")] - fn set_close_fd(&self, close_fd: bool) { - unsafe { - ffi::g_unix_output_stream_set_close_fd( - self.as_ref().to_glib_none().0, - close_fd.into_glib(), - ); - } - } - - #[doc(alias = "close-fd")] - fn connect_close_fd_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_close_fd_trampoline< - P: IsA, - F: Fn(&P) + 'static, - >( - this: *mut ffi::GUnixOutputStream, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(OutputStream::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - c"notify::close-fd".as_ptr() as *const _, - Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( - notify_close_fd_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } } impl> OutputStreamExt for O {} diff --git a/gio/Gir.toml b/gio/Gir.toml index 4b58cacbb4be..6f34adc0405a 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -906,12 +906,6 @@ status = "generate" name = "target_default_modified_time" version = "2.80" -[[object]] -name = "Gio.FileDescriptorBased" -status = "manual" -cfg_condition = "unix" -manual_traits = ["FileDescriptorBasedExtManual"] - [[object]] name = "Gio.FileEnumerator" status = "generate" @@ -1605,136 +1599,6 @@ manual_traits = ["UnixFDListExtManual"] manual = true doc_trait_name = "UnixFDListExtManual" -[[object]] -name = "Gio.UnixInputStream" -status = "generate" -cfg_condition = "unix" -manual_traits = ["UnixInputStreamExtManual"] - [[object.function]] - name = "new" - # has to use RawFd - manual = true - generate_doc = false - - [[object.function]] - name = "set_close_fd" - # Can cause file descriptor leaks - manual = true - doc_trait_name = "UnixInputStreamExtManual" - generate_doc = false - - [[object.function]] - name = "get_fd" - # conflicts with as FileDescriptorBased::fd - ignore = true - - [[object.property]] - name = "fd" - # has to use RawFd - ignore = true - - [[object.property]] - name = "close-fd" - ignore = true - -[[object]] -name = "Gio.UnixMountEntry" -status = "generate" -concurrency = "send+sync" -cfg_condition = "unix" - [[object.derive]] - name = "Debug" - [[object.function]] - pattern = "compare|get_device_path|get_fs_type|get_mount_path|guess_can_eject|guess_name|guess_icon|guess_should_display|guess_symbolic_icon|is_readonly|is_system_internal" - version = "2.0" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - name = "get_options" - version = "2.58" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - name = "get_root_path" - version = "2.60" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - name = "at" - version = "2.0" - rename = "for_mount_path" - [[object.function]] - name = "for" - version = "2.0" - rename = "for_file_path" - -[[object]] -name = "Gio.UnixMountMonitor" -status = "generate" -cfg_condition = "unix" - -[[object]] -name = "Gio.UnixMountPoint" -status = "generate" -concurrency = "send+sync" -cfg_condition = "unix" - [[object.derive]] - name = "Debug" - [[object.function]] - name = "compare" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - pattern = "get_.*" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - pattern = "guess_.*" - [[object.function.parameter]] - pattern = ".+" - const = true - [[object.function]] - pattern = "is_.*" - [[object.function.parameter]] - pattern = ".+" - const = true - -[[object]] -name = "Gio.UnixOutputStream" -status = "generate" -cfg_condition = "unix" -manual_traits = ["UnixOutputStreamExtManual"] - [[object.function]] - name = "new" - # has to use RawFd - manual = true - generate_doc = false - - [[object.function]] - name = "set_close_fd" - # Can cause file descriptor leaks - manual = true - doc_trait_name = "UnixOutputStreamExtManual" - generate_doc = false - - [[object.function]] - name = "get_fd" - # conflicts with as FileDescriptorBased::fd - ignore = true - - [[object.property]] - name = "fd" - # has to use RawFd - ignore = true - - [[object.property]] - name = "close-fd" - ignore = true [[object]] name = "Gio.UnixSocketAddress" From 732a14997f7f01f2b5c608674f61c218c5a06d1c Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 21 Nov 2025 14:15:19 +0100 Subject: [PATCH 11/29] glib: Remove no longer needed manual ffi functions --- glib/sys/src/manual.rs | 46 ----------------------------------------- glib/sys/tests/manual.h | 12 ----------- 2 files changed, 58 deletions(-) diff --git a/glib/sys/src/manual.rs b/glib/sys/src/manual.rs index 1c7874495608..e0789abb8408 100644 --- a/glib/sys/src/manual.rs +++ b/glib/sys/src/manual.rs @@ -75,52 +75,6 @@ pub const G_VARIANT_TYPE_BYTE_STRING: &str = "ay"; pub const G_VARIANT_TYPE_BYTE_STRING_ARRAY: &str = "aay"; pub const G_VARIANT_TYPE_VARDICT: &str = "a{sv}"; -#[cfg(target_family = "windows")] -pub use self::win32::*; - -#[cfg(target_family = "windows")] -mod win32 { - use libc::{c_char, c_int, c_uint}; - - pub type GWin32OSType = c_int; - pub const G_WIN32_OS_ANY: GWin32OSType = 0; - pub const G_WIN32_OS_WORKSTATION: GWin32OSType = 1; - pub const G_WIN32_OS_SERVER: GWin32OSType = 2; - - extern "C" { - pub fn g_win32_check_windows_version( - major: c_int, - minor: c_int, - spver: c_int, - os_type: GWin32OSType, - ) -> crate::gboolean; - - pub fn g_win32_get_command_line() -> *mut *mut c_char; - - pub fn g_win32_error_message(error: c_int) -> *mut c_char; - - pub fn g_win32_getlocale() -> *mut c_char; - - pub fn g_win32_get_package_installation_directory_of_module( - hmodule: std::os::windows::raw::HANDLE, - ) -> *mut c_char; - - pub fn g_win32_locale_filename_from_utf8(utf8filename: *const c_char) -> *mut c_char; - - pub fn g_win32_ftruncate(f: c_int, size: c_uint) -> c_int; - pub fn g_win32_get_package_installation_directory( - package: *const c_char, - dll_name: *const c_char, - ) -> *mut c_char; - pub fn g_win32_get_package_installation_subdirectory( - package: *const c_char, - dll_name: *const c_char, - subdir: *const c_char, - ) -> *mut c_char; - pub fn g_win32_get_windows_version() -> c_uint; - } -} - extern "C" { pub fn g_atomic_int_get(atomic: *const c_int) -> c_int; } diff --git a/glib/sys/tests/manual.h b/glib/sys/tests/manual.h index 513d6ae467c3..e79a07234a3e 100644 --- a/glib/sys/tests/manual.h +++ b/glib/sys/tests/manual.h @@ -3,18 +3,6 @@ #include #include -#ifndef G_PLATFORM_WIN32 -// glib-unix.h is not included automatically -#include -// polyfill the WIN32 constants on non-Win32 platforms -typedef enum -{ - G_WIN32_OS_ANY, - G_WIN32_OS_WORKSTATION, - G_WIN32_OS_SERVER, -} GWin32OSType; -#endif - // polyfill when the platform doesn't define tracing macros #ifndef G_TRACE_CURRENT_TIME #define G_TRACE_CURRENT_TIME 0 From c69f7e030551ca5ab259727b6324dee2aafe2a5f Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 09:53:59 +0100 Subject: [PATCH 12/29] glib/sys: Don't generate UnixPipe That is part of glib-unix --- glib/sys/Gir.toml | 4 ++-- glib/sys/src/lib.rs | 28 ---------------------------- glib/sys/tests/abi.rs | 20 -------------------- glib/sys/tests/constant.c | 2 -- glib/sys/tests/layout.c | 2 -- 5 files changed, 2 insertions(+), 54 deletions(-) diff --git a/glib/sys/Gir.toml b/glib/sys/Gir.toml index e5340b26ca88..ef5d767c61f4 100644 --- a/glib/sys/Gir.toml +++ b/glib/sys/Gir.toml @@ -102,12 +102,12 @@ status = "manual" [[object]] name = "GLib.UnixPipe" -status = "generate" +status = "ignore" cfg_condition = "unix" [[object]] name = "GLib.UnixPipeEnd" -status = "generate" +status = "ignore" cfg_condition = "unix" [[object]] diff --git a/glib/sys/src/lib.rs b/glib/sys/src/lib.rs index c5d42d0a59af..0419472373c2 100644 --- a/glib/sys/src/lib.rs +++ b/glib/sys/src/lib.rs @@ -652,16 +652,6 @@ pub const G_UNICODE_LINE_SEPARATOR: GUnicodeType = 27; pub const G_UNICODE_PARAGRAPH_SEPARATOR: GUnicodeType = 28; pub const G_UNICODE_SPACE_SEPARATOR: GUnicodeType = 29; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub type GUnixPipeEnd = c_int; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub const G_UNIX_PIPE_END_READ: GUnixPipeEnd = 0; -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -pub const G_UNIX_PIPE_END_WRITE: GUnixPipeEnd = 1; - pub type GUriError = c_int; pub const G_URI_ERROR_FAILED: GUriError = 0; pub const G_URI_ERROR_BAD_SCHEME: GUriError = 1; @@ -2537,24 +2527,6 @@ impl ::std::fmt::Debug for GTuples { } } -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -#[derive(Copy, Clone)] -#[repr(C)] -pub struct GUnixPipe { - pub fds: [c_int; 2], -} - -#[cfg(unix)] -#[cfg_attr(docsrs, doc(cfg(unix)))] -impl ::std::fmt::Debug for GUnixPipe { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GUnixPipe @ {self:p}")) - .field("fds", &self.fds) - .finish() - } -} - #[repr(C)] #[allow(dead_code)] pub struct GUri { diff --git a/glib/sys/tests/abi.rs b/glib/sys/tests/abi.rs index 4b5856264169..7d37ad23ace9 100644 --- a/glib/sys/tests/abi.rs +++ b/glib/sys/tests/abi.rs @@ -922,24 +922,6 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[ alignment: align_of::(), }, ), - #[cfg(unix)] - #[cfg_attr(docsrs, doc(cfg(unix)))] - ( - "GUnixPipe", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - #[cfg(unix)] - #[cfg_attr(docsrs, doc(cfg(unix)))] - ( - "GUnixPipeEnd", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), ( "GUriError", Layout { @@ -1803,8 +1785,6 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_UNICODE_TITLECASE_LETTER", "8"), ("(gint) G_UNICODE_UNASSIGNED", "2"), ("(gint) G_UNICODE_UPPERCASE_LETTER", "9"), - ("(gint) G_UNIX_PIPE_END_READ", "0"), - ("(gint) G_UNIX_PIPE_END_WRITE", "1"), ("(gint) G_URI_ERROR_BAD_AUTH_PARAMS", "4"), ("(gint) G_URI_ERROR_BAD_FRAGMENT", "9"), ("(gint) G_URI_ERROR_BAD_HOST", "5"), diff --git a/glib/sys/tests/constant.c b/glib/sys/tests/constant.c index 7e6edfac1bf0..5ba7c2b0aa4f 100644 --- a/glib/sys/tests/constant.c +++ b/glib/sys/tests/constant.c @@ -784,8 +784,6 @@ int main() { PRINT_CONSTANT((gint) G_UNICODE_TITLECASE_LETTER); PRINT_CONSTANT((gint) G_UNICODE_UNASSIGNED); PRINT_CONSTANT((gint) G_UNICODE_UPPERCASE_LETTER); - PRINT_CONSTANT((gint) G_UNIX_PIPE_END_READ); - PRINT_CONSTANT((gint) G_UNIX_PIPE_END_WRITE); PRINT_CONSTANT((gint) G_URI_ERROR_BAD_AUTH_PARAMS); PRINT_CONSTANT((gint) G_URI_ERROR_BAD_FRAGMENT); PRINT_CONSTANT((gint) G_URI_ERROR_BAD_HOST); diff --git a/glib/sys/tests/layout.c b/glib/sys/tests/layout.c index d2f07408254e..fd4528a174a5 100644 --- a/glib/sys/tests/layout.c +++ b/glib/sys/tests/layout.c @@ -110,8 +110,6 @@ int main() { printf("%s;%zu;%zu\n", "GUnicodeBreakType", sizeof(GUnicodeBreakType), alignof(GUnicodeBreakType)); printf("%s;%zu;%zu\n", "GUnicodeScript", sizeof(GUnicodeScript), alignof(GUnicodeScript)); printf("%s;%zu;%zu\n", "GUnicodeType", sizeof(GUnicodeType), alignof(GUnicodeType)); - printf("%s;%zu;%zu\n", "GUnixPipe", sizeof(GUnixPipe), alignof(GUnixPipe)); - printf("%s;%zu;%zu\n", "GUnixPipeEnd", sizeof(GUnixPipeEnd), alignof(GUnixPipeEnd)); printf("%s;%zu;%zu\n", "GUriError", sizeof(GUriError), alignof(GUriError)); printf("%s;%zu;%zu\n", "GUriFlags", sizeof(GUriFlags), alignof(GUriFlags)); printf("%s;%zu;%zu\n", "GUriHideFlags", sizeof(GUriHideFlags), alignof(GUriHideFlags)); From 16f6b472ea6933a754bba7be6736ec1d1d03dd1b Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:07:49 +0100 Subject: [PATCH 13/29] Regenerate with fixed GIR files --- gdk-pixbuf/src/auto/versions.txt | 2 +- gdk-pixbuf/sys/versions.txt | 2 +- gio-unix/src/auto/versions.txt | 2 +- gio-unix/sys/versions.txt | 2 +- gio-win32/src/auto/versions.txt | 2 +- gio-win32/sys/versions.txt | 2 +- gio/src/auto/enums.rs | 272 ------------------------------- gio/src/auto/flags.rs | 247 ++++++++++++++++++++++++++++ gio/src/auto/mod.rs | 6 +- gio/src/auto/versions.txt | 2 +- gio/sys/src/lib.rs | 52 +++--- gio/sys/tests/abi.rs | 10 +- gio/sys/tests/constant.c | 10 +- gio/sys/versions.txt | 2 +- gir-files | 2 +- glib-unix/src/auto/versions.txt | 2 +- glib-unix/sys/src/lib.rs | 12 +- glib-unix/sys/versions.txt | 2 +- glib-win32/src/auto/versions.txt | 2 +- glib-win32/sys/versions.txt | 2 +- glib/gobject-sys/versions.txt | 2 +- glib/src/auto/flags.rs | 10 +- glib/src/auto/versions.txt | 2 +- glib/sys/src/lib.rs | 8 +- glib/sys/tests/abi.rs | 8 +- glib/sys/tests/constant.c | 8 +- glib/sys/versions.txt | 2 +- graphene/src/auto/versions.txt | 2 +- graphene/sys/versions.txt | 2 +- pango/src/auto/versions.txt | 2 +- pango/sys/versions.txt | 2 +- pangocairo/src/auto/versions.txt | 2 +- pangocairo/sys/versions.txt | 2 +- 33 files changed, 325 insertions(+), 362 deletions(-) diff --git a/gdk-pixbuf/src/auto/versions.txt b/gdk-pixbuf/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gdk-pixbuf/src/auto/versions.txt +++ b/gdk-pixbuf/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gdk-pixbuf/sys/versions.txt b/gdk-pixbuf/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gdk-pixbuf/sys/versions.txt +++ b/gdk-pixbuf/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio-unix/src/auto/versions.txt b/gio-unix/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio-unix/src/auto/versions.txt +++ b/gio-unix/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio-unix/sys/versions.txt b/gio-unix/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio-unix/sys/versions.txt +++ b/gio-unix/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio-win32/src/auto/versions.txt b/gio-win32/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio-win32/src/auto/versions.txt +++ b/gio-win32/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio-win32/sys/versions.txt b/gio-win32/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio-win32/sys/versions.txt +++ b/gio-win32/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio/src/auto/enums.rs b/gio/src/auto/enums.rs index baec67562163..5accb1fd8667 100644 --- a/gio/src/auto/enums.rs +++ b/gio/src/auto/enums.rs @@ -2277,98 +2277,6 @@ impl From for glib::Value { } } -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "GIOModuleScopeFlags")] -pub enum IOModuleScopeFlags { - #[doc(alias = "G_IO_MODULE_SCOPE_NONE")] - None, - #[doc(alias = "G_IO_MODULE_SCOPE_BLOCK_DUPLICATES")] - BlockDuplicates, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for IOModuleScopeFlags { - type GlibType = ffi::GIOModuleScopeFlags; - - #[inline] - fn into_glib(self) -> ffi::GIOModuleScopeFlags { - match self { - Self::None => ffi::G_IO_MODULE_SCOPE_NONE, - Self::BlockDuplicates => ffi::G_IO_MODULE_SCOPE_BLOCK_DUPLICATES, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for IOModuleScopeFlags { - #[inline] - unsafe fn from_glib(value: ffi::GIOModuleScopeFlags) -> Self { - match value { - ffi::G_IO_MODULE_SCOPE_NONE => Self::None, - ffi::G_IO_MODULE_SCOPE_BLOCK_DUPLICATES => Self::BlockDuplicates, - value => Self::__Unknown(value), - } - } -} - -impl StaticType for IOModuleScopeFlags { - #[inline] - #[doc(alias = "g_io_module_scope_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::g_io_module_scope_flags_get_type()) } - } -} - -impl glib::HasParamSpec for IOModuleScopeFlags { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -impl glib::value::ValueType for IOModuleScopeFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for IOModuleScopeFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -impl ToValue for IOModuleScopeFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: IOModuleScopeFlags) -> Self { - ToValue::to_value(&v) - } -} - #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] @@ -3941,94 +3849,6 @@ impl From for glib::Value { } } -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "GTlsCertificateRequestFlags")] -pub enum TlsCertificateRequestFlags { - #[doc(alias = "G_TLS_CERTIFICATE_REQUEST_NONE")] - None, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for TlsCertificateRequestFlags { - type GlibType = ffi::GTlsCertificateRequestFlags; - - #[inline] - fn into_glib(self) -> ffi::GTlsCertificateRequestFlags { - match self { - Self::None => ffi::G_TLS_CERTIFICATE_REQUEST_NONE, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for TlsCertificateRequestFlags { - #[inline] - unsafe fn from_glib(value: ffi::GTlsCertificateRequestFlags) -> Self { - match value { - ffi::G_TLS_CERTIFICATE_REQUEST_NONE => Self::None, - value => Self::__Unknown(value), - } - } -} - -impl StaticType for TlsCertificateRequestFlags { - #[inline] - #[doc(alias = "g_tls_certificate_request_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::g_tls_certificate_request_flags_get_type()) } - } -} - -impl glib::HasParamSpec for TlsCertificateRequestFlags { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -impl glib::value::ValueType for TlsCertificateRequestFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for TlsCertificateRequestFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -impl ToValue for TlsCertificateRequestFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: TlsCertificateRequestFlags) -> Self { - ToValue::to_value(&v) - } -} - #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] @@ -4291,98 +4111,6 @@ impl From for glib::Value { } } -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "GTlsDatabaseLookupFlags")] -pub enum TlsDatabaseLookupFlags { - #[doc(alias = "G_TLS_DATABASE_LOOKUP_NONE")] - None, - #[doc(alias = "G_TLS_DATABASE_LOOKUP_KEYPAIR")] - Keypair, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for TlsDatabaseLookupFlags { - type GlibType = ffi::GTlsDatabaseLookupFlags; - - #[inline] - fn into_glib(self) -> ffi::GTlsDatabaseLookupFlags { - match self { - Self::None => ffi::G_TLS_DATABASE_LOOKUP_NONE, - Self::Keypair => ffi::G_TLS_DATABASE_LOOKUP_KEYPAIR, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for TlsDatabaseLookupFlags { - #[inline] - unsafe fn from_glib(value: ffi::GTlsDatabaseLookupFlags) -> Self { - match value { - ffi::G_TLS_DATABASE_LOOKUP_NONE => Self::None, - ffi::G_TLS_DATABASE_LOOKUP_KEYPAIR => Self::Keypair, - value => Self::__Unknown(value), - } - } -} - -impl StaticType for TlsDatabaseLookupFlags { - #[inline] - #[doc(alias = "g_tls_database_lookup_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::g_tls_database_lookup_flags_get_type()) } - } -} - -impl glib::HasParamSpec for TlsDatabaseLookupFlags { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -impl glib::value::ValueType for TlsDatabaseLookupFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for TlsDatabaseLookupFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -impl ToValue for TlsDatabaseLookupFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: TlsDatabaseLookupFlags) -> Self { - ToValue::to_value(&v) - } -} - #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsError")] diff --git a/gio/src/auto/flags.rs b/gio/src/auto/flags.rs index 30046ab36d83..d6128cd0c246 100644 --- a/gio/src/auto/flags.rs +++ b/gio/src/auto/flags.rs @@ -2183,6 +2183,89 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GIOModuleScopeFlags")] + pub struct IOModuleScopeFlags: u32 { + #[doc(alias = "G_IO_MODULE_SCOPE_NONE")] + const NONE = ffi::G_IO_MODULE_SCOPE_NONE as _; + #[doc(alias = "G_IO_MODULE_SCOPE_BLOCK_DUPLICATES")] + const BLOCK_DUPLICATES = ffi::G_IO_MODULE_SCOPE_BLOCK_DUPLICATES as _; + } +} + +#[doc(hidden)] +impl IntoGlib for IOModuleScopeFlags { + type GlibType = ffi::GIOModuleScopeFlags; + + #[inline] + fn into_glib(self) -> ffi::GIOModuleScopeFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for IOModuleScopeFlags { + #[inline] + unsafe fn from_glib(value: ffi::GIOModuleScopeFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for IOModuleScopeFlags { + #[inline] + #[doc(alias = "g_io_module_scope_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_io_module_scope_flags_get_type()) } + } +} + +impl glib::HasParamSpec for IOModuleScopeFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for IOModuleScopeFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for IOModuleScopeFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for IOModuleScopeFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: IOModuleScopeFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GIOStreamSpliceFlags")] @@ -3154,6 +3237,170 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GTlsCertificateRequestFlags")] + pub struct TlsCertificateRequestFlags: u32 { + #[doc(alias = "G_TLS_CERTIFICATE_REQUEST_NONE")] + const NONE = ffi::G_TLS_CERTIFICATE_REQUEST_NONE as _; + } +} + +#[doc(hidden)] +impl IntoGlib for TlsCertificateRequestFlags { + type GlibType = ffi::GTlsCertificateRequestFlags; + + #[inline] + fn into_glib(self) -> ffi::GTlsCertificateRequestFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for TlsCertificateRequestFlags { + #[inline] + unsafe fn from_glib(value: ffi::GTlsCertificateRequestFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for TlsCertificateRequestFlags { + #[inline] + #[doc(alias = "g_tls_certificate_request_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_tls_certificate_request_flags_get_type()) } + } +} + +impl glib::HasParamSpec for TlsCertificateRequestFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for TlsCertificateRequestFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for TlsCertificateRequestFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for TlsCertificateRequestFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: TlsCertificateRequestFlags) -> Self { + ToValue::to_value(&v) + } +} + +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GTlsDatabaseLookupFlags")] + pub struct TlsDatabaseLookupFlags: u32 { + #[doc(alias = "G_TLS_DATABASE_LOOKUP_NONE")] + const NONE = ffi::G_TLS_DATABASE_LOOKUP_NONE as _; + #[doc(alias = "G_TLS_DATABASE_LOOKUP_KEYPAIR")] + const KEYPAIR = ffi::G_TLS_DATABASE_LOOKUP_KEYPAIR as _; + } +} + +#[doc(hidden)] +impl IntoGlib for TlsDatabaseLookupFlags { + type GlibType = ffi::GTlsDatabaseLookupFlags; + + #[inline] + fn into_glib(self) -> ffi::GTlsDatabaseLookupFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for TlsDatabaseLookupFlags { + #[inline] + unsafe fn from_glib(value: ffi::GTlsDatabaseLookupFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for TlsDatabaseLookupFlags { + #[inline] + #[doc(alias = "g_tls_database_lookup_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_tls_database_lookup_flags_get_type()) } + } +} + +impl glib::HasParamSpec for TlsDatabaseLookupFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for TlsDatabaseLookupFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for TlsDatabaseLookupFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for TlsDatabaseLookupFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: TlsDatabaseLookupFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GTlsDatabaseVerifyFlags")] diff --git a/gio/src/auto/mod.rs b/gio/src/auto/mod.rs index 9276ad7edbce..76e399780de0 100644 --- a/gio/src/auto/mod.rs +++ b/gio/src/auto/mod.rs @@ -502,7 +502,6 @@ pub use self::enums::FileMonitorEvent; pub use self::enums::FileType; pub use self::enums::FilesystemPreviewType; pub use self::enums::IOErrorEnum; -pub use self::enums::IOModuleScopeFlags; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use self::enums::MemoryMonitorWarningLevel; @@ -522,14 +521,12 @@ pub use self::enums::SocketListenerEvent; pub use self::enums::SocketProtocol; pub use self::enums::SocketType; pub use self::enums::TlsAuthenticationMode; -pub use self::enums::TlsCertificateRequestFlags; #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] pub use self::enums::TlsChannelBindingError; #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] pub use self::enums::TlsChannelBindingType; -pub use self::enums::TlsDatabaseLookupFlags; pub use self::enums::TlsError; pub use self::enums::TlsInteractionResult; #[cfg(feature = "v2_70")] @@ -568,6 +565,7 @@ pub use self::flags::FileCreateFlags; pub use self::flags::FileMeasureFlags; pub use self::flags::FileMonitorFlags; pub use self::flags::FileQueryInfoFlags; +pub use self::flags::IOModuleScopeFlags; pub use self::flags::IOStreamSpliceFlags; pub use self::flags::MountMountFlags; pub use self::flags::MountUnmountFlags; @@ -581,6 +579,8 @@ pub use self::flags::SettingsBindFlags; pub use self::flags::SubprocessFlags; pub use self::flags::TestDBusFlags; pub use self::flags::TlsCertificateFlags; +pub use self::flags::TlsCertificateRequestFlags; +pub use self::flags::TlsDatabaseLookupFlags; pub use self::flags::TlsDatabaseVerifyFlags; pub use self::flags::TlsPasswordFlags; diff --git a/gio/src/auto/versions.txt b/gio/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio/src/auto/versions.txt +++ b/gio/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gio/sys/src/lib.rs b/gio/sys/src/lib.rs index bd6ea785c6a0..1552aa1dd441 100644 --- a/gio/sys/src/lib.rs +++ b/gio/sys/src/lib.rs @@ -244,10 +244,6 @@ pub const G_IO_ERROR_MESSAGE_TOO_LARGE: GIOErrorEnum = 46; pub const G_IO_ERROR_NO_SUCH_DEVICE: GIOErrorEnum = 47; pub const G_IO_ERROR_DESTINATION_UNSET: GIOErrorEnum = 48; -pub type GIOModuleScopeFlags = c_int; -pub const G_IO_MODULE_SCOPE_NONE: GIOModuleScopeFlags = 0; -pub const G_IO_MODULE_SCOPE_BLOCK_DUPLICATES: GIOModuleScopeFlags = 1; - pub type GMemoryMonitorWarningLevel = c_int; pub const G_MEMORY_MONITOR_WARNING_LEVEL_LOW: GMemoryMonitorWarningLevel = 50; pub const G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM: GMemoryMonitorWarningLevel = 100; @@ -331,9 +327,6 @@ pub const G_TLS_AUTHENTICATION_NONE: GTlsAuthenticationMode = 0; pub const G_TLS_AUTHENTICATION_REQUESTED: GTlsAuthenticationMode = 1; pub const G_TLS_AUTHENTICATION_REQUIRED: GTlsAuthenticationMode = 2; -pub type GTlsCertificateRequestFlags = c_int; -pub const G_TLS_CERTIFICATE_REQUEST_NONE: GTlsCertificateRequestFlags = 0; - pub type GTlsChannelBindingError = c_int; pub const G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED: GTlsChannelBindingError = 0; pub const G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE: GTlsChannelBindingError = 1; @@ -346,10 +339,6 @@ pub const G_TLS_CHANNEL_BINDING_TLS_UNIQUE: GTlsChannelBindingType = 0; pub const G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT: GTlsChannelBindingType = 1; pub const G_TLS_CHANNEL_BINDING_TLS_EXPORTER: GTlsChannelBindingType = 2; -pub type GTlsDatabaseLookupFlags = c_int; -pub const G_TLS_DATABASE_LOOKUP_NONE: GTlsDatabaseLookupFlags = 0; -pub const G_TLS_DATABASE_LOOKUP_KEYPAIR: GTlsDatabaseLookupFlags = 1; - pub type GTlsError = c_int; pub const G_TLS_ERROR_UNAVAILABLE: GTlsError = 0; pub const G_TLS_ERROR_MISC: GTlsError = 1; @@ -678,6 +667,10 @@ pub type GFileQueryInfoFlags = c_uint; pub const G_FILE_QUERY_INFO_NONE: GFileQueryInfoFlags = 0; pub const G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS: GFileQueryInfoFlags = 1; +pub type GIOModuleScopeFlags = c_uint; +pub const G_IO_MODULE_SCOPE_NONE: GIOModuleScopeFlags = 0; +pub const G_IO_MODULE_SCOPE_BLOCK_DUPLICATES: GIOModuleScopeFlags = 1; + pub type GIOStreamSpliceFlags = c_uint; pub const G_IO_STREAM_SPLICE_NONE: GIOStreamSpliceFlags = 0; pub const G_IO_STREAM_SPLICE_CLOSE_STREAM1: GIOStreamSpliceFlags = 1; @@ -742,6 +735,13 @@ pub const G_TLS_CERTIFICATE_INSECURE: GTlsCertificateFlags = 32; pub const G_TLS_CERTIFICATE_GENERIC_ERROR: GTlsCertificateFlags = 64; pub const G_TLS_CERTIFICATE_VALIDATE_ALL: GTlsCertificateFlags = 127; +pub type GTlsCertificateRequestFlags = c_uint; +pub const G_TLS_CERTIFICATE_REQUEST_NONE: GTlsCertificateRequestFlags = 0; + +pub type GTlsDatabaseLookupFlags = c_uint; +pub const G_TLS_DATABASE_LOOKUP_NONE: GTlsDatabaseLookupFlags = 0; +pub const G_TLS_DATABASE_LOOKUP_KEYPAIR: GTlsDatabaseLookupFlags = 1; + pub type GTlsDatabaseVerifyFlags = c_uint; pub const G_TLS_DATABASE_VERIFY_NONE: GTlsDatabaseVerifyFlags = 0; @@ -9215,11 +9215,6 @@ extern "C" { //========================================================================= pub fn g_io_error_enum_get_type() -> GType; - //========================================================================= - // GIOModuleScopeFlags - //========================================================================= - pub fn g_io_module_scope_flags_get_type() -> GType; - //========================================================================= // GMemoryMonitorWarningLevel //========================================================================= @@ -9301,11 +9296,6 @@ extern "C" { //========================================================================= pub fn g_tls_authentication_mode_get_type() -> GType; - //========================================================================= - // GTlsCertificateRequestFlags - //========================================================================= - pub fn g_tls_certificate_request_flags_get_type() -> GType; - //========================================================================= // GTlsChannelBindingError //========================================================================= @@ -9323,11 +9313,6 @@ extern "C" { #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] pub fn g_tls_channel_binding_type_get_type() -> GType; - //========================================================================= - // GTlsDatabaseLookupFlags - //========================================================================= - pub fn g_tls_database_lookup_flags_get_type() -> GType; - //========================================================================= // GTlsError //========================================================================= @@ -9486,6 +9471,11 @@ extern "C" { //========================================================================= pub fn g_file_query_info_flags_get_type() -> GType; + //========================================================================= + // GIOModuleScopeFlags + //========================================================================= + pub fn g_io_module_scope_flags_get_type() -> GType; + //========================================================================= // GIOStreamSpliceFlags //========================================================================= @@ -9548,6 +9538,16 @@ extern "C" { //========================================================================= pub fn g_tls_certificate_flags_get_type() -> GType; + //========================================================================= + // GTlsCertificateRequestFlags + //========================================================================= + pub fn g_tls_certificate_request_flags_get_type() -> GType; + + //========================================================================= + // GTlsDatabaseLookupFlags + //========================================================================= + pub fn g_tls_database_lookup_flags_get_type() -> GType; + //========================================================================= // GTlsDatabaseVerifyFlags //========================================================================= diff --git a/gio/sys/tests/abi.rs b/gio/sys/tests/abi.rs index 5b019541a2b7..0c6f59d6d5b3 100644 --- a/gio/sys/tests/abi.rs +++ b/gio/sys/tests/abi.rs @@ -2725,8 +2725,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_IO_ERROR_WOULD_MERGE", "29"), ("(gint) G_IO_ERROR_WOULD_RECURSE", "25"), ("(gint) G_IO_ERROR_WRONG_ETAG", "23"), - ("(gint) G_IO_MODULE_SCOPE_BLOCK_DUPLICATES", "1"), - ("(gint) G_IO_MODULE_SCOPE_NONE", "0"), + ("(guint) G_IO_MODULE_SCOPE_BLOCK_DUPLICATES", "1"), + ("(guint) G_IO_MODULE_SCOPE_NONE", "0"), ("(guint) G_IO_STREAM_SPLICE_CLOSE_STREAM1", "1"), ("(guint) G_IO_STREAM_SPLICE_CLOSE_STREAM2", "2"), ("(guint) G_IO_STREAM_SPLICE_NONE", "0"), @@ -2863,7 +2863,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(guint) G_TLS_CERTIFICATE_INSECURE", "32"), ("(guint) G_TLS_CERTIFICATE_NOT_ACTIVATED", "4"), ("(guint) G_TLS_CERTIFICATE_NO_FLAGS", "0"), - ("(gint) G_TLS_CERTIFICATE_REQUEST_NONE", "0"), + ("(guint) G_TLS_CERTIFICATE_REQUEST_NONE", "0"), ("(guint) G_TLS_CERTIFICATE_REVOKED", "16"), ("(guint) G_TLS_CERTIFICATE_UNKNOWN_CA", "1"), ("(guint) G_TLS_CERTIFICATE_VALIDATE_ALL", "127"), @@ -2875,8 +2875,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_TLS_CHANNEL_BINDING_TLS_EXPORTER", "2"), ("(gint) G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT", "1"), ("(gint) G_TLS_CHANNEL_BINDING_TLS_UNIQUE", "0"), - ("(gint) G_TLS_DATABASE_LOOKUP_KEYPAIR", "1"), - ("(gint) G_TLS_DATABASE_LOOKUP_NONE", "0"), + ("(guint) G_TLS_DATABASE_LOOKUP_KEYPAIR", "1"), + ("(guint) G_TLS_DATABASE_LOOKUP_NONE", "0"), ( "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT", "1.3.6.1.5.5.7.3.2", diff --git a/gio/sys/tests/constant.c b/gio/sys/tests/constant.c index 7fea42930ea3..ea52e75d2ee1 100644 --- a/gio/sys/tests/constant.c +++ b/gio/sys/tests/constant.c @@ -408,8 +408,8 @@ int main() { PRINT_CONSTANT((gint) G_IO_ERROR_WOULD_MERGE); PRINT_CONSTANT((gint) G_IO_ERROR_WOULD_RECURSE); PRINT_CONSTANT((gint) G_IO_ERROR_WRONG_ETAG); - PRINT_CONSTANT((gint) G_IO_MODULE_SCOPE_BLOCK_DUPLICATES); - PRINT_CONSTANT((gint) G_IO_MODULE_SCOPE_NONE); + PRINT_CONSTANT((guint) G_IO_MODULE_SCOPE_BLOCK_DUPLICATES); + PRINT_CONSTANT((guint) G_IO_MODULE_SCOPE_NONE); PRINT_CONSTANT((guint) G_IO_STREAM_SPLICE_CLOSE_STREAM1); PRINT_CONSTANT((guint) G_IO_STREAM_SPLICE_CLOSE_STREAM2); PRINT_CONSTANT((guint) G_IO_STREAM_SPLICE_NONE); @@ -528,7 +528,7 @@ int main() { PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_INSECURE); PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_NOT_ACTIVATED); PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_NO_FLAGS); - PRINT_CONSTANT((gint) G_TLS_CERTIFICATE_REQUEST_NONE); + PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_REQUEST_NONE); PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_REVOKED); PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_UNKNOWN_CA); PRINT_CONSTANT((guint) G_TLS_CERTIFICATE_VALIDATE_ALL); @@ -540,8 +540,8 @@ int main() { PRINT_CONSTANT((gint) G_TLS_CHANNEL_BINDING_TLS_EXPORTER); PRINT_CONSTANT((gint) G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT); PRINT_CONSTANT((gint) G_TLS_CHANNEL_BINDING_TLS_UNIQUE); - PRINT_CONSTANT((gint) G_TLS_DATABASE_LOOKUP_KEYPAIR); - PRINT_CONSTANT((gint) G_TLS_DATABASE_LOOKUP_NONE); + PRINT_CONSTANT((guint) G_TLS_DATABASE_LOOKUP_KEYPAIR); + PRINT_CONSTANT((guint) G_TLS_DATABASE_LOOKUP_NONE); PRINT_CONSTANT(G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT); PRINT_CONSTANT(G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER); PRINT_CONSTANT((guint) G_TLS_DATABASE_VERIFY_NONE); diff --git a/gio/sys/versions.txt b/gio/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/gio/sys/versions.txt +++ b/gio/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/gir-files b/gir-files index 3b05ae05a285..6715d605e539 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 3b05ae05a28512e43194beceff147078da76e766 +Subproject commit 6715d605e539493e8a7ac1189445dafc70284a40 diff --git a/glib-unix/src/auto/versions.txt b/glib-unix/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib-unix/src/auto/versions.txt +++ b/glib-unix/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib-unix/sys/src/lib.rs b/glib-unix/sys/src/lib.rs index 03780176751b..11b3eed12e3b 100644 --- a/glib-unix/sys/src/lib.rs +++ b/glib-unix/sys/src/lib.rs @@ -61,27 +61,27 @@ extern "C" { //========================================================================= #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] - pub fn g_unix_pipe_clear(self_: *mut glib::GUnixPipe); + pub fn g_unix_pipe_clear(self_: *mut GUnixPipe); #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] pub fn g_unix_pipe_close( - self_: *mut glib::GUnixPipe, - end: glib::GUnixPipeEnd, + self_: *mut GUnixPipe, + end: GUnixPipeEnd, error: *mut *mut glib::GError, ) -> gboolean; #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] - pub fn g_unix_pipe_get(self_: *mut glib::GUnixPipe, end: glib::GUnixPipeEnd) -> c_int; + pub fn g_unix_pipe_get(self_: *mut GUnixPipe, end: GUnixPipeEnd) -> c_int; #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] pub fn g_unix_pipe_open( - self_: *mut glib::GUnixPipe, + self_: *mut GUnixPipe, flags: c_int, error: *mut *mut glib::GError, ) -> gboolean; #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] - pub fn g_unix_pipe_steal(self_: *mut glib::GUnixPipe, end: glib::GUnixPipeEnd) -> c_int; + pub fn g_unix_pipe_steal(self_: *mut GUnixPipe, end: GUnixPipeEnd) -> c_int; //========================================================================= // Other functions diff --git a/glib-unix/sys/versions.txt b/glib-unix/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib-unix/sys/versions.txt +++ b/glib-unix/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib-win32/src/auto/versions.txt b/glib-win32/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib-win32/src/auto/versions.txt +++ b/glib-win32/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib-win32/sys/versions.txt b/glib-win32/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib-win32/sys/versions.txt +++ b/glib-win32/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib/gobject-sys/versions.txt b/glib/gobject-sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib/gobject-sys/versions.txt +++ b/glib/gobject-sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib/src/auto/flags.rs b/glib/src/auto/flags.rs index 2f1774dec589..35bdab794917 100644 --- a/glib/src/auto/flags.rs +++ b/glib/src/auto/flags.rs @@ -400,14 +400,8 @@ bitflags! { const NEWLINE_CR = ffi::G_REGEX_NEWLINE_CR as _; #[doc(alias = "G_REGEX_NEWLINE_LF")] const NEWLINE_LF = ffi::G_REGEX_NEWLINE_LF as _; - #[doc(alias = "G_REGEX_NEWLINE_CRLF")] - const NEWLINE_CRLF = ffi::G_REGEX_NEWLINE_CRLF as _; - #[doc(alias = "G_REGEX_NEWLINE_ANYCRLF")] - const NEWLINE_ANYCRLF = ffi::G_REGEX_NEWLINE_ANYCRLF as _; - #[doc(alias = "G_REGEX_BSR_ANYCRLF")] - const BSR_ANYCRLF = ffi::G_REGEX_BSR_ANYCRLF as _; - #[doc(alias = "G_REGEX_JAVASCRIPT_COMPAT")] - const JAVASCRIPT_COMPAT = ffi::G_REGEX_JAVASCRIPT_COMPAT as _; + #[doc(alias = "G_REGEX_NEWLINE_RESERVED1")] + const NEWLINE_RESERVED1 = ffi::G_REGEX_NEWLINE_RESERVED1 as _; } } diff --git a/glib/src/auto/versions.txt b/glib/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib/src/auto/versions.txt +++ b/glib/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/glib/sys/src/lib.rs b/glib/sys/src/lib.rs index 0419472373c2..1fedb3bd440f 100644 --- a/glib/sys/src/lib.rs +++ b/glib/sys/src/lib.rs @@ -840,7 +840,7 @@ pub const G_FORMAT_SIZE_ONLY_UNIT: GFormatSizeFlags = 16; pub type GHookFlagMask = c_uint; pub const G_HOOK_FLAG_ACTIVE: GHookFlagMask = 1; pub const G_HOOK_FLAG_IN_CALL: GHookFlagMask = 2; -pub const G_HOOK_FLAG_MASK: GHookFlagMask = 15; +pub const G_HOOK_FLAG_RESERVED1: GHookFlagMask = 4; pub type GIOCondition = c_uint; pub const G_IO_IN: GIOCondition = 1; @@ -926,10 +926,7 @@ pub const G_REGEX_FIRSTLINE: GRegexCompileFlags = 262144; pub const G_REGEX_DUPNAMES: GRegexCompileFlags = 524288; pub const G_REGEX_NEWLINE_CR: GRegexCompileFlags = 1048576; pub const G_REGEX_NEWLINE_LF: GRegexCompileFlags = 2097152; -pub const G_REGEX_NEWLINE_CRLF: GRegexCompileFlags = 3145728; -pub const G_REGEX_NEWLINE_ANYCRLF: GRegexCompileFlags = 5242880; -pub const G_REGEX_BSR_ANYCRLF: GRegexCompileFlags = 8388608; -pub const G_REGEX_JAVASCRIPT_COMPAT: GRegexCompileFlags = 33554432; +pub const G_REGEX_NEWLINE_RESERVED1: GRegexCompileFlags = 4194304; pub type GRegexMatchFlags = c_uint; pub const G_REGEX_MATCH_DEFAULT: GRegexMatchFlags = 0; @@ -975,6 +972,7 @@ pub const G_TEST_SUBPROCESS_DEFAULT: GTestSubprocessFlags = 0; pub const G_TEST_SUBPROCESS_INHERIT_STDIN: GTestSubprocessFlags = 1; pub const G_TEST_SUBPROCESS_INHERIT_STDOUT: GTestSubprocessFlags = 2; pub const G_TEST_SUBPROCESS_INHERIT_STDERR: GTestSubprocessFlags = 4; +pub const G_TEST_SUBPROCESS_INHERIT_DESCRIPTORS: GTestSubprocessFlags = 8; pub type GTestTrapFlags = c_uint; pub const G_TEST_TRAP_DEFAULT: GTestTrapFlags = 0; diff --git a/glib/sys/tests/abi.rs b/glib/sys/tests/abi.rs index 7d37ad23ace9..512ba22d912a 100644 --- a/glib/sys/tests/abi.rs +++ b/glib/sys/tests/abi.rs @@ -1130,7 +1130,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(guint) G_FORMAT_SIZE_ONLY_VALUE", "8"), ("(guint) G_HOOK_FLAG_ACTIVE", "1"), ("(guint) G_HOOK_FLAG_IN_CALL", "2"), - ("(guint) G_HOOK_FLAG_MASK", "15"), + ("(guint) G_HOOK_FLAG_RESERVED1", "4"), ("G_HOOK_FLAG_USER_SHIFT", "4"), ("G_IEEE754_DOUBLE_BIAS", "1023"), ("G_IEEE754_FLOAT_BIAS", "127"), @@ -1288,7 +1288,6 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("G_PRIORITY_LOW", "300"), ("G_REF_COUNT_INIT", "-1"), ("(guint) G_REGEX_ANCHORED", "16"), - ("(guint) G_REGEX_BSR_ANYCRLF", "8388608"), ("(guint) G_REGEX_CASELESS", "1"), ("(guint) G_REGEX_DEFAULT", "0"), ("(guint) G_REGEX_DOLLAR_ENDONLY", "32"), @@ -1380,7 +1379,6 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND", "125"), ("(guint) G_REGEX_EXTENDED", "8"), ("(guint) G_REGEX_FIRSTLINE", "262144"), - ("(guint) G_REGEX_JAVASCRIPT_COMPAT", "33554432"), ("(guint) G_REGEX_MATCH_ANCHORED", "16"), ("(guint) G_REGEX_MATCH_BSR_ANY", "16777216"), ("(guint) G_REGEX_MATCH_BSR_ANYCRLF", "8388608"), @@ -1398,10 +1396,9 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(guint) G_REGEX_MATCH_PARTIAL_HARD", "134217728"), ("(guint) G_REGEX_MATCH_PARTIAL_SOFT", "32768"), ("(guint) G_REGEX_MULTILINE", "2"), - ("(guint) G_REGEX_NEWLINE_ANYCRLF", "5242880"), ("(guint) G_REGEX_NEWLINE_CR", "1048576"), - ("(guint) G_REGEX_NEWLINE_CRLF", "3145728"), ("(guint) G_REGEX_NEWLINE_LF", "2097152"), + ("(guint) G_REGEX_NEWLINE_RESERVED1", "4194304"), ("(guint) G_REGEX_NO_AUTO_CAPTURE", "4096"), ("(guint) G_REGEX_OPTIMIZE", "8192"), ("(guint) G_REGEX_RAW", "2048"), @@ -1478,6 +1475,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_TEST_RUN_SKIPPED", "1"), ("(gint) G_TEST_RUN_SUCCESS", "0"), ("(guint) G_TEST_SUBPROCESS_DEFAULT", "0"), + ("(guint) G_TEST_SUBPROCESS_INHERIT_DESCRIPTORS", "8"), ("(guint) G_TEST_SUBPROCESS_INHERIT_STDERR", "4"), ("(guint) G_TEST_SUBPROCESS_INHERIT_STDIN", "1"), ("(guint) G_TEST_SUBPROCESS_INHERIT_STDOUT", "2"), diff --git a/glib/sys/tests/constant.c b/glib/sys/tests/constant.c index 5ba7c2b0aa4f..8edf50c73a4b 100644 --- a/glib/sys/tests/constant.c +++ b/glib/sys/tests/constant.c @@ -156,7 +156,7 @@ int main() { PRINT_CONSTANT((guint) G_FORMAT_SIZE_ONLY_VALUE); PRINT_CONSTANT((guint) G_HOOK_FLAG_ACTIVE); PRINT_CONSTANT((guint) G_HOOK_FLAG_IN_CALL); - PRINT_CONSTANT((guint) G_HOOK_FLAG_MASK); + PRINT_CONSTANT((guint) G_HOOK_FLAG_RESERVED1); PRINT_CONSTANT(G_HOOK_FLAG_USER_SHIFT); PRINT_CONSTANT(G_IEEE754_DOUBLE_BIAS); PRINT_CONSTANT(G_IEEE754_FLOAT_BIAS); @@ -314,7 +314,6 @@ int main() { PRINT_CONSTANT(G_PRIORITY_LOW); PRINT_CONSTANT(G_REF_COUNT_INIT); PRINT_CONSTANT((guint) G_REGEX_ANCHORED); - PRINT_CONSTANT((guint) G_REGEX_BSR_ANYCRLF); PRINT_CONSTANT((guint) G_REGEX_CASELESS); PRINT_CONSTANT((guint) G_REGEX_DEFAULT); PRINT_CONSTANT((guint) G_REGEX_DOLLAR_ENDONLY); @@ -379,7 +378,6 @@ int main() { PRINT_CONSTANT((gint) G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND); PRINT_CONSTANT((guint) G_REGEX_EXTENDED); PRINT_CONSTANT((guint) G_REGEX_FIRSTLINE); - PRINT_CONSTANT((guint) G_REGEX_JAVASCRIPT_COMPAT); PRINT_CONSTANT((guint) G_REGEX_MATCH_ANCHORED); PRINT_CONSTANT((guint) G_REGEX_MATCH_BSR_ANY); PRINT_CONSTANT((guint) G_REGEX_MATCH_BSR_ANYCRLF); @@ -397,10 +395,9 @@ int main() { PRINT_CONSTANT((guint) G_REGEX_MATCH_PARTIAL_HARD); PRINT_CONSTANT((guint) G_REGEX_MATCH_PARTIAL_SOFT); PRINT_CONSTANT((guint) G_REGEX_MULTILINE); - PRINT_CONSTANT((guint) G_REGEX_NEWLINE_ANYCRLF); PRINT_CONSTANT((guint) G_REGEX_NEWLINE_CR); - PRINT_CONSTANT((guint) G_REGEX_NEWLINE_CRLF); PRINT_CONSTANT((guint) G_REGEX_NEWLINE_LF); + PRINT_CONSTANT((guint) G_REGEX_NEWLINE_RESERVED1); PRINT_CONSTANT((guint) G_REGEX_NO_AUTO_CAPTURE); PRINT_CONSTANT((guint) G_REGEX_OPTIMIZE); PRINT_CONSTANT((guint) G_REGEX_RAW); @@ -477,6 +474,7 @@ int main() { PRINT_CONSTANT((gint) G_TEST_RUN_SKIPPED); PRINT_CONSTANT((gint) G_TEST_RUN_SUCCESS); PRINT_CONSTANT((guint) G_TEST_SUBPROCESS_DEFAULT); + PRINT_CONSTANT((guint) G_TEST_SUBPROCESS_INHERIT_DESCRIPTORS); PRINT_CONSTANT((guint) G_TEST_SUBPROCESS_INHERIT_STDERR); PRINT_CONSTANT((guint) G_TEST_SUBPROCESS_INHERIT_STDIN); PRINT_CONSTANT((guint) G_TEST_SUBPROCESS_INHERIT_STDOUT); diff --git a/glib/sys/versions.txt b/glib/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/glib/sys/versions.txt +++ b/glib/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/graphene/src/auto/versions.txt b/graphene/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/graphene/src/auto/versions.txt +++ b/graphene/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/graphene/sys/versions.txt b/graphene/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/graphene/sys/versions.txt +++ b/graphene/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/pango/src/auto/versions.txt b/pango/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/pango/src/auto/versions.txt +++ b/pango/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/pango/sys/versions.txt b/pango/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/pango/sys/versions.txt +++ b/pango/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/pangocairo/src/auto/versions.txt b/pangocairo/src/auto/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/pangocairo/src/auto/versions.txt +++ b/pangocairo/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) diff --git a/pangocairo/sys/versions.txt b/pangocairo/sys/versions.txt index b47135b9caf9..88cd8449e044 100644 --- a/pangocairo/sys/versions.txt +++ b/pangocairo/sys/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 1d0088ebcb66) -from gir-files (https://github.com/gtk-rs/gir-files @ 3b05ae05a285+) +from gir-files (https://github.com/gtk-rs/gir-files @ 6715d605e539) From 932bfd158c189508b5f390e837b2032b21fb8f79 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:14:23 +0100 Subject: [PATCH 14/29] glib/source: Fix imports on Win32 --- glib/src/source.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/glib/src/source.rs b/glib/src/source.rs index ca83225d833a..41a807f00233 100644 --- a/glib/src/source.rs +++ b/glib/src/source.rs @@ -1,11 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(unix)] use std::{cell::RefCell, mem::transmute, num::NonZeroU32, time::Duration}; use crate::ffi::{self, gboolean, gpointer}; -#[cfg(all(not(unix), docsrs))] -use libc::c_int as RawFd; use crate::{thread_guard::ThreadGuard, translate::*, ControlFlow, MainContext, Source}; From 1a30afa5c980468ec3e69e02f886e47acfc206da Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:19:56 +0100 Subject: [PATCH 15/29] glib/win32: Add missing imports --- glib-win32/src/functions.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glib-win32/src/functions.rs b/glib-win32/src/functions.rs index ed88838d16d9..12b222143fd5 100644 --- a/glib-win32/src/functions.rs +++ b/glib-win32/src/functions.rs @@ -1,4 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::translate::*; +use std::path::PathBuf; #[doc(alias = "g_win32_get_package_installation_directory_of_module")] #[doc(alias = "get_package_installation_directory_of_module")] From cc795e31e4be4f9b7833a13aa7993413520f0132 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:34:37 +0100 Subject: [PATCH 16/29] gio/win32: Manually implement streams Copying what we had in gio where it makes sense --- gio-win32/Gir.toml | 30 +++++++++- gio-win32/src/auto/input_stream.rs | 23 ++------ gio-win32/src/auto/output_stream.rs | 23 ++------ gio-win32/src/input_stream.rs | 57 ++++++++++++++++++ gio-win32/src/lib.rs | 3 + gio-win32/src/output_stream.rs | 57 ++++++++++++++++++ gio/src/lib.rs | 10 ---- gio/src/prelude.rs | 4 -- gio/src/win32_input_stream.rs | 91 ----------------------------- gio/src/win32_output_stream.rs | 91 ----------------------------- 10 files changed, 155 insertions(+), 234 deletions(-) create mode 100644 gio-win32/src/input_stream.rs create mode 100644 gio-win32/src/output_stream.rs delete mode 100644 gio/src/win32_input_stream.rs delete mode 100644 gio/src/win32_output_stream.rs diff --git a/gio-win32/Gir.toml b/gio-win32/Gir.toml index cea44f8e6b8d..69c7fb232aea 100644 --- a/gio-win32/Gir.toml +++ b/gio-win32/Gir.toml @@ -11,8 +11,6 @@ deprecate_by_min_version = true trust_return_value_nullability = true generate = [ - "GioWin32.InputStream", - "GioWin32.OutputStream" #"GioWin32.NetworkMonitor", ] @@ -28,3 +26,31 @@ manual = [ [[object]] name = "GioWin32.*" status = "generate" + +[[object]] +name = "GioWin32.InputStream" +status = "generate" +manual_traits = ["InputStreamExtManual"] + [[object.function]] + name = "new" + manual = true + [[object.function]] + name = "set_close_handle" + unsafe = true + [[object.function]] + name = "get_handle" + manual = true + +[[object]] +name = "GioWin32.OutputStream" +status = "generate" +manual_traits = ["OutputStreamExtManual"] + [[object.function]] + name = "new" + manual = true + [[object.function]] + name = "set_close_handle" + unsafe = true + [[object.function]] + name = "get_handle" + manual = true diff --git a/gio-win32/src/auto/input_stream.rs b/gio-win32/src/auto/input_stream.rs index db6d629de766..a0b18cc9e8df 100644 --- a/gio-win32/src/auto/input_stream.rs +++ b/gio-win32/src/auto/input_stream.rs @@ -21,11 +21,6 @@ glib::wrapper! { impl InputStream { pub const NONE: Option<&'static InputStream> = None; - - //#[doc(alias = "g_win32_input_stream_new")] - //pub fn new(handle: /*Unimplemented*/Option, close_handle: bool) -> InputStream { - // unsafe { TODO: call ffi:g_win32_input_stream_new() } - //} } pub trait InputStreamExt: IsA + 'static { @@ -40,21 +35,13 @@ pub trait InputStreamExt: IsA + 'static { } } - //#[doc(alias = "g_win32_input_stream_get_handle")] - //#[doc(alias = "get_handle")] - //fn handle(&self) -> /*Unimplemented*/Option { - // unsafe { TODO: call ffi:g_win32_input_stream_get_handle() } - //} - #[doc(alias = "g_win32_input_stream_set_close_handle")] #[doc(alias = "close-handle")] - fn set_close_handle(&self, close_handle: bool) { - unsafe { - ffi::g_win32_input_stream_set_close_handle( - self.as_ref().to_glib_none().0, - close_handle.into_glib(), - ); - } + unsafe fn set_close_handle(&self, close_handle: bool) { + ffi::g_win32_input_stream_set_close_handle( + self.as_ref().to_glib_none().0, + close_handle.into_glib(), + ); } #[doc(alias = "close-handle")] diff --git a/gio-win32/src/auto/output_stream.rs b/gio-win32/src/auto/output_stream.rs index f01561183eec..84195db1708d 100644 --- a/gio-win32/src/auto/output_stream.rs +++ b/gio-win32/src/auto/output_stream.rs @@ -21,11 +21,6 @@ glib::wrapper! { impl OutputStream { pub const NONE: Option<&'static OutputStream> = None; - - //#[doc(alias = "g_win32_output_stream_new")] - //pub fn new(handle: /*Unimplemented*/Option, close_handle: bool) -> OutputStream { - // unsafe { TODO: call ffi:g_win32_output_stream_new() } - //} } pub trait OutputStreamExt: IsA + 'static { @@ -40,21 +35,13 @@ pub trait OutputStreamExt: IsA + 'static { } } - //#[doc(alias = "g_win32_output_stream_get_handle")] - //#[doc(alias = "get_handle")] - //fn handle(&self) -> /*Unimplemented*/Option { - // unsafe { TODO: call ffi:g_win32_output_stream_get_handle() } - //} - #[doc(alias = "g_win32_output_stream_set_close_handle")] #[doc(alias = "close-handle")] - fn set_close_handle(&self, close_handle: bool) { - unsafe { - ffi::g_win32_output_stream_set_close_handle( - self.as_ref().to_glib_none().0, - close_handle.into_glib(), - ); - } + unsafe fn set_close_handle(&self, close_handle: bool) { + ffi::g_win32_output_stream_set_close_handle( + self.as_ref().to_glib_none().0, + close_handle.into_glib(), + ); } #[doc(alias = "close-handle")] diff --git a/gio-win32/src/input_stream.rs b/gio-win32/src/input_stream.rs new file mode 100644 index 000000000000..c17fd9006653 --- /dev/null +++ b/gio-win32/src/input_stream.rs @@ -0,0 +1,57 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; + +use glib::{prelude::*, translate::*}; + +use crate::{ffi, InputStream}; + +impl InputStream { + // rustdoc-stripper-ignore-next + /// Creates a new [`Self`] that takes ownership of the passed in handle. + /// + /// # Safety + /// You must not close the handle unless you've previously called [`InputStreamExtManual::set_close_handle`] + /// with `true` on this stream. At which point you may only do so when all references to this + /// stream have been dropped. + #[doc(alias = "g_win32_input_stream_new")] + pub unsafe fn take_handle(handle: impl IntoRawHandle) -> InputStream { + let handle = handle.into_raw_handle(); + let close_handle = true.into_glib(); + gio::InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) + .unsafe_cast() + } + + // rustdoc-stripper-ignore-next + /// Creates a new [`Self`] that does not take ownership of the passed in handle. + /// + /// # Safety + /// You may only close the handle if all references to this stream have been dropped. + #[doc(alias = "g_win32_input_stream_new")] + pub unsafe fn with_handle(handle: T) -> InputStream { + let handle = handle.as_raw_handle(); + let close_handle = false.into_glib(); + gio::InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) + .unsafe_cast() + } +} + +impl AsRawHandle for InputStream { + fn as_raw_handle(&self) -> RawHandle { + unsafe { ffi::g_win32_input_stream_get_handle(self.to_glib_none().0) as _ } + } +} + +pub trait InputStreamExtManual: IsA + Sized { + #[doc(alias = "g_win32_input_stream_get_handle")] + #[doc(alias = "get_handle")] + fn handle(&self) -> T { + unsafe { + T::from_raw_handle(ffi::g_win32_input_stream_get_handle( + self.as_ref().to_glib_none().0, + )) + } + } +} + +impl> InputStreamExtManual for O {} diff --git a/gio-win32/src/lib.rs b/gio-win32/src/lib.rs index 9ef6070874ac..4cc829356655 100644 --- a/gio-win32/src/lib.rs +++ b/gio-win32/src/lib.rs @@ -5,6 +5,9 @@ pub use ffi; mod auto; pub use auto::*; +mod input_stream; +mod output_stream; + pub mod functions { pub use super::auto::functions::*; } diff --git a/gio-win32/src/output_stream.rs b/gio-win32/src/output_stream.rs new file mode 100644 index 000000000000..e9c381889538 --- /dev/null +++ b/gio-win32/src/output_stream.rs @@ -0,0 +1,57 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; + +use glib::{prelude::*, translate::*}; + +use crate::{ffi, OutputStream}; + +impl OutputStream { + // rustdoc-stripper-ignore-next + /// Creates a new [`Self`] that takes ownership of the passed in handle. + /// + /// # Safety + /// You must not close the handle unless you've previously called [`OutputStreamExtManual::set_close_handle`] + /// with `true` on this stream. At which point you may only do so when all references to this + /// stream have been dropped. + #[doc(alias = "g_win32_output_stream_new")] + pub unsafe fn take_handle(handle: impl IntoRawHandle) -> OutputStream { + let handle = handle.into_raw_handle(); + let close_handle = true.into_glib(); + gio::OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) + .unsafe_cast() + } + + // rustdoc-stripper-ignore-next + /// Creates a new [`Self`] that does not take ownership of the passed in handle. + /// + /// # Safety + /// You may only close the handle if all references to this stream have been dropped. + #[doc(alias = "g_win32_output_stream_new")] + pub unsafe fn with_handle(handle: T) -> OutputStream { + let handle = handle.as_raw_handle(); + let close_handle = false.into_glib(); + gio::OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) + .unsafe_cast() + } +} + +impl AsRawHandle for OutputStream { + fn as_raw_handle(&self) -> RawHandle { + unsafe { ffi::g_win32_output_stream_get_handle(self.to_glib_none().0) as _ } + } +} + +pub trait OutputStreamExtManual: IsA + Sized { + #[doc(alias = "g_win32_output_stream_get_handle")] + #[doc(alias = "get_handle")] + fn handle(&self) -> T { + unsafe { + T::from_raw_handle(ffi::g_win32_output_stream_get_handle( + self.as_ref().to_glib_none().0, + )) + } + } +} + +impl> OutputStreamExtManual for O {} diff --git a/gio/src/lib.rs b/gio/src/lib.rs index 3bd29f513c3f..b6caa9ee0a5c 100644 --- a/gio/src/lib.rs +++ b/gio/src/lib.rs @@ -132,13 +132,3 @@ mod write_output_stream; pub use crate::write_output_stream::WriteOutputStream; mod dbus_proxy; mod tls_connection; - -#[cfg(windows)] -mod win32_input_stream; -#[cfg(windows)] -pub use self::win32_input_stream::Win32InputStream; - -#[cfg(windows)] -mod win32_output_stream; -#[cfg(windows)] -pub use self::win32_output_stream::Win32OutputStream; diff --git a/gio/src/prelude.rs b/gio/src/prelude.rs index 2f57968a45c1..536ace6b7bee 100644 --- a/gio/src/prelude.rs +++ b/gio/src/prelude.rs @@ -11,10 +11,6 @@ pub use crate::app_info::AppInfoExtManual; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use crate::debug_controller_dbus::DebugControllerDBusExtManual; -#[cfg(windows)] -pub use crate::win32_input_stream::Win32InputStreamExt; -#[cfg(windows)] -pub use crate::win32_output_stream::Win32OutputStreamExt; pub use crate::{ action_map::ActionMapExtManual, application::ApplicationExtManual, application_command_line::ApplicationCommandLineExtManual, auto::traits::*, diff --git a/gio/src/win32_input_stream.rs b/gio/src/win32_input_stream.rs deleted file mode 100644 index e2f0fe044aed..000000000000 --- a/gio/src/win32_input_stream.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; - -use glib::{prelude::*, translate::*}; - -use crate::{ffi, InputStream}; - -glib::wrapper! { - pub struct Win32InputStream(Object) @extends InputStream; - - match fn { - type_ => || ffi::g_win32_input_stream_get_type(), - } -} - -impl Win32InputStream { - pub const NONE: Option<&'static Win32InputStream> = None; - - // rustdoc-stripper-ignore-next - /// Creates a new [`Self`] that takes ownership of the passed in handle. - /// - /// # Safety - /// You must not close the handle unless you've previously called [`Win32InputStreamExtManual::set_close_handle`] - /// with `true` on this stream. At which point you may only do so when all references to this - /// stream have been dropped. - #[doc(alias = "g_win32_input_stream_new")] - pub unsafe fn take_handle(handle: impl IntoRawHandle) -> Win32InputStream { - let handle = handle.into_raw_handle(); - let close_handle = true.into_glib(); - InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) - .unsafe_cast() - } - - // rustdoc-stripper-ignore-next - /// Creates a new [`Self`] that does not take ownership of the passed in handle. - /// - /// # Safety - /// You may only close the handle if all references to this stream have been dropped. - #[doc(alias = "g_win32_input_stream_new")] - pub unsafe fn with_handle(handle: T) -> Win32InputStream { - let handle = handle.as_raw_handle(); - let close_handle = false.into_glib(); - InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) - .unsafe_cast() - } -} - -impl AsRawHandle for Win32InputStream { - fn as_raw_handle(&self) -> RawHandle { - unsafe { ffi::g_win32_input_stream_get_handle(self.to_glib_none().0) as _ } - } -} - -pub trait Win32InputStreamExt: IsA + Sized { - #[doc(alias = "g_win32_input_stream_get_close_handle")] - #[doc(alias = "get_close_handle")] - fn closes_handle(&self) -> bool { - unsafe { - from_glib(ffi::g_win32_input_stream_get_close_handle( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "g_win32_input_stream_get_handle")] - #[doc(alias = "get_handle")] - fn handle(&self) -> T { - unsafe { - T::from_raw_handle(ffi::g_win32_input_stream_get_handle( - self.as_ref().to_glib_none().0, - )) - } - } - - // rustdoc-stripper-ignore-next - /// Sets whether the handle of this stream will be closed when the stream is closed. - /// - /// # Safety - /// If you pass in `false` as the parameter, you may only close the handle if the all references - /// to the stream have been dropped. If you pass in `true`, you must never call close. - #[doc(alias = "g_win32_input_stream_set_close_handle")] - unsafe fn set_close_handle(&self, close_handle: bool) { - ffi::g_win32_input_stream_set_close_handle( - self.as_ref().to_glib_none().0, - close_handle.into_glib(), - ); - } -} - -impl> Win32InputStreamExt for O {} diff --git a/gio/src/win32_output_stream.rs b/gio/src/win32_output_stream.rs deleted file mode 100644 index b68a027d33a2..000000000000 --- a/gio/src/win32_output_stream.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; - -use glib::{prelude::*, translate::*}; - -use crate::{ffi, OutputStream}; - -glib::wrapper! { - pub struct Win32OutputStream(Object) @extends OutputStream; - - match fn { - type_ => || ffi::g_win32_output_stream_get_type(), - } -} - -impl Win32OutputStream { - pub const NONE: Option<&'static Win32OutputStream> = None; - - // rustdoc-stripper-ignore-next - /// Creates a new [`Self`] that takes ownership of the passed in handle. - /// - /// # Safety - /// You must not close the handle unless you've previously called [`Win32OutputStreamExtManual::set_close_handle`] - /// with `true` on this stream. At which point you may only do so when all references to this - /// stream have been dropped. - #[doc(alias = "g_win32_output_stream_new")] - pub unsafe fn take_handle(handle: impl IntoRawHandle) -> Win32OutputStream { - let handle = handle.into_raw_handle(); - let close_handle = true.into_glib(); - OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) - .unsafe_cast() - } - - // rustdoc-stripper-ignore-next - /// Creates a new [`Self`] that does not take ownership of the passed in handle. - /// - /// # Safety - /// You may only close the handle if all references to this stream have been dropped. - #[doc(alias = "g_win32_output_stream_new")] - pub unsafe fn with_handle(handle: T) -> Win32OutputStream { - let handle = handle.as_raw_handle(); - let close_handle = false.into_glib(); - OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) - .unsafe_cast() - } -} - -impl AsRawHandle for Win32OutputStream { - fn as_raw_handle(&self) -> RawHandle { - unsafe { ffi::g_win32_output_stream_get_handle(self.to_glib_none().0) as _ } - } -} - -pub trait Win32OutputStreamExt: IsA + Sized { - #[doc(alias = "g_win32_output_stream_get_close_handle")] - #[doc(alias = "get_close_handle")] - fn closes_handle(&self) -> bool { - unsafe { - from_glib(ffi::g_win32_output_stream_get_close_handle( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "g_win32_output_stream_get_handle")] - #[doc(alias = "get_handle")] - fn handle(&self) -> T { - unsafe { - T::from_raw_handle(ffi::g_win32_output_stream_get_handle( - self.as_ref().to_glib_none().0, - )) - } - } - - // rustdoc-stripper-ignore-next - /// Sets whether the handle of this stream will be closed when the stream is closed. - /// - /// # Safety - /// If you pass in `false` as the parameter, you may only close the handle if the all references - /// to the stream have been dropped. If you pass in `true`, you must never call close. - #[doc(alias = "g_win32_output_stream_set_close_handle")] - unsafe fn set_close_handle(&self, close_handle: bool) { - ffi::g_win32_output_stream_set_close_handle( - self.as_ref().to_glib_none().0, - close_handle.into_glib(), - ); - } -} - -impl> Win32OutputStreamExt for O {} From 15f8adeacf9f9639e733762c7685d069a79845c9 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:48:21 +0100 Subject: [PATCH 17/29] gio/win32: Add a type for GNetworkMonitorBase and drop duplicated manual ones --- gio-win32/sys/src/manual.rs | 126 +----------------------------------- 1 file changed, 2 insertions(+), 124 deletions(-) diff --git a/gio-win32/sys/src/manual.rs b/gio-win32/sys/src/manual.rs index 902551ba74e4..ba7e4cca3cb5 100644 --- a/gio-win32/sys/src/manual.rs +++ b/gio-win32/sys/src/manual.rs @@ -1,11 +1,6 @@ -use libc::c_void; - pub type GSocketFamily = libc::c_int; pub type GSocketMsgFlags = libc::c_int; -use gio_sys::{GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass}; -use glib_sys::{gboolean, GType}; - pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = windows_sys::Win32::Networking::WinSock::MSG_OOB; @@ -14,122 +9,5 @@ pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE; -extern "C" { - //========================================================================= - // GWin32InputStream - //========================================================================= - pub fn g_win32_input_stream_get_type() -> GType; - pub fn g_win32_input_stream_new( - handle: *mut c_void, - close_handle: gboolean, - ) -> *mut GInputStream; - pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; - pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; - pub fn g_win32_input_stream_set_close_handle( - stream: *mut GWin32InputStream, - close_handle: gboolean, - ); - - //========================================================================= - // GWin32OutputStream - //========================================================================= - pub fn g_win32_output_stream_get_type() -> GType; - pub fn g_win32_output_stream_new( - handle: *mut c_void, - close_handle: gboolean, - ) -> *mut GOutputStream; - pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; - pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; - pub fn g_win32_output_stream_set_close_handle( - stream: *mut GWin32OutputStream, - close_handle: gboolean, - ); -} - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct GWin32InputStreamClass { - pub parent_class: GInputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, -} - -impl ::std::fmt::Debug for GWin32InputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32InputStreamClass @ {:?}", self as *const _)) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } -} - -#[repr(C)] -pub struct _GWin32InputStreamPrivate(c_void); - -pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate; - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct GWin32InputStream { - pub parent_instance: GInputStream, - pub priv_: *mut GWin32InputStreamPrivate, -} - -impl ::std::fmt::Debug for GWin32InputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32InputStream @ {:?}", self as *const _)) - .field("parent_instance", &self.parent_instance) - .finish() - } -} - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct GWin32OutputStreamClass { - pub parent_class: GOutputStreamClass, - pub _g_reserved1: Option, - pub _g_reserved2: Option, - pub _g_reserved3: Option, - pub _g_reserved4: Option, - pub _g_reserved5: Option, -} - -impl ::std::fmt::Debug for GWin32OutputStreamClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}", self as *const _)) - .field("parent_class", &self.parent_class) - .field("_g_reserved1", &self._g_reserved1) - .field("_g_reserved2", &self._g_reserved2) - .field("_g_reserved3", &self._g_reserved3) - .field("_g_reserved4", &self._g_reserved4) - .field("_g_reserved5", &self._g_reserved5) - .finish() - } -} - -#[repr(C)] -pub struct _GWin32OutputStreamPrivate(c_void); - -pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate; - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct GWin32OutputStream { - pub parent_instance: GOutputStream, - pub priv_: *mut GWin32OutputStreamPrivate, -} - -impl ::std::fmt::Debug for GWin32OutputStream { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GWin32OutputStream @ {:?}", self as *const _)) - .field("parent_instance", &self.parent_instance) - .finish() - } -} +pub type GNetworkMonitorBase = glib_sys::gpointer; +pub type GNetworkMonitorBaseClass = glib_sys::gpointer; From 540606879654abadd63cb41f6cde541791651380 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:57:39 +0100 Subject: [PATCH 18/29] gio/win32: Add missing dep --- Cargo.lock | 1 + gio-win32/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 1aae7cc7d183..101751ffd420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -556,6 +556,7 @@ dependencies = [ "gio", "gio-win32-sys", "gir-format-check", + "glib", "libc", "tempfile", ] diff --git a/gio-win32/Cargo.toml b/gio-win32/Cargo.toml index cc1fad766540..65d245a37cfc 100644 --- a/gio-win32/Cargo.toml +++ b/gio-win32/Cargo.toml @@ -18,6 +18,7 @@ version.workspace = true ffi = { package = "gio-win32-sys", path = "./sys"} libc.workspace = true gio.workspace = true +glib.workspace = true [dev-dependencies] tempfile = "3" From c3ee432a93a0c564f20d4f376f8ecb71e32df8d0 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 10:58:26 +0100 Subject: [PATCH 19/29] deny: Drop no longer needed skips --- deny.toml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/deny.toml b/deny.toml index 7a0d6a754786..b9b13f8b9083 100644 --- a/deny.toml +++ b/deny.toml @@ -24,15 +24,6 @@ multiple-versions = "deny" wildcards = "allow" highlight = "all" -# system-deps depends on an old version -[[bans.skip]] -name = "toml_edit" -version = "0.22" - -[[bans.skip]] -name = "toml_datetime" -version = "0.6" - [sources] unknown-registry = "deny" unknown-git = "deny" From 81ef004b0a59bd6e0d542356f808541331b8f5df Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 27 Nov 2025 11:11:56 +0100 Subject: [PATCH 20/29] Add missing licenses --- gio-unix/COPYRIGHT | 1 + gio-unix/LICENSE | 1 + gio-unix/sys/COPYRIGHT | 1 + gio-unix/sys/LICENSE | 1 + gio-win32/COPYRIGHT | 1 + gio-win32/LICENSE | 1 + gio-win32/sys/COPYRIGHT | 1 + gio-win32/sys/LICENSE | 1 + glib-unix/COPYRIGHT | 1 + glib-unix/LICENSE | 1 + glib-unix/sys/COPYRIGHT | 1 + glib-unix/sys/LICENSE | 1 + glib-win32/COPYRIGHT | 1 + glib-win32/LICENSE | 1 + glib-win32/sys/COPYRIGHT | 1 + glib-win32/sys/LICENSE | 1 + 16 files changed, 16 insertions(+) create mode 120000 gio-unix/COPYRIGHT create mode 120000 gio-unix/LICENSE create mode 120000 gio-unix/sys/COPYRIGHT create mode 120000 gio-unix/sys/LICENSE create mode 120000 gio-win32/COPYRIGHT create mode 120000 gio-win32/LICENSE create mode 120000 gio-win32/sys/COPYRIGHT create mode 120000 gio-win32/sys/LICENSE create mode 120000 glib-unix/COPYRIGHT create mode 120000 glib-unix/LICENSE create mode 120000 glib-unix/sys/COPYRIGHT create mode 120000 glib-unix/sys/LICENSE create mode 120000 glib-win32/COPYRIGHT create mode 120000 glib-win32/LICENSE create mode 120000 glib-win32/sys/COPYRIGHT create mode 120000 glib-win32/sys/LICENSE diff --git a/gio-unix/COPYRIGHT b/gio-unix/COPYRIGHT new file mode 120000 index 000000000000..dc5f40a221a3 --- /dev/null +++ b/gio-unix/COPYRIGHT @@ -0,0 +1 @@ +../COPYRIGHT \ No newline at end of file diff --git a/gio-unix/LICENSE b/gio-unix/LICENSE new file mode 120000 index 000000000000..ea5b60640b01 --- /dev/null +++ b/gio-unix/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/gio-unix/sys/COPYRIGHT b/gio-unix/sys/COPYRIGHT new file mode 120000 index 000000000000..8b0161cc93b2 --- /dev/null +++ b/gio-unix/sys/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/gio-unix/sys/LICENSE b/gio-unix/sys/LICENSE new file mode 120000 index 000000000000..30cff7403da0 --- /dev/null +++ b/gio-unix/sys/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/gio-win32/COPYRIGHT b/gio-win32/COPYRIGHT new file mode 120000 index 000000000000..dc5f40a221a3 --- /dev/null +++ b/gio-win32/COPYRIGHT @@ -0,0 +1 @@ +../COPYRIGHT \ No newline at end of file diff --git a/gio-win32/LICENSE b/gio-win32/LICENSE new file mode 120000 index 000000000000..ea5b60640b01 --- /dev/null +++ b/gio-win32/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/gio-win32/sys/COPYRIGHT b/gio-win32/sys/COPYRIGHT new file mode 120000 index 000000000000..8b0161cc93b2 --- /dev/null +++ b/gio-win32/sys/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/gio-win32/sys/LICENSE b/gio-win32/sys/LICENSE new file mode 120000 index 000000000000..30cff7403da0 --- /dev/null +++ b/gio-win32/sys/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/glib-unix/COPYRIGHT b/glib-unix/COPYRIGHT new file mode 120000 index 000000000000..dc5f40a221a3 --- /dev/null +++ b/glib-unix/COPYRIGHT @@ -0,0 +1 @@ +../COPYRIGHT \ No newline at end of file diff --git a/glib-unix/LICENSE b/glib-unix/LICENSE new file mode 120000 index 000000000000..ea5b60640b01 --- /dev/null +++ b/glib-unix/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/glib-unix/sys/COPYRIGHT b/glib-unix/sys/COPYRIGHT new file mode 120000 index 000000000000..8b0161cc93b2 --- /dev/null +++ b/glib-unix/sys/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/glib-unix/sys/LICENSE b/glib-unix/sys/LICENSE new file mode 120000 index 000000000000..30cff7403da0 --- /dev/null +++ b/glib-unix/sys/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/glib-win32/COPYRIGHT b/glib-win32/COPYRIGHT new file mode 120000 index 000000000000..dc5f40a221a3 --- /dev/null +++ b/glib-win32/COPYRIGHT @@ -0,0 +1 @@ +../COPYRIGHT \ No newline at end of file diff --git a/glib-win32/LICENSE b/glib-win32/LICENSE new file mode 120000 index 000000000000..ea5b60640b01 --- /dev/null +++ b/glib-win32/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/glib-win32/sys/COPYRIGHT b/glib-win32/sys/COPYRIGHT new file mode 120000 index 000000000000..8b0161cc93b2 --- /dev/null +++ b/glib-win32/sys/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/glib-win32/sys/LICENSE b/glib-win32/sys/LICENSE new file mode 120000 index 000000000000..30cff7403da0 --- /dev/null +++ b/glib-win32/sys/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file From 13bdfb6df92ff90abbcf0be902089c47f5ad98ef Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 30 Nov 2025 12:19:28 +0100 Subject: [PATCH 21/29] Adapt to rust nightly docs changes --- gio-unix/Cargo.toml | 4 ++-- gio-unix/sys/Cargo.toml | 3 +-- gio-win32/Cargo.toml | 3 +-- gio-win32/sys/Cargo.toml | 3 +-- glib-unix/Cargo.toml | 3 +-- glib-unix/sys/Cargo.toml | 3 +-- glib-win32/Cargo.toml | 3 +-- glib-win32/sys/Cargo.toml | 3 +-- 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/gio-unix/Cargo.toml b/gio-unix/Cargo.toml index 1ac134abe2f6..11fd0a9dfa28 100644 --- a/gio-unix/Cargo.toml +++ b/gio-unix/Cargo.toml @@ -33,5 +33,5 @@ v2_84 = ["v2_82", "ffi/v2_84", "gio/v2_84"] [package.metadata.docs.rs] all-features = true -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +rustdoc-args = ["--generate-link-to-definition"] + diff --git a/gio-unix/sys/Cargo.toml b/gio-unix/sys/Cargo.toml index f3a660919e51..43a9f5ea9d50 100644 --- a/gio-unix/sys/Cargo.toml +++ b/gio-unix/sys/Cargo.toml @@ -32,9 +32,8 @@ version = "2.82" version = "2.84" [package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] all-features = true +rustdoc-args = ["--generate-link-to-definition"] [lib] name = "gio_unix_sys" diff --git a/gio-win32/Cargo.toml b/gio-win32/Cargo.toml index 65d245a37cfc..76731e0aa394 100644 --- a/gio-win32/Cargo.toml +++ b/gio-win32/Cargo.toml @@ -34,5 +34,4 @@ v2_84 = ["v2_82", "ffi/v2_84", "gio/v2_84"] [package.metadata.docs.rs] all-features = true -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +rustdoc-args = ["--generate-link-to-definition"] diff --git a/gio-win32/sys/Cargo.toml b/gio-win32/sys/Cargo.toml index 1b2b901bd30e..d95c1a35b12f 100644 --- a/gio-win32/sys/Cargo.toml +++ b/gio-win32/sys/Cargo.toml @@ -16,9 +16,8 @@ version = "2.56" version = "2.78" [package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] all-features = true +rustdoc-args = ["--generate-link-to-definition"] [lib] name = "gio_win32_sys" diff --git a/glib-unix/Cargo.toml b/glib-unix/Cargo.toml index 61f5952853ea..aefa4cabf49f 100644 --- a/glib-unix/Cargo.toml +++ b/glib-unix/Cargo.toml @@ -30,5 +30,4 @@ v2_80 = ["ffi/v2_80", "glib/v2_80"] [package.metadata.docs.rs] all-features = true -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +rustdoc-args = ["--generate-link-to-definition"] diff --git a/glib-unix/sys/Cargo.toml b/glib-unix/sys/Cargo.toml index 52e9a879feae..34f817ba83b8 100644 --- a/glib-unix/sys/Cargo.toml +++ b/glib-unix/sys/Cargo.toml @@ -16,9 +16,8 @@ version = "2.56" version = "2.80" [package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] all-features = true +rustdoc-args = ["--generate-link-to-definition"] [lib] name = "glib_unix_sys" diff --git a/glib-win32/Cargo.toml b/glib-win32/Cargo.toml index c3ad78898ae8..bac10c5a0734 100644 --- a/glib-win32/Cargo.toml +++ b/glib-win32/Cargo.toml @@ -27,5 +27,4 @@ default = [] [package.metadata.docs.rs] all-features = true -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +rustdoc-args = ["--generate-link-to-definition"] diff --git a/glib-win32/sys/Cargo.toml b/glib-win32/sys/Cargo.toml index 4fc09d56187d..d0e1d021e6db 100644 --- a/glib-win32/sys/Cargo.toml +++ b/glib-win32/sys/Cargo.toml @@ -13,9 +13,8 @@ name = "glib-2.0" version = "2.56" [package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] all-features = true +rustdoc-args = ["--generate-link-to-definition"] [dependencies] libc = "0.2" From de079bf4b4b1f08555b5d116d368421c7baabb38 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 10:37:46 +0100 Subject: [PATCH 22/29] gio: Move test to gio-unix As it uses gio::FdMessage which was moved to gio-unix. --- gio-unix/Gir.toml | 3 ++ gio-unix/src/auto/fd_message.rs | 30 -------------- gio-unix/src/fd_message.rs | 73 +++++++++++++++++++++++++++++++++ gio/src/socket.rs | 69 ------------------------------- 4 files changed, 76 insertions(+), 99 deletions(-) diff --git a/gio-unix/Gir.toml b/gio-unix/Gir.toml index 3c8991d40b3e..6bfafd376e74 100644 --- a/gio-unix/Gir.toml +++ b/gio-unix/Gir.toml @@ -66,6 +66,9 @@ manual_traits = ["DesktopAppInfoExtManual"] name = "GioUnix.FDMessage" status = "generate" manual_traits = ["FDMessageExtManual"] + [[object.function]] + pattern = "(append_fd|steal_fds)" + manual = true [[object]] name = "GioUnix.FileDescriptorBased" diff --git a/gio-unix/src/auto/fd_message.rs b/gio-unix/src/auto/fd_message.rs index 8008faa7f0b3..635192921fb8 100644 --- a/gio-unix/src/auto/fd_message.rs +++ b/gio-unix/src/auto/fd_message.rs @@ -43,21 +43,6 @@ impl Default for FDMessage { } pub trait FDMessageExt: IsA + 'static { - #[doc(alias = "g_unix_fd_message_append_fd")] - fn append_fd(&self, fd: i32) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = - ffi::g_unix_fd_message_append_fd(self.as_ref().to_glib_none().0, fd, &mut error); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - #[doc(alias = "g_unix_fd_message_get_fd_list")] #[doc(alias = "get_fd_list")] #[doc(alias = "fd-list")] @@ -68,21 +53,6 @@ pub trait FDMessageExt: IsA + 'static { )) } } - - #[doc(alias = "g_unix_fd_message_steal_fds")] - fn steal_fds(&self) -> Vec { - unsafe { - let mut length = std::mem::MaybeUninit::uninit(); - let ret = FromGlibContainer::from_glib_full_num( - ffi::g_unix_fd_message_steal_fds( - self.as_ref().to_glib_none().0, - length.as_mut_ptr(), - ), - length.assume_init() as _, - ); - ret - } - } } impl> FDMessageExt for O {} diff --git a/gio-unix/src/fd_message.rs b/gio-unix/src/fd_message.rs index 584a3d21e631..ac70f13334b1 100644 --- a/gio-unix/src/fd_message.rs +++ b/gio-unix/src/fd_message.rs @@ -41,3 +41,76 @@ pub trait FDMessageExtManual: IsA + Sized { } impl> FDMessageExtManual for O {} + +#[cfg(test)] +mod tests { + use std::{ + io, + os::unix::io::{AsRawFd, FromRawFd, OwnedFd}, + }; + + use crate::prelude::*; + use gio::prelude::UnixFDListExt; + use gio::Cancellable; + use gio::Socket; + use glib::prelude::Cast; + + #[test] + fn socket_messages() { + let mut fds = [0 as libc::c_int; 2]; + let (out_sock, in_sock) = unsafe { + let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()); + if ret != 0 { + panic!("{}", io::Error::last_os_error()); + } + ( + Socket::from_fd(OwnedFd::from_raw_fd(fds[0])).unwrap(), + Socket::from_fd(OwnedFd::from_raw_fd(fds[1])).unwrap(), + ) + }; + + let fd_msg = crate::FDMessage::new(); + fd_msg.append_fd(out_sock.as_raw_fd()).unwrap(); + let vs = [gio::OutputVector::new(&[0])]; + let ctrl_msgs = [fd_msg.upcast()]; + let mut out_msg = [gio::OutputMessage::new( + gio::SocketAddress::NONE, + vs.as_slice(), + ctrl_msgs.as_slice(), + )]; + let written = gio::prelude::SocketExtManual::send_messages( + &out_sock, + out_msg.as_mut_slice(), + 0, + Cancellable::NONE, + ) + .unwrap(); + assert_eq!(written, 1); + assert_eq!(out_msg[0].bytes_sent(), 1); + + let mut v = [0u8]; + let mut vs = [gio::InputVector::new(v.as_mut_slice())]; + let mut ctrl_msgs = gio::SocketControlMessages::new(); + let mut in_msg = [gio::InputMessage::new( + None, + vs.as_mut_slice(), + Some(&mut ctrl_msgs), + )]; + let received = gio::prelude::SocketExtManual::receive_messages( + &in_sock, + in_msg.as_mut_slice(), + 0, + Cancellable::NONE, + ) + .unwrap(); + + assert_eq!(received, 1); + assert_eq!(in_msg[0].bytes_received(), 1); + assert_eq!(ctrl_msgs.len(), 1); + let fds = ctrl_msgs[0] + .downcast_ref::() + .unwrap() + .fd_list(); + assert_eq!(fds.length(), 1); + } +} diff --git a/gio/src/socket.rs b/gio/src/socket.rs index 494dd3743e1b..cd85d7931893 100644 --- a/gio/src/socket.rs +++ b/gio/src/socket.rs @@ -825,75 +825,6 @@ pub type RawSocket = *mut std::os::raw::c_void; #[cfg(test)] mod tests { - /* - #[test] - #[cfg(unix)] - fn socket_messages() { - use std::{ - io, - os::unix::io::{AsRawFd, FromRawFd, OwnedFd}, - }; - - use super::Socket; - use crate::{prelude::*, Cancellable, UnixFDMessage}; - - let mut fds = [0 as libc::c_int; 2]; - let (out_sock, in_sock) = unsafe { - let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()); - if ret != 0 { - panic!("{}", io::Error::last_os_error()); - } - ( - Socket::from_fd(OwnedFd::from_raw_fd(fds[0])).unwrap(), - Socket::from_fd(OwnedFd::from_raw_fd(fds[1])).unwrap(), - ) - }; - - let fd_msg = UnixFDMessage::new(); - fd_msg.append_fd(out_sock.as_raw_fd()).unwrap(); - let vs = [super::OutputVector::new(&[0])]; - let ctrl_msgs = [fd_msg.upcast()]; - let mut out_msg = [super::OutputMessage::new( - crate::SocketAddress::NONE, - vs.as_slice(), - ctrl_msgs.as_slice(), - )]; - let written = super::SocketExtManual::send_messages( - &out_sock, - out_msg.as_mut_slice(), - 0, - Cancellable::NONE, - ) - .unwrap(); - assert_eq!(written, 1); - assert_eq!(out_msg[0].bytes_sent(), 1); - - let mut v = [0u8]; - let mut vs = [super::InputVector::new(v.as_mut_slice())]; - let mut ctrl_msgs = super::SocketControlMessages::new(); - let mut in_msg = [super::InputMessage::new( - None, - vs.as_mut_slice(), - Some(&mut ctrl_msgs), - )]; - let received = super::SocketExtManual::receive_messages( - &in_sock, - in_msg.as_mut_slice(), - 0, - Cancellable::NONE, - ) - .unwrap(); - - assert_eq!(received, 1); - assert_eq!(in_msg[0].bytes_received(), 1); - assert_eq!(ctrl_msgs.len(), 1); - let fds = ctrl_msgs[0] - .downcast_ref::() - .unwrap() - .fd_list(); - assert_eq!(fds.length(), 1); - } - */ #[test] #[cfg(unix)] fn dgram_socket_messages() { From 1174b5d33e04ae4c066fc73491043aa14fe41374 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 10:40:41 +0100 Subject: [PATCH 23/29] gdk-pixbuf: Ignore another clippy lint Requires fixing gir --- gdk-pixbuf/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/gdk-pixbuf/src/lib.rs b/gdk-pixbuf/src/lib.rs index abe7836b0a69..e4056846d93f 100644 --- a/gdk-pixbuf/src/lib.rs +++ b/gdk-pixbuf/src/lib.rs @@ -10,6 +10,7 @@ pub use glib; #[allow(clippy::too_many_arguments)] #[allow(unused_imports)] +#[allow(clippy::empty_line_after_outer_attr)] mod auto; pub mod subclass; From 0b0a99960e92ab3b566f8c493229e7db9d0e7798 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 10:52:36 +0100 Subject: [PATCH 24/29] Fix docs for new crates By adding missing README & doc cfg --- .github/workflows/docs.yml | 1 + gio-unix/README.md | 44 ++++++++++++++++++++++++++++++++++++++ gio-unix/src/lib.rs | 3 +++ gio-unix/sys/Cargo.toml | 3 +++ gio-win32/README.md | 44 ++++++++++++++++++++++++++++++++++++++ gio-win32/src/lib.rs | 3 +++ gio-win32/sys/Cargo.toml | 3 +++ glib-unix/README.md | 44 ++++++++++++++++++++++++++++++++++++++ glib-unix/src/lib.rs | 2 ++ glib-unix/sys/Cargo.toml | 3 +++ glib-win32/README.md | 44 ++++++++++++++++++++++++++++++++++++++ glib-win32/src/lib.rs | 2 ++ glib-win32/sys/Cargo.toml | 3 +++ 13 files changed, 199 insertions(+) create mode 100644 gio-unix/README.md create mode 100644 gio-win32/README.md create mode 100644 glib-unix/README.md create mode 100644 glib-win32/README.md diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 50b2d8e39b9c..faf71afddc26 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,6 +23,7 @@ jobs: 0.17=0.17 0.16=0.16 RUSTDOCFLAGS: --cfg docsrs -Zunstable-options --generate-link-to-definition + DOCS_RS: 1 steps: - uses: actions/checkout@v6 with: diff --git a/gio-unix/README.md b/gio-unix/README.md new file mode 100644 index 000000000000..5c149b4b8fa2 --- /dev/null +++ b/gio-unix/README.md @@ -0,0 +1,44 @@ +# Rust Gio Unix bindings + +__Rust__ bindings and wrappers for [gio](https://docs.gtk.org/gio/), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). + +Gio __2.56__ is the lowest supported version for the underlying library. + +## Minimum supported Rust version + +Currently, the minimum supported Rust version is `1.83.0`. + +## Documentation + + * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio_unix/) + * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/gio_unix) + * [GTK Installation instructions](https://www.gtk.org/docs/installations/) + +## Using + +We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), +as [demonstrated here](https://gtk-rs.org/#using). + +If you want to track the bleeding edge, use the git dependency instead: + +```toml +[dependencies] +gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } +``` + +Avoid mixing versioned and git crates like this: + +```toml +# This will not compile +[dependencies] +glib = "0.13" +gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } +``` + +### See Also + + * [glib](https://crates.io/crates/glib) + +## License + +__gio-unix__ is available under the MIT License, please refer to it. diff --git a/gio-unix/src/lib.rs b/gio-unix/src/lib.rs index d51692422ff2..7587d0d72c1a 100644 --- a/gio-unix/src/lib.rs +++ b/gio-unix/src/lib.rs @@ -1,5 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] + pub use ffi; #[allow(unused_imports)] diff --git a/gio-unix/sys/Cargo.toml b/gio-unix/sys/Cargo.toml index 43a9f5ea9d50..dcffa15dde83 100644 --- a/gio-unix/sys/Cargo.toml +++ b/gio-unix/sys/Cargo.toml @@ -8,6 +8,9 @@ workspace = true [package.edition] workspace = true +[package.license] +workspace = true + [package.metadata.system-deps.glib_2_0] name = "glib-2.0" version = "2.56" diff --git a/gio-win32/README.md b/gio-win32/README.md new file mode 100644 index 000000000000..9e3175b02883 --- /dev/null +++ b/gio-win32/README.md @@ -0,0 +1,44 @@ +# Rust Gio Win32 bindings + +__Rust__ bindings and wrappers for [gio](https://docs.gtk.org/gio/), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). + +Gio __2.56__ is the lowest supported version for the underlying library. + +## Minimum supported Rust version + +Currently, the minimum supported Rust version is `1.83.0`. + +## Documentation + + * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio_win32/) + * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/gio_win32) + * [GTK Installation instructions](https://www.gtk.org/docs/installations/) + +## Using + +We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), +as [demonstrated here](https://gtk-rs.org/#using). + +If you want to track the bleeding edge, use the git dependency instead: + +```toml +[dependencies] +gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } +``` + +Avoid mixing versioned and git crates like this: + +```toml +# This will not compile +[dependencies] +glib = "0.13" +gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } +``` + +### See Also + + * [glib](https://crates.io/crates/glib) + +## License + +__gio-win32__ is available under the MIT License, please refer to it. diff --git a/gio-win32/src/lib.rs b/gio-win32/src/lib.rs index 4cc829356655..47936c4f61c8 100644 --- a/gio-win32/src/lib.rs +++ b/gio-win32/src/lib.rs @@ -1,5 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] + pub use ffi; mod auto; diff --git a/gio-win32/sys/Cargo.toml b/gio-win32/sys/Cargo.toml index d95c1a35b12f..8b53d9e4dc47 100644 --- a/gio-win32/sys/Cargo.toml +++ b/gio-win32/sys/Cargo.toml @@ -8,6 +8,9 @@ workspace = true [package.edition] workspace = true +[package.license] +workspace = true + [package.metadata.system-deps.gio_windows_2_0] name = "gio-windows-2.0" version = "2.56" diff --git a/glib-unix/README.md b/glib-unix/README.md new file mode 100644 index 000000000000..c352aca99988 --- /dev/null +++ b/glib-unix/README.md @@ -0,0 +1,44 @@ +# Rust GLib Unix bindings + +__Rust__ bindings and wrappers for [glib](https://docs.gtk.org/glib/), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). + +GLib __2.56__ is the lowest supported version for the underlying library. + +## Minimum supported Rust version + +Currently, the minimum supported Rust version is `1.83.0`. + +## Documentation + + * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib_unix/) + * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/glib_unix) + * [GTK Installation instructions](https://www.gtk.org/docs/installations/) + +## Using + +We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), +as [demonstrated here](https://gtk-rs.org/#using). + +If you want to track the bleeding edge, use the git dependency instead: + +```toml +[dependencies] +glib = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "glib" } +``` + +Avoid mixing versioned and git crates like this: + +```toml +# This will not compile +[dependencies] +glib = "0.13" +glib = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "glib" } +``` + +### See Also + + * [gio](https://crates.io/crates/gio) + +## License + +__glib-unix__ is available under the MIT License, please refer to it. diff --git a/glib-unix/src/lib.rs b/glib-unix/src/lib.rs index b06f81315a81..aacb7bb7ffbe 100644 --- a/glib-unix/src/lib.rs +++ b/glib-unix/src/lib.rs @@ -1,5 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] pub use ffi; mod auto; diff --git a/glib-unix/sys/Cargo.toml b/glib-unix/sys/Cargo.toml index 34f817ba83b8..79de53ebbb73 100644 --- a/glib-unix/sys/Cargo.toml +++ b/glib-unix/sys/Cargo.toml @@ -8,6 +8,9 @@ workspace = true [package.edition] workspace = true +[package.license] +workspace = true + [package.metadata.system-deps.glib_2_0] name = "glib-2.0" version = "2.56" diff --git a/glib-win32/README.md b/glib-win32/README.md new file mode 100644 index 000000000000..c6035b6adfe5 --- /dev/null +++ b/glib-win32/README.md @@ -0,0 +1,44 @@ +# Rust GLib Win32 bindings + +__Rust__ bindings and wrappers for [glib](https://docs.gtk.org/glib/), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). + +GLib __2.56__ is the lowest supported version for the underlying library. + +## Minimum supported Rust version + +Currently, the minimum supported Rust version is `1.83.0`. + +## Documentation + + * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib_win32/) + * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/glib_win32) + * [GTK Installation instructions](https://www.gtk.org/docs/installations/) + +## Using + +We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), +as [demonstrated here](https://gtk-rs.org/#using). + +If you want to track the bleeding edge, use the git dependency instead: + +```toml +[dependencies] +glib = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "glib" } +``` + +Avoid mixing versioned and git crates like this: + +```toml +# This will not compile +[dependencies] +glib = "0.13" +glib = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "glib" } +``` + +### See Also + + * [gio](https://crates.io/crates/gio) + +## License + +__glib-win32 is available under the MIT License, please refer to it. diff --git a/glib-win32/src/lib.rs b/glib-win32/src/lib.rs index 2e49f777503d..3f3a0486681b 100644 --- a/glib-win32/src/lib.rs +++ b/glib-win32/src/lib.rs @@ -1,5 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] pub use ffi; mod auto; diff --git a/glib-win32/sys/Cargo.toml b/glib-win32/sys/Cargo.toml index d0e1d021e6db..c7cbe08dfd52 100644 --- a/glib-win32/sys/Cargo.toml +++ b/glib-win32/sys/Cargo.toml @@ -8,6 +8,9 @@ workspace = true [package.edition] workspace = true +[package.license] +workspace = true + [package.metadata.system-deps.glib_2_0] name = "glib-2.0" version = "2.56" From 80f816782eccdf22f7244ef8ea13e062ec35ee0e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 10:57:08 +0100 Subject: [PATCH 25/29] Force update windows-sys for new crates --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 101751ffd420..07b93d15fefa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,7 +521,7 @@ dependencies = [ "shell-words", "system-deps", "tempfile", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -572,7 +572,7 @@ dependencies = [ "shell-words", "system-deps", "tempfile", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] From 3f72bfbad4a08344adb72e5d91d27117e1e5cbbc Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 10:58:23 +0100 Subject: [PATCH 26/29] win32: Always depend on windows-sys No need for cfg(windows) anymore. --- gio-win32/sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio-win32/sys/Cargo.toml b/gio-win32/sys/Cargo.toml index 8b53d9e4dc47..dd8396e1428d 100644 --- a/gio-win32/sys/Cargo.toml +++ b/gio-win32/sys/Cargo.toml @@ -37,7 +37,7 @@ workspace = true [dependencies.gio-sys] workspace = true -[target."cfg(windows)".dependencies.windows-sys] +[dependencies.windows-sys] version = ">=0.52, <=0.61" features = ["Win32_Networking_WinSock"] From 47206a3b107fcd9ed68257ae009ec94f02acd9e2 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 11:08:44 +0100 Subject: [PATCH 27/29] win32: Guard std::os::windows usage Otherwise we fail to find std::os::windows when building docs --- gio-win32/src/input_stream.rs | 1 + gio-win32/src/output_stream.rs | 1 + glib-win32/src/functions.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/gio-win32/src/input_stream.rs b/gio-win32/src/input_stream.rs index c17fd9006653..c353685783d3 100644 --- a/gio-win32/src/input_stream.rs +++ b/gio-win32/src/input_stream.rs @@ -1,5 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(any(windows, docsrs))] use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; diff --git a/gio-win32/src/output_stream.rs b/gio-win32/src/output_stream.rs index e9c381889538..183a4a4192ec 100644 --- a/gio-win32/src/output_stream.rs +++ b/gio-win32/src/output_stream.rs @@ -1,5 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(any(windows, docsrs))] use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; diff --git a/glib-win32/src/functions.rs b/glib-win32/src/functions.rs index 12b222143fd5..750327bfb040 100644 --- a/glib-win32/src/functions.rs +++ b/glib-win32/src/functions.rs @@ -4,6 +4,7 @@ use std::path::PathBuf; #[doc(alias = "g_win32_get_package_installation_directory_of_module")] #[doc(alias = "get_package_installation_directory_of_module")] +#[cfg(all(docsrs, windows))] pub fn package_installation_directory_of_module( hmodule: std::os::windows::raw::HANDLE, ) -> Result { From dd50d253c0c7ccbb0741c49eff2cc0f8bff170ee Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 11:20:18 +0100 Subject: [PATCH 28/29] gio/win32: Add missing feature --- gio-win32/Cargo.toml | 3 ++- gio-win32/src/input_stream.rs | 10 +++++++++- gio-win32/src/output_stream.rs | 10 +++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gio-win32/Cargo.toml b/gio-win32/Cargo.toml index 76731e0aa394..23b14164cbc2 100644 --- a/gio-win32/Cargo.toml +++ b/gio-win32/Cargo.toml @@ -29,7 +29,8 @@ default = [] v2_58 = ["ffi/v2_82", "gio/v2_58"] v2_60 = ["v2_58", "ffi/v2_60", "gio/v2_60"] v2_66 = ["v2_60", "ffi/v2_66", "gio/v2_66"] -v2_82 = ["v2_66", "ffi/v2_82", "gio/v2_82"] +v2_78 = ["v2_60", "ffi/v2_78", "gio/v2_78"] +v2_82 = ["v2_78", "ffi/v2_82", "gio/v2_82"] v2_84 = ["v2_82", "ffi/v2_84", "gio/v2_84"] [package.metadata.docs.rs] diff --git a/gio-win32/src/input_stream.rs b/gio-win32/src/input_stream.rs index c353685783d3..92651799abc1 100644 --- a/gio-win32/src/input_stream.rs +++ b/gio-win32/src/input_stream.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(any(windows, docsrs))] +#[cfg(windows)] use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; @@ -16,6 +16,8 @@ impl InputStream { /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_win32_input_stream_new")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub unsafe fn take_handle(handle: impl IntoRawHandle) -> InputStream { let handle = handle.into_raw_handle(); let close_handle = true.into_glib(); @@ -29,6 +31,8 @@ impl InputStream { /// # Safety /// You may only close the handle if all references to this stream have been dropped. #[doc(alias = "g_win32_input_stream_new")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub unsafe fn with_handle(handle: T) -> InputStream { let handle = handle.as_raw_handle(); let close_handle = false.into_glib(); @@ -37,6 +41,8 @@ impl InputStream { } } +#[cfg(windows)] +#[cfg_attr(docsrs, doc(cfg(windows)))] impl AsRawHandle for InputStream { fn as_raw_handle(&self) -> RawHandle { unsafe { ffi::g_win32_input_stream_get_handle(self.to_glib_none().0) as _ } @@ -46,6 +52,8 @@ impl AsRawHandle for InputStream { pub trait InputStreamExtManual: IsA + Sized { #[doc(alias = "g_win32_input_stream_get_handle")] #[doc(alias = "get_handle")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_input_stream_get_handle( diff --git a/gio-win32/src/output_stream.rs b/gio-win32/src/output_stream.rs index 183a4a4192ec..bf95fbfcbae9 100644 --- a/gio-win32/src/output_stream.rs +++ b/gio-win32/src/output_stream.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(any(windows, docsrs))] +#[cfg(windows)] use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; @@ -16,6 +16,8 @@ impl OutputStream { /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_win32_output_stream_new")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub unsafe fn take_handle(handle: impl IntoRawHandle) -> OutputStream { let handle = handle.into_raw_handle(); let close_handle = true.into_glib(); @@ -29,6 +31,8 @@ impl OutputStream { /// # Safety /// You may only close the handle if all references to this stream have been dropped. #[doc(alias = "g_win32_output_stream_new")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub unsafe fn with_handle(handle: T) -> OutputStream { let handle = handle.as_raw_handle(); let close_handle = false.into_glib(); @@ -37,6 +41,8 @@ impl OutputStream { } } +#[cfg(windows)] +#[cfg_attr(docsrs, doc(cfg(windows)))] impl AsRawHandle for OutputStream { fn as_raw_handle(&self) -> RawHandle { unsafe { ffi::g_win32_output_stream_get_handle(self.to_glib_none().0) as _ } @@ -46,6 +52,8 @@ impl AsRawHandle for OutputStream { pub trait OutputStreamExtManual: IsA + Sized { #[doc(alias = "g_win32_output_stream_get_handle")] #[doc(alias = "get_handle")] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_output_stream_get_handle( From 894cbab22b963c6742955b111445df90deafa354 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 6 Dec 2025 11:31:20 +0100 Subject: [PATCH 29/29] Re-export preludes Along with trait names fixes to make it work without colliding with gio traits names --- gio-unix/Gir.toml | 6 ++++-- gio-unix/src/auto/input_stream.rs | 4 ++-- gio-unix/src/auto/mod.rs | 4 ++-- gio-unix/src/auto/output_stream.rs | 4 ++-- gio-unix/src/input_stream.rs | 4 ++-- gio-unix/src/lib.rs | 6 ++++-- gio-unix/src/output_stream.rs | 4 ++-- gio-win32/Gir.toml | 6 ++++-- gio-win32/src/auto/input_stream.rs | 4 ++-- gio-win32/src/auto/mod.rs | 4 ++-- gio-win32/src/auto/output_stream.rs | 4 ++-- gio-win32/src/input_stream.rs | 4 ++-- gio-win32/src/lib.rs | 4 ++++ gio-win32/src/output_stream.rs | 6 +++--- glib-unix/src/lib.rs | 4 ++++ glib-win32/src/functions.rs | 2 ++ glib-win32/src/lib.rs | 4 ++++ 17 files changed, 47 insertions(+), 27 deletions(-) diff --git a/gio-unix/Gir.toml b/gio-unix/Gir.toml index 6bfafd376e74..01d0ee8dbff8 100644 --- a/gio-unix/Gir.toml +++ b/gio-unix/Gir.toml @@ -127,7 +127,8 @@ concurrency = "send+sync" [[object]] name = "GioUnix.InputStream" status = "generate" -manual_traits = ["InputStreamExtManual"] +trait_name = "UnixInputStreamExt" +manual_traits = ["UnixInputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd @@ -158,7 +159,8 @@ manual_traits = ["InputStreamExtManual"] [[object]] name = "GioUnix.OutputStream" status = "generate" -manual_traits = ["OutputStreamExtManual"] +trait_name = "UnixOutputStreamExt" +manual_traits = ["UnixOutputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd diff --git a/gio-unix/src/auto/input_stream.rs b/gio-unix/src/auto/input_stream.rs index b7a783825782..05d294ad3f7d 100644 --- a/gio-unix/src/auto/input_stream.rs +++ b/gio-unix/src/auto/input_stream.rs @@ -18,7 +18,7 @@ impl InputStream { pub const NONE: Option<&'static InputStream> = None; } -pub trait InputStreamExt: IsA + 'static { +pub trait UnixInputStreamExt: IsA + 'static { #[doc(alias = "g_unix_input_stream_get_close_fd")] #[doc(alias = "get_close_fd")] #[doc(alias = "close-fd")] @@ -31,4 +31,4 @@ pub trait InputStreamExt: IsA + 'static { } } -impl> InputStreamExt for O {} +impl> UnixInputStreamExt for O {} diff --git a/gio-unix/src/auto/mod.rs b/gio-unix/src/auto/mod.rs index c9237ab761c3..a81a686fe952 100644 --- a/gio-unix/src/auto/mod.rs +++ b/gio-unix/src/auto/mod.rs @@ -35,6 +35,6 @@ pub(crate) mod functions; pub(crate) mod traits { pub use super::fd_message::FDMessageExt; pub use super::file_descriptor_based::FileDescriptorBasedExt; - pub use super::input_stream::InputStreamExt; - pub use super::output_stream::OutputStreamExt; + pub use super::input_stream::UnixInputStreamExt; + pub use super::output_stream::UnixOutputStreamExt; } diff --git a/gio-unix/src/auto/output_stream.rs b/gio-unix/src/auto/output_stream.rs index 430412a39a60..e1200075204c 100644 --- a/gio-unix/src/auto/output_stream.rs +++ b/gio-unix/src/auto/output_stream.rs @@ -18,7 +18,7 @@ impl OutputStream { pub const NONE: Option<&'static OutputStream> = None; } -pub trait OutputStreamExt: IsA + 'static { +pub trait UnixOutputStreamExt: IsA + 'static { #[doc(alias = "g_unix_output_stream_get_close_fd")] #[doc(alias = "get_close_fd")] #[doc(alias = "close-fd")] @@ -31,4 +31,4 @@ pub trait OutputStreamExt: IsA + 'static { } } -impl> OutputStreamExt for O {} +impl> UnixOutputStreamExt for O {} diff --git a/gio-unix/src/input_stream.rs b/gio-unix/src/input_stream.rs index 088711049160..0745e9b04cf5 100644 --- a/gio-unix/src/input_stream.rs +++ b/gio-unix/src/input_stream.rs @@ -47,7 +47,7 @@ impl AsFd for InputStream { } } -pub trait InputStreamExtManual: IsA + Sized { +pub trait UnixInputStreamExtManual: IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// @@ -60,4 +60,4 @@ pub trait InputStreamExtManual: IsA + Sized { } } -impl> InputStreamExtManual for O {} +impl> UnixInputStreamExtManual for O {} diff --git a/gio-unix/src/lib.rs b/gio-unix/src/lib.rs index 7587d0d72c1a..37628e85e6a8 100644 --- a/gio-unix/src/lib.rs +++ b/gio-unix/src/lib.rs @@ -25,6 +25,8 @@ pub mod functions { } pub mod prelude { + pub use gio::prelude::*; + pub use super::auto::traits::*; #[cfg(feature = "v2_58")] @@ -32,6 +34,6 @@ pub mod prelude { pub use crate::fd_message::FDMessageExtManual; pub use crate::file_descriptor_based::FileDescriptorBasedExtManual; - pub use crate::input_stream::InputStreamExtManual; - pub use crate::output_stream::OutputStreamExtManual; + pub use crate::input_stream::UnixInputStreamExtManual; + pub use crate::output_stream::UnixOutputStreamExtManual; } diff --git a/gio-unix/src/output_stream.rs b/gio-unix/src/output_stream.rs index a9de89f9a084..0b28dcd92b06 100644 --- a/gio-unix/src/output_stream.rs +++ b/gio-unix/src/output_stream.rs @@ -50,7 +50,7 @@ impl AsFd for OutputStream { } } -pub trait OutputStreamExtManual: IsA + Sized { +pub trait UnixOutputStreamExtManual: IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// @@ -66,4 +66,4 @@ pub trait OutputStreamExtManual: IsA + Sized { } } -impl> OutputStreamExtManual for O {} +impl> UnixOutputStreamExtManual for O {} diff --git a/gio-win32/Gir.toml b/gio-win32/Gir.toml index 69c7fb232aea..0f738cd15d5a 100644 --- a/gio-win32/Gir.toml +++ b/gio-win32/Gir.toml @@ -30,7 +30,8 @@ status = "generate" [[object]] name = "GioWin32.InputStream" status = "generate" -manual_traits = ["InputStreamExtManual"] +trait_name = "Win32InputStreamExt" +manual_traits = ["Win32InputStreamExtManual"] [[object.function]] name = "new" manual = true @@ -44,7 +45,8 @@ manual_traits = ["InputStreamExtManual"] [[object]] name = "GioWin32.OutputStream" status = "generate" -manual_traits = ["OutputStreamExtManual"] +trait_name = "Win32OutputStreamExt" +manual_traits = ["Win32OutputStreamExtManual"] [[object.function]] name = "new" manual = true diff --git a/gio-win32/src/auto/input_stream.rs b/gio-win32/src/auto/input_stream.rs index a0b18cc9e8df..ceb89393969a 100644 --- a/gio-win32/src/auto/input_stream.rs +++ b/gio-win32/src/auto/input_stream.rs @@ -23,7 +23,7 @@ impl InputStream { pub const NONE: Option<&'static InputStream> = None; } -pub trait InputStreamExt: IsA + 'static { +pub trait Win32InputStreamExt: IsA + 'static { #[doc(alias = "g_win32_input_stream_get_close_handle")] #[doc(alias = "get_close_handle")] #[doc(alias = "close-handle")] @@ -71,4 +71,4 @@ pub trait InputStreamExt: IsA + 'static { } } -impl> InputStreamExt for O {} +impl> Win32InputStreamExt for O {} diff --git a/gio-win32/src/auto/mod.rs b/gio-win32/src/auto/mod.rs index f04641004ea7..ce773feb5ad3 100644 --- a/gio-win32/src/auto/mod.rs +++ b/gio-win32/src/auto/mod.rs @@ -11,6 +11,6 @@ pub use self::output_stream::OutputStream; pub(crate) mod functions; pub(crate) mod traits { - pub use super::input_stream::InputStreamExt; - pub use super::output_stream::OutputStreamExt; + pub use super::input_stream::Win32InputStreamExt; + pub use super::output_stream::Win32OutputStreamExt; } diff --git a/gio-win32/src/auto/output_stream.rs b/gio-win32/src/auto/output_stream.rs index 84195db1708d..33974f511e64 100644 --- a/gio-win32/src/auto/output_stream.rs +++ b/gio-win32/src/auto/output_stream.rs @@ -23,7 +23,7 @@ impl OutputStream { pub const NONE: Option<&'static OutputStream> = None; } -pub trait OutputStreamExt: IsA + 'static { +pub trait Win32OutputStreamExt: IsA + 'static { #[doc(alias = "g_win32_output_stream_get_close_handle")] #[doc(alias = "get_close_handle")] #[doc(alias = "close-handle")] @@ -71,4 +71,4 @@ pub trait OutputStreamExt: IsA + 'static { } } -impl> OutputStreamExt for O {} +impl> Win32OutputStreamExt for O {} diff --git a/gio-win32/src/input_stream.rs b/gio-win32/src/input_stream.rs index 92651799abc1..fcb62c9ea6ed 100644 --- a/gio-win32/src/input_stream.rs +++ b/gio-win32/src/input_stream.rs @@ -49,7 +49,7 @@ impl AsRawHandle for InputStream { } } -pub trait InputStreamExtManual: IsA + Sized { +pub trait Win32InputStreamExtManual: IsA + Sized { #[doc(alias = "g_win32_input_stream_get_handle")] #[doc(alias = "get_handle")] #[cfg(windows)] @@ -63,4 +63,4 @@ pub trait InputStreamExtManual: IsA + Sized { } } -impl> InputStreamExtManual for O {} +impl> Win32InputStreamExtManual for O {} diff --git a/gio-win32/src/lib.rs b/gio-win32/src/lib.rs index 47936c4f61c8..eff9f0c50218 100644 --- a/gio-win32/src/lib.rs +++ b/gio-win32/src/lib.rs @@ -16,5 +16,9 @@ pub mod functions { } pub mod prelude { + pub use gio::prelude::*; + pub use super::auto::traits::*; + pub use super::input_stream::Win32InputStreamExtManual; + pub use super::output_stream::Win32OutputStreamExtManual; } diff --git a/gio-win32/src/output_stream.rs b/gio-win32/src/output_stream.rs index bf95fbfcbae9..7edcc8ef1520 100644 --- a/gio-win32/src/output_stream.rs +++ b/gio-win32/src/output_stream.rs @@ -12,7 +12,7 @@ impl OutputStream { /// Creates a new [`Self`] that takes ownership of the passed in handle. /// /// # Safety - /// You must not close the handle unless you've previously called [`OutputStreamExtManual::set_close_handle`] + /// You must not close the handle unless you've previously called [`Win32OutputStreamExtManual::set_close_handle`] /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_win32_output_stream_new")] @@ -49,7 +49,7 @@ impl AsRawHandle for OutputStream { } } -pub trait OutputStreamExtManual: IsA + Sized { +pub trait Win32OutputStreamExtManual: IsA + Sized { #[doc(alias = "g_win32_output_stream_get_handle")] #[doc(alias = "get_handle")] #[cfg(windows)] @@ -63,4 +63,4 @@ pub trait OutputStreamExtManual: IsA + Sized { } } -impl> OutputStreamExtManual for O {} +impl> Win32OutputStreamExtManual for O {} diff --git a/glib-unix/src/lib.rs b/glib-unix/src/lib.rs index aacb7bb7ffbe..ab5f766f992c 100644 --- a/glib-unix/src/lib.rs +++ b/glib-unix/src/lib.rs @@ -9,3 +9,7 @@ mod functions; pub use auto::functions::*; pub use functions::*; + +pub mod prelude { + pub use glib::prelude::*; +} diff --git a/glib-win32/src/functions.rs b/glib-win32/src/functions.rs index 750327bfb040..4a68148cd53c 100644 --- a/glib-win32/src/functions.rs +++ b/glib-win32/src/functions.rs @@ -1,5 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(windows)] use glib::translate::*; +#[cfg(windows)] use std::path::PathBuf; #[doc(alias = "g_win32_get_package_installation_directory_of_module")] diff --git a/glib-win32/src/lib.rs b/glib-win32/src/lib.rs index 3f3a0486681b..c0dbfb1bb992 100644 --- a/glib-win32/src/lib.rs +++ b/glib-win32/src/lib.rs @@ -10,3 +10,7 @@ mod functions; pub use auto::functions::*; pub use functions::*; + +pub mod prelude { + pub use glib::prelude::*; +}