objc2-core-foundation 0.3.2

Bindings to the CoreFoundation framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// Type of the callback function used to add a retain to the user-specified
/// info parameter.  This callback may returns the value to use whenever the
/// info parameter is retained, which is usually the value parameter passed
/// to this callback, but may be a different value if a different value
/// should be used.
///
/// Parameter `info`: A user-supplied info parameter provided in a CFTreeContext.
///
/// Returns: The retained info parameter.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftreeretaincallback?language=objc)
pub type CFTreeRetainCallBack = Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>;

/// Type of the callback function used to remove a retain previously
/// added to the user-specified info parameter.
///
/// Parameter `info`: A user-supplied info parameter provided in a CFTreeContext.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftreereleasecallback?language=objc)
pub type CFTreeReleaseCallBack = Option<unsafe extern "C-unwind" fn(*const c_void)>;

/// Type of the callback function used to provide a description of the
/// user-specified info parameter.
///
/// Parameter `info`: A user-supplied info parameter provided in a CFTreeContext.
///
/// Returns: A description of the info parameter.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftreecopydescriptioncallback?language=objc)
pub type CFTreeCopyDescriptionCallBack =
    Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;

/// Structure containing user-specified data and callbacks for a CFTree.
/// Field: version The version number of the structure type being passed
/// in as a parameter to the CFTree creation function.
/// This structure is version 0.
/// Field: info A C pointer to a user-specified block of data.
/// Field: retain The callback used to add a retain for the info field.
/// If this parameter is not a pointer to a function of the correct
/// prototype, the behavior is undefined.  The value may be NULL.
/// Field: release The calllback used to remove a retain previously added
/// for the info field.  If this parameter is not a pointer to a
/// function of the correct prototype, the behavior is undefined.
/// The value may be NULL.
/// Field: copyDescription The callback used to provide a description of
/// the info field.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftreecontext?language=objc)
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CFTreeContext {
    pub version: CFIndex,
    pub info: *mut c_void,
    pub retain: CFTreeRetainCallBack,
    pub release: CFTreeReleaseCallBack,
    pub copyDescription: CFTreeCopyDescriptionCallBack,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CFTreeContext {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <CFIndex>::ENCODING,
            <*mut c_void>::ENCODING,
            <CFTreeRetainCallBack>::ENCODING,
            <CFTreeReleaseCallBack>::ENCODING,
            <CFTreeCopyDescriptionCallBack>::ENCODING,
        ],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CFTreeContext {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Type of the callback function used by the apply functions of
/// CFTree.
///
/// Parameter `value`: The current value from the CFTree
///
/// Parameter `context`: The user-defined context parameter give to the apply
/// function.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftreeapplierfunction?language=objc)
pub type CFTreeApplierFunction = Option<unsafe extern "C-unwind" fn(*const c_void, *mut c_void)>;

/// This is the type of a reference to CFTrees.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftree?language=objc)
#[doc(alias = "CFTreeRef")]
#[repr(C)]
pub struct CFTree {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl CFTree {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__CFTree"> for CFTree {}
);

unsafe impl ConcreteType for CFTree {
    /// Returns the type identifier of all CFTree instances.
    #[doc(alias = "CFTreeGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CFTreeGetTypeID() -> CFTypeID;
        }
        unsafe { CFTreeGetTypeID() }
    }
}

impl CFTree {
    /// Creates a new mutable tree.
    ///
    /// Parameter `allocator`: The CFAllocator which should be used to allocate
    /// memory for the tree and storage for its children.  This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used.  If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `context`: A C pointer to a CFTreeContext structure to be copied
    /// and used as the context of the new tree.  The info parameter
    /// will be retained by the tree if a retain function is provided.
    /// If this value is not a valid C pointer to a CFTreeContext
    /// structure-sized block of storage, the result is undefined.
    /// If the version number of the storage is not a valid CFTreeContext
    /// version number, the result is undefined.
    ///
    /// Returns: A reference to the new CFTree.
    ///
    /// # Safety
    ///
    /// - `allocator` might not allow `None`.
    /// - `context` must be a valid pointer.
    #[doc(alias = "CFTreeCreate")]
    #[inline]
    pub unsafe fn new(
        allocator: Option<&CFAllocator>,
        context: *const CFTreeContext,
    ) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeCreate(
                allocator: Option<&CFAllocator>,
                context: *const CFTreeContext,
            ) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeCreate(allocator, context) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Returns the parent of the specified tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Returns: The parent of the tree.
    #[doc(alias = "CFTreeGetParent")]
    #[inline]
    pub fn parent(&self) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeGetParent(tree: &CFTree) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeGetParent(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Returns the sibling after the specified tree in the parent tree's list.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Returns: The next sibling of the tree.
    #[doc(alias = "CFTreeGetNextSibling")]
    #[inline]
    pub fn next_sibling(&self) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeGetNextSibling(tree: &CFTree) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeGetNextSibling(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Returns the first child of the tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Returns: The first child of the tree.
    #[doc(alias = "CFTreeGetFirstChild")]
    #[inline]
    pub fn first_child(&self) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeGetFirstChild(tree: &CFTree) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeGetFirstChild(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Returns the context of the specified tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `context`: A C pointer to a CFTreeContext structure to be filled in with
    /// the context of the specified tree.  If this value is not a valid C
    /// pointer to a CFTreeContext structure-sized block of storage, the
    /// result is undefined.  If the version number of the storage is not
    /// a valid CFTreeContext version number, the result is undefined.
    ///
    /// # Safety
    ///
    /// `context` must be a valid pointer.
    #[doc(alias = "CFTreeGetContext")]
    #[inline]
    pub unsafe fn context(&self, context: *mut CFTreeContext) {
        extern "C-unwind" {
            fn CFTreeGetContext(tree: &CFTree, context: *mut CFTreeContext);
        }
        unsafe { CFTreeGetContext(self, context) }
    }

    /// Returns the number of children of the specified tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Returns: The number of children.
    #[doc(alias = "CFTreeGetChildCount")]
    #[inline]
    pub fn child_count(&self) -> CFIndex {
        extern "C-unwind" {
            fn CFTreeGetChildCount(tree: &CFTree) -> CFIndex;
        }
        unsafe { CFTreeGetChildCount(self) }
    }

    /// Returns the nth child of the specified tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `idx`: The index of the child tree to be returned.  If this parameter
    /// is less than zero or greater than the number of children of the
    /// tree, the result is undefined.
    ///
    /// Returns: A reference to the specified child tree.
    #[doc(alias = "CFTreeGetChildAtIndex")]
    #[inline]
    pub fn child_at_index(&self, idx: CFIndex) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeGetChildAtIndex(tree: &CFTree, idx: CFIndex) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeGetChildAtIndex(self, idx) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Fills the buffer with children from the tree.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `children`: A C array of pointer-sized values to be filled with
    /// children from the tree.  If this parameter is not a valid pointer to a
    /// C array of at least CFTreeGetChildCount() pointers, the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `children` must be a valid pointer.
    #[doc(alias = "CFTreeGetChildren")]
    #[inline]
    pub unsafe fn children(&self, children: *mut *mut CFTree) {
        extern "C-unwind" {
            fn CFTreeGetChildren(tree: &CFTree, children: *mut *mut CFTree);
        }
        unsafe { CFTreeGetChildren(self, children) }
    }

    /// Calls a function once for each child of the tree.  Note that the applier
    /// only operates one level deep, and does not operate on descendents further
    /// removed than the immediate children of the tree.
    ///
    /// Parameter `tree`: The tree to be operated upon.  If this parameter is not a
    /// valid CFTree, the behavior is undefined.
    ///
    /// Parameter `applier`: The callback function to call once for each child of
    /// the given tree.  If this parameter is not a pointer to a
    /// function of the correct prototype, the behavior is undefined.
    /// If there are values in the tree which the applier function does
    /// not expect or cannot properly apply to, the behavior is undefined.
    ///
    /// Parameter `context`: A pointer-sized user-defined value, which is passed
    /// as the second parameter to the applier function, but is
    /// otherwise unused by this function.  If the context is not
    /// what is expected by the applier function, the behavior is
    /// undefined.
    ///
    /// # Safety
    ///
    /// - `applier` must be implemented correctly.
    /// - `context` must be a valid pointer.
    #[doc(alias = "CFTreeApplyFunctionToChildren")]
    #[inline]
    pub unsafe fn apply_function_to_children(
        &self,
        applier: CFTreeApplierFunction,
        context: *mut c_void,
    ) {
        extern "C-unwind" {
            fn CFTreeApplyFunctionToChildren(
                tree: &CFTree,
                applier: CFTreeApplierFunction,
                context: *mut c_void,
            );
        }
        unsafe { CFTreeApplyFunctionToChildren(self, applier, context) }
    }

    /// Returns the root tree of which the specified tree is a descendent.
    ///
    /// Parameter `tree`: The tree to be queried.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Returns: A reference to the root of the tree.
    #[doc(alias = "CFTreeFindRoot")]
    #[inline]
    pub fn find_root(&self) -> Option<CFRetained<CFTree>> {
        extern "C-unwind" {
            fn CFTreeFindRoot(tree: &CFTree) -> Option<NonNull<CFTree>>;
        }
        let ret = unsafe { CFTreeFindRoot(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Replaces the context of a tree.  The tree releases its retain on the
    /// info of the previous context, and retains the info of the new context.
    ///
    /// Parameter `tree`: The tree to be operated on.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `context`: A C pointer to a CFTreeContext structure to be copied
    /// and used as the context of the new tree.  The info parameter
    /// will be retained by the tree if a retain function is provided.
    /// If this value is not a valid C pointer to a CFTreeContext
    /// structure-sized block of storage, the result is undefined.
    /// If the version number of the storage is not a valid CFTreeContext
    /// version number, the result is undefined.
    ///
    /// # Safety
    ///
    /// `context` must be a valid pointer.
    #[doc(alias = "CFTreeSetContext")]
    #[inline]
    pub unsafe fn set_context(&self, context: *const CFTreeContext) {
        extern "C-unwind" {
            fn CFTreeSetContext(tree: &CFTree, context: *const CFTreeContext);
        }
        unsafe { CFTreeSetContext(self, context) }
    }

    /// Adds the newChild to the specified tree as the first in its list of children.
    ///
    /// Parameter `tree`: The tree to be operated on.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `newChild`: The child to be added.
    /// If this parameter is not a valid CFTree, the behavior is undefined.
    /// If this parameter is a tree which is already a child of any tree,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `new_child` might not allow `None`.
    #[doc(alias = "CFTreePrependChild")]
    #[inline]
    pub unsafe fn prepend_child(&self, new_child: Option<&CFTree>) {
        extern "C-unwind" {
            fn CFTreePrependChild(tree: &CFTree, new_child: Option<&CFTree>);
        }
        unsafe { CFTreePrependChild(self, new_child) }
    }

    /// Adds the newChild to the specified tree as the last in its list of children.
    ///
    /// Parameter `tree`: The tree to be operated on.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `newChild`: The child to be added.
    /// If this parameter is not a valid CFTree, the behavior is undefined.
    /// If this parameter is a tree which is already a child of any tree,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `new_child` might not allow `None`.
    #[doc(alias = "CFTreeAppendChild")]
    #[inline]
    pub unsafe fn append_child(&self, new_child: Option<&CFTree>) {
        extern "C-unwind" {
            fn CFTreeAppendChild(tree: &CFTree, new_child: Option<&CFTree>);
        }
        unsafe { CFTreeAppendChild(self, new_child) }
    }

    /// Inserts newSibling into the the parent tree's linked list of children after
    /// tree.  The newSibling will have the same parent as tree.
    ///
    /// Parameter `tree`: The tree to insert newSibling after.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.  If the tree does not have a
    /// parent, the behavior is undefined.
    ///
    /// Parameter `newSibling`: The sibling to be added.
    /// If this parameter is not a valid CFTree, the behavior is undefined.
    /// If this parameter is a tree which is already a child of any tree,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `new_sibling` might not allow `None`.
    #[doc(alias = "CFTreeInsertSibling")]
    #[inline]
    pub unsafe fn insert_sibling(&self, new_sibling: Option<&CFTree>) {
        extern "C-unwind" {
            fn CFTreeInsertSibling(tree: &CFTree, new_sibling: Option<&CFTree>);
        }
        unsafe { CFTreeInsertSibling(self, new_sibling) }
    }

    /// Removes the tree from its parent.
    ///
    /// Parameter `tree`: The tree to be removed.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    #[doc(alias = "CFTreeRemove")]
    #[inline]
    pub fn remove(&self) {
        extern "C-unwind" {
            fn CFTreeRemove(tree: &CFTree);
        }
        unsafe { CFTreeRemove(self) }
    }

    /// Removes all the children of the tree.
    ///
    /// Parameter `tree`: The tree to remove all children from.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    #[doc(alias = "CFTreeRemoveAllChildren")]
    #[inline]
    pub fn remove_all_children(&self) {
        extern "C-unwind" {
            fn CFTreeRemoveAllChildren(tree: &CFTree);
        }
        unsafe { CFTreeRemoveAllChildren(self) }
    }

    /// Sorts the children of the specified tree using the specified comparator function.
    ///
    /// Parameter `tree`: The tree to be operated on.  If this parameter is not a valid
    /// CFTree, the behavior is undefined.
    ///
    /// Parameter `comparator`: The function with the comparator function type
    /// signature which is used in the sort operation to compare
    /// children of the tree with the given value. If this parameter
    /// is not a pointer to a function of the correct prototype, the
    /// the behavior is undefined. The children of the tree are sorted
    /// from least to greatest according to this function.
    ///
    /// Parameter `context`: A pointer-sized user-defined value, which is passed
    /// as the third parameter to the comparator function, but is
    /// otherwise unused by this function. If the context is not
    /// what is expected by the comparator function, the behavior is
    /// undefined.
    ///
    /// # Safety
    ///
    /// - `comparator` must be implemented correctly.
    /// - `context` must be a valid pointer.
    #[doc(alias = "CFTreeSortChildren")]
    #[inline]
    pub unsafe fn sort_children(&self, comparator: CFComparatorFunction, context: *mut c_void) {
        extern "C-unwind" {
            fn CFTreeSortChildren(
                tree: &CFTree,
                comparator: CFComparatorFunction,
                context: *mut c_void,
            );
        }
        unsafe { CFTreeSortChildren(self, comparator, context) }
    }
}

#[deprecated = "renamed to `CFTree::new`"]
#[inline]
pub unsafe extern "C-unwind" fn CFTreeCreate(
    allocator: Option<&CFAllocator>,
    context: *const CFTreeContext,
) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeCreate(
            allocator: Option<&CFAllocator>,
            context: *const CFTreeContext,
        ) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeCreate(allocator, context) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFTree::parent`"]
#[inline]
pub extern "C-unwind" fn CFTreeGetParent(tree: &CFTree) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeGetParent(tree: &CFTree) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeGetParent(tree) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

#[deprecated = "renamed to `CFTree::next_sibling`"]
#[inline]
pub extern "C-unwind" fn CFTreeGetNextSibling(tree: &CFTree) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeGetNextSibling(tree: &CFTree) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeGetNextSibling(tree) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

#[deprecated = "renamed to `CFTree::first_child`"]
#[inline]
pub extern "C-unwind" fn CFTreeGetFirstChild(tree: &CFTree) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeGetFirstChild(tree: &CFTree) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeGetFirstChild(tree) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::context`"]
    pub fn CFTreeGetContext(tree: &CFTree, context: *mut CFTreeContext);
}

#[deprecated = "renamed to `CFTree::child_count`"]
#[inline]
pub extern "C-unwind" fn CFTreeGetChildCount(tree: &CFTree) -> CFIndex {
    extern "C-unwind" {
        fn CFTreeGetChildCount(tree: &CFTree) -> CFIndex;
    }
    unsafe { CFTreeGetChildCount(tree) }
}

#[deprecated = "renamed to `CFTree::child_at_index`"]
#[inline]
pub extern "C-unwind" fn CFTreeGetChildAtIndex(
    tree: &CFTree,
    idx: CFIndex,
) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeGetChildAtIndex(tree: &CFTree, idx: CFIndex) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeGetChildAtIndex(tree, idx) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::children`"]
    pub fn CFTreeGetChildren(tree: &CFTree, children: *mut *mut CFTree);
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::apply_function_to_children`"]
    pub fn CFTreeApplyFunctionToChildren(
        tree: &CFTree,
        applier: CFTreeApplierFunction,
        context: *mut c_void,
    );
}

#[deprecated = "renamed to `CFTree::find_root`"]
#[inline]
pub extern "C-unwind" fn CFTreeFindRoot(tree: &CFTree) -> Option<CFRetained<CFTree>> {
    extern "C-unwind" {
        fn CFTreeFindRoot(tree: &CFTree) -> Option<NonNull<CFTree>>;
    }
    let ret = unsafe { CFTreeFindRoot(tree) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::set_context`"]
    pub fn CFTreeSetContext(tree: &CFTree, context: *const CFTreeContext);
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::prepend_child`"]
    pub fn CFTreePrependChild(tree: &CFTree, new_child: Option<&CFTree>);
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::append_child`"]
    pub fn CFTreeAppendChild(tree: &CFTree, new_child: Option<&CFTree>);
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::insert_sibling`"]
    pub fn CFTreeInsertSibling(tree: &CFTree, new_sibling: Option<&CFTree>);
}

#[deprecated = "renamed to `CFTree::remove`"]
#[inline]
pub extern "C-unwind" fn CFTreeRemove(tree: &CFTree) {
    extern "C-unwind" {
        fn CFTreeRemove(tree: &CFTree);
    }
    unsafe { CFTreeRemove(tree) }
}

#[deprecated = "renamed to `CFTree::remove_all_children`"]
#[inline]
pub extern "C-unwind" fn CFTreeRemoveAllChildren(tree: &CFTree) {
    extern "C-unwind" {
        fn CFTreeRemoveAllChildren(tree: &CFTree);
    }
    unsafe { CFTreeRemoveAllChildren(tree) }
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFTree::sort_children`"]
    pub fn CFTreeSortChildren(
        tree: &CFTree,
        comparator: CFComparatorFunction,
        context: *mut c_void,
    );
}