objc2_core_foundation/generated/
CFDictionary.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// Structure containing the callbacks for keys of a CFDictionary.
13/// Field: version The version number of the structure type being passed
14/// in as a parameter to the CFDictionary creation functions.
15/// This structure is version 0.
16/// Field: retain The callback used to add a retain for the dictionary
17/// on keys as they are used to put values into the dictionary.
18/// This callback returns the value to use as the key in the
19/// dictionary, which is usually the value parameter passed to
20/// this callback, but may be a different value if a different
21/// value should be used as the key. The dictionary's allocator
22/// is passed as the first argument.
23/// Field: release The callback used to remove a retain previously added
24/// for the dictionary from keys as their values are removed from
25/// the dictionary. The dictionary's allocator is passed as the
26/// first argument.
27/// Field: copyDescription The callback used to create a descriptive
28/// string representation of each key in the dictionary. This
29/// is used by the CFCopyDescription() function.
30/// Field: equal The callback used to compare keys in the dictionary for
31/// equality.
32/// Field: hash The callback used to compute a hash code for keys as they
33/// are used to access, add, or remove values in the dictionary.
34///
35/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryretaincallback?language=objc)
36pub type CFDictionaryRetainCallBack =
37    Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void) -> *const c_void>;
38
39/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryreleasecallback?language=objc)
40pub type CFDictionaryReleaseCallBack =
41    Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void)>;
42
43/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionarycopydescriptioncallback?language=objc)
44pub type CFDictionaryCopyDescriptionCallBack =
45    Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;
46
47/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryequalcallback?language=objc)
48pub type CFDictionaryEqualCallBack =
49    Option<unsafe extern "C-unwind" fn(*const c_void, *const c_void) -> Boolean>;
50
51/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryhashcallback?language=objc)
52pub type CFDictionaryHashCallBack =
53    Option<unsafe extern "C-unwind" fn(*const c_void) -> CFHashCode>;
54
55/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionarykeycallbacks?language=objc)
56#[repr(C)]
57#[allow(unpredictable_function_pointer_comparisons)]
58#[derive(Clone, Copy, Debug, PartialEq)]
59pub struct CFDictionaryKeyCallBacks {
60    pub version: CFIndex,
61    pub retain: CFDictionaryRetainCallBack,
62    pub release: CFDictionaryReleaseCallBack,
63    pub copyDescription: CFDictionaryCopyDescriptionCallBack,
64    pub equal: CFDictionaryEqualCallBack,
65    pub hash: CFDictionaryHashCallBack,
66}
67
68#[cfg(feature = "objc2")]
69unsafe impl Encode for CFDictionaryKeyCallBacks {
70    const ENCODING: Encoding = Encoding::Struct(
71        "?",
72        &[
73            <CFIndex>::ENCODING,
74            <CFDictionaryRetainCallBack>::ENCODING,
75            <CFDictionaryReleaseCallBack>::ENCODING,
76            <CFDictionaryCopyDescriptionCallBack>::ENCODING,
77            <CFDictionaryEqualCallBack>::ENCODING,
78            <CFDictionaryHashCallBack>::ENCODING,
79        ],
80    );
81}
82
83#[cfg(feature = "objc2")]
84unsafe impl RefEncode for CFDictionaryKeyCallBacks {
85    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
86}
87
88extern "C" {
89    /// Predefined CFDictionaryKeyCallBacks structure containing a
90    /// set of callbacks appropriate for use when the keys of a
91    /// CFDictionary are all CFTypes.
92    ///
93    /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcftypedictionarykeycallbacks?language=objc)
94    pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
95}
96
97extern "C" {
98    /// Predefined CFDictionaryKeyCallBacks structure containing a
99    /// set of callbacks appropriate for use when the keys of a
100    /// CFDictionary are all CFStrings, which may be mutable and
101    /// need to be copied in order to serve as constant keys for
102    /// the values in the dictionary.
103    ///
104    /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfcopystringdictionarykeycallbacks?language=objc)
105    pub static kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
106}
107
108/// Structure containing the callbacks for values of a CFDictionary.
109/// Field: version The version number of the structure type being passed
110/// in as a parameter to the CFDictionary creation functions.
111/// This structure is version 0.
112/// Field: retain The callback used to add a retain for the dictionary
113/// on values as they are put into the dictionary.
114/// This callback returns the value to use as the value in the
115/// dictionary, which is usually the value parameter passed to
116/// this callback, but may be a different value if a different
117/// value should be added to the dictionary. The dictionary's
118/// allocator is passed as the first argument.
119/// Field: release The callback used to remove a retain previously added
120/// for the dictionary from values as they are removed from
121/// the dictionary. The dictionary's allocator is passed as the
122/// first argument.
123/// Field: copyDescription The callback used to create a descriptive
124/// string representation of each value in the dictionary. This
125/// is used by the CFCopyDescription() function.
126/// Field: equal The callback used to compare values in the dictionary for
127/// equality in some operations.
128///
129/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryvaluecallbacks?language=objc)
130#[repr(C)]
131#[allow(unpredictable_function_pointer_comparisons)]
132#[derive(Clone, Copy, Debug, PartialEq)]
133pub struct CFDictionaryValueCallBacks {
134    pub version: CFIndex,
135    pub retain: CFDictionaryRetainCallBack,
136    pub release: CFDictionaryReleaseCallBack,
137    pub copyDescription: CFDictionaryCopyDescriptionCallBack,
138    pub equal: CFDictionaryEqualCallBack,
139}
140
141#[cfg(feature = "objc2")]
142unsafe impl Encode for CFDictionaryValueCallBacks {
143    const ENCODING: Encoding = Encoding::Struct(
144        "?",
145        &[
146            <CFIndex>::ENCODING,
147            <CFDictionaryRetainCallBack>::ENCODING,
148            <CFDictionaryReleaseCallBack>::ENCODING,
149            <CFDictionaryCopyDescriptionCallBack>::ENCODING,
150            <CFDictionaryEqualCallBack>::ENCODING,
151        ],
152    );
153}
154
155#[cfg(feature = "objc2")]
156unsafe impl RefEncode for CFDictionaryValueCallBacks {
157    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
158}
159
160extern "C" {
161    /// Predefined CFDictionaryValueCallBacks structure containing a set
162    /// of callbacks appropriate for use when the values in a CFDictionary
163    /// are all CFTypes.
164    ///
165    /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcftypedictionaryvaluecallbacks?language=objc)
166    pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks;
167}
168
169/// Type of the callback function used by the apply functions of
170/// CFDictionarys.
171///
172/// Parameter `key`: The current key for the value.
173///
174/// Parameter `value`: The current value from the dictionary.
175///
176/// Parameter `context`: The user-defined context parameter given to the apply
177/// function.
178///
179/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionaryapplierfunction?language=objc)
180pub type CFDictionaryApplierFunction =
181    Option<unsafe extern "C-unwind" fn(*const c_void, *const c_void, *mut c_void)>;
182
183/// This is the type of a reference to immutable CFDictionarys.
184///
185/// This is toll-free bridged with `NSDictionary`.
186///
187/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdictionary?language=objc)
188#[doc(alias = "CFDictionaryRef")]
189#[repr(C)]
190pub struct CFDictionary<K: ?Sized = Opaque, V: ?Sized = Opaque> {
191    inner: [u8; 0],
192    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
193    _generics: PhantomData<(*mut K, *mut V)>,
194}
195
196cf_type!(
197    unsafe impl<K: ?Sized, V: ?Sized> CFDictionary<K, V> {}
198);
199#[cfg(feature = "objc2")]
200cf_objc2_type!(
201    unsafe impl<K: ?Sized, V: ?Sized> RefEncode<"__CFDictionary"> for CFDictionary<K, V> {}
202);
203
204impl<K: ?Sized, V: ?Sized> CFDictionary<K, V> {
205    /// Unchecked conversion of the generic parameters.
206    ///
207    /// # Safety
208    ///
209    /// The generics must be valid to reinterpret as the given types.
210    #[inline]
211    pub unsafe fn cast_unchecked<NewK: ?Sized, NewV: ?Sized>(&self) -> &CFDictionary<NewK, NewV> {
212        unsafe { &*((self as *const Self).cast()) }
213    }
214
215    /// Convert to the opaque/untyped variant.
216    #[inline]
217    pub fn as_opaque(&self) -> &CFDictionary {
218        unsafe { self.cast_unchecked() }
219    }
220}
221
222/// This is the type of a reference to mutable CFDictionarys.
223///
224/// This is toll-free bridged with `NSMutableDictionary`.
225///
226/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutabledictionary?language=objc)
227#[doc(alias = "CFMutableDictionaryRef")]
228#[repr(C)]
229pub struct CFMutableDictionary<K: ?Sized = Opaque, V: ?Sized = Opaque> {
230    inner: [u8; 0],
231    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
232    _generics: PhantomData<(*mut K, *mut V)>,
233}
234
235cf_type!(
236    unsafe impl<K: ?Sized, V: ?Sized> CFMutableDictionary<K, V>: CFDictionary<K, V> {}
237);
238#[cfg(feature = "objc2")]
239cf_objc2_type!(
240    unsafe impl<K: ?Sized, V: ?Sized> RefEncode<"__CFDictionary"> for CFMutableDictionary<K, V> {}
241);
242
243impl<K: ?Sized, V: ?Sized> CFMutableDictionary<K, V> {
244    /// Unchecked conversion of the generic parameters.
245    ///
246    /// # Safety
247    ///
248    /// The generics must be valid to reinterpret as the given types.
249    #[inline]
250    pub unsafe fn cast_unchecked<NewK: ?Sized, NewV: ?Sized>(
251        &self,
252    ) -> &CFMutableDictionary<NewK, NewV> {
253        unsafe { &*((self as *const Self).cast()) }
254    }
255
256    /// Convert to the opaque/untyped variant.
257    #[inline]
258    pub fn as_opaque(&self) -> &CFMutableDictionary {
259        unsafe { self.cast_unchecked() }
260    }
261}
262
263unsafe impl ConcreteType for CFDictionary {
264    /// Returns the type identifier of all CFDictionary instances.
265    #[doc(alias = "CFDictionaryGetTypeID")]
266    #[inline]
267    fn type_id() -> CFTypeID {
268        extern "C-unwind" {
269            fn CFDictionaryGetTypeID() -> CFTypeID;
270        }
271        unsafe { CFDictionaryGetTypeID() }
272    }
273}
274
275impl CFDictionary {
276    /// Creates a new immutable dictionary with the given values.
277    ///
278    /// Parameter `allocator`: The CFAllocator which should be used to allocate
279    /// memory for the dictionary and its storage for values. This
280    /// parameter may be NULL in which case the current default
281    /// CFAllocator is used. If this reference is not a valid
282    /// CFAllocator, the behavior is undefined.
283    ///
284    /// Parameter `keys`: A C array of the pointer-sized keys to be used for
285    /// the parallel C array of values to be put into the dictionary.
286    /// This parameter may be NULL if the numValues parameter is 0.
287    /// This C array is not changed or freed by this function. If
288    /// this parameter is not a valid pointer to a C array of at
289    /// least numValues pointers, the behavior is undefined.
290    ///
291    /// Parameter `values`: A C array of the pointer-sized values to be in the
292    /// dictionary. This parameter may be NULL if the numValues
293    /// parameter is 0. This C array is not changed or freed by
294    /// this function. If this parameter is not a valid pointer to
295    /// a C array of at least numValues pointers, the behavior is
296    /// undefined.
297    ///
298    /// Parameter `numValues`: The number of values to copy from the keys and
299    /// values C arrays into the CFDictionary. This number will be
300    /// the count of the dictionary. If this parameter is
301    /// negative, or greater than the number of values actually
302    /// in the keys or values C arrays, the behavior is undefined.
303    ///
304    /// Parameter `keyCallBacks`: A pointer to a CFDictionaryKeyCallBacks structure
305    /// initialized with the callbacks for the dictionary to use on
306    /// each key in the dictionary. The retain callback will be used
307    /// within this function, for example, to retain all of the new
308    /// keys from the keys C array. A copy of the contents of the
309    /// callbacks structure is made, so that a pointer to a structure
310    /// on the stack can be passed in, or can be reused for multiple
311    /// dictionary creations. If the version field of this
312    /// callbacks structure is not one of the defined ones for
313    /// CFDictionary, the behavior is undefined. The retain field may
314    /// be NULL, in which case the CFDictionary will do nothing to add
315    /// a retain to the keys of the contained values. The release field
316    /// may be NULL, in which case the CFDictionary will do nothing
317    /// to remove the dictionary's retain (if any) on the keys when the
318    /// dictionary is destroyed or a key-value pair is removed. If the
319    /// copyDescription field is NULL, the dictionary will create a
320    /// simple description for a key. If the equal field is NULL, the
321    /// dictionary will use pointer equality to test for equality of
322    /// keys. If the hash field is NULL, a key will be converted from
323    /// a pointer to an integer to compute the hash code. This callbacks
324    /// parameter itself may be NULL, which is treated as if a valid
325    /// structure of version 0 with all fields NULL had been passed in.
326    /// Otherwise, if any of the fields are not valid pointers to
327    /// functions of the correct type, or this parameter is not a
328    /// valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
329    /// the behavior is undefined. If any of the keys put into the
330    /// dictionary is not one understood by one of the callback functions
331    /// the behavior when that callback function is used is undefined.
332    ///
333    /// Parameter `valueCallBacks`: A pointer to a CFDictionaryValueCallBacks structure
334    /// initialized with the callbacks for the dictionary to use on
335    /// each value in the dictionary. The retain callback will be used
336    /// within this function, for example, to retain all of the new
337    /// values from the values C array. A copy of the contents of the
338    /// callbacks structure is made, so that a pointer to a structure
339    /// on the stack can be passed in, or can be reused for multiple
340    /// dictionary creations. If the version field of this callbacks
341    /// structure is not one of the defined ones for CFDictionary, the
342    /// behavior is undefined. The retain field may be NULL, in which
343    /// case the CFDictionary will do nothing to add a retain to values
344    /// as they are put into the dictionary. The release field may be
345    /// NULL, in which case the CFDictionary will do nothing to remove
346    /// the dictionary's retain (if any) on the values when the
347    /// dictionary is destroyed or a key-value pair is removed. If the
348    /// copyDescription field is NULL, the dictionary will create a
349    /// simple description for a value. If the equal field is NULL, the
350    /// dictionary will use pointer equality to test for equality of
351    /// values. This callbacks parameter itself may be NULL, which is
352    /// treated as if a valid structure of version 0 with all fields
353    /// NULL had been passed in. Otherwise,
354    /// if any of the fields are not valid pointers to functions
355    /// of the correct type, or this parameter is not a valid
356    /// pointer to a CFDictionaryValueCallBacks callbacks structure,
357    /// the behavior is undefined. If any of the values put into the
358    /// dictionary is not one understood by one of the callback functions
359    /// the behavior when that callback function is used is undefined.
360    ///
361    /// Returns: A reference to the new immutable CFDictionary.
362    ///
363    /// # Safety
364    ///
365    /// - `allocator` might not allow `None`.
366    /// - `keys` must be a valid pointer.
367    /// - `values` must be a valid pointer.
368    /// - `key_call_backs` must be a valid pointer.
369    /// - `value_call_backs` must be a valid pointer.
370    #[doc(alias = "CFDictionaryCreate")]
371    #[inline]
372    pub unsafe fn new(
373        allocator: Option<&CFAllocator>,
374        keys: *mut *const c_void,
375        values: *mut *const c_void,
376        num_values: CFIndex,
377        key_call_backs: *const CFDictionaryKeyCallBacks,
378        value_call_backs: *const CFDictionaryValueCallBacks,
379    ) -> Option<CFRetained<CFDictionary>> {
380        extern "C-unwind" {
381            fn CFDictionaryCreate(
382                allocator: Option<&CFAllocator>,
383                keys: *mut *const c_void,
384                values: *mut *const c_void,
385                num_values: CFIndex,
386                key_call_backs: *const CFDictionaryKeyCallBacks,
387                value_call_backs: *const CFDictionaryValueCallBacks,
388            ) -> Option<NonNull<CFDictionary>>;
389        }
390        let ret = unsafe {
391            CFDictionaryCreate(
392                allocator,
393                keys,
394                values,
395                num_values,
396                key_call_backs,
397                value_call_backs,
398            )
399        };
400        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
401    }
402
403    /// Creates a new immutable dictionary with the key-value pairs from
404    /// the given dictionary.
405    ///
406    /// Parameter `allocator`: The CFAllocator which should be used to allocate
407    /// memory for the dictionary and its storage for values. This
408    /// parameter may be NULL in which case the current default
409    /// CFAllocator is used. If this reference is not a valid
410    /// CFAllocator, the behavior is undefined.
411    ///
412    /// Parameter `theDict`: The dictionary which is to be copied. The keys and values
413    /// from the dictionary are copied as pointers into the new
414    /// dictionary (that is, the values themselves are copied, not
415    /// that which the values point to, if anything). However, the
416    /// keys and values are also retained by the new dictionary using
417    /// the retain function of the original dictionary.
418    /// The count of the new dictionary will be the same as the
419    /// given dictionary. The new dictionary uses the same callbacks
420    /// as the dictionary to be copied. If this parameter is
421    /// not a valid CFDictionary, the behavior is undefined.
422    ///
423    /// Returns: A reference to the new immutable CFDictionary.
424    #[doc(alias = "CFDictionaryCreateCopy")]
425    #[inline]
426    pub fn new_copy(
427        allocator: Option<&CFAllocator>,
428        the_dict: Option<&CFDictionary>,
429    ) -> Option<CFRetained<CFDictionary>> {
430        extern "C-unwind" {
431            fn CFDictionaryCreateCopy(
432                allocator: Option<&CFAllocator>,
433                the_dict: Option<&CFDictionary>,
434            ) -> Option<NonNull<CFDictionary>>;
435        }
436        let ret = unsafe { CFDictionaryCreateCopy(allocator, the_dict) };
437        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
438    }
439}
440
441impl CFMutableDictionary {
442    /// Creates a new mutable dictionary.
443    ///
444    /// Parameter `allocator`: The CFAllocator which should be used to allocate
445    /// memory for the dictionary and its storage for values. This
446    /// parameter may be NULL in which case the current default
447    /// CFAllocator is used. If this reference is not a valid
448    /// CFAllocator, the behavior is undefined.
449    ///
450    /// Parameter `capacity`: A hint about the number of values that will be held
451    /// by the CFDictionary. Pass 0 for no hint. The implementation may
452    /// ignore this hint, or may use it to optimize various
453    /// operations. A dictionary's actual capacity is only limited by
454    /// address space and available memory constraints). If this
455    /// parameter is negative, the behavior is undefined.
456    ///
457    /// Parameter `keyCallBacks`: A pointer to a CFDictionaryKeyCallBacks structure
458    /// initialized with the callbacks for the dictionary to use on
459    /// each key in the dictionary. A copy of the contents of the
460    /// callbacks structure is made, so that a pointer to a structure
461    /// on the stack can be passed in, or can be reused for multiple
462    /// dictionary creations. If the version field of this
463    /// callbacks structure is not one of the defined ones for
464    /// CFDictionary, the behavior is undefined. The retain field may
465    /// be NULL, in which case the CFDictionary will do nothing to add
466    /// a retain to the keys of the contained values. The release field
467    /// may be NULL, in which case the CFDictionary will do nothing
468    /// to remove the dictionary's retain (if any) on the keys when the
469    /// dictionary is destroyed or a key-value pair is removed. If the
470    /// copyDescription field is NULL, the dictionary will create a
471    /// simple description for a key. If the equal field is NULL, the
472    /// dictionary will use pointer equality to test for equality of
473    /// keys. If the hash field is NULL, a key will be converted from
474    /// a pointer to an integer to compute the hash code. This callbacks
475    /// parameter itself may be NULL, which is treated as if a valid
476    /// structure of version 0 with all fields NULL had been passed in.
477    /// Otherwise, if any of the fields are not valid pointers to
478    /// functions of the correct type, or this parameter is not a
479    /// valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
480    /// the behavior is undefined. If any of the keys put into the
481    /// dictionary is not one understood by one of the callback functions
482    /// the behavior when that callback function is used is undefined.
483    ///
484    /// Parameter `valueCallBacks`: A pointer to a CFDictionaryValueCallBacks structure
485    /// initialized with the callbacks for the dictionary to use on
486    /// each value in the dictionary. The retain callback will be used
487    /// within this function, for example, to retain all of the new
488    /// values from the values C array. A copy of the contents of the
489    /// callbacks structure is made, so that a pointer to a structure
490    /// on the stack can be passed in, or can be reused for multiple
491    /// dictionary creations. If the version field of this callbacks
492    /// structure is not one of the defined ones for CFDictionary, the
493    /// behavior is undefined. The retain field may be NULL, in which
494    /// case the CFDictionary will do nothing to add a retain to values
495    /// as they are put into the dictionary. The release field may be
496    /// NULL, in which case the CFDictionary will do nothing to remove
497    /// the dictionary's retain (if any) on the values when the
498    /// dictionary is destroyed or a key-value pair is removed. If the
499    /// copyDescription field is NULL, the dictionary will create a
500    /// simple description for a value. If the equal field is NULL, the
501    /// dictionary will use pointer equality to test for equality of
502    /// values. This callbacks parameter itself may be NULL, which is
503    /// treated as if a valid structure of version 0 with all fields
504    /// NULL had been passed in. Otherwise,
505    /// if any of the fields are not valid pointers to functions
506    /// of the correct type, or this parameter is not a valid
507    /// pointer to a CFDictionaryValueCallBacks callbacks structure,
508    /// the behavior is undefined. If any of the values put into the
509    /// dictionary is not one understood by one of the callback functions
510    /// the behavior when that callback function is used is undefined.
511    ///
512    /// Returns: A reference to the new mutable CFDictionary.
513    ///
514    /// # Safety
515    ///
516    /// - `allocator` might not allow `None`.
517    /// - `key_call_backs` must be a valid pointer.
518    /// - `value_call_backs` must be a valid pointer.
519    /// - The returned generics must be of the correct type.
520    #[doc(alias = "CFDictionaryCreateMutable")]
521    #[inline]
522    pub unsafe fn new(
523        allocator: Option<&CFAllocator>,
524        capacity: CFIndex,
525        key_call_backs: *const CFDictionaryKeyCallBacks,
526        value_call_backs: *const CFDictionaryValueCallBacks,
527    ) -> Option<CFRetained<CFMutableDictionary>> {
528        extern "C-unwind" {
529            fn CFDictionaryCreateMutable(
530                allocator: Option<&CFAllocator>,
531                capacity: CFIndex,
532                key_call_backs: *const CFDictionaryKeyCallBacks,
533                value_call_backs: *const CFDictionaryValueCallBacks,
534            ) -> Option<NonNull<CFMutableDictionary>>;
535        }
536        let ret = unsafe {
537            CFDictionaryCreateMutable(allocator, capacity, key_call_backs, value_call_backs)
538        };
539        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
540    }
541
542    /// Creates a new mutable dictionary with the key-value pairs from
543    /// the given dictionary.
544    ///
545    /// Parameter `allocator`: The CFAllocator which should be used to allocate
546    /// memory for the dictionary and its storage for values. This
547    /// parameter may be NULL in which case the current default
548    /// CFAllocator is used. If this reference is not a valid
549    /// CFAllocator, the behavior is undefined.
550    ///
551    /// Parameter `capacity`: A hint about the number of values that will be held
552    /// by the CFDictionary. Pass 0 for no hint. The implementation may
553    /// ignore this hint, or may use it to optimize various
554    /// operations. A dictionary's actual capacity is only limited by
555    /// address space and available memory constraints).
556    /// This parameter must be greater than or equal
557    /// to the count of the dictionary which is to be copied, or the
558    /// behavior is undefined. If this parameter is negative, the
559    /// behavior is undefined.
560    ///
561    /// Parameter `theDict`: The dictionary which is to be copied. The keys and values
562    /// from the dictionary are copied as pointers into the new
563    /// dictionary (that is, the values themselves are copied, not
564    /// that which the values point to, if anything). However, the
565    /// keys and values are also retained by the new dictionary using
566    /// the retain function of the original dictionary.
567    /// The count of the new dictionary will be the same as the
568    /// given dictionary. The new dictionary uses the same callbacks
569    /// as the dictionary to be copied. If this parameter is
570    /// not a valid CFDictionary, the behavior is undefined.
571    ///
572    /// Returns: A reference to the new mutable CFDictionary.
573    ///
574    /// # Safety
575    ///
576    /// - `allocator` might not allow `None`.
577    /// - `the_dict` generics must be of the correct type.
578    /// - `the_dict` might not allow `None`.
579    /// - The returned generics must be of the correct type.
580    #[doc(alias = "CFDictionaryCreateMutableCopy")]
581    #[inline]
582    pub unsafe fn new_copy(
583        allocator: Option<&CFAllocator>,
584        capacity: CFIndex,
585        the_dict: Option<&CFDictionary>,
586    ) -> Option<CFRetained<CFMutableDictionary>> {
587        extern "C-unwind" {
588            fn CFDictionaryCreateMutableCopy(
589                allocator: Option<&CFAllocator>,
590                capacity: CFIndex,
591                the_dict: Option<&CFDictionary>,
592            ) -> Option<NonNull<CFMutableDictionary>>;
593        }
594        let ret = unsafe { CFDictionaryCreateMutableCopy(allocator, capacity, the_dict) };
595        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
596    }
597}
598
599impl CFDictionary {
600    /// Returns the number of values currently in the dictionary.
601    ///
602    /// Parameter `theDict`: The dictionary to be queried. If this parameter is
603    /// not a valid CFDictionary, the behavior is undefined.
604    ///
605    /// Returns: The number of values in the dictionary.
606    #[doc(alias = "CFDictionaryGetCount")]
607    #[inline]
608    pub fn count(&self) -> CFIndex {
609        extern "C-unwind" {
610            fn CFDictionaryGetCount(the_dict: &CFDictionary) -> CFIndex;
611        }
612        unsafe { CFDictionaryGetCount(self) }
613    }
614
615    /// Counts the number of times the given key occurs in the dictionary.
616    ///
617    /// Parameter `theDict`: The dictionary to be searched. If this parameter is
618    /// not a valid CFDictionary, the behavior is undefined.
619    ///
620    /// Parameter `key`: The key for which to find matches in the dictionary. The
621    /// hash() and equal() key callbacks provided when the dictionary
622    /// was created are used to compare. If the hash() key callback
623    /// was NULL, the key is treated as a pointer and converted to
624    /// an integer. If the equal() key callback was NULL, pointer
625    /// equality (in C, ==) is used. If key, or any of the keys in
626    /// the dictionary, are not understood by the equal() callback,
627    /// the behavior is undefined.
628    ///
629    /// Returns: Returns 1 if a matching key is used by the dictionary,
630    /// 0 otherwise.
631    ///
632    /// # Safety
633    ///
634    /// - `the_dict` generics must be of the correct type.
635    /// - `key` must be a valid pointer.
636    #[doc(alias = "CFDictionaryGetCountOfKey")]
637    #[inline]
638    pub unsafe fn count_of_key(&self, key: *const c_void) -> CFIndex {
639        extern "C-unwind" {
640            fn CFDictionaryGetCountOfKey(the_dict: &CFDictionary, key: *const c_void) -> CFIndex;
641        }
642        unsafe { CFDictionaryGetCountOfKey(self, key) }
643    }
644
645    /// Counts the number of times the given value occurs in the dictionary.
646    ///
647    /// Parameter `theDict`: The dictionary to be searched. If this parameter is
648    /// not a valid CFDictionary, the behavior is undefined.
649    ///
650    /// Parameter `value`: The value for which to find matches in the dictionary. The
651    /// equal() callback provided when the dictionary was created is
652    /// used to compare. If the equal() value callback was NULL, pointer
653    /// equality (in C, ==) is used. If value, or any of the values in
654    /// the dictionary, are not understood by the equal() callback,
655    /// the behavior is undefined.
656    ///
657    /// Returns: The number of times the given value occurs in the dictionary.
658    ///
659    /// # Safety
660    ///
661    /// - `the_dict` generics must be of the correct type.
662    /// - `value` must be a valid pointer.
663    #[doc(alias = "CFDictionaryGetCountOfValue")]
664    #[inline]
665    pub unsafe fn count_of_value(&self, value: *const c_void) -> CFIndex {
666        extern "C-unwind" {
667            fn CFDictionaryGetCountOfValue(
668                the_dict: &CFDictionary,
669                value: *const c_void,
670            ) -> CFIndex;
671        }
672        unsafe { CFDictionaryGetCountOfValue(self, value) }
673    }
674
675    /// Reports whether or not the key is in the dictionary.
676    ///
677    /// Parameter `theDict`: The dictionary to be searched. If this parameter is
678    /// not a valid CFDictionary, the behavior is undefined.
679    ///
680    /// Parameter `key`: The key for which to find matches in the dictionary. The
681    /// hash() and equal() key callbacks provided when the dictionary
682    /// was created are used to compare. If the hash() key callback
683    /// was NULL, the key is treated as a pointer and converted to
684    /// an integer. If the equal() key callback was NULL, pointer
685    /// equality (in C, ==) is used. If key, or any of the keys in
686    /// the dictionary, are not understood by the equal() callback,
687    /// the behavior is undefined.
688    ///
689    /// Returns: true, if the key is in the dictionary, otherwise false.
690    ///
691    /// # Safety
692    ///
693    /// - `the_dict` generics must be of the correct type.
694    /// - `key` must be a valid pointer.
695    #[doc(alias = "CFDictionaryContainsKey")]
696    #[inline]
697    pub unsafe fn contains_ptr_key(&self, key: *const c_void) -> bool {
698        extern "C-unwind" {
699            fn CFDictionaryContainsKey(the_dict: &CFDictionary, key: *const c_void) -> Boolean;
700        }
701        let ret = unsafe { CFDictionaryContainsKey(self, key) };
702        ret != 0
703    }
704
705    /// Reports whether or not the value is in the dictionary.
706    ///
707    /// Parameter `theDict`: The dictionary to be searched. If this parameter is
708    /// not a valid CFDictionary, the behavior is undefined.
709    ///
710    /// Parameter `value`: The value for which to find matches in the dictionary. The
711    /// equal() callback provided when the dictionary was created is
712    /// used to compare. If the equal() callback was NULL, pointer
713    /// equality (in C, ==) is used. If value, or any of the values
714    /// in the dictionary, are not understood by the equal() callback,
715    /// the behavior is undefined.
716    ///
717    /// Returns: true, if the value is in the dictionary, otherwise false.
718    ///
719    /// # Safety
720    ///
721    /// - `the_dict` generics must be of the correct type.
722    /// - `value` must be a valid pointer.
723    #[doc(alias = "CFDictionaryContainsValue")]
724    #[inline]
725    pub unsafe fn contains_ptr_value(&self, value: *const c_void) -> bool {
726        extern "C-unwind" {
727            fn CFDictionaryContainsValue(the_dict: &CFDictionary, value: *const c_void) -> Boolean;
728        }
729        let ret = unsafe { CFDictionaryContainsValue(self, value) };
730        ret != 0
731    }
732
733    /// Retrieves the value associated with the given key.
734    ///
735    /// Parameter `theDict`: The dictionary to be queried. If this parameter is
736    /// not a valid CFDictionary, the behavior is undefined.
737    ///
738    /// Parameter `key`: The key for which to find a match in the dictionary. The
739    /// hash() and equal() key callbacks provided when the dictionary
740    /// was created are used to compare. If the hash() key callback
741    /// was NULL, the key is treated as a pointer and converted to
742    /// an integer. If the equal() key callback was NULL, pointer
743    /// equality (in C, ==) is used. If key, or any of the keys in
744    /// the dictionary, are not understood by the equal() callback,
745    /// the behavior is undefined.
746    ///
747    /// Returns: The value with the given key in the dictionary, or NULL if
748    /// no key-value pair with a matching key exists. Since NULL
749    /// can be a valid value in some dictionaries, the function
750    /// CFDictionaryGetValueIfPresent() must be used to distinguish
751    /// NULL-no-found from NULL-is-the-value.
752    ///
753    /// # Safety
754    ///
755    /// - `the_dict` generics must be of the correct type.
756    /// - `key` must be a valid pointer.
757    #[doc(alias = "CFDictionaryGetValue")]
758    #[inline]
759    pub unsafe fn value(&self, key: *const c_void) -> *const c_void {
760        extern "C-unwind" {
761            fn CFDictionaryGetValue(the_dict: &CFDictionary, key: *const c_void) -> *const c_void;
762        }
763        unsafe { CFDictionaryGetValue(self, key) }
764    }
765
766    /// Retrieves the value associated with the given key.
767    ///
768    /// Parameter `theDict`: The dictionary to be queried. If this parameter is
769    /// not a valid CFDictionary, the behavior is undefined.
770    ///
771    /// Parameter `key`: The key for which to find a match in the dictionary. The
772    /// hash() and equal() key callbacks provided when the dictionary
773    /// was created are used to compare. If the hash() key callback
774    /// was NULL, the key is treated as a pointer and converted to
775    /// an integer. If the equal() key callback was NULL, pointer
776    /// equality (in C, ==) is used. If key, or any of the keys in
777    /// the dictionary, are not understood by the equal() callback,
778    /// the behavior is undefined.
779    ///
780    /// Parameter `value`: A pointer to memory which should be filled with the
781    /// pointer-sized value if a matching key is found. If no key
782    /// match is found, the contents of the storage pointed to by
783    /// this parameter are undefined. This parameter may be NULL,
784    /// in which case the value from the dictionary is not returned
785    /// (but the return value of this function still indicates
786    /// whether or not the key-value pair was present).
787    ///
788    /// Returns: true, if a matching key was found, false otherwise.
789    ///
790    /// # Safety
791    ///
792    /// - `the_dict` generics must be of the correct type.
793    /// - `key` must be a valid pointer.
794    /// - `value` must be a valid pointer.
795    #[doc(alias = "CFDictionaryGetValueIfPresent")]
796    #[inline]
797    pub unsafe fn value_if_present(&self, key: *const c_void, value: *mut *const c_void) -> bool {
798        extern "C-unwind" {
799            fn CFDictionaryGetValueIfPresent(
800                the_dict: &CFDictionary,
801                key: *const c_void,
802                value: *mut *const c_void,
803            ) -> Boolean;
804        }
805        let ret = unsafe { CFDictionaryGetValueIfPresent(self, key, value) };
806        ret != 0
807    }
808
809    /// Fills the two buffers with the keys and values from the dictionary.
810    ///
811    /// Parameter `theDict`: The dictionary to be queried. If this parameter is
812    /// not a valid CFDictionary, the behavior is undefined.
813    ///
814    /// Parameter `keys`: A C array of pointer-sized values to be filled with keys
815    /// from the dictionary. The keys and values C arrays are parallel
816    /// to each other (that is, the items at the same indices form a
817    /// key-value pair from the dictionary). This parameter may be NULL
818    /// if the keys are not desired. If this parameter is not a valid
819    /// pointer to a C array of at least CFDictionaryGetCount() pointers,
820    /// or NULL, the behavior is undefined.
821    ///
822    /// Parameter `values`: A C array of pointer-sized values to be filled with values
823    /// from the dictionary. The keys and values C arrays are parallel
824    /// to each other (that is, the items at the same indices form a
825    /// key-value pair from the dictionary). This parameter may be NULL
826    /// if the values are not desired. If this parameter is not a valid
827    /// pointer to a C array of at least CFDictionaryGetCount() pointers,
828    /// or NULL, the behavior is undefined.
829    ///
830    /// # Safety
831    ///
832    /// - `the_dict` generics must be of the correct type.
833    /// - `keys` must be a valid pointer.
834    /// - `values` must be a valid pointer.
835    #[doc(alias = "CFDictionaryGetKeysAndValues")]
836    #[inline]
837    pub unsafe fn keys_and_values(&self, keys: *mut *const c_void, values: *mut *const c_void) {
838        extern "C-unwind" {
839            fn CFDictionaryGetKeysAndValues(
840                the_dict: &CFDictionary,
841                keys: *mut *const c_void,
842                values: *mut *const c_void,
843            );
844        }
845        unsafe { CFDictionaryGetKeysAndValues(self, keys, values) }
846    }
847
848    /// Calls a function once for each value in the dictionary.
849    ///
850    /// Parameter `theDict`: The dictionary to be queried. If this parameter is
851    /// not a valid CFDictionary, the behavior is undefined.
852    ///
853    /// Parameter `applier`: The callback function to call once for each value in
854    /// the dictionary. If this parameter is not a
855    /// pointer to a function of the correct prototype, the behavior
856    /// is undefined. If there are keys or values which the
857    /// applier function does not expect or cannot properly apply
858    /// to, the behavior is undefined.
859    ///
860    /// Parameter `context`: A pointer-sized user-defined value, which is passed
861    /// as the third parameter to the applier function, but is
862    /// otherwise unused by this function. If the context is not
863    /// what is expected by the applier function, the behavior is
864    /// undefined.
865    ///
866    /// # Safety
867    ///
868    /// - `the_dict` generics must be of the correct type.
869    /// - `applier` must be implemented correctly.
870    /// - `context` must be a valid pointer.
871    #[doc(alias = "CFDictionaryApplyFunction")]
872    #[inline]
873    pub unsafe fn apply_function(
874        &self,
875        applier: CFDictionaryApplierFunction,
876        context: *mut c_void,
877    ) {
878        extern "C-unwind" {
879            fn CFDictionaryApplyFunction(
880                the_dict: &CFDictionary,
881                applier: CFDictionaryApplierFunction,
882                context: *mut c_void,
883            );
884        }
885        unsafe { CFDictionaryApplyFunction(self, applier, context) }
886    }
887}
888
889impl CFMutableDictionary {
890    /// Adds the key-value pair to the dictionary if no such key already exists.
891    ///
892    /// Parameter `theDict`: The dictionary to which the value is to be added. If this
893    /// parameter is not a valid mutable CFDictionary, the behavior is
894    /// undefined.
895    ///
896    /// Parameter `key`: The key of the value to add to the dictionary. The key is
897    /// retained by the dictionary using the retain callback provided
898    /// when the dictionary was created. If the key is not of the sort
899    /// expected by the retain callback, the behavior is undefined. If
900    /// a key which matches this key is already present in the dictionary,
901    /// this function does nothing ("add if absent").
902    ///
903    /// Parameter `value`: The value to add to the dictionary. The value is retained
904    /// by the dictionary using the retain callback provided when the
905    /// dictionary was created. If the value is not of the sort expected
906    /// by the retain callback, the behavior is undefined.
907    ///
908    /// # Safety
909    ///
910    /// - `the_dict` generics must be of the correct type.
911    /// - `the_dict` might not allow `None`.
912    /// - `key` must be a valid pointer.
913    /// - `value` must be a valid pointer.
914    #[doc(alias = "CFDictionaryAddValue")]
915    #[inline]
916    pub unsafe fn add_value(
917        the_dict: Option<&CFMutableDictionary>,
918        key: *const c_void,
919        value: *const c_void,
920    ) {
921        extern "C-unwind" {
922            fn CFDictionaryAddValue(
923                the_dict: Option<&CFMutableDictionary>,
924                key: *const c_void,
925                value: *const c_void,
926            );
927        }
928        unsafe { CFDictionaryAddValue(the_dict, key, value) }
929    }
930
931    /// Sets the value of the key in the dictionary.
932    ///
933    /// Parameter `theDict`: The dictionary to which the value is to be set. If this
934    /// parameter is not a valid mutable CFDictionary, the behavior is
935    /// undefined.
936    ///
937    /// Parameter `key`: The key of the value to set into the dictionary. If a key
938    /// which matches this key is already present in the dictionary, only
939    /// the value is changed ("add if absent, replace if present"). If
940    /// no key matches the given key, the key-value pair is added to the
941    /// dictionary. If added, the key is retained by the dictionary,
942    /// using the retain callback provided
943    /// when the dictionary was created. If the key is not of the sort
944    /// expected by the key retain callback, the behavior is undefined.
945    ///
946    /// Parameter `value`: The value to add to or replace into the dictionary. The value
947    /// is retained by the dictionary using the retain callback provided
948    /// when the dictionary was created, and the previous value if any is
949    /// released. If the value is not of the sort expected by the
950    /// retain or release callbacks, the behavior is undefined.
951    ///
952    /// # Safety
953    ///
954    /// - `the_dict` generics must be of the correct type.
955    /// - `the_dict` might not allow `None`.
956    /// - `key` must be a valid pointer.
957    /// - `value` must be a valid pointer.
958    #[doc(alias = "CFDictionarySetValue")]
959    #[inline]
960    pub unsafe fn set_value(
961        the_dict: Option<&CFMutableDictionary>,
962        key: *const c_void,
963        value: *const c_void,
964    ) {
965        extern "C-unwind" {
966            fn CFDictionarySetValue(
967                the_dict: Option<&CFMutableDictionary>,
968                key: *const c_void,
969                value: *const c_void,
970            );
971        }
972        unsafe { CFDictionarySetValue(the_dict, key, value) }
973    }
974
975    /// Replaces the value of the key in the dictionary.
976    ///
977    /// Parameter `theDict`: The dictionary to which the value is to be replaced. If this
978    /// parameter is not a valid mutable CFDictionary, the behavior is
979    /// undefined.
980    ///
981    /// Parameter `key`: The key of the value to replace in the dictionary. If a key
982    /// which matches this key is present in the dictionary, the value
983    /// is changed to the given value, otherwise this function does
984    /// nothing ("replace if present").
985    ///
986    /// Parameter `value`: The value to replace into the dictionary. The value
987    /// is retained by the dictionary using the retain callback provided
988    /// when the dictionary was created, and the previous value is
989    /// released. If the value is not of the sort expected by the
990    /// retain or release callbacks, the behavior is undefined.
991    ///
992    /// # Safety
993    ///
994    /// - `the_dict` generics must be of the correct type.
995    /// - `the_dict` might not allow `None`.
996    /// - `key` must be a valid pointer.
997    /// - `value` must be a valid pointer.
998    #[doc(alias = "CFDictionaryReplaceValue")]
999    #[inline]
1000    pub unsafe fn replace_value(
1001        the_dict: Option<&CFMutableDictionary>,
1002        key: *const c_void,
1003        value: *const c_void,
1004    ) {
1005        extern "C-unwind" {
1006            fn CFDictionaryReplaceValue(
1007                the_dict: Option<&CFMutableDictionary>,
1008                key: *const c_void,
1009                value: *const c_void,
1010            );
1011        }
1012        unsafe { CFDictionaryReplaceValue(the_dict, key, value) }
1013    }
1014
1015    /// Removes the value of the key from the dictionary.
1016    ///
1017    /// Parameter `theDict`: The dictionary from which the value is to be removed. If this
1018    /// parameter is not a valid mutable CFDictionary, the behavior is
1019    /// undefined.
1020    ///
1021    /// Parameter `key`: The key of the value to remove from the dictionary. If a key
1022    /// which matches this key is present in the dictionary, the key-value
1023    /// pair is removed from the dictionary, otherwise this function does
1024    /// nothing ("remove if present").
1025    ///
1026    /// # Safety
1027    ///
1028    /// - `the_dict` generics must be of the correct type.
1029    /// - `the_dict` might not allow `None`.
1030    /// - `key` must be a valid pointer.
1031    #[doc(alias = "CFDictionaryRemoveValue")]
1032    #[inline]
1033    pub unsafe fn remove_value(the_dict: Option<&CFMutableDictionary>, key: *const c_void) {
1034        extern "C-unwind" {
1035            fn CFDictionaryRemoveValue(the_dict: Option<&CFMutableDictionary>, key: *const c_void);
1036        }
1037        unsafe { CFDictionaryRemoveValue(the_dict, key) }
1038    }
1039
1040    /// Removes all the values from the dictionary, making it empty.
1041    ///
1042    /// Parameter `theDict`: The dictionary from which all of the values are to be
1043    /// removed. If this parameter is not a valid mutable
1044    /// CFDictionary, the behavior is undefined.
1045    #[doc(alias = "CFDictionaryRemoveAllValues")]
1046    #[inline]
1047    pub fn remove_all_values(the_dict: Option<&CFMutableDictionary>) {
1048        extern "C-unwind" {
1049            fn CFDictionaryRemoveAllValues(the_dict: Option<&CFMutableDictionary>);
1050        }
1051        unsafe { CFDictionaryRemoveAllValues(the_dict) }
1052    }
1053}
1054
1055#[deprecated = "renamed to `CFDictionary::new`"]
1056#[inline]
1057pub unsafe extern "C-unwind" fn CFDictionaryCreate(
1058    allocator: Option<&CFAllocator>,
1059    keys: *mut *const c_void,
1060    values: *mut *const c_void,
1061    num_values: CFIndex,
1062    key_call_backs: *const CFDictionaryKeyCallBacks,
1063    value_call_backs: *const CFDictionaryValueCallBacks,
1064) -> Option<CFRetained<CFDictionary>> {
1065    extern "C-unwind" {
1066        fn CFDictionaryCreate(
1067            allocator: Option<&CFAllocator>,
1068            keys: *mut *const c_void,
1069            values: *mut *const c_void,
1070            num_values: CFIndex,
1071            key_call_backs: *const CFDictionaryKeyCallBacks,
1072            value_call_backs: *const CFDictionaryValueCallBacks,
1073        ) -> Option<NonNull<CFDictionary>>;
1074    }
1075    let ret = unsafe {
1076        CFDictionaryCreate(
1077            allocator,
1078            keys,
1079            values,
1080            num_values,
1081            key_call_backs,
1082            value_call_backs,
1083        )
1084    };
1085    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1086}
1087
1088#[deprecated = "renamed to `CFDictionary::new_copy`"]
1089#[inline]
1090pub extern "C-unwind" fn CFDictionaryCreateCopy(
1091    allocator: Option<&CFAllocator>,
1092    the_dict: Option<&CFDictionary>,
1093) -> Option<CFRetained<CFDictionary>> {
1094    extern "C-unwind" {
1095        fn CFDictionaryCreateCopy(
1096            allocator: Option<&CFAllocator>,
1097            the_dict: Option<&CFDictionary>,
1098        ) -> Option<NonNull<CFDictionary>>;
1099    }
1100    let ret = unsafe { CFDictionaryCreateCopy(allocator, the_dict) };
1101    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1102}
1103
1104#[deprecated = "renamed to `CFMutableDictionary::new`"]
1105#[inline]
1106pub unsafe extern "C-unwind" fn CFDictionaryCreateMutable(
1107    allocator: Option<&CFAllocator>,
1108    capacity: CFIndex,
1109    key_call_backs: *const CFDictionaryKeyCallBacks,
1110    value_call_backs: *const CFDictionaryValueCallBacks,
1111) -> Option<CFRetained<CFMutableDictionary>> {
1112    extern "C-unwind" {
1113        fn CFDictionaryCreateMutable(
1114            allocator: Option<&CFAllocator>,
1115            capacity: CFIndex,
1116            key_call_backs: *const CFDictionaryKeyCallBacks,
1117            value_call_backs: *const CFDictionaryValueCallBacks,
1118        ) -> Option<NonNull<CFMutableDictionary>>;
1119    }
1120    let ret =
1121        unsafe { CFDictionaryCreateMutable(allocator, capacity, key_call_backs, value_call_backs) };
1122    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1123}
1124
1125#[deprecated = "renamed to `CFMutableDictionary::new_copy`"]
1126#[inline]
1127pub unsafe extern "C-unwind" fn CFDictionaryCreateMutableCopy(
1128    allocator: Option<&CFAllocator>,
1129    capacity: CFIndex,
1130    the_dict: Option<&CFDictionary>,
1131) -> Option<CFRetained<CFMutableDictionary>> {
1132    extern "C-unwind" {
1133        fn CFDictionaryCreateMutableCopy(
1134            allocator: Option<&CFAllocator>,
1135            capacity: CFIndex,
1136            the_dict: Option<&CFDictionary>,
1137        ) -> Option<NonNull<CFMutableDictionary>>;
1138    }
1139    let ret = unsafe { CFDictionaryCreateMutableCopy(allocator, capacity, the_dict) };
1140    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1141}
1142
1143#[deprecated = "renamed to `CFDictionary::count`"]
1144#[inline]
1145pub extern "C-unwind" fn CFDictionaryGetCount(the_dict: &CFDictionary) -> CFIndex {
1146    extern "C-unwind" {
1147        fn CFDictionaryGetCount(the_dict: &CFDictionary) -> CFIndex;
1148    }
1149    unsafe { CFDictionaryGetCount(the_dict) }
1150}
1151
1152extern "C-unwind" {
1153    #[deprecated = "renamed to `CFDictionary::count_of_key`"]
1154    pub fn CFDictionaryGetCountOfKey(the_dict: &CFDictionary, key: *const c_void) -> CFIndex;
1155}
1156
1157extern "C-unwind" {
1158    #[deprecated = "renamed to `CFDictionary::count_of_value`"]
1159    pub fn CFDictionaryGetCountOfValue(the_dict: &CFDictionary, value: *const c_void) -> CFIndex;
1160}
1161
1162#[deprecated = "renamed to `CFDictionary::contains_ptr_key`"]
1163#[inline]
1164pub unsafe extern "C-unwind" fn CFDictionaryContainsKey(
1165    the_dict: &CFDictionary,
1166    key: *const c_void,
1167) -> bool {
1168    extern "C-unwind" {
1169        fn CFDictionaryContainsKey(the_dict: &CFDictionary, key: *const c_void) -> Boolean;
1170    }
1171    let ret = unsafe { CFDictionaryContainsKey(the_dict, key) };
1172    ret != 0
1173}
1174
1175#[deprecated = "renamed to `CFDictionary::contains_ptr_value`"]
1176#[inline]
1177pub unsafe extern "C-unwind" fn CFDictionaryContainsValue(
1178    the_dict: &CFDictionary,
1179    value: *const c_void,
1180) -> bool {
1181    extern "C-unwind" {
1182        fn CFDictionaryContainsValue(the_dict: &CFDictionary, value: *const c_void) -> Boolean;
1183    }
1184    let ret = unsafe { CFDictionaryContainsValue(the_dict, value) };
1185    ret != 0
1186}
1187
1188extern "C-unwind" {
1189    #[deprecated = "renamed to `CFDictionary::value`"]
1190    pub fn CFDictionaryGetValue(the_dict: &CFDictionary, key: *const c_void) -> *const c_void;
1191}
1192
1193#[deprecated = "renamed to `CFDictionary::value_if_present`"]
1194#[inline]
1195pub unsafe extern "C-unwind" fn CFDictionaryGetValueIfPresent(
1196    the_dict: &CFDictionary,
1197    key: *const c_void,
1198    value: *mut *const c_void,
1199) -> bool {
1200    extern "C-unwind" {
1201        fn CFDictionaryGetValueIfPresent(
1202            the_dict: &CFDictionary,
1203            key: *const c_void,
1204            value: *mut *const c_void,
1205        ) -> Boolean;
1206    }
1207    let ret = unsafe { CFDictionaryGetValueIfPresent(the_dict, key, value) };
1208    ret != 0
1209}
1210
1211extern "C-unwind" {
1212    #[deprecated = "renamed to `CFDictionary::keys_and_values`"]
1213    pub fn CFDictionaryGetKeysAndValues(
1214        the_dict: &CFDictionary,
1215        keys: *mut *const c_void,
1216        values: *mut *const c_void,
1217    );
1218}
1219
1220extern "C-unwind" {
1221    #[deprecated = "renamed to `CFDictionary::apply_function`"]
1222    pub fn CFDictionaryApplyFunction(
1223        the_dict: &CFDictionary,
1224        applier: CFDictionaryApplierFunction,
1225        context: *mut c_void,
1226    );
1227}
1228
1229extern "C-unwind" {
1230    #[deprecated = "renamed to `CFMutableDictionary::add_value`"]
1231    pub fn CFDictionaryAddValue(
1232        the_dict: Option<&CFMutableDictionary>,
1233        key: *const c_void,
1234        value: *const c_void,
1235    );
1236}
1237
1238extern "C-unwind" {
1239    #[deprecated = "renamed to `CFMutableDictionary::set_value`"]
1240    pub fn CFDictionarySetValue(
1241        the_dict: Option<&CFMutableDictionary>,
1242        key: *const c_void,
1243        value: *const c_void,
1244    );
1245}
1246
1247extern "C-unwind" {
1248    #[deprecated = "renamed to `CFMutableDictionary::replace_value`"]
1249    pub fn CFDictionaryReplaceValue(
1250        the_dict: Option<&CFMutableDictionary>,
1251        key: *const c_void,
1252        value: *const c_void,
1253    );
1254}
1255
1256extern "C-unwind" {
1257    #[deprecated = "renamed to `CFMutableDictionary::remove_value`"]
1258    pub fn CFDictionaryRemoveValue(the_dict: Option<&CFMutableDictionary>, key: *const c_void);
1259}
1260
1261#[deprecated = "renamed to `CFMutableDictionary::remove_all_values`"]
1262#[inline]
1263pub extern "C-unwind" fn CFDictionaryRemoveAllValues(the_dict: Option<&CFMutableDictionary>) {
1264    extern "C-unwind" {
1265        fn CFDictionaryRemoveAllValues(the_dict: Option<&CFMutableDictionary>);
1266    }
1267    unsafe { CFDictionaryRemoveAllValues(the_dict) }
1268}