Skip to content

Commit c71be85

Browse files
committed
Use immutable reference in a few places where now necessary
See madsmtm/objc2#150 for a bit of background
1 parent e77801c commit c71be85

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/input/appkit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR};
66
use crate::utils::load;
77

88
/// Called when editing this text field has ended (e.g. user pressed enter).
9-
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
9+
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
1010
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
1111
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
1212
view.text_did_end_editing(s.to_str());
1313
}
1414

15-
extern "C" fn text_did_begin_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
15+
extern "C" fn text_did_begin_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
1616
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
1717
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
1818
view.text_did_begin_editing(s.to_str());
1919
}
2020

21-
extern "C" fn text_did_change<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
21+
extern "C" fn text_did_change<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
2222
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
2323
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
2424
view.text_did_change(s.to_str());
2525
}
2626

27-
extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) -> BOOL {
27+
extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) -> BOOL {
2828
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
2929
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
3030

@@ -34,7 +34,7 @@ extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object,
3434
}
3535
}
3636

37-
extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) -> BOOL {
37+
extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) -> BOOL {
3838
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
3939
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
4040
match view.text_should_end_editing(s.to_str()) {

src/input/uikit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ use crate::input::{TextFieldDelegate, TEXTFIELD_DELEGATE_PTR};
1010
use crate::utils::load;
1111

1212
/// Called when editing this text field has ended (e.g. user pressed enter).
13-
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
13+
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
1414
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
1515
let s = NSString::retain(unsafe { msg_send![this, text] });
1616
view.text_did_end_editing(s.to_str());
1717
}
1818

19-
extern "C" fn text_did_begin_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
19+
extern "C" fn text_did_begin_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
2020
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
2121
let s = NSString::retain(unsafe { msg_send![this, text] });
2222
view.text_did_begin_editing(s.to_str());
2323
}
2424

25-
extern "C" fn text_did_change<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
25+
extern "C" fn text_did_change<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) {
2626
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
2727
let s = NSString::retain(unsafe { msg_send![this, text] });
2828
view.text_did_change(s.to_str());
2929
}
3030

31-
extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) -> BOOL {
31+
extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) -> BOOL {
3232
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
3333
let s = NSString::retain(unsafe { msg_send![this, text] });
3434

@@ -38,7 +38,7 @@ extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object,
3838
}
3939
}
4040

41-
extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) -> BOOL {
41+
extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &Object, _: Sel, _info: id) -> BOOL {
4242
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
4343
let s = NSString::retain(unsafe { msg_send![this, text] });
4444
match view.text_should_end_editing(s.to_str()) {

src/view/controller/appkit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::utils::load;
1111
use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR};
1212

1313
/// Called when the view controller receives a `viewWillAppear` message.
14-
extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
14+
extern "C" fn will_appear<T: ViewDelegate>(this: &Object, _: Sel) {
1515
unsafe {
1616
let _: () = msg_send![super(this, class!(NSViewController)), viewWillAppear];
1717
}
@@ -21,7 +21,7 @@ extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
2121
}
2222

2323
/// Called when the view controller receives a `viewDidAppear` message.
24-
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
24+
extern "C" fn did_appear<T: ViewDelegate>(this: &Object, _: Sel) {
2525
unsafe {
2626
let _: () = msg_send![super(this, class!(NSViewController)), viewDidAppear];
2727
}
@@ -31,7 +31,7 @@ extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
3131
}
3232

3333
/// Called when the view controller receives a `viewWillDisappear` message.
34-
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
34+
extern "C" fn will_disappear<T: ViewDelegate>(this: &Object, _: Sel) {
3535
unsafe {
3636
let _: () = msg_send![super(this, class!(NSViewController)), viewWillDisappear];
3737
}
@@ -41,7 +41,7 @@ extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
4141
}
4242

4343
/// Called when the view controller receives a `viewDidDisappear` message.
44-
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
44+
extern "C" fn did_disappear<T: ViewDelegate>(this: &Object, _: Sel) {
4545
unsafe {
4646
let _: () = msg_send![super(this, class!(NSViewController)), viewDidDisappear];
4747
}

src/view/controller/uikit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::utils::load;
1111
use crate::view::{ViewDelegate, VIEW_DELEGATE_PTR};
1212

1313
/// Called when the view controller receives a `viewWillAppear:` message.
14-
extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
14+
extern "C" fn will_appear<T: ViewDelegate>(this: &Object, _: Sel, animated: BOOL) {
1515
unsafe {
1616
let _: () = msg_send![super(this, class!(UIViewController)), viewWillAppear: animated];
1717
}
@@ -21,7 +21,7 @@ extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated:
2121
}
2222

2323
/// Called when the view controller receives a `viewDidAppear:` message.
24-
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
24+
extern "C" fn did_appear<T: ViewDelegate>(this: &Object, _: Sel, animated: BOOL) {
2525
unsafe {
2626
let _: () = msg_send![super(this, class!(UIViewController)), viewDidAppear: animated];
2727
}
@@ -31,7 +31,7 @@ extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: B
3131
}
3232

3333
/// Called when the view controller receives a `viewWillDisappear:` message.
34-
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
34+
extern "C" fn will_disappear<T: ViewDelegate>(this: &Object, _: Sel, animated: BOOL) {
3535
unsafe {
3636
let _: () = msg_send![super(this, class!(UIViewController)), viewWillDisappear: animated];
3737
}
@@ -41,7 +41,7 @@ extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animate
4141
}
4242

4343
/// Called when the view controller receives a `viewDidDisappear:` message.
44-
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
44+
extern "C" fn did_disappear<T: ViewDelegate>(this: &Object, _: Sel, animated: BOOL) {
4545
unsafe {
4646
let _: () = msg_send![super(this, class!(UIViewController)), viewDidDisappear: animated];
4747
}

0 commit comments

Comments
 (0)