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)
33#[cfg(feature = "CFBase")]
34pub type CFArrayRetainCallBack =
35 Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void) -> *const c_void>;
36
37/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfarrayreleasecallback?language=objc)
38#[cfg(feature = "CFBase")]
39pub type CFArrayReleaseCallBack =
40 Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void)>;
41
42/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfarraycopydescriptioncallback?language=objc)
43#[cfg(feature = "CFBase")]
44pub type CFArrayCopyDescriptionCallBack =
45 Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;
46
47/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfarrayequalcallback?language=objc)
48pub type CFArrayEqualCallBack =
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/cfarraycallbacks?language=objc)
52#[cfg(feature = "CFBase")]
53#[repr(C)]
54#[derive(Clone, Copy, Debug, PartialEq)]
55pub struct CFArrayCallBacks {
56 pub version: CFIndex,
57 pub retain: CFArrayRetainCallBack,
58 pub release: CFArrayReleaseCallBack,
59 pub copyDescription: CFArrayCopyDescriptionCallBack,
60 pub equal: CFArrayEqualCallBack,
61}
62
63#[cfg(all(feature = "CFBase", feature = "objc2"))]
64unsafe impl Encode for CFArrayCallBacks {
65 const ENCODING: Encoding = Encoding::Struct(
66 "?",
67 &[
68 <CFIndex>::ENCODING,
69 <CFArrayRetainCallBack>::ENCODING,
70 <CFArrayReleaseCallBack>::ENCODING,
71 <CFArrayCopyDescriptionCallBack>::ENCODING,
72 <CFArrayEqualCallBack>::ENCODING,
73 ],
74 );
75}
76
77#[cfg(all(feature = "CFBase", feature = "objc2"))]
78unsafe impl RefEncode for CFArrayCallBacks {
79 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
80}
81
82extern "C" {
83 /// Predefined CFArrayCallBacks structure containing a set of callbacks
84 /// appropriate for use when the values in a CFArray are all CFTypes.
85 ///
86 /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcftypearraycallbacks?language=objc)
87 #[cfg(feature = "CFBase")]
88 pub static kCFTypeArrayCallBacks: CFArrayCallBacks;
89}
90
91/// Type of the callback function used by the apply functions of
92/// CFArrays.
93///
94/// Parameter `value`: The current value from the array.
95///
96/// Parameter `context`: The user-defined context parameter given to the apply
97/// function.
98///
99/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfarrayapplierfunction?language=objc)
100pub type CFArrayApplierFunction = Option<unsafe extern "C-unwind" fn(*const c_void, *mut c_void)>;
101
102/// This is the type of a reference to immutable CFArrays.
103///
104/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfarray?language=objc)
105#[repr(C)]
106pub struct CFArray {
107 inner: [u8; 0],
108 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
109}
110
111cf_type!(
112 #[encoding_name = "__CFArray"]
113 unsafe impl CFArray {}
114);
115
116/// This is the type of a reference to mutable CFArrays.
117///
118/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutablearray?language=objc)
119#[repr(C)]
120pub struct CFMutableArray {
121 inner: [u8; 0],
122 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
123}
124
125cf_type!(
126 #[encoding_name = "__CFArray"]
127 unsafe impl CFMutableArray: CFArray {}
128);
129
130#[cfg(feature = "CFBase")]
131unsafe impl ConcreteType for CFArray {
132 /// Returns the type identifier of all CFArray instances.
133 #[doc(alias = "CFArrayGetTypeID")]
134 #[inline]
135 fn type_id() -> CFTypeID {
136 extern "C-unwind" {
137 fn CFArrayGetTypeID() -> CFTypeID;
138 }
139 unsafe { CFArrayGetTypeID() }
140 }
141}
142
143/// Creates a new immutable array with the given values.
144///
145/// Parameter `allocator`: The CFAllocator which should be used to allocate
146/// memory for the array and its storage for values. This
147/// parameter may be NULL in which case the current default
148/// CFAllocator is used. If this reference is not a valid
149/// CFAllocator, the behavior is undefined.
150///
151/// Parameter `values`: A C array of the pointer-sized values to be in the
152/// array. The values in the array are ordered in the same order
153/// in which they appear in this C array. This parameter may be
154/// NULL if the numValues parameter is 0. This C array is not
155/// changed or freed by this function. If this parameter is not
156/// a valid pointer to a C array of at least numValues pointers,
157/// the behavior is undefined.
158///
159/// Parameter `numValues`: The number of values to copy from the values C
160/// array into the CFArray. This number will be the count of the
161/// array.
162/// If this parameter is negative, or greater than the number of
163/// values actually in the value's C array, the behavior is
164/// undefined.
165///
166/// Parameter `callBacks`: A pointer to a CFArrayCallBacks structure
167/// initialized with the callbacks for the array to use on each
168/// value in the array. The retain callback will be used within
169/// this function, for example, to retain all of the new values
170/// from the values C array. A copy of the contents of the
171/// callbacks structure is made, so that a pointer to a
172/// structure on the stack can be passed in, or can be reused
173/// for multiple array creations. If the version field of this
174/// callbacks structure is not one of the defined ones for
175/// CFArray, the behavior is undefined. The retain field may be
176/// NULL, in which case the CFArray will do nothing to add a
177/// retain to the contained values for the array. The release
178/// field may be NULL, in which case the CFArray will do nothing
179/// to remove the array's retain (if any) on the values when the
180/// array is destroyed. If the copyDescription field is NULL,
181/// the array will create a simple description for the value. If
182/// the equal field is NULL, the array will use pointer equality
183/// to test for equality of values. This callbacks parameter
184/// itself may be NULL, which is treated as if a valid structure
185/// of version 0 with all fields NULL had been passed in.
186/// Otherwise, if any of the fields are not valid pointers to
187/// functions of the correct type, or this parameter is not a
188/// valid pointer to a CFArrayCallBacks callbacks structure,
189/// the behavior is undefined. If any of the values put into the
190/// array is not one understood by one of the callback functions
191/// the behavior when that callback function is used is
192/// undefined.
193///
194/// Returns: A reference to the new immutable CFArray.
195#[cfg(feature = "CFBase")]
196#[inline]
197pub unsafe extern "C-unwind" fn CFArrayCreate(
198 allocator: Option<&CFAllocator>,
199 values: *mut *const c_void,
200 num_values: CFIndex,
201 call_backs: *const CFArrayCallBacks,
202) -> Option<CFRetained<CFArray>> {
203 extern "C-unwind" {
204 fn CFArrayCreate(
205 allocator: Option<&CFAllocator>,
206 values: *mut *const c_void,
207 num_values: CFIndex,
208 call_backs: *const CFArrayCallBacks,
209 ) -> Option<NonNull<CFArray>>;
210 }
211 let ret = unsafe { CFArrayCreate(allocator, values, num_values, call_backs) };
212 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
213}
214
215/// Creates a new immutable array with the values from the given array.
216///
217/// Parameter `allocator`: The CFAllocator which should be used to allocate
218/// memory for the array and its storage for values. This
219/// parameter may be NULL in which case the current default
220/// CFAllocator is used. If this reference is not a valid
221/// CFAllocator, the behavior is undefined.
222///
223/// Parameter `theArray`: The array which is to be copied. The values from the
224/// array are copied as pointers into the new array (that is,
225/// the values themselves are copied, not that which the values
226/// point to, if anything). However, the values are also
227/// retained by the new array. The count of the new array will
228/// be the same as the given array. The new array uses the same
229/// callbacks as the array to be copied. If this parameter is
230/// not a valid CFArray, the behavior is undefined.
231///
232/// Returns: A reference to the new immutable CFArray.
233#[cfg(feature = "CFBase")]
234#[inline]
235pub unsafe extern "C-unwind" fn CFArrayCreateCopy(
236 allocator: Option<&CFAllocator>,
237 the_array: Option<&CFArray>,
238) -> Option<CFRetained<CFArray>> {
239 extern "C-unwind" {
240 fn CFArrayCreateCopy(
241 allocator: Option<&CFAllocator>,
242 the_array: Option<&CFArray>,
243 ) -> Option<NonNull<CFArray>>;
244 }
245 let ret = unsafe { CFArrayCreateCopy(allocator, the_array) };
246 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
247}
248
249/// Creates a new empty mutable array.
250///
251/// Parameter `allocator`: The CFAllocator which should be used to allocate
252/// memory for the array and its storage for values. This
253/// parameter may be NULL in which case the current default
254/// CFAllocator is used. If this reference is not a valid
255/// CFAllocator, the behavior is undefined.
256///
257/// Parameter `capacity`: A hint about the number of values that will be held
258/// by the CFArray. Pass 0 for no hint. The implementation may
259/// ignore this hint, or may use it to optimize various
260/// operations. An array's actual capacity is only limited by
261/// address space and available memory constraints). If this
262/// parameter is negative, the behavior is undefined.
263///
264/// Parameter `callBacks`: A pointer to a CFArrayCallBacks structure
265/// initialized with the callbacks for the array to use on each
266/// value in the array. A copy of the contents of the
267/// callbacks structure is made, so that a pointer to a
268/// structure on the stack can be passed in, or can be reused
269/// for multiple array creations. If the version field of this
270/// callbacks structure is not one of the defined ones for
271/// CFArray, the behavior is undefined. The retain field may be
272/// NULL, in which case the CFArray will do nothing to add a
273/// retain to the contained values for the array. The release
274/// field may be NULL, in which case the CFArray will do nothing
275/// to remove the array's retain (if any) on the values when the
276/// array is destroyed. If the copyDescription field is NULL,
277/// the array will create a simple description for the value. If
278/// the equal field is NULL, the array will use pointer equality
279/// to test for equality of values. This callbacks parameter
280/// itself may be NULL, which is treated as if a valid structure
281/// of version 0 with all fields NULL had been passed in.
282/// Otherwise, if any of the fields are not valid pointers to
283/// functions of the correct type, or this parameter is not a
284/// valid pointer to a CFArrayCallBacks callbacks structure,
285/// the behavior is undefined. If any of the values put into the
286/// array is not one understood by one of the callback functions
287/// the behavior when that callback function is used is
288/// undefined.
289///
290/// Returns: A reference to the new mutable CFArray.
291#[cfg(feature = "CFBase")]
292#[inline]
293pub unsafe extern "C-unwind" fn CFArrayCreateMutable(
294 allocator: Option<&CFAllocator>,
295 capacity: CFIndex,
296 call_backs: *const CFArrayCallBacks,
297) -> Option<CFRetained<CFMutableArray>> {
298 extern "C-unwind" {
299 fn CFArrayCreateMutable(
300 allocator: Option<&CFAllocator>,
301 capacity: CFIndex,
302 call_backs: *const CFArrayCallBacks,
303 ) -> Option<NonNull<CFMutableArray>>;
304 }
305 let ret = unsafe { CFArrayCreateMutable(allocator, capacity, call_backs) };
306 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
307}
308
309/// Creates a new mutable array with the values from the given 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).
322/// This parameter must be greater than or equal
323/// to the count of the array which is to be copied, or the
324/// behavior is undefined. If this parameter is negative, the
325/// behavior is undefined.
326///
327/// Parameter `theArray`: The array which is to be copied. The values from the
328/// array are copied as pointers into the new array (that is,
329/// the values themselves are copied, not that which the values
330/// point to, if anything). However, the values are also
331/// retained by the new array. The count of the new array will
332/// be the same as the given array. The new array uses the same
333/// callbacks as the array to be copied. If this parameter is
334/// not a valid CFArray, the behavior is undefined.
335///
336/// Returns: A reference to the new mutable CFArray.
337#[cfg(feature = "CFBase")]
338#[inline]
339pub unsafe extern "C-unwind" fn CFArrayCreateMutableCopy(
340 allocator: Option<&CFAllocator>,
341 capacity: CFIndex,
342 the_array: Option<&CFArray>,
343) -> Option<CFRetained<CFMutableArray>> {
344 extern "C-unwind" {
345 fn CFArrayCreateMutableCopy(
346 allocator: Option<&CFAllocator>,
347 capacity: CFIndex,
348 the_array: Option<&CFArray>,
349 ) -> Option<NonNull<CFMutableArray>>;
350 }
351 let ret = unsafe { CFArrayCreateMutableCopy(allocator, capacity, the_array) };
352 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
353}
354
355extern "C-unwind" {
356 /// Returns the number of values currently in the array.
357 ///
358 /// Parameter `theArray`: The array to be queried. If this parameter is not a valid
359 /// CFArray, the behavior is undefined.
360 ///
361 /// Returns: The number of values in the array.
362 #[cfg(feature = "CFBase")]
363 pub fn CFArrayGetCount(the_array: &CFArray) -> CFIndex;
364}
365
366extern "C-unwind" {
367 /// Counts the number of times the given value occurs in the array.
368 ///
369 /// Parameter `theArray`: The array to be searched. If this parameter is not a
370 /// valid CFArray, the behavior is undefined.
371 ///
372 /// Parameter `range`: The range within the array to search. If the range
373 /// location or end point (defined by the location plus length
374 /// minus 1) is outside the index space of the array (0 to
375 /// N-1 inclusive, where N is the count of the array), the
376 /// behavior is undefined. If the range length is negative, the
377 /// behavior is undefined. The range may be empty (length 0).
378 ///
379 /// Parameter `value`: The value for which to find matches in the array. The
380 /// equal() callback provided when the array was created is
381 /// used to compare. If the equal() callback was NULL, pointer
382 /// equality (in C, ==) is used. If value, or any of the values
383 /// in the array, are not understood by the equal() callback,
384 /// the behavior is undefined.
385 ///
386 /// Returns: The number of times the given value occurs in the array,
387 /// within the specified range.
388 #[cfg(feature = "CFBase")]
389 pub fn CFArrayGetCountOfValue(
390 the_array: &CFArray,
391 range: CFRange,
392 value: *const c_void,
393 ) -> CFIndex;
394}
395
396/// Reports whether or not the value is in the array.
397///
398/// Parameter `theArray`: The array to be searched. If this parameter is not a
399/// valid CFArray, the behavior is undefined.
400///
401/// Parameter `range`: The range within the array to search. If the range
402/// location or end point (defined by the location plus length
403/// minus 1) is outside the index space of the array (0 to
404/// N-1 inclusive, where N is the count of the array), the
405/// behavior is undefined. If the range length is negative, the
406/// behavior is undefined. The range may be empty (length 0).
407///
408/// Parameter `value`: The value for which to find matches in the array. The
409/// equal() callback provided when the array was created is
410/// used to compare. If the equal() callback was NULL, pointer
411/// equality (in C, ==) is used. If value, or any of the values
412/// in the array, are not understood by the equal() callback,
413/// the behavior is undefined.
414///
415/// Returns: true, if the value is in the specified range of the array,
416/// otherwise false.
417#[cfg(feature = "CFBase")]
418#[inline]
419pub unsafe extern "C-unwind" fn CFArrayContainsValue(
420 the_array: &CFArray,
421 range: CFRange,
422 value: *const c_void,
423) -> bool {
424 extern "C-unwind" {
425 fn CFArrayContainsValue(
426 the_array: &CFArray,
427 range: CFRange,
428 value: *const c_void,
429 ) -> Boolean;
430 }
431 let ret = unsafe { CFArrayContainsValue(the_array, range, value) };
432 ret != 0
433}
434
435extern "C-unwind" {
436 /// Retrieves the value at the given index.
437 ///
438 /// Parameter `theArray`: The array to be queried. If this parameter is not a
439 /// valid CFArray, the behavior is undefined.
440 ///
441 /// Parameter `idx`: The index of the value to retrieve. If the index is
442 /// outside the index space of the array (0 to N-1 inclusive,
443 /// where N is the count of the array), the behavior is
444 /// undefined.
445 ///
446 /// Returns: The value with the given index in the array.
447 #[cfg(feature = "CFBase")]
448 pub fn CFArrayGetValueAtIndex(the_array: &CFArray, idx: CFIndex) -> *const c_void;
449}
450
451extern "C-unwind" {
452 /// Fills the buffer with values from the array.
453 ///
454 /// Parameter `theArray`: The array to be queried. If this parameter is not a
455 /// valid CFArray, the behavior is undefined.
456 ///
457 /// Parameter `range`: The range of values within the array to retrieve. If
458 /// the range location or end point (defined by the location
459 /// plus length minus 1) is outside the index space of the
460 /// array (0 to N-1 inclusive, where N is the count of the
461 /// array), the behavior is undefined. If the range length is
462 /// negative, the behavior is undefined. The range may be empty
463 /// (length 0), in which case no values are put into the buffer.
464 ///
465 /// Parameter `values`: A C array of pointer-sized values to be filled with
466 /// values from the array. The values in the C array are ordered
467 /// in the same order in which they appear in the array. If this
468 /// parameter is not a valid pointer to a C array of at least
469 /// range.length pointers, the behavior is undefined.
470 #[cfg(feature = "CFBase")]
471 pub fn CFArrayGetValues(the_array: &CFArray, range: CFRange, values: *mut *const c_void);
472}
473
474extern "C-unwind" {
475 /// Calls a function once for each value in the array.
476 ///
477 /// Parameter `theArray`: The array to be operated upon. If this parameter is not
478 /// a valid CFArray, the behavior is undefined.
479 ///
480 /// Parameter `range`: The range of values within the array to which to apply
481 /// the function. If the range location or end point (defined by
482 /// the location plus length minus 1) is outside the index
483 /// space of the array (0 to N-1 inclusive, where N is the count
484 /// of the array), the behavior is undefined. If the range
485 /// length is negative, the behavior is undefined. The range may
486 /// be empty (length 0).
487 ///
488 /// Parameter `applier`: The callback function to call once for each value in
489 /// the given range in the array. If this parameter is not a
490 /// pointer to a function of the correct prototype, the behavior
491 /// is undefined. If there are values in the range which the
492 /// applier function does not expect or cannot properly apply
493 /// to, the behavior is undefined.
494 ///
495 /// Parameter `context`: A pointer-sized user-defined value, which is passed
496 /// as the second parameter to the applier function, but is
497 /// otherwise unused by this function. If the context is not
498 /// what is expected by the applier function, the behavior is
499 /// undefined.
500 #[cfg(feature = "CFBase")]
501 pub fn CFArrayApplyFunction(
502 the_array: &CFArray,
503 range: CFRange,
504 applier: CFArrayApplierFunction,
505 context: *mut c_void,
506 );
507}
508
509extern "C-unwind" {
510 /// Searches the array for the value.
511 ///
512 /// Parameter `theArray`: The array to be searched. If this parameter is not a
513 /// valid CFArray, the behavior is undefined.
514 ///
515 /// Parameter `range`: The range within the array to search. If the range
516 /// location or end point (defined by the location plus length
517 /// minus 1) is outside the index space of the array (0 to
518 /// N-1 inclusive, where N is the count of the array), the
519 /// behavior is undefined. If the range length is negative, the
520 /// behavior is undefined. The range may be empty (length 0).
521 /// The search progresses from the smallest index defined by
522 /// the range to the largest.
523 ///
524 /// Parameter `value`: The value for which to find a match in the array. The
525 /// equal() callback provided when the array was created is
526 /// used to compare. If the equal() callback was NULL, pointer
527 /// equality (in C, ==) is used. If value, or any of the values
528 /// in the array, are not understood by the equal() callback,
529 /// the behavior is undefined.
530 ///
531 /// Returns: The lowest index of the matching values in the range, or
532 /// kCFNotFound if no value in the range matched.
533 #[cfg(feature = "CFBase")]
534 pub fn CFArrayGetFirstIndexOfValue(
535 the_array: &CFArray,
536 range: CFRange,
537 value: *const c_void,
538 ) -> CFIndex;
539}
540
541extern "C-unwind" {
542 /// Searches the array for the value.
543 ///
544 /// Parameter `theArray`: The array to be searched. If this parameter is not a
545 /// valid CFArray, the behavior is undefined.
546 ///
547 /// Parameter `range`: The range within the array to search. If the range
548 /// location or end point (defined by the location plus length
549 /// minus 1) is outside the index space of the array (0 to
550 /// N-1 inclusive, where N is the count of the array), the
551 /// behavior is undefined. If the range length is negative, the
552 /// behavior is undefined. The range may be empty (length 0).
553 /// The search progresses from the largest index defined by the
554 /// range to the smallest.
555 ///
556 /// Parameter `value`: The value for which to find a match in the array. The
557 /// equal() callback provided when the array was created is
558 /// used to compare. If the equal() callback was NULL, pointer
559 /// equality (in C, ==) is used. If value, or any of the values
560 /// in the array, are not understood by the equal() callback,
561 /// the behavior is undefined.
562 ///
563 /// Returns: The highest index of the matching values in the range, or
564 /// kCFNotFound if no value in the range matched.
565 #[cfg(feature = "CFBase")]
566 pub fn CFArrayGetLastIndexOfValue(
567 the_array: &CFArray,
568 range: CFRange,
569 value: *const c_void,
570 ) -> CFIndex;
571}
572
573extern "C-unwind" {
574 /// Searches the array for the value using a binary search algorithm.
575 ///
576 /// Parameter `theArray`: The array to be searched. If this parameter is not a
577 /// valid CFArray, the behavior is undefined. If the array is
578 /// not sorted from least to greatest according to the
579 /// comparator function, the behavior is undefined.
580 ///
581 /// Parameter `range`: The range within the array to search. If the range
582 /// location or end point (defined by the location plus length
583 /// minus 1) is outside the index space of the array (0 to
584 /// N-1 inclusive, where N is the count of the array), the
585 /// behavior is undefined. If the range length is negative, the
586 /// behavior is undefined. The range may be empty (length 0).
587 ///
588 /// Parameter `value`: The value for which to find a match in the array. If
589 /// value, or any of the values in the array, are not understood
590 /// by the comparator callback, the behavior is undefined.
591 ///
592 /// Parameter `comparator`: The function with the comparator function type
593 /// signature which is used in the binary search operation to
594 /// compare values in the array with the given value. If this
595 /// parameter is not a pointer to a function of the correct
596 /// prototype, the behavior is undefined. If there are values
597 /// in the range which the comparator function does not expect
598 /// or cannot properly compare, the behavior is undefined.
599 ///
600 /// Parameter `context`: A pointer-sized user-defined value, which is passed
601 /// as the third parameter to the comparator function, but is
602 /// otherwise unused by this function. If the context is not
603 /// what is expected by the comparator function, the behavior is
604 /// undefined.
605 ///
606 /// Returns: The return value is either 1) the index of a value that
607 /// matched, if the target value matches one or more in the
608 /// range, 2) greater than or equal to the end point of the
609 /// range, if the value is greater than all the values in the
610 /// range, or 3) the index of the value greater than the target
611 /// value, if the value lies between two of (or less than all
612 /// of) the values in the range.
613 #[cfg(feature = "CFBase")]
614 pub fn CFArrayBSearchValues(
615 the_array: &CFArray,
616 range: CFRange,
617 value: *const c_void,
618 comparator: CFComparatorFunction,
619 context: *mut c_void,
620 ) -> CFIndex;
621}
622
623extern "C-unwind" {
624 /// Adds the value to the array giving it a new largest index.
625 ///
626 /// Parameter `theArray`: The array to which the value is to be added. If this
627 /// parameter is not a valid mutable CFArray, the behavior is
628 /// undefined.
629 ///
630 /// Parameter `value`: The value to add to the array. The value is retained by
631 /// the array using the retain callback provided when the array
632 /// was created. If the value is not of the sort expected by the
633 /// retain callback, the behavior is undefined. The value is
634 /// assigned to the index one larger than the previous largest
635 /// index, and the count of the array is increased by one.
636 pub fn CFArrayAppendValue(the_array: Option<&CFMutableArray>, value: *const c_void);
637}
638
639extern "C-unwind" {
640 /// Adds the value to the array, giving it the given index.
641 ///
642 /// Parameter `theArray`: The array to which the value is to be added. If this
643 /// parameter is not a valid mutable CFArray, the behavior is
644 /// undefined.
645 ///
646 /// Parameter `idx`: The index to which to add the new value. If the index is
647 /// outside the index space of the array (0 to N inclusive,
648 /// where N is the count of the array before the operation), the
649 /// behavior is undefined. If the index is the same as N, this
650 /// function has the same effect as CFArrayAppendValue().
651 ///
652 /// Parameter `value`: The value to add to the array. The value is retained by
653 /// the array using the retain callback provided when the array
654 /// was created. If the value is not of the sort expected by the
655 /// retain callback, the behavior is undefined. The value is
656 /// assigned to the given index, and all values with equal and
657 /// larger indices have their indexes increased by one.
658 #[cfg(feature = "CFBase")]
659 pub fn CFArrayInsertValueAtIndex(
660 the_array: Option<&CFMutableArray>,
661 idx: CFIndex,
662 value: *const c_void,
663 );
664}
665
666extern "C-unwind" {
667 /// Changes the value with the given index in the array.
668 ///
669 /// Parameter `theArray`: The array in which the value is to be changed. If this
670 /// parameter is not a valid mutable CFArray, the behavior is
671 /// undefined.
672 ///
673 /// Parameter `idx`: The index to which to set the new value. If the index is
674 /// outside the index space of the array (0 to N inclusive,
675 /// where N is the count of the array before the operation), the
676 /// behavior is undefined. If the index is the same as N, this
677 /// function has the same effect as CFArrayAppendValue().
678 ///
679 /// Parameter `value`: The value to set in the array. The value is retained by
680 /// the array using the retain callback provided when the array
681 /// was created, and the previous value with that index is
682 /// released. If the value is not of the sort expected by the
683 /// retain callback, the behavior is undefined. The indices of
684 /// other values is not affected.
685 #[cfg(feature = "CFBase")]
686 pub fn CFArraySetValueAtIndex(
687 the_array: Option<&CFMutableArray>,
688 idx: CFIndex,
689 value: *const c_void,
690 );
691}
692
693extern "C-unwind" {
694 /// Removes the value with the given index from the array.
695 ///
696 /// Parameter `theArray`: The array from which the value is to be removed. If
697 /// this parameter is not a valid mutable CFArray, the behavior
698 /// is undefined.
699 ///
700 /// Parameter `idx`: The index from which to remove the value. If the index is
701 /// outside the index space of the array (0 to N-1 inclusive,
702 /// where N is the count of the array before the operation), the
703 /// behavior is undefined.
704 #[cfg(feature = "CFBase")]
705 pub fn CFArrayRemoveValueAtIndex(the_array: Option<&CFMutableArray>, idx: CFIndex);
706}
707
708extern "C-unwind" {
709 /// Removes all the values from the array, making it empty.
710 ///
711 /// Parameter `theArray`: The array from which all of the values are to be
712 /// removed. If this parameter is not a valid mutable CFArray,
713 /// the behavior is undefined.
714 pub fn CFArrayRemoveAllValues(the_array: Option<&CFMutableArray>);
715}
716
717extern "C-unwind" {
718 /// Replaces a range of values in the array.
719 ///
720 /// Parameter `theArray`: The array from which all of the values are to be
721 /// removed. If this parameter is not a valid mutable CFArray,
722 /// the behavior is undefined.
723 ///
724 /// Parameter `range`: The range of values within the array to replace. If the
725 /// range location or end point (defined by the location plus
726 /// length minus 1) is outside the index space of the array (0
727 /// to N inclusive, where N is the count of the array), the
728 /// behavior is undefined. If the range length is negative, the
729 /// behavior is undefined. The range may be empty (length 0),
730 /// in which case the new values are merely inserted at the
731 /// range location.
732 ///
733 /// Parameter `newValues`: A C array of the pointer-sized values to be placed
734 /// into the array. The new values in the array are ordered in
735 /// the same order in which they appear in this C array. This
736 /// parameter may be NULL if the newCount parameter is 0. This
737 /// C array is not changed or freed by this function. If this
738 /// parameter is not a valid pointer to a C array of at least
739 /// newCount pointers, the behavior is undefined.
740 ///
741 /// Parameter `newCount`: The number of values to copy from the values C
742 /// array into the CFArray. If this parameter is different than
743 /// the range length, the excess newCount values will be
744 /// inserted after the range, or the excess range values will be
745 /// deleted. This parameter may be 0, in which case no new
746 /// values are replaced into the array and the values in the
747 /// range are simply removed. If this parameter is negative, or
748 /// greater than the number of values actually in the newValues
749 /// C array, the behavior is undefined.
750 #[cfg(feature = "CFBase")]
751 pub fn CFArrayReplaceValues(
752 the_array: Option<&CFMutableArray>,
753 range: CFRange,
754 new_values: *mut *const c_void,
755 new_count: CFIndex,
756 );
757}
758
759extern "C-unwind" {
760 /// Exchanges the values at two indices of the array.
761 ///
762 /// Parameter `theArray`: The array of which the values are to be swapped. If
763 /// this parameter is not a valid mutable CFArray, the behavior
764 /// is undefined.
765 ///
766 /// Parameter `idx1`: The first index whose values should be swapped. If the
767 /// index is outside the index space of the array (0 to N-1
768 /// inclusive, where N is the count of the array before the
769 /// operation), the behavior is undefined.
770 ///
771 /// Parameter `idx2`: The second index whose values should be swapped. If the
772 /// index is outside the index space of the array (0 to N-1
773 /// inclusive, where N is the count of the array before the
774 /// operation), the behavior is undefined.
775 #[cfg(feature = "CFBase")]
776 pub fn CFArrayExchangeValuesAtIndices(
777 the_array: Option<&CFMutableArray>,
778 idx1: CFIndex,
779 idx2: CFIndex,
780 );
781}
782
783extern "C-unwind" {
784 /// Sorts the values in the array using the given comparison function.
785 ///
786 /// Parameter `theArray`: The array whose values are to be sorted. If this
787 /// parameter is not a valid mutable CFArray, the behavior is
788 /// undefined.
789 ///
790 /// Parameter `range`: The range of values within the array to sort. If the
791 /// range location or end point (defined by the location plus
792 /// length minus 1) is outside the index space of the array (0
793 /// to N-1 inclusive, where N is the count of the array), the
794 /// behavior is undefined. If the range length is negative, the
795 /// behavior is undefined. The range may be empty (length 0).
796 ///
797 /// Parameter `comparator`: The function with the comparator function type
798 /// signature which is used in the sort operation to compare
799 /// values in the array with the given value. If this parameter
800 /// is not a pointer to a function of the correct prototype, the
801 /// the behavior is undefined. If there are values in the array
802 /// which the comparator function does not expect or cannot
803 /// properly compare, the behavior is undefined. The values in
804 /// the range are sorted from least to greatest according to
805 /// this function.
806 ///
807 /// Parameter `context`: A pointer-sized user-defined value, which is passed
808 /// as the third parameter to the comparator function, but is
809 /// otherwise unused by this function. If the context is not
810 /// what is expected by the comparator function, the behavior is
811 /// undefined.
812 #[cfg(feature = "CFBase")]
813 pub fn CFArraySortValues(
814 the_array: Option<&CFMutableArray>,
815 range: CFRange,
816 comparator: CFComparatorFunction,
817 context: *mut c_void,
818 );
819}
820
821extern "C-unwind" {
822 /// Adds the values from an array to another array.
823 ///
824 /// Parameter `theArray`: The array to which values from the otherArray are to
825 /// be added. If this parameter is not a valid mutable CFArray,
826 /// the behavior is undefined.
827 ///
828 /// Parameter `otherArray`: The array providing the values to be added to the
829 /// array. If this parameter is not a valid CFArray, the
830 /// behavior is undefined.
831 ///
832 /// Parameter `otherRange`: The range within the otherArray from which to add
833 /// the values to the array. If the range location or end point
834 /// (defined by the location plus length minus 1) is outside
835 /// the index space of the otherArray (0 to N-1 inclusive, where
836 /// N is the count of the otherArray), the behavior is
837 /// undefined. The new values are retained by the array using
838 /// the retain callback provided when the array was created. If
839 /// the values are not of the sort expected by the retain
840 /// callback, the behavior is undefined. The values are assigned
841 /// to the indices one larger than the previous largest index
842 /// in the array, and beyond, and the count of the array is
843 /// increased by range.length. The values are assigned new
844 /// indices in the array from smallest to largest index in the
845 /// order in which they appear in the otherArray.
846 #[cfg(feature = "CFBase")]
847 pub fn CFArrayAppendArray(
848 the_array: Option<&CFMutableArray>,
849 other_array: Option<&CFArray>,
850 other_range: CFRange,
851 );
852}