Skip to content

Commit 5aa2012

Browse files
Merge branch 'master' into bh
2 parents d0d9362 + 614b8d9 commit 5aa2012

File tree

4 files changed

+185
-0
lines changed

4 files changed

+185
-0
lines changed

core-foundation-sys/src/bag.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
}

core-foundation-sys/src/bit_vector.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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, UInt32, CFIndex, CFTypeID, CFRange, UInt8};
13+
14+
#[repr(C)]
15+
pub struct __CFBitVector(c_void);
16+
17+
pub type CFBitVectorRef = *const __CFBitVector;
18+
pub type CFMutableBitVectorRef = *mut __CFBitVector;
19+
pub type CFBit = UInt32;
20+
21+
extern {
22+
/*
23+
* CFBitVector.h
24+
*/
25+
26+
/* CFBitVector */
27+
/* Creating a Bit Vector */
28+
pub fn CFBitVectorCreate(allocator: CFAllocatorRef, bytes: *const UInt8, numBits: CFIndex) -> CFBitVectorRef;
29+
pub fn CFBitVectorCreateCopy(allocator: CFAllocatorRef, bv: CFBitVectorRef) -> CFBitVectorRef;
30+
31+
/* Getting Information About a Bit Vector */
32+
pub fn CFBitVectorContainsBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> Boolean;
33+
pub fn CFBitVectorGetBitAtIndex(bv: CFBitVectorRef, idx: CFIndex) -> CFBit;
34+
pub fn CFBitVectorGetBits(bv: CFBitVectorRef, range: CFRange, bytes: *mut UInt8);
35+
pub fn CFBitVectorGetCount(bv: CFBitVectorRef) -> CFIndex;
36+
pub fn CFBitVectorGetCountOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex;
37+
pub fn CFBitVectorGetFirstIndexOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex;
38+
pub fn CFBitVectorGetLastIndexOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex;
39+
40+
/* Getting the CFBitVector Type ID */
41+
pub fn CFBitVectorGetTypeID() -> CFTypeID;
42+
43+
/* CFMutableBitVector */
44+
/* Creating a CFMutableBitVector Object */
45+
pub fn CFBitVectorCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex) -> CFMutableBitVectorRef;
46+
pub fn CFBitVectorCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, bv: CFBitVectorRef) -> CFMutableBitVectorRef;
47+
48+
/* Modifying a Bit Vector */
49+
pub fn CFBitVectorFlipBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex);
50+
pub fn CFBitVectorFlipBits(bv: CFMutableBitVectorRef, range: CFRange);
51+
pub fn CFBitVectorSetAllBits(bv: CFMutableBitVectorRef, value: CFBit);
52+
pub fn CFBitVectorSetBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex, value: CFBit);
53+
pub fn CFBitVectorSetBits(bv: CFMutableBitVectorRef, range: CFRange, value: CFBit);
54+
pub fn CFBitVectorSetCount(bv: CFMutableBitVectorRef, count: CFIndex);
55+
}

core-foundation-sys/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ extern "C" {}
2222

2323
pub mod array;
2424
pub mod attributed_string;
25+
pub mod bag;
2526
pub mod base;
2627
pub mod binary_heap;
28+
pub mod bit_vector;
2729
pub mod bundle;
2830
pub mod calendar;
2931
pub mod characterset;
@@ -51,6 +53,7 @@ pub mod string_tokenizer;
5153
pub mod tree;
5254
pub mod timezone;
5355
pub mod url;
56+
pub mod url_enumerator;
5457
#[cfg(target_os = "macos")]
5558
pub mod user_notification;
5659
pub mod uuid;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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::{CFOptionFlags, CFIndex, CFTypeID, CFAllocatorRef, Boolean};
13+
use url::CFURLRef;
14+
use error::CFErrorRef;
15+
use array::CFArrayRef;
16+
17+
#[repr(C)]
18+
pub struct __CFURLEnumerator(c_void);
19+
20+
pub type CFURLEnumeratorRef = *mut __CFURLEnumerator;
21+
22+
pub type CFURLEnumeratorOptions = CFOptionFlags;
23+
pub const kCFURLEnumeratorDefaultBehavior: CFURLEnumeratorOptions = 0;
24+
pub const kCFURLEnumeratorDescendRecursively: CFURLEnumeratorOptions = 1 << 0;
25+
pub const kCFURLEnumeratorSkipInvisibles: CFURLEnumeratorOptions = 1 << 1;
26+
pub const kCFURLEnumeratorGenerateFileReferenceURLs: CFURLEnumeratorOptions = 1 << 2;
27+
pub const kCFURLEnumeratorSkipPackageContents: CFURLEnumeratorOptions = 1 << 3;
28+
pub const kCFURLEnumeratorIncludeDirectoriesPreOrder: CFURLEnumeratorOptions = 1 << 4;
29+
pub const kCFURLEnumeratorIncludeDirectoriesPostOrder: CFURLEnumeratorOptions = 1 << 5;
30+
//pub const kCFURLEnumeratorGenerateRelativePathURLs = 1UL << 6; // macos(10.15)+
31+
32+
pub type CFURLEnumeratorResult = CFIndex;
33+
pub const kCFURLEnumeratorSuccess: CFURLEnumeratorOptions = 1;
34+
pub const kCFURLEnumeratorEnd: CFURLEnumeratorOptions = 2;
35+
pub const kCFURLEnumeratorError: CFURLEnumeratorOptions = 3;
36+
pub const kCFURLEnumeratorDirectoryPostOrderSuccess: CFURLEnumeratorOptions = 4;
37+
38+
extern {
39+
/*
40+
* CFURLEnumerator.h
41+
*/
42+
pub fn CFURLEnumeratorGetTypeID() -> CFTypeID;
43+
pub fn CFURLEnumeratorCreateForDirectoryURL(alloc: CFAllocatorRef, directoryURL: CFURLRef, option: CFURLEnumeratorOptions, propertyKeys: CFArrayRef) -> CFURLEnumeratorRef;
44+
pub fn CFURLEnumeratorCreateForMountedVolumes(alloc: CFAllocatorRef, option: CFURLEnumeratorOptions, propertyKeys: CFArrayRef) -> CFURLEnumeratorRef;
45+
pub fn CFURLEnumeratorGetNextURL(enumerator: CFURLEnumeratorRef, url: *mut CFURLRef, error: *mut CFErrorRef) -> CFURLEnumeratorResult;
46+
pub fn CFURLEnumeratorSkipDescendents(enumerator: CFURLEnumeratorRef);
47+
pub fn CFURLEnumeratorGetDescendentLevel(enumerator: CFURLEnumeratorRef) -> CFIndex;
48+
pub fn CFURLEnumeratorGetSourceDidChange(enumerator: CFURLEnumeratorRef) -> Boolean; // deprecated since macos 10.7
49+
}

0 commit comments

Comments
 (0)