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::*;
pub type CFTreeRetainCallBack = Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>;
pub type CFTreeReleaseCallBack = Option<unsafe extern "C-unwind" fn(*const c_void)>;
pub type CFTreeCopyDescriptionCallBack =
Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;
#[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);
}
pub type CFTreeApplierFunction = Option<unsafe extern "C-unwind" fn(*const c_void, *mut c_void)>;
#[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 {
#[doc(alias = "CFTreeGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CFTreeGetTypeID() -> CFTypeID;
}
unsafe { CFTreeGetTypeID() }
}
}
impl CFTree {
#[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) })
}
#[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) })
}
#[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) })
}
#[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) })
}
#[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) }
}
#[doc(alias = "CFTreeGetChildCount")]
#[inline]
pub fn child_count(&self) -> CFIndex {
extern "C-unwind" {
fn CFTreeGetChildCount(tree: &CFTree) -> CFIndex;
}
unsafe { CFTreeGetChildCount(self) }
}
#[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) })
}
#[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) }
}
#[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) }
}
#[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) })
}
#[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) }
}
#[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) }
}
#[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) }
}
#[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) }
}
#[doc(alias = "CFTreeRemove")]
#[inline]
pub fn remove(&self) {
extern "C-unwind" {
fn CFTreeRemove(tree: &CFTree);
}
unsafe { CFTreeRemove(self) }
}
#[doc(alias = "CFTreeRemoveAllChildren")]
#[inline]
pub fn remove_all_children(&self) {
extern "C-unwind" {
fn CFTreeRemoveAllChildren(tree: &CFTree);
}
unsafe { CFTreeRemoveAllChildren(self) }
}
#[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,
);
}