Skip to content

Commit

Permalink
Use objc2-core-foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 24, 2025
1 parent 3c6cf86 commit 363d0de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion glutin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions glutin/src/api/cgl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 363d0de

Please sign in to comment.