From 6541d9a7898a1626a84178a71680f3fae3f2b882 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 13 Aug 2024 14:04:01 +0200 Subject: [PATCH] Fix invalid msg_send! (#702) --- cocoa-foundation/src/foundation.rs | 7 ++++--- cocoa/src/appkit.rs | 2 +- cocoa/src/quartzcore.rs | 9 +++++---- core-text/src/font.rs | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cocoa-foundation/src/foundation.rs b/cocoa-foundation/src/foundation.rs index c935d8e9..022b0e88 100644 --- a/cocoa-foundation/src/foundation.rs +++ b/cocoa-foundation/src/foundation.rs @@ -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 } } @@ -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 { diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index 0d9abc65..4a6747d4 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -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 diff --git a/cocoa/src/quartzcore.rs b/cocoa/src/quartzcore.rs index 65bfa68d..c96d8651 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -946,12 +946,12 @@ impl CALayer { #[inline] pub fn actions(&self) -> CFDictionary { - 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) { - msg_send![self.id(), setActions: actions] + msg_send![self.id(), setActions: actions.as_concrete_TypeRef()] } // TODO(pcwalton): Wrap `CAAnimation`. @@ -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}; @@ -1454,7 +1455,7 @@ 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()] } } @@ -1462,7 +1463,7 @@ pub mod transaction { 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()] } } } diff --git a/core-text/src/font.rs b/core-text/src/font.rs index f5deb644..c1db6b8a 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -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())