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() -> Imp { // Double-word sized fundamental data types don't use stret, // but any composite type larger than 4 bytes does. // let type_id = TypeId::of::(); if mem::size_of::() <= 4 || type_id == TypeId::of::() || type_id == TypeId::of::() || type_id == TypeId::of::() { objc_msgSend } else { objc_msgSend_stret } } pub fn msg_send_super_fn() -> Imp { let type_id = TypeId::of::(); if mem::size_of::() <= 4 || type_id == TypeId::of::() || type_id == TypeId::of::() || type_id == TypeId::of::() { objc_msgSendSuper } else { objc_msgSendSuper_stret } }