Skip to content

Commit

Permalink
sys: Add some GNUStep objc_msg_X functions
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 5, 2021
1 parent 4d72245 commit 98ae6d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 194 deletions.
13 changes: 4 additions & 9 deletions objc/src/message/gnustep.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
use core::mem;
use objc_sys::objc_super;
use objc_sys::{objc_msg_lookup, objc_msg_lookup_super, objc_super};

use super::{Encode, Message, MessageArguments, MessageError};
use crate::runtime::{Class, Imp, Object, Sel};

extern "C" {
fn objc_msg_lookup(receiver: *mut Object, op: Sel) -> Imp;
fn objc_msg_lookup_super(sup: *const objc_super, sel: Sel) -> Imp;
}
use crate::runtime::{Class, Object, Sel};

pub unsafe fn send_unverified<T, A, R>(obj: *const T, sel: Sel, args: A) -> Result<R, MessageError>
where
Expand All @@ -20,7 +15,7 @@ where
}

let receiver = obj as *mut T as *mut Object;
let msg_send_fn = objc_msg_lookup(receiver, sel);
let msg_send_fn = objc_msg_lookup(receiver as *mut _, sel.as_ptr() as *const _);
objc_try!({ A::invoke(msg_send_fn, receiver, sel, args) })
}

Expand All @@ -40,6 +35,6 @@ where
receiver: receiver as *mut _,
super_class: superclass as *const Class as *const _,
};
let msg_send_fn = objc_msg_lookup_super(&sup, sel);
let msg_send_fn = objc_msg_lookup_super(&sup, sel.as_ptr() as *const _);
objc_try!({ A::invoke(msg_send_fn, receiver, sel, args) })
}
7 changes: 7 additions & 0 deletions objc_sys/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ pub struct objc_super {
pub super_class: *const objc_class,
}

#[cfg(gnustep)]
extern "C" {
pub fn objc_msg_lookup(receiver: *mut objc_object, sel: *const objc_selector) -> IMP;
pub fn objc_msg_lookup_super(super: *const objc_super, sel: *const objc_selector) -> IMP;
// objc_msg_lookup_sender
}

extern "C" {
pub fn objc_msgSend();
#[cfg(apple)]
Expand Down
185 changes: 0 additions & 185 deletions objc_sys/src/tmp_gnustep.rs

This file was deleted.

3 changes: 3 additions & 0 deletions objc_sys/src/various.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ extern "C" {
// #[deprecated = "not recommended"]
// #[cfg(apple)]
// pub fn _objc_flush_caches

// #[cfg(gnustep)]
// objc_test_capability
}

0 comments on commit 98ae6d3

Please sign in to comment.