Fix some invalid msg_send! usage (#2138)

* Fix some invalid msg_send! usage

* Make the implementation of superclass clearer
This commit is contained in:
Mads Marquart 2022-01-10 21:39:17 +01:00 committed by GitHub
parent 8af222c1e3
commit 2a2abc4843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 45 deletions

View file

@ -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 {