Debian Codegraph @

.cargo/vendor/core-foundation-sys/src/bag.rs

raw
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::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
13 use crate::string::CFStringRef;
14
15 #[repr(C)]
16 pub struct __CFBag(c_void);
17
18 pub type CFBagRef = *const __CFBag;
19 pub type CFMutableBagRef = *mut __CFBag;
20
21 pub type CFBagRetainCallBack =
22 extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
23 pub type CFBagReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
24 pub type CFBagCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
25 pub type CFBagEqualCallBack =
26 extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
27 pub type CFBagHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode;
28
29 #[repr(C)]
30 #[derive(Debug, Clone, Copy)]
31 pub struct CFBagCallBacks {
32 pub version: CFIndex,
33 pub retain: CFBagRetainCallBack,
34 pub release: CFBagReleaseCallBack,
35 pub copyDescription: CFBagCopyDescriptionCallBack,
36 pub equal: CFBagEqualCallBack,
37 pub hash: CFBagHashCallBack,
38 }
39
40 pub type CFBagApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void);
41
42 extern "C" {
43 /*
44 * CFBag.h
45 */
46 /* Predefined Callback Structures */
47 pub static kCFTypeBagCallBacks: CFBagCallBacks;
48 pub static kCFCopyStringBagCallBacks: CFBagCallBacks;
49
50 /* CFBag */
51 /* Creating a Bag */
52 pub fn CFBagCreate(
53 allocator: CFAllocatorRef,
54 values: *const *const c_void,
55 numValues: CFIndex,
56 callBacks: *const CFBagCallBacks,
57 ) -> CFBagRef;
58 pub fn CFBagCreateCopy(allocator: CFAllocatorRef, theBag: CFBagRef) -> CFBagRef;
59
60 /* Examining a Bag */
61 pub fn CFBagContainsValue(theBag: CFBagRef, value: *const c_void) -> Boolean;
62 pub fn CFBagGetCount(theBag: CFBagRef) -> CFIndex;
63 pub fn CFBagGetCountOfValue(theBag: CFBagRef, value: *const c_void) -> CFIndex;
64 pub fn CFBagGetValue(theBag: CFBagRef, value: *const c_void) -> *const c_void;
65 pub fn CFBagGetValueIfPresent(
66 theBag: CFBagRef,
67 candidate: *const c_void,
68 value: *const *const c_void,
69 ) -> Boolean;
70 pub fn CFBagGetValues(theBag: CFBagRef, values: *const *const c_void);
71
72 /* Applying a Function to the Contents of a Bag */
73 pub fn CFBagApplyFunction(
74 theBag: CFBagRef,
75 applier: CFBagApplierFunction,
76 context: *mut c_void,
77 );
78
79 /* Getting the CFBag Type ID */
80 pub fn CFBagGetTypeID() -> CFTypeID;
81
82 /* CFMutableBag */
83 /* Creating a Mutable Bag */
84 pub fn CFBagCreateMutable(
85 allocator: CFAllocatorRef,
86 capacity: CFIndex,
87 callBacks: *const CFBagCallBacks,
88 ) -> CFMutableBagRef;
89 pub fn CFBagCreateMutableCopy(
90 allocator: CFAllocatorRef,
91 capacity: CFIndex,
92 theBag: CFBagRef,
93 ) -> CFMutableBagRef;
94
95 /* Modifying a Mutable Bag */
96 pub fn CFBagAddValue(theBag: CFMutableBagRef, value: *const c_void);
97 pub fn CFBagRemoveAllValues(theBag: CFMutableBagRef);
98 pub fn CFBagRemoveValue(theBag: CFMutableBagRef, value: *const c_void);
99 pub fn CFBagReplaceValue(theBag: CFMutableBagRef, value: *const c_void);
100 pub fn CFBagSetValue(theBag: CFMutableBagRef, value: *const c_void);
101 }