Skip to content

Commit

Permalink
Use renamed Object::get_ivar method (now Object::ivar)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 12, 2023
1 parent fb3b2d2 commit 2398689
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/appkit/app/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::user_activity::UserActivity;
/// standard `utils` version as this doesn't require `RefCell` backing.
fn app<T>(this: &Object) -> &T {
unsafe {
let app_ptr: usize = *this.get_ivar(APP_PTR);
let app_ptr: usize = *this.ivar(APP_PTR);
let app = app_ptr as *const T;
&*app
}
Expand Down
4 changes: 2 additions & 2 deletions src/appkit/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
queue.exec_async(move || unsafe {
let app: id = msg_send![register_app_class(), sharedApplication];
let app_delegate: id = msg_send![app, delegate];
let delegate_ptr: usize = *(*app_delegate).get_ivar(APP_PTR);
let delegate_ptr: usize = *(*app_delegate).ivar(APP_PTR);
let delegate = delegate_ptr as *const T;
(&*delegate).on_ui_message(message);
});
Expand All @@ -209,7 +209,7 @@ where
queue.exec_async(move || unsafe {
let app: id = msg_send![register_app_class(), sharedApplication];
let app_delegate: id = msg_send![app, delegate];
let delegate_ptr: usize = *(*app_delegate).get_ivar(APP_PTR);
let delegate_ptr: usize = *(*app_delegate).ivar(APP_PTR);
let delegate = delegate_ptr as *const T;
(&*delegate).on_background_message(message);
});
Expand Down
2 changes: 1 addition & 1 deletion src/appkit/menu/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl MenuItem {
/// need to do some extra logic to ensure release calls are properly sent.
extern "C" fn dealloc_cacao_menuitem(this: &Object, _: Sel) {
unsafe {
let ptr: usize = *this.get_ivar(BLOCK_PTR);
let ptr: usize = *this.ivar(BLOCK_PTR);
let obj = ptr as *mut Action;

if !obj.is_null() {
Expand Down
8 changes: 4 additions & 4 deletions src/color/appkit_dynamic_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ fn get_effective_color(this: &Object) -> id {
let style: id = msg_send![appearance, bestMatchFromAppearancesWithNames:&*names];

if style == NSAppearanceNameDarkAqua {
return *this.get_ivar(AQUA_DARK_COLOR_NORMAL_CONTRAST);
return *this.ivar(AQUA_DARK_COLOR_NORMAL_CONTRAST);
}

if style == NSAppearanceNameAccessibilityHighContrastAqua {
return *this.get_ivar(AQUA_LIGHT_COLOR_HIGH_CONTRAST);
return *this.ivar(AQUA_LIGHT_COLOR_HIGH_CONTRAST);
}

if style == NSAppearanceNameAccessibilityHighContrastDarkAqua {
return *this.get_ivar(AQUA_DARK_COLOR_HIGH_CONTRAST);
return *this.ivar(AQUA_DARK_COLOR_HIGH_CONTRAST);
}
}
}

unsafe {
return *this.get_ivar(AQUA_LIGHT_COLOR_NORMAL_CONTRAST);
return *this.ivar(AQUA_LIGHT_COLOR_NORMAL_CONTRAST);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/listview/row/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern "C" fn dragging_exited<T: ViewDelegate>(this: &mut Object, _: Sel, info:
/// Called for layer updates.
extern "C" fn update_layer(this: &Object, _: Sel) {
unsafe {
let background_color: id = *this.get_ivar(BACKGROUND_COLOR);
let background_color: id = *this.ivar(BACKGROUND_COLOR);

if background_color != nil {
let layer: id = msg_send![this, layer];
Expand All @@ -86,7 +86,7 @@ extern "C" fn update_layer(this: &Object, _: Sel) {
extern "C" fn dealloc<T: ViewDelegate>(this: &Object, _: Sel) {
// Load the Box pointer here, and just let it drop normally.
unsafe {
let ptr: usize = *(&*this).get_ivar(LISTVIEW_ROW_DELEGATE_PTR);
let ptr: usize = *(&*this).ivar(LISTVIEW_ROW_DELEGATE_PTR);
let obj = ptr as *mut T;
let _x = Box::from_raw(obj);

Expand Down
2 changes: 1 addition & 1 deletion src/listview/row/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ where
pub(crate) fn from_cached(view: id) -> ListViewRow<T> {
// @TODO: Make this better.
let delegate = unsafe {
let ptr: usize = *(&*view).get_ivar(LISTVIEW_ROW_DELEGATE_PTR);
let ptr: usize = *(&*view).ivar(LISTVIEW_ROW_DELEGATE_PTR);
let obj = ptr as *mut T;
Box::from_raw(obj)
//&*obj
Expand Down
2 changes: 1 addition & 1 deletion src/uikit/app/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::uikit::scene::{SceneConnectionOptions, SceneSession};
/// standard `utils` version as this doesn't require `RefCell` backing.
fn app<T>(this: &Object) -> &T {
unsafe {
//let app_ptr: usize = *this.get_ivar(APP_DELEGATE);
//let app_ptr: usize = *this.ivar(APP_DELEGATE);
let app = APP_DELEGATE as *const T;
&*app
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub trait Controller {
/// checking.
pub fn load<'a, T>(this: &'a Object, ptr_name: &str) -> &'a T {
unsafe {
let ptr: usize = *this.get_ivar(ptr_name);
let ptr: usize = *this.ivar(ptr_name);
let obj = ptr as *const T;
&*obj
}
Expand Down
2 changes: 1 addition & 1 deletion src/view/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern "C" fn dragging_exited<T: ViewDelegate>(this: &mut Object, _: Sel, info:
/// Called for layer updates.
extern "C" fn update_layer(this: &Object, _: Sel) {
unsafe {
let background_color: id = *this.get_ivar(BACKGROUND_COLOR);
let background_color: id = *this.ivar(BACKGROUND_COLOR);

if background_color != nil {
let layer: id = msg_send![this, layer];
Expand Down
2 changes: 1 addition & 1 deletion src/webview/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" fn alert<T: WebViewDelegate>(_: &Object, _: Sel, _: id, _: id, _: id,
}

/*unsafe {
let ptr: usize = *this.get_ivar(WEBVIEW_DELEGATE_PTR);
let ptr: usize = *this.ivar(WEBVIEW_DELEGATE_PTR);
let delegate = ptr as *const T;
(*webview).alert(alert);
}*/
Expand Down

0 comments on commit 2398689

Please sign in to comment.