Skip to content

Commit 3ef0b36

Browse files
authored
Auto merge of #591 - michaelwright235:tree2, r=jdm
sys: Introduce CFTree Implements CFTree and its related stuff. All functions are sorted in Apple docs order.
2 parents 7fe0d59 + f904d7f commit 3ef0b36

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

core-foundation-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub mod socket;
4747
pub mod stream;
4848
pub mod string;
4949
pub mod string_tokenizer;
50+
pub mod tree;
5051
pub mod timezone;
5152
pub mod url;
5253
#[cfg(target_os = "macos")]

core-foundation-sys/src/tree.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 base::{CFIndex, CFTypeID, CFAllocatorRef, CFComparatorFunction};
13+
use 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 {
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(tree: CFTreeRef, comparator: CFComparatorFunction, context: *mut c_void);
50+
51+
/* Examining a Tree */
52+
pub fn CFTreeFindRoot(tree: CFTreeRef) -> CFTreeRef;
53+
pub fn CFTreeGetChildAtIndex(tree: CFTreeRef, idx: CFIndex) -> CFTreeRef;
54+
pub fn CFTreeGetChildCount(tree: CFTreeRef) -> CFIndex;
55+
pub fn CFTreeGetChildren(tree: CFTreeRef, children: *mut CFTreeRef);
56+
pub fn CFTreeGetContext(tree: CFTreeRef, context: *mut CFTreeContext);
57+
pub fn CFTreeGetFirstChild(tree: CFTreeRef) -> CFTreeRef;
58+
pub fn CFTreeGetNextSibling(tree: CFTreeRef) -> CFTreeRef;
59+
pub fn CFTreeGetParent(tree: CFTreeRef) -> CFTreeRef;
60+
61+
/* Performing an Operation on Tree Elements */
62+
pub fn CFTreeApplyFunctionToChildren(tree: CFTreeRef, applier: CFTreeApplierFunction, context: *mut c_void);
63+
64+
/* Getting the Tree Type ID */
65+
pub fn CFTreeGetTypeID() -> CFTypeID;
66+
}

0 commit comments

Comments
 (0)