From 91d8daae0e4f198e996738e20ade3dc899752dfe Mon Sep 17 00:00:00 2001 From: michaelwright235 Date: Sun, 18 Jun 2023 23:39:17 +0300 Subject: [PATCH 1/3] sys: Introduce CFBag Implements CFBag related functions and constants. --- core-foundation-sys/src/bag.rs | 78 ++++++++++++++++++++++++++++++++++ core-foundation-sys/src/lib.rs | 1 + 2 files changed, 79 insertions(+) create mode 100644 core-foundation-sys/src/bag.rs diff --git a/core-foundation-sys/src/bag.rs b/core-foundation-sys/src/bag.rs new file mode 100644 index 0000000..3199f00 --- /dev/null +++ b/core-foundation-sys/src/bag.rs @@ -0,0 +1,78 @@ +// 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, CFHashCode, CFIndex, CFTypeID}; +use string::CFStringRef; + +#[repr(C)] +pub struct __CFBag(c_void); + +pub type CFBagRef = *const __CFBag; +pub type CFMutableBagRef = *mut __CFBag; + +pub type CFBagRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFBagReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); +pub type CFBagCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; +pub type CFBagEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; +pub type CFBagHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFBagCallBacks { + pub version: CFIndex, + pub retain: CFBagRetainCallBack, + pub release: CFBagReleaseCallBack, + pub copyDescription: CFBagCopyDescriptionCallBack, + pub equal: CFBagEqualCallBack, + pub hash: CFBagHashCallBack +} + +pub type CFBagApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void); + +extern { + /* + * CFBag.h + */ + /* Predefined Callback Structures */ + pub static kCFTypeBagCallBacks: CFBagCallBacks; + pub static kCFCopyStringBagCallBacks: CFBagCallBacks; + + /* CFBag */ + /* Creating a Bag */ + pub fn CFBagCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, callBacks: *const CFBagCallBacks) -> CFBagRef; + pub fn CFBagCreateCopy(allocator: CFAllocatorRef, theBag: CFBagRef) -> CFBagRef; + + /* Examining a Bag */ + pub fn CFBagContainsValue(theBag: CFBagRef, value: *const c_void) -> Boolean; + pub fn CFBagGetCount(theBag: CFBagRef) -> CFIndex; + pub fn CFBagGetCountOfValue(theBag: CFBagRef, value: *const c_void) -> CFIndex; + pub fn CFBagGetValue(theBag: CFBagRef, value: *const c_void) -> *const c_void; + pub fn CFBagGetValueIfPresent(theBag: CFBagRef, candidate: *const c_void, value: *const *const c_void) -> Boolean; + pub fn CFBagGetValues(theBag: CFBagRef, values: *const *const c_void); + + /* Applying a Function to the Contents of a Bag */ + pub fn CFBagApplyFunction(theBag: CFBagRef, applier: CFBagApplierFunction, context: *mut c_void); + + /* Getting the CFBag Type ID */ + pub fn CFBagGetTypeID() -> CFTypeID; + + /* CFMutableBag */ + /* Creating a Mutable Bag */ + pub fn CFBagCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, callBacks: *const CFBagCallBacks) -> CFMutableBagRef; + pub fn CFBagCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, theBag: CFBagRef) -> CFMutableBagRef; + + /* Modifying a Mutable Bag */ + pub fn CFBagAddValue(theBag: CFMutableBagRef, value: *const c_void); + pub fn CFBagRemoveAllValues(theBag: CFMutableBagRef); + pub fn CFBagRemoveValue(theBag: CFMutableBagRef, value: *const c_void); + pub fn CFBagReplaceValue(theBag: CFMutableBagRef, value: *const c_void); + pub fn CFBagSetValue(theBag: CFMutableBagRef, value: *const c_void); +} diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index c15b3a0..dd550cd 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -22,6 +22,7 @@ extern "C" {} pub mod array; pub mod attributed_string; +pub mod bag; pub mod base; pub mod bundle; pub mod calendar; From f1022e6be839a790a590e072c81de9ef5b80cb67 Mon Sep 17 00:00:00 2001 From: michaelwright235 Date: Mon, 19 Jun 2023 00:25:07 +0300 Subject: [PATCH 2/3] 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; From 5ded43c6be15104659402df78bb6b511e7cae667 Mon Sep 17 00:00:00 2001 From: michaelwright235 Date: Mon, 19 Jun 2023 00:55:20 +0300 Subject: [PATCH 3/3] sys: Introduce CFURLEnumerator Implements CFURLEnumerator related functions and constants. --- core-foundation-sys/src/lib.rs | 1 + core-foundation-sys/src/url_enumerator.rs | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 core-foundation-sys/src/url_enumerator.rs diff --git a/core-foundation-sys/src/lib.rs b/core-foundation-sys/src/lib.rs index dd550cd..0d5d519 100644 --- a/core-foundation-sys/src/lib.rs +++ b/core-foundation-sys/src/lib.rs @@ -51,6 +51,7 @@ pub mod string_tokenizer; pub mod tree; pub mod timezone; pub mod url; +pub mod url_enumerator; #[cfg(target_os = "macos")] pub mod user_notification; pub mod uuid; diff --git a/core-foundation-sys/src/url_enumerator.rs b/core-foundation-sys/src/url_enumerator.rs new file mode 100644 index 0000000..5534266 --- /dev/null +++ b/core-foundation-sys/src/url_enumerator.rs @@ -0,0 +1,49 @@ +// 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::{CFOptionFlags, CFIndex, CFTypeID, CFAllocatorRef, Boolean}; +use url::CFURLRef; +use error::CFErrorRef; +use array::CFArrayRef; + +#[repr(C)] +pub struct __CFURLEnumerator(c_void); + +pub type CFURLEnumeratorRef = *mut __CFURLEnumerator; + +pub type CFURLEnumeratorOptions = CFOptionFlags; +pub const kCFURLEnumeratorDefaultBehavior: CFURLEnumeratorOptions = 0; +pub const kCFURLEnumeratorDescendRecursively: CFURLEnumeratorOptions = 1 << 0; +pub const kCFURLEnumeratorSkipInvisibles: CFURLEnumeratorOptions = 1 << 1; +pub const kCFURLEnumeratorGenerateFileReferenceURLs: CFURLEnumeratorOptions = 1 << 2; +pub const kCFURLEnumeratorSkipPackageContents: CFURLEnumeratorOptions = 1 << 3; +pub const kCFURLEnumeratorIncludeDirectoriesPreOrder: CFURLEnumeratorOptions = 1 << 4; +pub const kCFURLEnumeratorIncludeDirectoriesPostOrder: CFURLEnumeratorOptions = 1 << 5; +//pub const kCFURLEnumeratorGenerateRelativePathURLs = 1UL << 6; // macos(10.15)+ + +pub type CFURLEnumeratorResult = CFIndex; +pub const kCFURLEnumeratorSuccess: CFURLEnumeratorOptions = 1; +pub const kCFURLEnumeratorEnd: CFURLEnumeratorOptions = 2; +pub const kCFURLEnumeratorError: CFURLEnumeratorOptions = 3; +pub const kCFURLEnumeratorDirectoryPostOrderSuccess: CFURLEnumeratorOptions = 4; + +extern { + /* + * CFURLEnumerator.h + */ + pub fn CFURLEnumeratorGetTypeID() -> CFTypeID; + pub fn CFURLEnumeratorCreateForDirectoryURL(alloc: CFAllocatorRef, directoryURL: CFURLRef, option: CFURLEnumeratorOptions, propertyKeys: CFArrayRef) -> CFURLEnumeratorRef; + pub fn CFURLEnumeratorCreateForMountedVolumes(alloc: CFAllocatorRef, option: CFURLEnumeratorOptions, propertyKeys: CFArrayRef) -> CFURLEnumeratorRef; + pub fn CFURLEnumeratorGetNextURL(enumerator: CFURLEnumeratorRef, url: *mut CFURLRef, error: *mut CFErrorRef) -> CFURLEnumeratorResult; + pub fn CFURLEnumeratorSkipDescendents(enumerator: CFURLEnumeratorRef); + pub fn CFURLEnumeratorGetDescendentLevel(enumerator: CFURLEnumeratorRef) -> CFIndex; + pub fn CFURLEnumeratorGetSourceDidChange(enumerator: CFURLEnumeratorRef) -> Boolean; // deprecated since macos 10.7 +}