blob: d26defc0de7666606c41f8761e118c0502f8f951 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use std::any::{Any, TypeId};
use std::mem;
use runtime::Imp;
extern {
fn objc_msgSend();
fn objc_msgSend_stret();
fn objc_msgSendSuper();
fn objc_msgSendSuper_stret();
}
pub fn msg_send_fn<R: Any>() -> Imp {
// Double-word sized fundamental data types don't use stret,
// but any composite type larger than 4 bytes does.
// <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf>
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id == TypeId::of::<i64>() ||
type_id == TypeId::of::<u64>() ||
type_id == TypeId::of::<f64>() {
objc_msgSend
} else {
objc_msgSend_stret
}
}
pub fn msg_send_super_fn<R: Any>() -> Imp {
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id == TypeId::of::<i64>() ||
type_id == TypeId::of::<u64>() ||
type_id == TypeId::of::<f64>() {
objc_msgSendSuper
} else {
objc_msgSendSuper_stret
}
}
|