Skip to content

Commit

Permalink
Use renamed ClassDecl (now ClassBuilder)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 12, 2023
1 parent d071b68 commit fb3b2d2
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 36 deletions.
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(_, _) -> _);

Expand Down
4 changes: 2 additions & 2 deletions src/appkit/segmentedcontrol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
});

Expand Down
1 change: 0 additions & 1 deletion src/appkit/toolbar/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion src/appkit/window/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
8 changes: 4 additions & 4 deletions src/foundation/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -132,7 +132,7 @@ impl ClassMap {
#[inline(always)]
pub fn load_or_register_class<F>(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)
}
Expand All @@ -158,7 +158,7 @@ pub fn load_or_register_class_with_optional_generated_suffix<F>(
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;
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/input/uikit.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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());
});

Expand Down
3 changes: 1 addition & 2 deletions src/listview/row/uikit.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
6 changes: 3 additions & 3 deletions src/scrollview/uikit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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());
});

Expand All @@ -92,7 +92,7 @@ pub(crate) fn register_scrollview_class_with_delegate<T: ScrollViewDelegate>() -

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.
Expand Down
6 changes: 3 additions & 3 deletions src/text/label/uikit.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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());
});

Expand All @@ -31,7 +31,7 @@ pub(crate) fn register_view_class_with_delegate<T: LabelDelegate>() -> &'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.
Expand Down
1 change: 0 additions & 1 deletion src/view/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion src/view/controller/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::sync::Once;

use objc::declare::ClassDecl;
use objc::runtime::{Class, Object, Sel};
use objc::{class, msg_send, sel};

Expand Down
1 change: 0 additions & 1 deletion src/view/controller/uikit.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
11 changes: 2 additions & 9 deletions src/view/splitviewcontroller/ios.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use objc::declare::ClassDecl;
use objc::runtime::{Bool, Class, Object, Sel};
use objc::{class, msg_send, sel};

Expand Down Expand Up @@ -52,13 +51,7 @@ pub(crate) fn register_view_controller_class<T: ViewDelegate + 'static>() -> &'s

decl.add_method(sel!(viewWillAppear:), will_appear::<T> as extern "C" fn(_, _, _));
decl.add_method(sel!(viewDidAppear:), did_appear::<T> as extern "C" fn(_, _, _));
decl.add_method(
sel!(viewWillDisappear:),
will_disappear::<T> as extern "C" fn(_, _, _)
);
decl.add_method(
sel!(viewDidDisappear:),
did_disappear::<T> as extern "C" fn(_, _, _)
);
decl.add_method(sel!(viewWillDisappear:), will_disappear::<T> as extern "C" fn(_, _, _));
decl.add_method(sel!(viewDidDisappear:), did_disappear::<T> as extern "C" fn(_, _, _));
})
}
3 changes: 1 addition & 2 deletions src/view/splitviewcontroller/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: ViewDelegate>(this: &mut Object, _: Sel) {
Expand Down
1 change: 0 additions & 1 deletion src/view/uikit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use objc::declare::ClassDecl;
use objc::rc::{Id, Owned};
use objc::runtime::{Class, Object, Sel};
use objc::{class, sel};
Expand Down
1 change: 0 additions & 1 deletion src/webview/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
1 change: 0 additions & 1 deletion src/webview/process_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down

0 comments on commit fb3b2d2

Please sign in to comment.