From f1022e6be839a790a590e072c81de9ef5b80cb67 Mon Sep 17 00:00:00 2001 From: michaelwright235 Date: Mon, 19 Jun 2023 00:25:07 +0300 Subject: [PATCH] sys: Introduce CFBitVector Implements CFBitVector and CFMutableBitVector related functions. --- core-foundation-sys/src/bit_vector.rs | 55 +++++++++++++++++++++++++++ core-foundation-sys/src/lib.rs | 1 + 2 files changed, 56 insertions(+) create mode 100644 core-foundation-sys/src/bit_vector.rs diff --git a/core-foundation-sys/src/bit_vector.rs b/core-foundation-sys/src/bit_vector.rs new file mode 100644 index 0000000..1c5fc72 --- /dev/null +++ b/core-foundation-sys/src/bit_vector.rs @@ -0,0 +1,55 @@ +// Copyright 2023 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use base::{CFAllocatorRef, Boolean, UInt32, CFIndex, CFTypeID, CFRange, UInt8}; + +#[repr(C)] +pub struct __CFBitVector(c_void); + +pub type CFBitVectorRef = *const __CFBitVector; +pub type CFMutableBitVectorRef = *mut __CFBitVector; +pub type CFBit = UInt32; + +extern { + /* + * CFBitVector.h + */ + + /* CFBitVector */ + /* Creating a Bit Vector */ + pub fn CFBitVectorCreate(allocator: CFAllocatorRef, bytes: *const UInt8, numBits: CFIndex) -> CFBitVectorRef; + pub fn CFBitVectorCreateCopy(allocator: CFAllocatorRef, bv: CFBitVectorRef) -> CFBitVectorRef; + + /* Getting Information About a Bit Vector */ + pub fn CFBitVectorContainsBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> Boolean; + pub fn CFBitVectorGetBitAtIndex(bv: CFBitVectorRef, idx: CFIndex) -> CFBit; + pub fn CFBitVectorGetBits(bv: CFBitVectorRef, range: CFRange, bytes: *mut UInt8); + pub fn CFBitVectorGetCount(bv: CFBitVectorRef) -> CFIndex; + pub fn CFBitVectorGetCountOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex; + pub fn CFBitVectorGetFirstIndexOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex; + pub fn CFBitVectorGetLastIndexOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex; + + /* Getting the CFBitVector Type ID */ + pub fn CFBitVectorGetTypeID() -> CFTypeID; + + /* CFMutableBitVector */ + /* Creating a CFMutableBitVector Object */ + pub fn CFBitVectorCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex) -> CFMutableBitVectorRef; + pub fn CFBitVectorCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, bv: CFBitVectorRef) -> CFMutableBitVectorRef; + + /* Modifying a Bit Vector */ + pub fn CFBitVectorFlipBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex); + pub fn CFBitVectorFlipBits(bv: CFMutableBitVectorRef, range: CFRange); + pub fn CFBitVectorSetAllBits(bv: CFMutableBitVectorRef, value: CFBit); + pub fn CFBitVectorSetBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex, value: CFBit); + pub fn CFBitVectorSetBits(bv: CFMutableBitVectorRef, range: CFRange, value: CFBit); + pub fn CFBitVectorSetCount(bv: CFMutableBitVectorRef, count: CFIndex); +} diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index dd550cd..a16258d 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -24,6 +24,7 @@ pub mod array; pub mod attributed_string; pub mod bag; pub mod base; +pub mod bit_vector; pub mod bundle; pub mod calendar; pub mod characterset;