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