From c71be858babc94837e92d795b7aa74338e7ec4d0 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Aug 2023 02:51:35 +0200 Subject: [PATCH] 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]; }