Remove extern crate statements (#3310)

This commit is contained in:
daxpedda 2023-12-25 09:25:09 +01:00 committed by GitHub
parent 61a873d79a
commit 28a811bbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 54 additions and 26 deletions

View file

@ -104,6 +104,9 @@
//! [android_1]: https://developer.android.com/training/multiscreen/screendensities //! [android_1]: https://developer.android.com/training/multiscreen/screendensities
//! [web_1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio //! [web_1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
pub trait Pixel: Copy + Into<f64> { pub trait Pixel: Copy + Into<f64> {
fn from_f64(f: f64) -> Self; fn from_f64(f: f64) -> Self;
fn cast<P: Pixel>(self) -> P { fn cast<P: Pixel>(self) -> P {

View file

@ -37,6 +37,8 @@ use std::sync::{Mutex, Weak};
#[cfg(not(wasm_platform))] #[cfg(not(wasm_platform))]
use std::time::Instant; use std::time::Instant;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use smol_str::SmolStr; use smol_str::SmolStr;
#[cfg(wasm_platform)] #[cfg(wasm_platform)]
use web_time::Instant; use web_time::Instant;

View file

@ -69,6 +69,9 @@
// //
// --------- END OF W3C SHORT NOTICE --------------------------------------------------------------- // --------- END OF W3C SHORT NOTICE ---------------------------------------------------------------
use bitflags::bitflags;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
pub use smol_str::SmolStr; pub use smol_str::SmolStr;
/// Contains the platform-native physical key identifier /// Contains the platform-native physical key identifier

View file

@ -160,15 +160,6 @@
#[cfg(feature = "rwh_06")] #[cfg(feature = "rwh_06")]
pub use rwh_06 as raw_window_handle; pub use rwh_06 as raw_window_handle;
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
#[macro_use]
extern crate bitflags;
pub mod dpi; pub mod dpi;
#[macro_use] #[macro_use]
pub mod error; pub mod error;

View file

@ -283,7 +283,7 @@ pub enum Idiom {
CarPlay, CarPlay,
} }
bitflags! { bitflags::bitflags! {
/// The [edges] of a screen. /// The [edges] of a screen.
/// ///
/// [edges]: https://developer.apple.com/documentation/uikit/uirectedge?language=objc /// [edges]: https://developer.apple.com/documentation/uikit/uirectedge?language=objc

View file

@ -2,6 +2,8 @@ use std::os::raw::c_void;
use icrate::Foundation::MainThreadMarker; use icrate::Foundation::MainThreadMarker;
use objc2::rc::Id; use objc2::rc::Id;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::{ use crate::{
event_loop::{EventLoopBuilder, EventLoopWindowTarget}, event_loop::{EventLoopBuilder, EventLoopWindowTarget},

View file

@ -15,6 +15,7 @@ use android_activity::input::{InputEvent, KeyAction, Keycode, MotionAction};
use android_activity::{ use android_activity::{
AndroidApp, AndroidAppWaker, ConfigurationRef, InputStatus, MainEvent, Rect, AndroidApp, AndroidAppWaker, ConfigurationRef, InputStatus, MainEvent, Rect,
}; };
use log::{debug, trace, warn};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use crate::{ use crate::{

View file

@ -78,7 +78,7 @@ impl<T: 'static> EventLoopWindowTarget<T> {
pub(crate) fn exit(&self) { pub(crate) fn exit(&self) {
// https://developer.apple.com/library/archive/qa/qa1561/_index.html // https://developer.apple.com/library/archive/qa/qa1561/_index.html
// it is not possible to quit an iOS app gracefully and programatically // it is not possible to quit an iOS app gracefully and programatically
warn!("`ControlFlow::Exit` ignored on iOS"); log::warn!("`ControlFlow::Exit` ignored on iOS");
} }
pub(crate) fn exiting(&self) -> bool { pub(crate) fn exiting(&self) -> bool {

View file

@ -39,7 +39,7 @@ extern_methods!(
} }
); );
bitflags! { bitflags::bitflags! {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct UIInterfaceOrientationMask: NSUInteger { pub struct UIInterfaceOrientationMask: NSUInteger {
const Portrait = 1 << 1; const Portrait = 1 << 1;

View file

@ -3,6 +3,7 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use icrate::Foundation::{CGFloat, CGPoint, CGRect, CGSize, MainThreadBound, MainThreadMarker}; use icrate::Foundation::{CGFloat, CGPoint, CGRect, CGSize, MainThreadBound, MainThreadMarker};
use log::{debug, warn};
use objc2::rc::Id; use objc2::rc::Id;
use objc2::runtime::AnyObject; use objc2::runtime::AnyObject;
use objc2::{class, msg_send}; use objc2::{class, msg_send};

View file

@ -682,7 +682,7 @@ fn byte_slice_to_smol_str(bytes: &[u8]) -> Option<SmolStr> {
std::str::from_utf8(bytes) std::str::from_utf8(bytes)
.map(SmolStr::new) .map(SmolStr::new)
.map_err(|e| { .map_err(|e| {
warn!( log::warn!(
"UTF-8 received from libxkbcommon ({:?}) was invalid: {e}", "UTF-8 received from libxkbcommon ({:?}) was invalid: {e}",
bytes bytes
) )

View file

@ -712,7 +712,7 @@ unsafe extern "C" fn x_error_callback(
// Don't log error. // Don't log error.
if !error_handled { if !error_handled {
error!("X11 error: {:#?}", error); log::error!("X11 error: {:#?}", error);
// XXX only update the error, if it wasn't handled by any of the hooks. // XXX only update the error, if it wasn't handled by any of the hooks.
*xconn.latest_error.lock().unwrap() = Some(error); *xconn.latest_error.lock().unwrap() = Some(error);
} }

View file

@ -552,7 +552,7 @@ impl<T: 'static> EventLoop<T> {
}; };
self.event_loop.dispatch(timeout, state).map_err(|error| { self.event_loop.dispatch(timeout, state).map_err(|error| {
error!("Error dispatching event loop: {}", error); log::error!("Error dispatching event loop: {}", error);
error.into() error.into()
}) })
} }

View file

@ -135,7 +135,7 @@ impl WinitState {
) { ) {
Ok(c) => Some(c), Ok(c) => Some(c),
Err(e) => { Err(e) => {
warn!("Subcompositor protocol not available, ignoring CSD: {e:?}"); log::warn!("Subcompositor protocol not available, ignoring CSD: {e:?}");
None None
} }
}; };

View file

@ -15,6 +15,8 @@ use sctk::shell::xdg::window::Window as SctkWindow;
use sctk::shell::xdg::window::WindowDecorations; use sctk::shell::xdg::window::WindowDecorations;
use sctk::shell::WaylandSurface; use sctk::shell::WaylandSurface;
use log::warn;
use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size}; use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size};
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError}; use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
use crate::event::{Ime, WindowEvent}; use crate::event::{Ime, WindowEvent};

View file

@ -86,7 +86,7 @@ extern "C" fn preedit_draw_callback(
let chg_range = let chg_range =
call_data.chg_first as usize..(call_data.chg_first + call_data.chg_length) as usize; call_data.chg_first as usize..(call_data.chg_first + call_data.chg_length) as usize;
if chg_range.start > client_data.text.len() || chg_range.end > client_data.text.len() { if chg_range.start > client_data.text.len() || chg_range.end > client_data.text.len() {
warn!( log::warn!(
"invalid chg range: buffer length={}, but chg_first={} chg_lengthg={}", "invalid chg range: buffer length={}, but chg_first={} chg_lengthg={}",
client_data.text.len(), client_data.text.len(),
call_data.chg_first, call_data.chg_first,

View file

@ -10,6 +10,10 @@ use std::sync::{
Arc, Arc,
}; };
use log::debug;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use super::{ffi, util, XConnection, XError}; use super::{ffi, util, XConnection, XError};
pub use self::context::ImeContextCreationError; pub use self::context::ImeContextCreationError;

View file

@ -22,6 +22,7 @@ pub use self::xdisplay::{XError, XNotSupported};
use calloop::generic::Generic; use calloop::generic::Generic;
use calloop::EventLoop as Loop; use calloop::EventLoop as Loop;
use calloop::{ping::Ping, Readiness}; use calloop::{ping::Ping, Readiness};
use log::warn;
use std::{ use std::{
cell::{Cell, RefCell}, cell::{Cell, RefCell},

View file

@ -1,5 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use super::*; use super::*;
#[derive(Debug)] #[derive(Debug)]

View file

@ -45,7 +45,7 @@ impl XConnection {
self.flush_requests()?; self.flush_requests()?;
Ok(true) Ok(true)
} else { } else {
error!("Could not select XKB events: The XKB extension is not initialized!"); log::error!("Could not select XKB events: The XKB extension is not initialized!");
Ok(false) Ok(false)
} }
} }

View file

@ -4,6 +4,7 @@ use super::*;
use crate::platform_impl::platform::x11::monitor; use crate::platform_impl::platform::x11::monitor;
use crate::{dpi::validate_scale_factor, platform_impl::platform::x11::VideoMode}; use crate::{dpi::validate_scale_factor, platform_impl::platform::x11::VideoMode};
use log::warn;
use x11rb::protocol::randr::{self, ConnectionExt as _}; use x11rb::protocol::randr::{self, ConnectionExt as _};
/// Represents values of `WINIT_HIDPI_FACTOR`. /// Represents values of `WINIT_HIDPI_FACTOR`.

View file

@ -7,6 +7,7 @@ use std::{
sync::{Arc, Mutex, MutexGuard}, sync::{Arc, Mutex, MutexGuard},
}; };
use log::{debug, info, warn};
use x11rb::{ use x11rb::{
connection::Connection, connection::Connection,
properties::{WmHints, WmHintsState, WmSizeHints, WmSizeHintsSpecification}, properties::{WmHints, WmHintsState, WmSizeHints, WmSizeHintsSpecification},

View file

@ -14,6 +14,7 @@ use std::{
use core_foundation::runloop::{CFRunLoopGetMain, CFRunLoopWakeUp}; use core_foundation::runloop::{CFRunLoopGetMain, CFRunLoopWakeUp};
use icrate::AppKit::{NSApplication, NSApplicationActivationPolicy}; use icrate::AppKit::{NSApplication, NSApplicationActivationPolicy};
use icrate::Foundation::{is_main_thread, MainThreadMarker, NSSize}; use icrate::Foundation::{is_main_thread, MainThreadMarker, NSSize};
use log::trace;
use objc2::rc::{autoreleasepool, Id}; use objc2::rc::{autoreleasepool, Id};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;

View file

@ -74,7 +74,7 @@ unsafe fn try_cursor_from_selector(sel: Sel) -> Option<Id<NSCursor>> {
let cursor: Id<NSCursor> = unsafe { msg_send_id![cls, performSelector: sel] }; let cursor: Id<NSCursor> = unsafe { msg_send_id![cls, performSelector: sel] };
Some(cursor) Some(cursor)
} else { } else {
warn!("cursor `{sel}` appears to be invalid"); log::warn!("cursor `{sel}` appears to be invalid");
None None
} }
} }

View file

@ -1,4 +1,5 @@
use icrate::Foundation::{NSNotFound, NSRange, NSUInteger}; use icrate::Foundation::{NSNotFound, NSRange, NSUInteger};
use log::trace;
// Replace with `!` once stable // Replace with `!` once stable
#[derive(Debug)] #[derive(Debug)]

View file

@ -73,7 +73,7 @@ enum ImeState {
Commited, Commited,
} }
bitflags! { bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
struct ModLocationMask: u8 { struct ModLocationMask: u8 {
const LEFT = 0b0001; const LEFT = 0b0001;
@ -338,7 +338,7 @@ declare_class!(
// Leave the Preedit self.ivars() // Leave the Preedit self.ivars()
self.ivars().ime_state.set(ImeState::Ground); self.ivars().ime_state.set(ImeState::Ground);
} else { } else {
warn!("Expected to have IME enabled when receiving unmarkText"); log::warn!("Expected to have IME enabled when receiving unmarkText");
} }
} }

View file

@ -46,6 +46,7 @@ use icrate::Foundation::{
CGFloat, MainThreadBound, MainThreadMarker, NSArray, NSCopying, NSObject, NSPoint, NSRect, CGFloat, MainThreadBound, MainThreadMarker, NSArray, NSCopying, NSObject, NSPoint, NSRect,
NSSize, NSString, NSSize, NSString,
}; };
use log::trace;
use objc2::rc::{autoreleasepool, Id}; use objc2::rc::{autoreleasepool, Id};
use objc2::{declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass}; use objc2::{declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass};

View file

@ -7,6 +7,7 @@ use std::{
time::Instant, time::Instant,
}; };
use bitflags::bitflags;
use orbclient::{ use orbclient::{
ButtonEvent, EventOption, FocusEvent, HoverEvent, KeyEvent, MouseEvent, MoveEvent, QuitEvent, ButtonEvent, EventOption, FocusEvent, HoverEvent, KeyEvent, MouseEvent, MoveEvent, QuitEvent,
ResizeEvent, ScrollEvent, TextInputEvent, ResizeEvent, ScrollEvent, TextInputEvent,
@ -459,7 +460,7 @@ impl<T: 'static> EventLoop<T> {
} }
} }
other => { other => {
warn!("unhandled event: {:?}", other); log::warn!("unhandled event: {:?}", other);
} }
} }
} }

View file

@ -9,7 +9,7 @@ use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::{JsCast, JsValue}; use wasm_bindgen::{JsCast, JsValue};
use web_sys::{KeyboardEvent, MouseEvent, PointerEvent, WheelEvent}; use web_sys::{KeyboardEvent, MouseEvent, PointerEvent, WheelEvent};
bitflags! { bitflags::bitflags! {
// https://www.w3.org/TR/pointerevents3/#the-buttons-property // https://www.w3.org/TR/pointerevents3/#the-buttons-property
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ButtonsState: u16 { pub struct ButtonsState: u16 {
@ -178,7 +178,7 @@ pub fn key_location(event: &KeyboardEvent) -> KeyLocation {
KeyboardEvent::DOM_KEY_LOCATION_NUMPAD => KeyLocation::Numpad, KeyboardEvent::DOM_KEY_LOCATION_NUMPAD => KeyLocation::Numpad,
KeyboardEvent::DOM_KEY_LOCATION_STANDARD => KeyLocation::Standard, KeyboardEvent::DOM_KEY_LOCATION_STANDARD => KeyLocation::Standard,
location => { location => {
warn!("Unexpected key location: {location}"); log::warn!("Unexpected key location: {location}");
KeyLocation::Standard KeyLocation::Standard
} }
} }

View file

@ -1,4 +1,5 @@
use js_sys::{Array, Object}; use js_sys::{Array, Object};
use log::warn;
use wasm_bindgen::prelude::{wasm_bindgen, Closure}; use wasm_bindgen::prelude::{wasm_bindgen, Closure};
use wasm_bindgen::{JsCast, JsValue}; use wasm_bindgen::{JsCast, JsValue};
use web_sys::{ use web_sys::{

View file

@ -18,6 +18,8 @@ use windows_sys::{
}, },
}; };
use log::debug;
use crate::platform_impl::platform::{ use crate::platform_impl::platform::{
definitions::{IDataObjectVtbl, IDropTarget, IDropTargetVtbl, IUnknownVtbl}, definitions::{IDataObjectVtbl, IDropTarget, IDropTargetVtbl, IUnknownVtbl},
WindowId, WindowId,

View file

@ -32,6 +32,7 @@ use windows_sys::Win32::{
}, },
}; };
use log::{trace, warn};
use smol_str::SmolStr; use smol_str::SmolStr;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;

View file

@ -104,7 +104,7 @@ static NUMPAD_KEYCODES: Lazy<HashSet<KeyCode>> = Lazy::new(|| {
keycodes keycodes
}); });
bitflags! { bitflags::bitflags! {
#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct WindowsModifiers : u8 { pub struct WindowsModifiers : u8 {
const SHIFT = 1 << 0; const SHIFT = 1 << 0;

View file

@ -54,6 +54,8 @@ use windows_sys::Win32::{
}, },
}; };
use log::warn;
use crate::{ use crate::{
cursor::Cursor, cursor::Cursor,
dpi::{PhysicalPosition, PhysicalSize, Position, Size}, dpi::{PhysicalPosition, PhysicalSize, Position, Size},

View file

@ -5,6 +5,7 @@ use crate::{
platform_impl::platform::{event_loop, util, Fullscreen, SelectedCursor}, platform_impl::platform::{event_loop, util, Fullscreen, SelectedCursor},
window::{Theme, WindowAttributes}, window::{Theme, WindowAttributes},
}; };
use bitflags::bitflags;
use std::io; use std::io;
use std::sync::MutexGuard; use std::sync::MutexGuard;
use windows_sys::Win32::{ use windows_sys::Win32::{

View file

@ -14,6 +14,8 @@ pub use crate::icon::{BadIcon, Icon};
#[doc(inline)] #[doc(inline)]
pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError}; pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Represents a window. /// Represents a window.
/// ///
@ -1674,7 +1676,7 @@ pub enum UserAttentionType {
Informational, Informational,
} }
bitflags! { bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WindowButtons: u32 { pub struct WindowButtons: u32 {
const CLOSE = 1 << 0; const CLOSE = 1 << 0;