Skip to content

Commit 519912f

Browse files
authored
Auto merge of #594 - michaelwright235:bh, r=jdm
sys: Introduce CFBinaryHeap Implements CFBinaryHeap related functions and constants.
2 parents 614b8d9 + 5aa2012 commit 519912f

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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::{CFTypeID, CFAllocatorRef, Boolean, CFIndex, CFComparisonResult};
13+
use string::CFStringRef;
14+
15+
#[repr(C)]
16+
pub struct __CFBinaryHeap(c_void);
17+
18+
pub type CFBinaryHeapRef = *mut __CFBinaryHeap;
19+
20+
#[repr(C)]
21+
#[derive(Debug, Clone, Copy)]
22+
pub struct CFBinaryHeapCompareContext {
23+
pub version: CFIndex,
24+
pub info: *mut c_void,
25+
pub retain: extern "C" fn (info: *const c_void) -> *const c_void,
26+
pub release: extern "C" fn (info: *const c_void),
27+
pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef,
28+
}
29+
30+
#[repr(C)]
31+
#[derive(Debug, Clone, Copy)]
32+
pub struct CFBinaryHeapCallBacks {
33+
pub version: CFIndex,
34+
pub retain: extern "C" fn (allocator: CFAllocatorRef, ptr: *const c_void) -> *const c_void,
35+
pub release: extern "C" fn (allocator: CFAllocatorRef, ptr: *const c_void),
36+
pub copyDescription: extern "C" fn (ptr: *const c_void) -> CFStringRef,
37+
pub compare: extern "C" fn (ptr1: *const c_void, ptr2: *const c_void, context: *mut c_void) -> CFComparisonResult
38+
}
39+
40+
pub type CFBinaryHeapApplierFunction = extern "C" fn (val: *const c_void, context: *const c_void);
41+
42+
extern {
43+
/*
44+
* CFBinaryHeap.h
45+
*/
46+
/* Predefined Callback Structures */
47+
pub static kCFStringBinaryHeapCallBacks: CFBinaryHeapCallBacks;
48+
49+
/* CFBinaryHeap Miscellaneous Functions */
50+
pub fn CFBinaryHeapAddValue(heap: CFBinaryHeapRef, value: *const c_void);
51+
pub fn CFBinaryHeapApplyFunction(heap: CFBinaryHeapRef, applier: CFBinaryHeapApplierFunction, context: *mut c_void);
52+
pub fn CFBinaryHeapContainsValue(heap: CFBinaryHeapRef, value: *const c_void) -> Boolean;
53+
pub fn CFBinaryHeapCreate(allocator: CFAllocatorRef, capacity: CFIndex, callBacks: *const CFBinaryHeapCallBacks, compareContext: *const CFBinaryHeapCompareContext) -> CFBinaryHeapRef;
54+
pub fn CFBinaryHeapCreateCopy(allocator: CFAllocatorRef, capacity: CFIndex, heap: CFBinaryHeapRef) -> CFBinaryHeapRef;
55+
pub fn CFBinaryHeapGetCount(heap: CFBinaryHeapRef) -> CFIndex;
56+
pub fn CFBinaryHeapGetCountOfValue(heap: CFBinaryHeapRef, value: *const c_void) -> CFIndex;
57+
pub fn CFBinaryHeapGetMinimum(heap: CFBinaryHeapRef) -> *const c_void;
58+
pub fn CFBinaryHeapGetMinimumIfPresent(heap: CFBinaryHeapRef, value: *const *const c_void) -> Boolean;
59+
pub fn CFBinaryHeapGetTypeID() -> CFTypeID;
60+
pub fn CFBinaryHeapGetValues(heap: CFBinaryHeapRef, values: *const *const c_void);
61+
pub fn CFBinaryHeapRemoveAllValues(heap: CFBinaryHeapRef);
62+
pub fn CFBinaryHeapRemoveMinimumValue(heap: CFBinaryHeapRef);
63+
}

core-foundation-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub mod array;
2424
pub mod attributed_string;
2525
pub mod bag;
2626
pub mod base;
27+
pub mod binary_heap;
2728
pub mod bit_vector;
2829
pub mod bundle;
2930
pub mod calendar;

0 commit comments

Comments
 (0)