/// Specifies the superclass of an instance. #[repr(C)] pubstructSuper { /// Specifies an instance of a class. pub receiver: *mut Object, /// Specifies the particular superclass of the instance to message. pub superclass: *const Class,
}
/// Types that may be sent Objective-C messages. /// For example: objects, classes, and blocks. pubunsafetrait Message { /** Sendsamessagetoselfwiththegivenselectorandarguments.
#Example ```no_run ##[macro_use]externcrateobjc; #useobjc::runtime::{BOOL,Class,Object}; #useobjc::Message; #fnmain(){ letobj:&Object; #obj=unsafe{msg_send![class!(NSObject),new]}; letsel=sel!(isKindOfClass:); // Verify isKindOfClass: takes one Class and returns a BOOL letresult=obj.verify_message::<(&Class,),BOOL>(sel); assert!(result.is_ok()); #} ```
*/ fn verify_message<A, R>(&self, sel: Sel) -> Result<(), MessageError> whereSelf: Sized, A: EncodeArguments, R: Encode { let obj = unsafe { &*(selfas *const _ as *const Object) };
verify_message_signature::<A, R>(obj.class(), sel)
}
}
unsafeimpl Message for Object { }
unsafeimpl Message for Class { }
/// Types that may be used as the arguments of an Objective-C message. pubtrait MessageArguments: Sized { /// Invoke an `Imp` with the given object, selector, and arguments. /// /// This method is the primitive used when sending messages and should not /// be called directly; instead, use the `msg_send!` macro or, in cases /// with a dynamic selector, the `Message::send_message` method. unsafefn invoke<R>(imp: Imp, obj: *mut Object, sel: Sel, args: Self) -> R where R: Any;
}
macro_rules! message_args_impl {
($($a:ident : $t:ident),*) => ( impl<$($t),*> MessageArguments for ($($t,)*) { unsafefn invoke<R>(imp: Imp, obj: *mut Object, sel: Sel, ($($a,)*): Self) -> R where R: Any { let imp: unsafeexternfn(*mut Object, Sel $(, $t)*) -> R =
mem::transmute(imp);
imp(obj, sel $(, $a)*)
}
}
);
}
message_args_impl!();
message_args_impl!(a: A);
message_args_impl!(a: A, b: B);
message_args_impl!(a: A, b: B, c: C);
message_args_impl!(a: A, b: B, c: C, d: D);
message_args_impl!(a: A, b: B, c: C, d: D, e: E);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K);
message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.