From fb3b2d20ea4eaa07750ea43ff39681df39aa5809 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 12 Sep 2023 02:06:36 +0200 Subject: [PATCH] Use renamed `ClassDecl` (now `ClassBuilder`) --- ARCHITECTURE.md | 2 +- src/appkit/segmentedcontrol.rs | 4 ++-- src/appkit/toolbar/class.rs | 1 - src/appkit/window/class.rs | 1 - src/foundation/class.rs | 8 ++++---- src/input/uikit.rs | 4 ++-- src/listview/row/uikit.rs | 3 +-- src/scrollview/uikit.rs | 6 +++--- src/text/label/uikit.rs | 6 +++--- src/view/appkit.rs | 1 - src/view/controller/appkit.rs | 1 - src/view/controller/uikit.rs | 1 - src/view/splitviewcontroller/ios.rs | 11 ++--------- src/view/splitviewcontroller/macos.rs | 3 +-- src/view/uikit.rs | 1 - src/webview/class.rs | 1 - src/webview/process_pool.rs | 1 - 17 files changed, 19 insertions(+), 36 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index e68bc142..6ac62756 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -360,7 +360,7 @@ pub(crate) fn register_view_class() -> &'static Class { INIT.call_once(|| unsafe { let superclass = class!(NSView); - let mut decl = ClassDecl::new("RSTView", superclass).unwrap(); + let mut decl = ClassBuilder::new("RSTView", superclass).unwrap(); decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(_, _) -> _); diff --git a/src/appkit/segmentedcontrol.rs b/src/appkit/segmentedcontrol.rs index c729a80e..40882eaa 100644 --- a/src/appkit/segmentedcontrol.rs +++ b/src/appkit/segmentedcontrol.rs @@ -6,7 +6,7 @@ use std::sync::Once; use std::cell::RefCell; use std::rc::Rc; -use objc::declare::ClassDecl; +use objc::declare::ClassBuilder; use objc::rc::{Id, Shared}; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, msg_send_id, sel}; @@ -332,7 +332,7 @@ fn register_class() -> *const Class { INIT.call_once(|| unsafe { let superclass = class!(NSSegmentedControl); - let decl = ClassDecl::new("RSTSegmentedControl", superclass).unwrap(); + let decl = ClassBuilder::new("RSTSegmentedControl", superclass).unwrap(); VIEW_CLASS = decl.register(); }); diff --git a/src/appkit/toolbar/class.rs b/src/appkit/toolbar/class.rs index 60ff60da..aab6eeb7 100644 --- a/src/appkit/toolbar/class.rs +++ b/src/appkit/toolbar/class.rs @@ -2,7 +2,6 @@ use std::sync::Once; -use objc::declare::ClassDecl; use objc::rc::Id; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, sel}; diff --git a/src/appkit/window/class.rs b/src/appkit/window/class.rs index b51944a1..950ea8bf 100644 --- a/src/appkit/window/class.rs +++ b/src/appkit/window/class.rs @@ -3,7 +3,6 @@ use std::sync::Once; -use objc::declare::ClassDecl; use objc::foundation::{CGFloat, NSSize}; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, sel}; diff --git a/src/foundation/class.rs b/src/foundation/class.rs index 820f602e..18c0a0c3 100644 --- a/src/foundation/class.rs +++ b/src/foundation/class.rs @@ -8,7 +8,7 @@ use std::thread; use std::time::Instant; use lazy_static::lazy_static; -use objc::declare::ClassDecl; +use objc::declare::ClassBuilder; use objc::ffi; use objc::runtime::Class; @@ -132,7 +132,7 @@ impl ClassMap { #[inline(always)] pub fn load_or_register_class(superclass_name: &'static str, subclass_name: &'static str, config: F) -> &'static Class where - F: Fn(&mut ClassDecl) + 'static + F: Fn(&mut ClassBuilder) + 'static { load_or_register_class_with_optional_generated_suffix(superclass_name, subclass_name, true, config) } @@ -158,7 +158,7 @@ pub fn load_or_register_class_with_optional_generated_suffix( config: F ) -> &'static Class where - F: Fn(&mut ClassDecl) + 'static + F: Fn(&mut ClassBuilder) + 'static { if let Some(subclass) = CLASSES.load(subclass_name, Some(superclass_name)) { return subclass; @@ -189,7 +189,7 @@ where false => format!("{}_{}", subclass_name, superclass_name) }; - match ClassDecl::new(&objc_subclass_name, superclass) { + match ClassBuilder::new(&objc_subclass_name, superclass) { Some(mut decl) => { config(&mut decl); diff --git a/src/input/uikit.rs b/src/input/uikit.rs index 4f5e0b4b..858856ae 100644 --- a/src/input/uikit.rs +++ b/src/input/uikit.rs @@ -1,6 +1,6 @@ use std::sync::Once; -use objc::declare::ClassDecl; +use objc::declare::ClassBuilder; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, sel}; @@ -49,7 +49,7 @@ pub(crate) fn register_view_class() -> &'static Class { INIT.call_once(|| unsafe { let superclass = class!(UITextField); - let decl = ClassDecl::new("RSTTextInputField", superclass).unwrap(); + let decl = ClassBuilder::new("RSTTextInputField", superclass).unwrap(); VIEW_CLASS = Some(decl.register()); }); diff --git a/src/listview/row/uikit.rs b/src/listview/row/uikit.rs index 276f8960..ca58cc02 100644 --- a/src/listview/row/uikit.rs +++ b/src/listview/row/uikit.rs @@ -1,7 +1,6 @@ -use objc::declare::ClassDecl; +use objc::rc::{Id, Owned}; use objc::runtime::{Class, Object, Sel}; use objc::{class, sel}; -use objc::rc::{Id, Owned}; use crate::dragdrop::DragInfo; use crate::foundation::{id, NSUInteger}; diff --git a/src/scrollview/uikit.rs b/src/scrollview/uikit.rs index 9f3bb849..88dbd2fa 100644 --- a/src/scrollview/uikit.rs +++ b/src/scrollview/uikit.rs @@ -9,7 +9,7 @@ use std::sync::Once; -use objc::declare::ClassDecl; +use objc::declare::ClassBuilder; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, sel}; @@ -77,7 +77,7 @@ pub(crate) fn register_scrollview_class() -> &'static Class { INIT.call_once(|| unsafe { let superclass = class!(UIScrollView); - let decl = ClassDecl::new("RSTScrollView", superclass).unwrap(); + let decl = ClassBuilder::new("RSTScrollView", superclass).unwrap(); VIEW_CLASS = Some(decl.register()); }); @@ -92,7 +92,7 @@ pub(crate) fn register_scrollview_class_with_delegate() - INIT.call_once(|| unsafe { let superclass = class!(UIScrollView); - let mut decl = ClassDecl::new("RSTScrollViewWithDelegate", superclass).unwrap(); + let mut decl = ClassBuilder::new("RSTScrollViewWithDelegate", superclass).unwrap(); // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/text/label/uikit.rs b/src/text/label/uikit.rs index f194dda6..39a674fd 100644 --- a/src/text/label/uikit.rs +++ b/src/text/label/uikit.rs @@ -1,6 +1,6 @@ use std::sync::Once; -use objc::declare::ClassDecl; +use objc::declare::ClassBuilder; use objc::runtime::{Class, Object, Sel}; use objc::{class, sel}; @@ -16,7 +16,7 @@ pub(crate) fn register_view_class() -> &'static Class { INIT.call_once(|| unsafe { let superclass = class!(UILabel); - let decl = ClassDecl::new("RSTTextField", superclass).unwrap(); + let decl = ClassBuilder::new("RSTTextField", superclass).unwrap(); VIEW_CLASS = Some(decl.register()); }); @@ -31,7 +31,7 @@ pub(crate) fn register_view_class_with_delegate() -> &'static INIT.call_once(|| unsafe { let superclass = class!(UIView); - let mut decl = ClassDecl::new("RSTTextFieldWithDelegate", superclass).unwrap(); + let mut decl = ClassBuilder::new("RSTTextFieldWithDelegate", superclass).unwrap(); // A pointer to the "view controller" on the Rust side. It's expected that this doesn't // move. diff --git a/src/view/appkit.rs b/src/view/appkit.rs index 294aa324..d41440cc 100644 --- a/src/view/appkit.rs +++ b/src/view/appkit.rs @@ -7,7 +7,6 @@ //! 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 objc::declare::ClassDecl; use objc::rc::{Id, Owned}; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, sel}; diff --git a/src/view/controller/appkit.rs b/src/view/controller/appkit.rs index d209dba8..a2a5e76c 100644 --- a/src/view/controller/appkit.rs +++ b/src/view/controller/appkit.rs @@ -2,7 +2,6 @@ use std::sync::Once; -use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; use objc::{class, msg_send, sel}; diff --git a/src/view/controller/uikit.rs b/src/view/controller/uikit.rs index c5737773..5dbf4bf9 100644 --- a/src/view/controller/uikit.rs +++ b/src/view/controller/uikit.rs @@ -1,7 +1,6 @@ use std::sync::Once; use std::unreachable; -use objc::declare::ClassDecl; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, sel}; diff --git a/src/view/splitviewcontroller/ios.rs b/src/view/splitviewcontroller/ios.rs index 744f3fdf..c65e5fef 100644 --- a/src/view/splitviewcontroller/ios.rs +++ b/src/view/splitviewcontroller/ios.rs @@ -1,4 +1,3 @@ -use objc::declare::ClassDecl; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, sel}; @@ -52,13 +51,7 @@ pub(crate) fn register_view_controller_class() -> &'s 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(_, _, _) - ); + 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/macos.rs b/src/view/splitviewcontroller/macos.rs index e5005170..dcc33429 100644 --- a/src/view/splitviewcontroller/macos.rs +++ b/src/view/splitviewcontroller/macos.rs @@ -2,13 +2,12 @@ use std::sync::Once; -use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; use objc::{class, msg_send, sel}; use crate::foundation::load_or_register_class; -use crate::view::{VIEW_DELEGATE_PTR, ViewDelegate}; 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) { diff --git a/src/view/uikit.rs b/src/view/uikit.rs index b944dcb0..a4840568 100644 --- a/src/view/uikit.rs +++ b/src/view/uikit.rs @@ -1,4 +1,3 @@ -use objc::declare::ClassDecl; use objc::rc::{Id, Owned}; use objc::runtime::{Class, Object, Sel}; use objc::{class, sel}; diff --git a/src/webview/class.rs b/src/webview/class.rs index f5ada8cc..a50a9af9 100644 --- a/src/webview/class.rs +++ b/src/webview/class.rs @@ -8,7 +8,6 @@ use std::sync::Once; use block::Block; -use objc::declare::ClassDecl; use objc::runtime::{Bool, Class, Object, Sel}; use objc::{class, msg_send, msg_send_id, sel}; diff --git a/src/webview/process_pool.rs b/src/webview/process_pool.rs index cecc27d2..622b9b32 100644 --- a/src/webview/process_pool.rs +++ b/src/webview/process_pool.rs @@ -6,7 +6,6 @@ use block::Block; use cocoa::foundation::{NSArray, NSInteger, NSPoint, NSRect, NSSize, NSString}; -use objc::declare::ClassDecl; use objc::runtime::{Class, Object, Sel}; use objc::{class, msg_send, sel};