Fix some invalid msg_send! usage (#2138)
* Fix some invalid msg_send! usage * Make the implementation of superclass clearer
This commit is contained in:
parent
8af222c1e3
commit
2a2abc4843
9 changed files with 53 additions and 45 deletions
|
|
@ -40,10 +40,9 @@ impl IdRef {
|
|||
IdRef(inner)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn retain(inner: id) -> IdRef {
|
||||
if inner != nil {
|
||||
let () = unsafe { msg_send![inner, retain] };
|
||||
let _: id = unsafe { msg_send![inner, retain] };
|
||||
}
|
||||
IdRef(inner)
|
||||
}
|
||||
|
|
@ -76,10 +75,7 @@ impl Deref for IdRef {
|
|||
|
||||
impl Clone for IdRef {
|
||||
fn clone(&self) -> IdRef {
|
||||
if self.0 != nil {
|
||||
let _: id = unsafe { msg_send![self.0, retain] };
|
||||
}
|
||||
IdRef(self.0)
|
||||
IdRef::retain(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +114,8 @@ pub unsafe fn app_name() -> Option<id> {
|
|||
}
|
||||
|
||||
pub unsafe fn superclass<'a>(this: &'a Object) -> &'a Class {
|
||||
let superclass: id = msg_send![this, superclass];
|
||||
&*(superclass as *const _)
|
||||
let superclass: *const Class = msg_send![this, superclass];
|
||||
&*superclass
|
||||
}
|
||||
|
||||
pub unsafe fn create_input_context(view: id) -> IdRef {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue