From 0e654ad76be543964a9ed21dca4569f63af9bad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C4=ABls=20Pi=C5=86=C4=B7is?= Date: Wed, 13 Mar 2019 20:04:15 +0000 Subject: [PATCH 1/3] Replace CoreFoundation-sys with mozilla's core-foundation --- Cargo.toml | 2 +- examples/list_serial_ports.rs | 8 ++++---- src/io_hid_base.rs | 2 +- src/io_hid_manager.rs | 2 +- src/lib.rs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 694fcc9..fbb8e14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,4 @@ build = "build.rs" [dependencies] libc = "0.2" mach = "0.1.1" -CoreFoundation-sys = "0.1.4" +core-foundation = "0.6.3" diff --git a/examples/list_serial_ports.rs b/examples/list_serial_ports.rs index 9bf933c..87d0821 100644 --- a/examples/list_serial_ports.rs +++ b/examples/list_serial_ports.rs @@ -1,5 +1,5 @@ extern crate IOKit_sys; -extern crate CoreFoundation_sys as cf; +extern crate core_foundation as cf; extern crate libc; extern crate mach; @@ -14,7 +14,7 @@ use mach::port::{mach_port_t,MACH_PORT_NULL}; use mach::kern_return::KERN_SUCCESS; use IOKit_sys::*; -use cf::*; +use cf::{base::*, string::*, dictionary::*}; fn main() { @@ -64,7 +64,7 @@ fn main() { let result = IORegistryEntryCreateCFProperties(modem_service, &mut props, kCFAllocatorDefault, 0); if result == KERN_SUCCESS { - CFDictionaryApplyFunction(props, print_property_entry, ptr::null()); + CFDictionaryApplyFunction(props, print_property_entry, ptr::null_mut()); } IOObjectRelease(modem_service); @@ -72,7 +72,7 @@ fn main() { } } -extern "C" fn print_property_entry(key: CFTypeRef, value: CFTypeRef, _context: *const c_void) { +extern "C" fn print_property_entry(key: CFTypeRef, value: CFTypeRef, _context: *mut c_void) { unsafe { let mut buf = Vec::::with_capacity(256); diff --git a/src/io_hid_base.rs b/src/io_hid_base.rs index b35222d..9801791 100644 --- a/src/io_hid_base.rs +++ b/src/io_hid_base.rs @@ -1,7 +1,7 @@ // exports from use libc::c_void; -use cf::CFIndex; +use cf::base::CFIndex; use io_return::IOReturn; use io_hid_keys::IOHIDReportType; diff --git a/src/io_hid_manager.rs b/src/io_hid_manager.rs index bff22d8..389dcca 100644 --- a/src/io_hid_manager.rs +++ b/src/io_hid_manager.rs @@ -1,7 +1,7 @@ // exports from use libc::c_void; -use cf::{CFAllocatorRef, CFDictionaryRef}; +use cf::{base::CFAllocatorRef, dictionary::CFDictionaryRef}; use types::IOOptionBits; use io_return::IOReturn; use io_hid_base::{IOHIDDeviceCallback, IOHIDReportCallback}; diff --git a/src/lib.rs b/src/lib.rs index 5ae964c..85d080a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,10 @@ #![allow(non_camel_case_types,non_upper_case_globals,non_snake_case)] -extern crate CoreFoundation_sys as cf; +extern crate core_foundation as cf; extern crate libc; extern crate mach; -use cf::{CFTypeRef,CFDictionaryRef,CFMutableDictionaryRef,CFStringRef,CFAllocatorRef}; +use cf::{base::CFTypeRef,dictionary::CFDictionaryRef,dictionary::CFMutableDictionaryRef,string::CFStringRef,base::CFAllocatorRef}; use libc::{c_void,c_char,c_int,size_t,uintptr_t}; use mach::boolean::boolean_t; From a58899a365330d3fbec8ab709fe9e0896a8804b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C4=ABls=20Pi=C5=86=C4=B7is?= Date: Wed, 13 Mar 2019 20:29:43 +0000 Subject: [PATCH 2/3] Bump version due to change in API --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fbb8e14..ca34668 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "IOKit-sys" -version = "0.1.5" +version = "0.2.0" authors = ["David Cuddeback "] description = "FFI bindings for IOKit" license = "MIT" From 5116a6727d430d38b7281acc0e7d1fed76dd3e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C4=ABls=20Pi=C5=86=C4=B7is?= Date: Fri, 15 Mar 2019 10:00:59 +0000 Subject: [PATCH 3/3] Add IONotificationPortGetRunLoopSource to src/lib.rs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 85d080a..c33de51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,6 @@ mod io_hid_manager; pub struct IONotificationPort { __private: c_void, } - pub type IONotificationPortRef = *mut IONotificationPort; pub type IOServiceMatchingCallback = extern fn (refcon: *mut c_void, iterator: io_iterator_t); @@ -63,6 +62,7 @@ extern "C" { pub fn IONotificationPortCreate(masterPort: mach_port_t) -> IONotificationPortRef; pub fn IONotificationPortDestroy(notify: IONotificationPortRef); + pub fn IONotificationPortGetRunLoopSource(notify: IONotificationPortRef) -> cf::runloop::CFRunLoopSourceRef; pub fn IONotificationPortGetMachPort(notify: IONotificationPortRef) -> mach_port_t; pub fn IOCreateReceivePort(msgType: u32, recvPort: *mut mach_port_t) -> kern_return_t;