diff --git a/core-foundation-sys/src/dictionary.rs b/core-foundation-sys/src/dictionary.rs new file mode 100644 index 0000000..2800d4c --- /dev/null +++ b/core-foundation-sys/src/dictionary.rs @@ -0,0 +1,57 @@ +use libc::{c_void}; + +use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean}; + +pub type CFDictionaryApplierFunction = *const u8; +pub type CFDictionaryCopyDescriptionCallBack = *const u8; +pub type CFDictionaryEqualCallBack = *const u8; +pub type CFDictionaryHashCallBack = *const u8; +pub type CFDictionaryReleaseCallBack = *const u8; +pub type CFDictionaryRetainCallBack = *const u8; + +#[allow(dead_code)] +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFDictionaryKeyCallBacks { + pub version: CFIndex, + pub retain: CFDictionaryRetainCallBack, + pub release: CFDictionaryReleaseCallBack, + pub copyDescription: CFDictionaryCopyDescriptionCallBack, + pub equal: CFDictionaryEqualCallBack, + pub hash: CFDictionaryHashCallBack +} + +#[allow(dead_code)] +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFDictionaryValueCallBacks { + pub version: CFIndex, + pub retain: CFDictionaryRetainCallBack, + pub release: CFDictionaryReleaseCallBack, + pub copyDescription: CFDictionaryCopyDescriptionCallBack, + pub equal: CFDictionaryEqualCallBack +} + +#[repr(C)] +struct __CFDictionary; + +pub type CFDictionaryRef = *const __CFDictionary; + +extern { + /* + * CFDictionary.h + */ + + pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; + pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; + + pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean; + pub fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, + numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, + valueCallBacks: *const CFDictionaryValueCallBacks) + -> CFDictionaryRef; + pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex; + pub fn CFDictionaryGetTypeID() -> CFTypeID; + pub fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) + -> Boolean; +} diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index 7af117d..68bcdb4 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -7,5 +7,6 @@ pub mod base; pub mod bundle; pub mod data; pub mod date; +pub mod dictionary; pub mod number; pub mod string; diff --git a/core-foundation-sys/src/number.rs b/core-foundation-sys/src/number.rs index 99b9c49..026a7b0 100644 --- a/core-foundation-sys/src/number.rs +++ b/core-foundation-sys/src/number.rs @@ -1,12 +1,47 @@ use libc::c_void; -use base::CFTypeID; +use base::{CFAllocatorRef, CFTypeID}; pub type CFBooleanRef = *const c_void; +pub type CFNumberType = u32; + +// members of enum CFNumberType +// static kCFNumberSInt8Type: CFNumberType = 1; +// static kCFNumberSInt16Type: CFNumberType = 2; +pub static kCFNumberSInt32Type: CFNumberType = 3; +pub static kCFNumberSInt64Type: CFNumberType = 4; +// static kCFNumberFloat32Type: CFNumberType = 5; +pub static kCFNumberFloat64Type: CFNumberType = 6; +// static kCFNumberCharType: CFNumberType = 7; +// static kCFNumberShortType: CFNumberType = 8; +// static kCFNumberIntType: CFNumberType = 9; +// static kCFNumberLongType: CFNumberType = 10; +// static kCFNumberLongLongType: CFNumberType = 11; +// static kCFNumberFloatType: CFNumberType = 12; +// static kCFNumberDoubleType: CFNumberType = 13; +// static kCFNumberCFIndexType: CFNumberType = 14; +// static kCFNumberNSIntegerType: CFNumberType = 15; +// static kCFNumberCGFloatType: CFNumberType = 16; +// static kCFNumberMaxType: CFNumberType = 16; + +#[repr(C)] +struct __CFNumber; + +pub type CFNumberRef = *const __CFNumber; + extern { + /* + * CFNumber.h + */ pub static kCFBooleanTrue: CFBooleanRef; pub static kCFBooleanFalse: CFBooleanRef; pub fn CFBooleanGetTypeID() -> CFTypeID; + pub fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void) + -> CFNumberRef; + //fn CFNumberGetByteSize + pub fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool; + //fn CFNumberCompare + pub fn CFNumberGetTypeID() -> CFTypeID; } diff --git a/core-foundation/src/dictionary.rs b/core-foundation/src/dictionary.rs index 5540d20..b08bdc1 100644 --- a/core-foundation/src/dictionary.rs +++ b/core-foundation/src/dictionary.rs @@ -9,49 +9,15 @@ //! Dictionaries of key-value pairs. -use core_foundation_sys::base::{Boolean, 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::dictionary::*; use libc::c_void; use std::mem; use std::ptr; use base::{CFType, CFIndexConvertible, TCFType}; -pub type CFDictionaryApplierFunction = *const u8; -pub type CFDictionaryCopyDescriptionCallBack = *const u8; -pub type CFDictionaryEqualCallBack = *const u8; -pub type CFDictionaryHashCallBack = *const u8; -pub type CFDictionaryReleaseCallBack = *const u8; -pub type CFDictionaryRetainCallBack = *const u8; - -#[allow(dead_code)] -#[repr(C)] -#[derive(Clone, Copy)] -pub struct CFDictionaryKeyCallBacks { - version: CFIndex, - retain: CFDictionaryRetainCallBack, - release: CFDictionaryReleaseCallBack, - copyDescription: CFDictionaryCopyDescriptionCallBack, - equal: CFDictionaryEqualCallBack, - hash: CFDictionaryHashCallBack -} - -#[allow(dead_code)] -#[repr(C)] -#[derive(Clone, Copy)] -pub struct CFDictionaryValueCallBacks { - version: CFIndex, - retain: CFDictionaryRetainCallBack, - release: CFDictionaryReleaseCallBack, - copyDescription: CFDictionaryCopyDescriptionCallBack, - equal: CFDictionaryEqualCallBack -} - -#[repr(C)] -struct __CFDictionary; - -pub type CFDictionaryRef = *const __CFDictionary; - /// An immutable dictionary of key-value pairs. pub struct CFDictionary(CFDictionaryRef); @@ -131,23 +97,3 @@ impl CFDictionary { TCFType::wrap_under_get_rule(value) } } - -#[link(name = "CoreFoundation", kind = "framework")] -extern { - /* - * CFDictionary.h - */ - - static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; - static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; - - fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean; - fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, - numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, - valueCallBacks: *const CFDictionaryValueCallBacks) - -> CFDictionaryRef; - fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex; - fn CFDictionaryGetTypeID() -> CFTypeID; - fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) - -> Boolean; -} diff --git a/core-foundation/src/number.rs b/core-foundation/src/number.rs index 0309bc8..22869e8 100644 --- a/core-foundation/src/number.rs +++ b/core-foundation/src/number.rs @@ -11,39 +11,12 @@ #![allow(non_upper_case_globals)] -use core_foundation_sys::base::{CFAllocatorRef, CFRelease, CFTypeID}; -use core_foundation_sys::base::{kCFAllocatorDefault}; -use libc::c_void; +use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault}; +use core_foundation_sys::number::*; use std::mem; use base::{TCFType}; -pub type CFNumberType = u32; - -// members of enum CFNumberType -// static kCFNumberSInt8Type: CFNumberType = 1; -// static kCFNumberSInt16Type: CFNumberType = 2; -static kCFNumberSInt32Type: CFNumberType = 3; -static kCFNumberSInt64Type: CFNumberType = 4; -// static kCFNumberFloat32Type: CFNumberType = 5; -static kCFNumberFloat64Type: CFNumberType = 6; -// static kCFNumberCharType: CFNumberType = 7; -// static kCFNumberShortType: CFNumberType = 8; -// static kCFNumberIntType: CFNumberType = 9; -// static kCFNumberLongType: CFNumberType = 10; -// static kCFNumberLongLongType: CFNumberType = 11; -// static kCFNumberFloatType: CFNumberType = 12; -// static kCFNumberDoubleType: CFNumberType = 13; -// static kCFNumberCFIndexType: CFNumberType = 14; -// static kCFNumberNSIntegerType: CFNumberType = 15; -// static kCFNumberCGFloatType: CFNumberType = 16; -// static kCFNumberMaxType: CFNumberType = 16; - -#[repr(C)] -struct __CFNumber; - -pub type CFNumberRef = *const __CFNumber; - /// An immutable numeric value. pub struct CFNumber(CFNumberRef); @@ -112,18 +85,3 @@ impl CFNumber { pub fn number(value: i64) -> CFNumber { CFNumber::from_i64(value) } - -#[link(name = "CoreFoundation", kind = "framework")] -extern { - /* - * CFNumber.h - */ - - - fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void) - -> CFNumberRef; - //fn CFNumberGetByteSize - fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool; - //fn CFNumberCompare - fn CFNumberGetTypeID() -> CFTypeID; -}