From eab9a3215fd2452dac3fc49ed1a00e225d0ce27d Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 23 Jan 2025 02:34:16 +0100 Subject: [PATCH] Use objc2-core-foundation --- glutin/Cargo.toml | 7 ++++++- glutin/src/api/cgl/display.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 9eaf298cf7..79d5f24113 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -55,12 +55,17 @@ x11-dl = { version = "2.20.0", optional = true } [target.'cfg(any(target_os = "macos"))'.dependencies] cgl = "0.3.2" -core-foundation = "0.9.3" dispatch2 = { version = "0.2.0", default-features = false, features = [ "std", "objc2", ] } objc2 = "0.6.0" +objc2-core-foundation = { version = "0.3.0", default-features = false, features = [ + "std", + "CFBase", + "CFString", + "CFBundle", +] } objc2-foundation = { version = "0.3.0", default-features = false, features = [ "std", "NSArray", diff --git a/glutin/src/api/cgl/display.rs b/glutin/src/api/cgl/display.rs index 40ff0f5697..f3b1d3c703 100644 --- a/glutin/src/api/cgl/display.rs +++ b/glutin/src/api/cgl/display.rs @@ -3,9 +3,9 @@ use std::ffi::{self, CStr}; use std::marker::PhantomData; -use core_foundation::base::TCFType; -use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName}; -use core_foundation::string::CFString; +use objc2_core_foundation::{ + CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName, CFString, +}; use raw_window_handle::RawDisplayHandle; use crate::config::ConfigTemplate; @@ -87,11 +87,11 @@ impl GlDisplay for Display { } fn get_proc_address(&self, addr: &CStr) -> *const ffi::c_void { - let symbol_name = CFString::new(addr.to_str().unwrap()); - let framework_name = CFString::new("com.apple.opengl"); + let symbol_name = CFString::from_str(addr.to_str().unwrap()); + let framework_name = CFString::from_static_str("com.apple.opengl"); unsafe { - let framework = CFBundleGetBundleWithIdentifier(framework_name.as_concrete_TypeRef()); - CFBundleGetFunctionPointerForName(framework, symbol_name.as_concrete_TypeRef()).cast() + let framework = CFBundleGetBundleWithIdentifier(Some(&framework_name)).unwrap(); + CFBundleGetFunctionPointerForName(&framework, Some(&symbol_name)) } }