Skip to content

Commit c1699c6

Browse files
authored
Auto merge of #593 - michaelwright235:bit_v, r=jdm
sys: Introduce CFBitVector Implements CFBitVector and CFMutableBitVector related functions.
2 parents ef44809 + f1022e6 commit c1699c6

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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: 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 bit_vector;
2728
pub mod bundle;
2829
pub mod calendar;
2930
pub mod characterset;

0 commit comments

Comments
 (0)