| 1 |
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT |
| 2 |
// file at the top-level directory of this distribution. |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 |
// option. This file may not be copied, modified, or distributed |
| 8 |
// except according to those terms. |
| 9 |
|
| 10 |
use std::os::raw::c_void; |
| 11 |
|
| 12 |
use crate::base::{CFAllocatorRef, CFComparatorFunction, CFIndex, CFTypeID}; |
| 13 |
use crate::string::CFStringRef; |
| 14 |
|
| 15 |
#[repr(C)] |
| 16 |
pub struct __CFTree(c_void); |
| 17 |
pub type CFTreeRef = *mut __CFTree; |
| 18 |
|
| 19 |
pub type CFTreeRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void; |
| 20 |
pub type CFTreeReleaseCallBack = extern "C" fn(info: *const c_void); |
| 21 |
pub type CFTreeCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef; |
| 22 |
pub type CFTreeApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void); |
| 23 |
|
| 24 |
#[repr(C)] |
| 25 |
pub struct CFTreeContext { |
| 26 |
pub version: CFIndex, |
| 27 |
pub info: *mut c_void, |
| 28 |
pub retain: CFTreeRetainCallBack, |
| 29 |
pub release: CFTreeReleaseCallBack, |
| 30 |
pub copyDescription: CFTreeCopyDescriptionCallBack, |
| 31 |
} |
| 32 |
|
| 33 |
extern "C" { |
| 34 |
/* |
| 35 |
* CFTree.h |
| 36 |
*/ |
| 37 |
/* Creating Trees */ |
| 38 |
pub fn CFTreeCreate(allocator: CFAllocatorRef, context: *const CFTreeContext) -> CFTreeRef; |
| 39 |
|
| 40 |
/* Modifying a Tree */ |
| 41 |
pub fn CFTreeAppendChild(tree: CFTreeRef, newChild: CFTreeRef); |
| 42 |
pub fn CFTreeInsertSibling(tree: CFTreeRef, newSibling: CFTreeRef); |
| 43 |
pub fn CFTreeRemoveAllChildren(tree: CFTreeRef); |
| 44 |
pub fn CFTreePrependChild(tree: CFTreeRef, newChild: CFTreeRef); |
| 45 |
pub fn CFTreeRemove(tree: CFTreeRef); |
| 46 |
pub fn CFTreeSetContext(tree: CFTreeRef, context: *const CFTreeContext); |
| 47 |
|
| 48 |
/* Sorting a Tree */ |
| 49 |
pub fn CFTreeSortChildren( |
| 50 |
tree: CFTreeRef, |
| 51 |
comparator: CFComparatorFunction, |
| 52 |
context: *mut c_void, |
| 53 |
); |
| 54 |
|
| 55 |
/* Examining a Tree */ |
| 56 |
pub fn CFTreeFindRoot(tree: CFTreeRef) -> CFTreeRef; |
| 57 |
pub fn CFTreeGetChildAtIndex(tree: CFTreeRef, idx: CFIndex) -> CFTreeRef; |
| 58 |
pub fn CFTreeGetChildCount(tree: CFTreeRef) -> CFIndex; |
| 59 |
pub fn CFTreeGetChildren(tree: CFTreeRef, children: *mut CFTreeRef); |
| 60 |
pub fn CFTreeGetContext(tree: CFTreeRef, context: *mut CFTreeContext); |
| 61 |
pub fn CFTreeGetFirstChild(tree: CFTreeRef) -> CFTreeRef; |
| 62 |
pub fn CFTreeGetNextSibling(tree: CFTreeRef) -> CFTreeRef; |
| 63 |
pub fn CFTreeGetParent(tree: CFTreeRef) -> CFTreeRef; |
| 64 |
|
| 65 |
/* Performing an Operation on Tree Elements */ |
| 66 |
pub fn CFTreeApplyFunctionToChildren( |
| 67 |
tree: CFTreeRef, |
| 68 |
applier: CFTreeApplierFunction, |
| 69 |
context: *mut c_void, |
| 70 |
); |
| 71 |
|
| 72 |
/* Getting the Tree Type ID */ |
| 73 |
pub fn CFTreeGetTypeID() -> CFTypeID; |
| 74 |
} |