1 // Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution. 3 // 4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 // option. This file may not be copied, modified, or distributed 8 // except according to those terms. 9 10 use std::os::raw::c_void; 11 12 use base::{CFAllocatorRef, CFHashCode, CFIndex, CFTypeID, Boolean}; 13 use string::CFStringRef; 14 15 pub type CFDictionaryApplierFunction = extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void); 16 17 pub type CFDictionaryRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; 18 pub type CFDictionaryReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); 19 pub type CFDictionaryCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; 20 pub type CFDictionaryEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; 21 pub type CFDictionaryHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode; 22 23 #[repr(C)] 24 #[derive(Clone, Copy)] 25 pub struct CFDictionaryKeyCallBacks { 26 pub version: CFIndex, 27 pub retain: CFDictionaryRetainCallBack, 28 pub release: CFDictionaryReleaseCallBack, 29 pub copyDescription: CFDictionaryCopyDescriptionCallBack, 30 pub equal: CFDictionaryEqualCallBack, 31 pub hash: CFDictionaryHashCallBack 32 } 33 34 #[repr(C)] 35 #[derive(Clone, Copy)] 36 pub struct CFDictionaryValueCallBacks { 37 pub version: CFIndex, 38 pub retain: CFDictionaryRetainCallBack, 39 pub release: CFDictionaryReleaseCallBack, 40 pub copyDescription: CFDictionaryCopyDescriptionCallBack, 41 pub equal: CFDictionaryEqualCallBack 42 } 43 44 #[repr(C)] 45 pub struct __CFDictionary(c_void); 46 47 pub type CFDictionaryRef = *const __CFDictionary; 48 pub type CFMutableDictionaryRef = *mut __CFDictionary; 49 50 extern { 51 /* 52 * CFDictionary.h 53 */ 54 55 pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; 56 pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; 57 CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean58 pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean; CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, valueCallBacks: *const CFDictionaryValueCallBacks) -> CFDictionaryRef59 pub fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, 60 numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, 61 valueCallBacks: *const CFDictionaryValueCallBacks) 62 -> CFDictionaryRef; CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex63 pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex; CFDictionaryGetTypeID() -> CFTypeID64 pub fn CFDictionaryGetTypeID() -> CFTypeID; CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) -> Boolean65 pub fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) 66 -> Boolean; CFDictionaryApplyFunction(theDict: CFDictionaryRef, applier: CFDictionaryApplierFunction, context: *mut c_void)67 pub fn CFDictionaryApplyFunction(theDict: CFDictionaryRef, 68 applier: CFDictionaryApplierFunction, 69 context: *mut c_void); CFDictionaryGetKeysAndValues(theDict: CFDictionaryRef, keys: *mut *const c_void, values: *mut *const c_void)70 pub fn CFDictionaryGetKeysAndValues(theDict: CFDictionaryRef, 71 keys: *mut *const c_void, 72 values: *mut *const c_void); 73 CFDictionaryCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, keyCallbacks: *const CFDictionaryKeyCallBacks, valueCallbacks: *const CFDictionaryValueCallBacks) -> CFMutableDictionaryRef74 pub fn CFDictionaryCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, 75 keyCallbacks: *const CFDictionaryKeyCallBacks, 76 valueCallbacks: *const CFDictionaryValueCallBacks) -> CFMutableDictionaryRef; CFDictionaryCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, theDict: CFDictionaryRef) -> CFMutableDictionaryRef77 pub fn CFDictionaryCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, 78 theDict: CFDictionaryRef) -> CFMutableDictionaryRef; CFDictionaryAddValue(theDict: CFMutableDictionaryRef, key: *const c_void, value: *const c_void)79 pub fn CFDictionaryAddValue(theDict: CFMutableDictionaryRef, 80 key: *const c_void, 81 value: *const c_void); CFDictionarySetValue(theDict: CFMutableDictionaryRef, key: *const c_void, value: *const c_void)82 pub fn CFDictionarySetValue(theDict: CFMutableDictionaryRef, 83 key: *const c_void, 84 value: *const c_void); CFDictionaryReplaceValue(theDict: CFMutableDictionaryRef, key: *const c_void, value: *const c_void)85 pub fn CFDictionaryReplaceValue(theDict: CFMutableDictionaryRef, 86 key: *const c_void, 87 value: *const c_void); CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, key: *const c_void)88 pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, 89 key: *const c_void); CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef)90 pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef); 91 } 92