From 3791fb9a1e8bc13b3a402c3a378d3196a32d9e5d Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Thu, 22 Feb 2024 21:47:10 +0100 Subject: [PATCH] all: remove extern_types feature --- src/libinput/sys.rs | 17 +++++++++++------ src/main.rs | 1 - src/pango.rs | 26 ++++++++++++++++---------- src/udev.rs | 19 +++++++++++++------ 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/libinput/sys.rs b/src/libinput/sys.rs index 00f109b8..e3308fdb 100644 --- a/src/libinput/sys.rs +++ b/src/libinput/sys.rs @@ -9,14 +9,19 @@ pub type libinput_log_handler = unsafe extern "C" fn( args: VaList, ); +#[repr(transparent)] +pub struct libinput(u8); +#[repr(transparent)] +pub struct libinput_device(u8); +#[repr(transparent)] +pub struct libinput_event(u8); +#[repr(transparent)] +pub struct libinput_event_keyboard(u8); +#[repr(transparent)] +pub struct libinput_event_pointer(u8); + #[link(name = "input")] extern "C" { - pub type libinput; - pub type libinput_device; - pub type libinput_event; - pub type libinput_event_keyboard; - pub type libinput_event_pointer; - pub fn libinput_log_set_handler(libinput: *mut libinput, log_handler: libinput_log_handler); pub fn libinput_log_set_priority(libinput: *mut libinput, priority: libinput_log_priority); pub fn libinput_path_create_context( diff --git a/src/main.rs b/src/main.rs index e2133382..040999f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ #![feature( c_variadic, // https://github.com/rust-lang/rust/issues/44930 thread_local, // https://github.com/rust-lang/rust/issues/29594 - extern_types, // https://github.com/rust-lang/rust/issues/43467 c_str_literals, // https://github.com/rust-lang/rust/issues/105723 )] #![allow( diff --git a/src/pango.rs b/src/pango.rs index 087fb10e..afce8b40 100644 --- a/src/pango.rs +++ b/src/pango.rs @@ -14,11 +14,13 @@ pub mod consts; include!(concat!(env!("OUT_DIR"), "/pango_tys.rs")); +#[repr(transparent)] +struct cairo_surface_t(u8); +#[repr(transparent)] +struct cairo_t(u8); + #[link(name = "cairo")] extern "C" { - type cairo_surface_t; - type cairo_t; - fn cairo_image_surface_create( format: cairo_format_t, width: c::c_int, @@ -41,26 +43,30 @@ extern "C" { fn cairo_move_to(cr: *mut cairo_t, x: f64, y: f64); } +#[repr(transparent)] +struct PangoContext_(u8); + #[link(name = "pangocairo-1.0")] extern "C" { - type PangoContext_; - fn pango_cairo_create_context(cr: *mut cairo_t) -> *mut PangoContext_; fn pango_cairo_show_layout(cr: *mut cairo_t, layout: *mut PangoLayout_); } +#[repr(transparent)] +struct GObject(u8); + #[link(name = "gobject-2.0")] extern "C" { - type GObject; - fn g_object_unref(object: *mut GObject); } +#[repr(transparent)] +struct PangoFontDescription_(u8); +#[repr(transparent)] +struct PangoLayout_(u8); + #[link(name = "pango-1.0")] extern "C" { - type PangoFontDescription_; - type PangoLayout_; - fn pango_font_description_from_string(str: *const c::c_char) -> *mut PangoFontDescription_; fn pango_font_description_free(desc: *mut PangoFontDescription_); fn pango_font_description_get_size(desc: *mut PangoFontDescription_) -> c::c_int; diff --git a/src/udev.rs b/src/udev.rs index 6f534a1c..0ee165ab 100644 --- a/src/udev.rs +++ b/src/udev.rs @@ -1,3 +1,5 @@ +#![allow(non_camel_case_types)] + use { crate::utils::oserror::OsError, std::{ffi::CStr, marker::PhantomData, ptr, rc::Rc}, @@ -5,14 +7,19 @@ use { uapi::{c, ustr, Errno, IntoUstr, Ustr}, }; +#[repr(transparent)] +struct udev(u8); +#[repr(transparent)] +struct udev_monitor(u8); +#[repr(transparent)] +struct udev_enumerate(u8); +#[repr(transparent)] +struct udev_list_entry(u8); +#[repr(transparent)] +struct udev_device(u8); + #[link(name = "udev")] extern "C" { - type udev; - type udev_monitor; - type udev_enumerate; - type udev_list_entry; - type udev_device; - fn udev_new() -> *mut udev; fn udev_unref(udev: *mut udev) -> *mut udev;