Skip to content

Commit

Permalink
Fix invalid msg_send! (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm authored Aug 13, 2024
1 parent 9d8c74e commit 6541d9a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions cocoa-foundation/src/foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ impl NSProcessInfo for id {
}

unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool {
msg_send![self, isOperatingSystemAtLeastVersion: version]
let res: BOOL = msg_send![self, isOperatingSystemAtLeastVersion: version];
res != NO
}
}

Expand Down Expand Up @@ -657,9 +658,9 @@ impl NSString for id {

unsafe fn init_str(self, string: &str) -> id {
msg_send![self,
initWithBytes:string.as_ptr()
initWithBytes:string.as_ptr() as *const c_void
length:string.len()
encoding:UTF8_ENCODING as id]
encoding:UTF8_ENCODING]
}

unsafe fn len(self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion cocoa/src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ impl NSOpenGLPixelFormat for id {
// Creating an NSOpenGLPixelFormat Object

unsafe fn initWithAttributes_(self, attributes: &[u32]) -> id {
msg_send![self, initWithAttributes: attributes]
msg_send![self, initWithAttributes:attributes.as_ptr()]
}

// Managing the Pixel Format
Expand Down
9 changes: 5 additions & 4 deletions cocoa/src/quartzcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,12 +946,12 @@ impl CALayer {

#[inline]
pub fn actions(&self) -> CFDictionary<CFStringRef, CFTypeRef> {
unsafe { msg_send![self.id(), actions] }
unsafe { CFDictionary::wrap_under_get_rule(msg_send![self.id(), actions]) }
}

#[inline]
pub unsafe fn set_actions(&self, actions: CFDictionary<CFStringRef, CFTypeRef>) {
msg_send![self.id(), setActions: actions]
msg_send![self.id(), setActions: actions.as_concrete_TypeRef()]
}

// TODO(pcwalton): Wrap `CAAnimation`.
Expand Down Expand Up @@ -1362,6 +1362,7 @@ impl CARenderer {
// really just a module.
pub mod transaction {
use block::{Block, ConcreteBlock, IntoConcreteBlock, RcBlock};
use core_foundation::base::TCFType;
use core_foundation::date::CFTimeInterval;
use core_foundation::string::CFString;
use objc::{class, msg_send, sel, sel_impl};
Expand Down Expand Up @@ -1454,15 +1455,15 @@ pub mod transaction {
pub fn value_for_key(key: &str) -> id {
unsafe {
let key: CFString = CFString::from(key);
msg_send![class!(CATransaction), valueForKey: key]
msg_send![class!(CATransaction), valueForKey: key.as_concrete_TypeRef()]
}
}

#[inline]
pub fn set_value_for_key(value: id, key: &str) {
unsafe {
let key: CFString = CFString::from(key);
msg_send![class!(CATransaction), setValue:value forKey:key]
msg_send![class!(CATransaction), setValue: value forKey: key.as_concrete_TypeRef()]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core-text/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub fn new_ui_font_for_language(
unsafe {
let font_ref = CTFontCreateUIFontForLanguage(
ui_type,
size,
size as CGFloat,
language
.as_ref()
.map(|x| x.as_concrete_TypeRef())
Expand Down

0 comments on commit 6541d9a

Please sign in to comment.