From f7aa8249155db4bc6cb2bd3d7f0e889c979f9e88 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Aug 2023 01:56:37 +0200 Subject: [PATCH 01/19] Use objc2 --- Cargo.toml | 11 ++++++----- src/lib.rs | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6d0e8ac7..70b7d1a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,15 +20,16 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] bitmask-enum = "2.2.1" -block = "0.1.6" -core-foundation = "0.9" -core-graphics = "0.23" +objc = { version = "=0.3.0-beta.1", package = "objc2" } +block = { version = "=0.2.0-alpha.5", package = "block2" } +# Temporary: Patched versions that implement `Encode` for common types +# Branch: `objc2` +core-foundation = { git = "https://github.com/madsmtm/core-foundation-rs.git", rev = "812338c66a96f899b516c0507051513337cb1fb8" } +core-graphics = { git = "https://github.com/madsmtm/core-foundation-rs.git", rev = "812338c66a96f899b516c0507051513337cb1fb8" } dispatch = "0.2.0" infer = { version = "0.15", optional = true } lazy_static = "1.4.0" libc = "0.2" -objc = "0.2.7" -objc_id = "0.1.1" os_info = "3.0.1" url = "2.1.1" uuid = { version = "1.1", features = ["v4"], optional = true } diff --git a/src/lib.rs b/src/lib.rs index aff3551f..cfe5f5e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,8 @@ #![cfg_attr(debug_assertions, allow(dead_code, unused_imports))] #![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))] #![cfg_attr(docsrs, feature(doc_cfg))] +// Temporary! +#![allow(deprecated)] // Copyright 2019+, the Cacao developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Dual-licensed under an MIT/MPL-2.0 license, see the LICENSE files in this repository. From 2c246a158cb8f593bfdfd9daa78b75c7c479d304 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 5 Sep 2023 12:34:20 +0200 Subject: [PATCH 02/19] Replace `objc_id` --- src/appkit/alert.rs | 2 +- src/appkit/app/mod.rs | 2 +- src/appkit/event/mod.rs | 2 +- src/appkit/haptics.rs | 2 +- src/appkit/menu/item.rs | 2 +- src/appkit/menu/menu.rs | 2 +- src/appkit/printing/settings.rs | 2 +- src/appkit/segmentedcontrol.rs | 2 +- src/appkit/toolbar/item.rs | 2 +- src/appkit/toolbar/mod.rs | 2 +- src/appkit/window/controller/mod.rs | 2 +- src/appkit/window/mod.rs | 2 +- src/button/mod.rs | 2 +- src/cloudkit/share.rs | 2 +- src/color/mod.rs | 2 +- src/defaults/mod.rs | 2 +- src/dragdrop.rs | 2 +- src/filesystem/manager.rs | 2 +- src/filesystem/save.rs | 2 +- src/filesystem/select.rs | 2 +- src/foundation/array.rs | 2 +- src/foundation/autoreleasepool.rs | 2 +- src/foundation/data.rs | 2 +- src/foundation/dictionary.rs | 2 +- src/foundation/number.rs | 2 +- src/foundation/string.rs | 2 +- src/foundation/urls/mod.rs | 2 +- src/image/handle.rs | 2 +- src/image/image.rs | 2 +- src/image/mod.rs | 2 +- src/input/mod.rs | 2 +- src/input/uikit.rs | 2 +- src/invoker.rs | 2 +- src/layout/animator.rs | 2 +- src/layout/constraint.rs | 4 +- src/layout/dimension.rs | 2 +- src/layout/horizontal.rs | 2 +- src/layout/traits.rs | 2 +- src/layout/vertical.rs | 2 +- src/lib.rs | 59 +++++++++++++++++++++++++ src/listview/actions.rs | 2 +- src/listview/appkit.rs | 2 +- src/listview/mod.rs | 2 +- src/listview/row/appkit.rs | 2 +- src/listview/row/mod.rs | 2 +- src/listview/row/uikit.rs | 2 +- src/networking/mod.rs | 2 +- src/notification_center/mod.rs | 2 +- src/pasteboard/mod.rs | 2 +- src/progress/mod.rs | 2 +- src/quicklook/config.rs | 2 +- src/quicklook/mod.rs | 2 +- src/scrollview/appkit.rs | 2 +- src/scrollview/mod.rs | 2 +- src/scrollview/uikit.rs | 2 +- src/select/mod.rs | 2 +- src/switch.rs | 2 +- src/text/attributed_string.rs | 2 +- src/text/font.rs | 2 +- src/text/label/mod.rs | 2 +- src/text/label/uikit.rs | 2 +- src/uikit/scene/config.rs | 2 +- src/uikit/scene/mod.rs | 2 +- src/uikit/scene/options.rs | 2 +- src/uikit/scene/session.rs | 2 +- src/uikit/window/mod.rs | 2 +- src/user_activity.rs | 2 +- src/user_notifications/notifications.rs | 2 +- src/utils/mod.rs | 2 +- src/utils/properties.rs | 2 +- src/view/animator.rs | 2 +- src/view/appkit.rs | 2 +- src/view/controller/mod.rs | 2 +- src/view/popover/mod.rs | 2 +- src/view/splitviewcontroller/mod.rs | 2 +- src/view/uikit.rs | 2 +- src/webview/config.rs | 2 +- src/webview/mod.rs | 2 +- 78 files changed, 137 insertions(+), 78 deletions(-) diff --git a/src/appkit/alert.rs b/src/appkit/alert.rs index 3483f304..af9b9d0e 100644 --- a/src/appkit/alert.rs +++ b/src/appkit/alert.rs @@ -24,9 +24,9 @@ //! } //! ``` +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSString}; diff --git a/src/appkit/app/mod.rs b/src/appkit/app/mod.rs index 9828855c..d46c710f 100644 --- a/src/appkit/app/mod.rs +++ b/src/appkit/app/mod.rs @@ -39,9 +39,9 @@ use std::sync::{Arc, Mutex}; use lazy_static::lazy_static; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::appkit::menu::Menu; use crate::foundation::{id, nil, AutoReleasePool, NSUInteger, NO, YES}; diff --git a/src/appkit/event/mod.rs b/src/appkit/event/mod.rs index 851639ff..ec10cacd 100644 --- a/src/appkit/event/mod.rs +++ b/src/appkit/event/mod.rs @@ -1,9 +1,9 @@ use bitmask_enum::bitmask; use block::ConcreteBlock; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::events::EventType; use crate::foundation::{id, nil, NSInteger, NSPoint, NSString}; diff --git a/src/appkit/haptics.rs b/src/appkit/haptics.rs index adf1356c..dfd45a17 100644 --- a/src/appkit/haptics.rs +++ b/src/appkit/haptics.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; +use crate::id_shim::ShareId; use objc::{class, msg_send, runtime::Object, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::NSUInteger; diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index 6218e19d..a5d61093 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -4,9 +4,9 @@ use std::fmt; +use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::events::EventModifierFlag; use crate::foundation::{id, load_or_register_class, NSString, NSUInteger}; diff --git a/src/appkit/menu/menu.rs b/src/appkit/menu/menu.rs index 8e22ff6c..11e1993d 100644 --- a/src/appkit/menu/menu.rs +++ b/src/appkit/menu/menu.rs @@ -2,9 +2,9 @@ use std::sync::{Arc, Mutex}; +use crate::id_shim::{Id, ShareId}; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::{Id, ShareId}; use crate::appkit::menu::item::MenuItem; use crate::foundation::{id, NSInteger, NSString}; diff --git a/src/appkit/printing/settings.rs b/src/appkit/printing/settings.rs index df40dba3..40df0841 100644 --- a/src/appkit/printing/settings.rs +++ b/src/appkit/printing/settings.rs @@ -1,8 +1,8 @@ //! Represents settings for printing items. Backed by an `NSDictionary` in Objective-C, this struct //! aims to make it easier to query/process printing operations. +use crate::id_shim::ShareId; use objc::runtime::Object; -use objc_id::ShareId; use crate::foundation::id; diff --git a/src/appkit/segmentedcontrol.rs b/src/appkit/segmentedcontrol.rs index ba9fbb72..1f2a2aea 100644 --- a/src/appkit/segmentedcontrol.rs +++ b/src/appkit/segmentedcontrol.rs @@ -6,10 +6,10 @@ use std::sync::Once; use std::cell::RefCell; use std::rc::Rc; +use crate::id_shim::ShareId; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::control::Control; diff --git a/src/appkit/toolbar/item.rs b/src/appkit/toolbar/item.rs index 201fc375..4615ed06 100644 --- a/src/appkit/toolbar/item.rs +++ b/src/appkit/toolbar/item.rs @@ -6,9 +6,9 @@ use core_graphics::geometry::CGSize; use std::fmt; +use crate::id_shim::{Id, ShareId}; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::{Id, ShareId}; use crate::appkit::segmentedcontrol::SegmentedControl; use crate::button::{BezelStyle, Button}; diff --git a/src/appkit/toolbar/mod.rs b/src/appkit/toolbar/mod.rs index 35298383..b783992c 100644 --- a/src/appkit/toolbar/mod.rs +++ b/src/appkit/toolbar/mod.rs @@ -5,9 +5,9 @@ use std::fmt; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSString, NSUInteger, NO, YES}; diff --git a/src/appkit/window/controller/mod.rs b/src/appkit/window/controller/mod.rs index 0fbba822..8561b53b 100644 --- a/src/appkit/window/controller/mod.rs +++ b/src/appkit/window/controller/mod.rs @@ -30,9 +30,9 @@ use std::fmt; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::Id; use crate::appkit::window::{Window, WindowConfig, WindowDelegate, WINDOW_DELEGATE_PTR}; use crate::foundation::{id, nil}; diff --git a/src/appkit/window/mod.rs b/src/appkit/window/mod.rs index 7069e55f..f1c7dade 100644 --- a/src/appkit/window/mod.rs +++ b/src/appkit/window/mod.rs @@ -13,9 +13,9 @@ use block::ConcreteBlock; use core_graphics::base::CGFloat; use core_graphics::geometry::{CGRect, CGSize}; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::appkit::toolbar::{Toolbar, ToolbarDelegate}; use crate::color::Color; diff --git a/src/button/mod.rs b/src/button/mod.rs index 354751b7..dc7fecc4 100644 --- a/src/button/mod.rs +++ b/src/button/mod.rs @@ -21,9 +21,9 @@ //! my_view.add_subview(&button); //! ``` +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; pub use enums::*; diff --git a/src/cloudkit/share.rs b/src/cloudkit/share.rs index ea2eec72..d36d9648 100644 --- a/src/cloudkit/share.rs +++ b/src/cloudkit/share.rs @@ -1,7 +1,7 @@ //! This module includes wrappers for `CKShare` and `CKShareMetaData`. +use crate::id_shim::ShareId; use objc::runtime::Object; -use objc_id::ShareId; use crate::foundation::id; diff --git a/src/color/mod.rs b/src/color/mod.rs index 0f46cd2e..648ff50a 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -18,9 +18,9 @@ use std::sync::{Arc, RwLock}; use core_graphics::base::CGFloat; use core_graphics::color::CGColor; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::id; use crate::utils::os; diff --git a/src/defaults/mod.rs b/src/defaults/mod.rs index 5e8d4910..091bfe2d 100644 --- a/src/defaults/mod.rs +++ b/src/defaults/mod.rs @@ -34,9 +34,9 @@ use std::collections::HashMap; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, nil, to_bool, NSData, NSMutableDictionary, NSNumber, NSString, BOOL, NO, YES}; diff --git a/src/dragdrop.rs b/src/dragdrop.rs index 7e32f62b..12cfcbb8 100644 --- a/src/dragdrop.rs +++ b/src/dragdrop.rs @@ -2,9 +2,9 @@ //! across the codebase, hence why they're here - they're not currently exhaustive, so feel free to //! tinker and pull request. +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::NSUInteger; use crate::pasteboard::Pasteboard; diff --git a/src/filesystem/manager.rs b/src/filesystem/manager.rs index 4a02878f..e455507a 100644 --- a/src/filesystem/manager.rs +++ b/src/filesystem/manager.rs @@ -4,9 +4,9 @@ use std::error::Error; use std::sync::{Arc, RwLock}; +use crate::id_shim::Id; use objc::runtime::{Object, BOOL}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use url::Url; use crate::error::Error as AppKitError; diff --git a/src/filesystem/save.rs b/src/filesystem/save.rs index e76dff0b..4e65e77f 100644 --- a/src/filesystem/save.rs +++ b/src/filesystem/save.rs @@ -4,9 +4,9 @@ use block::ConcreteBlock; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSInteger, NSString, NO, YES}; diff --git a/src/filesystem/select.rs b/src/filesystem/select.rs index 56ff4a93..0e5b822b 100644 --- a/src/filesystem/select.rs +++ b/src/filesystem/select.rs @@ -6,9 +6,9 @@ use std::path::PathBuf; use block::ConcreteBlock; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::filesystem::enums::ModalResponse; use crate::foundation::{id, nil, NSInteger, NSString, NO, NSURL, YES}; diff --git a/src/foundation/array.rs b/src/foundation/array.rs index 800156c2..a351b3d6 100644 --- a/src/foundation/array.rs +++ b/src/foundation/array.rs @@ -1,8 +1,8 @@ use std::ops::{Deref, DerefMut}; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::id; diff --git a/src/foundation/autoreleasepool.rs b/src/foundation/autoreleasepool.rs index 01dff603..11b80a1b 100644 --- a/src/foundation/autoreleasepool.rs +++ b/src/foundation/autoreleasepool.rs @@ -1,6 +1,6 @@ +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; /// A wrapper around `NSAutoReleasePool`. The core `App` structures create and manage one of these, /// but it's conceivable that users might need to create their own. diff --git a/src/foundation/data.rs b/src/foundation/data.rs index c8042865..79f3ce4d 100644 --- a/src/foundation/data.rs +++ b/src/foundation/data.rs @@ -5,9 +5,9 @@ use std::slice; use block::{Block, ConcreteBlock}; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, to_bool, NSUInteger, BOOL, NO, YES}; diff --git a/src/foundation/dictionary.rs b/src/foundation/dictionary.rs index 58909bf6..cffb5f7f 100644 --- a/src/foundation/dictionary.rs +++ b/src/foundation/dictionary.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use std::ops::{Deref, DerefMut}; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSString}; diff --git a/src/foundation/number.rs b/src/foundation/number.rs index 146762ac..f46d1e23 100644 --- a/src/foundation/number.rs +++ b/src/foundation/number.rs @@ -1,9 +1,9 @@ use std::ffi::CStr; use std::os::raw::c_char; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, to_bool, NSInteger, BOOL, NO, YES}; diff --git a/src/foundation/string.rs b/src/foundation/string.rs index 543640f4..8e19149c 100644 --- a/src/foundation/string.rs +++ b/src/foundation/string.rs @@ -3,9 +3,9 @@ use std::ops::{Deref, DerefMut}; use std::os::raw::c_char; use std::{fmt, slice, str}; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, to_bool, BOOL, NO, YES}; diff --git a/src/foundation/urls/mod.rs b/src/foundation/urls/mod.rs index 6af1374f..dab3dc22 100644 --- a/src/foundation/urls/mod.rs +++ b/src/foundation/urls/mod.rs @@ -3,9 +3,9 @@ use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSData, NSString, NSUInteger}; diff --git a/src/image/handle.rs b/src/image/handle.rs index 99ceb6f9..2bc0d216 100644 --- a/src/image/handle.rs +++ b/src/image/handle.rs @@ -1,5 +1,5 @@ -use objc_id::ShareId; +use crate::id_shim::ShareId; use objc::runtime::Object; /// Views get passed these, and can diff --git a/src/image/image.rs b/src/image/image.rs index 3588da3a..b4d10d84 100644 --- a/src/image/image.rs +++ b/src/image/image.rs @@ -1,5 +1,5 @@ +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc_id::ShareId; use objc::{class, msg_send, sel, sel_impl}; diff --git a/src/image/mod.rs b/src/image/mod.rs index a949da73..b743e056 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -1,6 +1,6 @@ +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/input/mod.rs b/src/input/mod.rs index 4af8bb02..d3b4aa8b 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -43,9 +43,9 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::control::Control; diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 83f15a23..2cb8e9f2 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -1,9 +1,9 @@ use std::sync::Once; +use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, load_or_register_class, NSString, NSUInteger, NO, YES}; use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR}; diff --git a/src/invoker.rs b/src/invoker.rs index d1cddb9d..f6bd537a 100644 --- a/src/invoker.rs +++ b/src/invoker.rs @@ -10,9 +10,9 @@ use std::fmt; +use crate::id_shim::ShareId; use objc::runtime::{Class, Object, Sel}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, load_or_register_class}; use crate::utils::load; diff --git a/src/layout/animator.rs b/src/layout/animator.rs index 758ae999..20e1552e 100644 --- a/src/layout/animator.rs +++ b/src/layout/animator.rs @@ -1,8 +1,8 @@ use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::id; diff --git a/src/layout/constraint.rs b/src/layout/constraint.rs index 2b6df128..6f992325 100644 --- a/src/layout/constraint.rs +++ b/src/layout/constraint.rs @@ -4,9 +4,9 @@ use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, NO, YES}; @@ -94,7 +94,7 @@ impl LayoutConstraint { /// Call this with your batch of constraints to activate them. // If you're astute, you'll note that, yes... this is kind of hacking around some - // borrowing rules with how objc_id::Id/objc_id::ShareId works. In this case, to + // borrowing rules with how crate::id_shim::Id/crate::id_shim::ShareId works. In this case, to // support the way autolayout constraints work over in the cocoa runtime, we need to be // able to clone these and pass them around... while also getting certain references to // them. diff --git a/src/layout/dimension.rs b/src/layout/dimension.rs index 80cb38ff..ef7cf217 100644 --- a/src/layout/dimension.rs +++ b/src/layout/dimension.rs @@ -1,8 +1,8 @@ use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSInteger}; use crate::layout::constraint::LayoutConstraint; diff --git a/src/layout/horizontal.rs b/src/layout/horizontal.rs index c2595376..8f445b7a 100644 --- a/src/layout/horizontal.rs +++ b/src/layout/horizontal.rs @@ -1,6 +1,6 @@ +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::id; use crate::layout::constraint::LayoutConstraint; diff --git a/src/layout/traits.rs b/src/layout/traits.rs index 833f27a6..31c37c73 100644 --- a/src/layout/traits.rs +++ b/src/layout/traits.rs @@ -4,9 +4,9 @@ use core_graphics::base::CGFloat; use core_graphics::geometry::{CGPoint, CGRect, CGSize}; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, to_bool, NSArray, NSString, NO, YES}; use crate::geometry::Rect; diff --git a/src/layout/vertical.rs b/src/layout/vertical.rs index 63ce6240..a47b45a1 100644 --- a/src/layout/vertical.rs +++ b/src/layout/vertical.rs @@ -1,6 +1,6 @@ +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::id; use crate::layout::constraint::LayoutConstraint; diff --git a/src/lib.rs b/src/lib.rs index cfe5f5e3..acab8d43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,65 @@ pub use lazy_static; pub use objc; pub use url; +// Temporary! +// +// Requires patched `objc2` with unsealed `MessageReceiver` trait +mod id_shim { + use core::ops::{Deref, DerefMut}; + use objc::rc::{self, Owned, Ownership, Shared}; + use objc::runtime::Object; + use objc::{Message, MessageReceiver}; + + #[repr(transparent)] + #[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] + pub struct Id(rc::Id); + + unsafe impl<'a, T: Message, O: Ownership> MessageReceiver for &'a Id { + fn __as_raw_receiver(self) -> *mut Object { + self.0.__as_raw_receiver() + } + } + + unsafe impl<'a, T: Message> MessageReceiver for &'a mut Id { + fn __as_raw_receiver(self) -> *mut Object { + self.0.__as_raw_receiver() + } + } + + impl Id { + pub unsafe fn from_ptr(ptr: *mut T) -> Id { + Self(rc::Id::retain(ptr).unwrap()) + } + + pub unsafe fn from_retained_ptr(ptr: *mut T) -> Id { + Self(rc::Id::new(ptr).unwrap()) + } + } + + impl Clone for Id { + fn clone(&self) -> Id { + Self(self.0.clone()) + } + } + + impl Deref for Id { + type Target = T; + + fn deref(&self) -> &T { + &*self.0 + } + } + + impl DerefMut for Id { + fn deref_mut(&mut self) -> &mut T { + &mut *self.0 + } + } + + pub type ShareId = Id; +} +pub use id_shim::*; + //#[cfg(all(feature = "appkit", feature = "uikit", not(feature = "doc_cfg")))] //compile_error!("The \"appkit\" and \"uikit\" features cannot be enabled together. Pick one. :)"); diff --git a/src/listview/actions.rs b/src/listview/actions.rs index f625d5c9..c339ed03 100644 --- a/src/listview/actions.rs +++ b/src/listview/actions.rs @@ -1,6 +1,6 @@ +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use block::ConcreteBlock; diff --git a/src/listview/appkit.rs b/src/listview/appkit.rs index 81b2dd31..73f780ac 100644 --- a/src/listview/appkit.rs +++ b/src/listview/appkit.rs @@ -7,9 +7,9 @@ //! for in the modern era. It also implements a few helpers for things like setting a background //! color, and enforcing layer backing by default. +use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{msg_send, sel, sel_impl}; -use objc_id::Id; use crate::appkit::menu::Menu; use crate::dragdrop::DragInfo; diff --git a/src/listview/mod.rs b/src/listview/mod.rs index cf3a2b4d..713e42fd 100644 --- a/src/listview/mod.rs +++ b/src/listview/mod.rs @@ -44,10 +44,10 @@ use std::collections::HashMap; +use crate::id_shim::ShareId; use core_graphics::base::CGFloat; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NSUInteger, NO, YES}; diff --git a/src/listview/row/appkit.rs b/src/listview/row/appkit.rs index 054820bb..370df02b 100644 --- a/src/listview/row/appkit.rs +++ b/src/listview/row/appkit.rs @@ -7,9 +7,9 @@ //! for in the modern era. It also implements a few helpers for things like setting a background //! color, and enforcing layer backing by default. +use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, nil, NSUInteger, NO, YES}; diff --git a/src/listview/row/mod.rs b/src/listview/row/mod.rs index 44c829f2..b27a3570 100644 --- a/src/listview/row/mod.rs +++ b/src/listview/row/mod.rs @@ -45,9 +45,9 @@ use std::cell::RefCell; use std::rc::Rc; +use crate::id_shim::{Id, ShareId}; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::{Id, ShareId}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/listview/row/uikit.rs b/src/listview/row/uikit.rs index 76ea8b97..907ac44b 100644 --- a/src/listview/row/uikit.rs +++ b/src/listview/row/uikit.rs @@ -1,7 +1,7 @@ use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, sel, sel_impl}; -use objc_id::Id; +use crate::id_shim::Id; use crate::dragdrop::DragInfo; use crate::foundation::{id, NSUInteger, NO, YES}; diff --git a/src/networking/mod.rs b/src/networking/mod.rs index 42d05096..3cd6728c 100644 --- a/src/networking/mod.rs +++ b/src/networking/mod.rs @@ -1,12 +1,12 @@ //! A lightweight wrapper over some networking components, like `NSURLRequest` and co. //! +use crate::id_shim::ShareId; use objc::runtime::Object; /// At the moment, this is mostly used for inspection of objects returned from system /// calls, as `NSURL` is pervasive in some filesystem references. Over time this may grow to /// include a proper networking stack, but the expectation for v0.1 is that most apps will want to /// use their standard Rust networking libraries (however... odd... the async story may be). use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, NSString}; diff --git a/src/notification_center/mod.rs b/src/notification_center/mod.rs index c62ed586..9e50653e 100644 --- a/src/notification_center/mod.rs +++ b/src/notification_center/mod.rs @@ -18,7 +18,7 @@ //use lazy_static::lazy_static; //use objc::{class, msg_send, sel, sel_impl}; //use objc::runtime::Object; -//use objc_id::ShareId; +//use crate::id_shim::ShareId; mod name; pub use name::NotificationName; diff --git a/src/pasteboard/mod.rs b/src/pasteboard/mod.rs index 3847ff49..15449002 100644 --- a/src/pasteboard/mod.rs +++ b/src/pasteboard/mod.rs @@ -15,9 +15,9 @@ use std::path::PathBuf; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use url::Url; use crate::error::Error; diff --git a/src/progress/mod.rs b/src/progress/mod.rs index 90ef3a0b..68fecb62 100644 --- a/src/progress/mod.rs +++ b/src/progress/mod.rs @@ -17,9 +17,9 @@ use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::foundation::{id, nil, NSUInteger, NO, YES}; diff --git a/src/quicklook/config.rs b/src/quicklook/config.rs index 7c347c46..fa62fc71 100644 --- a/src/quicklook/config.rs +++ b/src/quicklook/config.rs @@ -1,9 +1,9 @@ use std::path::Path; +use crate::id_shim::ShareId; use core_graphics::base::CGFloat; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, NSString, NSUInteger, YES}; use crate::utils::CGSize; diff --git a/src/quicklook/mod.rs b/src/quicklook/mod.rs index 4628963b..5e72fc71 100644 --- a/src/quicklook/mod.rs +++ b/src/quicklook/mod.rs @@ -1,8 +1,8 @@ use std::path::Path; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use block::ConcreteBlock; diff --git a/src/scrollview/appkit.rs b/src/scrollview/appkit.rs index 6d083087..90bcb6c4 100644 --- a/src/scrollview/appkit.rs +++ b/src/scrollview/appkit.rs @@ -7,9 +7,9 @@ //! for in the modern era. It also implements a few helpers for things like setting a background //! color, and enforcing layer backing by default. +use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{sel, sel_impl}; -use objc_id::Id; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, NSUInteger, NO, YES}; diff --git a/src/scrollview/mod.rs b/src/scrollview/mod.rs index 3f939183..f6759e21 100644 --- a/src/scrollview/mod.rs +++ b/src/scrollview/mod.rs @@ -42,9 +42,9 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/scrollview/uikit.rs b/src/scrollview/uikit.rs index f21caafc..6fafd042 100644 --- a/src/scrollview/uikit.rs +++ b/src/scrollview/uikit.rs @@ -9,10 +9,10 @@ use std::sync::Once; +use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSUInteger, NO, YES}; use crate::scrollview::{ScrollViewDelegate, SCROLLVIEW_DELEGATE_PTR}; diff --git a/src/select/mod.rs b/src/select/mod.rs index dd01cd0d..e0db1df0 100644 --- a/src/select/mod.rs +++ b/src/select/mod.rs @@ -1,9 +1,9 @@ //! Implements a Select-style dropdown. By default this uses NSPopupSelect on macOS. +use crate::id_shim::ShareId; use core_graphics::geometry::CGRect; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::control::Control; use crate::foundation::{id, load_or_register_class, nil, NSInteger, NSString, NO, YES}; diff --git a/src/switch.rs b/src/switch.rs index d453f48a..773c38e3 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -1,9 +1,9 @@ //! A wrapper for NSSwitch. Currently the epitome of jank - if you're poking around here, expect //! that this will change at some point. +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, load_or_register_class, nil, NSString, NO}; use crate::invoker::TargetActionHandler; diff --git a/src/text/attributed_string.rs b/src/text/attributed_string.rs index 4cfde00b..8b5b4480 100644 --- a/src/text/attributed_string.rs +++ b/src/text/attributed_string.rs @@ -5,9 +5,9 @@ use std::{fmt, slice, str}; use core_foundation::base::CFRange; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::color::Color; use crate::foundation::{id, to_bool, NSString, BOOL, NO, YES}; diff --git a/src/text/font.rs b/src/text/font.rs index f65c0bc3..9ebbe5fc 100644 --- a/src/text/font.rs +++ b/src/text/font.rs @@ -4,9 +4,9 @@ use std::ops::Deref; use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; use crate::utils::os; diff --git a/src/text/label/mod.rs b/src/text/label/mod.rs index 04844a3d..496e439b 100644 --- a/src/text/label/mod.rs +++ b/src/text/label/mod.rs @@ -43,9 +43,9 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NSUInteger, NO, YES}; diff --git a/src/text/label/uikit.rs b/src/text/label/uikit.rs index 87d4c0bf..c631dccd 100644 --- a/src/text/label/uikit.rs +++ b/src/text/label/uikit.rs @@ -1,9 +1,9 @@ use std::sync::Once; +use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSUInteger, NO, YES}; use crate::text::label::{LabelDelegate, LABEL_DELEGATE_PTR}; diff --git a/src/uikit/scene/config.rs b/src/uikit/scene/config.rs index 46ff2059..99358a2a 100644 --- a/src/uikit/scene/config.rs +++ b/src/uikit/scene/config.rs @@ -1,6 +1,6 @@ +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, load_or_register_class, ClassMap, NSString}; diff --git a/src/uikit/scene/mod.rs b/src/uikit/scene/mod.rs index 4bab965c..ee61b799 100644 --- a/src/uikit/scene/mod.rs +++ b/src/uikit/scene/mod.rs @@ -5,9 +5,9 @@ use core_graphics::geometry::CGRect; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::id; use crate::geometry::Rect; diff --git a/src/uikit/scene/options.rs b/src/uikit/scene/options.rs index 9ba48ab9..38192896 100644 --- a/src/uikit/scene/options.rs +++ b/src/uikit/scene/options.rs @@ -1,6 +1,6 @@ +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSString}; diff --git a/src/uikit/scene/session.rs b/src/uikit/scene/session.rs index bf16825a..69d6d208 100644 --- a/src/uikit/scene/session.rs +++ b/src/uikit/scene/session.rs @@ -1,6 +1,6 @@ +use crate::id_shim::Id; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSString}; use crate::uikit::scene::enums::SessionRole; diff --git a/src/uikit/window/mod.rs b/src/uikit/window/mod.rs index 671fff1a..4d1d08fe 100644 --- a/src/uikit/window/mod.rs +++ b/src/uikit/window/mod.rs @@ -1,8 +1,8 @@ use core_graphics::geometry::CGRect; +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::id; use crate::geometry::Rect; diff --git a/src/user_activity.rs b/src/user_activity.rs index a51af862..d0f5d881 100644 --- a/src/user_activity.rs +++ b/src/user_activity.rs @@ -2,8 +2,8 @@ //! //! This is primarily used in handling app handoff between devices. +use crate::id_shim::ShareId; use objc::runtime::Object; -use objc_id::ShareId; use crate::foundation::id; diff --git a/src/user_notifications/notifications.rs b/src/user_notifications/notifications.rs index 228f404c..26cdd5bd 100644 --- a/src/user_notifications/notifications.rs +++ b/src/user_notifications/notifications.rs @@ -1,9 +1,9 @@ //! Acts as a (currently dumb) wrapper for `UNMutableNotificationContent`, which is what you mostly //! need to pass to the notification center for things to work. +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSString}; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e005a586..11050e56 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -6,9 +6,9 @@ use core_graphics::base::CGFloat; use objc::{class, msg_send, sel, sel_impl}; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{Encode, Encoding}; -use objc_id::ShareId; use crate::foundation::{id, BOOL, NO, YES}; diff --git a/src/utils/properties.rs b/src/utils/properties.rs index f4d5ee83..ef4cef3d 100644 --- a/src/utils/properties.rs +++ b/src/utils/properties.rs @@ -1,8 +1,8 @@ use std::cell::RefCell; use std::rc::Rc; +use crate::id_shim::Id; use objc::runtime::Object; -use objc_id::Id; use crate::foundation::id; diff --git a/src/view/animator.rs b/src/view/animator.rs index 335120c1..415f0e5e 100644 --- a/src/view/animator.rs +++ b/src/view/animator.rs @@ -1,8 +1,8 @@ use core_graphics::base::CGFloat; +use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::id; diff --git a/src/view/appkit.rs b/src/view/appkit.rs index 4ada6c03..dfb93846 100644 --- a/src/view/appkit.rs +++ b/src/view/appkit.rs @@ -7,10 +7,10 @@ //! for in the modern era. It also implements a few helpers for things like setting a background //! color, and enforcing layer backing by default. +use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, nil, NSUInteger, NO, YES}; diff --git a/src/view/controller/mod.rs b/src/view/controller/mod.rs index 70a429ef..aea1cfc7 100644 --- a/src/view/controller/mod.rs +++ b/src/view/controller/mod.rs @@ -1,6 +1,6 @@ +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::id; use crate::layout::Layout; diff --git a/src/view/popover/mod.rs b/src/view/popover/mod.rs index 8f7c0cc6..deb6a641 100644 --- a/src/view/popover/mod.rs +++ b/src/view/popover/mod.rs @@ -1,7 +1,7 @@ +use crate::id_shim::ShareId; use core_graphics::geometry::CGRect; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; #[cfg(feature = "appkit")] use crate::appkit::toolbar::ToolbarItem; diff --git a/src/view/splitviewcontroller/mod.rs b/src/view/splitviewcontroller/mod.rs index 65e83a0b..e6e20c64 100644 --- a/src/view/splitviewcontroller/mod.rs +++ b/src/view/splitviewcontroller/mod.rs @@ -1,6 +1,6 @@ +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::appkit::toolbar::ToolbarItem; use crate::foundation::{id, nil, NSString}; diff --git a/src/view/uikit.rs b/src/view/uikit.rs index ba029458..de3e8878 100644 --- a/src/view/uikit.rs +++ b/src/view/uikit.rs @@ -1,7 +1,7 @@ +use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; use objc::{class, sel, sel_impl}; -use objc_id::Id; use crate::foundation::load_or_register_class; use crate::foundation::{id, NSUInteger, NO, YES}; diff --git a/src/webview/config.rs b/src/webview/config.rs index 7a08dc9f..df8005d0 100644 --- a/src/webview/config.rs +++ b/src/webview/config.rs @@ -1,9 +1,9 @@ //! A wrapper for `WKWebViewConfiguration`. It aims to (mostly) cover //! the important pieces of configuring and updating a WebView configuration. +use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::Id; use crate::foundation::{id, NSInteger, NSString, NO, YES}; use crate::webview::enums::InjectAt; diff --git a/src/webview/mod.rs b/src/webview/mod.rs index 1161068c..dec54869 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -15,9 +15,9 @@ use core_graphics::geometry::CGRect; +use crate::id_shim::ShareId; use objc::runtime::Object; use objc::{class, msg_send, sel, sel_impl}; -use objc_id::ShareId; use crate::foundation::{id, nil, NSString, NO, YES}; use crate::geometry::Rect; From b4719f78c90aae96a6cc4aee14a582677698b3b6 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 5 Sep 2023 12:28:06 +0200 Subject: [PATCH 03/19] Remove sel_impl import --- examples/browser/toolbar.rs | 2 +- src/appkit/alert.rs | 2 +- src/appkit/animation.rs | 2 +- src/appkit/app/delegate.rs | 2 +- src/appkit/app/mod.rs | 2 +- src/appkit/cursor.rs | 2 +- src/appkit/event/mod.rs | 2 +- src/appkit/haptics.rs | 2 +- src/appkit/menu/item.rs | 2 +- src/appkit/menu/menu.rs | 2 +- src/appkit/segmentedcontrol.rs | 2 +- src/appkit/toolbar/class.rs | 2 +- src/appkit/toolbar/item.rs | 2 +- src/appkit/toolbar/mod.rs | 2 +- src/appkit/window/class.rs | 2 +- src/appkit/window/controller/mod.rs | 2 +- src/appkit/window/mod.rs | 2 +- src/bundle.rs | 2 +- src/button/mod.rs | 2 +- src/color/appkit_dynamic_color.rs | 2 +- src/color/mod.rs | 2 +- src/control/mod.rs | 2 +- src/defaults/mod.rs | 2 +- src/dragdrop.rs | 2 +- src/error.rs | 2 +- src/filesystem/manager.rs | 2 +- src/filesystem/save.rs | 2 +- src/filesystem/select.rs | 2 +- src/foundation/array.rs | 2 +- src/foundation/autoreleasepool.rs | 2 +- src/foundation/data.rs | 2 +- src/foundation/dictionary.rs | 2 +- src/foundation/number.rs | 2 +- src/foundation/string.rs | 2 +- src/foundation/urls/mod.rs | 2 +- src/image/image.rs | 2 +- src/image/mod.rs | 2 +- src/input/appkit.rs | 2 +- src/input/mod.rs | 2 +- src/input/uikit.rs | 2 +- src/invoker.rs | 2 +- src/layer/mod.rs | 2 +- src/layout/animator.rs | 2 +- src/layout/constraint.rs | 2 +- src/layout/dimension.rs | 2 +- src/layout/horizontal.rs | 2 +- src/layout/safe_guide.rs | 2 +- src/layout/traits.rs | 2 +- src/layout/vertical.rs | 2 +- src/listview/actions.rs | 2 +- src/listview/appkit.rs | 2 +- src/listview/mod.rs | 2 +- src/listview/row/appkit.rs | 2 +- src/listview/row/mod.rs | 2 +- src/listview/row/uikit.rs | 2 +- src/networking/mod.rs | 4 ++-- src/notification_center/mod.rs | 2 +- src/pasteboard/mod.rs | 2 +- src/progress/mod.rs | 2 +- src/quicklook/config.rs | 2 +- src/quicklook/mod.rs | 2 +- src/scrollview/appkit.rs | 2 +- src/scrollview/mod.rs | 2 +- src/scrollview/uikit.rs | 2 +- src/select/mod.rs | 2 +- src/switch.rs | 2 +- src/text/attributed_string.rs | 2 +- src/text/font.rs | 2 +- src/text/label/mod.rs | 2 +- src/text/label/uikit.rs | 2 +- src/uikit/app/delegate.rs | 2 +- src/uikit/app/mod.rs | 2 +- src/uikit/scene/config.rs | 2 +- src/uikit/scene/delegate.rs | 2 +- src/uikit/scene/mod.rs | 2 +- src/uikit/scene/options.rs | 2 +- src/uikit/scene/session.rs | 2 +- src/uikit/window/mod.rs | 2 +- src/user_notifications/mod.rs | 2 +- src/user_notifications/notifications.rs | 2 +- src/utils/mod.rs | 2 +- src/view/animator.rs | 2 +- src/view/appkit.rs | 2 +- src/view/controller/appkit.rs | 2 +- src/view/controller/mod.rs | 2 +- src/view/controller/uikit.rs | 2 +- src/view/mod.rs | 2 +- src/view/popover/mod.rs | 2 +- src/view/splitviewcontroller/ios.rs | 2 +- src/view/splitviewcontroller/macos.rs | 2 +- src/view/splitviewcontroller/mod.rs | 2 +- src/view/uikit.rs | 2 +- src/webview/actions.rs | 2 +- src/webview/class.rs | 2 +- src/webview/config.rs | 2 +- src/webview/mod.rs | 2 +- src/webview/process_pool.rs | 2 +- 97 files changed, 98 insertions(+), 98 deletions(-) diff --git a/examples/browser/toolbar.rs b/examples/browser/toolbar.rs index b4416dd7..91ac5546 100644 --- a/examples/browser/toolbar.rs +++ b/examples/browser/toolbar.rs @@ -1,4 +1,4 @@ -use cacao::objc::{msg_send, sel, sel_impl}; +use cacao::objc::{msg_send, sel}; use cacao::button::Button; use cacao::input::{TextField, TextFieldDelegate}; diff --git a/src/appkit/alert.rs b/src/appkit/alert.rs index af9b9d0e..62d6ddd5 100644 --- a/src/appkit/alert.rs +++ b/src/appkit/alert.rs @@ -26,7 +26,7 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString}; diff --git a/src/appkit/animation.rs b/src/appkit/animation.rs index 73a2f8b2..b7750d67 100644 --- a/src/appkit/animation.rs +++ b/src/appkit/animation.rs @@ -1,5 +1,5 @@ use block::ConcreteBlock; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; diff --git a/src/appkit/app/delegate.rs b/src/appkit/app/delegate.rs index 0e90c2fe..4296fbdd 100644 --- a/src/appkit/app/delegate.rs +++ b/src/appkit/app/delegate.rs @@ -6,7 +6,7 @@ use std::ffi::c_void; use block::Block; use objc::runtime::{Class, Object, Sel}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use url::Url; use crate::appkit::app::{AppDelegate, APP_PTR}; diff --git a/src/appkit/app/mod.rs b/src/appkit/app/mod.rs index d46c710f..e67066f0 100644 --- a/src/appkit/app/mod.rs +++ b/src/appkit/app/mod.rs @@ -41,7 +41,7 @@ use lazy_static::lazy_static; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::menu::Menu; use crate::foundation::{id, nil, AutoReleasePool, NSUInteger, NO, YES}; diff --git a/src/appkit/cursor.rs b/src/appkit/cursor.rs index 838f0d9d..2a161f30 100644 --- a/src/appkit/cursor.rs +++ b/src/appkit/cursor.rs @@ -1,4 +1,4 @@ -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NO, YES}; diff --git a/src/appkit/event/mod.rs b/src/appkit/event/mod.rs index ec10cacd..1e21a526 100644 --- a/src/appkit/event/mod.rs +++ b/src/appkit/event/mod.rs @@ -3,7 +3,7 @@ use block::ConcreteBlock; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::events::EventType; use crate::foundation::{id, nil, NSInteger, NSPoint, NSString}; diff --git a/src/appkit/haptics.rs b/src/appkit/haptics.rs index dfd45a17..c7772a44 100644 --- a/src/appkit/haptics.rs +++ b/src/appkit/haptics.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; use crate::id_shim::ShareId; -use objc::{class, msg_send, runtime::Object, sel, sel_impl}; +use objc::{class, msg_send, runtime::Object, sel}; use crate::foundation::NSUInteger; diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index a5d61093..69c0b91b 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -6,7 +6,7 @@ use std::fmt; use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::events::EventModifierFlag; use crate::foundation::{id, load_or_register_class, NSString, NSUInteger}; diff --git a/src/appkit/menu/menu.rs b/src/appkit/menu/menu.rs index 11e1993d..00106f4d 100644 --- a/src/appkit/menu/menu.rs +++ b/src/appkit/menu/menu.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex}; use crate::id_shim::{Id, ShareId}; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::menu::item::MenuItem; use crate::foundation::{id, NSInteger, NSString}; diff --git a/src/appkit/segmentedcontrol.rs b/src/appkit/segmentedcontrol.rs index 1f2a2aea..b9d753e6 100644 --- a/src/appkit/segmentedcontrol.rs +++ b/src/appkit/segmentedcontrol.rs @@ -9,7 +9,7 @@ use std::rc::Rc; use crate::id_shim::ShareId; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::control::Control; diff --git a/src/appkit/toolbar/class.rs b/src/appkit/toolbar/class.rs index 719f799f..8e190972 100644 --- a/src/appkit/toolbar/class.rs +++ b/src/appkit/toolbar/class.rs @@ -4,7 +4,7 @@ use std::sync::Once; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::toolbar::{ToolbarDelegate, TOOLBAR_PTR}; use crate::foundation::{id, load_or_register_class, NSArray, NSString, BOOL}; diff --git a/src/appkit/toolbar/item.rs b/src/appkit/toolbar/item.rs index 4615ed06..e6af5a33 100644 --- a/src/appkit/toolbar/item.rs +++ b/src/appkit/toolbar/item.rs @@ -8,7 +8,7 @@ use std::fmt; use crate::id_shim::{Id, ShareId}; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::segmentedcontrol::SegmentedControl; use crate::button::{BezelStyle, Button}; diff --git a/src/appkit/toolbar/mod.rs b/src/appkit/toolbar/mod.rs index b783992c..dfcc287f 100644 --- a/src/appkit/toolbar/mod.rs +++ b/src/appkit/toolbar/mod.rs @@ -7,7 +7,7 @@ use std::fmt; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSString, NSUInteger, NO, YES}; diff --git a/src/appkit/window/class.rs b/src/appkit/window/class.rs index 73a53898..9cf662b8 100644 --- a/src/appkit/window/class.rs +++ b/src/appkit/window/class.rs @@ -7,7 +7,7 @@ use core_graphics::base::CGFloat; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, sel, sel_impl}; +use objc::{class, sel}; use crate::appkit::window::{WindowDelegate, WINDOW_DELEGATE_PTR}; use crate::foundation::{id, load_or_register_class, NSUInteger, BOOL, NO, YES}; diff --git a/src/appkit/window/controller/mod.rs b/src/appkit/window/controller/mod.rs index 8561b53b..1c6e3a20 100644 --- a/src/appkit/window/controller/mod.rs +++ b/src/appkit/window/controller/mod.rs @@ -32,7 +32,7 @@ use std::fmt; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::appkit::window::{Window, WindowConfig, WindowDelegate, WINDOW_DELEGATE_PTR}; use crate::foundation::{id, nil}; diff --git a/src/appkit/window/mod.rs b/src/appkit/window/mod.rs index f1c7dade..436b3bae 100644 --- a/src/appkit/window/mod.rs +++ b/src/appkit/window/mod.rs @@ -15,7 +15,7 @@ use core_graphics::geometry::{CGRect, CGSize}; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::toolbar::{Toolbar, ToolbarDelegate}; use crate::color::Color; diff --git a/src/bundle.rs b/src/bundle.rs index 5be1e11e..a34b5821 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -11,7 +11,7 @@ use std::ffi::CString; use std::mem; -use objc::{class, msg_send, sel, sel_impl, Encode, Encoding, EncodeArguments, Message}; +use objc::{class, msg_send, sel, Encode, Encoding, EncodeArguments, Message}; use objc::runtime::{Class, Sel, Method, Object, Imp}; use objc::runtime::{ objc_getClass, diff --git a/src/button/mod.rs b/src/button/mod.rs index dc7fecc4..d7ac525b 100644 --- a/src/button/mod.rs +++ b/src/button/mod.rs @@ -23,7 +23,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; pub use enums::*; diff --git a/src/color/appkit_dynamic_color.rs b/src/color/appkit_dynamic_color.rs index aa035022..3f4664be 100644 --- a/src/color/appkit_dynamic_color.rs +++ b/src/color/appkit_dynamic_color.rs @@ -12,7 +12,7 @@ use core_graphics::base::CGFloat; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, load_or_register_class, nil, NSArray, NSInteger}; use crate::utils::os; diff --git a/src/color/mod.rs b/src/color/mod.rs index 648ff50a..d1c45d4c 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -20,7 +20,7 @@ use core_graphics::color::CGColor; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; use crate::utils::os; diff --git a/src/control/mod.rs b/src/control/mod.rs index 233968a6..8691011c 100644 --- a/src/control/mod.rs +++ b/src/control/mod.rs @@ -1,5 +1,5 @@ use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSUInteger, NO, YES}; use crate::objc_access::ObjcAccess; diff --git a/src/defaults/mod.rs b/src/defaults/mod.rs index 091bfe2d..ca95a94d 100644 --- a/src/defaults/mod.rs +++ b/src/defaults/mod.rs @@ -36,7 +36,7 @@ use std::collections::HashMap; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, to_bool, NSData, NSMutableDictionary, NSNumber, NSString, BOOL, NO, YES}; diff --git a/src/dragdrop.rs b/src/dragdrop.rs index 12cfcbb8..4b2477a0 100644 --- a/src/dragdrop.rs +++ b/src/dragdrop.rs @@ -4,7 +4,7 @@ use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::NSUInteger; use crate::pasteboard::Pasteboard; diff --git a/src/error.rs b/src/error.rs index 0620fd21..e36d19b5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,7 +7,7 @@ use std::error; use std::fmt; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSInteger, NSString}; diff --git a/src/filesystem/manager.rs b/src/filesystem/manager.rs index e455507a..57ad8aa9 100644 --- a/src/filesystem/manager.rs +++ b/src/filesystem/manager.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, RwLock}; use crate::id_shim::Id; use objc::runtime::{Object, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use url::Url; use crate::error::Error as AppKitError; diff --git a/src/filesystem/save.rs b/src/filesystem/save.rs index 4e65e77f..e95082fc 100644 --- a/src/filesystem/save.rs +++ b/src/filesystem/save.rs @@ -6,7 +6,7 @@ use block::ConcreteBlock; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSInteger, NSString, NO, YES}; diff --git a/src/filesystem/select.rs b/src/filesystem/select.rs index 0e5b822b..71b6f7d5 100644 --- a/src/filesystem/select.rs +++ b/src/filesystem/select.rs @@ -8,7 +8,7 @@ use block::ConcreteBlock; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::filesystem::enums::ModalResponse; use crate::foundation::{id, nil, NSInteger, NSString, NO, NSURL, YES}; diff --git a/src/foundation/array.rs b/src/foundation/array.rs index a351b3d6..853d1ecc 100644 --- a/src/foundation/array.rs +++ b/src/foundation/array.rs @@ -2,7 +2,7 @@ use std::ops::{Deref, DerefMut}; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; diff --git a/src/foundation/autoreleasepool.rs b/src/foundation/autoreleasepool.rs index 11b80a1b..80119025 100644 --- a/src/foundation/autoreleasepool.rs +++ b/src/foundation/autoreleasepool.rs @@ -1,6 +1,6 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; /// A wrapper around `NSAutoReleasePool`. The core `App` structures create and manage one of these, /// but it's conceivable that users might need to create their own. diff --git a/src/foundation/data.rs b/src/foundation/data.rs index 79f3ce4d..473bcead 100644 --- a/src/foundation/data.rs +++ b/src/foundation/data.rs @@ -7,7 +7,7 @@ use block::{Block, ConcreteBlock}; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, to_bool, NSUInteger, BOOL, NO, YES}; diff --git a/src/foundation/dictionary.rs b/src/foundation/dictionary.rs index cffb5f7f..8be03366 100644 --- a/src/foundation/dictionary.rs +++ b/src/foundation/dictionary.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString}; diff --git a/src/foundation/number.rs b/src/foundation/number.rs index f46d1e23..42b5d965 100644 --- a/src/foundation/number.rs +++ b/src/foundation/number.rs @@ -3,7 +3,7 @@ use std::os::raw::c_char; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, to_bool, NSInteger, BOOL, NO, YES}; diff --git a/src/foundation/string.rs b/src/foundation/string.rs index 8e19149c..70fc646f 100644 --- a/src/foundation/string.rs +++ b/src/foundation/string.rs @@ -5,7 +5,7 @@ use std::{fmt, slice, str}; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, to_bool, BOOL, NO, YES}; diff --git a/src/foundation/urls/mod.rs b/src/foundation/urls/mod.rs index dab3dc22..4568a8ab 100644 --- a/src/foundation/urls/mod.rs +++ b/src/foundation/urls/mod.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSData, NSString, NSUInteger}; diff --git a/src/image/image.rs b/src/image/image.rs index b4d10d84..ea174fad 100644 --- a/src/image/image.rs +++ b/src/image/image.rs @@ -1,7 +1,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use block::ConcreteBlock; diff --git a/src/image/mod.rs b/src/image/mod.rs index b743e056..0ee6407e 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -1,6 +1,6 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/input/appkit.rs b/src/input/appkit.rs index 66df7b63..b6aa2107 100644 --- a/src/input/appkit.rs +++ b/src/input/appkit.rs @@ -1,5 +1,5 @@ use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, load_or_register_class, NSString, NO, YES}; use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR}; diff --git a/src/input/mod.rs b/src/input/mod.rs index d3b4aa8b..e71fb9c5 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -45,7 +45,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::control::Control; diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 2cb8e9f2..1c92f81c 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -3,7 +3,7 @@ use std::sync::Once; use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, load_or_register_class, NSString, NSUInteger, NO, YES}; use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR}; diff --git a/src/invoker.rs b/src/invoker.rs index f6bd537a..02133d29 100644 --- a/src/invoker.rs +++ b/src/invoker.rs @@ -12,7 +12,7 @@ use std::fmt; use crate::id_shim::ShareId; use objc::runtime::{Class, Object, Sel}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, load_or_register_class}; use crate::utils::load; diff --git a/src/layer/mod.rs b/src/layer/mod.rs index 5f849db4..b61c8d76 100644 --- a/src/layer/mod.rs +++ b/src/layer/mod.rs @@ -14,7 +14,7 @@ use core_graphics::base::CGFloat; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; use crate::utils::properties::ObjcProperty; diff --git a/src/layout/animator.rs b/src/layout/animator.rs index 20e1552e..5a11a13e 100644 --- a/src/layout/animator.rs +++ b/src/layout/animator.rs @@ -2,7 +2,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; diff --git a/src/layout/constraint.rs b/src/layout/constraint.rs index 6f992325..17055e24 100644 --- a/src/layout/constraint.rs +++ b/src/layout/constraint.rs @@ -6,7 +6,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NO, YES}; diff --git a/src/layout/dimension.rs b/src/layout/dimension.rs index ef7cf217..afcda720 100644 --- a/src/layout/dimension.rs +++ b/src/layout/dimension.rs @@ -2,7 +2,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSInteger}; use crate::layout::constraint::LayoutConstraint; diff --git a/src/layout/horizontal.rs b/src/layout/horizontal.rs index 8f445b7a..754efaab 100644 --- a/src/layout/horizontal.rs +++ b/src/layout/horizontal.rs @@ -1,6 +1,6 @@ use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; use crate::layout::constraint::LayoutConstraint; diff --git a/src/layout/safe_guide.rs b/src/layout/safe_guide.rs index 5cd14ecd..3e11e8ed 100644 --- a/src/layout/safe_guide.rs +++ b/src/layout/safe_guide.rs @@ -1,4 +1,4 @@ -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; use crate::layout::{LayoutAnchorDimension, LayoutAnchorX, LayoutAnchorY}; diff --git a/src/layout/traits.rs b/src/layout/traits.rs index 31c37c73..56c1298f 100644 --- a/src/layout/traits.rs +++ b/src/layout/traits.rs @@ -6,7 +6,7 @@ use core_graphics::geometry::{CGPoint, CGRect, CGSize}; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, nil, to_bool, NSArray, NSString, NO, YES}; use crate::geometry::Rect; diff --git a/src/layout/vertical.rs b/src/layout/vertical.rs index a47b45a1..db9c49ab 100644 --- a/src/layout/vertical.rs +++ b/src/layout/vertical.rs @@ -1,6 +1,6 @@ use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; use crate::layout::constraint::LayoutConstraint; diff --git a/src/listview/actions.rs b/src/listview/actions.rs index c339ed03..7013c8fe 100644 --- a/src/listview/actions.rs +++ b/src/listview/actions.rs @@ -1,6 +1,6 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use block::ConcreteBlock; diff --git a/src/listview/appkit.rs b/src/listview/appkit.rs index 73f780ac..728bb57d 100644 --- a/src/listview/appkit.rs +++ b/src/listview/appkit.rs @@ -9,7 +9,7 @@ use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::appkit::menu::Menu; use crate::dragdrop::DragInfo; diff --git a/src/listview/mod.rs b/src/listview/mod.rs index 713e42fd..fe4a0b98 100644 --- a/src/listview/mod.rs +++ b/src/listview/mod.rs @@ -47,7 +47,7 @@ use std::collections::HashMap; use crate::id_shim::ShareId; use core_graphics::base::CGFloat; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NSUInteger, NO, YES}; diff --git a/src/listview/row/appkit.rs b/src/listview/row/appkit.rs index 370df02b..fd2131f9 100644 --- a/src/listview/row/appkit.rs +++ b/src/listview/row/appkit.rs @@ -9,7 +9,7 @@ use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, nil, NSUInteger, NO, YES}; diff --git a/src/listview/row/mod.rs b/src/listview/row/mod.rs index b27a3570..510a6781 100644 --- a/src/listview/row/mod.rs +++ b/src/listview/row/mod.rs @@ -47,7 +47,7 @@ use std::rc::Rc; use crate::id_shim::{Id, ShareId}; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/listview/row/uikit.rs b/src/listview/row/uikit.rs index 907ac44b..349296bf 100644 --- a/src/listview/row/uikit.rs +++ b/src/listview/row/uikit.rs @@ -1,6 +1,6 @@ use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, sel, sel_impl}; +use objc::{class, sel}; use crate::id_shim::Id; use crate::dragdrop::DragInfo; diff --git a/src/networking/mod.rs b/src/networking/mod.rs index 3cd6728c..037b16a7 100644 --- a/src/networking/mod.rs +++ b/src/networking/mod.rs @@ -6,7 +6,7 @@ use objc::runtime::Object; /// calls, as `NSURL` is pervasive in some filesystem references. Over time this may grow to /// include a proper networking stack, but the expectation for v0.1 is that most apps will want to /// use their standard Rust networking libraries (however... odd... the async story may be). -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, NSString}; @@ -32,7 +32,7 @@ impl URLRequest { #[cfg(test)] mod tests { - use objc::{class, msg_send, sel, sel_impl}; + use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString}; use crate::networking::URLRequest; diff --git a/src/notification_center/mod.rs b/src/notification_center/mod.rs index 9e50653e..ddc260e7 100644 --- a/src/notification_center/mod.rs +++ b/src/notification_center/mod.rs @@ -16,7 +16,7 @@ //use std::collections::HashMap; //use lazy_static::lazy_static; -//use objc::{class, msg_send, sel, sel_impl}; +//use objc::{class, msg_send, sel}; //use objc::runtime::Object; //use crate::id_shim::ShareId; diff --git a/src/pasteboard/mod.rs b/src/pasteboard/mod.rs index 15449002..68859da9 100644 --- a/src/pasteboard/mod.rs +++ b/src/pasteboard/mod.rs @@ -17,7 +17,7 @@ use std::path::PathBuf; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use url::Url; use crate::error::Error; diff --git a/src/progress/mod.rs b/src/progress/mod.rs index 68fecb62..7e65fdc2 100644 --- a/src/progress/mod.rs +++ b/src/progress/mod.rs @@ -19,7 +19,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSUInteger, NO, YES}; diff --git a/src/quicklook/config.rs b/src/quicklook/config.rs index fa62fc71..369970b0 100644 --- a/src/quicklook/config.rs +++ b/src/quicklook/config.rs @@ -3,7 +3,7 @@ use std::path::Path; use crate::id_shim::ShareId; use core_graphics::base::CGFloat; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString, NSUInteger, YES}; use crate::utils::CGSize; diff --git a/src/quicklook/mod.rs b/src/quicklook/mod.rs index 5e72fc71..035da652 100644 --- a/src/quicklook/mod.rs +++ b/src/quicklook/mod.rs @@ -2,7 +2,7 @@ use std::path::Path; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use block::ConcreteBlock; diff --git a/src/scrollview/appkit.rs b/src/scrollview/appkit.rs index 90bcb6c4..87acd178 100644 --- a/src/scrollview/appkit.rs +++ b/src/scrollview/appkit.rs @@ -9,7 +9,7 @@ use crate::id_shim::Id; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{sel, sel_impl}; +use objc::sel; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, NSUInteger, NO, YES}; diff --git a/src/scrollview/mod.rs b/src/scrollview/mod.rs index f6759e21..13995ecf 100644 --- a/src/scrollview/mod.rs +++ b/src/scrollview/mod.rs @@ -44,7 +44,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; diff --git a/src/scrollview/uikit.rs b/src/scrollview/uikit.rs index 6fafd042..da42fdd1 100644 --- a/src/scrollview/uikit.rs +++ b/src/scrollview/uikit.rs @@ -12,7 +12,7 @@ use std::sync::Once; use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, sel, sel_impl}; +use objc::{class, sel}; use crate::foundation::{id, NSUInteger, NO, YES}; use crate::scrollview::{ScrollViewDelegate, SCROLLVIEW_DELEGATE_PTR}; diff --git a/src/select/mod.rs b/src/select/mod.rs index e0db1df0..56bf8109 100644 --- a/src/select/mod.rs +++ b/src/select/mod.rs @@ -3,7 +3,7 @@ use crate::id_shim::ShareId; use core_graphics::geometry::CGRect; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::control::Control; use crate::foundation::{id, load_or_register_class, nil, NSInteger, NSString, NO, YES}; diff --git a/src/switch.rs b/src/switch.rs index 773c38e3..2c59f0a5 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -3,7 +3,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, load_or_register_class, nil, NSString, NO}; use crate::invoker::TargetActionHandler; diff --git a/src/text/attributed_string.rs b/src/text/attributed_string.rs index 8b5b4480..9ce1c804 100644 --- a/src/text/attributed_string.rs +++ b/src/text/attributed_string.rs @@ -7,7 +7,7 @@ use core_foundation::base::CFRange; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::color::Color; use crate::foundation::{id, to_bool, NSString, BOOL, NO, YES}; diff --git a/src/text/font.rs b/src/text/font.rs index 9ebbe5fc..71b7b70b 100644 --- a/src/text/font.rs +++ b/src/text/font.rs @@ -6,7 +6,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSArray, NSString, NO, YES}; use crate::utils::os; diff --git a/src/text/label/mod.rs b/src/text/label/mod.rs index 496e439b..8d2514b6 100644 --- a/src/text/label/mod.rs +++ b/src/text/label/mod.rs @@ -45,7 +45,7 @@ use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NSUInteger, NO, YES}; diff --git a/src/text/label/uikit.rs b/src/text/label/uikit.rs index c631dccd..cbbd5782 100644 --- a/src/text/label/uikit.rs +++ b/src/text/label/uikit.rs @@ -3,7 +3,7 @@ use std::sync::Once; use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, sel, sel_impl}; +use objc::{class, sel}; use crate::foundation::{id, NSUInteger, NO, YES}; use crate::text::label::{LabelDelegate, LABEL_DELEGATE_PTR}; diff --git a/src/uikit/app/delegate.rs b/src/uikit/app/delegate.rs index 653bdf02..2f8c4fbb 100644 --- a/src/uikit/app/delegate.rs +++ b/src/uikit/app/delegate.rs @@ -3,7 +3,7 @@ //! for potential future use. use objc::runtime::{Class, Object, Sel}; -use objc::{sel, sel_impl}; +use objc::sel; //use crate::error::Error; use crate::foundation::{id, load_or_register_class_with_optional_generated_suffix, BOOL, YES}; diff --git a/src/uikit/app/mod.rs b/src/uikit/app/mod.rs index 1e0045c3..eb9367ed 100644 --- a/src/uikit/app/mod.rs +++ b/src/uikit/app/mod.rs @@ -38,7 +38,7 @@ use libc::{c_char, c_int}; use std::ffi::CString; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, AutoReleasePool, NSString, NSUInteger, NO, YES}; use crate::notification_center::Dispatcher; diff --git a/src/uikit/scene/config.rs b/src/uikit/scene/config.rs index 99358a2a..4a943d4f 100644 --- a/src/uikit/scene/config.rs +++ b/src/uikit/scene/config.rs @@ -1,6 +1,6 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, load_or_register_class, ClassMap, NSString}; diff --git a/src/uikit/scene/delegate.rs b/src/uikit/scene/delegate.rs index 660267f0..ac11c3f9 100644 --- a/src/uikit/scene/delegate.rs +++ b/src/uikit/scene/delegate.rs @@ -1,5 +1,5 @@ use objc::runtime::{Class, Object, Protocol, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, load_or_register_class_with_optional_generated_suffix}; use crate::uikit::app::SCENE_DELEGATE_VENDOR; diff --git a/src/uikit/scene/mod.rs b/src/uikit/scene/mod.rs index ee61b799..7ca7e559 100644 --- a/src/uikit/scene/mod.rs +++ b/src/uikit/scene/mod.rs @@ -7,7 +7,7 @@ use core_graphics::geometry::CGRect; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; use crate::geometry::Rect; diff --git a/src/uikit/scene/options.rs b/src/uikit/scene/options.rs index 38192896..a254a7f0 100644 --- a/src/uikit/scene/options.rs +++ b/src/uikit/scene/options.rs @@ -1,6 +1,6 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString}; diff --git a/src/uikit/scene/session.rs b/src/uikit/scene/session.rs index 69d6d208..01842dae 100644 --- a/src/uikit/scene/session.rs +++ b/src/uikit/scene/session.rs @@ -1,6 +1,6 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, NSString}; use crate::uikit::scene::enums::SessionRole; diff --git a/src/uikit/window/mod.rs b/src/uikit/window/mod.rs index 4d1d08fe..6ba1f48a 100644 --- a/src/uikit/window/mod.rs +++ b/src/uikit/window/mod.rs @@ -2,7 +2,7 @@ use core_graphics::geometry::CGRect; use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::id; use crate::geometry::Rect; diff --git a/src/user_notifications/mod.rs b/src/user_notifications/mod.rs index e98241f2..4b7c0adf 100644 --- a/src/user_notifications/mod.rs +++ b/src/user_notifications/mod.rs @@ -6,7 +6,7 @@ use block::ConcreteBlock; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use uuid::Uuid; use crate::foundation::{id, nil, NSString, NSUInteger}; diff --git a/src/user_notifications/notifications.rs b/src/user_notifications/notifications.rs index 26cdd5bd..2c0cbb24 100644 --- a/src/user_notifications/notifications.rs +++ b/src/user_notifications/notifications.rs @@ -3,7 +3,7 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSString}; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 11050e56..9a931c11 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -4,7 +4,7 @@ use core_graphics::base::CGFloat; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::id_shim::ShareId; use objc::runtime::Object; diff --git a/src/view/animator.rs b/src/view/animator.rs index 415f0e5e..0f7357e0 100644 --- a/src/view/animator.rs +++ b/src/view/animator.rs @@ -2,7 +2,7 @@ use core_graphics::base::CGFloat; use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; diff --git a/src/view/appkit.rs b/src/view/appkit.rs index dfb93846..de7058a6 100644 --- a/src/view/appkit.rs +++ b/src/view/appkit.rs @@ -10,7 +10,7 @@ use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::dragdrop::DragInfo; use crate::foundation::{id, load_or_register_class, nil, NSUInteger, NO, YES}; diff --git a/src/view/controller/appkit.rs b/src/view/controller/appkit.rs index 67eb1f16..2bfe7ec9 100644 --- a/src/view/controller/appkit.rs +++ b/src/view/controller/appkit.rs @@ -4,7 +4,7 @@ use std::sync::Once; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::load_or_register_class; use crate::utils::load; diff --git a/src/view/controller/mod.rs b/src/view/controller/mod.rs index aea1cfc7..bd449cd8 100644 --- a/src/view/controller/mod.rs +++ b/src/view/controller/mod.rs @@ -1,6 +1,6 @@ use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::id; use crate::layout::Layout; diff --git a/src/view/controller/uikit.rs b/src/view/controller/uikit.rs index 273a257f..4c59a86c 100644 --- a/src/view/controller/uikit.rs +++ b/src/view/controller/uikit.rs @@ -3,7 +3,7 @@ use std::unreachable; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::load_or_register_class; use crate::foundation::{to_bool, BOOL}; diff --git a/src/view/mod.rs b/src/view/mod.rs index b8ed7797..c7824eb2 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -43,7 +43,7 @@ //! For more information on Autolayout, view the module or check out the examples folder. use objc::runtime::{Class, Object}; -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::color::Color; use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NO, YES}; diff --git a/src/view/popover/mod.rs b/src/view/popover/mod.rs index deb6a641..d88995bf 100644 --- a/src/view/popover/mod.rs +++ b/src/view/popover/mod.rs @@ -1,7 +1,7 @@ use crate::id_shim::ShareId; use core_graphics::geometry::CGRect; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; #[cfg(feature = "appkit")] use crate::appkit::toolbar::ToolbarItem; diff --git a/src/view/splitviewcontroller/ios.rs b/src/view/splitviewcontroller/ios.rs index 8c45d439..77c4b8a4 100644 --- a/src/view/splitviewcontroller/ios.rs +++ b/src/view/splitviewcontroller/ios.rs @@ -1,6 +1,6 @@ use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::BOOL; use crate::utils::{as_bool, load}; diff --git a/src/view/splitviewcontroller/macos.rs b/src/view/splitviewcontroller/macos.rs index d175abfd..7e55421a 100644 --- a/src/view/splitviewcontroller/macos.rs +++ b/src/view/splitviewcontroller/macos.rs @@ -4,7 +4,7 @@ use std::sync::Once; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::load_or_register_class; use crate::view::{VIEW_DELEGATE_PTR, ViewDelegate}; diff --git a/src/view/splitviewcontroller/mod.rs b/src/view/splitviewcontroller/mod.rs index e6e20c64..1dd2be29 100644 --- a/src/view/splitviewcontroller/mod.rs +++ b/src/view/splitviewcontroller/mod.rs @@ -1,6 +1,6 @@ use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::appkit::toolbar::ToolbarItem; use crate::foundation::{id, nil, NSString}; diff --git a/src/view/uikit.rs b/src/view/uikit.rs index de3e8878..bbc62a83 100644 --- a/src/view/uikit.rs +++ b/src/view/uikit.rs @@ -1,7 +1,7 @@ use crate::id_shim::Id; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, sel, sel_impl}; +use objc::{class, sel}; use crate::foundation::load_or_register_class; use crate::foundation::{id, NSUInteger, NO, YES}; diff --git a/src/webview/actions.rs b/src/webview/actions.rs index 0b05cc57..d6e1f27b 100644 --- a/src/webview/actions.rs +++ b/src/webview/actions.rs @@ -1,6 +1,6 @@ //! Implements wrappers around `WKNavigationAction` and `WKNavigationActionPolicy`. -use objc::{msg_send, sel, sel_impl}; +use objc::{msg_send, sel}; use crate::foundation::{id, NSInteger, BOOL, NO, YES}; use crate::networking::URLRequest; diff --git a/src/webview/class.rs b/src/webview/class.rs index af1ef6a5..d35dfd7f 100644 --- a/src/webview/class.rs +++ b/src/webview/class.rs @@ -10,7 +10,7 @@ use block::Block; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, load_or_register_class, nil, NSArray, NSInteger, NSString, NO, YES}; use crate::webview::actions::{NavigationAction, NavigationResponse}; diff --git a/src/webview/config.rs b/src/webview/config.rs index df8005d0..e40e909c 100644 --- a/src/webview/config.rs +++ b/src/webview/config.rs @@ -3,7 +3,7 @@ use crate::id_shim::Id; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, NSInteger, NSString, NO, YES}; use crate::webview::enums::InjectAt; diff --git a/src/webview/mod.rs b/src/webview/mod.rs index dec54869..1b0b2042 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -17,7 +17,7 @@ use core_graphics::geometry::CGRect; use crate::id_shim::ShareId; use objc::runtime::Object; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NSString, NO, YES}; use crate::geometry::Rect; diff --git a/src/webview/process_pool.rs b/src/webview/process_pool.rs index 62f5c7d6..726c67e5 100644 --- a/src/webview/process_pool.rs +++ b/src/webview/process_pool.rs @@ -8,7 +8,7 @@ use block::Block; use cocoa::foundation::{NSArray, NSInteger, NSPoint, NSRect, NSSize, NSString}; use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel, BOOL}; -use objc::{class, msg_send, sel, sel_impl}; +use objc::{class, msg_send, sel}; use crate::foundation::{id, nil, NO, YES}; use crate::webview::traits::WebViewController; From 86d3eeb8e328616c087d65a8196eea4a0e0d5d3a Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Aug 2023 01:56:53 +0200 Subject: [PATCH 04/19] Fix `add_method` calls --- ARCHITECTURE.md | 6 +- src/appkit/app/delegate.rs | 81 +++++++++++------------- src/appkit/menu/item.rs | 4 +- src/appkit/toolbar/class.rs | 8 +-- src/appkit/window/class.rs | 78 +++++++++-------------- src/color/appkit_dynamic_color.rs | 89 ++++++++++----------------- src/image/appkit.rs | 2 +- src/input/appkit.rs | 13 ++-- src/input/uikit.rs | 10 +-- src/invoker.rs | 2 +- src/listview/appkit.rs | 33 ++++------ src/listview/row/appkit.rs | 24 +++----- src/scrollview/appkit.rs | 17 ++--- src/scrollview/uikit.rs | 12 ++-- src/uikit/app/delegate.rs | 6 +- src/uikit/scene/delegate.rs | 4 +- src/view/appkit.rs | 28 ++++----- src/view/controller/appkit.rs | 8 +-- src/view/controller/uikit.rs | 14 ++--- src/view/splitviewcontroller/ios.rs | 8 +-- src/view/splitviewcontroller/macos.rs | 8 +-- src/webview/class.rs | 21 +++---- src/webview/process_pool.rs | 2 +- 23 files changed, 192 insertions(+), 286 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index ee3b68af..522399f6 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -360,7 +360,7 @@ pub(crate) fn register_view_class() -> *const Class { let superclass = class!(NSView); let mut decl = ClassDecl::new("RSTView", superclass).unwrap(); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); decl.add_ivar::(BACKGROUND_COLOR); @@ -384,12 +384,12 @@ pub(crate) fn register_view_class_with_delegate(instance: &T) - decl.add_method( sel!(isFlipped), - enforce_normalcy as extern "C" fn(&Object, _) -> BOOL + enforce_normalcy as extern "C" fn(_, _) -> _, ); decl.add_method( sel!(draggingEntered:), - dragging_entered:: as extern "C" fn (&mut Object, _, _) -> NSUInteger + dragging_entered:: as extern "C" fn (_, _, _) -> _, ); }) } diff --git a/src/appkit/app/delegate.rs b/src/appkit/app/delegate.rs index 4296fbdd..f34c32b2 100644 --- a/src/appkit/app/delegate.rs +++ b/src/appkit/app/delegate.rs @@ -298,150 +298,141 @@ pub(crate) fn register_app_delegate_class() -> *co // Launching Applications decl.add_method( sel!(applicationWillFinishLaunching:), - will_finish_launching:: as extern "C" fn(&Object, _, _) + will_finish_launching:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(applicationDidFinishLaunching:), - did_finish_launching:: as extern "C" fn(&Object, _, _) + did_finish_launching:: as extern "C" fn(_, _, _) ); // Managing Active Status decl.add_method( sel!(applicationWillBecomeActive:), - will_become_active:: as extern "C" fn(&Object, _, _) + will_become_active:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(applicationDidBecomeActive:), - did_become_active:: as extern "C" fn(&Object, _, _) + did_become_active:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(applicationWillResignActive:), - will_resign_active:: as extern "C" fn(&Object, _, _) + will_resign_active:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(applicationDidResignActive:), - did_resign_active:: as extern "C" fn(&Object, _, _) + did_resign_active:: as extern "C" fn(_, _, _) ); // Terminating Applications decl.add_method( sel!(applicationShouldTerminate:), - should_terminate:: as extern "C" fn(&Object, _, _) -> NSUInteger - ); - decl.add_method( - sel!(applicationWillTerminate:), - will_terminate:: as extern "C" fn(&Object, _, _) + should_terminate:: as extern "C" fn(_, _, _) -> _ ); + decl.add_method(sel!(applicationWillTerminate:), will_terminate:: as extern "C" fn(_, _, _)); decl.add_method( sel!(applicationShouldTerminateAfterLastWindowClosed:), - should_terminate_after_last_window_closed:: as extern "C" fn(&Object, _, _) -> BOOL + should_terminate_after_last_window_closed:: as extern "C" fn(_, _, _) -> _ ); // Hiding Applications - decl.add_method(sel!(applicationWillHide:), will_hide:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(applicationDidHide:), did_hide:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(applicationWillUnhide:), will_unhide:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(applicationDidUnhide:), did_unhide:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(applicationWillHide:), will_hide:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(applicationDidHide:), did_hide:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(applicationWillUnhide:), will_unhide:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(applicationDidUnhide:), did_unhide:: as extern "C" fn(_, _, _)); // Managing Windows - decl.add_method(sel!(applicationWillUpdate:), will_update:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(applicationDidUpdate:), did_update:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(applicationWillUpdate:), will_update:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(applicationDidUpdate:), did_update:: as extern "C" fn(_, _, _)); decl.add_method( sel!(applicationShouldHandleReopen:hasVisibleWindows:), - should_handle_reopen:: as extern "C" fn(&Object, _, _, BOOL) -> BOOL + should_handle_reopen:: as extern "C" fn(_, _, _, _) -> _ ); // Dock Menu - decl.add_method( - sel!(applicationDockMenu:), - dock_menu:: as extern "C" fn(&Object, _, _) -> id - ); + decl.add_method(sel!(applicationDockMenu:), dock_menu:: as extern "C" fn(_, _, _) -> _); // Displaying Errors decl.add_method( sel!(application:willPresentError:), - will_present_error:: as extern "C" fn(&Object, _, _, id) -> id + will_present_error:: as extern "C" fn(_, _, _, _) -> _ ); // Managing the Screen decl.add_method( sel!(applicationDidChangeScreenParameters:), - did_change_screen_parameters:: as extern "C" fn(&Object, _, _) + did_change_screen_parameters:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(applicationDidChangeOcclusionState:), - did_change_occlusion_state:: as extern "C" fn(&Object, _, _) + did_change_occlusion_state:: as extern "C" fn(_, _, _) ); // User Activities decl.add_method( sel!(application:willContinueUserActivityWithType:), - will_continue_user_activity_with_type:: as extern "C" fn(&Object, _, _, id) -> BOOL + will_continue_user_activity_with_type:: as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(application:continueUserActivity:restorationHandler:), - continue_user_activity:: as extern "C" fn(&Object, _, _, id, id) -> BOOL + continue_user_activity:: as extern "C" fn(_, _, _, _, _) -> _ ); decl.add_method( sel!(application:didFailToContinueUserActivityWithType:error:), - failed_to_continue_user_activity:: as extern "C" fn(&Object, _, _, id, id) + failed_to_continue_user_activity:: as extern "C" fn(_, _, _, _, _) ); decl.add_method( sel!(application:didUpdateUserActivity:), - did_update_user_activity:: as extern "C" fn(&Object, _, _, id) + did_update_user_activity:: as extern "C" fn(_, _, _, _) ); // Handling push notifications decl.add_method( sel!(application:didRegisterForRemoteNotificationsWithDeviceToken:), - registered_for_remote_notifications:: as extern "C" fn(&Object, _, _, id) + registered_for_remote_notifications:: as extern "C" fn(_, _, _, _) ); decl.add_method( sel!(application:didFailToRegisterForRemoteNotificationsWithError:), - failed_to_register_for_remote_notifications:: as extern "C" fn(&Object, _, _, id) + failed_to_register_for_remote_notifications:: as extern "C" fn(_, _, _, _) ); decl.add_method( sel!(application:didReceiveRemoteNotification:), - did_receive_remote_notification:: as extern "C" fn(&Object, _, _, id) + did_receive_remote_notification:: as extern "C" fn(_, _, _, _) ); // CloudKit #[cfg(feature = "cloudkit")] decl.add_method( sel!(application:userDidAcceptCloudKitShareWithMetadata:), - accepted_cloudkit_share:: as extern "C" fn(&Object, _, _, id) + accepted_cloudkit_share:: as extern "C" fn(_, _, _, _) ); // Opening Files - decl.add_method( - sel!(application:openURLs:), - open_urls:: as extern "C" fn(&Object, _, _, id) - ); + decl.add_method(sel!(application:openURLs:), open_urls:: as extern "C" fn(_, _, _, _)); decl.add_method( sel!(application:openFileWithoutUI:), - open_file_without_ui:: as extern "C" fn(&Object, _, _, id) -> BOOL + open_file_without_ui:: as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(applicationShouldOpenUntitledFile:), - should_open_untitled_file:: as extern "C" fn(&Object, _, _) -> BOOL + should_open_untitled_file:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(applicationOpenUntitledFile:), - open_untitled_file:: as extern "C" fn(&Object, _, _) -> BOOL + open_untitled_file:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(application:openTempFile:), - open_temp_file:: as extern "C" fn(&Object, _, _, id) -> BOOL + open_temp_file:: as extern "C" fn(_, _, _, _) -> _ ); // Printing decl.add_method( sel!(application:printFile:), - print_file:: as extern "C" fn(&Object, _, _, id) -> BOOL + print_file:: as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(application:printFiles:withSettings:showPrintPanels:), - print_files:: as extern "C" fn(&Object, _, id, id, id, BOOL) -> NSUInteger + print_files:: as extern "C" fn(_, _, _, _, _, _) -> _ ); // @TODO: Restoring Application State @@ -450,7 +441,7 @@ pub(crate) fn register_app_delegate_class() -> *co // Scripting decl.add_method( sel!(application:delegateHandlesKey:), - delegate_handles_key:: as extern "C" fn(&Object, _, _, id) -> BOOL + delegate_handles_key:: as extern "C" fn(_, _, _, _) -> _ ); }) } diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index 69c0b91b..57f21f3a 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -318,7 +318,7 @@ pub(crate) fn register_menu_item_class() -> *const Class { load_or_register_class("NSMenuItem", "CacaoMenuItem", |decl| unsafe { decl.add_ivar::(BLOCK_PTR); - decl.add_method(sel!(dealloc), dealloc_cacao_menuitem as extern "C" fn(&Object, _)); - decl.add_method(sel!(fireBlockAction:), fire_block_action as extern "C" fn(&Object, _, id)); + decl.add_method(sel!(dealloc), dealloc_cacao_menuitem as extern "C" fn(_, _)); + decl.add_method(sel!(fireBlockAction:), fire_block_action as extern "C" fn(_, _, _)); }) } diff --git a/src/appkit/toolbar/class.rs b/src/appkit/toolbar/class.rs index 8e190972..29139fcb 100644 --- a/src/appkit/toolbar/class.rs +++ b/src/appkit/toolbar/class.rs @@ -73,19 +73,19 @@ pub(crate) fn register_toolbar_class(instance: &T) -> *const // Add callback methods decl.add_method( sel!(toolbarAllowedItemIdentifiers:), - allowed_item_identifiers:: as extern "C" fn(&Object, _, _) -> id + allowed_item_identifiers:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(toolbarDefaultItemIdentifiers:), - default_item_identifiers:: as extern "C" fn(&Object, _, _) -> id + default_item_identifiers:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(toolbarSelectableItemIdentifiers:), - selectable_item_identifiers:: as extern "C" fn(&Object, _, _) -> id + selectable_item_identifiers:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:), - item_for_identifier:: as extern "C" fn(&Object, _, _, _, _) -> id + item_for_identifier:: as extern "C" fn(_, _, _, _, _) -> _ ); }) } diff --git a/src/appkit/window/class.rs b/src/appkit/window/class.rs index 9cf662b8..19dca2a6 100644 --- a/src/appkit/window/class.rs +++ b/src/appkit/window/class.rs @@ -232,112 +232,94 @@ pub(crate) fn register_window_class_with_delegate(instance: & decl.add_ivar::(WINDOW_DELEGATE_PTR); // NSWindowDelegate methods - decl.add_method( - sel!(windowShouldClose:), - should_close:: as extern "C" fn(&Object, _, _) -> BOOL - ); - decl.add_method(sel!(windowWillClose:), will_close:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(windowShouldClose:), should_close:: as extern "C" fn(_, _, _) -> _); + decl.add_method(sel!(windowWillClose:), will_close:: as extern "C" fn(_, _, _)); // Sizing decl.add_method( sel!(windowWillResize:toSize:), - will_resize:: as extern "C" fn(&Object, _, _, CGSize) -> CGSize + will_resize:: as extern "C" fn(_, _, _, _) -> _ ); - decl.add_method(sel!(windowDidResize:), did_resize:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(windowDidResize:), did_resize:: as extern "C" fn(_, _, _)); decl.add_method( sel!(windowWillStartLiveResize:), - will_start_live_resize:: as extern "C" fn(&Object, _, _) + will_start_live_resize:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidEndLiveResize:), - did_end_live_resize:: as extern "C" fn(&Object, _, _) + did_end_live_resize:: as extern "C" fn(_, _, _) ); // Minimizing - decl.add_method( - sel!(windowWillMiniaturize:), - will_miniaturize:: as extern "C" fn(&Object, _, _) - ); - decl.add_method( - sel!(windowDidMiniaturize:), - did_miniaturize:: as extern "C" fn(&Object, _, _) - ); + decl.add_method(sel!(windowWillMiniaturize:), will_miniaturize:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidMiniaturize:), did_miniaturize:: as extern "C" fn(_, _, _)); decl.add_method( sel!(windowDidDeminiaturize:), - did_deminiaturize:: as extern "C" fn(&Object, _, _) + did_deminiaturize:: as extern "C" fn(_, _, _) ); // Full Screen decl.add_method( sel!(window:willUseFullScreenContentSize:), - content_size_for_full_screen:: as extern "C" fn(&Object, _, _, CGSize) -> CGSize + content_size_for_full_screen:: as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(window:willUseFullScreenPresentationOptions:), - options_for_full_screen:: as extern "C" fn(&Object, _, _, NSUInteger) -> NSUInteger + options_for_full_screen:: as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(windowWillEnterFullScreen:), - will_enter_full_screen:: as extern "C" fn(&Object, _, _) + will_enter_full_screen:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidEnterFullScreen:), - did_enter_full_screen:: as extern "C" fn(&Object, _, _) + did_enter_full_screen:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowWillExitFullScreen:), - will_exit_full_screen:: as extern "C" fn(&Object, _, _) + will_exit_full_screen:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidExitFullScreen:), - did_exit_full_screen:: as extern "C" fn(&Object, _, _) + did_exit_full_screen:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidFailToEnterFullScreen:), - did_fail_to_enter_full_screen:: as extern "C" fn(&Object, _, _) + did_fail_to_enter_full_screen:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidFailToExitFullScreen:), - did_fail_to_exit_full_screen:: as extern "C" fn(&Object, _, _) + did_fail_to_exit_full_screen:: as extern "C" fn(_, _, _) ); // Key status - decl.add_method(sel!(windowDidBecomeKey:), did_become_key:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(windowDidResignKey:), did_resign_key:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(windowDidBecomeKey:), did_become_key:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidResignKey:), did_resign_key:: as extern "C" fn(_, _, _)); // Main status - decl.add_method( - sel!(windowDidBecomeMain:), - did_become_main:: as extern "C" fn(&Object, _, _) - ); - decl.add_method( - sel!(windowDidResignMain:), - did_resign_main:: as extern "C" fn(&Object, _, _) - ); + decl.add_method(sel!(windowDidBecomeMain:), did_become_main:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidResignMain:), did_resign_main:: as extern "C" fn(_, _, _)); // Moving Windows - decl.add_method(sel!(windowWillMove:), will_move:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(windowDidMove:), did_move:: as extern "C" fn(&Object, _, _)); - decl.add_method( - sel!(windowDidChangeScreen:), - did_change_screen:: as extern "C" fn(&Object, _, _) - ); + decl.add_method(sel!(windowWillMove:), will_move:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidMove:), did_move:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidChangeScreen:), did_change_screen:: as extern "C" fn(_, _, _)); decl.add_method( sel!(windowDidChangeScreenProfile:), - did_change_screen_profile:: as extern "C" fn(&Object, _, _) + did_change_screen_profile:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(windowDidChangeBackingProperties:), - did_change_backing_properties:: as extern "C" fn(&Object, _, _) + did_change_backing_properties:: as extern "C" fn(_, _, _) ); // Random decl.add_method( sel!(windowDidChangeOcclusionState:), - did_change_occlusion_state:: as extern "C" fn(&Object, _, _) + did_change_occlusion_state:: as extern "C" fn(_, _, _) ); - decl.add_method(sel!(windowDidExpose:), did_expose:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(windowDidUpdate:), did_update:: as extern "C" fn(&Object, _, _)); - decl.add_method(sel!(cancelOperation:), cancel:: as extern "C" fn(&Object, _, _)); + decl.add_method(sel!(windowDidExpose:), did_expose:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(windowDidUpdate:), did_update:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(cancelOperation:), cancel:: as extern "C" fn(_, _, _)); }) } diff --git a/src/color/appkit_dynamic_color.rs b/src/color/appkit_dynamic_color.rs index 3f4664be..d0cd0946 100644 --- a/src/color/appkit_dynamic_color.rs +++ b/src/color/appkit_dynamic_color.rs @@ -256,92 +256,65 @@ extern "C" fn color_with_system_effect(this: &Object, _: Sel, effect: NSInteger) pub(crate) fn register_class() -> *const Class { load_or_register_class("NSColor", "CacaoDynamicColor", |decl| unsafe { // These methods all need to be forwarded, so let's hook them up. - decl.add_method(sel!(colorSpace), color_space as extern "C" fn(&Object, _) -> id); + decl.add_method(sel!(colorSpace), color_space as extern "C" fn(_, _) -> _); decl.add_method( sel!(colorUsingColorSpace:), - color_using_color_space as extern "C" fn(&Object, _, id) -> id + color_using_color_space as extern "C" fn(_, _, _) -> _ ); - decl.add_method(sel!(colorSpaceName), color_space_name as extern "C" fn(&Object, _) -> id); + decl.add_method(sel!(colorSpaceName), color_space_name as extern "C" fn(_, _) -> _); decl.add_method( sel!(colorUsingColorSpaceName:), - color_using_color_space_name as extern "C" fn(&Object, _, id) -> id - ); - decl.add_method( - sel!(numberOfComponents), - number_of_components as extern "C" fn(&Object, _) -> NSInteger + color_using_color_space_name as extern "C" fn(_, _, _) -> _ ); + decl.add_method(sel!(numberOfComponents), number_of_components as extern "C" fn(_, _) -> _); - decl.add_method(sel!(getComponents:), get_components as extern "C" fn(&Object, _, CGFloat)); - decl.add_method( - sel!(getRed:green:blue:alpha:), - get_rgba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat) - ); - decl.add_method(sel!(redComponent), red_component as extern "C" fn(&Object, _) -> CGFloat); - decl.add_method(sel!(greenComponent), green_component as extern "C" fn(&Object, _) -> CGFloat); - decl.add_method(sel!(blueComponent), blue_component as extern "C" fn(&Object, _) -> CGFloat); + decl.add_method(sel!(getComponents:), get_components as extern "C" fn(_, _, _)); + decl.add_method(sel!(getRed:green:blue:alpha:), get_rgba as extern "C" fn(_, _, _, _, _, _)); + decl.add_method(sel!(redComponent), red_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(greenComponent), green_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(blueComponent), blue_component as extern "C" fn(_, _) -> _); - decl.add_method(sel!(hueComponent), hue_component as extern "C" fn(&Object, _) -> CGFloat); - decl.add_method( - sel!(saturationComponent), - saturation_component as extern "C" fn(&Object, _) -> CGFloat - ); - decl.add_method( - sel!(brightnessComponent), - brightness_component as extern "C" fn(&Object, _) -> CGFloat - ); + decl.add_method(sel!(hueComponent), hue_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(saturationComponent), saturation_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(brightnessComponent), brightness_component as extern "C" fn(_, _) -> _); decl.add_method( sel!(getHue:saturation:brightness:alpha:), - get_hsba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat) + get_hsba as extern "C" fn(_, _, _, _, _, _) ); - decl.add_method(sel!(whiteComponent), white_component as extern "C" fn(&Object, _) -> CGFloat); - decl.add_method( - sel!(getWhite:alpha:), - get_white as extern "C" fn(&Object, _, CGFloat, CGFloat) - ); + decl.add_method(sel!(whiteComponent), white_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(getWhite:alpha:), get_white as extern "C" fn(_, _, _, _)); - decl.add_method(sel!(cyanComponent), cyan_component as extern "C" fn(&Object, _) -> CGFloat); - decl.add_method( - sel!(magentaComponent), - magenta_component as extern "C" fn(&Object, _) -> CGFloat - ); - decl.add_method( - sel!(yellowComponent), - yellow_component as extern "C" fn(&Object, _) -> CGFloat - ); - decl.add_method(sel!(blackComponent), black_component as extern "C" fn(&Object, _) -> CGFloat); + decl.add_method(sel!(cyanComponent), cyan_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(magentaComponent), magenta_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(yellowComponent), yellow_component as extern "C" fn(_, _) -> _); + decl.add_method(sel!(blackComponent), black_component as extern "C" fn(_, _) -> _); decl.add_method( sel!(getCyan:magenta:yellow:black:alpha:), - get_cmyk as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat, CGFloat) + get_cmyk as extern "C" fn(_, _, _, _, _, _, _) ); - decl.add_method(sel!(alphaComponent), alpha_component as extern "C" fn(&Object, _) -> CGFloat); + decl.add_method(sel!(alphaComponent), alpha_component as extern "C" fn(_, _) -> _); - decl.add_method(sel!(CGColor), cg_color as extern "C" fn(&Object, _) -> id); - decl.add_method(sel!(setStroke), set_stroke as extern "C" fn(&Object, _)); - decl.add_method(sel!(setFill), set_fill as extern "C" fn(&Object, _)); - decl.add_method(sel!(set), call_set as extern "C" fn(&Object, _)); + decl.add_method(sel!(CGColor), cg_color as extern "C" fn(_, _) -> _); + decl.add_method(sel!(setStroke), set_stroke as extern "C" fn(_, _)); + decl.add_method(sel!(setFill), set_fill as extern "C" fn(_, _)); + decl.add_method(sel!(set), call_set as extern "C" fn(_, _)); - decl.add_method( - sel!(highlightWithLevel:), - highlight_with_level as extern "C" fn(&Object, _, CGFloat) -> id - ); - decl.add_method( - sel!(shadowWithLevel:), - shadow_with_level as extern "C" fn(&Object, _, CGFloat) -> id - ); + decl.add_method(sel!(highlightWithLevel:), highlight_with_level as extern "C" fn(_, _, _) -> _); + decl.add_method(sel!(shadowWithLevel:), shadow_with_level as extern "C" fn(_, _, _) -> _); decl.add_method( sel!(colorWithAlphaComponent:), - color_with_alpha_component as extern "C" fn(&Object, _, CGFloat) -> id + color_with_alpha_component as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(blendedColorWithFraction:ofColor:), - blended_color as extern "C" fn(&Object, _, CGFloat, id) -> id + blended_color as extern "C" fn(_, _, _, _) -> _ ); decl.add_method( sel!(colorWithSystemEffect:), - color_with_system_effect as extern "C" fn(&Object, _, NSInteger) -> id + color_with_system_effect as extern "C" fn(_, _, _) -> _ ); decl.add_ivar::(AQUA_LIGHT_COLOR_NORMAL_CONTRAST); diff --git a/src/image/appkit.rs b/src/image/appkit.rs index 2af6d950..e558b0df 100644 --- a/src/image/appkit.rs +++ b/src/image/appkit.rs @@ -16,6 +16,6 @@ use crate::foundation::load_or_register_class; /// used if there's no delegates. pub(crate) fn register_image_view_class() -> *const Class { load_or_register_class("NSImageView", "RSTImageView", |decl| unsafe { - //decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + //decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); }) } diff --git a/src/input/appkit.rs b/src/input/appkit.rs index b6aa2107..4c8495c9 100644 --- a/src/input/appkit.rs +++ b/src/input/appkit.rs @@ -58,22 +58,19 @@ pub(crate) fn register_view_class_with_delegate(instance: // move. decl.add_ivar::(TEXTFIELD_DELEGATE_PTR); - decl.add_method( - sel!(textDidEndEditing:), - text_did_end_editing:: as extern "C" fn(&mut Object, _, _) - ); + decl.add_method(sel!(textDidEndEditing:), text_did_end_editing:: as extern "C" fn(_, _, _)); decl.add_method( sel!(textDidBeginEditing:), - text_did_begin_editing:: as extern "C" fn(&mut Object, _, _) + text_did_begin_editing:: as extern "C" fn(_, _, _) ); - decl.add_method(sel!(textDidChange:), text_did_change:: as extern "C" fn(&mut Object, _, _)); + decl.add_method(sel!(textDidChange:), text_did_change:: as extern "C" fn(_, _, _)); decl.add_method( sel!(textShouldBeginEditing:), - text_should_begin_editing:: as extern "C" fn(&mut Object, Sel, id) -> BOOL + text_should_begin_editing:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(textShouldEndEditing:), - text_should_end_editing:: as extern "C" fn(&mut Object, Sel, id) -> BOOL + text_should_end_editing:: as extern "C" fn(_, _, _) -> _ ); }) } diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 1c92f81c..66a9366f 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -73,23 +73,23 @@ pub(crate) fn register_view_class_with_delegate(instance: decl.add_method( sel!(textFieldDidEndEditing:), - text_did_end_editing:: as extern "C" fn(&mut Object, _, _) + text_did_end_editing:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(textFieldDidBeginEditing:), - text_did_begin_editing:: as extern "C" fn(&mut Object, _, _) + text_did_begin_editing:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(textFieldDidChangeSelection:), - text_did_change:: as extern "C" fn(&mut Object, _, _) + text_did_change:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(textFieldShouldBeginEditing:), - text_should_begin_editing:: as extern "C" fn(&mut Object, Sel, id) -> BOOL + text_should_begin_editing:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(textFieldShouldEndEditing:), - text_should_end_editing:: as extern "C" fn(&mut Object, Sel, id) -> BOOL + text_should_end_editing:: as extern "C" fn(_, _, _) -> _ ); }) } diff --git a/src/invoker.rs b/src/invoker.rs index 02133d29..03f199c1 100644 --- a/src/invoker.rs +++ b/src/invoker.rs @@ -94,6 +94,6 @@ extern "C" fn perform(this: &mut Object, _: Sel, pub(crate) fn register_invoker_class() -> *const Class { load_or_register_class("NSObject", "RSTTargetActionHandler", |decl| unsafe { decl.add_ivar::(ACTION_CALLBACK_PTR); - decl.add_method(sel!(perform:), perform:: as extern "C" fn(&mut Object, _, id)); + decl.add_method(sel!(perform:), perform:: as extern "C" fn(_, _, _)); }) } diff --git a/src/listview/appkit.rs b/src/listview/appkit.rs index 728bb57d..5a66f388 100644 --- a/src/listview/appkit.rs +++ b/src/listview/appkit.rs @@ -193,58 +193,49 @@ pub(crate) fn register_listview_class_with_delegate(instanc load_or_register_class("NSTableView", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(LISTVIEW_DELEGATE_PTR); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); // Tableview-specific decl.add_method( sel!(numberOfRowsInTableView:), - number_of_items:: as extern "C" fn(&Object, _, id) -> NSInteger + number_of_items:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(tableView:willDisplayCell:forTableColumn:row:), - will_display_cell:: as extern "C" fn(&Object, _, id, id, id, NSInteger) + will_display_cell:: as extern "C" fn(_, _, _, _, _, _) ); decl.add_method( sel!(tableView:viewForTableColumn:row:), - view_for_column:: as extern "C" fn(&Object, _, id, id, NSInteger) -> id + view_for_column:: as extern "C" fn(_, _, _, _, _) -> _ ); decl.add_method( sel!(tableViewSelectionDidChange:), - selection_did_change:: as extern "C" fn(&Object, _, id) + selection_did_change:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(tableView:rowActionsForRow:edge:), - row_actions_for_row:: as extern "C" fn(&Object, _, id, NSInteger, NSInteger) -> id + row_actions_for_row:: as extern "C" fn(_, _, _, _, _) -> _ ); // A slot for some menu handling; we just let it be done here for now rather than do the // whole delegate run, since things are fast enough nowadays to just replace the entire // menu. - decl.add_method( - sel!(menuNeedsUpdate:), - menu_needs_update:: as extern "C" fn(&Object, _, id) - ); + decl.add_method(sel!(menuNeedsUpdate:), menu_needs_update:: as extern "C" fn(_, _, _)); // Drag and drop operations (e.g, accepting files) - decl.add_method( - sel!(draggingEntered:), - dragging_entered:: as extern "C" fn(&mut Object, _, _) -> NSUInteger - ); + decl.add_method(sel!(draggingEntered:), dragging_entered:: as extern "C" fn(_, _, _) -> _); decl.add_method( sel!(prepareForDragOperation:), - prepare_for_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + prepare_for_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(performDragOperation:), - perform_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + perform_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(concludeDragOperation:), - conclude_drag_operation:: as extern "C" fn(&mut Object, _, _) - ); - decl.add_method( - sel!(draggingExited:), - dragging_exited:: as extern "C" fn(&mut Object, _, _) + conclude_drag_operation:: as extern "C" fn(_, _, _) ); + decl.add_method(sel!(draggingExited:), dragging_exited:: as extern "C" fn(_, _, _)); }) } diff --git a/src/listview/row/appkit.rs b/src/listview/row/appkit.rs index fd2131f9..253cc899 100644 --- a/src/listview/row/appkit.rs +++ b/src/listview/row/appkit.rs @@ -105,7 +105,7 @@ extern "C" fn dealloc(this: &Object, _: Sel) { /// used if there's no delegates. pub(crate) fn register_listview_row_class() -> *const Class { load_or_register_class("NSView", "RSTTableViewRow", |decl| unsafe { - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); }) } @@ -118,32 +118,26 @@ pub(crate) fn register_listview_row_class_with_delegate() -> *c decl.add_ivar::(LISTVIEW_ROW_DELEGATE_PTR); decl.add_ivar::(BACKGROUND_COLOR); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); - decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(&Object, _)); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); + decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(_, _)); // Drag and drop operations (e.g, accepting files) - decl.add_method( - sel!(draggingEntered:), - dragging_entered:: as extern "C" fn(&mut Object, _, _) -> NSUInteger - ); + decl.add_method(sel!(draggingEntered:), dragging_entered:: as extern "C" fn(_, _, _) -> _); decl.add_method( sel!(prepareForDragOperation:), - prepare_for_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + prepare_for_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(performDragOperation:), - perform_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + perform_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(concludeDragOperation:), - conclude_drag_operation:: as extern "C" fn(&mut Object, _, _) - ); - decl.add_method( - sel!(draggingExited:), - dragging_exited:: as extern "C" fn(&mut Object, _, _) + conclude_drag_operation:: as extern "C" fn(_, _, _) ); + decl.add_method(sel!(draggingExited:), dragging_exited:: as extern "C" fn(_, _, _)); // Cleanup - decl.add_method(sel!(dealloc), dealloc:: as extern "C" fn(&Object, _)); + decl.add_method(sel!(dealloc), dealloc:: as extern "C" fn(_, _)); }) } diff --git a/src/scrollview/appkit.rs b/src/scrollview/appkit.rs index 87acd178..fc1de0ff 100644 --- a/src/scrollview/appkit.rs +++ b/src/scrollview/appkit.rs @@ -85,28 +85,21 @@ pub(crate) fn register_scrollview_class_with_delegate() - // move. decl.add_ivar::(SCROLLVIEW_DELEGATE_PTR); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); // Drag and drop operations (e.g, accepting files) - decl.add_method( - sel!(draggingEntered:), - dragging_entered:: as extern "C" fn(&mut Object, _, _) -> NSUInteger - ); + decl.add_method(sel!(draggingEntered:), dragging_entered:: as extern "C" fn(_, _, _) -> _); decl.add_method( sel!(prepareForDragOperation:), - prepare_for_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + prepare_for_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(performDragOperation:), - perform_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + perform_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(concludeDragOperation:), - conclude_drag_operation:: as extern "C" fn(&mut Object, _, _) - ); - decl.add_method( - sel!(draggingExited:), - dragging_exited:: as extern "C" fn(&mut Object, _, _) + conclude_drag_operation:: as extern "C" fn(_, _, _) ); }) } diff --git a/src/scrollview/uikit.rs b/src/scrollview/uikit.rs index da42fdd1..c9ecbf9f 100644 --- a/src/scrollview/uikit.rs +++ b/src/scrollview/uikit.rs @@ -105,29 +105,29 @@ pub(crate) fn register_scrollview_class_with_delegate() - // move. decl.add_ivar::(SCROLLVIEW_DELEGATE_PTR); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); /* // Drag and drop operations (e.g, accepting files) decl.add_method( sel!(draggingEntered:), - dragging_entered:: as extern "C" fn(&mut Object, _, _) -> NSUInteger + dragging_entered:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(prepareForDragOperation:), - prepare_for_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + prepare_for_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(performDragOperation:), - perform_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + perform_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(concludeDragOperation:), - conclude_drag_operation:: as extern "C" fn(&mut Object, _, _) + conclude_drag_operation:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(draggingExited:), - dragging_exited:: as extern "C" fn(&mut Object, _, _) + dragging_exited:: as extern "C" fn(_, _, _) ); */ diff --git a/src/uikit/app/delegate.rs b/src/uikit/app/delegate.rs index 2f8c4fbb..b9ed6a8a 100644 --- a/src/uikit/app/delegate.rs +++ b/src/uikit/app/delegate.rs @@ -47,17 +47,17 @@ pub(crate) fn register_app_delegate_class() -> *const Class { // Launching Applications decl.add_method( sel!(application:didFinishLaunchingWithOptions:), - did_finish_launching:: as extern "C" fn(&Object, _, _, id) -> BOOL + did_finish_launching:: as extern "C" fn(_, _, _, _) -> _ ); // Scenes decl.add_method( sel!(application:configurationForConnectingSceneSession:options:), - configuration_for_scene_session:: as extern "C" fn(&Object, _, _, id, id) -> id + configuration_for_scene_session:: as extern "C" fn(_, _, _, _, _) -> _ ); /*decl.add_method( sel!(application:didDiscardSceneSessions:), - did_discard_scene_sessions:: as extern "C" fn(&Object, _, _, id) + did_discard_scene_sessions:: as extern "C" fn(_, _, _, _) );*/ }) } diff --git a/src/uikit/scene/delegate.rs b/src/uikit/scene/delegate.rs index ac11c3f9..1b80b409 100644 --- a/src/uikit/scene/delegate.rs +++ b/src/uikit/scene/delegate.rs @@ -55,12 +55,12 @@ pub(crate) fn register_window_scene_delegate_class as extern "C" fn(&mut Object, _) -> id); + decl.add_method(sel!(init), init:: as extern "C" fn(_, _) -> _); // UIWindowSceneDelegate API decl.add_method( sel!(scene:willConnectToSession:options:), - scene_will_connect_to_session_with_options:: as extern "C" fn(&Object, _, _, _, _) + scene_will_connect_to_session_with_options:: as extern "C" fn(_, _, _, _, _) ); }) } diff --git a/src/view/appkit.rs b/src/view/appkit.rs index de7058a6..0aa92eb5 100644 --- a/src/view/appkit.rs +++ b/src/view/appkit.rs @@ -91,9 +91,9 @@ extern "C" fn update_layer(this: &Object, _: Sel) { /// used if there's no delegates. pub(crate) fn register_view_class() -> *const Class { load_or_register_class("NSView", "RSTView", |decl| unsafe { - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); - decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(&Object, _)); - decl.add_method(sel!(wantsUpdateLayer), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); + decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(_, _)); + decl.add_method(sel!(wantsUpdateLayer), enforce_normalcy as extern "C" fn(_, _) -> _); decl.add_ivar::(BACKGROUND_COLOR); }) @@ -108,36 +108,30 @@ pub(crate) fn register_view_class_with_delegate(instance: &T) - decl.add_ivar::(VIEW_DELEGATE_PTR); decl.add_ivar::(BACKGROUND_COLOR); - decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(&Object, _)); + decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(_, _)); - decl.add_method(sel!(wantsUpdateLayer), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(wantsUpdateLayer), enforce_normalcy as extern "C" fn(_, _) -> _); - decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL); + decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); // Drag and drop operations (e.g, accepting files) - decl.add_method( - sel!(draggingEntered:), - dragging_entered:: as extern "C" fn(&mut Object, _, _) -> NSUInteger - ); + decl.add_method(sel!(draggingEntered:), dragging_entered:: as extern "C" fn(_, _, _) -> _); decl.add_method( sel!(prepareForDragOperation:), - prepare_for_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + prepare_for_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(performDragOperation:), - perform_drag_operation:: as extern "C" fn(&mut Object, _, _) -> BOOL + perform_drag_operation:: as extern "C" fn(_, _, _) -> _ ); decl.add_method( sel!(concludeDragOperation:), - conclude_drag_operation:: as extern "C" fn(&mut Object, _, _) + conclude_drag_operation:: as extern "C" fn(_, _, _) ); - decl.add_method( - sel!(draggingExited:), - dragging_exited:: as extern "C" fn(&mut Object, _, _) - ); + decl.add_method(sel!(draggingExited:), dragging_exited:: as extern "C" fn(_, _, _)); }) } diff --git a/src/view/controller/appkit.rs b/src/view/controller/appkit.rs index 2bfe7ec9..45fb03a4 100644 --- a/src/view/controller/appkit.rs +++ b/src/view/controller/appkit.rs @@ -55,9 +55,9 @@ pub(crate) fn register_view_controller_class(instance load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear), will_appear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewDidAppear), did_appear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern "C" fn(&mut Object, _)); + decl.add_method(sel!(viewWillAppear), will_appear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewDidAppear), did_appear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern "C" fn(_, _)); }) } diff --git a/src/view/controller/uikit.rs b/src/view/controller/uikit.rs index 4c59a86c..9598dd51 100644 --- a/src/view/controller/uikit.rs +++ b/src/view/controller/uikit.rs @@ -55,15 +55,9 @@ pub(crate) fn register_view_controller_class(instance load_or_register_class("UIViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear:), will_appear:: as extern "C" fn(&mut Object, _, BOOL)); - decl.add_method(sel!(viewDidAppear:), did_appear:: as extern "C" fn(&mut Object, _, BOOL)); - decl.add_method( - sel!(viewWillDisappear:), - will_disappear:: as extern "C" fn(&mut Object, _, BOOL) - ); - decl.add_method( - sel!(viewDidDisappear:), - did_disappear:: as extern "C" fn(&mut Object, _, BOOL) - ); + decl.add_method(sel!(viewWillAppear:), will_appear:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(viewDidAppear:), did_appear:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(viewWillDisappear:), will_disappear:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(viewDidDisappear:), did_disappear:: as extern "C" fn(_, _, _)); }) } diff --git a/src/view/splitviewcontroller/ios.rs b/src/view/splitviewcontroller/ios.rs index 77c4b8a4..5e25766e 100644 --- a/src/view/splitviewcontroller/ios.rs +++ b/src/view/splitviewcontroller/ios.rs @@ -51,15 +51,15 @@ pub(crate) fn register_view_controller_class() -> *co load_or_register_class("UIViewController", "RSTViewController", |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear:), will_appear:: as extern "C" fn(&mut Object, _, BOOL)); - decl.add_method(sel!(viewDidAppear:), did_appear:: as extern "C" fn(&mut Object, _, BOOL)); + decl.add_method(sel!(viewWillAppear:), will_appear:: as extern "C" fn(_, _, _)); + decl.add_method(sel!(viewDidAppear:), did_appear:: as extern "C" fn(_, _, _)); decl.add_method( sel!(viewWillDisappear:), - will_disappear:: as extern "C" fn(&mut Object, _, BOOL) + will_disappear:: as extern "C" fn(_, _, _) ); decl.add_method( sel!(viewDidDisappear:), - did_disappear:: as extern "C" fn(&mut Object, _, BOOL) + did_disappear:: as extern "C" fn(_, _, _) ); }) } diff --git a/src/view/splitviewcontroller/macos.rs b/src/view/splitviewcontroller/macos.rs index 7e55421a..a31d966b 100644 --- a/src/view/splitviewcontroller/macos.rs +++ b/src/view/splitviewcontroller/macos.rs @@ -55,9 +55,9 @@ pub(crate) fn register_view_controller_class(instance load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear), will_appear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewDidAppear), did_appear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern "C" fn(&mut Object, _)); - decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern "C" fn(&mut Object, _)); + decl.add_method(sel!(viewWillAppear), will_appear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewDidAppear), did_appear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern "C" fn(_, _)); + decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern "C" fn(_, _)); }) } diff --git a/src/webview/class.rs b/src/webview/class.rs index d35dfd7f..ee468ab5 100644 --- a/src/webview/class.rs +++ b/src/webview/class.rs @@ -176,10 +176,7 @@ extern "C" fn accepts_first_mouse(_: &mut Object, _: Sel, _: id) -> BOOL { /// varieties of delegates needed there). pub fn register_webview_class() -> *const Class { load_or_register_class("WKWebView", "CacaoWebView", |decl| unsafe { - decl.add_method( - sel!(acceptsFirstMouse:), - accepts_first_mouse as extern "C" fn(&mut Object, Sel, id) -> BOOL - ); + decl.add_method(sel!(acceptsFirstMouse:), accepts_first_mouse as extern "C" fn(_, _, _) -> _); }) } @@ -193,37 +190,37 @@ pub fn register_webview_delegate_class(instance: &T) -> *con // WKNavigationDelegate decl.add_method( sel!(webView:decidePolicyForNavigationAction:decisionHandler:), - decide_policy_for_action:: as extern "C" fn(&Object, _, _, id, usize) + decide_policy_for_action:: as extern "C" fn(_, _, _, _, _) ); decl.add_method( sel!(webView:decidePolicyForNavigationResponse:decisionHandler:), - decide_policy_for_response:: as extern "C" fn(&Object, _, _, id, usize) + decide_policy_for_response:: as extern "C" fn(_, _, _, _, _) ); // WKScriptMessageHandler decl.add_method( sel!(userContentController:didReceiveScriptMessage:), - on_message:: as extern "C" fn(&Object, _, _, id) + on_message:: as extern "C" fn(_, _, _, _) ); // Custom protocol handler decl.add_method( sel!(webView:startURLSchemeTask:), - start_url_scheme_task:: as extern "C" fn(&Object, Sel, id, id) + start_url_scheme_task:: as extern "C" fn(_, _, _, _) ); decl.add_method( sel!(webView:stopURLSchemeTask:), - stop_url_scheme_task:: as extern "C" fn(&Object, Sel, id, id) + stop_url_scheme_task:: as extern "C" fn(_, _, _, _) ); // WKUIDelegate decl.add_method( sel!(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:), - alert:: as extern "C" fn(&Object, _, _, id, _, _) + alert:: as extern "C" fn(_, _, _, _, _, _) ); decl.add_method( sel!(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:), - run_open_panel:: as extern "C" fn(&Object, _, _, id, _, usize) + run_open_panel:: as extern "C" fn(_, _, _, _, _, _) ); // WKDownloadDelegate is a private class on macOS that handles downloading (saving) files. @@ -232,7 +229,7 @@ pub fn register_webview_delegate_class(instance: &T) -> *con #[cfg(feature = "webview-downloading-macos")] decl.add_method( sel!(_download:decideDestinationWithSuggestedFilename:completionHandler:), - handle_download:: as extern "C" fn(&Object, _, id, id, usize) + handle_download:: as extern "C" fn(_, _, _, _, _) ); }) } diff --git a/src/webview/process_pool.rs b/src/webview/process_pool.rs index 726c67e5..84e5ac02 100644 --- a/src/webview/process_pool.rs +++ b/src/webview/process_pool.rs @@ -21,6 +21,6 @@ extern "C" fn download_delegate(this: &Object, _: Sel) -> id { pub fn register_process_pool() -> *const Object { load_or_register_class("WKProcessPool", "RSTWebViewProcessPool", |decl| unsafe { //decl.add_ivar::(DOWNLOAD_DELEGATE_PTR); - decl.add_method(sel!(_downloadDelegate), download_delegate as extern "C" fn(&Object, _) -> id); + decl.add_method(sel!(_downloadDelegate), download_delegate as extern "C" fn(_, _) -> _); }) } From 420b6bf550bedaeead014bfbe90345a1b09c65a2 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 10 Jul 2022 19:30:01 +0200 Subject: [PATCH 05/19] Fix accessing raw FFI functions --- src/bundle.rs | 32 +++++++++++++++----------------- src/foundation/class.rs | 7 ++++--- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/bundle.rs b/src/bundle.rs index a34b5821..78bac9e5 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -11,14 +11,9 @@ use std::ffi::CString; use std::mem; -use objc::{class, msg_send, sel, Encode, Encoding, EncodeArguments, Message}; -use objc::runtime::{Class, Sel, Method, Object, Imp}; -use objc::runtime::{ - objc_getClass, - class_addMethod, - class_getInstanceMethod, - method_exchangeImplementations -}; +use objc::ffi; +use objc::runtime::{Class, Imp, Object, Sel}; +use objc::{class, msg_send, sel, Encode, EncodeArguments, Encoding, Message}; use crate::foundation::{id, nil, BOOL, YES, NSString}; @@ -73,24 +68,27 @@ extern "C" fn get_bundle_id(this: &Object, s: Sel, v: id) -> id { } } -unsafe fn swizzle_bundle_id(bundle_id: &str, func: F) where F: MethodImplementation { +unsafe fn swizzle_bundle_id(bundle_id: &str, func: F) +where + F: MethodImplementation, +{ let name = CString::new("NSBundle").unwrap(); - let cls = objc_getClass(name.as_ptr()); + let cls = ffi::objc_getClass(name.as_ptr()); // let mut cls = class!(NSBundle) as *mut Class; // Class::get("NSBundle").unwrap(); // let types = format!("{}{}{}", Encoding::String, <*mut Object>::ENCODING, Sel::ENCODING); - let added = class_addMethod( - cls as *mut Class, - sel!(__bundleIdentifier), + let added = ffi::class_addMethod( + cls as *mut ffi::objc_class, + sel!(__bundleIdentifier).as_ptr(), func.imp(), - CString::new("*@:").unwrap().as_ptr() + CString::new("*@:").unwrap().as_ptr(), ); - let method1 = class_getInstanceMethod(cls, sel!(bundleIdentifier)) as *mut Method; - let method2 = class_getInstanceMethod(cls, sel!(__bundleIdentifier)) as *mut Method; - method_exchangeImplementations(method1, method2); + let method1 = ffi::class_getInstanceMethod(cls, sel!(bundleIdentifier).as_ptr()) as *mut ffi::objc_method; + let method2 = ffi::class_getInstanceMethod(cls, sel!(__bundleIdentifier).as_ptr()) as *mut ffi::objc_method; + ffi::method_exchangeImplementations(method1, method2); } pub fn set_bundle_id(bundle_id: &str) { diff --git a/src/foundation/class.rs b/src/foundation/class.rs index 9d2b334b..2398771c 100644 --- a/src/foundation/class.rs +++ b/src/foundation/class.rs @@ -9,7 +9,8 @@ use std::time::Instant; use lazy_static::lazy_static; use objc::declare::ClassDecl; -use objc::runtime::{objc_getClass, Class}; +use objc::ffi; +use objc::runtime::Class; lazy_static! { static ref CLASSES: ClassMap = ClassMap::new(); @@ -83,7 +84,7 @@ impl ClassMap { // runtime, and we can wind up in a situation where we're attempting to register a Class // that already exists but we can't see. let objc_class_name = CString::new(class_name).unwrap(); - let class = unsafe { objc_getClass(objc_class_name.as_ptr() as *const _) }; + let class = unsafe { ffi::objc_getClass(objc_class_name.as_ptr() as *const _) }; // This should not happen for our use-cases, but it's conceivable that this could actually // be expected, so just return None and let the caller panic if so desired. @@ -101,7 +102,7 @@ impl ClassMap { }); } - Some(class) + Some(class.cast()) } /// Store a newly created subclass type. From f765f3daf06c01f3f280aefcaf81a52e2d0c1617 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 10 Jul 2022 18:14:03 +0200 Subject: [PATCH 06/19] Fix Encode impl --- src/utils/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 9a931c11..9c65ef88 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -92,12 +92,7 @@ impl CGSize { } unsafe impl Encode for CGSize { - /// Adds support for CGSize Objective-C encoding. - fn encode() -> Encoding { - let encoding = format!("{{CGSize={}{}}}", CGFloat::encode().as_str(), CGFloat::encode().as_str()); - - unsafe { Encoding::from_str(&encoding) } - } + const ENCODING: Encoding<'static> = Encoding::Struct("CGSize", &[CGFloat::ENCODING, CGFloat::ENCODING]); } /// A helper method for ensuring that Cocoa is running in multi-threaded mode. From c94e4cc1a19915e1085088865daab01e9ca9142b Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 5 Sep 2023 12:43:10 +0200 Subject: [PATCH 07/19] Fix message sends arguments that do not implement `Encode` --- examples/browser/toolbar.rs | 4 ++-- src/appkit/alert.rs | 6 +++--- src/appkit/animation.rs | 9 ++++++--- src/appkit/app/delegate.rs | 2 +- src/appkit/event/mod.rs | 14 ++++++++++---- src/appkit/haptics.rs | 2 +- src/appkit/menu/item.rs | 2 +- src/appkit/segmentedcontrol.rs | 2 +- src/appkit/toolbar/item.rs | 4 ++-- src/appkit/toolbar/mod.rs | 2 +- src/appkit/window/mod.rs | 8 ++++---- src/color/mod.rs | 8 ++++---- src/defaults/mod.rs | 2 +- src/error.rs | 2 +- src/filesystem/save.rs | 2 +- src/filesystem/select.rs | 8 ++++++-- src/foundation/urls/mod.rs | 20 ++++++++++++-------- src/image/image.rs | 19 ++++++++++++------- src/image/mod.rs | 4 +++- src/input/mod.rs | 4 +++- src/layout/dimension.rs | 12 ++++++------ src/layout/horizontal.rs | 6 +++--- src/layout/vertical.rs | 6 +++--- src/listview/actions.rs | 8 +++++--- src/listview/mod.rs | 4 +++- src/pasteboard/mod.rs | 4 ++-- src/quicklook/mod.rs | 7 +++++-- src/scrollview/mod.rs | 4 +++- src/select/mod.rs | 2 +- src/switch.rs | 2 +- src/text/attributed_string.rs | 21 +++++++++++++-------- src/text/label/mod.rs | 4 +++- src/uikit/scene/config.rs | 2 +- src/uikit/scene/delegate.rs | 4 ++-- src/user_notifications/mod.rs | 16 ++++++++++++---- src/user_notifications/notifications.rs | 4 ++-- src/utils/mod.rs | 21 +++++++++++++++++++++ src/webview/class.rs | 17 +++++++++++------ src/webview/config.rs | 15 ++++++++++----- 39 files changed, 182 insertions(+), 101 deletions(-) diff --git a/examples/browser/toolbar.rs b/examples/browser/toolbar.rs index 91ac5546..ce49e3d9 100644 --- a/examples/browser/toolbar.rs +++ b/examples/browser/toolbar.rs @@ -35,12 +35,12 @@ impl BrowserToolbar { let back_button = Button::new("Back"); let mut back_item = ToolbarItem::new(BACK_BUTTON); back_item.set_button(back_button); - back_item.set_action(|| Action::Back.dispatch()); + back_item.set_action(|_| Action::Back.dispatch()); let forwards_button = Button::new("Forwards"); let mut forwards_item = ToolbarItem::new(FWDS_BUTTON); forwards_item.set_button(forwards_button); - forwards_item.set_action(|| Action::Forwards.dispatch()); + forwards_item.set_action(|_| Action::Forwards.dispatch()); let url_bar = TextField::with(URLBar); let url_bar_item = ToolbarItem::new(URL_BAR); diff --git a/src/appkit/alert.rs b/src/appkit/alert.rs index 62d6ddd5..25c48e8f 100644 --- a/src/appkit/alert.rs +++ b/src/appkit/alert.rs @@ -45,9 +45,9 @@ impl Alert { Alert(unsafe { let alert: id = msg_send![class!(NSAlert), new]; - let _: () = msg_send![alert, setMessageText: title]; - let _: () = msg_send![alert, setInformativeText: message]; - let _: () = msg_send![alert, addButtonWithTitle: ok]; + let _: () = msg_send![alert, setMessageText: &*title]; + let _: () = msg_send![alert, setInformativeText: &*message]; + let _: () = msg_send![alert, addButtonWithTitle: &*ok]; Id::from_ptr(alert) }) } diff --git a/src/appkit/animation.rs b/src/appkit/animation.rs index b7750d67..48deb215 100644 --- a/src/appkit/animation.rs +++ b/src/appkit/animation.rs @@ -39,7 +39,7 @@ impl AnimationContext { unsafe { //let context: id = msg_send![class!(NSAnimationContext), currentContext]; - let _: () = msg_send![class!(NSAnimationContext), runAnimationGroup: block]; + let _: () = msg_send![class!(NSAnimationContext), runAnimationGroup: &*block]; } } @@ -66,8 +66,11 @@ impl AnimationContext { unsafe { //let context: id = msg_send![class!(NSAnimationContext), currentContext]; - let _: () = msg_send![class!(NSAnimationContext), runAnimationGroup:block - completionHandler:completion_block]; + let _: () = msg_send![ + class!(NSAnimationContext), + runAnimationGroup: &*block, + completionHandler: &*completion_block, + ]; } } } diff --git a/src/appkit/app/delegate.rs b/src/appkit/app/delegate.rs index f34c32b2..3890291a 100644 --- a/src/appkit/app/delegate.rs +++ b/src/appkit/app/delegate.rs @@ -145,7 +145,7 @@ extern "C" fn continue_user_activity(this: &Object, _: Sel, _: i let activity = UserActivity::with_inner(activity); match app::(this).continue_user_activity(activity, || unsafe { - let handler = handler as *const Block<(id,), c_void>; + let handler = handler as *const Block<(id,), ()>; (*handler).call((nil,)); }) { true => YES, diff --git a/src/appkit/event/mod.rs b/src/appkit/event/mod.rs index 1e21a526..966785f2 100644 --- a/src/appkit/event/mod.rs +++ b/src/appkit/event/mod.rs @@ -137,8 +137,11 @@ impl Event { let block = block.copy(); EventMonitor(unsafe { - msg_send![class!(NSEvent), addLocalMonitorForEventsMatchingMask:mask.bits - handler:block] + Id::from_ptr(msg_send![ + class!(NSEvent), + addLocalMonitorForEventsMatchingMask: mask.bits, + handler: &*block, + ]) }) } @@ -163,8 +166,11 @@ impl Event { let block = block.copy(); EventMonitor(unsafe { - msg_send![class!(NSEvent), addGlobalMonitorForEventsMatchingMask:mask.bits - handler:block] + Id::from_ptr(msg_send![ + class!(NSEvent), + addGlobalMonitorForEventsMatchingMask: mask.bits, + handler: &*block, + ]) }) } } diff --git a/src/appkit/haptics.rs b/src/appkit/haptics.rs index c7772a44..a7185a9e 100644 --- a/src/appkit/haptics.rs +++ b/src/appkit/haptics.rs @@ -11,7 +11,7 @@ pub struct HapticFeedbackPerformer(pub ShareId); impl HapticFeedbackPerformer { pub fn perform(&self, pattern: FeedbackPattern, performance_time: PerformanceTime) { unsafe { - let _: () = msg_send![&*self.0, performFeedbackPattern: pattern performanceTime: performance_time]; + let _: () = msg_send![&*self.0, performFeedbackPattern: pattern as isize performanceTime: performance_time as usize]; } } } diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index 57f21f3a..ac75ccee 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -229,7 +229,7 @@ impl MenuItem { if let MenuItem::Custom(objc) = self { unsafe { let key = NSString::new(key); - let _: () = msg_send![&*objc, setKeyEquivalent: key]; + let _: () = msg_send![&*objc, setKeyEquivalent: &*key]; } return MenuItem::Custom(objc); diff --git a/src/appkit/segmentedcontrol.rs b/src/appkit/segmentedcontrol.rs index b9d753e6..dfd2e155 100644 --- a/src/appkit/segmentedcontrol.rs +++ b/src/appkit/segmentedcontrol.rs @@ -171,7 +171,7 @@ impl SegmentedControl { pub fn set_tooltip_segment(&mut self, index: NSUInteger, tooltip: &str) { self.objc.with_mut(|obj| unsafe { let converted = NSString::new(tooltip); - let _: () = msg_send![obj, setToolTip: converted forSegment: index]; + let _: () = msg_send![obj, setToolTip: &*converted.objc, forSegment: index]; }) } diff --git a/src/appkit/toolbar/item.rs b/src/appkit/toolbar/item.rs index e6af5a33..649b873c 100644 --- a/src/appkit/toolbar/item.rs +++ b/src/appkit/toolbar/item.rs @@ -34,9 +34,9 @@ impl ToolbarItem { let identifier = identifier.into(); let objc = unsafe { - let identifr = NSString::new(&identifier); + let identifer = NSString::new(&identifier); let alloc: id = msg_send![class!(NSToolbarItem), alloc]; - let item: id = msg_send![alloc, initWithItemIdentifier: identifr]; + let item: id = msg_send![alloc, initWithItemIdentifier: &*identifer]; Id::from_ptr(item) }; diff --git a/src/appkit/toolbar/mod.rs b/src/appkit/toolbar/mod.rs index dfcc287f..da0652c7 100644 --- a/src/appkit/toolbar/mod.rs +++ b/src/appkit/toolbar/mod.rs @@ -55,7 +55,7 @@ where let (objc, objc_delegate) = unsafe { let alloc: id = msg_send![class!(NSToolbar), alloc]; let identifier = NSString::new(&identifier); - let toolbar: id = msg_send![alloc, initWithIdentifier: identifier]; + let toolbar: id = msg_send![alloc, initWithIdentifier: &*identifier]; let objc_delegate: id = msg_send![cls, new]; //WithIdentifier:identifier]; let ptr: *const T = &*delegate; diff --git a/src/appkit/window/mod.rs b/src/appkit/window/mod.rs index 436b3bae..308127ed 100644 --- a/src/appkit/window/mod.rs +++ b/src/appkit/window/mod.rs @@ -201,7 +201,7 @@ impl Window { pub fn set_title(&self, title: &str) { unsafe { let title = NSString::new(title); - let _: () = msg_send![&*self.objc, setTitle: title]; + let _: () = msg_send![&*self.objc, setTitle: &*title]; } } @@ -216,7 +216,7 @@ impl Window { unsafe { let subtitle = NSString::new(subtitle); - let _: () = msg_send![&*self.objc, setSubtitle: subtitle]; + let _: () = msg_send![&*self.objc, setSubtitle: &*subtitle]; } } @@ -252,7 +252,7 @@ impl Window { pub fn set_autosave_name(&self, name: &str) { unsafe { let autosave = NSString::new(name); - let _: () = msg_send![&*self.objc, setFrameAutosaveName: autosave]; + let _: () = msg_send![&*self.objc, setFrameAutosaveName: &*autosave]; } } @@ -514,7 +514,7 @@ impl Window { let block = block.copy(); unsafe { - let _: () = msg_send![&*self.objc, beginSheet:&*window.objc completionHandler:block]; + let _: () = msg_send![&*self.objc, beginSheet: &*window.objc, completionHandler: &*block]; } } diff --git a/src/color/mod.rs b/src/color/mod.rs index d1c45d4c..992faf56 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -15,6 +15,7 @@ /// @TODO: bundle iOS/tvOS support. use std::sync::{Arc, RwLock}; +use core_foundation::base::TCFType; use core_graphics::base::CGFloat; use core_graphics::color::CGColor; @@ -247,9 +248,9 @@ impl Color { let b = blue as CGFloat / 255.0; let a = alpha as CGFloat / 255.0; #[cfg(feature = "appkit")] - let ptr = unsafe { Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedRed:r green:g blue:b alpha:a]) }; + let ptr = unsafe { Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedRed: r, green: g, blue: b, alpha: a]) }; #[cfg(all(feature = "uikit", not(feature = "appkit")))] - let ptr = unsafe { Id::from_ptr(msg_send![class!(UIColor), colorWithRed:r green:g blue:b alpha:a]) }; + let ptr = unsafe { Id::from_ptr(msg_send![class!(UIColor), colorWithRed: r, green: g, blue: b, alpha: a]) }; Color::Custom(Arc::new(RwLock::new(ptr))) } @@ -398,10 +399,9 @@ impl Color { /// you're not using a cached version of this unless you explicitly want the _same_ color /// in every context it's used in. pub fn cg_color(&self) -> CGColor { - // @TODO: This should probably return a CGColorRef... unsafe { let objc: id = self.into(); - msg_send![objc, CGColor] + CGColor::wrap_under_get_rule(msg_send![objc, CGColor]) } } } diff --git a/src/defaults/mod.rs b/src/defaults/mod.rs index ca95a94d..d8014231 100644 --- a/src/defaults/mod.rs +++ b/src/defaults/mod.rs @@ -133,7 +133,7 @@ impl UserDefaults { let value: id = value.into(); unsafe { - let _: () = msg_send![&*self.0, setObject:value forKey:key]; + let _: () = msg_send![&*self.0, setObject: value, forKey: &*key]; } } diff --git a/src/error.rs b/src/error.rs index e36d19b5..584e708b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -58,7 +58,7 @@ impl Error { unsafe { let domain = NSString::new(&self.domain); let code = self.code as NSInteger; - msg_send![class!(NSError), errorWithDomain:domain code:code userInfo:nil] + msg_send![class!(NSError), errorWithDomain: &*domain, code: code, userInfo: nil] } } } diff --git a/src/filesystem/save.rs b/src/filesystem/save.rs index e95082fc..fdec114c 100644 --- a/src/filesystem/save.rs +++ b/src/filesystem/save.rs @@ -95,7 +95,7 @@ impl FileSavePanel { let _: () = msg_send![&*self.panel, runModal]; completion.call((1,)); //beginWithCompletionHandler:completion.copy()]; - //let _: () = msg_send![&*self.panel, beginWithCompletionHandler:completion.copy()]; + //let _: () = msg_send![&*self.panel, beginWithCompletionHandler: &*completion.copy()]; } } } diff --git a/src/filesystem/select.rs b/src/filesystem/select.rs index 71b6f7d5..40807995 100644 --- a/src/filesystem/select.rs +++ b/src/filesystem/select.rs @@ -148,7 +148,7 @@ impl FileSelectPanel { }); unsafe { - let _: () = msg_send![&*self.panel, beginWithCompletionHandler:completion.copy()]; + let _: () = msg_send![&*self.panel, beginWithCompletionHandler: &*completion.copy()]; } } @@ -184,7 +184,11 @@ impl FileSelectPanel { }); unsafe { - let _: () = msg_send![&*self.panel, beginSheetModalForWindow:&*window.objc completionHandler:completion.copy()]; + let _: () = msg_send![ + &*self.panel, + beginSheetModalForWindow: &*window.objc, + completionHandler: &*completion.copy(), + ]; } } } diff --git a/src/foundation/urls/mod.rs b/src/foundation/urls/mod.rs index 4568a8ab..e4099bec 100644 --- a/src/foundation/urls/mod.rs +++ b/src/foundation/urls/mod.rs @@ -105,18 +105,22 @@ impl<'a> NSURL<'a> { // Mutability woes mean we just go through a match here to satisfy message passing needs. let bookmark_data = NSData::retain(match relative_to_url { Some(relative_url) => unsafe { - msg_send![&*self.objc, bookmarkDataWithOptions:opts - includingResourceValuesForKeys:resource_keys - relativeToURL:relative_url - error:nil + msg_send![ + &*self.objc, + bookmarkDataWithOptions: opts, + includingResourceValuesForKeys: resource_keys, + relativeToURL: &*relative_url, + error: nil, ] }, None => unsafe { - msg_send![&*self.objc, bookmarkDataWithOptions:opts - includingResourceValuesForKeys:resource_keys - relativeToURL:nil - error:nil + msg_send![ + &*self.objc, + bookmarkDataWithOptions: opts, + includingResourceValuesForKeys: resource_keys, + relativeToURL: nil, + error: nil, ] } }); diff --git a/src/image/image.rs b/src/image/image.rs index ea174fad..80cb2826 100644 --- a/src/image/image.rs +++ b/src/image/image.rs @@ -142,7 +142,7 @@ impl Image { Image(unsafe { let alloc: id = msg_send![Self::class(), alloc]; - ShareId::from_ptr(msg_send![alloc, initWithContentsOfFile: file_path]) + ShareId::from_ptr(msg_send![alloc, initWithContentsOfFile: &*file_path]) }) } @@ -161,7 +161,7 @@ impl Image { Image(unsafe { let alloc: id = msg_send![Self::class(), alloc]; - ShareId::from_ptr(msg_send![alloc, initWithData: data]) + ShareId::from_ptr(msg_send![alloc, initWithData: &*data]) }) } @@ -196,8 +196,11 @@ impl Image { true => { let icon = NSString::new(icon.to_sfsymbol_str()); let desc = NSString::new(accessibility_description); - msg_send![Self::class(), imageWithSystemSymbolName:&*icon - accessibilityDescription:&*desc] + msg_send![ + Self::class(), + imageWithSystemSymbolName: &*icon, + accessibilityDescription: &*desc, + ] }, false => { @@ -284,9 +287,11 @@ impl Image { let block = block.copy(); Image(unsafe { - let img: id = msg_send![Self::class(), imageWithSize:target_frame.size - flipped:YES - drawingHandler:block + let img: id = msg_send![ + Self::class(), + imageWithSize: target_frame.size, + flipped: YES, + drawingHandler: &*block, ]; ShareId::from_ptr(img) diff --git a/src/image/mod.rs b/src/image/mod.rs index 0ee6407e..66649c47 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -1,3 +1,5 @@ +use core_foundation::base::TCFType; + use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel}; @@ -149,7 +151,7 @@ impl ImageView { /// Call this to set the background color for the backing layer. pub fn set_background_color>(&self, color: C) { self.objc.with_mut(|obj| unsafe { - let cg = color.as_ref().cg_color(); + let cg = color.as_ref().cg_color().as_concrete_TypeRef(); let layer: id = msg_send![obj, layer]; let _: () = msg_send![layer, setBackgroundColor: cg]; }); diff --git a/src/input/mod.rs b/src/input/mod.rs index e71fb9c5..4cdf616b 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -43,6 +43,8 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use core_foundation::base::TCFType; + use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{class, msg_send, sel}; @@ -306,7 +308,7 @@ impl TextField { /// Call this to set the background color for the backing layer. pub fn set_background_color>(&self, color: C) { self.objc.with_mut(|obj| unsafe { - let cg = color.as_ref().cg_color(); + let cg = color.as_ref().cg_color().as_concrete_TypeRef(); let layer: id = msg_send![obj, layer]; let _: () = msg_send![layer, setBackgroundColor: cg]; }); diff --git a/src/layout/dimension.rs b/src/layout/dimension.rs index afcda720..74759e94 100644 --- a/src/layout/dimension.rs +++ b/src/layout/dimension.rs @@ -51,7 +51,7 @@ impl LayoutAnchorDimension { if let Self::Width(obj) | Self::Height(obj) = self { return LayoutConstraint::new(unsafe { let value = constant as CGFloat; - msg_send![*obj, constraintEqualToConstant: value] + msg_send![obj, constraintEqualToConstant: value] }); } @@ -63,7 +63,7 @@ impl LayoutAnchorDimension { if let Self::Width(obj) | Self::Height(obj) = self { return LayoutConstraint::new(unsafe { let value = constant as CGFloat; - msg_send![*obj, constraintGreaterThanOrEqualToConstant: value] + msg_send![obj, constraintGreaterThanOrEqualToConstant: value] }); } @@ -75,7 +75,7 @@ impl LayoutAnchorDimension { if let Self::Width(obj) | Self::Height(obj) = self { return LayoutConstraint::new(unsafe { let value = constant as CGFloat; - msg_send![*obj, constraintLessThanOrEqualToConstant: value] + msg_send![obj, constraintLessThanOrEqualToConstant: value] }); } @@ -112,21 +112,21 @@ impl LayoutAnchorDimension { /// Return a constraint equal to another dimension anchor. pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorDimension) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintEqualToAnchor:&**to] + msg_send![from, constraintEqualToAnchor:&**to] }) } /// Return a constraint greater than or equal to another dimension anchor. pub fn constraint_greater_than_or_equal_to(&self, anchor_to: &LayoutAnchorDimension) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintGreaterThanOrEqualToAnchor:&**to] + msg_send![from, constraintGreaterThanOrEqualToAnchor:&**to] }) } /// Return a constraint less than or equal to another dimension anchor. pub fn constraint_less_than_or_equal_to(&self, anchor_to: &LayoutAnchorDimension) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintLessThanOrEqualToAnchor:&**to] + msg_send![from, constraintLessThanOrEqualToAnchor:&**to] }) } } diff --git a/src/layout/horizontal.rs b/src/layout/horizontal.rs index 754efaab..bb828633 100644 --- a/src/layout/horizontal.rs +++ b/src/layout/horizontal.rs @@ -160,21 +160,21 @@ impl LayoutAnchorX { /// Return a constraint equal to another horizontal anchor. pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorX) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintEqualToAnchor:&**to] + msg_send![from, constraintEqualToAnchor:&**to] }) } /// Return a constraint greater than or equal to another horizontal anchor. pub fn constraint_greater_than_or_equal_to(&self, anchor_to: &LayoutAnchorX) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintGreaterThanOrEqualToAnchor:&**to] + msg_send![from, constraintGreaterThanOrEqualToAnchor:&**to] }) } /// Return a constraint less than or equal to another horizontal anchor. pub fn constraint_less_than_or_equal_to(&self, anchor_to: &LayoutAnchorX) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintLessThanOrEqualToAnchor:&**to] + msg_send![from, constraintLessThanOrEqualToAnchor:&**to] }) } } diff --git a/src/layout/vertical.rs b/src/layout/vertical.rs index db9c49ab..232945a7 100644 --- a/src/layout/vertical.rs +++ b/src/layout/vertical.rs @@ -79,21 +79,21 @@ impl LayoutAnchorY { /// Return a constraint equal to another vertical anchor. pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorY) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintEqualToAnchor:&**to] + msg_send![from, constraintEqualToAnchor:&**to] }) } /// Return a constraint greater than or equal to another vertical anchor. pub fn constraint_greater_than_or_equal_to(&self, anchor_to: &LayoutAnchorY) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintGreaterThanOrEqualToAnchor:&**to] + msg_send![from, constraintGreaterThanOrEqualToAnchor:&**to] }) } /// Return a constraint less than or equal to another vertical anchor. pub fn constraint_less_than_or_equal_to(&self, anchor_to: &LayoutAnchorY) -> LayoutConstraint { self.constraint_with(anchor_to, |from, to| unsafe { - msg_send![*from, constraintLessThanOrEqualToAnchor:&**to] + msg_send![from, constraintLessThanOrEqualToAnchor:&**to] }) } } diff --git a/src/listview/actions.rs b/src/listview/actions.rs index 7013c8fe..6059d005 100644 --- a/src/listview/actions.rs +++ b/src/listview/actions.rs @@ -65,9 +65,11 @@ impl RowAction { RowAction(unsafe { let cls = class!(NSTableViewRowAction); - Id::from_ptr(msg_send![cls, rowActionWithStyle:style - title:&*title - handler:block + Id::from_ptr(msg_send![ + cls, + rowActionWithStyle: style, + title: &*title, + handler: &*block, ]) }) } diff --git a/src/listview/mod.rs b/src/listview/mod.rs index fe4a0b98..4b924e4e 100644 --- a/src/listview/mod.rs +++ b/src/listview/mod.rs @@ -44,6 +44,8 @@ use std::collections::HashMap; +use core_foundation::base::TCFType; + use crate::id_shim::ShareId; use core_graphics::base::CGFloat; use objc::runtime::{Class, Object}; @@ -439,7 +441,7 @@ impl ListView { pub fn set_background_color>(&self, color: C) { // @TODO: This is wrong. self.objc.with_mut(|obj| unsafe { - let color = color.as_ref().cg_color(); + let color = color.as_ref().cg_color().as_concrete_TypeRef(); let layer: id = msg_send![obj, layer]; let _: () = msg_send![layer, setBackgroundColor: color]; }); diff --git a/src/pasteboard/mod.rs b/src/pasteboard/mod.rs index 68859da9..1db2f872 100644 --- a/src/pasteboard/mod.rs +++ b/src/pasteboard/mod.rs @@ -63,7 +63,7 @@ impl Pasteboard { let ptype: NSString = PasteboardType::String.into(); unsafe { - let _: () = msg_send![&*self.0, setString:&*contents forType:ptype]; + let _: () = msg_send![&*self.0, setString: &*contents, forType: &*ptype]; } } @@ -91,7 +91,7 @@ impl Pasteboard { unsafe { let class: id = msg_send![class!(NSURL), class]; let classes = NSArray::new(&[class]); - let contents: id = msg_send![&*self.0, readObjectsForClasses:classes options:nil]; + let contents: id = msg_send![&*self.0, readObjectsForClasses: &*classes, options: nil]; // This can happen if the Pasteboard server has an error in returning items. // In our case, we'll bubble up an error by checking the pasteboard. diff --git a/src/quicklook/mod.rs b/src/quicklook/mod.rs index 035da652..bca530d0 100644 --- a/src/quicklook/mod.rs +++ b/src/quicklook/mod.rs @@ -48,8 +48,11 @@ impl ThumbnailGenerator { let request = config.to_request(path); unsafe { - let _: () = msg_send![&*self.0, generateRepresentationsForRequest:request - updateHandler:block]; + let _: () = msg_send![ + &*self.0, + generateRepresentationsForRequest: request, + updateHandler: &*block, + ]; } } } diff --git a/src/scrollview/mod.rs b/src/scrollview/mod.rs index 13995ecf..16ee2dfa 100644 --- a/src/scrollview/mod.rs +++ b/src/scrollview/mod.rs @@ -42,6 +42,8 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use core_foundation::base::TCFType; + use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel}; @@ -296,7 +298,7 @@ impl ScrollView { pub fn set_background_color>(&self, color: C) { // @TODO: This is wrong. self.objc.with_mut(|obj| unsafe { - let color = color.as_ref().cg_color(); + let color = color.as_ref().cg_color().as_concrete_TypeRef(); let layer: id = msg_send![obj, layer]; let _: () = msg_send![layer, setBackgroundColor: color]; }); diff --git a/src/select/mod.rs b/src/select/mod.rs index 56bf8109..dd6abeb5 100644 --- a/src/select/mod.rs +++ b/src/select/mod.rs @@ -161,7 +161,7 @@ impl Select { pub fn add_item(&self, title: &str) { self.objc.with_mut(|obj| unsafe { let s = NSString::new(title); - let _: () = msg_send![obj, addItemWithTitle: s]; + let _: () = msg_send![obj, addItemWithTitle: &*s]; }); } diff --git a/src/switch.rs b/src/switch.rs index 2c59f0a5..8400da9e 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -69,7 +69,7 @@ impl Switch { let title = NSString::new(text); let view: id = unsafe { - let button: id = msg_send![register_class(), buttonWithTitle:title target:nil action:nil]; + let button: id = msg_send![register_class(), buttonWithTitle: &*title, target: nil, action: nil]; #[cfg(feature = "autolayout")] let _: () = msg_send![button, setTranslatesAutoresizingMaskIntoConstraints: NO]; diff --git a/src/text/attributed_string.rs b/src/text/attributed_string.rs index 9ce1c804..f07cacfd 100644 --- a/src/text/attributed_string.rs +++ b/src/text/attributed_string.rs @@ -3,14 +3,13 @@ use std::ops::{Deref, DerefMut, Range}; use std::os::raw::c_char; use std::{fmt, slice, str}; -use core_foundation::base::CFRange; - use crate::id_shim::Id; use objc::runtime::Object; use objc::{class, msg_send, sel}; use crate::color::Color; use crate::foundation::{id, to_bool, NSString, BOOL, NO, YES}; +use crate::utils::CFRange; use super::Font; @@ -49,19 +48,25 @@ impl AttributedString { let range = CFRange::init(range.start, range.end); unsafe { - let _: () = msg_send![&*self.0, addAttribute:NSForegroundColorAttributeName - value:color - range:range + let _: () = msg_send![ + &*self.0, + addAttribute: NSForegroundColorAttributeName, + value: color, + range: range, ]; } } /// Set the font for the specified range. pub fn set_font(&mut self, font: Font, range: Range) { + let range = CFRange::init(range.start, range.end); + unsafe { - let _: () = msg_send![&*self.0, addAttribute:NSFontAttributeName - value:&*font - range:range + let _: () = msg_send![ + &*self.0, + addAttribute: NSFontAttributeName, + value: &*font, + range: range, ]; } } diff --git a/src/text/label/mod.rs b/src/text/label/mod.rs index 8d2514b6..417d9085 100644 --- a/src/text/label/mod.rs +++ b/src/text/label/mod.rs @@ -43,6 +43,8 @@ //! //! For more information on Autolayout, view the module or check out the examples folder. +use core_foundation::base::TCFType; + use crate::id_shim::ShareId; use objc::runtime::{Class, Object}; use objc::{msg_send, sel}; @@ -324,7 +326,7 @@ impl Label { // @TODO: This is wrong. // Needs to set ivar and such, akin to View. self.objc.with_mut(|obj| unsafe { - let color = color.as_ref().cg_color(); + let color = color.as_ref().cg_color().as_concrete_TypeRef(); let layer: id = msg_send![obj, layer]; let _: () = msg_send![layer, setBackgroundColor: color]; }); diff --git a/src/uikit/scene/config.rs b/src/uikit/scene/config.rs index 4a943d4f..a76d5fe2 100644 --- a/src/uikit/scene/config.rs +++ b/src/uikit/scene/config.rs @@ -24,7 +24,7 @@ impl SceneConfig { let role = NSString::from(role); let cls = class!(UISceneConfiguration); - let config: id = msg_send![cls, configurationWithName:name sessionRole:role]; + let config: id = msg_send![cls, configurationWithName: &*name, sessionRole: &*role]; let _: () = msg_send![config, setSceneClass: class!(UIWindowScene)]; diff --git a/src/uikit/scene/delegate.rs b/src/uikit/scene/delegate.rs index 1b80b409..2673b7c6 100644 --- a/src/uikit/scene/delegate.rs +++ b/src/uikit/scene/delegate.rs @@ -9,9 +9,9 @@ use crate::utils::load; pub(crate) static WINDOW_SCENE_PTR: &str = "rstWindowSceneDelegatePtr"; /// -extern "C" fn init Box>(this: &mut Object, _: Sel) -> id { +extern "C" fn init Box>(mut this: &mut Object, _: Sel) -> id { let x = unsafe { - *this = msg_send![super(this, class!(UIResponder)), init]; + this = msg_send![super(this, class!(UIResponder)), init]; let scene_delegate_vendor = SCENE_DELEGATE_VENDOR as *const F; let factory: &F = &*scene_delegate_vendor; diff --git a/src/user_notifications/mod.rs b/src/user_notifications/mod.rs index 4b7c0adf..f18f827e 100644 --- a/src/user_notifications/mod.rs +++ b/src/user_notifications/mod.rs @@ -27,7 +27,7 @@ impl NotificationCenter { unsafe { // @TODO: Revisit. let block = ConcreteBlock::new(|_: id, error: id| { - let localized_description = NSString::new(msg_send![error, localizedDescription]); + let localized_description = NSString::retain(msg_send![error, localizedDescription]); let e = localized_description.to_str(); if e != "" { println!("{:?}", e); @@ -41,7 +41,11 @@ impl NotificationCenter { } let center: id = msg_send![class!(UNUserNotificationCenter), currentNotificationCenter]; - let _: () = msg_send![center, requestAuthorizationWithOptions:opts completionHandler:block.copy()]; + let _: () = msg_send![ + center, + requestAuthorizationWithOptions:opts, + completionHandler: &*block.copy(), + ]; } } @@ -51,8 +55,12 @@ impl NotificationCenter { unsafe { let identifier = NSString::new(&uuidentifier); - let request: id = - msg_send![class!(UNNotificationRequest), requestWithIdentifier:identifier content:&*notification.0 trigger:nil]; + let request: id = msg_send![ + class!(UNNotificationRequest), + requestWithIdentifier: &*identifier, + content: &*notification.0, + trigger: nil, + ]; let center: id = msg_send![class!(UNUserNotificationCenter), currentNotificationCenter]; let _: () = msg_send![center, addNotificationRequest: request]; } diff --git a/src/user_notifications/notifications.rs b/src/user_notifications/notifications.rs index 2c0cbb24..770e2e01 100644 --- a/src/user_notifications/notifications.rs +++ b/src/user_notifications/notifications.rs @@ -21,8 +21,8 @@ impl Notification { Notification(unsafe { let content: id = msg_send![class!(UNMutableNotificationContent), new]; - let _: () = msg_send![content, setTitle: title]; - let _: () = msg_send![content, setBody: body]; + let _: () = msg_send![content, setTitle: &*title]; + let _: () = msg_send![content, setBody: &*body]; Id::from_ptr(content) }) } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 9c65ef88..830c9661 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,6 +2,7 @@ //! belong to. These are typically internal, and if you rely on them... well, don't be surprised if //! they go away one day. +use core_foundation::base::CFIndex; use core_graphics::base::CGFloat; use objc::{class, msg_send, sel}; @@ -95,6 +96,26 @@ unsafe impl Encode for CGSize { const ENCODING: Encoding<'static> = Encoding::Struct("CGSize", &[CGFloat::ENCODING, CGFloat::ENCODING]); } +#[repr(C)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct CFRange { + pub location: CFIndex, + pub length: CFIndex +} + +impl CFRange { + pub fn init(location: CFIndex, length: CFIndex) -> CFRange { + CFRange { + location: location, + length: length + } + } +} + +unsafe impl Encode for CFRange { + const ENCODING: Encoding<'static> = Encoding::Struct("CFRange", &[CFIndex::ENCODING, CFIndex::ENCODING]); +} + /// A helper method for ensuring that Cocoa is running in multi-threaded mode. /// /// Why do we need this? According to Apple, if you're going to make use of standard POSIX threads, diff --git a/src/webview/class.rs b/src/webview/class.rs index ee468ab5..1ca540a3 100644 --- a/src/webview/class.rs +++ b/src/webview/class.rs @@ -68,8 +68,13 @@ extern "C" fn start_url_scheme_task(this: &Object, _: Sel, _ if let Some(content) = delegate.on_custom_protocol_request(uri_str) { let mime = MimeType::parse(&content, uri_str); let nsurlresponse: id = msg_send![class!(NSURLResponse), alloc]; - let response: id = msg_send![nsurlresponse, initWithURL:url MIMEType:NSString::new(&mime) - expectedContentLength:content.len() textEncodingName:null::()]; + let response: id = msg_send![ + nsurlresponse, + initWithURL: url, + MIMEType: &*NSString::new(&mime), + expectedContentLength: content.len(), + textEncodingName: null::(), + ]; let _: () = msg_send![task, didReceiveResponse: response]; // Send data @@ -94,7 +99,7 @@ extern "C" fn decide_policy_for_action(this: &Object, _: Sel let action = NavigationAction::new(action); delegate.policy_for_navigation_action(action, |policy| unsafe { - let handler = handler as *const Block<(NSInteger,), c_void>; + let handler = handler as *const Block<(NSInteger,), ()>; (*handler).call((policy.into(),)); }); } @@ -106,7 +111,7 @@ extern "C" fn decide_policy_for_response(this: &Object, _: S let response = NavigationResponse::new(response); delegate.policy_for_navigation_response(response, |policy| unsafe { - let handler = handler as *const Block<(NSInteger,), c_void>; + let handler = handler as *const Block<(NSInteger,), ()>; (*handler).call((policy.into(),)); }); } @@ -116,7 +121,7 @@ extern "C" fn run_open_panel(this: &Object, _: Sel, _: id, p let delegate = load::(this, WEBVIEW_DELEGATE_PTR); delegate.run_open_panel(params.into(), move |urls| unsafe { - let handler = handler as *const Block<(id,), c_void>; + let handler = handler as *const Block<(id,), ()>; match urls { Some(u) => { @@ -146,7 +151,7 @@ extern "C" fn run_open_panel(this: &Object, _: Sel, _: id, p extern "C" fn handle_download(this: &Object, _: Sel, download: id, suggested_filename: id, handler: usize) { let delegate = load::(this, WEBVIEW_DELEGATE_PTR); - let handler = handler as *const Block<(objc::runtime::BOOL, id), c_void>; + let handler = handler as *const Block<(objc::runtime::BOOL, id), ()>; let filename = NSString::from_retained(suggested_filename); delegate.run_save_panel(filename.to_str(), move |can_overwrite, path| unsafe { diff --git a/src/webview/config.rs b/src/webview/config.rs index e40e909c..6c3fe6b0 100644 --- a/src/webview/config.rs +++ b/src/webview/config.rs @@ -47,10 +47,15 @@ impl WebViewConfig { unsafe { let alloc: id = msg_send![class!(WKUserScript), alloc]; - let user_script: id = msg_send![alloc, initWithSource:source injectionTime:at forMainFrameOnly:match main_frame_only { - true => YES, - false => NO - }]; + let user_script: id = msg_send![ + alloc, + initWithSource: &*source, + injectionTime: at, + forMainFrameOnly: match main_frame_only { + true => YES, + false => NO + }, + ]; let content_controller: id = msg_send![&*self.objc, userContentController]; let _: () = msg_send![content_controller, addUserScript: user_script]; @@ -70,7 +75,7 @@ impl WebViewConfig { unsafe { let yes: id = msg_send![class!(NSNumber), numberWithBool: YES]; let preferences: id = msg_send![&*self.objc, preferences]; - let _: () = msg_send![preferences, setValue:yes forKey:key]; + let _: () = msg_send![preferences, setValue: yes, forKey: &*key]; } } From 6aa8b8a4d16fbb1c049ebfefd957acfe1e9ed311 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Aug 2023 02:51:35 +0200 Subject: [PATCH 08/19] Use immutable reference in a few places where now necessary See https://github.com/madsmtm/objc2/pull/150 for a bit of background --- src/input/appkit.rs | 10 +++++----- src/input/uikit.rs | 10 +++++----- src/view/controller/appkit.rs | 8 ++++---- src/view/controller/uikit.rs | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/input/appkit.rs b/src/input/appkit.rs index 4c8495c9..3139c502 100644 --- a/src/input/appkit.rs +++ b/src/input/appkit.rs @@ -6,25 +6,25 @@ use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR}; use crate::utils::load; /// Called when editing this text field has ended (e.g. user pressed enter). -extern "C" fn text_did_end_editing(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_end_editing(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, stringValue] }); view.text_did_end_editing(s.to_str()); } -extern "C" fn text_did_begin_editing(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_begin_editing(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, stringValue] }); view.text_did_begin_editing(s.to_str()); } -extern "C" fn text_did_change(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_change(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, stringValue] }); view.text_did_change(s.to_str()); } -extern "C" fn text_should_begin_editing(this: &mut Object, _: Sel, _info: id) -> BOOL { +extern "C" fn text_should_begin_editing(this: &Object, _: Sel, _info: id) -> BOOL { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, stringValue] }); @@ -34,7 +34,7 @@ extern "C" fn text_should_begin_editing(this: &mut Object, } } -extern "C" fn text_should_end_editing(this: &mut Object, _: Sel, _info: id) -> BOOL { +extern "C" fn text_should_end_editing(this: &Object, _: Sel, _info: id) -> BOOL { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, stringValue] }); match view.text_should_end_editing(s.to_str()) { diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 66a9366f..63065704 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -10,25 +10,25 @@ use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR}; use crate::utils::load; /// Called when editing this text field has ended (e.g. user pressed enter). -extern "C" fn text_did_end_editing(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_end_editing(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, text] }); view.text_did_end_editing(s.to_str()); } -extern "C" fn text_did_begin_editing(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_begin_editing(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, text] }); view.text_did_begin_editing(s.to_str()); } -extern "C" fn text_did_change(this: &mut Object, _: Sel, _info: id) { +extern "C" fn text_did_change(this: &Object, _: Sel, _info: id) { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, text] }); view.text_did_change(s.to_str()); } -extern "C" fn text_should_begin_editing(this: &mut Object, _: Sel, _info: id) -> BOOL { +extern "C" fn text_should_begin_editing(this: &Object, _: Sel, _info: id) -> BOOL { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, text] }); @@ -38,7 +38,7 @@ extern "C" fn text_should_begin_editing(this: &mut Object, } } -extern "C" fn text_should_end_editing(this: &mut Object, _: Sel, _info: id) -> BOOL { +extern "C" fn text_should_end_editing(this: &Object, _: Sel, _info: id) -> BOOL { let view = load::(this, TEXTFIELD_DELEGATE_PTR); let s = NSString::retain(unsafe { msg_send![this, text] }); match view.text_should_end_editing(s.to_str()) { diff --git a/src/view/controller/appkit.rs b/src/view/controller/appkit.rs index 45fb03a4..fe63aa5f 100644 --- a/src/view/controller/appkit.rs +++ b/src/view/controller/appkit.rs @@ -11,7 +11,7 @@ use crate::utils::load; use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR}; /// Called when the view controller receives a `viewWillAppear` message. -extern "C" fn will_appear(this: &mut Object, _: Sel) { +extern "C" fn will_appear(this: &Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewWillAppear]; } @@ -21,7 +21,7 @@ extern "C" fn will_appear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewDidAppear` message. -extern "C" fn did_appear(this: &mut Object, _: Sel) { +extern "C" fn did_appear(this: &Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewDidAppear]; } @@ -31,7 +31,7 @@ extern "C" fn did_appear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewWillDisappear` message. -extern "C" fn will_disappear(this: &mut Object, _: Sel) { +extern "C" fn will_disappear(this: &Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewWillDisappear]; } @@ -41,7 +41,7 @@ extern "C" fn will_disappear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewDidDisappear` message. -extern "C" fn did_disappear(this: &mut Object, _: Sel) { +extern "C" fn did_disappear(this: &Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewDidDisappear]; } diff --git a/src/view/controller/uikit.rs b/src/view/controller/uikit.rs index 9598dd51..f2526f5c 100644 --- a/src/view/controller/uikit.rs +++ b/src/view/controller/uikit.rs @@ -11,7 +11,7 @@ use crate::utils::load; use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR}; /// Called when the view controller receives a `viewWillAppear:` message. -extern "C" fn will_appear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn will_appear(this: &Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewWillAppear: animated]; } @@ -21,7 +21,7 @@ extern "C" fn will_appear(this: &mut Object, _: Sel, animated: } /// Called when the view controller receives a `viewDidAppear:` message. -extern "C" fn did_appear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn did_appear(this: &Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewDidAppear: animated]; } @@ -31,7 +31,7 @@ extern "C" fn did_appear(this: &mut Object, _: Sel, animated: B } /// Called when the view controller receives a `viewWillDisappear:` message. -extern "C" fn will_disappear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn will_disappear(this: &Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewWillDisappear: animated]; } @@ -41,7 +41,7 @@ extern "C" fn will_disappear(this: &mut Object, _: Sel, animate } /// Called when the view controller receives a `viewDidDisappear:` message. -extern "C" fn did_disappear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn did_disappear(this: &Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewDidDisappear: animated]; } From bf787e0ba69ba3cf436e0e37f1779e2f7faf5df9 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 20 Jul 2022 06:19:31 +0200 Subject: [PATCH 09/19] Add a few Send + Sync bounds where examples require it This is something we'll need to look into properly --- src/layout/animator.rs | 4 ++++ src/view/animator.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/layout/animator.rs b/src/layout/animator.rs index 5a11a13e..c07222a1 100644 --- a/src/layout/animator.rs +++ b/src/layout/animator.rs @@ -23,3 +23,7 @@ impl LayoutConstraintAnimatorProxy { } } } + +// TODO: Safety +unsafe impl Send for LayoutConstraintAnimatorProxy {} +unsafe impl Sync for LayoutConstraintAnimatorProxy {} diff --git a/src/view/animator.rs b/src/view/animator.rs index 0f7357e0..92b8a3ea 100644 --- a/src/view/animator.rs +++ b/src/view/animator.rs @@ -22,3 +22,7 @@ impl ViewAnimatorProxy { } } } + +// TODO: Safety +unsafe impl Send for ViewAnimatorProxy {} +unsafe impl Sync for ViewAnimatorProxy {} From c7f219412733243dd5642c22fc6813fba9d2efe8 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 5 Sep 2023 12:45:45 +0200 Subject: [PATCH 10/19] Use `&'static Class` instead of `*const Class` Safer and more ergonomic. Also required for `msg_send_id!` macro --- ARCHITECTURE.md | 10 +++++----- src/appkit/app/class.rs | 2 +- src/appkit/app/delegate.rs | 2 +- src/appkit/menu/item.rs | 2 +- src/appkit/toolbar/class.rs | 2 +- src/appkit/window/class.rs | 2 +- src/appkit/window/controller/class.rs | 2 +- src/button/mod.rs | 2 +- src/color/appkit_dynamic_color.rs | 2 +- src/foundation/class.rs | 14 +++++++------- src/image/appkit.rs | 2 +- src/image/mod.rs | 2 +- src/image/uikit.rs | 2 +- src/input/appkit.rs | 4 ++-- src/input/mod.rs | 2 +- src/input/uikit.rs | 10 +++++----- src/invoker.rs | 2 +- src/listview/appkit.rs | 4 ++-- src/listview/mod.rs | 2 +- src/listview/row/appkit.rs | 4 ++-- src/listview/row/mod.rs | 2 +- src/listview/row/uikit.rs | 4 ++-- src/scrollview/appkit.rs | 4 ++-- src/scrollview/mod.rs | 2 +- src/scrollview/uikit.rs | 16 ++++++++-------- src/select/mod.rs | 2 +- src/switch.rs | 2 +- src/text/label/appkit.rs | 4 ++-- src/text/label/mod.rs | 2 +- src/text/label/uikit.rs | 16 ++++++++-------- src/uikit/app/class.rs | 2 +- src/uikit/app/delegate.rs | 2 +- src/uikit/scene/delegate.rs | 2 +- src/view/appkit.rs | 4 ++-- src/view/controller/appkit.rs | 2 +- src/view/controller/uikit.rs | 2 +- src/view/splitviewcontroller/ios.rs | 2 +- src/view/splitviewcontroller/macos.rs | 2 +- src/view/uikit.rs | 4 ++-- src/webview/class.rs | 4 ++-- 40 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 522399f6..71c87851 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -352,8 +352,8 @@ We'll step through an example (abridged) `View` bridge below, for macOS. You sho For our basic `View` type, we want to just map to the corresponding class on the Objective-C side (in this case, `NSView`), and maybe do a bit of tweaking for sanity reasons. ``` rust -pub(crate) fn register_view_class() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_view_class() -> &'static Class { + static mut VIEW_CLASS: Option<'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { @@ -364,10 +364,10 @@ pub(crate) fn register_view_class() -> *const Class { decl.add_ivar::(BACKGROUND_COLOR); - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } ``` @@ -377,7 +377,7 @@ Objective-C method signatures, as well as provision space for variable storage ( For our _delegate_ types, we need a different class creation method - one that creates a subclass per-unique-type: ``` rust -pub(crate) fn register_view_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_view_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("NSView", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); decl.add_ivar::(BACKGROUND_COLOR); diff --git a/src/appkit/app/class.rs b/src/appkit/app/class.rs index 59690d96..223be7f1 100644 --- a/src/appkit/app/class.rs +++ b/src/appkit/app/class.rs @@ -7,6 +7,6 @@ use objc::runtime::Class; use crate::foundation::load_or_register_class; /// Used for injecting a custom NSApplication. Currently does nothing. -pub(crate) fn register_app_class() -> *const Class { +pub(crate) fn register_app_class() -> &'static Class { load_or_register_class("NSApplication", "RSTApplication", |decl| unsafe {}) } diff --git a/src/appkit/app/delegate.rs b/src/appkit/app/delegate.rs index 3890291a..879f040b 100644 --- a/src/appkit/app/delegate.rs +++ b/src/appkit/app/delegate.rs @@ -291,7 +291,7 @@ extern "C" fn delegate_handles_key(this: &Object, _: Sel, _: id, /// Registers an `NSObject` application delegate, and configures it for the various callbacks and /// pointers we need to have. -pub(crate) fn register_app_delegate_class() -> *const Class { +pub(crate) fn register_app_delegate_class() -> &'static Class { load_or_register_class("NSObject", "RSTAppDelegate", |decl| unsafe { decl.add_ivar::(APP_PTR); diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index ac75ccee..e591e474 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -314,7 +314,7 @@ extern "C" fn fire_block_action(this: &Object, _: Sel, _item: id) { /// /// In general, we do not want to do more than we need to here - menus are one of the last areas /// where Carbon still lurks, and subclassing things can get weird. -pub(crate) fn register_menu_item_class() -> *const Class { +pub(crate) fn register_menu_item_class() -> &'static Class { load_or_register_class("NSMenuItem", "CacaoMenuItem", |decl| unsafe { decl.add_ivar::(BLOCK_PTR); diff --git a/src/appkit/toolbar/class.rs b/src/appkit/toolbar/class.rs index 29139fcb..feecfda0 100644 --- a/src/appkit/toolbar/class.rs +++ b/src/appkit/toolbar/class.rs @@ -65,7 +65,7 @@ extern "C" fn item_for_identifier(this: &Object, _: Sel, _: /// Registers a `NSToolbar` subclass, and configures it to hold some ivars for various things we need /// to store. We use it as our delegate as well, just to cut down on moving pieces. -pub(crate) fn register_toolbar_class(instance: &T) -> *const Class { +pub(crate) fn register_toolbar_class(instance: &T) -> &'static Class { load_or_register_class("NSObject", instance.subclass_name(), |decl| unsafe { // For callbacks decl.add_ivar::(TOOLBAR_PTR); diff --git a/src/appkit/window/class.rs b/src/appkit/window/class.rs index 19dca2a6..09c6c02c 100644 --- a/src/appkit/window/class.rs +++ b/src/appkit/window/class.rs @@ -227,7 +227,7 @@ extern "C" fn cancel(this: &Object, _: Sel, _: id) { /// Injects an `NSWindowDelegate` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_window_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_window_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("NSWindow", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(WINDOW_DELEGATE_PTR); diff --git a/src/appkit/window/controller/class.rs b/src/appkit/window/controller/class.rs index 21cce00a..b5ecab44 100644 --- a/src/appkit/window/controller/class.rs +++ b/src/appkit/window/controller/class.rs @@ -8,7 +8,7 @@ use crate::foundation::load_or_register_class; /// Injects an `NSWindowController` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_window_controller_class() -> *const Class { +pub(crate) fn register_window_controller_class() -> &'static Class { load_or_register_class("NSWindowController", "RSTWindowController", |decl| unsafe { decl.add_ivar::(WINDOW_DELEGATE_PTR); }) diff --git a/src/button/mod.rs b/src/button/mod.rs index d7ac525b..0fc91da2 100644 --- a/src/button/mod.rs +++ b/src/button/mod.rs @@ -352,7 +352,7 @@ impl Drop for Button { /// Registers an `NSButton` subclass, and configures it to hold some ivars /// for various things we need to store. -fn register_class() -> *const Class { +fn register_class() -> &'static Class { #[cfg(feature = "appkit")] let super_class = "NSButton"; #[cfg(all(feature = "uikit", not(feature = "appkit")))] diff --git a/src/color/appkit_dynamic_color.rs b/src/color/appkit_dynamic_color.rs index d0cd0946..000ebc17 100644 --- a/src/color/appkit_dynamic_color.rs +++ b/src/color/appkit_dynamic_color.rs @@ -253,7 +253,7 @@ extern "C" fn color_with_system_effect(this: &Object, _: Sel, effect: NSInteger) unsafe { msg_send![color, colorWithSystemEffect: effect] } } -pub(crate) fn register_class() -> *const Class { +pub(crate) fn register_class() -> &'static Class { load_or_register_class("NSColor", "CacaoDynamicColor", |decl| unsafe { // These methods all need to be forwarded, so let's hook them up. decl.add_method(sel!(colorSpace), color_space as extern "C" fn(_, _) -> _); diff --git a/src/foundation/class.rs b/src/foundation/class.rs index 2398771c..820f602e 100644 --- a/src/foundation/class.rs +++ b/src/foundation/class.rs @@ -60,7 +60,7 @@ impl ClassMap { } /// A publicly accessible load method that just passes through our global singleton. - pub fn static_load(class_name: &'static str, superclass_name: Option<&'static str>) -> Option<*const Class> { + pub fn static_load(class_name: &'static str, superclass_name: Option<&'static str>) -> Option<&'static Class> { CLASSES.load(class_name, superclass_name) } @@ -68,12 +68,12 @@ impl ClassMap { /// /// This checks our internal map first, and then calls out to the Objective-C runtime to ensure /// we're not missing anything. - pub fn load(&self, class_name: &'static str, superclass_name: Option<&'static str>) -> Option<*const Class> { + pub fn load(&self, class_name: &'static str, superclass_name: Option<&'static str>) -> Option<&'static Class> { { let reader = self.0.read().unwrap(); if let Some(entry) = (*reader).get(&(class_name, superclass_name)) { let ptr = &entry.ptr; - return Some(*ptr as *const Class); + return Some(unsafe { &*(*ptr as *const Class) }); } } @@ -102,7 +102,7 @@ impl ClassMap { }); } - Some(class.cast()) + Some(unsafe { class.cast::().as_ref() }.unwrap()) } /// Store a newly created subclass type. @@ -130,7 +130,7 @@ impl ClassMap { /// > class name - but most cases do not need this and it would be a larger change to orchestrate at /// > the moment. #[inline(always)] -pub fn load_or_register_class(superclass_name: &'static str, subclass_name: &'static str, config: F) -> *const Class +pub fn load_or_register_class(superclass_name: &'static str, subclass_name: &'static str, config: F) -> &'static Class where F: Fn(&mut ClassDecl) + 'static { @@ -156,7 +156,7 @@ pub fn load_or_register_class_with_optional_generated_suffix( subclass_name: &'static str, should_append_random_subclass_name_suffix: bool, config: F -) -> *const Class +) -> &'static Class where F: Fn(&mut ClassDecl) + 'static { @@ -189,7 +189,7 @@ where false => format!("{}_{}", subclass_name, superclass_name) }; - match ClassDecl::new(&objc_subclass_name, unsafe { &*superclass }) { + match ClassDecl::new(&objc_subclass_name, superclass) { Some(mut decl) => { config(&mut decl); diff --git a/src/image/appkit.rs b/src/image/appkit.rs index e558b0df..15382d42 100644 --- a/src/image/appkit.rs +++ b/src/image/appkit.rs @@ -14,7 +14,7 @@ use crate::foundation::load_or_register_class; /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_image_view_class() -> *const Class { +pub(crate) fn register_image_view_class() -> &'static Class { load_or_register_class("NSImageView", "RSTImageView", |decl| unsafe { //decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); }) diff --git a/src/image/mod.rs b/src/image/mod.rs index 66649c47..c6d23c08 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -33,7 +33,7 @@ mod icons; pub use icons::*; /// A helper method for instantiating view classes and applying default settings to them. -fn allocate_view(registration_fn: fn() -> *const Class) -> id { +fn allocate_view(registration_fn: fn() -> &'static Class) -> id { unsafe { let view: id = msg_send![registration_fn(), new]; diff --git a/src/image/uikit.rs b/src/image/uikit.rs index 8cb89a3e..1893abd1 100644 --- a/src/image/uikit.rs +++ b/src/image/uikit.rs @@ -5,6 +5,6 @@ use crate::foundation::load_or_register_class; /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_image_view_class() -> *const Class { +pub(crate) fn register_image_view_class() -> &'static Class { load_or_register_class("UIImageView", "RSTImageView", |decl| unsafe {}) } diff --git a/src/input/appkit.rs b/src/input/appkit.rs index 3139c502..7f22d1a6 100644 --- a/src/input/appkit.rs +++ b/src/input/appkit.rs @@ -46,13 +46,13 @@ extern "C" fn text_should_end_editing(this: &Object, _: Se /// Injects an `NSTextField` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { +pub(crate) fn register_view_class() -> &'static Class { load_or_register_class("NSTextField", "RSTTextInputField", |decl| unsafe {}) } /// Injects an `NSTextField` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_view_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("NSTextField", instance.subclass_name(), |decl| unsafe { // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/input/mod.rs b/src/input/mod.rs index 4cdf616b..f42d9ff9 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -78,7 +78,7 @@ pub use traits::TextFieldDelegate; pub(crate) static TEXTFIELD_DELEGATE_PTR: &str = "rstTextFieldDelegatePtr"; /// A helper method for instantiating view classes and applying default settings to them. -fn common_init(class: *const Class) -> id { +fn common_init(class: &Class) -> id { unsafe { let view: id = msg_send![class, new]; diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 63065704..f63e68f9 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -50,22 +50,22 @@ extern "C" fn text_should_end_editing(this: &Object, _: Se /// Injects an `UITextField` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_view_class() -> &'static Class { + static mut VIEW_CLASS: Option<&'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { let superclass = class!(UITextField); let decl = ClassDecl::new("RSTTextInputField", superclass).unwrap(); - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } /// Injects an `UITextField` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_view_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("UITextField", instance.subclass_name(), |decl| unsafe { // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/invoker.rs b/src/invoker.rs index 03f199c1..7b21c989 100644 --- a/src/invoker.rs +++ b/src/invoker.rs @@ -91,7 +91,7 @@ extern "C" fn perform(this: &mut Object, _: Sel, /// The `NSButton` owns this object on instantiation, and will release it /// on drop. We handle the heap copy on the Rust side, so setting the block /// is just an ivar. -pub(crate) fn register_invoker_class() -> *const Class { +pub(crate) fn register_invoker_class() -> &'static Class { load_or_register_class("NSObject", "RSTTargetActionHandler", |decl| unsafe { decl.add_ivar::(ACTION_CALLBACK_PTR); decl.add_method(sel!(perform:), perform:: as extern "C" fn(_, _, _)); diff --git a/src/listview/appkit.rs b/src/listview/appkit.rs index 5a66f388..2277b38a 100644 --- a/src/listview/appkit.rs +++ b/src/listview/appkit.rs @@ -181,7 +181,7 @@ extern "C" fn dragging_exited(this: &mut Object, _: Sel, in /// need to do. Note that we treat and constrain this as a one-column "list" view to match /// `UITableView` semantics; if `NSTableView`'s multi column behavior is needed, then it can /// be added in. -pub(crate) fn register_listview_class() -> *const Class { +pub(crate) fn register_listview_class() -> &'static Class { load_or_register_class("NSTableView", "RSTListView", |decl| unsafe {}) } @@ -189,7 +189,7 @@ pub(crate) fn register_listview_class() -> *const Class { /// need to do. Note that we treat and constrain this as a one-column "list" view to match /// `UITableView` semantics; if `NSTableView`'s multi column behavior is needed, then it can /// be added in. -pub(crate) fn register_listview_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_listview_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("NSTableView", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(LISTVIEW_DELEGATE_PTR); diff --git a/src/listview/mod.rs b/src/listview/mod.rs index 4b924e4e..b3d91e69 100644 --- a/src/listview/mod.rs +++ b/src/listview/mod.rs @@ -100,7 +100,7 @@ use std::cell::RefCell; use std::rc::Rc; /// A helper method for instantiating view classes and applying default settings to them. -fn common_init(class: *const Class) -> id { +fn common_init(class: &Class) -> id { unsafe { // Note: we do *not* enable AutoLayout here as we're by default placing this in a scroll // view, and we want it to just do its thing. diff --git a/src/listview/row/appkit.rs b/src/listview/row/appkit.rs index 253cc899..1c8470eb 100644 --- a/src/listview/row/appkit.rs +++ b/src/listview/row/appkit.rs @@ -103,7 +103,7 @@ extern "C" fn dealloc(this: &Object, _: Sel) { /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_listview_row_class() -> *const Class { +pub(crate) fn register_listview_row_class() -> &'static Class { load_or_register_class("NSView", "RSTTableViewRow", |decl| unsafe { decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); }) @@ -111,7 +111,7 @@ pub(crate) fn register_listview_row_class() -> *const Class { /// Injects an `NSView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_listview_row_class_with_delegate() -> *const Class { +pub(crate) fn register_listview_row_class_with_delegate() -> &'static Class { load_or_register_class("NSView", "RSTableViewRowWithDelegate", |decl| unsafe { // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/listview/row/mod.rs b/src/listview/row/mod.rs index 510a6781..6e8a1ff2 100644 --- a/src/listview/row/mod.rs +++ b/src/listview/row/mod.rs @@ -77,7 +77,7 @@ pub(crate) static BACKGROUND_COLOR: &str = "cacaoBackgroundColor"; pub(crate) static LISTVIEW_ROW_DELEGATE_PTR: &str = "cacaoListViewRowDelegatePtr"; /// A helper method for instantiating view classes and applying default settings to them. -fn allocate_view(registration_fn: fn() -> *const Class) -> id { +fn allocate_view(registration_fn: fn() -> &'static Class) -> id { unsafe { let view: id = msg_send![registration_fn(), new]; diff --git a/src/listview/row/uikit.rs b/src/listview/row/uikit.rs index 349296bf..cffaaa72 100644 --- a/src/listview/row/uikit.rs +++ b/src/listview/row/uikit.rs @@ -11,13 +11,13 @@ use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR}; /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { +pub(crate) fn register_view_class() -> &'static Class { load_or_register_class("UIView", "RSTView", |decl| unsafe {}) } /// Injects an `NSView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate() -> *const Class { +pub(crate) fn register_view_class_with_delegate() -> &'static Class { load_or_register_class("UIView", "RSTViewWithDelegate", |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); }) diff --git a/src/scrollview/appkit.rs b/src/scrollview/appkit.rs index fc1de0ff..9cdb10e6 100644 --- a/src/scrollview/appkit.rs +++ b/src/scrollview/appkit.rs @@ -73,13 +73,13 @@ extern "C" fn dragging_exited(this: &mut Object, _: Sel, } /// Injects an `NSScrollView` subclass. -pub(crate) fn register_scrollview_class() -> *const Class { +pub(crate) fn register_scrollview_class() -> &'static Class { load_or_register_class("NSScrollView", "RSTScrollView", |decl| unsafe {}) } /// Injects an `NSView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_scrollview_class_with_delegate() -> *const Class { +pub(crate) fn register_scrollview_class_with_delegate() -> &'static Class { load_or_register_class("NSScrollView", "RSTScrollViewWithDelegate", |decl| unsafe { // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/scrollview/mod.rs b/src/scrollview/mod.rs index 16ee2dfa..702c1430 100644 --- a/src/scrollview/mod.rs +++ b/src/scrollview/mod.rs @@ -75,7 +75,7 @@ pub use traits::ScrollViewDelegate; pub(crate) static SCROLLVIEW_DELEGATE_PTR: &str = "rstScrollViewDelegatePtr"; /// A helper method for instantiating view classes and applying default settings to them. -fn allocate_view(registration_fn: fn() -> *const Class) -> id { +fn allocate_view(registration_fn: fn() -> &'static Class) -> id { unsafe { let view: id = msg_send![registration_fn(), new]; diff --git a/src/scrollview/uikit.rs b/src/scrollview/uikit.rs index c9ecbf9f..cbe0eccd 100644 --- a/src/scrollview/uikit.rs +++ b/src/scrollview/uikit.rs @@ -78,23 +78,23 @@ extern "C" fn dragging_exited(this: &mut Object, _: Sel, */ /// Injects an `UIScrollView` subclass. -pub(crate) fn register_scrollview_class() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_scrollview_class() -> &'static Class { + static mut VIEW_CLASS: Option<&'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { let superclass = class!(UIScrollView); let decl = ClassDecl::new("RSTScrollView", superclass).unwrap(); - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } /// Injects an `NSView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_scrollview_class_with_delegate() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_scrollview_class_with_delegate() -> &'static Class { + static mut VIEW_CLASS: Option<&'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { @@ -131,8 +131,8 @@ pub(crate) fn register_scrollview_class_with_delegate() - ); */ - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } diff --git a/src/select/mod.rs b/src/select/mod.rs index dd6abeb5..676121d8 100644 --- a/src/select/mod.rs +++ b/src/select/mod.rs @@ -262,6 +262,6 @@ impl Drop for Select { /// Registers an `NSSelect` subclass, and configures it to hold some ivars /// for various things we need to store. -fn register_class() -> *const Class { +fn register_class() -> &'static Class { load_or_register_class("NSPopUpButton", "CacaoSelect", |decl| unsafe {}) } diff --git a/src/switch.rs b/src/switch.rs index 8400da9e..35ef605f 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -172,6 +172,6 @@ impl Drop for Switch { /// Registers an `NSButton` subclass, and configures it to hold some ivars /// for various things we need to store. -fn register_class() -> *const Class { +fn register_class() -> &'static Class { load_or_register_class("NSButton", "RSTSwitch", |decl| unsafe {}) } diff --git a/src/text/label/appkit.rs b/src/text/label/appkit.rs index 4dfc927d..cd6ff886 100644 --- a/src/text/label/appkit.rs +++ b/src/text/label/appkit.rs @@ -15,13 +15,13 @@ use crate::text::label::{LabelDelegate, LABEL_DELEGATE_PTR}; /// Injects an `NSTextField` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { +pub(crate) fn register_view_class() -> &'static Class { load_or_register_class("NSTextField", "RSTTextField", |decl| unsafe {}) } /// Injects an `NSTextField` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate() -> *const Class { +pub(crate) fn register_view_class_with_delegate() -> &'static Class { load_or_register_class("NSView", "RSTTextFieldWithDelegate", |decl| unsafe { // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/text/label/mod.rs b/src/text/label/mod.rs index 417d9085..8063f6c0 100644 --- a/src/text/label/mod.rs +++ b/src/text/label/mod.rs @@ -78,7 +78,7 @@ pub use traits::LabelDelegate; pub(crate) static LABEL_DELEGATE_PTR: &str = "rstLabelDelegatePtr"; /// A helper method for instantiating view classes and applying default settings to them. -fn allocate_view(registration_fn: fn() -> *const Class) -> id { +fn allocate_view(registration_fn: fn() -> &'static Class) -> id { unsafe { #[cfg(feature = "appkit")] let view: id = { diff --git a/src/text/label/uikit.rs b/src/text/label/uikit.rs index cbbd5782..9b1097d3 100644 --- a/src/text/label/uikit.rs +++ b/src/text/label/uikit.rs @@ -11,23 +11,23 @@ use crate::text::label::{LabelDelegate, LABEL_DELEGATE_PTR}; /// Injects an `UILabel` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_view_class() -> &'static Class { + static mut VIEW_CLASS: Option<&'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { let superclass = class!(UILabel); let decl = ClassDecl::new("RSTTextField", superclass).unwrap(); - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } /// Injects an `UILabel` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate() -> *const Class { - static mut VIEW_CLASS: *const Class = 0 as *const Class; +pub(crate) fn register_view_class_with_delegate() -> &'static Class { + static mut VIEW_CLASS: Option<&'static Class> = None; static INIT: Once = Once::new(); INIT.call_once(|| unsafe { @@ -38,8 +38,8 @@ pub(crate) fn register_view_class_with_delegate() -> *const Cl // move. decl.add_ivar::(LABEL_DELEGATE_PTR); - VIEW_CLASS = decl.register(); + VIEW_CLASS = Some(decl.register()); }); - unsafe { VIEW_CLASS } + unsafe { VIEW_CLASS.unwrap() } } diff --git a/src/uikit/app/class.rs b/src/uikit/app/class.rs index c4f13283..16b55307 100644 --- a/src/uikit/app/class.rs +++ b/src/uikit/app/class.rs @@ -7,7 +7,7 @@ use objc::runtime::Class; use crate::foundation::load_or_register_class_with_optional_generated_suffix; /// Used for injecting a custom UIApplication. Currently does nothing. -pub(crate) fn register_app_class() -> *const Class { +pub(crate) fn register_app_class() -> &'static Class { let should_generate_suffix = false; load_or_register_class_with_optional_generated_suffix("UIApplication", "RSTApplication", should_generate_suffix, |decl| {}) diff --git a/src/uikit/app/delegate.rs b/src/uikit/app/delegate.rs index b9ed6a8a..b8524cd6 100644 --- a/src/uikit/app/delegate.rs +++ b/src/uikit/app/delegate.rs @@ -40,7 +40,7 @@ extern "C" fn configuration_for_scene_session(this: &Object, _: /// Registers an `NSObject` application delegate, and configures it for the various callbacks and /// pointers we need to have. -pub(crate) fn register_app_delegate_class() -> *const Class { +pub(crate) fn register_app_delegate_class() -> &'static Class { let should_generate_suffix = false; load_or_register_class_with_optional_generated_suffix("NSObject", "RSTAppDelegate", should_generate_suffix, |decl| unsafe { diff --git a/src/uikit/scene/delegate.rs b/src/uikit/scene/delegate.rs index 2673b7c6..99f8dcbb 100644 --- a/src/uikit/scene/delegate.rs +++ b/src/uikit/scene/delegate.rs @@ -44,7 +44,7 @@ extern "C" fn scene_will_connect_to_session_with_options /// Registers an `NSObject` application delegate, and configures it for the various callbacks and /// pointers we need to have. -pub(crate) fn register_window_scene_delegate_class Box>() -> *const Class { +pub(crate) fn register_window_scene_delegate_class Box>() -> &'static Class { let should_generate_suffix = false; load_or_register_class_with_optional_generated_suffix("UIResponder", "RSTWindowSceneDelegate", false, |decl| unsafe { diff --git a/src/view/appkit.rs b/src/view/appkit.rs index 0aa92eb5..19eae29c 100644 --- a/src/view/appkit.rs +++ b/src/view/appkit.rs @@ -89,7 +89,7 @@ extern "C" fn update_layer(this: &Object, _: Sel) { /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { +pub(crate) fn register_view_class() -> &'static Class { load_or_register_class("NSView", "RSTView", |decl| unsafe { decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); decl.add_method(sel!(updateLayer), update_layer as extern "C" fn(_, _)); @@ -101,7 +101,7 @@ pub(crate) fn register_view_class() -> *const Class { /// Injects an `NSView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_view_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("NSView", instance.subclass_name(), |decl| unsafe { // A pointer to the ViewDelegate instance on the Rust side. // It's expected that this doesn't move. diff --git a/src/view/controller/appkit.rs b/src/view/controller/appkit.rs index fe63aa5f..d209dba8 100644 --- a/src/view/controller/appkit.rs +++ b/src/view/controller/appkit.rs @@ -51,7 +51,7 @@ extern "C" fn did_disappear(this: &Object, _: Sel) { } /// Registers an `NSViewDelegate`. -pub(crate) fn register_view_controller_class(instance: &T) -> *const Class { +pub(crate) fn register_view_controller_class(instance: &T) -> &'static Class { load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); diff --git a/src/view/controller/uikit.rs b/src/view/controller/uikit.rs index f2526f5c..c11341ad 100644 --- a/src/view/controller/uikit.rs +++ b/src/view/controller/uikit.rs @@ -51,7 +51,7 @@ extern "C" fn did_disappear(this: &Object, _: Sel, animated: BO } /// Registers an `NSViewDelegate`. -pub(crate) fn register_view_controller_class(instance: &T) -> *const Class { +pub(crate) fn register_view_controller_class(instance: &T) -> &'static Class { load_or_register_class("UIViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); diff --git a/src/view/splitviewcontroller/ios.rs b/src/view/splitviewcontroller/ios.rs index 5e25766e..96cf3df0 100644 --- a/src/view/splitviewcontroller/ios.rs +++ b/src/view/splitviewcontroller/ios.rs @@ -47,7 +47,7 @@ extern "C" fn did_disappear(this: &mut Object, _: Sel, animated } /// Registers an `NSViewDelegate`. -pub(crate) fn register_view_controller_class() -> *const Class { +pub(crate) fn register_view_controller_class() -> &'static Class { load_or_register_class("UIViewController", "RSTViewController", |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); diff --git a/src/view/splitviewcontroller/macos.rs b/src/view/splitviewcontroller/macos.rs index a31d966b..e5005170 100644 --- a/src/view/splitviewcontroller/macos.rs +++ b/src/view/splitviewcontroller/macos.rs @@ -51,7 +51,7 @@ extern "C" fn did_disappear(this: &mut Object, _: Sel) { } /// Registers an `NSViewDelegate`. -pub(crate) fn register_view_controller_class(instance: &T) -> *const Class { +pub(crate) fn register_view_controller_class(instance: &T) -> &'static Class { load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); diff --git a/src/view/uikit.rs b/src/view/uikit.rs index bbc62a83..82534602 100644 --- a/src/view/uikit.rs +++ b/src/view/uikit.rs @@ -11,13 +11,13 @@ use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR}; /// Injects an `NSView` subclass. This is used for the default views that don't use delegates - we /// have separate classes here since we don't want to waste cycles on methods that will never be /// used if there's no delegates. -pub(crate) fn register_view_class() -> *const Class { +pub(crate) fn register_view_class() -> &'static Class { load_or_register_class("UIView", "RSTView", |decl| unsafe {}) } /// Injects a `UIView` subclass, with some callback and pointer ivars for what we /// need to do. -pub(crate) fn register_view_class_with_delegate(instance: &T) -> *const Class { +pub(crate) fn register_view_class_with_delegate(instance: &T) -> &'static Class { load_or_register_class("UIView", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); }) diff --git a/src/webview/class.rs b/src/webview/class.rs index 1ca540a3..97cbbde8 100644 --- a/src/webview/class.rs +++ b/src/webview/class.rs @@ -179,7 +179,7 @@ extern "C" fn accepts_first_mouse(_: &mut Object, _: Sel, _: id) -> BOOL { /// Registers an `NSViewController` that we effectively turn into a `WebViewController`. Acts as /// both a subclass of `NSViewController` and a delegate of the held `WKWebView` (for the various /// varieties of delegates needed there). -pub fn register_webview_class() -> *const Class { +pub fn register_webview_class() -> &'static Class { load_or_register_class("WKWebView", "CacaoWebView", |decl| unsafe { decl.add_method(sel!(acceptsFirstMouse:), accepts_first_mouse as extern "C" fn(_, _, _) -> _); }) @@ -188,7 +188,7 @@ pub fn register_webview_class() -> *const Class { /// Registers an `NSViewController` that we effectively turn into a `WebViewController`. Acts as /// both a subclass of `NSViewController` and a delegate of the held `WKWebView` (for the various /// varieties of delegates needed there). -pub fn register_webview_delegate_class(instance: &T) -> *const Class { +pub fn register_webview_delegate_class(instance: &T) -> &'static Class { load_or_register_class("NSObject", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(WEBVIEW_DELEGATE_PTR); From c1f01ef2f7d87d616b27815e72f0ecacc72e0591 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 5 Sep 2023 12:42:58 +0200 Subject: [PATCH 11/19] Use msg_send_id! and rc::Id --- ARCHITECTURE.md | 2 +- src/appkit/alert.rs | 16 +++--- src/appkit/app/mod.rs | 21 +++---- src/appkit/event/mod.rs | 20 ++++--- src/appkit/haptics.rs | 11 ++-- src/appkit/menu/item.rs | 37 +++++++----- src/appkit/menu/menu.rs | 14 ++--- src/appkit/printing/settings.rs | 6 +- src/appkit/segmentedcontrol.rs | 6 +- src/appkit/toolbar/item.rs | 13 ++--- src/appkit/toolbar/mod.rs | 22 ++++---- src/appkit/window/controller/mod.rs | 14 ++--- src/appkit/window/mod.rs | 75 ++++++++++++------------- src/button/mod.rs | 6 +- src/cloudkit/share.rs | 6 +- src/color/mod.rs | 37 +++++++----- src/defaults/mod.rs | 12 ++-- src/dragdrop.rs | 4 +- src/filesystem/manager.rs | 14 ++--- src/filesystem/save.rs | 13 ++--- src/filesystem/select.rs | 13 ++--- src/foundation/array.rs | 40 +++++++------ src/foundation/autoreleasepool.rs | 8 +-- src/foundation/data.rs | 31 ++++++---- src/foundation/dictionary.rs | 8 +-- src/foundation/number.rs | 19 ++++--- src/foundation/string.rs | 37 ++++++------ src/foundation/urls/mod.rs | 12 ++-- src/image/handle.rs | 6 +- src/image/image.rs | 54 +++++++++--------- src/image/mod.rs | 2 +- src/input/appkit.rs | 1 + src/input/mod.rs | 2 +- src/input/uikit.rs | 1 - src/invoker.rs | 22 ++++---- src/layout/animator.rs | 8 +-- src/layout/constraint.rs | 9 ++- src/layout/dimension.rs | 16 +++--- src/layout/horizontal.rs | 26 ++++----- src/layout/traits.rs | 2 +- src/layout/vertical.rs | 18 +++--- src/lib.rs | 59 ------------------- src/listview/actions.rs | 13 +++-- src/listview/appkit.rs | 12 ++-- src/listview/mod.rs | 41 +++++++------- src/listview/row/appkit.rs | 12 ++-- src/listview/row/mod.rs | 2 +- src/listview/row/uikit.rs | 2 +- src/networking/mod.rs | 8 +-- src/notification_center/mod.rs | 10 ++-- src/pasteboard/mod.rs | 14 ++--- src/progress/mod.rs | 2 +- src/quicklook/config.rs | 2 +- src/quicklook/mod.rs | 8 +-- src/scrollview/appkit.rs | 12 ++-- src/scrollview/mod.rs | 2 +- src/scrollview/uikit.rs | 1 - src/select/mod.rs | 6 +- src/switch.rs | 6 +- src/text/attributed_string.rs | 12 ++-- src/text/font.rs | 18 +++--- src/text/label/mod.rs | 2 +- src/text/label/uikit.rs | 1 - src/uikit/scene/config.rs | 14 ++--- src/uikit/scene/mod.rs | 6 +- src/uikit/scene/options.rs | 6 +- src/uikit/scene/session.rs | 6 +- src/uikit/window/mod.rs | 10 ++-- src/user_activity.rs | 6 +- src/user_notifications/notifications.rs | 14 ++--- src/utils/mod.rs | 4 +- src/utils/properties.rs | 8 +-- src/view/animator.rs | 8 +-- src/view/appkit.rs | 12 ++-- src/view/controller/mod.rs | 16 +++--- src/view/popover/mod.rs | 18 +++--- src/view/splitviewcontroller/mod.rs | 30 +++++----- src/view/uikit.rs | 2 +- src/webview/config.rs | 11 ++-- src/webview/mod.rs | 12 ++-- 80 files changed, 539 insertions(+), 573 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 71c87851..927f4f9f 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -412,7 +412,7 @@ Here, we just want to tell `NSView` to use top,left as the origin point, so we n extern "C" fn dragging_entered(this: &mut Object, _: Sel, info: id) -> NSUInteger { let view = utils::load::(this, VIEW_DELEGATE_PTR); view.dragging_entered(DragInfo { - info: unsafe { Id::from_ptr(info) } + info: unsafe { Id::retain(info).unwrap() } }).into() } ``` diff --git a/src/appkit/alert.rs b/src/appkit/alert.rs index 25c48e8f..bcfa9740 100644 --- a/src/appkit/alert.rs +++ b/src/appkit/alert.rs @@ -24,16 +24,16 @@ //! } //! ``` -use crate::id_shim::Id; +use objc::rc::{Id, Owned}; use objc::runtime::Object; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::foundation::{id, NSString}; /// Represents an `NSAlert`. Has no information other than the retained pointer to the Objective C /// side, so... don't bother inspecting this. #[derive(Debug)] -pub struct Alert(Id); +pub struct Alert(Id); impl Alert { /// Creates a basic `NSAlert`, storing a pointer to it in the Objective C runtime. @@ -44,11 +44,11 @@ impl Alert { let ok = NSString::new("OK"); Alert(unsafe { - let alert: id = msg_send![class!(NSAlert), new]; - let _: () = msg_send![alert, setMessageText: &*title]; - let _: () = msg_send![alert, setInformativeText: &*message]; - let _: () = msg_send![alert, addButtonWithTitle: &*ok]; - Id::from_ptr(alert) + let mut alert = msg_send_id![class!(NSAlert), new].unwrap(); + let _: () = msg_send![&mut alert, setMessageText: &*title]; + let _: () = msg_send![&mut alert, setInformativeText: &*message]; + let _: () = msg_send![&mut alert, addButtonWithTitle: &*ok]; + alert }) } diff --git a/src/appkit/app/mod.rs b/src/appkit/app/mod.rs index e67066f0..10ccdd05 100644 --- a/src/appkit/app/mod.rs +++ b/src/appkit/app/mod.rs @@ -39,9 +39,9 @@ use std::sync::{Arc, Mutex}; use lazy_static::lazy_static; -use crate::id_shim::Id; +use objc::rc::{Id, Owned}; use objc::runtime::Object; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::appkit::menu::Menu; use crate::foundation::{id, nil, AutoReleasePool, NSUInteger, NO, YES}; @@ -88,11 +88,11 @@ pub(crate) fn shared_application T>(handler: F) -> T { /// application. pub struct App { /// The underlying Objective-C Object. - pub objc: Id, + pub objc: Id, /// The underlying Objective-C Object, which in this case is a delegate that forwards to the /// app delegate. - pub objc_delegate: Id, + pub objc_delegate: Id, /// The stored `AppDelegate`. pub delegate: Box, @@ -144,20 +144,17 @@ where let pool = AutoReleasePool::new(); - let objc = unsafe { - let app: id = msg_send![register_app_class(), sharedApplication]; - Id::from_ptr(app) - }; + let objc = unsafe { msg_send_id![register_app_class(), sharedApplication].unwrap() }; let app_delegate = Box::new(delegate); let objc_delegate = unsafe { let delegate_class = register_app_delegate_class::(); - let delegate: id = msg_send![delegate_class, new]; + let mut delegate: Id = msg_send_id![delegate_class, new].unwrap(); let delegate_ptr: *const T = &*app_delegate; - (&mut *delegate).set_ivar(APP_PTR, delegate_ptr as usize); - let _: () = msg_send![&*objc, setDelegate: delegate]; - Id::from_ptr(delegate) + delegate.set_ivar(APP_PTR, delegate_ptr as usize); + let _: () = msg_send![&*objc, setDelegate: &*delegate]; + delegate }; App { diff --git a/src/appkit/event/mod.rs b/src/appkit/event/mod.rs index 966785f2..1a92d062 100644 --- a/src/appkit/event/mod.rs +++ b/src/appkit/event/mod.rs @@ -1,9 +1,9 @@ use bitmask_enum::bitmask; use block::ConcreteBlock; -use crate::id_shim::Id; +use objc::rc::{Id, Owned}; use objc::runtime::Object; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::events::EventType; use crate::foundation::{id, nil, NSInteger, NSPoint, NSString}; @@ -53,15 +53,15 @@ pub enum EventMask { /// A wrapper over an `NSEvent`. #[derive(Debug)] -pub struct EventMonitor(pub Id); +pub struct EventMonitor(pub Id); /// A wrapper over an `NSEvent`. #[derive(Debug)] -pub struct Event(pub Id); +pub struct Event(pub Id); impl Event { pub(crate) fn new(objc: id) -> Self { - Event(unsafe { Id::from_ptr(objc) }) + Event(unsafe { Id::retain(objc).unwrap() }) } /// The event's type. @@ -137,11 +137,12 @@ impl Event { let block = block.copy(); EventMonitor(unsafe { - Id::from_ptr(msg_send![ + msg_send_id![ class!(NSEvent), addLocalMonitorForEventsMatchingMask: mask.bits, handler: &*block, - ]) + ] + .unwrap() }) } @@ -166,11 +167,12 @@ impl Event { let block = block.copy(); EventMonitor(unsafe { - Id::from_ptr(msg_send![ + msg_send_id![ class!(NSEvent), addGlobalMonitorForEventsMatchingMask: mask.bits, handler: &*block, - ]) + ] + .unwrap() }) } } diff --git a/src/appkit/haptics.rs b/src/appkit/haptics.rs index a7185a9e..ca582d13 100644 --- a/src/appkit/haptics.rs +++ b/src/appkit/haptics.rs @@ -1,12 +1,12 @@ use std::convert::TryFrom; -use crate::id_shim::ShareId; -use objc::{class, msg_send, runtime::Object, sel}; +use objc::rc::{Id, Shared}; +use objc::{class, msg_send, msg_send_id, runtime::Object, sel}; use crate::foundation::NSUInteger; #[derive(Clone, Debug)] -pub struct HapticFeedbackPerformer(pub ShareId); +pub struct HapticFeedbackPerformer(pub Id); impl HapticFeedbackPerformer { pub fn perform(&self, pattern: FeedbackPattern, performance_time: PerformanceTime) { @@ -19,10 +19,7 @@ impl HapticFeedbackPerformer { impl Default for HapticFeedbackPerformer { /// Returns the default haptic feedback performer. fn default() -> Self { - HapticFeedbackPerformer(unsafe { - let manager = msg_send![class!(NSHapticFeedbackManager), defaultPerformer]; - ShareId::from_ptr(manager) - }) + HapticFeedbackPerformer(unsafe { msg_send_id![class!(NSHapticFeedbackManager), defaultPerformer].unwrap() }) } } diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index e591e474..84d15a08 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -4,9 +4,9 @@ use std::fmt; -use crate::id_shim::Id; +use objc::rc::{Id, Owned}; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::events::EventModifierFlag; use crate::foundation::{id, load_or_register_class, NSString, NSUInteger}; @@ -37,7 +37,7 @@ fn make_menu_item>( key: Option<&str>, action: Option, modifiers: Option<&[EventModifierFlag]> -) -> Id { +) -> Id { unsafe { let title = NSString::new(title.as_ref()); @@ -50,14 +50,22 @@ fn make_menu_item>( // Stock menu items that use selectors targeted at system pieces are just standard // `NSMenuItem`s. If there's no custom ones, we use our subclass that has a slot to store a // handler pointer. - let alloc: id = msg_send![register_menu_item_class(), alloc]; - let item = Id::from_retained_ptr(match action { - Some(a) => msg_send![alloc, initWithTitle:&*title action:a keyEquivalent:&*key], - - None => msg_send![alloc, initWithTitle:&*title - action:sel!(fireBlockAction:) - keyEquivalent:&*key] - }); + let alloc = msg_send_id![register_menu_item_class(), alloc]; + let item = match action { + Some(a) => msg_send_id![ + alloc, + initWithTitle: &*title, + action: a, + keyEquivalent: &*key, + ], + None => msg_send_id![ + alloc, + initWithTitle: &*title, + action: sel!(fireBlockAction:), + keyEquivalent: &*key, + ] + } + .unwrap(); if let Some(modifiers) = modifiers { let mut key_mask: NSUInteger = 0; @@ -83,7 +91,7 @@ pub enum MenuItem { /// You can (and should) create this variant via the `new(title)` method, but if you need to do /// something crazier, then wrap it in this and you can hook into the Cacao menu system /// accordingly. - Custom(Id), + Custom(Id), /// Shows a standard "About" item, which will bring up the necessary window when clicked /// (include a `credits.html` in your App to make use of here). The argument baked in here @@ -150,7 +158,7 @@ pub enum MenuItem { impl MenuItem { /// Consumes and returns a handle for the underlying MenuItem. This is internal as we make a few assumptions /// for how it interacts with our `Menu` setup, but this could be made public in the future. - pub(crate) unsafe fn to_objc(self) -> Id { + pub(crate) unsafe fn to_objc(self) -> Id { match self { Self::Custom(objc) => objc, @@ -211,8 +219,7 @@ impl MenuItem { Self::Separator => { let cls = class!(NSMenuItem); - let separator: id = msg_send![cls, separatorItem]; - Id::from_ptr(separator) + msg_send_id![cls, separatorItem].unwrap() } } } diff --git a/src/appkit/menu/menu.rs b/src/appkit/menu/menu.rs index 00106f4d..30f7691d 100644 --- a/src/appkit/menu/menu.rs +++ b/src/appkit/menu/menu.rs @@ -2,9 +2,9 @@ use std::sync::{Arc, Mutex}; -use crate::id_shim::{Id, ShareId}; +use objc::rc::{Id, Owned, Shared}; use objc::runtime::Object; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::appkit::menu::item::MenuItem; use crate::foundation::{id, NSInteger, NSString}; @@ -12,7 +12,7 @@ use crate::foundation::{id, NSInteger, NSString}; /// A struct that represents an `NSMenu`. It takes ownership of items, and handles instrumenting /// them throughout the application lifecycle. #[derive(Debug)] -pub struct Menu(pub Id); +pub struct Menu(pub Id); impl Menu { /// Creates a new `Menu` with the given title, and uses the passed items as submenu items. @@ -27,16 +27,16 @@ impl Menu { pub fn new(title: &str, items: Vec) -> Self { Menu(unsafe { let cls = class!(NSMenu); - let alloc: id = msg_send![cls, alloc]; + let alloc = msg_send_id![cls, alloc]; let title = NSString::new(title); - let menu: id = msg_send![alloc, initWithTitle:&*title]; + let mut menu = msg_send_id![alloc, initWithTitle: &*title].unwrap(); for item in items.into_iter() { let objc = item.to_objc(); - let _: () = msg_send![menu, addItem:&*objc]; + let _: () = msg_send![&mut menu, addItem:&*objc]; } - Id::from_retained_ptr(menu) + menu }) } diff --git a/src/appkit/printing/settings.rs b/src/appkit/printing/settings.rs index 40df0841..b13281bb 100644 --- a/src/appkit/printing/settings.rs +++ b/src/appkit/printing/settings.rs @@ -1,7 +1,7 @@ //! Represents settings for printing items. Backed by an `NSDictionary` in Objective-C, this struct //! aims to make it easier to query/process printing operations. -use crate::id_shim::ShareId; +use objc::rc::{Id, Shared}; use objc::runtime::Object; use crate::foundation::id; @@ -10,14 +10,14 @@ use crate::foundation::id; /// application/user. #[derive(Clone, Debug)] pub struct PrintSettings { - pub inner: ShareId + pub inner: Id } impl PrintSettings { /// Internal method, constructs a wrapper around the backing `NSDictionary` print settings. pub(crate) fn with_inner(inner: id) -> Self { PrintSettings { - inner: unsafe { ShareId::from_ptr(inner) } + inner: unsafe { Id::retain(inner).unwrap() } } } } diff --git a/src/appkit/segmentedcontrol.rs b/src/appkit/segmentedcontrol.rs index dfd2e155..26747b2a 100644 --- a/src/appkit/segmentedcontrol.rs +++ b/src/appkit/segmentedcontrol.rs @@ -6,10 +6,10 @@ use std::sync::Once; use std::cell::RefCell; use std::rc::Rc; -use crate::id_shim::ShareId; use objc::declare::ClassDecl; +use objc::rc::{Id, Shared}; use objc::runtime::{Class, Object, Sel}; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::color::Color; use crate::control::Control; @@ -193,7 +193,7 @@ impl SegmentedControl { /// best just to message pass or something. pub fn set_action(&mut self, action: F) { // @TODO: This probably isn't ideal but gets the job done for now; needs revisiting. - let this = self.objc.get(|obj| unsafe { ShareId::from_ptr(msg_send![obj, self]) }); + let this: Id<_, Shared> = self.objc.get(|obj| unsafe { msg_send_id![obj, self] }).unwrap(); let handler = TargetActionHandler::new(&*this, move |obj: *const Object| unsafe { let selected: i32 = msg_send![obj, selectedSegment]; action(selected) diff --git a/src/appkit/toolbar/item.rs b/src/appkit/toolbar/item.rs index 649b873c..295e92fd 100644 --- a/src/appkit/toolbar/item.rs +++ b/src/appkit/toolbar/item.rs @@ -6,9 +6,9 @@ use core_graphics::geometry::CGSize; use std::fmt; -use crate::id_shim::{Id, ShareId}; +use objc::rc::{Id, Owned, Shared}; use objc::runtime::Object; -use objc::{class, msg_send, sel}; +use objc::{class, msg_send, msg_send_id, sel}; use crate::appkit::segmentedcontrol::SegmentedControl; use crate::button::{BezelStyle, Button}; @@ -20,7 +20,7 @@ use crate::invoker::TargetActionHandler; #[derive(Debug)] pub struct ToolbarItem { pub identifier: String, - pub objc: Id, + pub objc: Id, pub button: Option