Skip to content

Commit

Permalink
Reborrow a few places where now necessary
Browse files Browse the repository at this point in the history
See madsmtm/objc2#150 for a bit of background
  • Loading branch information
madsmtm committed Jul 20, 2022
1 parent 008c08d commit a2d40b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/input/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ use crate::utils::load;
/// Called when editing this text field has ended (e.g. user pressed enter).
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
let s = NSString::retain(unsafe { msg_send![&*this, stringValue] });
view.text_did_end_editing(s.to_str());
}

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

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

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

match view.text_should_begin_editing(s.to_str()) {
true => YES,
Expand All @@ -41,7 +41,7 @@ extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object,

extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) -> BOOL {
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
let s = NSString::retain(unsafe { msg_send![&*this, stringValue] });
match view.text_should_end_editing(s.to_str()) {
true => YES,
false => NO
Expand Down
8 changes: 4 additions & 4 deletions src/view/controller/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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) {
unsafe {
let _: () = msg_send![super(this, class!(NSViewController)), viewWillAppear];
let _: () = msg_send![super(&mut *this, class!(NSViewController)), viewWillAppear];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -23,7 +23,7 @@ extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
/// Called when the view controller receives a `viewDidAppear` message.
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
unsafe {
let _: () = msg_send![super(this, class!(NSViewController)), viewDidAppear];
let _: () = msg_send![super(&mut *this, class!(NSViewController)), viewDidAppear];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -33,7 +33,7 @@ extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
/// Called when the view controller receives a `viewWillDisappear` message.
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
unsafe {
let _: () = msg_send![super(this, class!(NSViewController)), viewWillDisappear];
let _: () = msg_send![super(&mut *this, class!(NSViewController)), viewWillDisappear];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -43,7 +43,7 @@ extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
/// Called when the view controller receives a `viewDidDisappear` message.
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
unsafe {
let _: () = msg_send![super(this, class!(NSViewController)), viewDidDisappear];
let _: () = msg_send![super(&mut *this, class!(NSViewController)), viewDidDisappear];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand Down
8 changes: 4 additions & 4 deletions src/view/controller/uikit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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, animated: BOOL) {
unsafe {
let _: () = msg_send![super(this, class!(UIViewController)), viewWillAppear: animated];
let _: () = msg_send![super(&mut *this, class!(UIViewController)), viewWillAppear: animated];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -23,7 +23,7 @@ extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated:
/// Called when the view controller receives a `viewDidAppear:` message.
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
unsafe {
let _: () = msg_send![super(this, class!(UIViewController)), viewDidAppear: animated];
let _: () = msg_send![super(&mut *this, class!(UIViewController)), viewDidAppear: animated];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -33,7 +33,7 @@ extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: B
/// Called when the view controller receives a `viewWillDisappear:` message.
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
unsafe {
let _: () = msg_send![super(this, class!(UIViewController)), viewWillDisappear: animated];
let _: () = msg_send![super(&mut *this, class!(UIViewController)), viewWillDisappear: animated];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand All @@ -43,7 +43,7 @@ extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animate
/// Called when the view controller receives a `viewDidDisappear:` message.
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
unsafe {
let _: () = msg_send![super(this, class!(UIViewController)), viewDidDisappear: animated];
let _: () = msg_send![super(&mut *this, class!(UIViewController)), viewDidDisappear: animated];
}

let controller = load::<T>(this, VIEW_DELEGATE_PTR);
Expand Down

0 comments on commit a2d40b2

Please sign in to comment.