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