diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index cc84bc3..a32eae8 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -10,4 +10,5 @@ pub mod date; pub mod dictionary; pub mod number; pub mod runloop; +pub mod set; pub mod string; diff --git a/core-foundation-sys/src/set.rs b/core-foundation-sys/src/set.rs new file mode 100644 index 0000000..9ef4a24 --- /dev/null +++ b/core-foundation-sys/src/set.rs @@ -0,0 +1,43 @@ +use libc::c_void; + +use base::{CFAllocatorRef, CFIndex, CFTypeID}; + +pub type CFSetRetainCallBack = *const u8; +pub type CFSetReleaseCallBack = *const u8; +pub type CFSetCopyDescriptionCallBack = *const u8; +pub type CFSetEqualCallBack = *const u8; +pub type CFSetHashCallBack = *const u8; + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFSetCallBacks { + pub version: CFIndex, + pub retain: CFSetRetainCallBack, + pub release: CFSetReleaseCallBack, + pub copyDescription: CFSetCopyDescriptionCallBack, + pub equal: CFSetEqualCallBack, + pub hash: CFSetHashCallBack, +} + +#[repr(C)] +struct __CFSet; + +pub type CFSetRef = *const __CFSet; + +extern { + /* + * CFSet.h + */ + + pub static kCFTypeSetCallBacks: CFSetCallBacks; + + /* Creating Sets */ + pub fn CFSetCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, + callBacks: *const CFSetCallBacks) -> CFSetRef; + + /* Applying a Function to Set Members */ + //fn CFSetApplyFunction + + pub fn CFSetGetTypeID() -> CFTypeID; +} + diff --git a/core-foundation/src/set.rs b/core-foundation/src/set.rs index 680007f..00f9190 100644 --- a/core-foundation/src/set.rs +++ b/core-foundation/src/set.rs @@ -9,37 +9,14 @@ //! An immutable bag of elements. -use core_foundation_sys::base::{CFAllocatorRef, CFIndex, CFRelease}; -use core_foundation_sys::base::{CFTypeID, CFTypeRef, kCFAllocatorDefault}; +use core_foundation_sys::base::CFRelease; +use core_foundation_sys::base::{CFTypeRef, kCFAllocatorDefault}; +use core_foundation_sys::set::*; use base::{CFIndexConvertible, TCFType}; -use libc::c_void; use std::mem; -pub type CFSetRetainCallBack = *const u8; -pub type CFSetReleaseCallBack = *const u8; -pub type CFSetCopyDescriptionCallBack = *const u8; -pub type CFSetEqualCallBack = *const u8; -pub type CFSetHashCallBack = *const u8; - -#[allow(dead_code)] -#[repr(C)] -#[derive(Clone, Copy)] -pub struct CFSetCallBacks { - version: CFIndex, - retain: CFSetRetainCallBack, - release: CFSetReleaseCallBack, - copyDescription: CFSetCopyDescriptionCallBack, - equal: CFSetEqualCallBack, - hash: CFSetHashCallBack, -} - -#[repr(C)] -struct __CFSet; - -pub type CFSetRef = *const __CFSet; - /// An immutable bag of elements. pub struct CFSet(CFSetRef); @@ -66,22 +43,3 @@ impl CFSet { } } } - -#[link(name = "CoreFoundation", kind = "framework")] -extern { - /* - * CFSet.h - */ - - static kCFTypeSetCallBacks: CFSetCallBacks; - - /* Creating Sets */ - fn CFSetCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, - callBacks: *const CFSetCallBacks) -> CFSetRef; - - /* Applying a Function to Set Members */ - //fn CFSetApplyFunction - - fn CFSetGetTypeID() -> CFTypeID; -} -