diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/core-foundation-sys/src | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/core-foundation-sys/src')
40 files changed, 4622 insertions, 718 deletions
diff --git a/vendor/core-foundation-sys/src/array.rs b/vendor/core-foundation-sys/src/array.rs index c73896125..1e521b3e4 100644 --- a/vendor/core-foundation-sys/src/array.rs +++ b/vendor/core-foundation-sys/src/array.rs @@ -9,18 +9,19 @@ use std::os::raw::c_void; -use base::{CFRange, CFIndex, CFAllocatorRef, CFTypeID, Boolean, CFComparisonResult}; -use string::CFStringRef; +use crate::base::{Boolean, CFAllocatorRef, CFComparatorFunction, CFIndex, CFRange, CFTypeID}; +use crate::string::CFStringRef; -pub type CFArrayRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFArrayRetainCallBack = + extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; pub type CFArrayReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); pub type CFArrayCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; -pub type CFArrayEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; +pub type CFArrayEqualCallBack = + extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; pub type CFArrayApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void); -pub type CFComparatorFunction = extern "C" fn(val1: *const c_void, val2: *const c_void) -> CFComparisonResult; #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct CFArrayCallBacks { pub version: CFIndex, pub retain: CFArrayRetainCallBack, @@ -35,33 +36,107 @@ pub struct __CFArray(c_void); pub type CFArrayRef = *const __CFArray; pub type CFMutableArrayRef = *mut __CFArray; -extern { +extern "C" { /* * CFArray.h */ + pub static kCFTypeArrayCallBacks: CFArrayCallBacks; - pub fn CFArrayGetTypeID() -> CFTypeID; - pub fn CFArrayCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, callBacks: *const CFArrayCallBacks) -> CFArrayRef; - pub fn CFArrayCreateCopy(allocator: CFAllocatorRef , theArray: CFArrayRef) -> CFArrayRef; - pub fn CFArrayCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, callBacks: *const CFArrayCallBacks) -> CFMutableArrayRef; - pub fn CFArrayCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, theArray: CFArrayRef)-> CFMutableArrayRef; + /* CFArray */ + /* Creating an Array */ + pub fn CFArrayCreate( + allocator: CFAllocatorRef, + values: *const *const c_void, + numValues: CFIndex, + callBacks: *const CFArrayCallBacks, + ) -> CFArrayRef; + pub fn CFArrayCreateCopy(allocator: CFAllocatorRef, theArray: CFArrayRef) -> CFArrayRef; + + /* Examining an Array */ + pub fn CFArrayBSearchValues( + theArray: CFArrayRef, + range: CFRange, + value: *const c_void, + comparator: CFComparatorFunction, + context: *mut c_void, + ) -> CFIndex; + pub fn CFArrayContainsValue( + theArray: CFArrayRef, + range: CFRange, + value: *const c_void, + ) -> Boolean; pub fn CFArrayGetCount(theArray: CFArrayRef) -> CFIndex; - pub fn CFArrayGetCountOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex; - pub fn CFArrayContainsValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> Boolean; - pub fn CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void; + pub fn CFArrayGetCountOfValue( + theArray: CFArrayRef, + range: CFRange, + value: *const c_void, + ) -> CFIndex; + pub fn CFArrayGetFirstIndexOfValue( + theArray: CFArrayRef, + range: CFRange, + value: *const c_void, + ) -> CFIndex; + pub fn CFArrayGetLastIndexOfValue( + theArray: CFArrayRef, + range: CFRange, + value: *const c_void, + ) -> CFIndex; pub fn CFArrayGetValues(theArray: CFArrayRef, range: CFRange, values: *mut *const c_void); - pub fn CFArrayApplyFunction(theArray: CFArrayRef, range: CFRange, applier: CFArrayApplierFunction, context: *mut c_void); - pub fn CFArrayGetFirstIndexOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex; - pub fn CFArrayGetLastIndexOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex; - pub fn CFArrayBSearchValues(theArray: CFArrayRef, range: CFRange, value: *const c_void, comparator: CFComparatorFunction, context: *mut c_void) -> CFIndex; + pub fn CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void; + + /* Applying a Function to Elements */ + pub fn CFArrayApplyFunction( + theArray: CFArrayRef, + range: CFRange, + applier: CFArrayApplierFunction, + context: *mut c_void, + ); + + /* Getting the CFArray Type ID */ + pub fn CFArrayGetTypeID() -> CFTypeID; + + /* CFMutableArray */ + /* CFMutableArray Miscellaneous Functions */ + pub fn CFArrayAppendArray( + theArray: CFMutableArrayRef, + otherArray: CFArrayRef, + otherRange: CFRange, + ); pub fn CFArrayAppendValue(theArray: CFMutableArrayRef, value: *const c_void); - pub fn CFArrayInsertValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void); - pub fn CFArraySetValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void); - pub fn CFArrayRemoveValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex); + pub fn CFArrayCreateMutable( + allocator: CFAllocatorRef, + capacity: CFIndex, + callBacks: *const CFArrayCallBacks, + ) -> CFMutableArrayRef; + pub fn CFArrayCreateMutableCopy( + allocator: CFAllocatorRef, + capacity: CFIndex, + theArray: CFArrayRef, + ) -> CFMutableArrayRef; + pub fn CFArrayExchangeValuesAtIndices( + theArray: CFMutableArrayRef, + idx1: CFIndex, + idx2: CFIndex, + ); + pub fn CFArrayInsertValueAtIndex( + theArray: CFMutableArrayRef, + idx: CFIndex, + value: *const c_void, + ); pub fn CFArrayRemoveAllValues(theArray: CFMutableArrayRef); - pub fn CFArrayReplaceValues(theArray: CFMutableArrayRef, range: CFRange, newValues: *mut *const c_void, newCount: CFIndex); - pub fn CFArrayExchangeValuesAtIndices(theArray: CFMutableArrayRef, idx1: CFIndex, idx2: CFIndex); - pub fn CFArraySortValues(theArray: CFMutableArrayRef, range: CFRange, comparator: CFComparatorFunction, context: *mut c_void); - pub fn CFArrayAppendArray(theArray: CFMutableArrayRef, otherArray: CFArrayRef, otherRange: CFRange ); + pub fn CFArrayRemoveValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex); + pub fn CFArrayReplaceValues( + theArray: CFMutableArrayRef, + range: CFRange, + newValues: *mut *const c_void, + newCount: CFIndex, + ); + pub fn CFArraySetValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void); + pub fn CFArraySortValues( + theArray: CFMutableArrayRef, + range: CFRange, + comparator: CFComparatorFunction, + context: *mut c_void, + ); } diff --git a/vendor/core-foundation-sys/src/attributed_string.rs b/vendor/core-foundation-sys/src/attributed_string.rs index c91bf5be3..54c27ec41 100644 --- a/vendor/core-foundation-sys/src/attributed_string.rs +++ b/vendor/core-foundation-sys/src/attributed_string.rs @@ -7,49 +7,114 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, CFTypeRef}; +use crate::dictionary::CFDictionaryRef; +use crate::string::CFMutableStringRef; +use crate::string::CFStringRef; use std::os::raw::c_void; -use base::{CFAllocatorRef, CFTypeRef, CFIndex, CFRange, CFTypeID}; -use string::CFStringRef; -use dictionary::CFDictionaryRef; #[repr(C)] pub struct __CFAttributedString(c_void); pub type CFAttributedStringRef = *const __CFAttributedString; -pub type CFMutableAttributedStringRef = *const __CFAttributedString; +pub type CFMutableAttributedStringRef = *mut __CFAttributedString; -extern { - /* CFAttributedString */ +extern "C" { + /* + * CFAttributedString.h + */ + /* CFAttributedString */ + /* Creating a CFAttributedString */ pub fn CFAttributedStringCreate( allocator: CFAllocatorRef, str: CFStringRef, attributes: CFDictionaryRef, ) -> CFAttributedStringRef; - + pub fn CFAttributedStringCreateCopy( + alloc: CFAllocatorRef, + aStr: CFAttributedStringRef, + ) -> CFAttributedStringRef; + pub fn CFAttributedStringCreateWithSubstring( + alloc: CFAllocatorRef, + aStr: CFAttributedStringRef, + range: CFRange, + ) -> CFAttributedStringRef; pub fn CFAttributedStringGetLength(astr: CFAttributedStringRef) -> CFIndex; + pub fn CFAttributedStringGetString(aStr: CFAttributedStringRef) -> CFStringRef; + + /* Accessing Attributes */ + pub fn CFAttributedStringGetAttribute( + aStr: CFAttributedStringRef, + loc: CFIndex, + attrName: CFStringRef, + effectiveRange: *mut CFRange, + ) -> CFTypeRef; + pub fn CFAttributedStringGetAttributes( + aStr: CFAttributedStringRef, + loc: CFIndex, + effectiveRange: *mut CFRange, + ) -> CFDictionaryRef; + pub fn CFAttributedStringGetAttributeAndLongestEffectiveRange( + aStr: CFAttributedStringRef, + loc: CFIndex, + attrName: CFStringRef, + inRange: CFRange, + longestEffectiveRange: *mut CFRange, + ) -> CFTypeRef; + pub fn CFAttributedStringGetAttributesAndLongestEffectiveRange( + aStr: CFAttributedStringRef, + loc: CFIndex, + inRange: CFRange, + longestEffectiveRange: *mut CFRange, + ) -> CFDictionaryRef; + /* Getting Attributed String Properties */ pub fn CFAttributedStringGetTypeID() -> CFTypeID; /* CFMutableAttributedString */ - - pub fn CFAttributedStringCreateMutableCopy( - allocator: CFAllocatorRef, max_length: CFIndex, astr: CFAttributedStringRef - ) -> CFMutableAttributedStringRef; - + /* Creating a CFMutableAttributedString */ pub fn CFAttributedStringCreateMutable( allocator: CFAllocatorRef, max_length: CFIndex, ) -> CFMutableAttributedStringRef; + pub fn CFAttributedStringCreateMutableCopy( + allocator: CFAllocatorRef, + max_length: CFIndex, + astr: CFAttributedStringRef, + ) -> CFMutableAttributedStringRef; + /* Modifying a CFMutableAttributedString */ + pub fn CFAttributedStringBeginEditing(aStr: CFMutableAttributedStringRef); + pub fn CFAttributedStringEndEditing(aStr: CFMutableAttributedStringRef); + pub fn CFAttributedStringGetMutableString( + aStr: CFMutableAttributedStringRef, + ) -> CFMutableStringRef; + pub fn CFAttributedStringRemoveAttribute( + aStr: CFMutableAttributedStringRef, + range: CFRange, + attrName: CFStringRef, + ); pub fn CFAttributedStringReplaceString( - astr: CFMutableAttributedStringRef, range: CFRange, replacement: CFStringRef); - + aStr: CFMutableAttributedStringRef, + range: CFRange, + replacement: CFStringRef, + ); + pub fn CFAttributedStringReplaceAttributedString( + aStr: CFMutableAttributedStringRef, + range: CFRange, + replacement: CFAttributedStringRef, + ); pub fn CFAttributedStringSetAttribute( - astr: CFMutableAttributedStringRef, + aStr: CFMutableAttributedStringRef, range: CFRange, - attr_name: CFStringRef, + attrName: CFStringRef, value: CFTypeRef, ); - + pub fn CFAttributedStringSetAttributes( + aStr: CFMutableAttributedStringRef, + range: CFRange, + replacement: CFDictionaryRef, + clearOtherAttributes: Boolean, + ); } diff --git a/vendor/core-foundation-sys/src/bag.rs b/vendor/core-foundation-sys/src/bag.rs new file mode 100644 index 000000000..041caa59c --- /dev/null +++ b/vendor/core-foundation-sys/src/bag.rs @@ -0,0 +1,101 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID}; +use crate::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 "C" { + /* + * 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/vendor/core-foundation-sys/src/base.rs b/vendor/core-foundation-sys/src/base.rs index 52a166fdf..78e06a65f 100644 --- a/vendor/core-foundation-sys/src/base.rs +++ b/vendor/core-foundation-sys/src/base.rs @@ -7,21 +7,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::string::CFStringRef; use std::cmp::Ordering; -use std::os::raw::{c_uint, c_void, c_int}; -use string::CFStringRef; +use std::os::raw::{c_int, c_short, c_uchar, c_uint, c_ushort, c_void}; pub type Boolean = u8; pub type mach_port_t = c_uint; pub type CFAllocatorRef = *const c_void; pub type CFNullRef = *const c_void; pub type CFTypeRef = *const c_void; +pub type ConstStr255Param = *const c_uchar; +pub type StringPtr = *mut c_uchar; +pub type ConstStringPtr = *const c_uchar; pub type OSStatus = i32; +pub type UInt8 = c_uchar; +pub type UInt16 = c_ushort; +pub type SInt16 = c_short; pub type SInt32 = c_int; +pub type UInt32 = c_uint; pub type CFTypeID = usize; pub type CFOptionFlags = usize; pub type CFHashCode = usize; pub type CFIndex = isize; +pub type LangCode = SInt16; +pub type RegionCode = SInt16; +pub type UTF32Char = c_uint; +pub type UTF16Char = c_ushort; +pub type UTF8Char = c_uchar; #[repr(isize)] #[derive(Clone, Copy, Debug, PartialEq)] @@ -31,43 +43,53 @@ pub enum CFComparisonResult { GreaterThan = 1, } -impl Into<Ordering> for CFComparisonResult { - fn into(self) -> Ordering { - match self { +pub type CFComparatorFunction = extern "C" fn( + val1: *const c_void, + val2: *const c_void, + context: *mut c_void, +) -> CFComparisonResult; + +impl From<CFComparisonResult> for Ordering { + fn from(val: CFComparisonResult) -> Self { + match val { CFComparisonResult::LessThan => Ordering::Less, CFComparisonResult::EqualTo => Ordering::Equal, - CFComparisonResult::GreaterThan => Ordering::Greater + CFComparisonResult::GreaterThan => Ordering::Greater, } } } #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug, PartialEq)] pub struct CFRange { pub location: CFIndex, - pub length: CFIndex + pub length: CFIndex, } // for back-compat impl CFRange { pub fn init(location: CFIndex, length: CFIndex) -> CFRange { - CFRange { - location: location, - length: length, - } + CFRange { location, length } } } pub type CFAllocatorRetainCallBack = extern "C" fn(info: *mut c_void) -> *mut c_void; pub type CFAllocatorReleaseCallBack = extern "C" fn(info: *mut c_void); pub type CFAllocatorCopyDescriptionCallBack = extern "C" fn(info: *mut c_void) -> CFStringRef; -pub type CFAllocatorAllocateCallBack = extern "C" fn(allocSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void; -pub type CFAllocatorReallocateCallBack = extern "C" fn(ptr: *mut c_void, newsize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void; +pub type CFAllocatorAllocateCallBack = + extern "C" fn(allocSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void; +pub type CFAllocatorReallocateCallBack = extern "C" fn( + ptr: *mut c_void, + newsize: CFIndex, + hint: CFOptionFlags, + info: *mut c_void, +) -> *mut c_void; pub type CFAllocatorDeallocateCallBack = extern "C" fn(ptr: *mut c_void, info: *mut c_void); -pub type CFAllocatorPreferredSizeCallBack = extern "C" fn(size: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> CFIndex; +pub type CFAllocatorPreferredSizeCallBack = + extern "C" fn(size: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> CFIndex; #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct CFAllocatorContext { pub version: CFIndex, pub info: *mut c_void, @@ -77,7 +99,7 @@ pub struct CFAllocatorContext { pub allocate: Option<CFAllocatorAllocateCallBack>, pub reallocate: Option<CFAllocatorReallocateCallBack>, pub deallocate: Option<CFAllocatorDeallocateCallBack>, - pub preferredSize: Option<CFAllocatorPreferredSizeCallBack> + pub preferredSize: Option<CFAllocatorPreferredSizeCallBack>, } /// Trait for all types which are Core Foundation reference types. @@ -110,7 +132,7 @@ impl<T> TCFTypeRef for *mut T { /// Constant used by some functions to indicate failed searches. pub static kCFNotFound: CFIndex = -1; -extern { +extern "C" { /* * CFBase.h */ @@ -124,11 +146,27 @@ extern { pub static kCFAllocatorNull: CFAllocatorRef; pub static kCFAllocatorUseContext: CFAllocatorRef; - pub fn CFAllocatorCreate(allocator: CFAllocatorRef, context: *mut CFAllocatorContext) -> CFAllocatorRef; - pub fn CFAllocatorAllocate(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> *mut c_void; + pub fn CFAllocatorCreate( + allocator: CFAllocatorRef, + context: *mut CFAllocatorContext, + ) -> CFAllocatorRef; + pub fn CFAllocatorAllocate( + allocator: CFAllocatorRef, + size: CFIndex, + hint: CFOptionFlags, + ) -> *mut c_void; pub fn CFAllocatorDeallocate(allocator: CFAllocatorRef, ptr: *mut c_void); - pub fn CFAllocatorGetPreferredSizeForSize(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> CFIndex; - pub fn CFAllocatorReallocate(allocator: CFAllocatorRef, ptr: *mut c_void, newsize: CFIndex, hint: CFOptionFlags) -> *mut c_void; + pub fn CFAllocatorGetPreferredSizeForSize( + allocator: CFAllocatorRef, + size: CFIndex, + hint: CFOptionFlags, + ) -> CFIndex; + pub fn CFAllocatorReallocate( + allocator: CFAllocatorRef, + ptr: *mut c_void, + newsize: CFIndex, + hint: CFOptionFlags, + ) -> *mut c_void; pub fn CFAllocatorGetDefault() -> CFAllocatorRef; pub fn CFAllocatorSetDefault(allocator: CFAllocatorRef); pub fn CFAllocatorGetContext(allocator: CFAllocatorRef, context: *mut CFAllocatorContext); @@ -138,10 +176,12 @@ extern { pub static kCFNull: CFNullRef; + pub fn CFNullGetTypeID() -> CFTypeID; + /* CFType Reference */ - //fn CFCopyTypeIDDescription - //fn CFGetAllocator + pub fn CFCopyTypeIDDescription(type_id: CFTypeID) -> CFStringRef; + pub fn CFGetAllocator(cf: CFTypeRef) -> CFAllocatorRef; pub fn CFCopyDescription(cf: CFTypeRef) -> CFStringRef; pub fn CFEqual(cf1: CFTypeRef, cf2: CFTypeRef) -> Boolean; pub fn CFGetRetainCount(cf: CFTypeRef) -> CFIndex; diff --git a/vendor/core-foundation-sys/src/binary_heap.rs b/vendor/core-foundation-sys/src/binary_heap.rs new file mode 100644 index 000000000..8bcaa8e26 --- /dev/null +++ b/vendor/core-foundation-sys/src/binary_heap.rs @@ -0,0 +1,83 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID}; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFBinaryHeap(c_void); + +pub type CFBinaryHeapRef = *mut __CFBinaryHeap; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFBinaryHeapCompareContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn(info: *const c_void) -> *const c_void, + pub release: extern "C" fn(info: *const c_void), + pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFBinaryHeapCallBacks { + pub version: CFIndex, + pub retain: extern "C" fn(allocator: CFAllocatorRef, ptr: *const c_void) -> *const c_void, + pub release: extern "C" fn(allocator: CFAllocatorRef, ptr: *const c_void), + pub copyDescription: extern "C" fn(ptr: *const c_void) -> CFStringRef, + pub compare: extern "C" fn( + ptr1: *const c_void, + ptr2: *const c_void, + context: *mut c_void, + ) -> CFComparisonResult, +} + +pub type CFBinaryHeapApplierFunction = extern "C" fn(val: *const c_void, context: *const c_void); + +extern "C" { + /* + * CFBinaryHeap.h + */ + /* Predefined Callback Structures */ + pub static kCFStringBinaryHeapCallBacks: CFBinaryHeapCallBacks; + + /* CFBinaryHeap Miscellaneous Functions */ + pub fn CFBinaryHeapAddValue(heap: CFBinaryHeapRef, value: *const c_void); + pub fn CFBinaryHeapApplyFunction( + heap: CFBinaryHeapRef, + applier: CFBinaryHeapApplierFunction, + context: *mut c_void, + ); + pub fn CFBinaryHeapContainsValue(heap: CFBinaryHeapRef, value: *const c_void) -> Boolean; + pub fn CFBinaryHeapCreate( + allocator: CFAllocatorRef, + capacity: CFIndex, + callBacks: *const CFBinaryHeapCallBacks, + compareContext: *const CFBinaryHeapCompareContext, + ) -> CFBinaryHeapRef; + pub fn CFBinaryHeapCreateCopy( + allocator: CFAllocatorRef, + capacity: CFIndex, + heap: CFBinaryHeapRef, + ) -> CFBinaryHeapRef; + pub fn CFBinaryHeapGetCount(heap: CFBinaryHeapRef) -> CFIndex; + pub fn CFBinaryHeapGetCountOfValue(heap: CFBinaryHeapRef, value: *const c_void) -> CFIndex; + pub fn CFBinaryHeapGetMinimum(heap: CFBinaryHeapRef) -> *const c_void; + pub fn CFBinaryHeapGetMinimumIfPresent( + heap: CFBinaryHeapRef, + value: *const *const c_void, + ) -> Boolean; + pub fn CFBinaryHeapGetTypeID() -> CFTypeID; + pub fn CFBinaryHeapGetValues(heap: CFBinaryHeapRef, values: *const *const c_void); + pub fn CFBinaryHeapRemoveAllValues(heap: CFBinaryHeapRef); + pub fn CFBinaryHeapRemoveMinimumValue(heap: CFBinaryHeapRef); +} diff --git a/vendor/core-foundation-sys/src/bit_vector.rs b/vendor/core-foundation-sys/src/bit_vector.rs new file mode 100644 index 000000000..f270c3d1d --- /dev/null +++ b/vendor/core-foundation-sys/src/bit_vector.rs @@ -0,0 +1,74 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UInt32, UInt8}; + +#[repr(C)] +pub struct __CFBitVector(c_void); + +pub type CFBitVectorRef = *const __CFBitVector; +pub type CFMutableBitVectorRef = *mut __CFBitVector; +pub type CFBit = UInt32; + +extern "C" { + /* + * 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/vendor/core-foundation-sys/src/bundle.rs b/vendor/core-foundation-sys/src/bundle.rs index 29f8e1261..60aaa4c77 100644 --- a/vendor/core-foundation-sys/src/bundle.rs +++ b/vendor/core-foundation-sys/src/bundle.rs @@ -9,31 +9,226 @@ use std::os::raw::c_void; -use base::{CFTypeID, CFAllocatorRef}; -use url::CFURLRef; -use dictionary::CFDictionaryRef; -use string::CFStringRef; +use crate::array::CFArrayRef; +#[cfg(target_os = "macos")] +use crate::base::SInt32; +use crate::base::{Boolean, CFAllocatorRef, CFTypeID, CFTypeRef, UInt32}; +use crate::dictionary::CFDictionaryRef; +use crate::error::CFErrorRef; +use crate::string::CFStringRef; +use crate::url::CFURLRef; +use std::os::raw::{c_int, c_uint}; #[repr(C)] pub struct __CFBundle(c_void); pub type CFBundleRef = *mut __CFBundle; +pub type CFPlugInRef = *mut __CFBundle; +pub type CFBundleRefNum = c_int; -extern { +#[allow(unused)] +#[inline(always)] +pub unsafe fn CFCopyLocalizedString(key: CFStringRef, comment: CFStringRef) -> CFStringRef { + CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, std::ptr::null()) +} +#[allow(unused)] +#[inline(always)] +pub unsafe fn CFCopyLocalizedStringFromTable( + key: CFStringRef, + tbl: CFStringRef, + comment: CFStringRef, +) -> CFStringRef { + CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, tbl) +} +#[allow(unused)] +#[inline(always)] +pub unsafe fn CFCopyLocalizedStringFromTableInBundle( + key: CFStringRef, + tbl: CFStringRef, + bundle: CFBundleRef, + comment: CFStringRef, +) -> CFStringRef { + CFBundleCopyLocalizedString(bundle, key, key, tbl) +} +#[allow(unused)] +#[inline(always)] +pub unsafe fn CFCopyLocalizedStringWithDefaultValue( + key: CFStringRef, + tbl: CFStringRef, + bundle: CFBundleRef, + value: CFStringRef, + comment: CFStringRef, +) -> CFStringRef { + CFBundleCopyLocalizedString(bundle, key, value, tbl) +} + +pub static kCFBundleExecutableArchitectureI386: c_uint = 0x00000007; +pub static kCFBundleExecutableArchitecturePPC: c_uint = 0x00000012; +pub static kCFBundleExecutableArchitectureX86_64: c_uint = 0x01000007; +pub static kCFBundleExecutableArchitecturePPC64: c_uint = 0x01000012; +//pub static kCFBundleExecutableArchitectureARM64: c_uint = 0x0100000c; //macos(11.0)+ + +extern "C" { /* * CFBundle.h */ - pub fn CFBundleCreate(allocator: CFAllocatorRef, bundleURL: CFURLRef) -> CFBundleRef; + /* Information Property List Keys */ + pub static kCFBundleInfoDictionaryVersionKey: CFStringRef; + pub static kCFBundleExecutableKey: CFStringRef; + pub static kCFBundleIdentifierKey: CFStringRef; + pub static kCFBundleVersionKey: CFStringRef; + pub static kCFBundleDevelopmentRegionKey: CFStringRef; + pub static kCFBundleNameKey: CFStringRef; + pub static kCFBundleLocalizationsKey: CFStringRef; + + /* Creating and Accessing Bundles */ + pub fn CFBundleCreate(allocator: CFAllocatorRef, bundleURL: CFURLRef) -> CFBundleRef; + pub fn CFBundleCreateBundlesFromDirectory( + allocator: CFAllocatorRef, + directoryURL: CFURLRef, + bundleType: CFStringRef, + ) -> CFArrayRef; + pub fn CFBundleGetAllBundles() -> CFArrayRef; pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef; - pub fn CFBundleGetFunctionPointerForName(bundle: CFBundleRef, function_name: CFStringRef) -> *const c_void; pub fn CFBundleGetMainBundle() -> CFBundleRef; - pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; - pub fn CFBundleGetTypeID() -> CFTypeID; + /* Loading and Unloading a Bundle */ + pub fn CFBundleIsExecutableLoaded(bundle: CFBundleRef) -> Boolean; + pub fn CFBundlePreflightExecutable(bundle: CFBundleRef, error: *mut CFErrorRef) -> Boolean; + pub fn CFBundleLoadExecutable(bundle: CFBundleRef) -> Boolean; + pub fn CFBundleLoadExecutableAndReturnError( + bundle: CFBundleRef, + error: *mut CFErrorRef, + ) -> Boolean; + pub fn CFBundleUnloadExecutable(bundle: CFBundleRef); + + /* Finding Locations in a Bundle */ + pub fn CFBundleCopyAuxiliaryExecutableURL( + bundle: CFBundleRef, + executableName: CFStringRef, + ) -> CFURLRef; + pub fn CFBundleCopyBuiltInPlugInsURL(bundle: CFBundleRef) -> CFURLRef; pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef; pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleCopyResourcesDirectoryURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleCopySharedFrameworksURL(bundle: CFBundleRef) -> CFURLRef; pub fn CFBundleCopySharedSupportURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleCopySupportFilesDirectoryURL(bundle: CFBundleRef) -> CFURLRef; + + /* Locating Bundle Resources */ + #[cfg(target_os = "macos")] + pub fn CFBundleCloseBundleResourceMap(bundle: CFBundleRef, refNum: CFBundleRefNum); // DEPRECATED macosx(10.0, 10.15) + pub fn CFBundleCopyResourceURL( + bundle: CFBundleRef, + resourceName: CFStringRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + ) -> CFURLRef; + pub fn CFBundleCopyResourceURLInDirectory( + bundleURL: CFURLRef, + resourceName: CFStringRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + ) -> CFURLRef; + pub fn CFBundleCopyResourceURLsOfType( + bundle: CFBundleRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + ) -> CFArrayRef; + pub fn CFBundleCopyResourceURLsOfTypeInDirectory( + bundleURL: CFURLRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + ) -> CFArrayRef; + pub fn CFBundleCopyResourceURLForLocalization( + bundle: CFBundleRef, + resourceName: CFStringRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + localizationName: CFStringRef, + ) -> CFURLRef; + pub fn CFBundleCopyResourceURLsOfTypeForLocalization( + bundle: CFBundleRef, + resourceType: CFStringRef, + subDirName: CFStringRef, + localizationName: CFStringRef, + ) -> CFArrayRef; + #[cfg(target_os = "macos")] + pub fn CFBundleOpenBundleResourceFiles( + bundle: CFBundleRef, + refNum: *mut CFBundleRefNum, + localizedRefNum: *mut CFBundleRefNum, + ) -> SInt32; // DEPRECATED macosx(10.0, 10.15) + #[cfg(target_os = "macos")] + pub fn CFBundleOpenBundleResourceMap(bundle: CFBundleRef) -> CFBundleRefNum; // DEPRECATED macosx(10.0, 10.15) + + /* Managing Localizations */ + pub fn CFBundleCopyBundleLocalizations(bundle: CFBundleRef) -> CFArrayRef; + pub fn CFBundleCopyLocalizedString( + bundle: CFBundleRef, + key: CFStringRef, + value: CFStringRef, + tableName: CFStringRef, + ) -> CFStringRef; + pub fn CFBundleCopyLocalizationsForPreferences( + locArray: CFArrayRef, + prefArray: CFArrayRef, + ) -> CFArrayRef; + pub fn CFBundleCopyLocalizationsForURL(url: CFURLRef) -> CFArrayRef; + pub fn CFBundleCopyPreferredLocalizationsFromArray(locArray: CFArrayRef) -> CFArrayRef; + + /* Managing Executable Code */ + pub fn CFBundleGetDataPointerForName( + bundle: CFBundleRef, + symbolName: CFStringRef, + ) -> *mut c_void; + pub fn CFBundleGetDataPointersForNames( + bundle: CFBundleRef, + symbolNames: CFArrayRef, + stbl: *mut [c_void], + ); + pub fn CFBundleGetFunctionPointerForName( + bundle: CFBundleRef, + function_name: CFStringRef, + ) -> *const c_void; + pub fn CFBundleGetFunctionPointersForNames( + bundle: CFBundleRef, + functionNames: CFArrayRef, + ftbl: *mut [c_void], + ); + pub fn CFBundleGetPlugIn(bundle: CFBundleRef) -> CFPlugInRef; + + /* Getting Bundle Properties */ pub fn CFBundleCopyBundleURL(bundle: CFBundleRef) -> CFURLRef; - pub fn CFBundleCopyResourcesDirectoryURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleGetDevelopmentRegion(bundle: CFBundleRef) -> CFStringRef; + pub fn CFBundleGetIdentifier(bundle: CFBundleRef) -> CFStringRef; + pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; + pub fn CFBundleGetLocalInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; + pub fn CFBundleGetValueForInfoDictionaryKey(bundle: CFBundleRef, key: CFStringRef) + -> CFTypeRef; + pub fn CFBundleCopyInfoDictionaryInDirectory(bundleURL: CFURLRef) -> CFDictionaryRef; + pub fn CFBundleCopyInfoDictionaryForURL(url: CFURLRef) -> CFDictionaryRef; + pub fn CFBundleGetPackageInfo( + bundle: CFBundleRef, + packageType: *mut UInt32, + packageCreator: *mut UInt32, + ); + pub fn CFBundleGetPackageInfoInDirectory( + url: CFURLRef, + packageType: *mut UInt32, + packageCreator: *mut UInt32, + ) -> Boolean; + pub fn CFBundleCopyExecutableArchitectures(bundle: CFBundleRef) -> CFArrayRef; + pub fn CFBundleCopyExecutableArchitecturesForURL(url: CFURLRef) -> CFArrayRef; + pub fn CFBundleGetVersionNumber(bundle: CFBundleRef) -> UInt32; + + /* macos(11.0)+ + pub fn CFBundleIsExecutableLoadable(bundle: CFBundleRef) -> Boolean; + pub fn CFBundleIsExecutableLoadableForURL(url: CFURLRef) -> Boolean; + pub fn CFBundleIsArchitectureLoadable(arch: cpu_type_t) -> Boolean; + */ + + /* Getting the CFBundle Type ID */ + pub fn CFBundleGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/calendar.rs b/vendor/core-foundation-sys/src/calendar.rs new file mode 100644 index 000000000..54c2a00cd --- /dev/null +++ b/vendor/core-foundation-sys/src/calendar.rs @@ -0,0 +1,128 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_char, c_void}; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID}; +use crate::date::{CFAbsoluteTime, CFTimeInterval}; +use crate::locale::{CFCalendarIdentifier, CFLocaleRef}; +use crate::timezone::CFTimeZoneRef; + +#[repr(C)] +pub struct __CFCalendar(c_void); +pub type CFCalendarRef = *mut __CFCalendar; + +pub type CFCalendarUnit = CFOptionFlags; +pub const kCFCalendarUnitEra: CFCalendarUnit = 1 << 1; +pub const kCFCalendarUnitYear: CFCalendarUnit = 1 << 2; +pub const kCFCalendarUnitMonth: CFCalendarUnit = 1 << 3; +pub const kCFCalendarUnitDay: CFCalendarUnit = 1 << 4; +pub const kCFCalendarUnitHour: CFCalendarUnit = 1 << 5; +pub const kCFCalendarUnitMinute: CFCalendarUnit = 1 << 6; +pub const kCFCalendarUnitSecond: CFCalendarUnit = 1 << 7; +pub const kCFCalendarUnitWeek: CFCalendarUnit = 1 << 8; // deprecated since macos 10.10 +pub const kCFCalendarUnitWeekday: CFCalendarUnit = 1 << 9; +pub const kCFCalendarUnitWeekdayOrdinal: CFCalendarUnit = 1 << 10; +pub const kCFCalendarUnitQuarter: CFCalendarUnit = 1 << 11; +pub const kCFCalendarUnitWeekOfMonth: CFCalendarUnit = 1 << 12; +pub const kCFCalendarUnitWeekOfYear: CFCalendarUnit = 1 << 13; +pub const kCFCalendarUnitYearForWeekOfYear: CFCalendarUnit = 1 << 14; + +pub const kCFCalendarComponentsWrap: CFOptionFlags = 1 << 0; + +extern "C" { + /* + * CFCalendar.h + */ + + /* Creating a Calendar */ + pub fn CFCalendarCopyCurrent() -> CFCalendarRef; + pub fn CFCalendarCreateWithIdentifier( + allocator: CFAllocatorRef, + identifier: CFCalendarIdentifier, + ) -> CFCalendarRef; + + /* Calendrical Calculations */ + pub fn CFCalendarAddComponents( + identifier: CFCalendarIdentifier, + /* inout */ at: *mut CFAbsoluteTime, + options: CFOptionFlags, + componentDesc: *const char, + ... + ) -> Boolean; + pub fn CFCalendarComposeAbsoluteTime( + identifier: CFCalendarIdentifier, + /* out */ at: *mut CFAbsoluteTime, + componentDesc: *const c_char, + ... + ) -> Boolean; + pub fn CFCalendarDecomposeAbsoluteTime( + identifier: CFCalendarIdentifier, + at: CFAbsoluteTime, + componentDesc: *const c_char, + ... + ) -> Boolean; + pub fn CFCalendarGetComponentDifference( + identifier: CFCalendarIdentifier, + startingAT: CFAbsoluteTime, + resultAT: CFAbsoluteTime, + options: CFOptionFlags, + componentDesc: *const c_char, + ... + ) -> Boolean; + + /* Getting Ranges of Units */ + pub fn CFCalendarGetRangeOfUnit( + identifier: CFCalendarIdentifier, + smallerUnit: CFCalendarUnit, + biggerUnit: CFCalendarUnit, + at: CFAbsoluteTime, + ) -> CFRange; + pub fn CFCalendarGetOrdinalityOfUnit( + identifier: CFCalendarIdentifier, + smallerUnit: CFCalendarUnit, + biggerUnit: CFCalendarUnit, + at: CFAbsoluteTime, + ) -> CFIndex; + pub fn CFCalendarGetTimeRangeOfUnit( + identifier: CFCalendarIdentifier, + unit: CFCalendarUnit, + at: CFAbsoluteTime, + startp: *mut CFAbsoluteTime, + tip: *mut CFTimeInterval, + ) -> Boolean; + pub fn CFCalendarGetMaximumRangeOfUnit( + identifier: CFCalendarIdentifier, + unit: CFCalendarUnit, + ) -> CFRange; + pub fn CFCalendarGetMinimumRangeOfUnit( + identifier: CFCalendarIdentifier, + unit: CFCalendarUnit, + ) -> CFRange; + + /* Getting and Setting the Time Zone */ + pub fn CFCalendarCopyTimeZone(identifier: CFCalendarIdentifier) -> CFTimeZoneRef; + pub fn CFCalendarSetTimeZone(identifier: CFCalendarIdentifier, tz: CFTimeZoneRef); + + /* Getting the Identifier */ + pub fn CFCalendarGetIdentifier(identifier: CFCalendarIdentifier) -> CFCalendarIdentifier; + + /* Getting and Setting the Locale */ + pub fn CFCalendarCopyLocale(identifier: CFCalendarIdentifier) -> CFLocaleRef; + pub fn CFCalendarSetLocale(identifier: CFCalendarIdentifier, locale: CFLocaleRef); + + /* Getting and Setting Day Information */ + pub fn CFCalendarGetFirstWeekday(identifier: CFCalendarIdentifier) -> CFIndex; + pub fn CFCalendarSetFirstWeekday(identifier: CFCalendarIdentifier, wkdy: CFIndex); + pub fn CFCalendarGetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier) -> CFIndex; + pub fn CFCalendarSetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier, mwd: CFIndex); + + /* Getting the Type ID */ + pub fn CFCalendarGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/characterset.rs b/vendor/core-foundation-sys/src/characterset.rs index 6b347a5cd..8d75679af 100644 --- a/vendor/core-foundation-sys/src/characterset.rs +++ b/vendor/core-foundation-sys/src/characterset.rs @@ -7,10 +7,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UTF32Char}; +use crate::data::CFDataRef; +use crate::string::{CFStringRef, UniChar}; use std::os::raw::c_void; -use base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID}; -use data::CFDataRef; -use string::{CFStringRef, UniChar}; pub type CFCharacterSetPredefinedSet = CFIndex; @@ -35,24 +35,90 @@ pub static kCFCharacterSetNewline: CFCharacterSetPredefinedSet = 15; pub struct __CFCharacterSet(c_void); pub type CFCharacterSetRef = *const __CFCharacterSet; -pub type CFMutableCharacterSetRef = *const __CFCharacterSet; +pub type CFMutableCharacterSetRef = *mut __CFCharacterSet; -extern { +extern "C" { + /* + * CFCharacterSet.h + */ + + /* CFCharacterSet */ + /* Creating Character Sets */ + pub fn CFCharacterSetCreateCopy( + alloc: CFAllocatorRef, + theSet: CFCharacterSetRef, + ) -> CFCharacterSetRef; + pub fn CFCharacterSetCreateInvertedSet( + alloc: CFAllocatorRef, + theSet: CFCharacterSetRef, + ) -> CFCharacterSetRef; + pub fn CFCharacterSetCreateWithCharactersInRange( + alloc: CFAllocatorRef, + theRange: CFRange, + ) -> CFCharacterSetRef; + pub fn CFCharacterSetCreateWithCharactersInString( + alloc: CFAllocatorRef, + theString: CFStringRef, + ) -> CFCharacterSetRef; + pub fn CFCharacterSetCreateWithBitmapRepresentation( + alloc: CFAllocatorRef, + theData: CFDataRef, + ) -> CFCharacterSetRef; + + /* Getting Predefined Character Sets */ + pub fn CFCharacterSetGetPredefined( + theSetIdentifier: CFCharacterSetPredefinedSet, + ) -> CFCharacterSetRef; + + /* Querying Character Sets */ + pub fn CFCharacterSetCreateBitmapRepresentation( + alloc: CFAllocatorRef, + theSet: CFCharacterSetRef, + ) -> CFDataRef; + pub fn CFCharacterSetHasMemberInPlane(theSet: CFCharacterSetRef, thePlane: CFIndex) -> Boolean; + pub fn CFCharacterSetIsCharacterMember(theSet: CFCharacterSetRef, theChar: UniChar) -> Boolean; + pub fn CFCharacterSetIsLongCharacterMember( + theSet: CFCharacterSetRef, + theChar: UTF32Char, + ) -> Boolean; + pub fn CFCharacterSetIsSupersetOfSet( + theSet: CFCharacterSetRef, + theOtherset: CFCharacterSetRef, + ) -> Boolean; + + /* Getting the Character Set Type Identifier */ pub fn CFCharacterSetGetTypeID() -> CFTypeID; - pub fn CFCharacterSetGetPredefined(theSetIdentifier: CFCharacterSetPredefinedSet) -> CFCharacterSetRef; - pub fn CFCharacterSetCreateWithCharactersInRange(alloc: CFAllocatorRef, theRange: CFRange) -> CFCharacterSetRef; - pub fn CFCharacterSetCreateWithCharactersInString(alloc: CFAllocatorRef, theString: CFStringRef) -> CFCharacterSetRef; - pub fn CFCharacterSetCreateWithBitmapRepresentation(alloc: CFAllocatorRef, theData: CFDataRef) -> CFCharacterSetRef; + + /* CFMutableCharacterSet */ + /* Creating a Mutable Character Set */ pub fn CFCharacterSetCreateMutable(alloc: CFAllocatorRef) -> CFMutableCharacterSetRef; - pub fn CFCharacterSetCreateCopy(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFCharacterSetRef; - pub fn CFCharacterSetCreateMutableCopy(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFMutableCharacterSetRef; - pub fn CFCharacterSetIsCharacterMember(theSet: CFCharacterSetRef, theChar: UniChar) -> Boolean; - pub fn CFCharacterSetCreateBitmapRepresentation(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFDataRef; + pub fn CFCharacterSetCreateMutableCopy( + alloc: CFAllocatorRef, + theSet: CFCharacterSetRef, + ) -> CFMutableCharacterSetRef; + + /* Adding Characters */ pub fn CFCharacterSetAddCharactersInRange(theSet: CFMutableCharacterSetRef, theRange: CFRange); - pub fn CFCharacterSetRemoveCharactersInRange(theSet: CFMutableCharacterSetRef, theRange: CFRange); - pub fn CFCharacterSetAddCharactersInString(theSet: CFMutableCharacterSetRef, theString: CFStringRef); - pub fn CFCharacterSetRemoveCharactersInString(theSet: CFMutableCharacterSetRef, theString: CFStringRef); - pub fn CFCharacterSetUnion(theSet: CFMutableCharacterSetRef, theOtherSet: CFCharacterSetRef); - pub fn CFCharacterSetIntersect(theSet: CFMutableCharacterSetRef, theOtherSet: CFCharacterSetRef); + pub fn CFCharacterSetAddCharactersInString( + theSet: CFMutableCharacterSetRef, + theString: CFStringRef, + ); + + /* Removing Characters */ + pub fn CFCharacterSetRemoveCharactersInRange( + theSet: CFMutableCharacterSetRef, + theRange: CFRange, + ); + pub fn CFCharacterSetRemoveCharactersInString( + theSet: CFMutableCharacterSetRef, + theString: CFStringRef, + ); + + /* Logical Operations */ + pub fn CFCharacterSetIntersect( + theSet: CFMutableCharacterSetRef, + theOtherSet: CFCharacterSetRef, + ); pub fn CFCharacterSetInvert(theSet: CFMutableCharacterSetRef); + pub fn CFCharacterSetUnion(theSet: CFMutableCharacterSetRef, theOtherSet: CFCharacterSetRef); } diff --git a/vendor/core-foundation-sys/src/data.rs b/vendor/core-foundation-sys/src/data.rs index e5ed0dc9f..ba87d0c5d 100644 --- a/vendor/core-foundation-sys/src/data.rs +++ b/vendor/core-foundation-sys/src/data.rs @@ -7,32 +7,71 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID}; use std::os::raw::c_void; -use base::{CFAllocatorRef, CFTypeID, CFIndex, CFRange}; - #[repr(C)] pub struct __CFData(c_void); pub type CFDataRef = *const __CFData; +pub type CFMutableDataRef = *mut __CFData; +pub type CFDataSearchFlags = CFOptionFlags; + +// typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags) +pub const kCFDataSearchBackwards: CFDataSearchFlags = 1usize << 0; +pub const kCFDataSearchAnchored: CFDataSearchFlags = 1usize << 1; -extern { +extern "C" { /* * CFData.h */ - pub fn CFDataCreate(allocator: CFAllocatorRef, - bytes: *const u8, length: CFIndex) -> CFDataRef; - //fn CFDataFind - pub fn CFDataGetBytePtr(theData: CFDataRef) -> *const u8; - pub fn CFDataGetBytes(theData: CFDataRef, range: CFRange, buffer: *mut u8); - pub fn CFDataGetLength(theData: CFDataRef) -> CFIndex; + /* CFData */ + /* Creating a CFData Object */ + pub fn CFDataCreate(allocator: CFAllocatorRef, bytes: *const u8, length: CFIndex) -> CFDataRef; + pub fn CFDataCreateCopy(allocator: CFAllocatorRef, theData: CFDataRef) -> CFDataRef; pub fn CFDataCreateWithBytesNoCopy( allocator: CFAllocatorRef, bytes: *const u8, length: CFIndex, - allocator: CFAllocatorRef, + bytesDeallocator: CFAllocatorRef, ) -> CFDataRef; + /* Examining a CFData Object */ + pub fn CFDataGetBytePtr(theData: CFDataRef) -> *const u8; + pub fn CFDataGetBytes(theData: CFDataRef, range: CFRange, buffer: *mut u8); + pub fn CFDataGetLength(theData: CFDataRef) -> CFIndex; + pub fn CFDataFind( + theData: CFDataRef, + dataToFind: CFDataRef, + searchRange: CFRange, + compareOptions: CFDataSearchFlags, + ) -> CFRange; + + /* Getting the CFData Type ID */ pub fn CFDataGetTypeID() -> CFTypeID; + + /* CFMutableData */ + /* Creating a Mutable Data Object */ + pub fn CFDataCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex) -> CFMutableDataRef; + pub fn CFDataCreateMutableCopy( + allocator: CFAllocatorRef, + capacity: CFIndex, + theData: CFDataRef, + ) -> CFMutableDataRef; + + /* Accessing Data */ + pub fn CFDataGetMutableBytePtr(theData: CFMutableDataRef) -> *mut u8; + + /* Modifying a Mutable Data Object */ + pub fn CFDataAppendBytes(theData: CFMutableDataRef, bytes: *const u8, length: CFIndex); + pub fn CFDataDeleteBytes(theData: CFMutableDataRef, range: CFRange); + pub fn CFDataReplaceBytes( + theData: CFMutableDataRef, + range: CFRange, + newBytes: *const u8, + newLength: CFIndex, + ); + pub fn CFDataIncreaseLength(theData: CFMutableDataRef, extraLength: CFIndex); + pub fn CFDataSetLength(theData: CFMutableDataRef, length: CFIndex); } diff --git a/vendor/core-foundation-sys/src/date.rs b/vendor/core-foundation-sys/src/date.rs index f83ce1dd1..26b55d402 100644 --- a/vendor/core-foundation-sys/src/date.rs +++ b/vendor/core-foundation-sys/src/date.rs @@ -9,7 +9,7 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFComparisonResult, CFTypeID}; +use crate::base::{CFAllocatorRef, CFComparisonResult, CFTypeID}; #[repr(C)] pub struct __CFDate(c_void); @@ -19,7 +19,7 @@ pub type CFDateRef = *const __CFDate; pub type CFTimeInterval = f64; pub type CFAbsoluteTime = CFTimeInterval; -extern { +extern "C" { pub static kCFAbsoluteTimeIntervalSince1904: CFTimeInterval; pub static kCFAbsoluteTimeIntervalSince1970: CFTimeInterval; @@ -28,7 +28,11 @@ extern { pub fn CFDateCreate(allocator: CFAllocatorRef, at: CFAbsoluteTime) -> CFDateRef; pub fn CFDateGetAbsoluteTime(date: CFDateRef) -> CFAbsoluteTime; pub fn CFDateGetTimeIntervalSinceDate(date: CFDateRef, other: CFDateRef) -> CFTimeInterval; - pub fn CFDateCompare(date: CFDateRef, other: CFDateRef, context: *mut c_void) -> CFComparisonResult; + pub fn CFDateCompare( + date: CFDateRef, + other: CFDateRef, + context: *mut c_void, + ) -> CFComparisonResult; pub fn CFDateGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/date_formatter.rs b/vendor/core-foundation-sys/src/date_formatter.rs new file mode 100644 index 000000000..83c6e1fa7 --- /dev/null +++ b/vendor/core-foundation-sys/src/date_formatter.rs @@ -0,0 +1,147 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef}; +use crate::date::{CFAbsoluteTime, CFDateRef}; +use crate::locale::CFLocaleRef; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFDateFormatter(c_void); +pub type CFDateFormatterRef = *mut __CFDateFormatter; + +pub type CFDateFormatterKey = CFStringRef; +pub type CFDateFormatterStyle = CFIndex; +pub type CFISO8601DateFormatOptions = CFOptionFlags; + +/* Date Formatter Styles */ +pub const kCFDateFormatterNoStyle: CFDateFormatterStyle = 0; +pub const kCFDateFormatterShortStyle: CFDateFormatterStyle = 1; +pub const kCFDateFormatterMediumStyle: CFDateFormatterStyle = 2; +pub const kCFDateFormatterLongStyle: CFDateFormatterStyle = 3; +pub const kCFDateFormatterFullStyle: CFDateFormatterStyle = 4; + +//pub const kCFISO8601DateFormatWithYear: CFISO8601DateFormatOptions = 1 << 0; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithMonth: CFISO8601DateFormatOptions = 1 << 1; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithWeekOfYear: CFISO8601DateFormatOptions = 1 << 2; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithDay: CFISO8601DateFormatOptions = 1 << 4; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithTime: CFISO8601DateFormatOptions = 1 << 5; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithTimeZone: CFISO8601DateFormatOptions = 1 << 6; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithSpaceBetweenDateAndTime: CFISO8601DateFormatOptions = 1 << 7; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithDashSeparatorInDate: CFISO8601DateFormatOptions = 1 << 8; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithColonSeparatorInTime: CFISO8601DateFormatOptions = 1 << 9; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithColonSeparatorInTimeZone: CFISO8601DateFormatOptions = 1 << 10; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithFractionalSeconds: CFISO8601DateFormatOptions = 1 << 11; // macosx(10.13)+ +//pub const kCFISO8601DateFormatWithFullDate: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithYear | kCFISO8601DateFormatWithMonth | kCFISO8601DateFormatWithDay | kCFISO8601DateFormatWithDashSeparatorInDate; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithFullTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithTime | kCFISO8601DateFormatWithColonSeparatorInTime | kCFISO8601DateFormatWithTimeZone | kCFISO8601DateFormatWithColonSeparatorInTimeZone; // macosx(10.12)+ +//pub const kCFISO8601DateFormatWithInternetDateTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithFullDate | kCFISO8601DateFormatWithFullTime; // macosx(10.12)+ + +extern "C" { + /* + * CFDateFormatter.h + */ + + /* Date Formatter Property Keys */ + // The values for these keys are all CFType objects. + // The specific types for each key are specified above. + pub static kCFDateFormatterIsLenient: CFDateFormatterKey; // CFBoolean + pub static kCFDateFormatterTimeZone: CFDateFormatterKey; // CFTimeZone + pub static kCFDateFormatterCalendarName: CFDateFormatterKey; // CFString + pub static kCFDateFormatterDefaultFormat: CFDateFormatterKey; // CFString + pub static kCFDateFormatterTwoDigitStartDate: CFDateFormatterKey; // CFDate + pub static kCFDateFormatterDefaultDate: CFDateFormatterKey; // CFDate + pub static kCFDateFormatterCalendar: CFDateFormatterKey; // CFCalendar + pub static kCFDateFormatterEraSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterAMSymbol: CFDateFormatterKey; // CFString + pub static kCFDateFormatterPMSymbol: CFDateFormatterKey; // CFString + pub static kCFDateFormatterLongEraSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterVeryShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterVeryShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterVeryShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterVeryShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterQuarterSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortQuarterSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterShortStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString + pub static kCFDateFormatterGregorianStartDate: CFDateFormatterKey; // CFDate + pub static kCFDateFormatterDoesRelativeDateFormattingKey: CFDateFormatterKey; // CFBoolean + + /* Creating a Date Formatter */ + pub fn CFDateFormatterCreate( + allocator: CFAllocatorRef, + locale: CFLocaleRef, + dateStyle: CFDateFormatterStyle, + timeStyle: CFDateFormatterStyle, + ) -> CFDateFormatterRef; + + /* Configuring a Date Formatter */ + pub fn CFDateFormatterSetFormat(formatter: CFDateFormatterRef, formatString: CFStringRef); + pub fn CFDateFormatterSetProperty( + formatter: CFDateFormatterRef, + key: CFStringRef, + value: CFTypeRef, + ); + + /* Parsing Strings */ + pub fn CFDateFormatterCreateDateFromString( + allocator: CFAllocatorRef, + formatter: CFDateFormatterRef, + string: CFStringRef, + rangep: *mut CFRange, + ) -> CFDateRef; + pub fn CFDateFormatterGetAbsoluteTimeFromString( + formatter: CFDateFormatterRef, + string: CFStringRef, + rangep: *mut CFRange, + atp: *mut CFAbsoluteTime, + ) -> Boolean; + + /* Creating Strings From Data */ + pub fn CFDateFormatterCreateStringWithAbsoluteTime( + allocator: CFAllocatorRef, + formatter: CFDateFormatterRef, + at: CFAbsoluteTime, + ) -> CFStringRef; + pub fn CFDateFormatterCreateStringWithDate( + allocator: CFAllocatorRef, + formatter: CFDateFormatterRef, + date: CFDateRef, + ) -> CFStringRef; + pub fn CFDateFormatterCreateDateFormatFromTemplate( + allocator: CFAllocatorRef, + tmplate: CFStringRef, + options: CFOptionFlags, + locale: CFLocaleRef, + ) -> CFStringRef; + + /* Getting Information About a Date Formatter */ + pub fn CFDateFormatterCopyProperty( + formatter: CFDateFormatterRef, + key: CFDateFormatterKey, + ) -> CFTypeRef; + pub fn CFDateFormatterGetDateStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle; + pub fn CFDateFormatterGetFormat(formatter: CFDateFormatterRef) -> CFStringRef; + pub fn CFDateFormatterGetLocale(formatter: CFDateFormatterRef) -> CFLocaleRef; + pub fn CFDateFormatterGetTimeStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle; + + /* Getting the CFDateFormatter Type ID */ + pub fn CFDateFormatterGetTypeID() -> CFTypeID; + + //pub fn CFDateFormatterCreateISO8601Formatter(allocator: CFAllocatorRef, formatOptions: CFISO8601DateFormatOptions) -> CFDateFormatterRef; // macosx(10.12)+ +} diff --git a/vendor/core-foundation-sys/src/dictionary.rs b/vendor/core-foundation-sys/src/dictionary.rs index d10e9c120..8c04d680d 100644 --- a/vendor/core-foundation-sys/src/dictionary.rs +++ b/vendor/core-foundation-sys/src/dictionary.rs @@ -9,15 +9,19 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFHashCode, CFIndex, CFTypeID, Boolean}; -use string::CFStringRef; +use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID}; +use crate::string::CFStringRef; -pub type CFDictionaryApplierFunction = extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void); +pub type CFDictionaryApplierFunction = + extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void); -pub type CFDictionaryRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; -pub type CFDictionaryReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); +pub type CFDictionaryRetainCallBack = + extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFDictionaryReleaseCallBack = + extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); pub type CFDictionaryCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; -pub type CFDictionaryEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; +pub type CFDictionaryEqualCallBack = + extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; pub type CFDictionaryHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode; #[repr(C)] @@ -28,7 +32,7 @@ pub struct CFDictionaryKeyCallBacks { pub release: CFDictionaryReleaseCallBack, pub copyDescription: CFDictionaryCopyDescriptionCallBack, pub equal: CFDictionaryEqualCallBack, - pub hash: CFDictionaryHashCallBack + pub hash: CFDictionaryHashCallBack, } #[repr(C)] @@ -38,7 +42,7 @@ pub struct CFDictionaryValueCallBacks { pub retain: CFDictionaryRetainCallBack, pub release: CFDictionaryReleaseCallBack, pub copyDescription: CFDictionaryCopyDescriptionCallBack, - pub equal: CFDictionaryEqualCallBack + pub equal: CFDictionaryEqualCallBack, } #[repr(C)] @@ -47,45 +51,89 @@ pub struct __CFDictionary(c_void); pub type CFDictionaryRef = *const __CFDictionary; pub type CFMutableDictionaryRef = *mut __CFDictionary; -extern { +extern "C" { /* * CFDictionary.h */ pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; + pub static kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; + /* CFDictionary */ + /* Creating a dictionary */ + pub fn CFDictionaryCreate( + allocator: CFAllocatorRef, + keys: *const *const c_void, + values: *const *const c_void, + numValues: CFIndex, + keyCallBacks: *const CFDictionaryKeyCallBacks, + valueCallBacks: *const CFDictionaryValueCallBacks, + ) -> CFDictionaryRef; + pub fn CFDictionaryCreateCopy( + allocator: CFAllocatorRef, + theDict: CFDictionaryRef, + ) -> CFDictionaryRef; + + /* Examining a dictionary */ pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean; - pub fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void, - numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks, - valueCallBacks: *const CFDictionaryValueCallBacks) - -> CFDictionaryRef; + pub fn CFDictionaryContainsValue(theDict: CFDictionaryRef, value: *const c_void) -> Boolean; pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex; + pub fn CFDictionaryGetCountOfKey(theDict: CFDictionaryRef, key: *const c_void) -> CFIndex; + pub fn CFDictionaryGetCountOfValue(heDict: CFDictionaryRef, value: *const c_void) -> CFIndex; + pub fn CFDictionaryGetKeysAndValues( + theDict: CFDictionaryRef, + keys: *mut *const c_void, + values: *mut *const c_void, + ); + pub fn CFDictionaryGetValue(theDict: CFDictionaryRef, key: *const c_void) -> *const c_void; + pub fn CFDictionaryGetValueIfPresent( + theDict: CFDictionaryRef, + key: *const c_void, + value: *mut *const c_void, + ) -> Boolean; + + /* Applying a function to a dictionary */ + pub fn CFDictionaryApplyFunction( + theDict: CFDictionaryRef, + applier: CFDictionaryApplierFunction, + context: *mut c_void, + ); + + /* Getting the CFDictionary type ID */ pub fn CFDictionaryGetTypeID() -> CFTypeID; - pub fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void) - -> Boolean; - pub fn CFDictionaryApplyFunction(theDict: CFDictionaryRef, - applier: CFDictionaryApplierFunction, - context: *mut c_void); - pub fn CFDictionaryGetKeysAndValues(theDict: CFDictionaryRef, - keys: *mut *const c_void, - values: *mut *const c_void); - - pub fn CFDictionaryCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, - keyCallbacks: *const CFDictionaryKeyCallBacks, - valueCallbacks: *const CFDictionaryValueCallBacks) -> CFMutableDictionaryRef; - pub fn CFDictionaryCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, - theDict: CFDictionaryRef) -> CFMutableDictionaryRef; - pub fn CFDictionaryAddValue(theDict: CFMutableDictionaryRef, - key: *const c_void, - value: *const c_void); - pub fn CFDictionarySetValue(theDict: CFMutableDictionaryRef, - key: *const c_void, - value: *const c_void); - pub fn CFDictionaryReplaceValue(theDict: CFMutableDictionaryRef, - key: *const c_void, - value: *const c_void); - pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, - key: *const c_void); + + /* CFMutableDictionary */ + /* Creating a Mutable Dictionary */ + pub fn CFDictionaryCreateMutable( + allocator: CFAllocatorRef, + capacity: CFIndex, + keyCallbacks: *const CFDictionaryKeyCallBacks, + valueCallbacks: *const CFDictionaryValueCallBacks, + ) -> CFMutableDictionaryRef; + pub fn CFDictionaryCreateMutableCopy( + allocator: CFAllocatorRef, + capacity: CFIndex, + theDict: CFDictionaryRef, + ) -> CFMutableDictionaryRef; + + /* Modifying a Dictionary */ + pub fn CFDictionaryAddValue( + theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void, + ); pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef); + pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, key: *const c_void); + pub fn CFDictionaryReplaceValue( + theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void, + ); + pub fn CFDictionarySetValue( + theDict: CFMutableDictionaryRef, + key: *const c_void, + value: *const c_void, + ); + } diff --git a/vendor/core-foundation-sys/src/error.rs b/vendor/core-foundation-sys/src/error.rs index 8a4c1d494..e8ebd6c42 100644 --- a/vendor/core-foundation-sys/src/error.rs +++ b/vendor/core-foundation-sys/src/error.rs @@ -9,24 +9,54 @@ use std::os::raw::c_void; -use base::{CFTypeID, CFIndex}; -use string::CFStringRef; +use crate::base::{CFAllocatorRef, CFIndex, CFTypeID}; +use crate::dictionary::CFDictionaryRef; +use crate::string::CFStringRef; #[repr(C)] pub struct __CFError(c_void); pub type CFErrorRef = *mut __CFError; +pub type CFErrorDomain = CFStringRef; extern "C" { - pub fn CFErrorGetTypeID() -> CFTypeID; + /* + * CFError.h + */ + /* Error domains */ pub static kCFErrorDomainPOSIX: CFStringRef; pub static kCFErrorDomainOSStatus: CFStringRef; pub static kCFErrorDomainMach: CFStringRef; pub static kCFErrorDomainCocoa: CFStringRef; + /* Keys for the user info dictionary */ + pub static kCFErrorLocalizedDescriptionKey: CFStringRef; + // pub static kCFErrorLocalizedFailureKey: CFStringRef; // macos(10.13)+ + pub static kCFErrorLocalizedFailureReasonKey: CFStringRef; + pub static kCFErrorLocalizedRecoverySuggestionKey: CFStringRef; + pub static kCFErrorDescriptionKey: CFStringRef; + pub static kCFErrorUnderlyingErrorKey: CFStringRef; + pub static kCFErrorURLKey: CFStringRef; + pub static kCFErrorFilePathKey: CFStringRef; + + /* Creating a CFError */ + pub fn CFErrorCreate( + allocator: CFAllocatorRef, + domain: CFErrorDomain, + code: CFIndex, + userInfo: CFDictionaryRef, + ) -> CFErrorRef; + //pub fn CFErrorCreateWithUserInfoKeysAndValues + + /* Getting Information About an Error */ pub fn CFErrorGetDomain(err: CFErrorRef) -> CFStringRef; pub fn CFErrorGetCode(err: CFErrorRef) -> CFIndex; - + pub fn CFErrorCopyUserInfo(err: CFErrorRef) -> CFDictionaryRef; pub fn CFErrorCopyDescription(err: CFErrorRef) -> CFStringRef; + pub fn CFErrorCopyFailureReason(err: CFErrorRef) -> CFStringRef; + pub fn CFErrorCopyRecoverySuggestion(err: CFErrorRef) -> CFStringRef; + + /* Getting the CFError Type ID */ + pub fn CFErrorGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/file_security.rs b/vendor/core-foundation-sys/src/file_security.rs new file mode 100644 index 000000000..a4ec6112b --- /dev/null +++ b/vendor/core-foundation-sys/src/file_security.rs @@ -0,0 +1,71 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +#[cfg(feature = "mac_os_10_8_features")] +use crate::base::CFOptionFlags; +use crate::base::{Boolean, CFAllocatorRef, CFTypeID}; +use crate::uuid::CFUUIDRef; + +#[repr(C)] +pub struct __CFFileSecurity(c_void); +pub type CFFileSecurityRef = *mut __CFFileSecurity; + +#[cfg(feature = "mac_os_10_8_features")] +pub type CFFileSecurityClearOptions = CFOptionFlags; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearOwner: CFFileSecurityClearOptions = 1 << 0; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearGroup: CFFileSecurityClearOptions = 1 << 1; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearMode: CFFileSecurityClearOptions = 1 << 2; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearOwnerUUID: CFFileSecurityClearOptions = 1 << 3; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearGroupUUID: CFFileSecurityClearOptions = 1 << 4; +#[cfg(feature = "mac_os_10_8_features")] +pub const kCFFileSecurityClearAccessControlList: CFFileSecurityClearOptions = 1 << 5; + +extern "C" { + /* + * CFFileSecurity.h + */ + pub fn CFFileSecurityGetTypeID() -> CFTypeID; + pub fn CFFileSecurityCreate(allocator: CFAllocatorRef) -> CFFileSecurityRef; + pub fn CFFileSecurityCreateCopy( + allocator: CFAllocatorRef, + fileSec: CFFileSecurityRef, + ) -> CFFileSecurityRef; + pub fn CFFileSecurityCopyOwnerUUID( + fileSec: CFFileSecurityRef, + ownerUUID: *mut CFUUIDRef, + ) -> Boolean; + pub fn CFFileSecuritySetOwnerUUID(fileSec: CFFileSecurityRef, ownerUUID: CFUUIDRef) -> Boolean; + pub fn CFFileSecurityCopyGroupUUID( + fileSec: CFFileSecurityRef, + groupUUID: *mut CFUUIDRef, + ) -> Boolean; + pub fn CFFileSecuritySetGroupUUID(fileSec: CFFileSecurityRef, groupUUID: CFUUIDRef) -> Boolean; + //pub fn CFFileSecurityCopyAccessControlList(fileSec: CFFileSecurityRef, accessControlList: *mut acl_t) -> Boolean; + //pub fn CFFileSecuritySetAccessControlList(fileSec: CFFileSecurityRef, accessControlList: acl_t) -> Boolean; + //pub fn CFFileSecurityGetOwner(fileSec: CFFileSecurityRef, owner: *mut uid_t) -> Boolean; + //pub fn CFFileSecuritySetOwner(fileSec: CFFileSecurityRef, owner: uid_t) -> Boolean; + //pub fn CFFileSecurityGetGroup(fileSec: CFFileSecurityRef, group: *mut gid_t) -> Boolean; + //pub fn CFFileSecuritySetGroup(fileSec: CFFileSecurityRef, group: gid_t) -> Boolean; + //pub fn CFFileSecurityGetMode(fileSec: CFFileSecurityRef, mode: *mut mode_t) -> Boolean; + //pub fn CFFileSecuritySetMode(fileSec: CFFileSecurityRef, mode: mode_t) -> Boolean; + + #[cfg(feature = "mac_os_10_8_features")] + #[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")] + pub fn CFFileSecurityClearProperties( + fileSec: CFFileSecurityRef, + clearPropertyMask: CFFileSecurityClearOptions, + ) -> Boolean; +} diff --git a/vendor/core-foundation-sys/src/filedescriptor.rs b/vendor/core-foundation-sys/src/filedescriptor.rs index 3f51d1072..271adb716 100644 --- a/vendor/core-foundation-sys/src/filedescriptor.rs +++ b/vendor/core-foundation-sys/src/filedescriptor.rs @@ -9,9 +9,9 @@ use std::os::raw::{c_int, c_void}; -use base::{Boolean, CFIndex, CFTypeID, CFOptionFlags, CFAllocatorRef}; -use string::CFStringRef; -use runloop::CFRunLoopSourceRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID}; +use crate::runloop::CFRunLoopSourceRef; +use crate::string::CFStringRef; pub type CFFileDescriptorNativeDescriptor = c_int; @@ -21,38 +21,60 @@ pub struct __CFFileDescriptor(c_void); pub type CFFileDescriptorRef = *mut __CFFileDescriptor; /* Callback Reason Types */ -pub const kCFFileDescriptorReadCallBack: CFOptionFlags = 1 << 0; +pub const kCFFileDescriptorReadCallBack: CFOptionFlags = 1 << 0; pub const kCFFileDescriptorWriteCallBack: CFOptionFlags = 1 << 1; -pub type CFFileDescriptorCallBack = extern "C" fn (f: CFFileDescriptorRef, callBackTypes: CFOptionFlags, info: *mut c_void); +pub type CFFileDescriptorCallBack = + extern "C" fn(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags, info: *mut c_void); #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub struct CFFileDescriptorContext { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<extern "C" fn (info: *const c_void) -> *const c_void>, - pub release: Option<extern "C" fn (info: *const c_void)>, - pub copyDescription: Option<extern "C" fn (info: *const c_void) -> CFStringRef>, + pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>, } -extern { +extern "C" { /* * CFFileDescriptor.h */ - pub fn CFFileDescriptorGetTypeID() -> CFTypeID; - pub fn CFFileDescriptorCreate(allocator: CFAllocatorRef, fd: CFFileDescriptorNativeDescriptor, closeOnInvalidate: Boolean, callout: CFFileDescriptorCallBack, context: *const CFFileDescriptorContext) -> CFFileDescriptorRef; + /* Creating a CFFileDescriptor */ + pub fn CFFileDescriptorCreate( + allocator: CFAllocatorRef, + fd: CFFileDescriptorNativeDescriptor, + closeOnInvalidate: Boolean, + callout: CFFileDescriptorCallBack, + context: *const CFFileDescriptorContext, + ) -> CFFileDescriptorRef; - pub fn CFFileDescriptorGetNativeDescriptor(f: CFFileDescriptorRef) -> CFFileDescriptorNativeDescriptor; + /* Getting Information About a File Descriptor */ + pub fn CFFileDescriptorGetNativeDescriptor( + f: CFFileDescriptorRef, + ) -> CFFileDescriptorNativeDescriptor; + pub fn CFFileDescriptorIsValid(f: CFFileDescriptorRef) -> Boolean; + pub fn CFFileDescriptorGetContext( + f: CFFileDescriptorRef, + context: *mut CFFileDescriptorContext, + ); - pub fn CFFileDescriptorGetContext(f: CFFileDescriptorRef, context: *mut CFFileDescriptorContext); + /* Invalidating a File Descriptor */ + pub fn CFFileDescriptorInvalidate(f: CFFileDescriptorRef); + /* Managing Callbacks */ pub fn CFFileDescriptorEnableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags); pub fn CFFileDescriptorDisableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags); - pub fn CFFileDescriptorInvalidate(f: CFFileDescriptorRef); - pub fn CFFileDescriptorIsValid(f: CFFileDescriptorRef) -> Boolean; + /* Creating a Run Loop Source */ + pub fn CFFileDescriptorCreateRunLoopSource( + allocator: CFAllocatorRef, + f: CFFileDescriptorRef, + order: CFIndex, + ) -> CFRunLoopSourceRef; - pub fn CFFileDescriptorCreateRunLoopSource(allocator: CFAllocatorRef, f: CFFileDescriptorRef, order: CFIndex) -> CFRunLoopSourceRef; + /* Getting the CFFileDescriptor Type ID */ + pub fn CFFileDescriptorGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/lib.rs b/vendor/core-foundation-sys/src/lib.rs index 48c08878b..948ce807d 100644 --- a/vendor/core-foundation-sys/src/lib.rs +++ b/vendor/core-foundation-sys/src/lib.rs @@ -6,37 +6,69 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, improper_ctypes)] - -#![cfg_attr(all(feature="mac_os_10_7_support", feature="mac_os_10_8_features"), feature(linkage))] // back-compat requires weak linkage +#![allow( + non_snake_case, + non_camel_case_types, + non_upper_case_globals, + improper_ctypes +)] +#![cfg_attr( + all(feature = "mac_os_10_7_support", feature = "mac_os_10_8_features"), + feature(linkage) +)] // back-compat requires weak linkage // Link to CoreFoundation on any Apple device. // // We don't use `target_vendor` since that is going to be deprecated: // https://github.com/rust-lang/lang-team/issues/102 #[cfg_attr( - any(target_os = "macos", target_os = "ios", target_os = "tvos"), + all( + any(target_os = "macos", target_os = "ios", target_os = "tvos"), + feature = "link" + ), link(name = "CoreFoundation", kind = "framework") )] extern "C" {} pub mod array; pub mod attributed_string; +pub mod bag; pub mod base; +pub mod binary_heap; +pub mod bit_vector; pub mod bundle; +pub mod calendar; pub mod characterset; pub mod data; pub mod date; +pub mod date_formatter; pub mod dictionary; pub mod error; +pub mod file_security; pub mod filedescriptor; +pub mod locale; +pub mod mach_port; pub mod messageport; +pub mod notification_center; pub mod number; +pub mod number_formatter; +pub mod plugin; +pub mod preferences; pub mod propertylist; pub mod runloop; pub mod set; +pub mod socket; +pub mod stream; pub mod string; +pub mod string_tokenizer; pub mod timezone; +pub mod tree; pub mod url; +pub mod url_enumerator; +#[cfg(target_os = "macos")] +pub mod user_notification; pub mod uuid; -pub mod mach_port; +#[cfg(target_os = "macos")] +pub mod xml_node; +#[cfg(target_os = "macos")] +pub mod xml_parser; diff --git a/vendor/core-foundation-sys/src/locale.rs b/vendor/core-foundation-sys/src/locale.rs new file mode 100644 index 000000000..f80e5c4a6 --- /dev/null +++ b/vendor/core-foundation-sys/src/locale.rs @@ -0,0 +1,146 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::array::CFArrayRef; +use crate::base::{CFAllocatorRef, CFIndex, CFTypeID, CFTypeRef, LangCode, RegionCode}; +use crate::dictionary::CFDictionaryRef; +use crate::notification_center::CFNotificationName; +use crate::string::CFStringRef; +use std::os::raw::c_void; + +#[repr(C)] +pub struct __CFLocale(c_void); +pub type CFLocaleRef = *const __CFLocale; + +pub type CFLocaleIdentifier = CFStringRef; +pub type CFLocaleKey = CFStringRef; +pub type CFCalendarIdentifier = CFStringRef; +pub type CFLocaleLanguageDirection = CFIndex; + +pub const kCFLocaleLanguageDirectionUnknown: CFLocaleLanguageDirection = 0; +pub const kCFLocaleLanguageDirectionLeftToRight: CFLocaleLanguageDirection = 1; +pub const kCFLocaleLanguageDirectionRightToLeft: CFLocaleLanguageDirection = 2; +pub const kCFLocaleLanguageDirectionTopToBottom: CFLocaleLanguageDirection = 3; +pub const kCFLocaleLanguageDirectionBottomToTop: CFLocaleLanguageDirection = 4; + +extern "C" { + /* + * CFLocale.h + */ + + /* Locale Change Notification */ + pub static kCFLocaleCurrentLocaleDidChangeNotification: CFNotificationName; + + /* Locale Property Keys */ + pub static kCFLocaleIdentifier: CFLocaleKey; + pub static kCFLocaleLanguageCode: CFLocaleKey; + pub static kCFLocaleCountryCode: CFLocaleKey; + pub static kCFLocaleScriptCode: CFLocaleKey; + pub static kCFLocaleVariantCode: CFLocaleKey; + + pub static kCFLocaleExemplarCharacterSet: CFLocaleKey; + pub static kCFLocaleCalendarIdentifier: CFLocaleKey; + pub static kCFLocaleCalendar: CFLocaleKey; + pub static kCFLocaleCollationIdentifier: CFLocaleKey; + pub static kCFLocaleUsesMetricSystem: CFLocaleKey; + pub static kCFLocaleMeasurementSystem: CFLocaleKey; + pub static kCFLocaleDecimalSeparator: CFLocaleKey; + pub static kCFLocaleGroupingSeparator: CFLocaleKey; + pub static kCFLocaleCurrencySymbol: CFLocaleKey; + pub static kCFLocaleCurrencyCode: CFLocaleKey; + pub static kCFLocaleCollatorIdentifier: CFLocaleKey; + pub static kCFLocaleQuotationBeginDelimiterKey: CFLocaleKey; + pub static kCFLocaleQuotationEndDelimiterKey: CFLocaleKey; + pub static kCFLocaleAlternateQuotationBeginDelimiterKey: CFLocaleKey; + pub static kCFLocaleAlternateQuotationEndDelimiterKey: CFLocaleKey; + + /* Locale Calendar Identifiers */ + pub static kCFGregorianCalendar: CFCalendarIdentifier; + pub static kCFBuddhistCalendar: CFCalendarIdentifier; + pub static kCFChineseCalendar: CFCalendarIdentifier; + pub static kCFHebrewCalendar: CFCalendarIdentifier; + pub static kCFIslamicCalendar: CFCalendarIdentifier; + pub static kCFIslamicCivilCalendar: CFCalendarIdentifier; + pub static kCFJapaneseCalendar: CFCalendarIdentifier; + pub static kCFRepublicOfChinaCalendar: CFCalendarIdentifier; + pub static kCFPersianCalendar: CFCalendarIdentifier; + pub static kCFIndianCalendar: CFCalendarIdentifier; + pub static kCFISO8601Calendar: CFCalendarIdentifier; + //pub static kCFIslamicTabularCalendar: CFCalendarIdentifier; // macos(10.10)+ + //pub static kCFIslamicUmmAlQuraCalendar: CFCalendarIdentifier; // macos(10.10)+ + + /* Creating a Locale */ + pub fn CFLocaleCopyCurrent() -> CFLocaleRef; + pub fn CFLocaleCreate( + allocator: CFAllocatorRef, + localeIdentifier: CFLocaleIdentifier, + ) -> CFLocaleRef; + pub fn CFLocaleCreateCopy(allocator: CFAllocatorRef, locale: CFLocaleRef) -> CFLocaleRef; + pub fn CFLocaleGetSystem() -> CFLocaleRef; + + /* Getting System Locale Information */ + pub fn CFLocaleCopyAvailableLocaleIdentifiers() -> CFArrayRef; + + /* Getting ISO Information */ + pub fn CFLocaleCopyISOCountryCodes() -> CFArrayRef; + pub fn CFLocaleCopyISOLanguageCodes() -> CFArrayRef; + pub fn CFLocaleCopyISOCurrencyCodes() -> CFArrayRef; + pub fn CFLocaleCopyCommonISOCurrencyCodes() -> CFArrayRef; + + /* Language Preferences */ + pub fn CFLocaleCopyPreferredLanguages() -> CFArrayRef; + + /* Getting Information About a Locale */ + pub fn CFLocaleCopyDisplayNameForPropertyValue( + displayLocale: CFLocaleRef, + key: CFLocaleKey, + value: CFStringRef, + ) -> CFStringRef; + pub fn CFLocaleGetValue(locale: CFLocaleRef, key: CFLocaleKey) -> CFTypeRef; + pub fn CFLocaleGetIdentifier(locale: CFLocaleRef) -> CFLocaleIdentifier; + + /* Getting and Creating Locale Identifiers */ + pub fn CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes( + allocator: CFAllocatorRef, + lcode: LangCode, + rcode: RegionCode, + ) -> CFLocaleIdentifier; + pub fn CFLocaleCreateCanonicalLanguageIdentifierFromString( + allocator: CFAllocatorRef, + localeIdentifier: CFStringRef, + ) -> CFLocaleIdentifier; + pub fn CFLocaleCreateCanonicalLocaleIdentifierFromString( + allocator: CFAllocatorRef, + localeIdentifier: CFStringRef, + ) -> CFLocaleIdentifier; + pub fn CFLocaleCreateComponentsFromLocaleIdentifier( + allocator: CFAllocatorRef, + localeID: CFLocaleIdentifier, + ) -> CFDictionaryRef; + pub fn CFLocaleCreateLocaleIdentifierFromComponents( + allocator: CFAllocatorRef, + dictionary: CFDictionaryRef, + ) -> CFLocaleIdentifier; + pub fn CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode( + allocator: CFAllocatorRef, + lcid: u32, + ) -> CFLocaleIdentifier; + pub fn CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier( + localeIdentifier: CFLocaleIdentifier, + ) -> u32; + + /* Getting Line and Character Direction for a Language */ + pub fn CFLocaleGetLanguageCharacterDirection( + isoLangCode: CFStringRef, + ) -> CFLocaleLanguageDirection; + pub fn CFLocaleGetLanguageLineDirection(isoLangCode: CFStringRef) -> CFLocaleLanguageDirection; + + /* Getting the CFLocale Type ID */ + pub fn CFLocaleGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/mach_port.rs b/vendor/core-foundation-sys/src/mach_port.rs index 2341fd4e7..1f47275de 100644 --- a/vendor/core-foundation-sys/src/mach_port.rs +++ b/vendor/core-foundation-sys/src/mach_port.rs @@ -1,20 +1,75 @@ -pub use base::{CFAllocatorRef, CFIndex, CFTypeID}; -use runloop::CFRunLoopSourceRef; +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::base::{mach_port_t, Boolean}; +pub use crate::base::{CFAllocatorRef, CFIndex, CFTypeID}; +use crate::runloop::CFRunLoopSourceRef; +use crate::string::CFStringRef; use std::os::raw::c_void; #[repr(C)] pub struct __CFMachPort(c_void); -pub type CFMachPortRef = *const __CFMachPort; +pub type CFMachPortRef = *mut __CFMachPort; + +pub type CFMachPortCallBack = + extern "C" fn(port: CFMachPortRef, msg: *mut c_void, size: CFIndex, info: *mut c_void); +pub type CFMachPortInvalidationCallBack = extern "C" fn(port: CFMachPortRef, info: *mut c_void); + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFMachPortContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn(info: *const c_void) -> *const c_void, + pub release: extern "C" fn(info: *const c_void), + pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef, +} extern "C" { /* * CFMachPort.h */ + + /* Creating a CFMachPort Object */ + pub fn CFMachPortCreate( + allocator: CFAllocatorRef, + callout: CFMachPortCallBack, + context: *mut CFMachPortContext, + shouldFreeInfo: *mut Boolean, + ) -> CFMachPortRef; + pub fn CFMachPortCreateWithPort( + allocator: CFAllocatorRef, + portNum: mach_port_t, + callout: CFMachPortCallBack, + context: *mut CFMachPortContext, + shouldFreeInfo: *mut Boolean, + ) -> CFMachPortRef; + + /* Configuring a CFMachPort Object */ + pub fn CFMachPortInvalidate(port: CFMachPortRef); pub fn CFMachPortCreateRunLoopSource( allocator: CFAllocatorRef, port: CFMachPortRef, order: CFIndex, ) -> CFRunLoopSourceRef; - + pub fn CFMachPortSetInvalidationCallBack( + port: CFMachPortRef, + callout: CFMachPortInvalidationCallBack, + ); + + /* Examining a CFMachPort Object */ + pub fn CFMachPortGetContext(port: CFMachPortRef, context: *mut CFMachPortContext); + pub fn CFMachPortGetInvalidationCallBack(port: CFMachPortRef) + -> CFMachPortInvalidationCallBack; + pub fn CFMachPortGetPort(port: CFMachPortRef) -> mach_port_t; + pub fn CFMachPortIsValid(port: CFMachPortRef) -> Boolean; + + /* Getting the CFMachPort Type ID */ pub fn CFMachPortGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/messageport.rs b/vendor/core-foundation-sys/src/messageport.rs index e33d9aa4b..4ccdcc8b3 100644 --- a/vendor/core-foundation-sys/src/messageport.rs +++ b/vendor/core-foundation-sys/src/messageport.rs @@ -9,71 +9,98 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean}; -use data::CFDataRef; -use date::CFTimeInterval; -use runloop::CFRunLoopSourceRef; -use string::CFStringRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID, SInt32}; +use crate::data::CFDataRef; +use crate::date::CFTimeInterval; +use crate::runloop::CFRunLoopSourceRef; +use crate::string::CFStringRef; #[repr(C)] -#[derive(Copy, Clone)] -#[derive(Debug)] +#[derive(Copy, Clone, Debug)] pub struct CFMessagePortContext { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<unsafe extern fn(info: *const c_void) -> *const c_void>, - pub release: Option<unsafe extern fn(info: *const c_void)>, - pub copyDescription: Option<unsafe extern fn(info: *const c_void) - -> CFStringRef>, + pub retain: Option<unsafe extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<unsafe extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<unsafe extern "C" fn(info: *const c_void) -> CFStringRef>, } pub type CFMessagePortCallBack = Option< - unsafe extern fn(local: CFMessagePortRef, - msgid: i32, - data: CFDataRef, - info: *mut c_void) -> CFDataRef>; + unsafe extern "C" fn( + local: CFMessagePortRef, + msgid: i32, + data: CFDataRef, + info: *mut c_void, + ) -> CFDataRef, +>; -pub type CFMessagePortInvalidationCallBack = Option< - unsafe extern "C" fn(ms: CFMessagePortRef, info: *mut c_void)>; +pub type CFMessagePortInvalidationCallBack = + Option<unsafe extern "C" fn(ms: CFMessagePortRef, info: *mut c_void)>; + +/* CFMessagePortSendRequest Error Codes */ +pub const kCFMessagePortSuccess: SInt32 = 0; +pub const kCFMessagePortSendTimeout: SInt32 = -1; +pub const kCFMessagePortReceiveTimeout: SInt32 = -2; +pub const kCFMessagePortIsInvalid: SInt32 = -3; +pub const kCFMessagePortTransportError: SInt32 = -4; +pub const kCFMessagePortBecameInvalidError: SInt32 = -5; #[repr(C)] pub struct __CFMessagePort(c_void); pub type CFMessagePortRef = *mut __CFMessagePort; -extern { +extern "C" { /* * CFMessagePort.h */ - pub fn CFMessagePortGetTypeID() -> CFTypeID; - pub fn CFMessagePortCreateLocal(allocator: CFAllocatorRef, - name: CFStringRef, - callout: CFMessagePortCallBack, - context: *const CFMessagePortContext, - shouldFreeInfo: *mut Boolean) - -> CFMessagePortRef; - pub fn CFMessagePortCreateRemote(allocator: CFAllocatorRef, - name: CFStringRef) -> CFMessagePortRef; - pub fn CFMessagePortIsRemote(ms: CFMessagePortRef) -> Boolean; - pub fn CFMessagePortGetName(ms: CFMessagePortRef) -> CFStringRef; - pub fn CFMessagePortSetName(ms: CFMessagePortRef, newName: CFStringRef) - -> Boolean; - pub fn CFMessagePortGetContext(ms: CFMessagePortRef, - context: *mut CFMessagePortContext); + + /* Creating a CFMessagePort Object */ + pub fn CFMessagePortCreateLocal( + allocator: CFAllocatorRef, + name: CFStringRef, + callout: CFMessagePortCallBack, + context: *const CFMessagePortContext, + shouldFreeInfo: *mut Boolean, + ) -> CFMessagePortRef; + pub fn CFMessagePortCreateRemote( + allocator: CFAllocatorRef, + name: CFStringRef, + ) -> CFMessagePortRef; + + /* Configuring a CFMessagePort Object */ + pub fn CFMessagePortCreateRunLoopSource( + allocator: CFAllocatorRef, + local: CFMessagePortRef, + order: CFIndex, + ) -> CFRunLoopSourceRef; + pub fn CFMessagePortSetInvalidationCallBack( + ms: CFMessagePortRef, + callout: CFMessagePortInvalidationCallBack, + ); + pub fn CFMessagePortSetName(ms: CFMessagePortRef, newName: CFStringRef) -> Boolean; + + /* Using a Message Port */ pub fn CFMessagePortInvalidate(ms: CFMessagePortRef); + pub fn CFMessagePortSendRequest( + remote: CFMessagePortRef, + msgid: i32, + data: CFDataRef, + sendTimeout: CFTimeInterval, + rcvTimeout: CFTimeInterval, + replyMode: CFStringRef, + returnData: *mut CFDataRef, + ) -> i32; + //pub fn CFMessagePortSetDispatchQueue(ms: CFMessagePortRef, queue: dispatch_queue_t); + + /* Examining a Message Port */ + pub fn CFMessagePortGetContext(ms: CFMessagePortRef, context: *mut CFMessagePortContext); + pub fn CFMessagePortGetInvalidationCallBack( + ms: CFMessagePortRef, + ) -> CFMessagePortInvalidationCallBack; + pub fn CFMessagePortGetName(ms: CFMessagePortRef) -> CFStringRef; + pub fn CFMessagePortIsRemote(ms: CFMessagePortRef) -> Boolean; pub fn CFMessagePortIsValid(ms: CFMessagePortRef) -> Boolean; - pub fn CFMessagePortGetInvalidationCallBack(ms: CFMessagePortRef) - -> CFMessagePortInvalidationCallBack; - pub fn CFMessagePortSetInvalidationCallBack(ms: CFMessagePortRef, - callout: CFMessagePortInvalidationCallBack); - pub fn CFMessagePortSendRequest(remote: CFMessagePortRef, msgid: i32, - data: CFDataRef, - sendTimeout: CFTimeInterval, - rcvTimeout: CFTimeInterval, - replyMode: CFStringRef, - returnData: *mut CFDataRef) -> i32; - pub fn CFMessagePortCreateRunLoopSource(allocator: CFAllocatorRef, - local: CFMessagePortRef, - order: CFIndex) - -> CFRunLoopSourceRef; - // CFMessagePortSetDispatchQueue + + /* Getting the CFMessagePort Type ID */ + pub fn CFMessagePortGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/notification_center.rs b/vendor/core-foundation-sys/src/notification_center.rs new file mode 100644 index 000000000..2ed829233 --- /dev/null +++ b/vendor/core-foundation-sys/src/notification_center.rs @@ -0,0 +1,89 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFIndex, CFOptionFlags, CFTypeID}; +use crate::dictionary::CFDictionaryRef; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFNotificationCenter(c_void); + +pub type CFNotificationCenterRef = *mut __CFNotificationCenter; + +pub type CFNotificationName = CFStringRef; +pub type CFNotificationCallback = extern "C" fn( + center: CFNotificationCenterRef, + observer: *mut c_void, + name: CFNotificationName, + object: *const c_void, + userInfo: CFDictionaryRef, +); +pub type CFNotificationSuspensionBehavior = CFIndex; + +pub const CFNotificationSuspensionBehaviorDrop: CFNotificationSuspensionBehavior = 1; +pub const CFNotificationSuspensionBehaviorCoalesce: CFNotificationSuspensionBehavior = 2; +pub const CFNotificationSuspensionBehaviorHold: CFNotificationSuspensionBehavior = 3; +pub const CFNotificationSuspensionBehaviorDeliverImmediately: CFNotificationSuspensionBehavior = 4; + +/* Notification Posting Options */ +pub const kCFNotificationDeliverImmediately: CFOptionFlags = 1usize << 0; +pub const kCFNotificationPostToAllSessions: CFOptionFlags = 1usize << 1; + +extern "C" { + /* + * CFNotificationCenter.h + */ + + /* Accessing a Notification Center */ + pub fn CFNotificationCenterGetDarwinNotifyCenter() -> CFNotificationCenterRef; + #[cfg(any(target_os = "macos", target_os = "windows"))] + pub fn CFNotificationCenterGetDistributedCenter() -> CFNotificationCenterRef; + pub fn CFNotificationCenterGetLocalCenter() -> CFNotificationCenterRef; + + /* Posting a Notification */ + pub fn CFNotificationCenterPostNotification( + center: CFNotificationCenterRef, + name: CFNotificationName, + object: *const c_void, + userInfo: CFDictionaryRef, + deliverImmediately: Boolean, + ); + pub fn CFNotificationCenterPostNotificationWithOptions( + center: CFNotificationCenterRef, + name: CFNotificationName, + object: *const c_void, + userInfo: CFDictionaryRef, + options: CFOptionFlags, + ); + + /* Adding and Removing Observers */ + pub fn CFNotificationCenterAddObserver( + center: CFNotificationCenterRef, + observer: *const c_void, + callBack: CFNotificationCallback, + name: CFStringRef, + object: *const c_void, + suspensionBehavior: CFNotificationSuspensionBehavior, + ); + pub fn CFNotificationCenterRemoveEveryObserver( + center: CFNotificationCenterRef, + observer: *const c_void, + ); + pub fn CFNotificationCenterRemoveObserver( + center: CFNotificationCenterRef, + observer: *const c_void, + name: CFNotificationName, + object: *const c_void, + ); + + /* Getting the CFNotificationCenter Type ID */ + pub fn CFNotificationCenterGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/number.rs b/vendor/core-foundation-sys/src/number.rs index c056a245b..d822d417d 100644 --- a/vendor/core-foundation-sys/src/number.rs +++ b/vendor/core-foundation-sys/src/number.rs @@ -9,7 +9,7 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFTypeID, CFComparisonResult}; +use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID}; #[repr(C)] pub struct __CFBoolean(c_void); @@ -19,23 +19,23 @@ pub type CFBooleanRef = *const __CFBoolean; pub type CFNumberType = u32; // members of enum CFNumberType -pub const kCFNumberSInt8Type: CFNumberType = 1; -pub const kCFNumberSInt16Type: CFNumberType = 2; -pub const kCFNumberSInt32Type: CFNumberType = 3; -pub const kCFNumberSInt64Type: CFNumberType = 4; -pub const kCFNumberFloat32Type: CFNumberType = 5; -pub const kCFNumberFloat64Type: CFNumberType = 6; -pub const kCFNumberCharType: CFNumberType = 7; -pub const kCFNumberShortType: CFNumberType = 8; -pub const kCFNumberIntType: CFNumberType = 9; -pub const kCFNumberLongType: CFNumberType = 10; -pub const kCFNumberLongLongType: CFNumberType = 11; -pub const kCFNumberFloatType: CFNumberType = 12; -pub const kCFNumberDoubleType: CFNumberType = 13; -pub const kCFNumberCFIndexType: CFNumberType = 14; +pub const kCFNumberSInt8Type: CFNumberType = 1; +pub const kCFNumberSInt16Type: CFNumberType = 2; +pub const kCFNumberSInt32Type: CFNumberType = 3; +pub const kCFNumberSInt64Type: CFNumberType = 4; +pub const kCFNumberFloat32Type: CFNumberType = 5; +pub const kCFNumberFloat64Type: CFNumberType = 6; +pub const kCFNumberCharType: CFNumberType = 7; +pub const kCFNumberShortType: CFNumberType = 8; +pub const kCFNumberIntType: CFNumberType = 9; +pub const kCFNumberLongType: CFNumberType = 10; +pub const kCFNumberLongLongType: CFNumberType = 11; +pub const kCFNumberFloatType: CFNumberType = 12; +pub const kCFNumberDoubleType: CFNumberType = 13; +pub const kCFNumberCFIndexType: CFNumberType = 14; pub const kCFNumberNSIntegerType: CFNumberType = 15; -pub const kCFNumberCGFloatType: CFNumberType = 16; -pub const kCFNumberMaxType: CFNumberType = 16; +pub const kCFNumberCGFloatType: CFNumberType = 16; +pub const kCFNumberMaxType: CFNumberType = 16; // This is an enum due to zero-sized types warnings. // For more details see https://github.com/rust-lang/rust/issues/27303 @@ -43,23 +43,45 @@ pub enum __CFNumber {} pub type CFNumberRef = *const __CFNumber; -extern { +extern "C" { /* * CFNumber.h */ pub static kCFBooleanTrue: CFBooleanRef; pub static kCFBooleanFalse: CFBooleanRef; + pub static kCFNumberPositiveInfinity: CFNumberRef; + pub static kCFNumberNegativeInfinity: CFNumberRef; + pub static kCFNumberNaN: CFNumberRef; - pub fn CFBooleanGetTypeID() -> CFTypeID; - pub fn CFBooleanGetValue(boolean: CFBooleanRef) -> bool; + /* Creating a Number */ + pub fn CFNumberCreate( + allocator: CFAllocatorRef, + theType: CFNumberType, + valuePtr: *const c_void, + ) -> CFNumberRef; - pub fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void) - -> CFNumberRef; - //fn CFNumberGetByteSize - pub fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool; - pub fn CFNumberCompare(date: CFNumberRef, other: CFNumberRef, context: *mut c_void) -> CFComparisonResult; - pub fn CFNumberGetTypeID() -> CFTypeID; + /* Getting Information About Numbers */ + pub fn CFNumberGetByteSize(number: CFNumberRef) -> CFIndex; pub fn CFNumberGetType(number: CFNumberRef) -> CFNumberType; + pub fn CFNumberGetValue( + number: CFNumberRef, + theType: CFNumberType, + valuePtr: *mut c_void, + ) -> bool; + pub fn CFNumberIsFloatType(number: CFNumberRef) -> Boolean; + + /* Comparing Numbers */ + pub fn CFNumberCompare( + date: CFNumberRef, + other: CFNumberRef, + context: *mut c_void, + ) -> CFComparisonResult; + + /* Getting the CFNumber Type ID */ + pub fn CFNumberGetTypeID() -> CFTypeID; + + pub fn CFBooleanGetValue(boolean: CFBooleanRef) -> bool; + pub fn CFBooleanGetTypeID() -> CFTypeID; } #[cfg(test)] diff --git a/vendor/core-foundation-sys/src/number_formatter.rs b/vendor/core-foundation-sys/src/number_formatter.rs new file mode 100644 index 000000000..cae7b11b0 --- /dev/null +++ b/vendor/core-foundation-sys/src/number_formatter.rs @@ -0,0 +1,163 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_double, c_void}; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef}; +use crate::locale::CFLocaleRef; +use crate::number::{CFNumberRef, CFNumberType}; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFNumberFormatter(c_void); + +pub type CFNumberFormatterRef = *mut __CFNumberFormatter; + +pub type CFNumberFormatterKey = CFStringRef; +pub type CFNumberFormatterStyle = CFIndex; +pub type CFNumberFormatterOptionFlags = CFOptionFlags; +pub type CFNumberFormatterRoundingMode = CFIndex; +pub type CFNumberFormatterPadPosition = CFIndex; + +/* Number Formatter Styles */ +pub const kCFNumberFormatterNoStyle: CFNumberFormatterStyle = 0; +pub const kCFNumberFormatterDecimalStyle: CFNumberFormatterStyle = 1; +pub const kCFNumberFormatterCurrencyStyle: CFNumberFormatterStyle = 2; +pub const kCFNumberFormatterPercentStyle: CFNumberFormatterStyle = 3; +pub const kCFNumberFormatterScientificStyle: CFNumberFormatterStyle = 4; +pub const kCFNumberFormatterSpellOutStyle: CFNumberFormatterStyle = 5; +//pub const kCFNumberFormatterOrdinalStyle: CFNumberFormatterStyle = 6; // macos(10.11)+ +//pub const kCFNumberFormatterCurrencyISOCodeStyle: CFNumberFormatterStyle = 8; // macos(10.11)+ +//pub const kCFNumberFormatterCurrencyPluralStyle: CFNumberFormatterStyle = 9; // macos(10.11)+ +//pub const kCFNumberFormatterCurrencyAccountingStyle: CFNumberFormatterStyle = 10; // macos(10.11)+ + +/* Number Format Options */ +pub const kCFNumberFormatterParseIntegersOnly: CFNumberFormatterOptionFlags = 1; + +/* CFNumberFormatterRoundingMode */ +pub const kCFNumberFormatterRoundCeiling: CFNumberFormatterRoundingMode = 0; +pub const kCFNumberFormatterRoundFloor: CFNumberFormatterRoundingMode = 1; +pub const kCFNumberFormatterRoundDown: CFNumberFormatterRoundingMode = 2; +pub const kCFNumberFormatterRoundUp: CFNumberFormatterRoundingMode = 3; +pub const kCFNumberFormatterRoundHalfEven: CFNumberFormatterRoundingMode = 4; +pub const kCFNumberFormatterRoundHalfDown: CFNumberFormatterRoundingMode = 5; +pub const kCFNumberFormatterRoundHalfUp: CFNumberFormatterRoundingMode = 6; + +/* Padding Positions */ +pub const kCFNumberFormatterPadBeforePrefix: CFNumberFormatterPadPosition = 0; +pub const kCFNumberFormatterPadAfterPrefix: CFNumberFormatterPadPosition = 1; +pub const kCFNumberFormatterPadBeforeSuffix: CFNumberFormatterPadPosition = 2; +pub const kCFNumberFormatterPadAfterSuffix: CFNumberFormatterPadPosition = 3; + +extern "C" { + /* + * CFNumberFormatter.h + */ + + /* Number Formatter Property Keys */ + // The values for these keys are all CFType objects. + // The specific types for each key are specified above. + pub static kCFNumberFormatterCurrencyCode: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterDecimalSeparator: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterCurrencyDecimalSeparator: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterAlwaysShowDecimalSeparator: CFNumberFormatterKey; // CFBoolean + pub static kCFNumberFormatterGroupingSeparator: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterUseGroupingSeparator: CFNumberFormatterKey; // CFBoolean + pub static kCFNumberFormatterPercentSymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterZeroSymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterNaNSymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterInfinitySymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterMinusSign: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterPlusSign: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterCurrencySymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterExponentSymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterMinIntegerDigits: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterMaxIntegerDigits: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterMinFractionDigits: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterMaxFractionDigits: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterGroupingSize: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterSecondaryGroupingSize: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterRoundingMode: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterRoundingIncrement: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterFormatWidth: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterPaddingPosition: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterPaddingCharacter: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterDefaultFormat: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterMultiplier: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterPositivePrefix: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterPositiveSuffix: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterNegativePrefix: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterNegativeSuffix: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterPerMillSymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterInternationalCurrencySymbol: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterCurrencyGroupingSeparator: CFNumberFormatterKey; // CFString + pub static kCFNumberFormatterIsLenient: CFNumberFormatterKey; // CFBoolean + pub static kCFNumberFormatterUseSignificantDigits: CFNumberFormatterKey; // CFBoolean + pub static kCFNumberFormatterMinSignificantDigits: CFNumberFormatterKey; // CFNumber + pub static kCFNumberFormatterMaxSignificantDigits: CFNumberFormatterKey; // CFNumber + + /* Creating a Number Formatter */ + pub fn CFNumberFormatterCreate( + allocator: CFAllocatorRef, + locale: CFLocaleRef, + style: CFNumberFormatterStyle, + ) -> CFNumberFormatterRef; + + /* Configuring a Number Formatter */ + pub fn CFNumberFormatterSetFormat(formatter: CFNumberFormatterRef, formatString: CFStringRef); + pub fn CFNumberFormatterSetProperty( + formatter: CFNumberFormatterRef, + key: CFNumberFormatterKey, + value: CFTypeRef, + ); + + /* Formatting Values */ + pub fn CFNumberFormatterCreateNumberFromString( + allocator: CFAllocatorRef, + formatter: CFNumberFormatterRef, + string: CFStringRef, + rangep: *mut CFRange, + options: CFOptionFlags, + ) -> CFNumberRef; + pub fn CFNumberFormatterCreateStringWithNumber( + allocator: CFAllocatorRef, + formatter: CFNumberFormatterRef, + number: CFNumberRef, + ) -> CFStringRef; + pub fn CFNumberFormatterCreateStringWithValue( + allocator: CFAllocatorRef, + formatter: CFNumberFormatterRef, + numberType: CFNumberType, + valuePtr: *const c_void, + ) -> CFStringRef; + pub fn CFNumberFormatterGetDecimalInfoForCurrencyCode( + currencyCode: CFStringRef, + defaultFractionDigits: *mut i32, + roundingIncrement: *mut c_double, + ) -> Boolean; + pub fn CFNumberFormatterGetValueFromString( + formatter: CFNumberFormatterRef, + string: CFStringRef, + rangep: *mut CFRange, + numberType: CFNumberType, + valuePtr: *mut c_void, + ) -> Boolean; + + /* Examining a Number Formatter */ + pub fn CFNumberFormatterCopyProperty( + formatter: CFNumberFormatterRef, + key: CFNumberFormatterKey, + ) -> CFTypeRef; + pub fn CFNumberFormatterGetFormat(formatter: CFNumberFormatterRef) -> CFStringRef; + pub fn CFNumberFormatterGetLocale(formatter: CFNumberFormatterRef) -> CFLocaleRef; + pub fn CFNumberFormatterGetStyle(formatter: CFNumberFormatterRef) -> CFNumberFormatterStyle; + + /* Getting the CFNumberFormatter Type ID */ + pub fn CFNumberFormatterGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/plugin.rs b/vendor/core-foundation-sys/src/plugin.rs new file mode 100644 index 000000000..fa236777c --- /dev/null +++ b/vendor/core-foundation-sys/src/plugin.rs @@ -0,0 +1,99 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::array::CFArrayRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID}; +use crate::bundle::{CFBundleRef, CFPlugInRef}; +use crate::string::CFStringRef; +use crate::url::CFURLRef; +use crate::uuid::CFUUIDRef; + +#[repr(C)] +pub struct __CFPlugInInstance(c_void); +pub type CFPlugInInstanceRef = *mut __CFPlugInInstance; + +pub type CFPlugInDynamicRegisterFunction = extern "C" fn(plugIn: CFPlugInRef); +pub type CFPlugInUnloadFunction = extern "C" fn(plugIn: CFPlugInRef); +pub type CFPlugInFactoryFunction = + extern "C" fn(allocator: CFAllocatorRef, typeUUID: CFUUIDRef) -> *mut c_void; + +pub type CFPlugInInstanceGetInterfaceFunction = extern "C" fn( + instance: CFPlugInInstanceRef, + interfaceName: CFStringRef, + ftbl: *mut *mut c_void, +) -> Boolean; +pub type CFPlugInInstanceDeallocateInstanceDataFunction = extern "C" fn(instanceData: *mut c_void); + +extern "C" { + /* + * CFPlugIn.h + */ + + /* CFPlugIn */ + /* Information Property List Keys */ + pub static kCFPlugInDynamicRegistrationKey: CFStringRef; + pub static kCFPlugInDynamicRegisterFunctionKey: CFStringRef; + pub static kCFPlugInUnloadFunctionKey: CFStringRef; + pub static kCFPlugInFactoriesKey: CFStringRef; + pub static kCFPlugInTypesKey: CFStringRef; + + /* Creating Plug-ins */ + pub fn CFPlugInCreate(allocator: CFAllocatorRef, plugInURL: CFURLRef) -> CFPlugInRef; + pub fn CFPlugInInstanceCreate( + allocator: CFAllocatorRef, + factoryUUID: CFUUIDRef, + typeUUID: CFUUIDRef, + ) -> *mut c_void; + + /* Registration */ + pub fn CFPlugInRegisterFactoryFunction( + factoryUUID: CFUUIDRef, + func: CFPlugInFactoryFunction, + ) -> Boolean; + pub fn CFPlugInRegisterFactoryFunctionByName( + CfactoryUUID: CFUUIDRef, + plugIn: CFPlugInRef, + functionName: CFStringRef, + ) -> Boolean; + pub fn CFPlugInRegisterPlugInType(factoryUUID: CFUUIDRef, typeUUID: CFUUIDRef) -> Boolean; + pub fn CFPlugInUnregisterFactory(factoryUUID: CFUUIDRef) -> Boolean; + pub fn CFPlugInUnregisterPlugInType(factoryUUID: CFUUIDRef, typeUUID: CFUUIDRef) -> Boolean; + + /* CFPlugIn Miscellaneous Functions */ + pub fn CFPlugInAddInstanceForFactory(factoryID: CFUUIDRef); + pub fn CFPlugInFindFactoriesForPlugInType(typeUUID: CFUUIDRef) -> CFArrayRef; + pub fn CFPlugInFindFactoriesForPlugInTypeInPlugIn( + typeUUID: CFUUIDRef, + plugIn: CFPlugInRef, + ) -> CFArrayRef; + pub fn CFPlugInGetBundle(plugIn: CFPlugInRef) -> CFBundleRef; + pub fn CFPlugInGetTypeID() -> CFTypeID; + pub fn CFPlugInIsLoadOnDemand(plugIn: CFPlugInRef) -> Boolean; + pub fn CFPlugInRemoveInstanceForFactory(factoryID: CFUUIDRef); + pub fn CFPlugInSetLoadOnDemand(plugIn: CFPlugInRef, flag: Boolean); + + /* CFPlugInInstance: deprecated */ + pub fn CFPlugInInstanceCreateWithInstanceDataSize( + allocator: CFAllocatorRef, + instanceDataSize: CFIndex, + deallocateInstanceFunction: CFPlugInInstanceDeallocateInstanceDataFunction, + factoryName: CFStringRef, + getInterfaceFunction: CFPlugInInstanceGetInterfaceFunction, + ) -> CFPlugInInstanceRef; + pub fn CFPlugInInstanceGetFactoryName(instance: CFPlugInInstanceRef) -> CFStringRef; + pub fn CFPlugInInstanceGetInstanceData(instance: CFPlugInInstanceRef) -> *mut c_void; + pub fn CFPlugInInstanceGetInterfaceFunctionTable( + instance: CFPlugInInstanceRef, + interfaceName: CFStringRef, + ftbl: *mut *mut c_void, + ) -> Boolean; + pub fn CFPlugInInstanceGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/preferences.rs b/vendor/core-foundation-sys/src/preferences.rs new file mode 100644 index 000000000..0899938e5 --- /dev/null +++ b/vendor/core-foundation-sys/src/preferences.rs @@ -0,0 +1,103 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::array::CFArrayRef; +use crate::base::{Boolean, CFIndex}; +use crate::dictionary::CFDictionaryRef; +use crate::propertylist::CFPropertyListRef; +use crate::string::CFStringRef; + +extern "C" { + /* + * CFPreferences.h + */ + /* Application, Host, and User Keys */ + pub static kCFPreferencesAnyApplication: CFStringRef; + pub static kCFPreferencesCurrentApplication: CFStringRef; + pub static kCFPreferencesAnyHost: CFStringRef; + pub static kCFPreferencesCurrentHost: CFStringRef; + pub static kCFPreferencesAnyUser: CFStringRef; + pub static kCFPreferencesCurrentUser: CFStringRef; + + /* Getting Preference Values */ + pub fn CFPreferencesCopyAppValue( + key: CFStringRef, + applicationID: CFStringRef, + ) -> CFPropertyListRef; + pub fn CFPreferencesCopyKeyList( + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ) -> CFArrayRef; + pub fn CFPreferencesCopyMultiple( + keysToFetch: CFArrayRef, + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ) -> CFDictionaryRef; + pub fn CFPreferencesCopyValue( + key: CFStringRef, + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ) -> CFPropertyListRef; + pub fn CFPreferencesGetAppBooleanValue( + key: CFStringRef, + applicationID: CFStringRef, + keyExistsAndHasValidFormat: *mut Boolean, + ) -> Boolean; + pub fn CFPreferencesGetAppIntegerValue( + key: CFStringRef, + applicationID: CFStringRef, + keyExistsAndHasValidFormat: *mut Boolean, + ) -> CFIndex; + + /* Setting Preference Values */ + pub fn CFPreferencesSetAppValue( + key: CFStringRef, + value: CFPropertyListRef, + applicationID: CFStringRef, + ); + pub fn CFPreferencesSetMultiple( + keysToSet: CFDictionaryRef, + keysToRemove: CFArrayRef, + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ); + pub fn CFPreferencesSetValue( + key: CFStringRef, + value: CFPropertyListRef, + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ); + + /* Synchronizing Preferences */ + pub fn CFPreferencesAppSynchronize(applicationID: CFStringRef) -> Boolean; + pub fn CFPreferencesSynchronize( + applicationID: CFStringRef, + userName: CFStringRef, + hostName: CFStringRef, + ) -> Boolean; + + /* Adding and Removing Suite Preferences */ + pub fn CFPreferencesAddSuitePreferencesToApp(applicationID: CFStringRef, suiteID: CFStringRef); + pub fn CFPreferencesRemoveSuitePreferencesFromApp( + applicationID: CFStringRef, + suiteID: CFStringRef, + ); + + /* Miscellaneous Functions */ + pub fn CFPreferencesAppValueIsForced(key: CFStringRef, applicationID: CFStringRef) -> Boolean; + pub fn CFPreferencesCopyApplicationList( + userName: CFStringRef, + hostName: CFStringRef, + ) -> CFArrayRef; // deprecated since macos 10.9 +} diff --git a/vendor/core-foundation-sys/src/propertylist.rs b/vendor/core-foundation-sys/src/propertylist.rs index 574c4d13f..d4ceb1b0c 100644 --- a/vendor/core-foundation-sys/src/propertylist.rs +++ b/vendor/core-foundation-sys/src/propertylist.rs @@ -7,9 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeRef}; -use data::CFDataRef; -use error::CFErrorRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeRef}; +use crate::data::CFDataRef; +use crate::error::CFErrorRef; +use crate::stream::{CFReadStreamRef, CFWriteStreamRef}; +use crate::string::CFStringRef; pub type CFPropertyListRef = CFTypeRef; @@ -23,24 +25,80 @@ pub const kCFPropertyListImmutable: CFPropertyListMutabilityOptions = 0; pub const kCFPropertyListMutableContainers: CFPropertyListMutabilityOptions = 1; pub const kCFPropertyListMutableContainersAndLeaves: CFPropertyListMutabilityOptions = 2; +/* Reading and Writing Error Codes */ +pub const kCFPropertyListReadCorruptError: CFIndex = 3840; +pub const kCFPropertyListReadUnknownVersionError: CFIndex = 3841; +pub const kCFPropertyListReadStreamError: CFIndex = 3842; +pub const kCFPropertyListWriteStreamError: CFIndex = 3851; + extern "C" { - // CFPropertyList.h - // - - // fn CFPropertyListCreateDeepCopy - // fn CFPropertyListIsValid - pub fn CFPropertyListCreateWithData(allocator: CFAllocatorRef, - data: CFDataRef, - options: CFPropertyListMutabilityOptions, - format: *mut CFPropertyListFormat, - error: *mut CFErrorRef) - -> CFPropertyListRef; - // fn CFPropertyListCreateWithStream - // fn CFPropertyListWrite - pub fn CFPropertyListCreateData(allocator: CFAllocatorRef, - propertyList: CFPropertyListRef, - format: CFPropertyListFormat, - options: CFOptionFlags, - error: *mut CFErrorRef) - -> CFDataRef; + /* + * CFPropertyList.h + */ + + /* Creating a Property List */ + pub fn CFPropertyListCreateWithData( + allocator: CFAllocatorRef, + data: CFDataRef, + options: CFPropertyListMutabilityOptions, + format: *mut CFPropertyListFormat, + error: *mut CFErrorRef, + ) -> CFPropertyListRef; + pub fn CFPropertyListCreateWithStream( + allocator: CFAllocatorRef, + stream: CFReadStreamRef, + streamLength: CFIndex, + options: CFOptionFlags, + format: *mut CFPropertyListFormat, + error: *mut CFErrorRef, + ) -> CFPropertyListRef; + pub fn CFPropertyListCreateDeepCopy( + allocator: CFAllocatorRef, + propertyList: CFPropertyListRef, + mutabilityOption: CFOptionFlags, + ) -> CFPropertyListRef; + pub fn CFPropertyListCreateFromXMLData( + allocator: CFAllocatorRef, + xmlData: CFDataRef, + mutabilityOption: CFOptionFlags, + errorString: *mut CFStringRef, + ) -> CFPropertyListRef; // deprecated + pub fn CFPropertyListCreateFromStream( + allocator: CFAllocatorRef, + stream: CFReadStreamRef, + streamLength: CFIndex, + mutabilityOption: CFOptionFlags, + format: *mut CFPropertyListFormat, + errorString: *mut CFStringRef, + ) -> CFPropertyListRef; // deprecated + + /* Exporting a Property List */ + pub fn CFPropertyListCreateData( + allocator: CFAllocatorRef, + propertyList: CFPropertyListRef, + format: CFPropertyListFormat, + options: CFOptionFlags, + error: *mut CFErrorRef, + ) -> CFDataRef; + pub fn CFPropertyListWrite( + propertyList: CFPropertyListRef, + stream: CFWriteStreamRef, + format: CFPropertyListFormat, + options: CFOptionFlags, + error: *mut CFErrorRef, + ) -> CFIndex; + pub fn CFPropertyListCreateXMLData( + allocator: CFAllocatorRef, + propertyList: CFPropertyListRef, + ) -> CFDataRef; // deprecated + pub fn CFPropertyListWriteToStream( + propertyList: CFPropertyListRef, + stream: CFWriteStreamRef, + format: CFPropertyListFormat, + errorString: *mut CFStringRef, + ) -> CFIndex; + + /* Validating a Property List */ + pub fn CFPropertyListIsValid(plist: CFPropertyListRef, format: CFPropertyListFormat) + -> Boolean; } diff --git a/vendor/core-foundation-sys/src/runloop.rs b/vendor/core-foundation-sys/src/runloop.rs index 53035a2e7..5d5fda7a0 100644 --- a/vendor/core-foundation-sys/src/runloop.rs +++ b/vendor/core-foundation-sys/src/runloop.rs @@ -9,10 +9,12 @@ use std::os::raw::c_void; -use array::CFArrayRef; -use base::{Boolean, CFIndex, CFTypeID, CFAllocatorRef, CFOptionFlags, CFHashCode, mach_port_t}; -use date::{CFAbsoluteTime, CFTimeInterval}; -use string::CFStringRef; +use crate::array::CFArrayRef; +use crate::base::{ + mach_port_t, Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFOptionFlags, CFTypeID, +}; +use crate::date::{CFAbsoluteTime, CFTimeInterval}; +use crate::string::CFStringRef; #[repr(C)] pub struct __CFRunLoop(c_void); @@ -30,135 +32,225 @@ pub struct __CFRunLoopObserver(c_void); pub type CFRunLoopObserverRef = *mut __CFRunLoopObserver; // Reasons for CFRunLoopRunInMode() to Return -pub const kCFRunLoopRunFinished: i32 = 1; -pub const kCFRunLoopRunStopped: i32 = 2; -pub const kCFRunLoopRunTimedOut: i32 = 3; +pub const kCFRunLoopRunFinished: i32 = 1; +pub const kCFRunLoopRunStopped: i32 = 2; +pub const kCFRunLoopRunTimedOut: i32 = 3; pub const kCFRunLoopRunHandledSource: i32 = 4; // Run Loop Observer Activities //typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) { pub type CFRunLoopActivity = CFOptionFlags; -pub const kCFRunLoopEntry: CFOptionFlags = 1 << 0; -pub const kCFRunLoopBeforeTimers: CFOptionFlags = 1 << 1; +pub const kCFRunLoopEntry: CFOptionFlags = 1 << 0; +pub const kCFRunLoopBeforeTimers: CFOptionFlags = 1 << 1; pub const kCFRunLoopBeforeSources: CFOptionFlags = 1 << 2; pub const kCFRunLoopBeforeWaiting: CFOptionFlags = 1 << 5; -pub const kCFRunLoopAfterWaiting: CFOptionFlags = 1 << 6; -pub const kCFRunLoopExit: CFOptionFlags = 1 << 7; +pub const kCFRunLoopAfterWaiting: CFOptionFlags = 1 << 6; +pub const kCFRunLoopExit: CFOptionFlags = 1 << 7; pub const kCFRunLoopAllActivities: CFOptionFlags = 0x0FFFFFFF; #[repr(C)] +#[derive(Debug, Clone, Copy)] pub struct CFRunLoopSourceContext { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<extern "C" fn (info: *const c_void) -> *const c_void>, - pub release: Option<extern "C" fn (info: *const c_void)>, - pub copyDescription: Option<extern "C" fn (info: *const c_void) -> CFStringRef>, - pub equal: Option<extern "C" fn (info1: *const c_void, info2: *const c_void) -> Boolean>, - pub hash: Option<extern "C" fn (info: *const c_void) -> CFHashCode>, - pub schedule: Option<extern "C" fn (info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>, - pub cancel: Option<extern "C" fn (info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>, - pub perform: extern "C" fn (info: *const c_void), + pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>, + pub equal: Option<extern "C" fn(info1: *const c_void, info2: *const c_void) -> Boolean>, + pub hash: Option<extern "C" fn(info: *const c_void) -> CFHashCode>, + pub schedule: Option<extern "C" fn(info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>, + pub cancel: Option<extern "C" fn(info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>, + pub perform: extern "C" fn(info: *const c_void), } #[repr(C)] +#[derive(Debug, Clone, Copy)] pub struct CFRunLoopSourceContext1 { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<extern "C" fn (info: *const c_void) -> *const c_void>, - pub release: Option<extern "C" fn (info: *const c_void)>, - pub copyDescription: Option<extern "C" fn (info: *const c_void) -> CFStringRef>, - pub equal: Option<extern "C" fn (info1: *const c_void, info2: *const c_void) -> Boolean>, - pub hash: Option<extern "C" fn (info: *const c_void) -> CFHashCode>, - // note that the following two fields are platform dependent in the C header, the ones here are for macOS - pub getPort: extern "C" fn (info: *mut c_void) -> mach_port_t, - pub perform: extern "C" fn (msg: *mut c_void, size: CFIndex, allocator: CFAllocatorRef, info: *mut c_void) -> *mut c_void, + pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>, + pub equal: Option<extern "C" fn(info1: *const c_void, info2: *const c_void) -> Boolean>, + pub hash: Option<extern "C" fn(info: *const c_void) -> CFHashCode>, + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub getPort: extern "C" fn(info: *mut c_void) -> mach_port_t, + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub perform: extern "C" fn( + msg: *mut c_void, + size: CFIndex, + allocator: CFAllocatorRef, + info: *mut c_void, + ) -> *mut c_void, + + #[cfg(not(any(target_os = "macos", target_os = "ios")))] + pub getPort: extern "C" fn(info: *mut c_void) -> *mut c_void, + #[cfg(not(any(target_os = "macos", target_os = "ios")))] + pub perform: extern "C" fn(info: *mut c_void) -> *mut c_void, } #[repr(C)] +#[derive(Debug, Clone, Copy)] pub struct CFRunLoopObserverContext { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<extern "C" fn (info: *const c_void) -> *const c_void>, - pub release: Option<extern "C" fn (info: *const c_void)>, - pub copyDescription: Option<extern "C" fn (info: *const c_void) -> CFStringRef>, + pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>, } -pub type CFRunLoopObserverCallBack = extern "C" fn (observer: CFRunLoopObserverRef, activity: CFRunLoopActivity, info: *mut c_void); +pub type CFRunLoopObserverCallBack = + extern "C" fn(observer: CFRunLoopObserverRef, activity: CFRunLoopActivity, info: *mut c_void); #[repr(C)] +#[derive(Clone, Copy, Debug)] pub struct CFRunLoopTimerContext { pub version: CFIndex, pub info: *mut c_void, - pub retain: Option<extern "C" fn (info: *const c_void) -> *const c_void>, - pub release: Option<extern "C" fn (info: *const c_void)>, - pub copyDescription: Option<extern "C" fn (info: *const c_void) -> CFStringRef>, + pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>, + pub release: Option<extern "C" fn(info: *const c_void)>, + pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>, } -pub type CFRunLoopTimerCallBack = extern "C" fn (timer: CFRunLoopTimerRef, info: *mut c_void); +pub type CFRunLoopTimerCallBack = extern "C" fn(timer: CFRunLoopTimerRef, info: *mut c_void); #[repr(C)] pub struct __CFRunLoopTimer(c_void); pub type CFRunLoopTimerRef = *mut __CFRunLoopTimer; -extern { +extern "C" { /* * CFRunLoop.h */ + pub static kCFRunLoopDefaultMode: CFStringRef; pub static kCFRunLoopCommonModes: CFStringRef; - pub fn CFRunLoopGetTypeID() -> CFTypeID; + + /* CFRunLoop */ + /* Getting a Run Loop */ pub fn CFRunLoopGetCurrent() -> CFRunLoopRef; pub fn CFRunLoopGetMain() -> CFRunLoopRef; - pub fn CFRunLoopCopyCurrentMode(rl: CFRunLoopRef) -> CFStringRef; - pub fn CFRunLoopCopyAllModes(rl: CFRunLoopRef) -> CFArrayRef; - pub fn CFRunLoopAddCommonMode(rl: CFRunLoopRef, mode: CFStringRef); - pub fn CFRunLoopGetNextTimerFireDate(rl: CFRunLoopRef, mode: CFStringRef) -> CFAbsoluteTime; + + /* Starting and Stopping a Run Loop */ pub fn CFRunLoopRun(); - pub fn CFRunLoopRunInMode(mode: CFStringRef, seconds: CFTimeInterval, returnAfterSourceHandled: Boolean) -> i32; - pub fn CFRunLoopIsWaiting(rl: CFRunLoopRef) -> Boolean; + pub fn CFRunLoopRunInMode( + mode: CFStringRef, + seconds: CFTimeInterval, + returnAfterSourceHandled: Boolean, + ) -> i32; pub fn CFRunLoopWakeUp(rl: CFRunLoopRef); pub fn CFRunLoopStop(rl: CFRunLoopRef); - // fn CFRunLoopPerformBlock(rl: CFRunLoopRef, mode: CFTypeRef, block: void (^)(void)); - pub fn CFRunLoopContainsSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef) -> Boolean; + pub fn CFRunLoopIsWaiting(rl: CFRunLoopRef) -> Boolean; + + /* Managing Sources */ pub fn CFRunLoopAddSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef); + pub fn CFRunLoopContainsSource( + rl: CFRunLoopRef, + source: CFRunLoopSourceRef, + mode: CFStringRef, + ) -> Boolean; pub fn CFRunLoopRemoveSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef); - pub fn CFRunLoopContainsObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef) -> Boolean; - pub fn CFRunLoopAddObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef); - pub fn CFRunLoopRemoveObserver(rl: CFRunLoopRef, observer: CFRunLoopObserverRef, mode: CFStringRef); - pub fn CFRunLoopContainsTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef) -> Boolean; + + /* Managing Observers */ + pub fn CFRunLoopAddObserver( + rl: CFRunLoopRef, + observer: CFRunLoopObserverRef, + mode: CFStringRef, + ); + pub fn CFRunLoopContainsObserver( + rl: CFRunLoopRef, + observer: CFRunLoopObserverRef, + mode: CFStringRef, + ) -> Boolean; + pub fn CFRunLoopRemoveObserver( + rl: CFRunLoopRef, + observer: CFRunLoopObserverRef, + mode: CFStringRef, + ); + + /* Managing Run Loop Modes */ + pub fn CFRunLoopAddCommonMode(rl: CFRunLoopRef, mode: CFStringRef); + pub fn CFRunLoopCopyAllModes(rl: CFRunLoopRef) -> CFArrayRef; + pub fn CFRunLoopCopyCurrentMode(rl: CFRunLoopRef) -> CFStringRef; + + /* Managing Timers */ pub fn CFRunLoopAddTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef); + pub fn CFRunLoopGetNextTimerFireDate(rl: CFRunLoopRef, mode: CFStringRef) -> CFAbsoluteTime; pub fn CFRunLoopRemoveTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef); + pub fn CFRunLoopContainsTimer( + rl: CFRunLoopRef, + timer: CFRunLoopTimerRef, + mode: CFStringRef, + ) -> Boolean; - pub fn CFRunLoopSourceGetTypeID() -> CFTypeID; - pub fn CFRunLoopSourceCreate(allocator: CFAllocatorRef, order: CFIndex, context: *mut CFRunLoopSourceContext) -> CFRunLoopSourceRef; + /* Scheduling Blocks */ + // fn CFRunLoopPerformBlock(rl: CFRunLoopRef, mode: CFTypeRef, block: void (^)(void)); + + /* Getting the CFRunLoop Type ID */ + pub fn CFRunLoopGetTypeID() -> CFTypeID; + + /* CFRunLoopSource */ + /* CFRunLoopSource Miscellaneous Functions */ + pub fn CFRunLoopSourceCreate( + allocator: CFAllocatorRef, + order: CFIndex, + context: *mut CFRunLoopSourceContext, + ) -> CFRunLoopSourceRef; + pub fn CFRunLoopSourceGetContext( + source: CFRunLoopSourceRef, + context: *mut CFRunLoopSourceContext, + ); pub fn CFRunLoopSourceGetOrder(source: CFRunLoopSourceRef) -> CFIndex; + pub fn CFRunLoopSourceGetTypeID() -> CFTypeID; pub fn CFRunLoopSourceInvalidate(source: CFRunLoopSourceRef); pub fn CFRunLoopSourceIsValid(source: CFRunLoopSourceRef) -> Boolean; - pub fn CFRunLoopSourceGetContext(source: CFRunLoopSourceRef, context: *mut CFRunLoopSourceContext); pub fn CFRunLoopSourceSignal(source: CFRunLoopSourceRef); - pub fn CFRunLoopObserverGetTypeID() -> CFTypeID; - pub fn CFRunLoopObserverCreate(allocator: CFAllocatorRef, activities: CFOptionFlags, repeats: Boolean, order: CFIndex, callout: CFRunLoopObserverCallBack, context: *mut CFRunLoopObserverContext) -> CFRunLoopObserverRef; + /* CFRunLoopObserver */ + /* CFRunLoopObserver Miscellaneous Functions */ // fn CFRunLoopObserverCreateWithHandler(allocator: CFAllocatorRef, activities: CFOptionFlags, repeats: Boolean, order: CFIndex, block: void (^) (CFRunLoopObserverRef observer, CFRunLoopActivity activity)) -> CFRunLoopObserverRef; - pub fn CFRunLoopObserverGetActivities(observer: CFRunLoopObserverRef) -> CFOptionFlags; + pub fn CFRunLoopObserverCreate( + allocator: CFAllocatorRef, + activities: CFOptionFlags, + repeats: Boolean, + order: CFIndex, + callout: CFRunLoopObserverCallBack, + context: *mut CFRunLoopObserverContext, + ) -> CFRunLoopObserverRef; pub fn CFRunLoopObserverDoesRepeat(observer: CFRunLoopObserverRef) -> Boolean; + pub fn CFRunLoopObserverGetActivities(observer: CFRunLoopObserverRef) -> CFOptionFlags; + pub fn CFRunLoopObserverGetContext( + observer: CFRunLoopObserverRef, + context: *mut CFRunLoopObserverContext, + ); pub fn CFRunLoopObserverGetOrder(observer: CFRunLoopObserverRef) -> CFIndex; + pub fn CFRunLoopObserverGetTypeID() -> CFTypeID; pub fn CFRunLoopObserverInvalidate(observer: CFRunLoopObserverRef); pub fn CFRunLoopObserverIsValid(observer: CFRunLoopObserverRef) -> Boolean; - pub fn CFRunLoopObserverGetContext(observer: CFRunLoopObserverRef, context: *mut CFRunLoopObserverContext); - pub fn CFRunLoopTimerGetTypeID() -> CFTypeID; - pub fn CFRunLoopTimerCreate(allocator: CFAllocatorRef, fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, callout: CFRunLoopTimerCallBack, context: *mut CFRunLoopTimerContext) -> CFRunLoopTimerRef; + /* CFRunLoopTimer */ + /* CFRunLoopTimer Miscellaneous Functions */ // fn CFRunLoopTimerCreateWithHandler(allocator: CFAllocatorRef, fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, block: void (^) (CFRunLoopTimerRef timer)) -> CFRunLoopTimerRef; - pub fn CFRunLoopTimerGetNextFireDate(timer: CFRunLoopTimerRef) -> CFAbsoluteTime; - pub fn CFRunLoopTimerSetNextFireDate(timer: CFRunLoopTimerRef, fireDate: CFAbsoluteTime); - pub fn CFRunLoopTimerGetInterval(timer: CFRunLoopTimerRef) -> CFTimeInterval; + pub fn CFRunLoopTimerCreate( + allocator: CFAllocatorRef, + fireDate: CFAbsoluteTime, + interval: CFTimeInterval, + flags: CFOptionFlags, + order: CFIndex, + callout: CFRunLoopTimerCallBack, + context: *mut CFRunLoopTimerContext, + ) -> CFRunLoopTimerRef; pub fn CFRunLoopTimerDoesRepeat(timer: CFRunLoopTimerRef) -> Boolean; + pub fn CFRunLoopTimerGetContext(timer: CFRunLoopTimerRef, context: *mut CFRunLoopTimerContext); + pub fn CFRunLoopTimerGetInterval(timer: CFRunLoopTimerRef) -> CFTimeInterval; + pub fn CFRunLoopTimerGetNextFireDate(timer: CFRunLoopTimerRef) -> CFAbsoluteTime; pub fn CFRunLoopTimerGetOrder(timer: CFRunLoopTimerRef) -> CFIndex; + pub fn CFRunLoopTimerGetTypeID() -> CFTypeID; pub fn CFRunLoopTimerInvalidate(timer: CFRunLoopTimerRef); pub fn CFRunLoopTimerIsValid(timer: CFRunLoopTimerRef) -> Boolean; - pub fn CFRunLoopTimerGetContext(timer: CFRunLoopTimerRef, context: *mut CFRunLoopTimerContext); - pub fn CFRunLoopTimerGetTolerance(timer: CFRunLoopTimerRef) -> CFTimeInterval; - pub fn CFRunLoopTimerSetTolerance(timer: CFRunLoopTimerRef, tolerance: CFTimeInterval); + pub fn CFRunLoopTimerSetNextFireDate(timer: CFRunLoopTimerRef, fireDate: CFAbsoluteTime); + pub fn CFRunLoopTimerGetTolerance(timer: CFRunLoopTimerRef) -> CFTimeInterval; //macos(10.9)+ + pub fn CFRunLoopTimerSetTolerance(timer: CFRunLoopTimerRef, tolerance: CFTimeInterval); //macos(10.9)+ } diff --git a/vendor/core-foundation-sys/src/set.rs b/vendor/core-foundation-sys/src/set.rs index a5cc1b16f..8141c5999 100644 --- a/vendor/core-foundation-sys/src/set.rs +++ b/vendor/core-foundation-sys/src/set.rs @@ -9,15 +9,17 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean}; +use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID}; +use crate::string::CFStringRef; -pub type CFSetApplierFunction = extern "C" fn (value: *const c_void, - context: *const c_void); -pub type CFSetRetainCallBack = *const u8; -pub type CFSetReleaseCallBack = *const u8; -pub type CFSetCopyDescriptionCallBack = *const u8; -pub type CFSetEqualCallBack = *const u8; -pub type CFSetHashCallBack = *const u8; +pub type CFSetApplierFunction = extern "C" fn(value: *const c_void, context: *const c_void); +pub type CFSetRetainCallBack = + extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void; +pub type CFSetReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void); +pub type CFSetCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef; +pub type CFSetEqualCallBack = + extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean; +pub type CFSetHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode; #[repr(C)] #[derive(Clone, Copy)] @@ -34,17 +36,24 @@ pub struct CFSetCallBacks { pub struct __CFSet(c_void); pub type CFSetRef = *const __CFSet; +pub type CFMutableSetRef = *mut __CFSet; -extern { +extern "C" { /* * CFSet.h */ pub static kCFTypeSetCallBacks: CFSetCallBacks; + pub static kCFCopyStringSetCallBacks: CFSetCallBacks; + /* CFSet */ /* Creating Sets */ - pub fn CFSetCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, - callBacks: *const CFSetCallBacks) -> CFSetRef; + pub fn CFSetCreate( + allocator: CFAllocatorRef, + values: *const *const c_void, + numValues: CFIndex, + callBacks: *const CFSetCallBacks, + ) -> CFSetRef; pub fn CFSetCreateCopy(allocator: CFAllocatorRef, theSet: CFSetRef) -> CFSetRef; /* Examining a Set */ @@ -52,15 +61,38 @@ extern { pub fn CFSetGetCount(theSet: CFSetRef) -> CFIndex; pub fn CFSetGetCountOfValue(theSet: CFSetRef, value: *const c_void) -> CFIndex; pub fn CFSetGetValue(theSet: CFSetRef, value: *const c_void) -> *const c_void; - pub fn CFSetGetValueIfPresent(theSet: CFSetRef, candidate: *const c_void, value: *mut *const c_void) -> Boolean; + pub fn CFSetGetValueIfPresent( + theSet: CFSetRef, + candidate: *const c_void, + value: *mut *const c_void, + ) -> Boolean; pub fn CFSetGetValues(theSet: CFSetRef, values: *mut *const c_void); /* Applying a Function to Set Members */ - pub fn CFSetApplyFunction(theSet: CFSetRef, - applier: CFSetApplierFunction, - context: *const c_void); + pub fn CFSetApplyFunction( + theSet: CFSetRef, + applier: CFSetApplierFunction, + context: *const c_void, + ); /* Getting the CFSet Type ID */ pub fn CFSetGetTypeID() -> CFTypeID; -} + /* CFMutableSet */ + /* CFMutableSet Miscellaneous Functions */ + pub fn CFSetAddValue(theSet: CFMutableSetRef, value: *const c_void); + pub fn CFSetCreateMutable( + allocator: CFAllocatorRef, + capacity: CFIndex, + callBacks: *const CFSetCallBacks, + ) -> CFMutableSetRef; + pub fn CFSetCreateMutableCopy( + allocator: CFAllocatorRef, + capacity: CFIndex, + theSet: CFSetRef, + ) -> CFMutableSetRef; + pub fn CFSetRemoveAllValues(theSet: CFMutableSetRef); + pub fn CFSetRemoveValue(theSet: CFMutableSetRef, value: *const c_void); + pub fn CFSetReplaceValue(theSet: CFMutableSetRef, value: *const c_void); + pub fn CFSetSetValue(theSet: CFMutableSetRef, value: *const c_void); +} diff --git a/vendor/core-foundation-sys/src/socket.rs b/vendor/core-foundation-sys/src/socket.rs new file mode 100644 index 000000000..6fb70a108 --- /dev/null +++ b/vendor/core-foundation-sys/src/socket.rs @@ -0,0 +1,188 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32, UInt16}; +use crate::data::CFDataRef; +use crate::date::CFTimeInterval; +use crate::propertylist::CFPropertyListRef; +use crate::runloop::CFRunLoopSourceRef; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFSocket(c_void); + +pub type CFSocketRef = *mut __CFSocket; + +pub type CFSocketError = CFIndex; +pub type CFSocketCallBackType = CFOptionFlags; +pub type CFSocketCallBack = extern "C" fn( + s: CFSocketRef, + _type: CFSocketCallBackType, + address: CFDataRef, + cdata: *const c_void, + info: *mut c_void, +); +#[cfg(not(target_os = "windows"))] +pub type CFSocketNativeHandle = std::os::raw::c_int; +#[cfg(target_os = "windows")] +pub type CFSocketNativeHandle = std::os::raw::c_ulong; + +pub const kCFSocketSuccess: CFSocketError = 0; +pub const kCFSocketError: CFSocketError = -1; +pub const kCFSocketTimeout: CFSocketError = -2; + +#[derive(Debug, Copy, Clone)] +#[repr(C)] +pub struct CFSocketSignature { + pub protocolFamily: SInt32, + pub socketType: SInt32, + pub protocol: SInt32, + pub address: CFDataRef, +} + +#[derive(Debug, Copy, Clone)] +#[repr(C)] +pub struct CFSocketContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn(info: *const c_void) -> *const c_void, + pub release: extern "C" fn(info: *const c_void), + pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef, +} + +pub const kCFSocketNoCallBack: CFSocketError = 0; +pub const kCFSocketReadCallBack: CFSocketError = 1; +pub const kCFSocketAcceptCallBack: CFSocketError = 2; +pub const kCFSocketDataCallBack: CFSocketError = 3; +pub const kCFSocketConnectCallBack: CFSocketError = 4; +pub const kCFSocketWriteCallBack: CFSocketError = 8; + +pub const kCFSocketAutomaticallyReenableReadCallBack: CFOptionFlags = 1; +pub const kCFSocketAutomaticallyReenableAcceptCallBack: CFOptionFlags = 2; +pub const kCFSocketAutomaticallyReenableDataCallBack: CFOptionFlags = 3; +pub const kCFSocketAutomaticallyReenableWriteCallBack: CFOptionFlags = 8; +pub const kCFSocketLeaveErrors: CFOptionFlags = 64; +pub const kCFSocketCloseOnInvalidate: CFOptionFlags = 128; + +extern "C" { + /* + * CFSocket.h + */ + + /* CFSocket Name Server Keys: Not used */ + pub static kCFSocketCommandKey: CFStringRef; + pub static kCFSocketNameKey: CFStringRef; + pub static kCFSocketValueKey: CFStringRef; + pub static kCFSocketResultKey: CFStringRef; + pub static kCFSocketErrorKey: CFStringRef; + pub static kCFSocketRegisterCommand: CFStringRef; + pub static kCFSocketRetrieveCommand: CFStringRef; + + /* Creating Sockets */ + pub fn CFSocketCreate( + allocator: CFAllocatorRef, + protocolFamily: SInt32, + socketType: SInt32, + protocol: SInt32, + callBackTypes: CFOptionFlags, + callout: CFSocketCallBack, + context: *const CFSocketContext, + ) -> CFSocketRef; + pub fn CFSocketCreateConnectedToSocketSignature( + allocator: CFAllocatorRef, + signature: *const CFSocketSignature, + callBackTypes: CFOptionFlags, + callout: CFSocketCallBack, + context: *const CFSocketContext, + timeout: CFTimeInterval, + ) -> CFSocketRef; + pub fn CFSocketCreateWithNative( + allocator: CFAllocatorRef, + sock: CFSocketNativeHandle, + callBackTypes: CFOptionFlags, + callout: CFSocketCallBack, + context: *const CFSocketContext, + ) -> CFSocketRef; + pub fn CFSocketCreateWithSocketSignature( + allocator: CFAllocatorRef, + signature: *const CFSocketSignature, + callBackTypes: CFOptionFlags, + callout: CFSocketCallBack, + context: *const CFSocketContext, + ) -> CFSocketRef; + + /* Configuring Sockets */ + pub fn CFSocketCopyAddress(s: CFSocketRef) -> CFDataRef; + pub fn CFSocketCopyPeerAddress(s: CFSocketRef) -> CFDataRef; + pub fn CFSocketDisableCallBacks(s: CFSocketRef, callBackTypes: CFOptionFlags); + pub fn CFSocketEnableCallBacks(s: CFSocketRef, callBackTypes: CFOptionFlags); + pub fn CFSocketGetContext(s: CFSocketRef, context: *mut CFSocketContext); + pub fn CFSocketGetNative(s: CFSocketRef) -> CFSocketNativeHandle; + pub fn CFSocketGetSocketFlags(s: CFSocketRef) -> CFOptionFlags; + pub fn CFSocketSetAddress(s: CFSocketRef, address: CFDataRef) -> CFSocketError; + pub fn CFSocketSetSocketFlags(s: CFSocketRef, flags: CFOptionFlags); + + /* Using Sockets */ + pub fn CFSocketConnectToAddress( + s: CFSocketRef, + address: CFDataRef, + timeout: CFTimeInterval, + ) -> CFSocketError; + pub fn CFSocketCreateRunLoopSource( + allocator: CFAllocatorRef, + s: CFSocketRef, + order: CFIndex, + ) -> CFRunLoopSourceRef; + pub fn CFSocketGetTypeID() -> CFTypeID; + pub fn CFSocketInvalidate(s: CFSocketRef); + pub fn CFSocketIsValid(s: CFSocketRef) -> Boolean; + pub fn CFSocketSendData( + s: CFSocketRef, + address: CFDataRef, + data: CFDataRef, + timeout: CFTimeInterval, + ) -> CFSocketError; + + /* Socket Name Server Utilities */ + pub fn CFSocketCopyRegisteredSocketSignature( + nameServerSignature: *const CFSocketSignature, + timeout: CFTimeInterval, + name: CFStringRef, + signature: *mut CFSocketSignature, + nameServerAddress: *mut CFDataRef, + ) -> CFSocketError; + pub fn CFSocketCopyRegisteredValue( + nameServerSignature: *const CFSocketSignature, + timeout: CFTimeInterval, + name: CFStringRef, + value: *mut CFPropertyListRef, + nameServerAddress: *mut CFDataRef, + ) -> CFSocketError; + pub fn CFSocketGetDefaultNameRegistryPortNumber() -> UInt16; + pub fn CFSocketRegisterSocketSignature( + nameServerSignature: *const CFSocketSignature, + timeout: CFTimeInterval, + name: CFStringRef, + signature: *const CFSocketSignature, + ) -> CFSocketError; + pub fn CFSocketRegisterValue( + nameServerSignature: *const CFSocketSignature, + timeout: CFTimeInterval, + name: CFStringRef, + value: CFPropertyListRef, + ) -> CFSocketError; + pub fn CFSocketSetDefaultNameRegistryPortNumber(port: UInt16); + pub fn CFSocketUnregister( + nameServerSignature: *const CFSocketSignature, + timeout: CFTimeInterval, + name: CFStringRef, + ) -> CFSocketError; +} diff --git a/vendor/core-foundation-sys/src/stream.rs b/vendor/core-foundation-sys/src/stream.rs new file mode 100644 index 000000000..922700e48 --- /dev/null +++ b/vendor/core-foundation-sys/src/stream.rs @@ -0,0 +1,281 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_int, c_void}; + +use crate::base::{ + Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, CFTypeRef, SInt32, UInt32, UInt8, +}; +use crate::error::CFErrorRef; +use crate::runloop::CFRunLoopRef; +use crate::socket::{CFSocketNativeHandle, CFSocketSignature}; +use crate::string::CFStringRef; +use crate::url::CFURLRef; + +#[repr(C)] +pub struct __CFReadStream(c_void); + +#[repr(C)] +pub struct __CFWriteStream(c_void); + +pub type CFReadStreamRef = *mut __CFReadStream; +pub type CFWriteStreamRef = *mut __CFWriteStream; +pub type CFStreamPropertyKey = CFStringRef; +pub type CFStreamStatus = CFIndex; +pub type CFStreamEventType = CFOptionFlags; +pub type CFStreamErrorDomain = CFIndex; + +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct CFStreamError { + pub domain: CFIndex, + pub error: SInt32, +} + +/* CFStreamStatus: Constants that describe the status of a stream */ +pub const kCFStreamStatusNotOpen: CFStreamStatus = 0; +pub const kCFStreamStatusOpening: CFStreamStatus = 1; +pub const kCFStreamStatusOpen: CFStreamStatus = 2; +pub const kCFStreamStatusReading: CFStreamStatus = 3; +pub const kCFStreamStatusWriting: CFStreamStatus = 4; +pub const kCFStreamStatusAtEnd: CFStreamStatus = 5; +pub const kCFStreamStatusClosed: CFStreamStatus = 6; +pub const kCFStreamStatusError: CFStreamStatus = 7; + +// deprecated +pub const kCFStreamErrorDomainCustom: CFStreamErrorDomain = -1; +pub const kCFStreamErrorDomainPOSIX: CFStreamErrorDomain = 1; +pub const kCFStreamErrorDomainMacOSStatus: CFStreamErrorDomain = 2; + +/* CFStreamEventType: Defines constants for stream-related events */ +pub const kCFStreamEventNone: CFStreamEventType = 0; +pub const kCFStreamEventOpenCompleted: CFStreamEventType = 1; +pub const kCFStreamEventHasBytesAvailable: CFStreamEventType = 2; +pub const kCFStreamEventCanAcceptBytes: CFStreamEventType = 4; +pub const kCFStreamEventErrorOccurred: CFStreamEventType = 8; +pub const kCFStreamEventEndEncountered: CFStreamEventType = 16; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFStreamClientContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn(info: *const c_void) -> *const c_void, + pub release: extern "C" fn(info: *const c_void), + pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef, +} + +pub type CFReadStreamClientCallBack = extern "C" fn( + stream: CFReadStreamRef, + _type: CFStreamEventType, + clientCallBackInfo: *mut c_void, +); +pub type CFWriteStreamClientCallBack = extern "C" fn( + stream: CFWriteStreamRef, + _type: CFStreamEventType, + clientCallBackInfo: *mut c_void, +); + +extern "C" { + /* + * CFStream.h + */ + + /* Stream Properties */ + pub static kCFStreamPropertyAppendToFile: CFStreamPropertyKey; + pub static kCFStreamPropertyDataWritten: CFStreamPropertyKey; + pub static kCFStreamPropertyFileCurrentOffset: CFStreamPropertyKey; + pub static kCFStreamPropertySocketNativeHandle: CFStreamPropertyKey; + pub static kCFStreamPropertySocketRemoteHostName: CFStreamPropertyKey; + pub static kCFStreamPropertySocketRemotePortNumber: CFStreamPropertyKey; + pub static kCFStreamPropertyShouldCloseNativeSocket: CFStringRef; + pub static kCFStreamPropertySocketSecurityLevel: CFStringRef; + + /* CFStream Socket Security Level Constants */ + pub static kCFStreamSocketSecurityLevelNone: CFStringRef; + pub static kCFStreamSocketSecurityLevelSSLv2: CFStringRef; + pub static kCFStreamSocketSecurityLevelSSLv3: CFStringRef; + pub static kCFStreamSocketSecurityLevelTLSv1: CFStringRef; + pub static kCFStreamSocketSecurityLevelNegotiatedSSL: CFStringRef; + + /* CFStream SOCKS Proxy Key Constants */ + pub static kCFStreamPropertySOCKSProxy: CFStringRef; + pub static kCFStreamPropertySOCKSProxyHost: CFStringRef; + pub static kCFStreamPropertySOCKSProxyPort: CFStringRef; + pub static kCFStreamPropertySOCKSVersion: CFStringRef; + pub static kCFStreamSocketSOCKSVersion4: CFStringRef; + pub static kCFStreamSocketSOCKSVersion5: CFStringRef; + pub static kCFStreamPropertySOCKSUser: CFStringRef; + pub static kCFStreamPropertySOCKSPassword: CFStringRef; + + /* CFStream Error Domain Constants (CFHost) */ + pub static kCFStreamErrorDomainSOCKS: c_int; + pub static kCFStreamErrorDomainSSL: c_int; + + /* CFStream: Creating Streams */ + pub fn CFStreamCreatePairWithPeerSocketSignature( + alloc: CFAllocatorRef, + signature: *const CFSocketSignature, + readStream: *mut CFReadStreamRef, + writeStream: *mut CFWriteStreamRef, + ); // deprecated + pub fn CFStreamCreatePairWithSocketToHost( + alloc: CFAllocatorRef, + host: CFStringRef, + port: UInt32, + readStream: *mut CFReadStreamRef, + writeStream: *mut CFWriteStreamRef, + ); // deprecated + pub fn CFStreamCreatePairWithSocket( + alloc: CFAllocatorRef, + sock: CFSocketNativeHandle, + readStream: *mut CFReadStreamRef, + writeStream: *mut CFWriteStreamRef, + ); // deprecated + pub fn CFStreamCreateBoundPair( + alloc: CFAllocatorRef, + readStream: *mut CFReadStreamRef, + writeStream: *mut CFWriteStreamRef, + transferBufferSize: CFIndex, + ); + + //pub fn CFReadStreamSetDispatchQueue(stream: CFReadStreamRef, q: dispatch_queue_t); // macos(10.9)+ + //pub fn CFWriteStreamSetDispatchQueue(stream: CFWriteStreamRef, q: dispatch_queue_t); // macos(10.9)+ + //pub fn CFReadStreamCopyDispatchQueue(stream: CFReadStreamRef) -> dispatch_queue_t; // macos(10.9)+ + //pub fn CFWriteStreamCopyDispatchQueue(stream: CFReadStreamRef) -> dispatch_queue_t; // macos(10.9)+ + + /* CFReadStream */ + /* Creating a Read Stream */ + pub fn CFReadStreamCreateWithBytesNoCopy( + alloc: CFAllocatorRef, + bytes: *const UInt8, + length: CFIndex, + bytesDeallocator: CFAllocatorRef, + ) -> CFReadStreamRef; + pub fn CFReadStreamCreateWithFile(alloc: CFAllocatorRef, fileURL: CFURLRef) -> CFReadStreamRef; + + /* Opening and Closing a Read Stream */ + pub fn CFReadStreamClose(stream: CFReadStreamRef); + pub fn CFReadStreamOpen(stream: CFReadStreamRef) -> Boolean; + + /* Reading from a Stream */ + pub fn CFReadStreamRead( + stream: CFReadStreamRef, + buffer: *mut UInt8, + bufferLength: CFIndex, + ) -> CFIndex; + + /* Scheduling a Read Stream */ + pub fn CFReadStreamScheduleWithRunLoop( + stream: CFReadStreamRef, + runLoop: CFRunLoopRef, + runLoopMode: CFStringRef, + ); + pub fn CFReadStreamUnscheduleFromRunLoop( + stream: CFReadStreamRef, + runLoop: CFRunLoopRef, + runLoopMode: CFStringRef, + ); + + /* Examining Stream Properties */ + pub fn CFReadStreamCopyProperty( + stream: CFReadStreamRef, + propertyName: CFStreamPropertyKey, + ) -> CFTypeRef; + pub fn CFReadStreamGetBuffer( + stream: CFReadStreamRef, + maxBytesToRead: CFIndex, + numBytesRead: *mut CFIndex, + ) -> *const UInt8; + pub fn CFReadStreamCopyError(stream: CFReadStreamRef) -> CFErrorRef; + pub fn CFReadStreamGetError(stream: CFReadStreamRef) -> CFStreamError; // deprecated + pub fn CFReadStreamGetStatus(stream: CFReadStreamRef) -> CFStreamStatus; + pub fn CFReadStreamHasBytesAvailable(stream: CFReadStreamRef) -> Boolean; + + /* Setting Stream Properties */ + pub fn CFReadStreamSetClient( + stream: CFReadStreamRef, + streamEvents: CFOptionFlags, + clientCB: CFReadStreamClientCallBack, + clientContext: *mut CFStreamClientContext, + ) -> Boolean; + pub fn CFReadStreamSetProperty( + stream: CFReadStreamRef, + propertyName: CFStreamPropertyKey, + propertyValue: CFTypeRef, + ) -> Boolean; + + /* Getting the CFReadStream Type ID */ + pub fn CFReadStreamGetTypeID() -> CFTypeID; + + /* CFWriteStream */ + /* Creating a Write Stream */ + pub fn CFWriteStreamCreateWithAllocatedBuffers( + alloc: CFAllocatorRef, + bufferAllocator: CFAllocatorRef, + ) -> CFWriteStreamRef; + pub fn CFWriteStreamCreateWithBuffer( + alloc: CFAllocatorRef, + buffer: *mut UInt8, + bufferCapacity: CFIndex, + ) -> CFWriteStreamRef; + pub fn CFWriteStreamCreateWithFile( + alloc: CFAllocatorRef, + fileURL: CFURLRef, + ) -> CFWriteStreamRef; + + /* Opening and Closing a Stream */ + pub fn CFWriteStreamClose(stream: CFWriteStreamRef); + pub fn CFWriteStreamOpen(stream: CFWriteStreamRef) -> Boolean; + + /* Writing to a Stream */ + pub fn CFWriteStreamWrite( + stream: CFWriteStreamRef, + buffer: *const UInt8, + bufferLength: CFIndex, + ) -> CFIndex; + + /* Scheduling a Write Stream */ + pub fn CFWriteStreamScheduleWithRunLoop( + stream: CFWriteStreamRef, + runLoop: CFRunLoopRef, + runLoopMode: CFStringRef, + ); + pub fn CFWriteStreamUnscheduleFromRunLoop( + stream: CFWriteStreamRef, + runLoop: CFRunLoopRef, + runLoopMode: CFStringRef, + ); + + /* Examining Stream Properties */ + pub fn CFWriteStreamCanAcceptBytes(stream: CFWriteStreamRef) -> Boolean; + pub fn CFWriteStreamCopyProperty( + stream: CFWriteStreamRef, + propertyName: CFStreamPropertyKey, + ) -> CFTypeRef; + pub fn CFWriteStreamCopyError(stream: CFWriteStreamRef) -> CFErrorRef; + pub fn CFWriteStreamGetError(stream: CFWriteStreamRef) -> CFStreamError; // deprecated + pub fn CFWriteStreamGetStatus(stream: CFWriteStreamRef) -> CFStreamStatus; + + /* Setting Stream Properties */ + pub fn CFWriteStreamSetClient( + stream: CFWriteStreamRef, + streamEvents: CFOptionFlags, + clientCB: CFWriteStreamClientCallBack, + clientContext: *mut CFStreamClientContext, + ) -> Boolean; + pub fn CFWriteStreamSetProperty( + stream: CFWriteStreamRef, + propertyName: CFStreamPropertyKey, + propertyValue: CFTypeRef, + ) -> Boolean; + + /* Getting the CFWriteStream Type ID */ + pub fn CFWriteStreamGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/string.rs b/vendor/core-foundation-sys/src/string.rs index d4f655078..2cb6ae948 100644 --- a/vendor/core-foundation-sys/src/string.rs +++ b/vendor/core-foundation-sys/src/string.rs @@ -7,317 +7,540 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::os::raw::{c_char, c_ushort, c_void}; - -use base::{Boolean, CFOptionFlags, CFIndex, CFAllocatorRef, CFRange, CFTypeID}; - -pub type UniChar = c_ushort; - -// CFString.h +use crate::array::CFArrayRef; +use crate::base::{ + Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFOptionFlags, CFRange, CFTypeID, + ConstStr255Param, ConstStringPtr, SInt32, StringPtr, UInt32, UInt8, UTF32Char, +}; +use crate::characterset::CFCharacterSetRef; +use crate::data::CFDataRef; +use crate::dictionary::CFDictionaryRef; +use crate::locale::CFLocaleRef; +use std::os::raw::{c_char, c_double, c_ulong, c_ushort, c_void}; pub type CFStringCompareFlags = CFOptionFlags; -//static kCFCompareCaseInsensitive: CFStringCompareFlags = 1; -//static kCFCompareBackwards: CFStringCompareFlags = 4; -//static kCFCompareAnchored: CFStringCompareFlags = 8; -//static kCFCompareNonliteral: CFStringCompareFlags = 16; -//static kCFCompareLocalized: CFStringCompareFlags = 32; -//static kCFCompareNumerically: CFStringCompareFlags = 64; -//static kCFCompareDiacriticInsensitive: CFStringCompareFlags = 128; -//static kCFCompareWidthInsensitive: CFStringCompareFlags = 256; -//static kCFCompareForcedOrdering: CFStringCompareFlags = 512; +pub const kCFCompareCaseInsensitive: CFStringCompareFlags = 1; +pub const kCFCompareBackwards: CFStringCompareFlags = 4; +pub const kCFCompareAnchored: CFStringCompareFlags = 8; +pub const kCFCompareNonliteral: CFStringCompareFlags = 16; +pub const kCFCompareLocalized: CFStringCompareFlags = 32; +pub const kCFCompareNumerically: CFStringCompareFlags = 64; +pub const kCFCompareDiacriticInsensitive: CFStringCompareFlags = 128; +pub const kCFCompareWidthInsensitive: CFStringCompareFlags = 256; +pub const kCFCompareForcedOrdering: CFStringCompareFlags = 512; -pub type CFStringEncoding = u32; +pub type CFStringEncoding = UInt32; +pub type UniChar = c_ushort; // macOS built-in encodings. -//static kCFStringEncodingMacRoman: CFStringEncoding = 0; -//static kCFStringEncodingWindowsLatin1: CFStringEncoding = 0x0500; -//static kCFStringEncodingISOLatin1: CFStringEncoding = 0x0201; -//static kCFStringEncodingNextStepLatin: CFStringEncoding = 0x0B01; -//static kCFStringEncodingASCII: CFStringEncoding = 0x0600; -//static kCFStringEncodingUnicode: CFStringEncoding = 0x0100; -pub static kCFStringEncodingUTF8: CFStringEncoding = 0x08000100; -//static kCFStringEncodingNonLossyASCII: CFStringEncoding = 0x0BFF; - -//static kCFStringEncodingUTF16: CFStringEncoding = 0x0100; -//static kCFStringEncodingUTF16BE: CFStringEncoding = 0x10000100; -//static kCFStringEncodingUTF16LE: CFStringEncoding = 0x14000100; -//static kCFStringEncodingUTF32: CFStringEncoding = 0x0c000100; -//static kCFStringEncodingUTF32BE: CFStringEncoding = 0x18000100; -//static kCFStringEncodingUTF32LE: CFStringEncoding = 0x1c000100; +pub const kCFStringEncodingMacRoman: CFStringEncoding = 0; +pub const kCFStringEncodingWindowsLatin1: CFStringEncoding = 0x0500; +pub const kCFStringEncodingISOLatin1: CFStringEncoding = 0x0201; +pub const kCFStringEncodingNextStepLatin: CFStringEncoding = 0x0B01; +pub const kCFStringEncodingASCII: CFStringEncoding = 0x0600; +pub const kCFStringEncodingUnicode: CFStringEncoding = 0x0100; +pub const kCFStringEncodingUTF8: CFStringEncoding = 0x08000100; +pub const kCFStringEncodingNonLossyASCII: CFStringEncoding = 0x0BFF; +pub const kCFStringEncodingUTF16: CFStringEncoding = 0x0100; +pub const kCFStringEncodingUTF16BE: CFStringEncoding = 0x10000100; +pub const kCFStringEncodingUTF16LE: CFStringEncoding = 0x14000100; +pub const kCFStringEncodingUTF32: CFStringEncoding = 0x0c000100; +pub const kCFStringEncodingUTF32BE: CFStringEncoding = 0x18000100; +pub const kCFStringEncodingUTF32LE: CFStringEncoding = 0x1c000100; // CFStringEncodingExt.h +// External encodings, except those defined above. +pub const kCFStringEncodingMacJapanese: CFStringEncoding = 1; +pub const kCFStringEncodingMacChineseTrad: CFStringEncoding = 2; +pub const kCFStringEncodingMacKorean: CFStringEncoding = 3; +pub const kCFStringEncodingMacArabic: CFStringEncoding = 4; +pub const kCFStringEncodingMacHebrew: CFStringEncoding = 5; +pub const kCFStringEncodingMacGreek: CFStringEncoding = 6; +pub const kCFStringEncodingMacCyrillic: CFStringEncoding = 7; +pub const kCFStringEncodingMacDevanagari: CFStringEncoding = 9; +pub const kCFStringEncodingMacGurmukhi: CFStringEncoding = 10; +pub const kCFStringEncodingMacGujarati: CFStringEncoding = 11; +pub const kCFStringEncodingMacOriya: CFStringEncoding = 12; +pub const kCFStringEncodingMacBengali: CFStringEncoding = 13; +pub const kCFStringEncodingMacTamil: CFStringEncoding = 14; +pub const kCFStringEncodingMacTelugu: CFStringEncoding = 15; +pub const kCFStringEncodingMacKannada: CFStringEncoding = 16; +pub const kCFStringEncodingMacMalayalam: CFStringEncoding = 17; +pub const kCFStringEncodingMacSinhalese: CFStringEncoding = 18; +pub const kCFStringEncodingMacBurmese: CFStringEncoding = 19; +pub const kCFStringEncodingMacKhmer: CFStringEncoding = 20; +pub const kCFStringEncodingMacThai: CFStringEncoding = 21; +pub const kCFStringEncodingMacLaotian: CFStringEncoding = 22; +pub const kCFStringEncodingMacGeorgian: CFStringEncoding = 23; +pub const kCFStringEncodingMacArmenian: CFStringEncoding = 24; +pub const kCFStringEncodingMacChineseSimp: CFStringEncoding = 25; +pub const kCFStringEncodingMacTibetan: CFStringEncoding = 26; +pub const kCFStringEncodingMacMongolian: CFStringEncoding = 27; +pub const kCFStringEncodingMacEthiopic: CFStringEncoding = 28; +pub const kCFStringEncodingMacCentralEurRoman: CFStringEncoding = 29; +pub const kCFStringEncodingMacVietnamese: CFStringEncoding = 30; +pub const kCFStringEncodingMacExtArabic: CFStringEncoding = 31; +pub const kCFStringEncodingMacSymbol: CFStringEncoding = 33; +pub const kCFStringEncodingMacDingbats: CFStringEncoding = 34; +pub const kCFStringEncodingMacTurkish: CFStringEncoding = 35; +pub const kCFStringEncodingMacCroatian: CFStringEncoding = 36; +pub const kCFStringEncodingMacIcelandic: CFStringEncoding = 37; +pub const kCFStringEncodingMacRomanian: CFStringEncoding = 38; +pub const kCFStringEncodingMacCeltic: CFStringEncoding = 39; +pub const kCFStringEncodingMacGaelic: CFStringEncoding = 40; +pub const kCFStringEncodingMacFarsi: CFStringEncoding = 0x8C; +pub const kCFStringEncodingMacUkrainian: CFStringEncoding = 0x98; +pub const kCFStringEncodingMacInuit: CFStringEncoding = 0xEC; +pub const kCFStringEncodingMacVT100: CFStringEncoding = 0xFC; +pub const kCFStringEncodingMacHFS: CFStringEncoding = 0xFF; +pub const kCFStringEncodingISOLatin2: CFStringEncoding = 0x0202; +pub const kCFStringEncodingISOLatin3: CFStringEncoding = 0x0203; +pub const kCFStringEncodingISOLatin4: CFStringEncoding = 0x0204; +pub const kCFStringEncodingISOLatinCyrillic: CFStringEncoding = 0x0205; +pub const kCFStringEncodingISOLatinArabic: CFStringEncoding = 0x0206; +pub const kCFStringEncodingISOLatinGreek: CFStringEncoding = 0x0207; +pub const kCFStringEncodingISOLatinHebrew: CFStringEncoding = 0x0208; +pub const kCFStringEncodingISOLatin5: CFStringEncoding = 0x0209; +pub const kCFStringEncodingISOLatin6: CFStringEncoding = 0x020A; +pub const kCFStringEncodingISOLatinThai: CFStringEncoding = 0x020B; +pub const kCFStringEncodingISOLatin7: CFStringEncoding = 0x020D; +pub const kCFStringEncodingISOLatin8: CFStringEncoding = 0x020E; +pub const kCFStringEncodingISOLatin9: CFStringEncoding = 0x020F; +pub const kCFStringEncodingISOLatin10: CFStringEncoding = 0x0210; +pub const kCFStringEncodingDOSLatinUS: CFStringEncoding = 0x0400; +pub const kCFStringEncodingDOSGreek: CFStringEncoding = 0x0405; +pub const kCFStringEncodingDOSBalticRim: CFStringEncoding = 0x0406; +pub const kCFStringEncodingDOSLatin1: CFStringEncoding = 0x0410; +pub const kCFStringEncodingDOSGreek1: CFStringEncoding = 0x0411; +pub const kCFStringEncodingDOSLatin2: CFStringEncoding = 0x0412; +pub const kCFStringEncodingDOSCyrillic: CFStringEncoding = 0x0413; +pub const kCFStringEncodingDOSTurkish: CFStringEncoding = 0x0414; +pub const kCFStringEncodingDOSPortuguese: CFStringEncoding = 0x0415; +pub const kCFStringEncodingDOSIcelandic: CFStringEncoding = 0x0416; +pub const kCFStringEncodingDOSHebrew: CFStringEncoding = 0x0417; +pub const kCFStringEncodingDOSCanadianFrench: CFStringEncoding = 0x0418; +pub const kCFStringEncodingDOSArabic: CFStringEncoding = 0x0419; +pub const kCFStringEncodingDOSNordic: CFStringEncoding = 0x041A; +pub const kCFStringEncodingDOSRussian: CFStringEncoding = 0x041B; +pub const kCFStringEncodingDOSGreek2: CFStringEncoding = 0x041C; +pub const kCFStringEncodingDOSThai: CFStringEncoding = 0x041D; +pub const kCFStringEncodingDOSJapanese: CFStringEncoding = 0x0420; +pub const kCFStringEncodingDOSChineseSimplif: CFStringEncoding = 0x0421; +pub const kCFStringEncodingDOSKorean: CFStringEncoding = 0x0422; +pub const kCFStringEncodingDOSChineseTrad: CFStringEncoding = 0x0423; +pub const kCFStringEncodingWindowsLatin2: CFStringEncoding = 0x0501; +pub const kCFStringEncodingWindowsCyrillic: CFStringEncoding = 0x0502; +pub const kCFStringEncodingWindowsGreek: CFStringEncoding = 0x0503; +pub const kCFStringEncodingWindowsLatin5: CFStringEncoding = 0x0504; +pub const kCFStringEncodingWindowsHebrew: CFStringEncoding = 0x0505; +pub const kCFStringEncodingWindowsArabic: CFStringEncoding = 0x0506; +pub const kCFStringEncodingWindowsBalticRim: CFStringEncoding = 0x0507; +pub const kCFStringEncodingWindowsVietnamese: CFStringEncoding = 0x0508; +pub const kCFStringEncodingWindowsKoreanJohab: CFStringEncoding = 0x0510; +pub const kCFStringEncodingANSEL: CFStringEncoding = 0x0601; +pub const kCFStringEncodingJIS_X0201_76: CFStringEncoding = 0x0620; +pub const kCFStringEncodingJIS_X0208_83: CFStringEncoding = 0x0621; +pub const kCFStringEncodingJIS_X0208_90: CFStringEncoding = 0x0622; +pub const kCFStringEncodingJIS_X0212_90: CFStringEncoding = 0x0623; +pub const kCFStringEncodingJIS_C6226_78: CFStringEncoding = 0x0624; +pub const kCFStringEncodingShiftJIS_X0213: CFStringEncoding = 0x0628; +pub const kCFStringEncodingShiftJIS_X0213_MenKuTen: CFStringEncoding = 0x0629; +pub const kCFStringEncodingGB_2312_80: CFStringEncoding = 0x0630; +pub const kCFStringEncodingGBK_95: CFStringEncoding = 0x0631; +pub const kCFStringEncodingGB_18030_2000: CFStringEncoding = 0x0632; +pub const kCFStringEncodingKSC_5601_87: CFStringEncoding = 0x0640; +pub const kCFStringEncodingKSC_5601_92_Johab: CFStringEncoding = 0x0641; +pub const kCFStringEncodingCNS_11643_92_P1: CFStringEncoding = 0x0651; +pub const kCFStringEncodingCNS_11643_92_P2: CFStringEncoding = 0x0652; +pub const kCFStringEncodingCNS_11643_92_P3: CFStringEncoding = 0x0653; +pub const kCFStringEncodingISO_2022_JP: CFStringEncoding = 0x0820; +pub const kCFStringEncodingISO_2022_JP_2: CFStringEncoding = 0x0821; +pub const kCFStringEncodingISO_2022_JP_1: CFStringEncoding = 0x0822; +pub const kCFStringEncodingISO_2022_JP_3: CFStringEncoding = 0x0823; +pub const kCFStringEncodingISO_2022_CN: CFStringEncoding = 0x0830; +pub const kCFStringEncodingISO_2022_CN_EXT: CFStringEncoding = 0x0831; +pub const kCFStringEncodingISO_2022_KR: CFStringEncoding = 0x0840; +pub const kCFStringEncodingEUC_JP: CFStringEncoding = 0x0920; +pub const kCFStringEncodingEUC_CN: CFStringEncoding = 0x0930; +pub const kCFStringEncodingEUC_TW: CFStringEncoding = 0x0931; +pub const kCFStringEncodingEUC_KR: CFStringEncoding = 0x0940; +pub const kCFStringEncodingShiftJIS: CFStringEncoding = 0x0A01; +pub const kCFStringEncodingKOI8_R: CFStringEncoding = 0x0A02; +pub const kCFStringEncodingBig5: CFStringEncoding = 0x0A03; +pub const kCFStringEncodingMacRomanLatin1: CFStringEncoding = 0x0A04; +pub const kCFStringEncodingHZ_GB_2312: CFStringEncoding = 0x0A05; +pub const kCFStringEncodingBig5_HKSCS_1999: CFStringEncoding = 0x0A06; +pub const kCFStringEncodingVISCII: CFStringEncoding = 0x0A07; +pub const kCFStringEncodingKOI8_U: CFStringEncoding = 0x0A08; +pub const kCFStringEncodingBig5_E: CFStringEncoding = 0x0A09; +pub const kCFStringEncodingNextStepJapanese: CFStringEncoding = 0x0B02; +pub const kCFStringEncodingEBCDIC_US: CFStringEncoding = 0x0C01; +pub const kCFStringEncodingEBCDIC_CP037: CFStringEncoding = 0x0C02; +pub const kCFStringEncodingUTF7: CFStringEncoding = 0x04000100; +pub const kCFStringEncodingUTF7_IMAP: CFStringEncoding = 0x0A10; +pub const kCFStringEncodingShiftJIS_X0213_00: CFStringEncoding = 0x0628; /* Deprecated */ -pub type CFStringEncodings = CFIndex; +pub const kCFStringEncodingInvalidId: u32 = 0xffffffff; -// External encodings, except those defined above. -// Defined above: kCFStringEncodingMacRoman = 0 -//static kCFStringEncodingMacJapanese: CFStringEncoding = 1; -//static kCFStringEncodingMacChineseTrad: CFStringEncoding = 2; -//static kCFStringEncodingMacKorean: CFStringEncoding = 3; -//static kCFStringEncodingMacArabic: CFStringEncoding = 4; -//static kCFStringEncodingMacHebrew: CFStringEncoding = 5; -//static kCFStringEncodingMacGreek: CFStringEncoding = 6; -//static kCFStringEncodingMacCyrillic: CFStringEncoding = 7; -//static kCFStringEncodingMacDevanagari: CFStringEncoding = 9; -//static kCFStringEncodingMacGurmukhi: CFStringEncoding = 10; -//static kCFStringEncodingMacGujarati: CFStringEncoding = 11; -//static kCFStringEncodingMacOriya: CFStringEncoding = 12; -//static kCFStringEncodingMacBengali: CFStringEncoding = 13; -//static kCFStringEncodingMacTamil: CFStringEncoding = 14; -//static kCFStringEncodingMacTelugu: CFStringEncoding = 15; -//static kCFStringEncodingMacKannada: CFStringEncoding = 16; -//static kCFStringEncodingMacMalayalam: CFStringEncoding = 17; -//static kCFStringEncodingMacSinhalese: CFStringEncoding = 18; -//static kCFStringEncodingMacBurmese: CFStringEncoding = 19; -//static kCFStringEncodingMacKhmer: CFStringEncoding = 20; -//static kCFStringEncodingMacThai: CFStringEncoding = 21; -//static kCFStringEncodingMacLaotian: CFStringEncoding = 22; -//static kCFStringEncodingMacGeorgian: CFStringEncoding = 23; -//static kCFStringEncodingMacArmenian: CFStringEncoding = 24; -//static kCFStringEncodingMacChineseSimp: CFStringEncoding = 25; -//static kCFStringEncodingMacTibetan: CFStringEncoding = 26; -//static kCFStringEncodingMacMongolian: CFStringEncoding = 27; -//static kCFStringEncodingMacEthiopic: CFStringEncoding = 28; -//static kCFStringEncodingMacCentralEurRoman: CFStringEncoding = 29; -//static kCFStringEncodingMacVietnamese: CFStringEncoding = 30; -//static kCFStringEncodingMacExtArabic: CFStringEncoding = 31; -//static kCFStringEncodingMacSymbol: CFStringEncoding = 33; -//static kCFStringEncodingMacDingbats: CFStringEncoding = 34; -//static kCFStringEncodingMacTurkish: CFStringEncoding = 35; -//static kCFStringEncodingMacCroatian: CFStringEncoding = 36; -//static kCFStringEncodingMacIcelandic: CFStringEncoding = 37; -//static kCFStringEncodingMacRomanian: CFStringEncoding = 38; -//static kCFStringEncodingMacCeltic: CFStringEncoding = 39; -//static kCFStringEncodingMacGaelic: CFStringEncoding = 40; -//static kCFStringEncodingMacFarsi: CFStringEncoding = 0x8C; -//static kCFStringEncodingMacUkrainian: CFStringEncoding = 0x98; -//static kCFStringEncodingMacInuit: CFStringEncoding = 0xEC; -//static kCFStringEncodingMacVT100: CFStringEncoding = 0xFC; -//static kCFStringEncodingMacHFS: CFStringEncoding = 0xFF; -// Defined above: kCFStringEncodingISOLatin1 = 0x0201 -//static kCFStringEncodingISOLatin2: CFStringEncoding = 0x0202; -//static kCFStringEncodingISOLatin3: CFStringEncoding = 0x0203; -//static kCFStringEncodingISOLatin4: CFStringEncoding = 0x0204; -//static kCFStringEncodingISOLatinCyrillic: CFStringEncoding = 0x0205; -//static kCFStringEncodingISOLatinArabic: CFStringEncoding = 0x0206; -//static kCFStringEncodingISOLatinGreek: CFStringEncoding = 0x0207; -//static kCFStringEncodingISOLatinHebrew: CFStringEncoding = 0x0208; -//static kCFStringEncodingISOLatin5: CFStringEncoding = 0x0209; -//static kCFStringEncodingISOLatin6: CFStringEncoding = 0x020A; -//static kCFStringEncodingISOLatinThai: CFStringEncoding = 0x020B; -//static kCFStringEncodingISOLatin7: CFStringEncoding = 0x020D; -//static kCFStringEncodingISOLatin8: CFStringEncoding = 0x020E; -//static kCFStringEncodingISOLatin9: CFStringEncoding = 0x020F; -//static kCFStringEncodingISOLatin10: CFStringEncoding = 0x0210; -//static kCFStringEncodingDOSLatinUS: CFStringEncoding = 0x0400; -//static kCFStringEncodingDOSGreek: CFStringEncoding = 0x0405; -//static kCFStringEncodingDOSBalticRim: CFStringEncoding = 0x0406; -//static kCFStringEncodingDOSLatin1: CFStringEncoding = 0x0410; -//static kCFStringEncodingDOSGreek1: CFStringEncoding = 0x0411; -//static kCFStringEncodingDOSLatin2: CFStringEncoding = 0x0412; -//static kCFStringEncodingDOSCyrillic: CFStringEncoding = 0x0413; -//static kCFStringEncodingDOSTurkish: CFStringEncoding = 0x0414; -//static kCFStringEncodingDOSPortuguese: CFStringEncoding = 0x0415; -//static kCFStringEncodingDOSIcelandic: CFStringEncoding = 0x0416; -//static kCFStringEncodingDOSHebrew: CFStringEncoding = 0x0417; -//static kCFStringEncodingDOSCanadianFrench: CFStringEncoding = 0x0418; -//static kCFStringEncodingDOSArabic: CFStringEncoding = 0x0419; -//static kCFStringEncodingDOSNordic: CFStringEncoding = 0x041A; -//static kCFStringEncodingDOSRussian: CFStringEncoding = 0x041B; -//static kCFStringEncodingDOSGreek2: CFStringEncoding = 0x041C; -//static kCFStringEncodingDOSThai: CFStringEncoding = 0x041D; -//static kCFStringEncodingDOSJapanese: CFStringEncoding = 0x0420; -//static kCFStringEncodingDOSChineseSimplif: CFStringEncoding = 0x0421; -//static kCFStringEncodingDOSKorean: CFStringEncoding = 0x0422; -//static kCFStringEncodingDOSChineseTrad: CFStringEncoding = 0x0423; -// Defined above: kCFStringEncodingWindowsLatin1 = 0x0500 -//static kCFStringEncodingWindowsLatin2: CFStringEncoding = 0x0501; -//static kCFStringEncodingWindowsCyrillic: CFStringEncoding = 0x0502; -//static kCFStringEncodingWindowsGreek: CFStringEncoding = 0x0503; -//static kCFStringEncodingWindowsLatin5: CFStringEncoding = 0x0504; -//static kCFStringEncodingWindowsHebrew: CFStringEncoding = 0x0505; -//static kCFStringEncodingWindowsArabic: CFStringEncoding = 0x0506; -//static kCFStringEncodingWindowsBalticRim: CFStringEncoding = 0x0507; -//static kCFStringEncodingWindowsVietnamese: CFStringEncoding = 0x0508; -//static kCFStringEncodingWindowsKoreanJohab: CFStringEncoding = 0x0510; -// Defined above: kCFStringEncodingASCII = 0x0600 -//static kCFStringEncodingANSEL: CFStringEncoding = 0x0601; -//static kCFStringEncodingJIS_X0201_76: CFStringEncoding = 0x0620; -//static kCFStringEncodingJIS_X0208_83: CFStringEncoding = 0x0621; -//static kCFStringEncodingJIS_X0208_90: CFStringEncoding = 0x0622; -//static kCFStringEncodingJIS_X0212_90: CFStringEncoding = 0x0623; -//static kCFStringEncodingJIS_C6226_78: CFStringEncoding = 0x0624; -//static kCFStringEncodingShiftJIS_X0213: CFStringEncoding = 0x0628; -//static kCFStringEncodingShiftJIS_X0213_MenKuTen: CFStringEncoding = 0x0629; -//static kCFStringEncodingGB_2312_80: CFStringEncoding = 0x0630; -//static kCFStringEncodingGBK_95: CFStringEncoding = 0x0631; -//static kCFStringEncodingGB_18030_2000: CFStringEncoding = 0x0632; -//static kCFStringEncodingKSC_5601_87: CFStringEncoding = 0x0640; -//static kCFStringEncodingKSC_5601_92_Johab: CFStringEncoding = 0x0641; -//static kCFStringEncodingCNS_11643_92_P1: CFStringEncoding = 0x0651; -//static kCFStringEncodingCNS_11643_92_P2: CFStringEncoding = 0x0652; -//static kCFStringEncodingCNS_11643_92_P3: CFStringEncoding = 0x0653; -//static kCFStringEncodingISO_2022_JP: CFStringEncoding = 0x0820; -//static kCFStringEncodingISO_2022_JP_2: CFStringEncoding = 0x0821; -//static kCFStringEncodingISO_2022_JP_1: CFStringEncoding = 0x0822; -//static kCFStringEncodingISO_2022_JP_3: CFStringEncoding = 0x0823; -//static kCFStringEncodingISO_2022_CN: CFStringEncoding = 0x0830; -//static kCFStringEncodingISO_2022_CN_EXT: CFStringEncoding = 0x0831; -//static kCFStringEncodingISO_2022_KR: CFStringEncoding = 0x0840; -//static kCFStringEncodingEUC_JP: CFStringEncoding = 0x0920; -//static kCFStringEncodingEUC_CN: CFStringEncoding = 0x0930; -//static kCFStringEncodingEUC_TW: CFStringEncoding = 0x0931; -//static kCFStringEncodingEUC_KR: CFStringEncoding = 0x0940; -//static kCFStringEncodingShiftJIS: CFStringEncoding = 0x0A01; -//static kCFStringEncodingKOI8_R: CFStringEncoding = 0x0A02; -//static kCFStringEncodingBig5: CFStringEncoding = 0x0A03; -//static kCFStringEncodingMacRomanLatin1: CFStringEncoding = 0x0A04; -//static kCFStringEncodingHZ_GB_2312: CFStringEncoding = 0x0A05; -//static kCFStringEncodingBig5_HKSCS_1999: CFStringEncoding = 0x0A06; -//static kCFStringEncodingVISCII: CFStringEncoding = 0x0A07; -//static kCFStringEncodingKOI8_U: CFStringEncoding = 0x0A08; -//static kCFStringEncodingBig5_E: CFStringEncoding = 0x0A09; -// Defined above: kCFStringEncodingNextStepLatin = 0x0B01 -//static kCFStringEncodingNextStepJapanese: CFStringEncoding = 0x0B02; -//static kCFStringEncodingEBCDIC_US: CFStringEncoding = 0x0C01; -//static kCFStringEncodingEBCDIC_CP037: CFStringEncoding = 0x0C02; -//static kCFStringEncodingUTF7: CFStringEncoding = 0x04000100; -//static kCFStringEncodingUTF7_IMAP: CFStringEncoding = 0x0A10; -//static kCFStringEncodingShiftJIS_X0213_00: CFStringEncoding = 0x0628; /* Deprecated */ +pub type CFStringNormalizationForm = CFIndex; +pub const kCFStringNormalizationFormD: CFStringNormalizationForm = 0; +pub const kCFStringNormalizationFormKD: CFStringNormalizationForm = 1; +pub const kCFStringNormalizationFormC: CFStringNormalizationForm = 2; +pub const kCFStringNormalizationFormKC: CFStringNormalizationForm = 3; #[repr(C)] pub struct __CFString(c_void); pub type CFStringRef = *const __CFString; +pub type CFMutableStringRef = *mut __CFString; + +/* todo: The source code of the following functions is right in CFString.h */ +/* +pub fn CFStringGetLongCharacterForSurrogatePair(surrogateHigh: UniChar, surrogateLow: UniChar) -> UTF32Char; +pub fn CFStringGetSurrogatePairForLongCharacter(character: UTF32Char, surrogates: *mut UniChar) -> Boolean; +pub fn CFStringIsSurrogateHighCharacter(character: UniChar) -> Boolean; +pub fn CFStringIsSurrogateLowCharacter(character: UniChar) -> Boolean; +pub fn CFStringInitInlineBuffer(str: CFStringRef, buf: *mut CFStringInlineBuffer, range: CFRange); +pub fn CFStringGetCharacterFromInlineBuffer(buf: *mut CFStringInlineBuffer, idx: CFIndex) -> UniChar; +*/ -extern { +extern "C" { /* * CFString.h */ // N.B. organized according to "Functions by task" in docs + /* CFString */ /* Creating a CFString */ //fn CFSTR - //fn CFStringCreateArrayBySeparatingStrings - //fn CFStringCreateByCombiningStrings - //fn CFStringCreateCopy - //fn CFStringCreateFromExternalRepresentation - pub fn CFStringCreateWithBytes(alloc: CFAllocatorRef, - bytes: *const u8, - numBytes: CFIndex, - encoding: CFStringEncoding, - isExternalRepresentation: Boolean) - -> CFStringRef; - pub fn CFStringCreateWithBytesNoCopy(alloc: CFAllocatorRef, - bytes: *const u8, - numBytes: CFIndex, - encoding: CFStringEncoding, - isExternalRepresentation: Boolean, - contentsDeallocator: CFAllocatorRef) - -> CFStringRef; - //fn CFStringCreateWithCharacters - pub fn CFStringCreateWithCharactersNoCopy(alloc: CFAllocatorRef, - chars: *const UniChar, - numChars: CFIndex, - contentsDeallocator: CFAllocatorRef) - -> CFStringRef; - pub fn CFStringCreateWithCString(alloc: CFAllocatorRef, - cStr: *const c_char, - encoding: CFStringEncoding) - -> CFStringRef; - //fn CFStringCreateWithCStringNoCopy - //fn CFStringCreateWithFormat - //fn CFStringCreateWithFormatAndArguments - //fn CFStringCreateWithPascalString - //fn CFStringCreateWithPascalStringNoCopy - //fn CFStringCreateWithSubstring + pub fn CFStringCreateArrayBySeparatingStrings( + alloc: CFAllocatorRef, + theString: CFStringRef, + separatorString: CFStringRef, + ) -> CFArrayRef; + pub fn CFStringCreateByCombiningStrings( + alloc: CFAllocatorRef, + theArray: CFArrayRef, + separatorString: CFStringRef, + ) -> CFStringRef; + pub fn CFStringCreateCopy(alloc: CFAllocatorRef, theString: CFStringRef) -> CFStringRef; + pub fn CFStringCreateFromExternalRepresentation( + alloc: CFAllocatorRef, + data: CFDataRef, + encoding: CFStringEncoding, + ) -> CFStringRef; + pub fn CFStringCreateWithBytes( + alloc: CFAllocatorRef, + bytes: *const UInt8, + numBytes: CFIndex, + encoding: CFStringEncoding, + isExternalRepresentation: Boolean, + ) -> CFStringRef; + pub fn CFStringCreateWithBytesNoCopy( + alloc: CFAllocatorRef, + bytes: *const UInt8, + numBytes: CFIndex, + encoding: CFStringEncoding, + isExternalRepresentation: Boolean, + contentsDeallocator: CFAllocatorRef, + ) -> CFStringRef; + pub fn CFStringCreateWithCharacters( + alloc: CFAllocatorRef, + chars: *const UniChar, + numChars: CFIndex, + ) -> CFStringRef; + pub fn CFStringCreateWithCharactersNoCopy( + alloc: CFAllocatorRef, + chars: *const UniChar, + numChars: CFIndex, + contentsDeallocator: CFAllocatorRef, + ) -> CFStringRef; + pub fn CFStringCreateWithCString( + alloc: CFAllocatorRef, + cStr: *const c_char, + encoding: CFStringEncoding, + ) -> CFStringRef; + pub fn CFStringCreateWithCStringNoCopy( + alloc: CFAllocatorRef, + cStr: *const c_char, + encoding: CFStringEncoding, + contentsDeallocator: CFAllocatorRef, + ) -> CFStringRef; + pub fn CFStringCreateWithFormat( + alloc: CFAllocatorRef, + formatOptions: CFDictionaryRef, + format: CFStringRef, + ... + ) -> CFStringRef; + //pub fn CFStringCreateWithFormatAndArguments(alloc: CFAllocatorRef, formatOptions: CFDictionaryRef, format: CFStringRef, arguments: va_list) -> CFStringRef; + pub fn CFStringCreateWithPascalString( + alloc: CFAllocatorRef, + pStr: ConstStr255Param, + encoding: CFStringEncoding, + ) -> CFStringRef; + pub fn CFStringCreateWithPascalStringNoCopy( + alloc: CFAllocatorRef, + pStr: ConstStr255Param, + encoding: CFStringEncoding, + contentsDeallocator: CFAllocatorRef, + ) -> CFStringRef; + pub fn CFStringCreateWithSubstring( + alloc: CFAllocatorRef, + str: CFStringRef, + range: CFRange, + ) -> CFStringRef; /* Searching Strings */ - //fn CFStringCreateArrayWithFindResults - //fn CFStringFind - //fn CFStringFindCharacterFromSet - //fn CFStringFindWithOptions - //fn CFStringFindWithOptionsAndLocale - //fn CFStringGetLineBounds + pub fn CFStringCreateArrayWithFindResults( + alloc: CFAllocatorRef, + theString: CFStringRef, + stringToFind: CFStringRef, + rangeToSearch: CFRange, + compareOptions: CFStringCompareFlags, + ) -> CFArrayRef; + pub fn CFStringFind( + theString: CFStringRef, + stringToFind: CFStringRef, + compareOptions: CFStringCompareFlags, + ) -> CFRange; + pub fn CFStringFindCharacterFromSet( + theString: CFStringRef, + theSet: CFCharacterSetRef, + rangeToSearch: CFRange, + searchOptions: CFStringCompareFlags, + result: *mut CFRange, + ) -> Boolean; + pub fn CFStringFindWithOptions( + theString: CFStringRef, + stringToFind: CFStringRef, + rangeToSearch: CFRange, + searchOptions: CFStringCompareFlags, + result: *mut CFRange, + ) -> Boolean; + pub fn CFStringFindWithOptionsAndLocale( + theString: CFStringRef, + stringToFind: CFStringRef, + rangeToSearch: CFRange, + searchOptions: CFStringCompareFlags, + locale: CFLocaleRef, + result: *mut CFRange, + ) -> Boolean; + pub fn CFStringGetLineBounds( + theString: CFStringRef, + range: CFRange, + lineBeginIndex: *mut CFIndex, + lineEndIndex: *mut CFIndex, + contentsEndIndex: *mut CFIndex, + ); /* Comparing Strings */ - //fn CFStringCompare - //fn CFStringCompareWithOptions - //fn CFStringCompareWithOptionsAndLocale - //fn CFStringHasPrefix - //fn CFStringHasSuffix + pub fn CFStringCompare( + theString1: CFStringRef, + theString2: CFStringRef, + compareOptions: CFStringCompareFlags, + ) -> CFComparisonResult; + pub fn CFStringCompareWithOptions( + theString1: CFStringRef, + theString2: CFStringRef, + rangeToCompare: CFRange, + compareOptions: CFStringCompareFlags, + ) -> CFComparisonResult; + pub fn CFStringCompareWithOptionsAndLocale( + theString1: CFStringRef, + theString2: CFStringRef, + rangeToCompare: CFRange, + compareOptions: CFStringCompareFlags, + locale: CFLocaleRef, + ) -> CFComparisonResult; + pub fn CFStringHasPrefix(theString: CFStringRef, prefix: CFStringRef) -> Boolean; + pub fn CFStringHasSuffix(theString: CFStringRef, suffix: CFStringRef) -> Boolean; /* Accessing Characters */ - //fn CFStringCreateExternalRepresentation - pub fn CFStringGetBytes(theString: CFStringRef, - range: CFRange, - encoding: CFStringEncoding, - lossByte: u8, - isExternalRepresentation: Boolean, - buffer: *mut u8, - maxBufLen: CFIndex, - usedBufLen: *mut CFIndex) - -> CFIndex; - //fn CFStringGetCharacterAtIndex - //fn CFStringGetCharacters - //fn CFStringGetCharactersPtr - //fn CFStringGetCharacterFromInlineBuffer - pub fn CFStringGetCString(theString: CFStringRef, - buffer: *mut c_char, - bufferSize: CFIndex, - encoding: CFStringEncoding) - -> Boolean; - pub fn CFStringGetCStringPtr(theString: CFStringRef, - encoding: CFStringEncoding) - -> *const c_char; + pub fn CFStringCreateExternalRepresentation( + alloc: CFAllocatorRef, + theString: CFStringRef, + encoding: CFStringEncoding, + lossByte: UInt8, + ) -> CFDataRef; + pub fn CFStringGetBytes( + theString: CFStringRef, + range: CFRange, + encoding: CFStringEncoding, + lossByte: UInt8, + isExternalRepresentation: Boolean, + buffer: *mut UInt8, + maxBufLen: CFIndex, + usedBufLen: *mut CFIndex, + ) -> CFIndex; + pub fn CFStringGetCharacterAtIndex(theString: CFStringRef, idx: CFIndex) -> UniChar; + pub fn CFStringGetCharacters(theString: CFStringRef, range: CFRange, buffer: *mut UniChar); + pub fn CFStringGetCharactersPtr(theString: CFStringRef) -> *const UniChar; + pub fn CFStringGetCString( + theString: CFStringRef, + buffer: *mut c_char, + bufferSize: CFIndex, + encoding: CFStringEncoding, + ) -> Boolean; + pub fn CFStringGetCStringPtr( + theString: CFStringRef, + encoding: CFStringEncoding, + ) -> *const c_char; pub fn CFStringGetLength(theString: CFStringRef) -> CFIndex; - //fn CFStringGetPascalString - //fn CFStringGetPascalStringPtr - //fn CFStringGetRangeOfComposedCharactersAtIndex - //fn CFStringInitInlineBuffer + pub fn CFStringGetPascalString( + theString: CFStringRef, + buffer: StringPtr, + bufferSize: CFIndex, + encoding: CFStringEncoding, + ) -> Boolean; + pub fn CFStringGetPascalStringPtr( + theString: CFStringRef, + encoding: CFStringEncoding, + ) -> ConstStringPtr; + pub fn CFStringGetRangeOfComposedCharactersAtIndex( + theString: CFStringRef, + theIndex: CFIndex, + ) -> CFRange; /* Working With Hyphenation */ - //fn CFStringGetHyphenationLocationBeforeIndex - //fn CFStringIsHyphenationAvailableForLocale + pub fn CFStringGetHyphenationLocationBeforeIndex( + string: CFStringRef, + location: CFIndex, + limitRange: CFRange, + options: CFOptionFlags, + locale: CFLocaleRef, + character: *mut UTF32Char, + ) -> CFIndex; + pub fn CFStringIsHyphenationAvailableForLocale(locale: CFLocaleRef) -> Boolean; /* Working With Encodings */ - //fn CFStringConvertEncodingToIANACharSetName - //fn CFStringConvertEncodingToNSStringEncoding - //fn CFStringConvertEncodingToWindowsCodepage - //fn CFStringConvertIANACharSetNameToEncoding - //fn CFStringConvertNSStringEncodingToEncoding - //fn CFStringConvertWindowsCodepageToEncoding - //fn CFStringGetFastestEncoding - //fn CFStringGetListOfAvailableEncodings - //fn CFStringGetMaximumSizeForEncoding - //fn CFStringGetMostCompatibleMacStringEncoding - //fn CFStringGetNameOfEncoding - //fn CFStringGetSmallestEncoding - //fn CFStringGetSystemEncoding - //fn CFStringIsEncodingAvailable + pub fn CFStringConvertEncodingToIANACharSetName(encoding: CFStringEncoding) -> CFStringRef; + pub fn CFStringConvertEncodingToNSStringEncoding(encoding: CFStringEncoding) -> c_ulong; + pub fn CFStringConvertEncodingToWindowsCodepage(encoding: CFStringEncoding) -> UInt32; + pub fn CFStringConvertIANACharSetNameToEncoding(theString: CFStringRef) -> CFStringEncoding; + pub fn CFStringConvertNSStringEncodingToEncoding(encoding: c_ulong) -> CFStringEncoding; + pub fn CFStringConvertWindowsCodepageToEncoding(codepage: UInt32) -> CFStringEncoding; + pub fn CFStringGetFastestEncoding(theString: CFStringRef) -> CFStringEncoding; + pub fn CFStringGetListOfAvailableEncodings() -> *const CFStringEncoding; + pub fn CFStringGetMaximumSizeForEncoding( + length: CFIndex, + encoding: CFStringEncoding, + ) -> CFIndex; + pub fn CFStringGetMostCompatibleMacStringEncoding( + encoding: CFStringEncoding, + ) -> CFStringEncoding; + pub fn CFStringGetNameOfEncoding(encoding: CFStringEncoding) -> CFStringRef; + pub fn CFStringGetSmallestEncoding(theString: CFStringRef) -> CFStringEncoding; + pub fn CFStringGetSystemEncoding() -> CFStringEncoding; + pub fn CFStringIsEncodingAvailable(encoding: CFStringEncoding) -> Boolean; /* Getting Numeric Values */ - //fn CFStringGetDoubleValue - //fn CFStringGetIntValue + pub fn CFStringGetDoubleValue(str: CFStringRef) -> c_double; + pub fn CFStringGetIntValue(str: CFStringRef) -> SInt32; /* Getting String Properties */ - //fn CFShowStr + pub fn CFShowStr(str: CFStringRef); pub fn CFStringGetTypeID() -> CFTypeID; /* String File System Representations */ - //fn CFStringCreateWithFileSystemRepresentation - //fn CFStringGetFileSystemRepresentation - //fn CFStringGetMaximumSizeOfFileSystemRepresentation + pub fn CFStringCreateWithFileSystemRepresentation( + alloc: CFAllocatorRef, + buffer: *const c_char, + ) -> CFStringRef; + pub fn CFStringGetFileSystemRepresentation( + string: CFStringRef, + buffer: *mut c_char, + maxBufLen: CFIndex, + ) -> Boolean; + pub fn CFStringGetMaximumSizeOfFileSystemRepresentation(string: CFStringRef) -> CFIndex; /* Getting Paragraph Bounds */ - //fn CFStringGetParagraphBounds + pub fn CFStringGetParagraphBounds( + string: CFStringRef, + range: CFRange, + parBeginIndex: *mut CFIndex, + parEndIndex: *mut CFIndex, + contentsEndIndex: *mut CFIndex, + ); - /* Managing Surrogates */ - //fn CFStringGetLongCharacterForSurrogatePair - //fn CFStringGetSurrogatePairForLongCharacter - //fn CFStringIsSurrogateHighCharacter - //fn CFStringIsSurrogateLowCharacter + /* CFMutableString */ + /* CFMutableString Miscellaneous Functions */ + pub fn CFStringAppend(theString: CFMutableStringRef, appendedString: CFStringRef); + pub fn CFStringAppendCharacters( + theString: CFMutableStringRef, + chars: *const UniChar, + numChars: CFIndex, + ); + pub fn CFStringAppendCString( + theString: CFMutableStringRef, + cStr: *const c_char, + encoding: CFStringEncoding, + ); + pub fn CFStringAppendFormat( + theString: CFMutableStringRef, + formatOptions: CFDictionaryRef, + format: CFStringRef, + ... + ); + //pub fn CFStringAppendFormatAndArguments(theString: CFMutableStringRef, formatOptions: CFDictionaryRef, format: CFStringRef, arguments: va_list); + pub fn CFStringAppendPascalString( + theString: CFMutableStringRef, + pStr: ConstStr255Param, + encoding: CFStringEncoding, + ); + pub fn CFStringCapitalize(theString: CFMutableStringRef, locale: CFLocaleRef); + pub fn CFStringCreateMutable(alloc: CFAllocatorRef, maxLength: CFIndex) -> CFMutableStringRef; + pub fn CFStringCreateMutableCopy( + alloc: CFAllocatorRef, + maxLength: CFIndex, + theString: CFStringRef, + ) -> CFMutableStringRef; + pub fn CFStringCreateMutableWithExternalCharactersNoCopy( + alloc: CFAllocatorRef, + chars: *mut UniChar, + numChars: CFIndex, + capacity: CFIndex, + externalCharactersAllocator: CFAllocatorRef, + ) -> CFMutableStringRef; + pub fn CFStringDelete(theString: CFMutableStringRef, range: CFRange); + pub fn CFStringFindAndReplace( + theString: CFMutableStringRef, + stringToFind: CFStringRef, + replacementString: CFStringRef, + rangeToSearch: CFRange, + compareOptions: CFStringCompareFlags, + ) -> CFIndex; + pub fn CFStringFold( + theString: CFMutableStringRef, + theFlags: CFStringCompareFlags, + theLocale: CFLocaleRef, + ); + pub fn CFStringInsert(str: CFMutableStringRef, idx: CFIndex, insertedStr: CFStringRef); + pub fn CFStringLowercase(theString: CFMutableStringRef, locale: CFLocaleRef); + pub fn CFStringNormalize(theString: CFMutableStringRef, theForm: CFStringNormalizationForm); + pub fn CFStringPad( + theString: CFMutableStringRef, + padString: CFStringRef, + length: CFIndex, + indexIntoPad: CFIndex, + ); + pub fn CFStringReplace(theString: CFMutableStringRef, range: CFRange, replacement: CFStringRef); + pub fn CFStringReplaceAll(theString: CFMutableStringRef, replacement: CFStringRef); + pub fn CFStringSetExternalCharactersNoCopy( + theString: CFMutableStringRef, + chars: *mut UniChar, + length: CFIndex, + capacity: CFIndex, + ); + pub fn CFStringTransform( + string: CFMutableStringRef, + range: *mut CFRange, + transform: CFStringRef, + reverse: Boolean, + ) -> Boolean; + pub fn CFStringTrim(theString: CFMutableStringRef, trimString: CFStringRef); + pub fn CFStringTrimWhitespace(theString: CFMutableStringRef); + pub fn CFStringUppercase(theString: CFMutableStringRef, locale: CFLocaleRef); } diff --git a/vendor/core-foundation-sys/src/string_tokenizer.rs b/vendor/core-foundation-sys/src/string_tokenizer.rs new file mode 100644 index 000000000..b23d6a2d3 --- /dev/null +++ b/vendor/core-foundation-sys/src/string_tokenizer.rs @@ -0,0 +1,91 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::array::CFMutableArrayRef; +use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef}; +use crate::locale::CFLocaleRef; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFStringTokenizer(c_void); +pub type CFStringTokenizerRef = *mut __CFStringTokenizer; + +pub type CFStringTokenizerTokenType = CFOptionFlags; + +pub const kCFStringTokenizerTokenNone: CFStringTokenizerTokenType = 0; +pub const kCFStringTokenizerTokenNormal: CFStringTokenizerTokenType = 1 << 0; +pub const kCFStringTokenizerTokenHasSubTokensMask: CFStringTokenizerTokenType = 1 << 1; +pub const kCFStringTokenizerTokenHasDerivedSubTokensMask: CFStringTokenizerTokenType = 1 << 2; +pub const kCFStringTokenizerTokenHasHasNumbersMask: CFStringTokenizerTokenType = 1 << 3; +pub const kCFStringTokenizerTokenHasNonLettersMask: CFStringTokenizerTokenType = 1 << 4; +pub const kCFStringTokenizerTokenIsCJWordMask: CFStringTokenizerTokenType = 1 << 5; + +/* Tokenization Modifiers */ +pub const kCFStringTokenizerUnitWord: CFOptionFlags = 0; +pub const kCFStringTokenizerUnitSentence: CFOptionFlags = 1; +pub const kCFStringTokenizerUnitParagraph: CFOptionFlags = 2; +pub const kCFStringTokenizerUnitLineBreak: CFOptionFlags = 3; +pub const kCFStringTokenizerUnitWordBoundary: CFOptionFlags = 4; +pub const kCFStringTokenizerAttributeLatinTranscription: CFOptionFlags = 1 << 16; +pub const kCFStringTokenizerAttributeLanguage: CFOptionFlags = 1 << 17; + +extern "C" { + /* + * CFStringTokenizer.h + */ + + /* Creating a Tokenizer */ + pub fn CFStringTokenizerCreate( + alloc: CFAllocatorRef, + string: CFStringRef, + range: CFRange, + options: CFOptionFlags, + locale: CFLocaleRef, + ) -> CFStringTokenizerRef; + + /* Setting the String */ + pub fn CFStringTokenizerSetString( + tokenizer: CFStringTokenizerRef, + string: CFStringRef, + range: CFRange, + ); + + /* Changing the Location */ + pub fn CFStringTokenizerAdvanceToNextToken( + tokenizer: CFStringTokenizerRef, + ) -> CFStringTokenizerTokenType; + pub fn CFStringTokenizerGoToTokenAtIndex( + tokenizer: CFStringTokenizerRef, + index: CFIndex, + ) -> CFStringTokenizerTokenType; + + /* Getting Information About the Current Token */ + pub fn CFStringTokenizerCopyCurrentTokenAttribute( + tokenizer: CFStringTokenizerRef, + attribute: CFOptionFlags, + ) -> CFTypeRef; + pub fn CFStringTokenizerGetCurrentTokenRange(tokenizer: CFStringTokenizerRef) -> CFRange; + pub fn CFStringTokenizerGetCurrentSubTokens( + tokenizer: CFStringTokenizerRef, + ranges: *mut CFRange, + maxRangeLength: CFIndex, + derivedSubTokens: CFMutableArrayRef, + ) -> CFIndex; + + /* Identifying a Language */ + pub fn CFStringTokenizerCopyBestStringLanguage( + string: CFStringRef, + range: CFRange, + ) -> CFStringRef; + + /* Getting the CFStringTokenizer Type ID */ + pub fn CFStringTokenizerGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/timezone.rs b/vendor/core-foundation-sys/src/timezone.rs index 0b279db18..076062a49 100644 --- a/vendor/core-foundation-sys/src/timezone.rs +++ b/vendor/core-foundation-sys/src/timezone.rs @@ -9,21 +9,83 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFTypeID}; -use date::{CFTimeInterval, CFAbsoluteTime}; -use string::CFStringRef; +use crate::array::CFArrayRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID}; +use crate::data::CFDataRef; +use crate::date::{CFAbsoluteTime, CFTimeInterval}; +use crate::dictionary::CFDictionaryRef; +use crate::locale::CFLocaleRef; +use crate::notification_center::CFNotificationName; +use crate::string::CFStringRef; #[repr(C)] pub struct __CFTimeZone(c_void); pub type CFTimeZoneRef = *const __CFTimeZone; +pub type CFTimeZoneNameStyle = CFIndex; -extern { - pub fn CFTimeZoneCopySystem() -> CFTimeZoneRef; +/* Constants to specify styles for time zone names */ +pub const kCFTimeZoneNameStyleStandard: CFTimeZoneNameStyle = 0; +pub const kCFTimeZoneNameStyleShortStandard: CFTimeZoneNameStyle = 1; +pub const kCFTimeZoneNameStyleDaylightSaving: CFTimeZoneNameStyle = 2; +pub const kCFTimeZoneNameStyleShortDaylightSaving: CFTimeZoneNameStyle = 3; +pub const kCFTimeZoneNameStyleGeneric: CFTimeZoneNameStyle = 4; +pub const kCFTimeZoneNameStyleShortGeneric: CFTimeZoneNameStyle = 5; + +extern "C" { + /* + * CFTimeZone.h + */ + + pub static kCFTimeZoneSystemTimeZoneDidChangeNotification: CFNotificationName; + + /* Creating a Time Zone */ + pub fn CFTimeZoneCreate( + allocator: CFAllocatorRef, + name: CFStringRef, + data: CFDataRef, + ) -> CFTimeZoneRef; + pub fn CFTimeZoneCreateWithName( + allocator: CFAllocatorRef, + name: CFStringRef, + tryAbbrev: Boolean, + ) -> CFTimeZoneRef; + pub fn CFTimeZoneCreateWithTimeIntervalFromGMT( + allocator: CFAllocatorRef, + interval: CFTimeInterval, + ) -> CFTimeZoneRef; + + /* System and Default Time Zones and Information */ + pub fn CFTimeZoneCopyAbbreviationDictionary() -> CFDictionaryRef; + pub fn CFTimeZoneCopyAbbreviation(tz: CFTimeZoneRef, at: CFAbsoluteTime) -> CFStringRef; pub fn CFTimeZoneCopyDefault() -> CFTimeZoneRef; - pub fn CFTimeZoneCreateWithTimeIntervalFromGMT(allocator: CFAllocatorRef, interval: CFTimeInterval) -> CFTimeZoneRef; + pub fn CFTimeZoneCopySystem() -> CFTimeZoneRef; + pub fn CFTimeZoneSetDefault(tz: CFTimeZoneRef); + pub fn CFTimeZoneCopyKnownNames() -> CFArrayRef; + pub fn CFTimeZoneResetSystem(); + pub fn CFTimeZoneSetAbbreviationDictionary(dict: CFDictionaryRef); + + /* Getting Information About Time Zones */ + pub fn CFTimeZoneGetName(tz: CFTimeZoneRef) -> CFStringRef; + pub fn CFTimeZoneCopyLocalizedName( + tz: CFTimeZoneRef, + style: CFTimeZoneNameStyle, + locale: CFLocaleRef, + ) -> CFStringRef; pub fn CFTimeZoneGetSecondsFromGMT(tz: CFTimeZoneRef, time: CFAbsoluteTime) -> CFTimeInterval; + pub fn CFTimeZoneGetData(tz: CFTimeZoneRef) -> CFDataRef; + /* Getting Daylight Savings Time Information */ + pub fn CFTimeZoneIsDaylightSavingTime(tz: CFTimeZoneRef, at: CFAbsoluteTime) -> Boolean; + pub fn CFTimeZoneGetDaylightSavingTimeOffset( + tz: CFTimeZoneRef, + at: CFAbsoluteTime, + ) -> CFTimeInterval; + pub fn CFTimeZoneGetNextDaylightSavingTimeTransition( + tz: CFTimeZoneRef, + at: CFAbsoluteTime, + ) -> CFAbsoluteTime; + + /* Getting the CFTimeZone Type ID */ pub fn CFTimeZoneGetTypeID() -> CFTypeID; - pub fn CFTimeZoneGetName(tz: CFTimeZoneRef) -> CFStringRef; } diff --git a/vendor/core-foundation-sys/src/tree.rs b/vendor/core-foundation-sys/src/tree.rs new file mode 100644 index 000000000..da6fdd607 --- /dev/null +++ b/vendor/core-foundation-sys/src/tree.rs @@ -0,0 +1,74 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{CFAllocatorRef, CFComparatorFunction, CFIndex, CFTypeID}; +use crate::string::CFStringRef; + +#[repr(C)] +pub struct __CFTree(c_void); +pub type CFTreeRef = *mut __CFTree; + +pub type CFTreeRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void; +pub type CFTreeReleaseCallBack = extern "C" fn(info: *const c_void); +pub type CFTreeCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef; +pub type CFTreeApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void); + +#[repr(C)] +pub struct CFTreeContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: CFTreeRetainCallBack, + pub release: CFTreeReleaseCallBack, + pub copyDescription: CFTreeCopyDescriptionCallBack, +} + +extern "C" { + /* + * CFTree.h + */ + /* Creating Trees */ + pub fn CFTreeCreate(allocator: CFAllocatorRef, context: *const CFTreeContext) -> CFTreeRef; + + /* Modifying a Tree */ + pub fn CFTreeAppendChild(tree: CFTreeRef, newChild: CFTreeRef); + pub fn CFTreeInsertSibling(tree: CFTreeRef, newSibling: CFTreeRef); + pub fn CFTreeRemoveAllChildren(tree: CFTreeRef); + pub fn CFTreePrependChild(tree: CFTreeRef, newChild: CFTreeRef); + pub fn CFTreeRemove(tree: CFTreeRef); + pub fn CFTreeSetContext(tree: CFTreeRef, context: *const CFTreeContext); + + /* Sorting a Tree */ + pub fn CFTreeSortChildren( + tree: CFTreeRef, + comparator: CFComparatorFunction, + context: *mut c_void, + ); + + /* Examining a Tree */ + pub fn CFTreeFindRoot(tree: CFTreeRef) -> CFTreeRef; + pub fn CFTreeGetChildAtIndex(tree: CFTreeRef, idx: CFIndex) -> CFTreeRef; + pub fn CFTreeGetChildCount(tree: CFTreeRef) -> CFIndex; + pub fn CFTreeGetChildren(tree: CFTreeRef, children: *mut CFTreeRef); + pub fn CFTreeGetContext(tree: CFTreeRef, context: *mut CFTreeContext); + pub fn CFTreeGetFirstChild(tree: CFTreeRef) -> CFTreeRef; + pub fn CFTreeGetNextSibling(tree: CFTreeRef) -> CFTreeRef; + pub fn CFTreeGetParent(tree: CFTreeRef) -> CFTreeRef; + + /* Performing an Operation on Tree Elements */ + pub fn CFTreeApplyFunctionToChildren( + tree: CFTreeRef, + applier: CFTreeApplierFunction, + context: *mut c_void, + ); + + /* Getting the Tree Type ID */ + pub fn CFTreeGetTypeID() -> CFTypeID; +} diff --git a/vendor/core-foundation-sys/src/url.rs b/vendor/core-foundation-sys/src/url.rs index 08e7bcd9f..2274d3608 100644 --- a/vendor/core-foundation-sys/src/url.rs +++ b/vendor/core-foundation-sys/src/url.rs @@ -9,12 +9,14 @@ use std::os::raw::c_void; -use base::{CFOptionFlags, CFIndex, CFAllocatorRef, Boolean, CFTypeID, CFTypeRef, SInt32}; -use data::CFDataRef; -use array::CFArrayRef; -use dictionary::CFDictionaryRef; -use string::{CFStringRef, CFStringEncoding}; -use error::CFErrorRef; +use crate::array::CFArrayRef; +use crate::base::{ + Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef, SInt32, +}; +use crate::data::CFDataRef; +use crate::dictionary::CFDictionaryRef; +use crate::error::CFErrorRef; +use crate::string::{CFStringEncoding, CFStringRef}; #[repr(C)] pub struct __CFURL(c_void); @@ -28,95 +30,330 @@ pub type CFURLBookmarkFileCreationOptions = CFOptionFlags; pub type CFURLPathStyle = CFIndex; /* typedef CF_ENUM(CFIndex, CFURLPathStyle) */ -pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0; -pub const kCFURLHFSPathStyle: CFURLPathStyle = 1; +pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0; +pub const kCFURLHFSPathStyle: CFURLPathStyle = 1; pub const kCFURLWindowsPathStyle: CFURLPathStyle = 2; -pub static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions = - (1u32 << 8) as usize; +/* Bookmark Data Creation Options */ pub static kCFURLBookmarkCreationMinimalBookmarkMask: CFURLBookmarkCreationOptions = (1u32 << 9) as usize; pub static kCFURLBookmarkCreationSuitableForBookmarkFile: CFURLBookmarkCreationOptions = (1u32 << 10) as usize; + +#[cfg(target_os = "macos")] pub static kCFURLBookmarkCreationWithSecurityScope: CFURLBookmarkCreationOptions = (1u32 << 11) as usize; + +#[cfg(target_os = "macos")] pub static kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess: CFURLBookmarkCreationOptions = (1u32 << 12) as usize; -// TODO: there are a lot of missing keys and constants. Add if you are bored or need them. +pub static kCFURLBookmarkCreationWithoutImplicitSecurityScope: CFURLBookmarkCreationOptions = + (1u32 << 29) as usize; + +pub static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions = + (1u32 << 8) as usize; // deprecated + +/* The types of components in a URL. */ +pub type CFURLComponentType = CFIndex; +pub const kCFURLComponentScheme: CFIndex = 1; +pub const kCFURLComponentNetLocation: CFIndex = 2; +pub const kCFURLComponentPath: CFIndex = 3; +pub const kCFURLComponentResourceSpecifier: CFIndex = 4; +pub const kCFURLComponentUser: CFIndex = 5; +pub const kCFURLComponentPassword: CFIndex = 6; +pub const kCFURLComponentUserInfo: CFIndex = 7; +pub const kCFURLComponentHost: CFIndex = 8; +pub const kCFURLComponentPort: CFIndex = 9; +pub const kCFURLComponentParameterString: CFIndex = 10; +pub const kCFURLComponentQuery: CFIndex = 11; +pub const kCFURLComponentFragment: CFIndex = 12; -extern { +/* Bookmark Data Resolution Options */ +pub const kCFURLBookmarkResolutionWithoutUIMask: CFURLBookmarkResolutionOptions = + (1u32 << 8) as usize; +pub const kCFURLBookmarkResolutionWithoutMountingMask: CFURLBookmarkResolutionOptions = + (1u32 << 9) as usize; +#[cfg(target_os = "macos")] +pub const kCFURLBookmarkResolutionWithSecurityScope: CFURLBookmarkResolutionOptions = + (1u32 << 10) as usize; +//pub const kCFURLBookmarkResolutionWithoutImplicitStartAccessing: CFURLBookmarkResolutionOptions = ( 1u32 << 15 ) as usize; // macos(11.2)+ +pub const kCFBookmarkResolutionWithoutUIMask: CFURLBookmarkResolutionOptions = (1u32 << 8) as usize; +pub const kCFBookmarkResolutionWithoutMountingMask: CFURLBookmarkResolutionOptions = + (1u32 << 9) as usize; + +extern "C" { /* * CFURL.h */ /* Common File System Resource Keys */ - pub static kCFURLAttributeModificationDateKey: CFStringRef; - pub static kCFURLContentAccessDateKey: CFStringRef; - pub static kCFURLContentModificationDateKey: CFStringRef; - pub static kCFURLCreationDateKey: CFStringRef; - pub static kCFURLFileResourceIdentifierKey: CFStringRef; - pub static kCFURLFileSecurityKey: CFStringRef; - pub static kCFURLHasHiddenExtensionKey: CFStringRef; - pub static kCFURLIsDirectoryKey: CFStringRef; - pub static kCFURLIsExecutableKey: CFStringRef; - pub static kCFURLIsHiddenKey: CFStringRef; - pub static kCFURLIsPackageKey: CFStringRef; - pub static kCFURLIsReadableKey: CFStringRef; + pub static kCFURLNameKey: CFStringRef; + pub static kCFURLLocalizedNameKey: CFStringRef; pub static kCFURLIsRegularFileKey: CFStringRef; + pub static kCFURLIsDirectoryKey: CFStringRef; pub static kCFURLIsSymbolicLinkKey: CFStringRef; + pub static kCFURLIsVolumeKey: CFStringRef; + pub static kCFURLIsPackageKey: CFStringRef; + pub static kCFURLIsApplicationKey: CFStringRef; + // pub static kCFURLApplicationIsScriptableKey: CFStringRef; //macos(10.11)+ + pub static kCFURLIsSystemImmutableKey: CFStringRef; pub static kCFURLIsUserImmutableKey: CFStringRef; - pub static kCFURLIsVolumeKey: CFStringRef; - pub static kCFURLIsWritableKey: CFStringRef; - pub static kCFURLLabelNumberKey: CFStringRef; + pub static kCFURLIsHiddenKey: CFStringRef; + pub static kCFURLHasHiddenExtensionKey: CFStringRef; + pub static kCFURLCreationDateKey: CFStringRef; + pub static kCFURLContentAccessDateKey: CFStringRef; + pub static kCFURLContentModificationDateKey: CFStringRef; + pub static kCFURLAttributeModificationDateKey: CFStringRef; + // pub static kCFURLFileIdentifierKey: CFStringRef; //macos(13.3)+ + // pub static kCFURLFileContentIdentifierKey: CFStringRef; //macos(11.0)+ + // pub static kCFURLMayShareFileContentKey: CFStringRef; //macos(11.0)+ + // pub static kCFURLMayHaveExtendedAttributesKey: CFStringRef; //macos(11.0)+ + // pub static kCFURLIsPurgeableKey: CFStringRef; //macos(11.0)+ + // pub static kCFURLIsSparseKey: CFStringRef; //macos(11.0)+ + pub static kCFURLLinkCountKey: CFStringRef; - pub static kCFURLLocalizedLabelKey: CFStringRef; - pub static kCFURLLocalizedNameKey: CFStringRef; - pub static kCFURLLocalizedTypeDescriptionKey: CFStringRef; - pub static kCFURLNameKey: CFStringRef; pub static kCFURLParentDirectoryURLKey: CFStringRef; - pub static kCFURLPreferredIOBlockSizeKey: CFStringRef; - pub static kCFURLTypeIdentifierKey: CFStringRef; - pub static kCFURLVolumeIdentifierKey: CFStringRef; pub static kCFURLVolumeURLKey: CFStringRef; - #[cfg(feature="mac_os_10_8_features")] + pub static kCFURLTypeIdentifierKey: CFStringRef; //deprecated + + pub static kCFURLLocalizedTypeDescriptionKey: CFStringRef; + pub static kCFURLLabelNumberKey: CFStringRef; + pub static kCFURLLabelColorKey: CFStringRef; //deprecated + pub static kCFURLLocalizedLabelKey: CFStringRef; + pub static kCFURLEffectiveIconKey: CFStringRef; //deprecated + pub static kCFURLCustomIconKey: CFStringRef; //deprecated + + pub static kCFURLFileResourceIdentifierKey: CFStringRef; + pub static kCFURLVolumeIdentifierKey: CFStringRef; + pub static kCFURLPreferredIOBlockSizeKey: CFStringRef; + pub static kCFURLIsReadableKey: CFStringRef; + pub static kCFURLIsWritableKey: CFStringRef; + pub static kCFURLIsExecutableKey: CFStringRef; + pub static kCFURLFileSecurityKey: CFStringRef; + + #[cfg(feature = "mac_os_10_8_features")] #[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")] pub static kCFURLIsExcludedFromBackupKey: CFStringRef; + // pub static kCFURLTagNamesKey: CFStringRef; //macos(10.9)+ + #[cfg(feature = "mac_os_10_8_features")] + #[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")] + pub static kCFURLPathKey: CFStringRef; // macos(10.8)+ + pub static kCFURLCanonicalPathKey: CFStringRef; // macos(10.12)+ + + pub static kCFURLIsMountTriggerKey: CFStringRef; + + // pub static kCFURLGenerationIdentifierKey: CFStringRef; // macos(10.10)+ + // pub static kCFURLDocumentIdentifierKey: CFStringRef; // macos(10.10)+ + // pub static kCFURLAddedToDirectoryDateKey: CFStringRef; // macos(10.10)+ + // pub static kCFURLQuarantinePropertiesKey: CFStringRef; // macos(10.10)+ + pub static kCFURLFileResourceTypeKey: CFStringRef; + /* File Resource Types. The file system object type values returned for the kCFURLFileResourceTypeKey */ + pub static kCFURLFileResourceTypeNamedPipe: CFStringRef; + pub static kCFURLFileResourceTypeCharacterSpecial: CFStringRef; + pub static kCFURLFileResourceTypeDirectory: CFStringRef; + pub static kCFURLFileResourceTypeBlockSpecial: CFStringRef; + pub static kCFURLFileResourceTypeRegular: CFStringRef; + pub static kCFURLFileResourceTypeSymbolicLink: CFStringRef; + pub static kCFURLFileResourceTypeSocket: CFStringRef; + pub static kCFURLFileResourceTypeUnknown: CFStringRef; + + /* File Property Keys */ + pub static kCFURLFileSizeKey: CFStringRef; + pub static kCFURLFileAllocatedSizeKey: CFStringRef; + pub static kCFURLTotalFileSizeKey: CFStringRef; + pub static kCFURLTotalFileAllocatedSizeKey: CFStringRef; + pub static kCFURLIsAliasFileKey: CFStringRef; + + // pub static kCFURLFileProtectionKey: CFStringRef; // ios(9.0)+ + + /* The protection level values returned for the kCFURLFileProtectionKey */ + // pub static kCFURLFileProtectionNone: CFStringRef; // ios(9.0)+ + // pub static kCFURLFileProtectionComplete: CFStringRef; // ios(9.0)+ + // pub static kCFURLFileProtectionCompleteUnlessOpen: CFStringRef; // ios(9.0)+ + // pub static kCFURLFileProtectionCompleteUntilFirstUserAuthentication: CFStringRef; // ios(9.0)+ + + /* Volume Property Keys */ + pub static kCFURLVolumeLocalizedFormatDescriptionKey: CFStringRef; + pub static kCFURLVolumeTotalCapacityKey: CFStringRef; + pub static kCFURLVolumeAvailableCapacityKey: CFStringRef; + //pub static kCFURLVolumeAvailableCapacityForImportantUsageKey: CFStringRef; //macos(10.13)+ + //pub static kCFURLVolumeAvailableCapacityForOpportunisticUsageKey: CFStringRef; //macos(10.13)+ + + pub static kCFURLVolumeResourceCountKey: CFStringRef; + pub static kCFURLVolumeSupportsPersistentIDsKey: CFStringRef; + pub static kCFURLVolumeSupportsSymbolicLinksKey: CFStringRef; + pub static kCFURLVolumeSupportsHardLinksKey: CFStringRef; + pub static kCFURLVolumeSupportsJournalingKey: CFStringRef; + pub static kCFURLVolumeIsJournalingKey: CFStringRef; + pub static kCFURLVolumeSupportsSparseFilesKey: CFStringRef; + pub static kCFURLVolumeSupportsZeroRunsKey: CFStringRef; + pub static kCFURLVolumeSupportsCaseSensitiveNamesKey: CFStringRef; + pub static kCFURLVolumeSupportsCasePreservedNamesKey: CFStringRef; + pub static kCFURLVolumeSupportsRootDirectoryDatesKey: CFStringRef; + pub static kCFURLVolumeSupportsVolumeSizesKey: CFStringRef; + pub static kCFURLVolumeSupportsRenamingKey: CFStringRef; + pub static kCFURLVolumeSupportsAdvisoryFileLockingKey: CFStringRef; + pub static kCFURLVolumeSupportsExtendedSecurityKey: CFStringRef; + pub static kCFURLVolumeIsBrowsableKey: CFStringRef; + pub static kCFURLVolumeMaximumFileSizeKey: CFStringRef; + pub static kCFURLVolumeIsEjectableKey: CFStringRef; + pub static kCFURLVolumeIsRemovableKey: CFStringRef; + pub static kCFURLVolumeIsInternalKey: CFStringRef; + pub static kCFURLVolumeIsAutomountedKey: CFStringRef; + pub static kCFURLVolumeIsLocalKey: CFStringRef; + pub static kCFURLVolumeIsReadOnlyKey: CFStringRef; + pub static kCFURLVolumeCreationDateKey: CFStringRef; + pub static kCFURLVolumeURLForRemountingKey: CFStringRef; + pub static kCFURLVolumeUUIDStringKey: CFStringRef; + pub static kCFURLVolumeNameKey: CFStringRef; + pub static kCFURLVolumeLocalizedNameKey: CFStringRef; + // pub static kCFURLVolumeIsEncryptedKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeIsRootFileSystemKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeSupportsCompressionKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeSupportsFileCloningKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeSupportsSwapRenamingKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeSupportsExclusiveRenamingKey: CFStringRef; //macos(10.12)+ + // pub static kCFURLVolumeSupportsImmutableFilesKey: CFStringRef; //macos(10.13)+ + // pub static kCFURLVolumeSupportsAccessPermissionsKey: CFStringRef; //macos(10.13)+ + // pub static kCFURLVolumeSupportsFileProtectionKey: CFStringRef; //macos(11.0)+ + // pub static kCFURLVolumeTypeNameKey: CFStringRef; //macos(13.3)+ + // pub static kCFURLVolumeSubtypeKey: CFStringRef; //macos(13.3)+ + // pub static kCFURLVolumeMountFromLocationKey: CFStringRef; //macos(13.3)+ + + /* iCloud Constants */ + pub static kCFURLIsUbiquitousItemKey: CFStringRef; + pub static kCFURLUbiquitousItemHasUnresolvedConflictsKey: CFStringRef; + pub static kCFURLUbiquitousItemIsDownloadedKey: CFStringRef; // deprecated + pub static kCFURLUbiquitousItemIsDownloadingKey: CFStringRef; + pub static kCFURLUbiquitousItemIsUploadedKey: CFStringRef; + pub static kCFURLUbiquitousItemIsUploadingKey: CFStringRef; + pub static kCFURLUbiquitousItemPercentDownloadedKey: CFStringRef; // deprecated + pub static kCFURLUbiquitousItemPercentUploadedKey: CFStringRef; // deprecated + // pub static kCFURLUbiquitousItemDownloadingStatusKey: CFStringRef; // macos(10.9)+ + // pub static kCFURLUbiquitousItemDownloadingErrorKey: CFStringRef; // macos(10.9)+ + // pub static kCFURLUbiquitousItemUploadingErrorKey: CFStringRef; // macos(10.9)+ + // pub static kCFURLUbiquitousItemIsExcludedFromSyncKey: CFStringRef; // macos(11.3)+ + + /* The values returned for kCFURLUbiquitousItemDownloadingStatusKey */ + // pub static kCFURLUbiquitousItemDownloadingStatusNotDownloaded: CFStringRef; // macos(10.9)+ + // pub static kCFURLUbiquitousItemDownloadingStatusDownloaded: CFStringRef; // macos(10.9)+ + // pub static kCFURLUbiquitousItemDownloadingStatusCurrent: CFStringRef; // macos(10.9)+ + + /* CFError userInfo Dictionary Keys */ + pub static kCFURLKeysOfUnsetValuesKey: CFStringRef; + /* Creating a CFURL */ pub fn CFURLCopyAbsoluteURL(anURL: CFURLRef) -> CFURLRef; - pub fn CFURLCreateAbsoluteURLWithBytes(allocator: CFAllocatorRef, relativeURLBytes: *const u8, length: CFIndex, encoding: CFStringEncoding, baseURL: CFURLRef, useCompatibilityMode: Boolean) -> CFURLRef; - pub fn CFURLCreateByResolvingBookmarkData(allocator: CFAllocatorRef, bookmark: CFDataRef, options: CFURLBookmarkResolutionOptions, relativeToURL: CFURLRef, resourcePropertiesToInclude: CFArrayRef, isStale: *mut Boolean, error: *mut CFErrorRef) -> CFURLRef; - //fn CFURLCreateCopyAppendingPathComponent - //fn CFURLCreateCopyAppendingPathExtension - //fn CFURLCreateCopyDeletingLastPathComponent - //fn CFURLCreateCopyDeletingPathExtension - pub fn CFURLCreateFilePathURL(allocator: CFAllocatorRef, url: CFURLRef, error: *mut CFErrorRef) -> CFURLRef; - //fn CFURLCreateFileReferenceURL - pub fn CFURLCreateFromFileSystemRepresentation(allocator: CFAllocatorRef, buffer: *const u8, bufLen: CFIndex, isDirectory: Boolean) -> CFURLRef; - //fn CFURLCreateFromFileSystemRepresentationRelativeToBase - //fn CFURLCreateFromFSRef - pub fn CFURLCreateWithBytes(allocator: CFAllocatorRef, URLBytes: *const u8, length: CFIndex, encoding: CFStringEncoding, baseURL: CFURLRef) -> CFURLRef; - pub fn CFURLCreateWithFileSystemPath(allocator: CFAllocatorRef, filePath: CFStringRef, pathStyle: CFURLPathStyle, isDirectory: Boolean) -> CFURLRef; - pub fn CFURLCreateWithFileSystemPathRelativeToBase(allocator: CFAllocatorRef, filePath: CFStringRef, pathStyle: CFURLPathStyle, isDirectory: Boolean, baseURL: CFURLRef) -> CFURLRef; - //fn CFURLCreateWithString(allocator: CFAllocatorRef, urlString: CFStringRef, - // baseURL: CFURLRef) -> CFURLRef; + pub fn CFURLCreateAbsoluteURLWithBytes( + allocator: CFAllocatorRef, + relativeURLBytes: *const u8, + length: CFIndex, + encoding: CFStringEncoding, + baseURL: CFURLRef, + useCompatibilityMode: Boolean, + ) -> CFURLRef; + pub fn CFURLCreateByResolvingBookmarkData( + allocator: CFAllocatorRef, + bookmark: CFDataRef, + options: CFURLBookmarkResolutionOptions, + relativeToURL: CFURLRef, + resourcePropertiesToInclude: CFArrayRef, + isStale: *mut Boolean, + error: *mut CFErrorRef, + ) -> CFURLRef; + pub fn CFURLCreateCopyAppendingPathComponent( + allocator: CFAllocatorRef, + url: CFURLRef, + pathComponent: CFStringRef, + isDirectory: Boolean, + ) -> CFURLRef; + pub fn CFURLCreateCopyAppendingPathExtension( + allocator: CFAllocatorRef, + url: CFURLRef, + extension: CFStringRef, + ) -> CFURLRef; + pub fn CFURLCreateCopyDeletingLastPathComponent( + allocator: CFAllocatorRef, + url: CFURLRef, + ) -> CFURLRef; + pub fn CFURLCreateCopyDeletingPathExtension( + allocator: CFAllocatorRef, + url: CFURLRef, + ) -> CFURLRef; + pub fn CFURLCreateFilePathURL( + allocator: CFAllocatorRef, + url: CFURLRef, + error: *mut CFErrorRef, + ) -> CFURLRef; + pub fn CFURLCreateFileReferenceURL( + allocator: CFAllocatorRef, + url: CFURLRef, + error: *mut CFErrorRef, + ) -> CFURLRef; + pub fn CFURLCreateFromFileSystemRepresentation( + allocator: CFAllocatorRef, + buffer: *const u8, + bufLen: CFIndex, + isDirectory: Boolean, + ) -> CFURLRef; + pub fn CFURLCreateFromFileSystemRepresentationRelativeToBase( + allocator: CFAllocatorRef, + buffer: *const u8, + bufLen: CFIndex, + isDirectory: Boolean, + baseURL: CFURLRef, + ) -> CFURLRef; + //pub fn CFURLCreateFromFSRef(allocator: CFAllocatorRef, fsRef: *const FSRef) -> CFURLRef + pub fn CFURLCreateWithBytes( + allocator: CFAllocatorRef, + URLBytes: *const u8, + length: CFIndex, + encoding: CFStringEncoding, + baseURL: CFURLRef, + ) -> CFURLRef; + pub fn CFURLCreateWithFileSystemPath( + allocator: CFAllocatorRef, + filePath: CFStringRef, + pathStyle: CFURLPathStyle, + isDirectory: Boolean, + ) -> CFURLRef; + pub fn CFURLCreateWithFileSystemPathRelativeToBase( + allocator: CFAllocatorRef, + filePath: CFStringRef, + pathStyle: CFURLPathStyle, + isDirectory: Boolean, + baseURL: CFURLRef, + ) -> CFURLRef; + pub fn CFURLCreateWithString( + allocator: CFAllocatorRef, + URLString: CFStringRef, + baseURL: CFURLRef, + ) -> CFURLRef; /* Accessing the Parts of a URL */ pub fn CFURLCanBeDecomposed(anURL: CFURLRef) -> Boolean; pub fn CFURLCopyFileSystemPath(anURL: CFURLRef, pathStyle: CFURLPathStyle) -> CFStringRef; - pub fn CFURLCopyFragment(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyFragment(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) + -> CFStringRef; pub fn CFURLCopyHostName(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyLastPathComponent(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyNetLocation(anURL: CFURLRef) -> CFStringRef; - pub fn CFURLCopyParameterString(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyParameterString( + anURL: CFURLRef, + charactersToLeaveEscaped: CFStringRef, + ) -> CFStringRef; // deprecated pub fn CFURLCopyPassword(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyPath(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyPathExtension(anURL: CFURLRef) -> CFStringRef; - pub fn CFURLCopyQueryString(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef) -> CFStringRef; + pub fn CFURLCopyQueryString( + anURL: CFURLRef, + charactersToLeaveEscaped: CFStringRef, + ) -> CFStringRef; pub fn CFURLCopyResourceSpecifier(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyScheme(anURL: CFURLRef) -> CFStringRef; pub fn CFURLCopyStrictPath(anURL: CFURLRef, isAbsolute: *mut Boolean) -> CFStringRef; @@ -125,45 +362,120 @@ extern { pub fn CFURLHasDirectoryPath(anURL: CFURLRef) -> Boolean; /* Converting URLs to Other Representations */ - //fn CFURLCreateData(allocator: CFAllocatorRef, url: CFURLRef, - // encoding: CFStringEncoding, escapeWhitespace: bool) -> CFDataRef; - //fn CFURLCreateStringByAddingPercentEscapes - //fn CFURLCreateStringByReplacingPercentEscapes - //fn CFURLCreateStringByReplacingPercentEscapesUsingEncoding - pub fn CFURLGetFileSystemRepresentation(anURL: CFURLRef, resolveAgainstBase: Boolean, buffer: *mut u8, maxBufLen: CFIndex) -> Boolean; - - //fn CFURLGetFSRef + pub fn CFURLCreateData( + allocator: CFAllocatorRef, + url: CFURLRef, + encoding: CFStringEncoding, + escapeWhitespace: Boolean, + ) -> CFDataRef; + pub fn CFURLCreateStringByAddingPercentEscapes( + allocator: CFAllocatorRef, + originalString: CFStringRef, + charactersToLeaveUnescaped: CFStringRef, + legalURLCharactersToBeEscaped: CFStringRef, + encoding: CFStringEncoding, + ) -> CFStringRef; // API_DEPRECATED("Use [NSString stringByAddingPercentEncodingWithAllowedCharacters:] instead, which always uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent (since each URL component or subcomponent has different rules for what characters are valid).", macos(10.0,10.11), ios(2.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0)); + pub fn CFURLCreateStringByReplacingPercentEscapes( + allocator: CFAllocatorRef, + originalString: CFStringRef, + charactersToLeaveEscaped: CFStringRef, + ) -> CFStringRef; + pub fn CFURLCreateStringByReplacingPercentEscapesUsingEncoding( + allocator: CFAllocatorRef, + origString: CFStringRef, + charsToLeaveEscaped: CFStringRef, + encoding: CFStringEncoding, + ) -> CFStringRef; // deprecated + pub fn CFURLGetFileSystemRepresentation( + anURL: CFURLRef, + resolveAgainstBase: Boolean, + buffer: *mut u8, + maxBufLen: CFIndex, + ) -> Boolean; + //pub fn CFURLIsFileReferenceURL(url: CFURLRef) -> Boolean; // macos(10.9)+ + //pub fn CFURLGetFSRef(url: CFURLRef, fsRef: *mut FSRef) -> Boolean; pub fn CFURLGetString(anURL: CFURLRef) -> CFStringRef; /* Getting URL Properties */ - //fn CFURLGetBaseURL(anURL: CFURLRef) -> CFURLRef; + pub fn CFURLGetBaseURL(anURL: CFURLRef) -> CFURLRef; pub fn CFURLGetBytes(anURL: CFURLRef, buffer: *mut u8, bufferLength: CFIndex) -> CFIndex; - //fn CFURLGetByteRangeForComponent + pub fn CFURLGetByteRangeForComponent( + url: CFURLRef, + component: CFURLComponentType, + rangeIncludingSeparators: *mut CFRange, + ) -> CFRange; pub fn CFURLGetTypeID() -> CFTypeID; - //fn CFURLResourceIsReachable + pub fn CFURLResourceIsReachable(url: CFURLRef, error: *mut CFErrorRef) -> Boolean; /* Getting and Setting File System Resource Properties */ pub fn CFURLClearResourcePropertyCache(url: CFURLRef); - //fn CFURLClearResourcePropertyCacheForKey - //fn CFURLCopyResourcePropertiesForKeys - //fn CFURLCopyResourcePropertyForKey - pub fn CFURLCreateResourcePropertiesForKeysFromBookmarkData(allocator: CFAllocatorRef, resourcePropertiesToReturn: CFArrayRef, bookmark: CFDataRef) -> CFDictionaryRef; - pub fn CFURLCreateResourcePropertyForKeyFromBookmarkData(allocator: CFAllocatorRef, resourcePropertyKey: CFStringRef, bookmark: CFDataRef) -> CFTypeRef; - //fn CFURLSetResourcePropertiesForKeys - pub fn CFURLSetResourcePropertyForKey(url: CFURLRef, key: CFStringRef, value: CFTypeRef, error: *mut CFErrorRef) -> Boolean; - //fn CFURLSetTemporaryResourcePropertyForKey + pub fn CFURLClearResourcePropertyCacheForKey(url: CFURLRef, key: CFStringRef); + pub fn CFURLCopyResourcePropertiesForKeys( + url: CFURLRef, + keys: CFArrayRef, + error: *mut CFErrorRef, + ) -> CFDictionaryRef; + //pub fn CFURLCopyResourcePropertyForKey(url: CFURLRef, key: CFStringRef, propertyValueTypeRefPtr: *mut c_void, error: *mut CFErrorRef) -> Boolean + pub fn CFURLCreateResourcePropertiesForKeysFromBookmarkData( + allocator: CFAllocatorRef, + resourcePropertiesToReturn: CFArrayRef, + bookmark: CFDataRef, + ) -> CFDictionaryRef; + pub fn CFURLCreateResourcePropertyForKeyFromBookmarkData( + allocator: CFAllocatorRef, + resourcePropertyKey: CFStringRef, + bookmark: CFDataRef, + ) -> CFTypeRef; + pub fn CFURLSetResourcePropertiesForKeys( + url: CFURLRef, + keyedPropertyValues: CFDictionaryRef, + error: *mut CFErrorRef, + ) -> Boolean; + pub fn CFURLSetResourcePropertyForKey( + url: CFURLRef, + key: CFStringRef, + value: CFTypeRef, + error: *mut CFErrorRef, + ) -> Boolean; + pub fn CFURLSetTemporaryResourcePropertyForKey( + url: CFURLRef, + key: CFStringRef, + propertyValue: CFTypeRef, + ); /* Working with Bookmark Data */ - pub fn CFURLCreateBookmarkData(allocator: CFAllocatorRef, url: CFURLRef, options: CFURLBookmarkCreationOptions, resourcePropertiesToInclude: CFArrayRef, relativeToURL: CFURLRef, error: *mut CFErrorRef) -> CFDataRef; - pub fn CFURLCreateBookmarkDataFromAliasRecord(allocator: CFAllocatorRef, aliasRecordDataRef: CFDataRef) -> CFDataRef; - pub fn CFURLCreateBookmarkDataFromFile(allocator: CFAllocatorRef, fileURL: CFURLRef, errorRef: *mut CFErrorRef) -> CFDataRef; - pub fn CFURLWriteBookmarkDataToFile(bookmarkRef: CFDataRef, fileURL: CFURLRef, options: CFURLBookmarkFileCreationOptions, errorRef: *mut CFErrorRef) -> Boolean; + pub fn CFURLCreateBookmarkData( + allocator: CFAllocatorRef, + url: CFURLRef, + options: CFURLBookmarkCreationOptions, + resourcePropertiesToInclude: CFArrayRef, + relativeToURL: CFURLRef, + error: *mut CFErrorRef, + ) -> CFDataRef; + + #[cfg(target_os = "macos")] + pub fn CFURLCreateBookmarkDataFromAliasRecord( + allocator: CFAllocatorRef, + aliasRecordDataRef: CFDataRef, + ) -> CFDataRef; // deprecated + + pub fn CFURLCreateBookmarkDataFromFile( + allocator: CFAllocatorRef, + fileURL: CFURLRef, + errorRef: *mut CFErrorRef, + ) -> CFDataRef; + pub fn CFURLWriteBookmarkDataToFile( + bookmarkRef: CFDataRef, + fileURL: CFURLRef, + options: CFURLBookmarkFileCreationOptions, + errorRef: *mut CFErrorRef, + ) -> Boolean; pub fn CFURLStartAccessingSecurityScopedResource(url: CFURLRef) -> Boolean; pub fn CFURLStopAccessingSecurityScopedResource(url: CFURLRef); } #[test] -#[cfg(feature="mac_os_10_8_features")] +#[cfg(feature = "mac_os_10_8_features")] fn can_see_excluded_from_backup_key() { let _ = unsafe { kCFURLIsExcludedFromBackupKey }; } diff --git a/vendor/core-foundation-sys/src/url_enumerator.rs b/vendor/core-foundation-sys/src/url_enumerator.rs new file mode 100644 index 000000000..71b74beb5 --- /dev/null +++ b/vendor/core-foundation-sys/src/url_enumerator.rs @@ -0,0 +1,62 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::array::CFArrayRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID}; +use crate::error::CFErrorRef; +use crate::url::CFURLRef; + +#[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 "C" { + /* + * 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 +} diff --git a/vendor/core-foundation-sys/src/user_notification.rs b/vendor/core-foundation-sys/src/user_notification.rs new file mode 100644 index 000000000..643271826 --- /dev/null +++ b/vendor/core-foundation-sys/src/user_notification.rs @@ -0,0 +1,138 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32}; +use crate::date::CFTimeInterval; +use crate::dictionary::CFDictionaryRef; +use crate::runloop::CFRunLoopSourceRef; +use crate::string::CFStringRef; +use crate::url::CFURLRef; + +#[repr(C)] +pub struct __CFUserNotification(c_void); + +pub type CFUserNotificationCallBack = + extern "C" fn(userNotification: CFUserNotificationRef, responseFlags: CFOptionFlags); +pub type CFUserNotificationRef = *mut __CFUserNotification; + +/* Alert Levels */ +pub const kCFUserNotificationStopAlertLevel: CFOptionFlags = 0; +pub const kCFUserNotificationNoteAlertLevel: CFOptionFlags = 1; +pub const kCFUserNotificationCautionAlertLevel: CFOptionFlags = 2; +pub const kCFUserNotificationPlainAlertLevel: CFOptionFlags = 3; + +/* Response Codes */ +pub const kCFUserNotificationDefaultResponse: CFOptionFlags = 0; +pub const kCFUserNotificationAlternateResponse: CFOptionFlags = 1; +pub const kCFUserNotificationOtherResponse: CFOptionFlags = 2; +pub const kCFUserNotificationCancelResponse: CFOptionFlags = 3; + +/* Button Flags */ +pub const kCFUserNotificationNoDefaultButtonFlag: CFOptionFlags = 1usize << 5; +pub const kCFUserNotificationUseRadioButtonsFlag: CFOptionFlags = 1usize << 6; + +#[inline(always)] +pub fn CFUserNotificationCheckBoxChecked(i: CFIndex) -> CFOptionFlags { + (1u32 << (8 + i)) as CFOptionFlags +} + +#[inline(always)] +pub fn CFUserNotificationSecureTextField(i: CFIndex) -> CFOptionFlags { + (1u32 << (16 + i)) as CFOptionFlags +} + +#[inline(always)] +pub fn CFUserNotificationPopUpSelection(n: CFIndex) -> CFOptionFlags { + (n << 24) as CFOptionFlags +} + +extern "C" { + /* + * CFUserNotification.h + */ + + /* Dialog Description Keys */ + pub static kCFUserNotificationIconURLKey: CFStringRef; + pub static kCFUserNotificationSoundURLKey: CFStringRef; + pub static kCFUserNotificationLocalizationURLKey: CFStringRef; + pub static kCFUserNotificationAlertHeaderKey: CFStringRef; + pub static kCFUserNotificationAlertMessageKey: CFStringRef; + pub static kCFUserNotificationDefaultButtonTitleKey: CFStringRef; + pub static kCFUserNotificationAlternateButtonTitleKey: CFStringRef; + pub static kCFUserNotificationOtherButtonTitleKey: CFStringRef; + pub static kCFUserNotificationProgressIndicatorValueKey: CFStringRef; + pub static kCFUserNotificationPopUpTitlesKey: CFStringRef; + pub static kCFUserNotificationTextFieldTitlesKey: CFStringRef; + pub static kCFUserNotificationCheckBoxTitlesKey: CFStringRef; + pub static kCFUserNotificationTextFieldValuesKey: CFStringRef; + pub static kCFUserNotificationPopUpSelectionKey: CFStringRef; + pub static kCFUserNotificationAlertTopMostKey: CFStringRef; + pub static kCFUserNotificationKeyboardTypesKey: CFStringRef; + + /* CFUserNotification Miscellaneous Functions */ + pub fn CFUserNotificationCancel(userNotification: CFUserNotificationRef) -> SInt32; + pub fn CFUserNotificationCreate( + allocator: CFAllocatorRef, + timeout: CFTimeInterval, + flags: CFOptionFlags, + error: *mut SInt32, + dictionary: CFDictionaryRef, + ) -> CFUserNotificationRef; + pub fn CFUserNotificationCreateRunLoopSource( + allocator: CFAllocatorRef, + userNotification: CFUserNotificationRef, + callout: CFUserNotificationCallBack, + order: CFIndex, + ) -> CFRunLoopSourceRef; + pub fn CFUserNotificationDisplayAlert( + timeout: CFTimeInterval, + flags: CFOptionFlags, + iconURL: CFURLRef, + soundURL: CFURLRef, + localizationURL: CFURLRef, + alertHeader: CFStringRef, + alertMessage: CFStringRef, + defaultButtonTitle: CFStringRef, + alternateButtonTitle: CFStringRef, + otherButtonTitle: CFStringRef, + responseFlags: *mut CFOptionFlags, + ) -> SInt32; + pub fn CFUserNotificationDisplayNotice( + timeout: CFTimeInterval, + flags: CFOptionFlags, + iconURL: CFURLRef, + soundURL: CFURLRef, + localizationURL: CFURLRef, + alertHeader: CFStringRef, + alertMessage: CFStringRef, + defaultButtonTitle: CFStringRef, + ) -> SInt32; + pub fn CFUserNotificationGetTypeID() -> CFTypeID; + pub fn CFUserNotificationGetResponseDictionary( + userNotification: CFUserNotificationRef, + ) -> CFDictionaryRef; + pub fn CFUserNotificationGetResponseValue( + userNotification: CFUserNotificationRef, + key: CFStringRef, + idx: CFIndex, + ) -> CFStringRef; + pub fn CFUserNotificationReceiveResponse( + userNotification: CFUserNotificationRef, + timeout: CFTimeInterval, + responseFlags: *mut CFOptionFlags, + ) -> SInt32; + pub fn CFUserNotificationUpdate( + userNotification: CFUserNotificationRef, + timeout: CFTimeInterval, + flags: CFOptionFlags, + dictionary: CFDictionaryRef, + ) -> SInt32; +} diff --git a/vendor/core-foundation-sys/src/uuid.rs b/vendor/core-foundation-sys/src/uuid.rs index 425395293..a1714a8a8 100644 --- a/vendor/core-foundation-sys/src/uuid.rs +++ b/vendor/core-foundation-sys/src/uuid.rs @@ -9,7 +9,8 @@ use std::os::raw::c_void; -use base::{CFAllocatorRef, CFTypeID}; +use crate::base::{CFAllocatorRef, CFTypeID}; +use crate::string::CFStringRef; #[repr(C)] pub struct __CFUUID(c_void); @@ -17,33 +18,78 @@ pub struct __CFUUID(c_void); pub type CFUUIDRef = *const __CFUUID; #[repr(C)] -#[derive(Clone, Copy, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct CFUUIDBytes { - pub byte0: u8, - pub byte1: u8, - pub byte2: u8, - pub byte3: u8, - pub byte4: u8, - pub byte5: u8, - pub byte6: u8, - pub byte7: u8, - pub byte8: u8, - pub byte9: u8, + pub byte0: u8, + pub byte1: u8, + pub byte2: u8, + pub byte3: u8, + pub byte4: u8, + pub byte5: u8, + pub byte6: u8, + pub byte7: u8, + pub byte8: u8, + pub byte9: u8, pub byte10: u8, pub byte11: u8, pub byte12: u8, pub byte13: u8, pub byte14: u8, - pub byte15: u8 + pub byte15: u8, } -extern { +extern "C" { /* * CFUUID.h */ + + /* Creating CFUUID Objects */ pub fn CFUUIDCreate(allocator: CFAllocatorRef) -> CFUUIDRef; + pub fn CFUUIDCreateFromString(alloc: CFAllocatorRef, uuidStr: CFStringRef) -> CFUUIDRef; pub fn CFUUIDCreateFromUUIDBytes(allocator: CFAllocatorRef, bytes: CFUUIDBytes) -> CFUUIDRef; + pub fn CFUUIDCreateWithBytes( + alloc: CFAllocatorRef, + byte0: u8, + byte1: u8, + byte2: u8, + byte3: u8, + byte4: u8, + byte5: u8, + byte6: u8, + byte7: u8, + byte8: u8, + byte9: u8, + byte10: u8, + byte11: u8, + byte12: u8, + byte13: u8, + byte14: u8, + byte15: u8, + ) -> CFUUIDRef; + + /* Getting Information About CFUUID Objects */ + pub fn CFUUIDCreateString(allocator: CFAllocatorRef, uid: CFUUIDRef) -> CFStringRef; + pub fn CFUUIDGetConstantUUIDWithBytes( + alloc: CFAllocatorRef, + byte0: u8, + byte1: u8, + byte2: u8, + byte3: u8, + byte4: u8, + byte5: u8, + byte6: u8, + byte7: u8, + byte8: u8, + byte9: u8, + byte10: u8, + byte11: u8, + byte12: u8, + byte13: u8, + byte14: u8, + byte15: u8, + ) -> CFUUIDRef; pub fn CFUUIDGetUUIDBytes(uuid: CFUUIDRef) -> CFUUIDBytes; + /* Getting the CFUUID Type Identifier */ pub fn CFUUIDGetTypeID() -> CFTypeID; } diff --git a/vendor/core-foundation-sys/src/xml_node.rs b/vendor/core-foundation-sys/src/xml_node.rs new file mode 100644 index 000000000..332beec82 --- /dev/null +++ b/vendor/core-foundation-sys/src/xml_node.rs @@ -0,0 +1,147 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::{c_char, c_void}; + +use crate::array::CFArrayRef; +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID}; +use crate::dictionary::CFDictionaryRef; +use crate::string::{CFStringEncoding, CFStringRef}; +use crate::tree::CFTreeRef; +use crate::url::CFURLRef; + +#[repr(C)] +pub struct __CFXMLNode(c_void); + +pub type CFXMLNodeRef = *mut __CFXMLNode; +pub type CFXMLTreeRef = CFTreeRef; + +pub const kCFXMLNodeCurrentVersion: CFIndex = 1; + +pub type CFXMLNodeTypeCode = CFIndex; +pub const kCFXMLNodeTypeDocument: CFXMLNodeTypeCode = 1; +pub const kCFXMLNodeTypeElement: CFXMLNodeTypeCode = 2; +pub const kCFXMLNodeTypeAttribute: CFXMLNodeTypeCode = 3; +pub const kCFXMLNodeTypeProcessingInstruction: CFXMLNodeTypeCode = 4; +pub const kCFXMLNodeTypeComment: CFXMLNodeTypeCode = 5; +pub const kCFXMLNodeTypeText: CFXMLNodeTypeCode = 6; +pub const kCFXMLNodeTypeCDATASection: CFXMLNodeTypeCode = 7; +pub const kCFXMLNodeTypeDocumentFragment: CFXMLNodeTypeCode = 8; +pub const kCFXMLNodeTypeEntity: CFXMLNodeTypeCode = 9; +pub const kCFXMLNodeTypeEntityReference: CFXMLNodeTypeCode = 10; +pub const kCFXMLNodeTypeDocumentType: CFXMLNodeTypeCode = 11; +pub const kCFXMLNodeTypeWhitespace: CFXMLNodeTypeCode = 12; +pub const kCFXMLNodeTypeNotation: CFXMLNodeTypeCode = 13; +pub const kCFXMLNodeTypeElementTypeDeclaration: CFXMLNodeTypeCode = 14; +pub const kCFXMLNodeTypeAttributeListDeclaration: CFXMLNodeTypeCode = 15; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLElementInfo { + pub attributes: CFDictionaryRef, + pub attributeOrder: CFArrayRef, + pub isEmpty: Boolean, + pub _reserved: [c_char; 3], +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLProcessingInstructionInfo { + pub dataString: CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLDocumentInfo { + pub sourceURL: CFURLRef, + pub encoding: CFStringEncoding, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLExternalID { + pub systemID: CFURLRef, + pub publicID: CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLDocumentTypeInfo { + pub externalID: CFXMLExternalID, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLNotationInfo { + pub externalID: CFXMLExternalID, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLElementTypeDeclarationInfo { + pub contentDescription: CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLAttributeDeclarationInfo { + pub attributeName: CFStringRef, + pub typeString: CFStringRef, + pub defaultString: CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLAttributeListDeclarationInfo { + pub numberOfAttributes: CFIndex, + pub attributes: *mut CFXMLAttributeDeclarationInfo, +} + +pub type CFXMLEntityTypeCode = CFIndex; +pub const kCFXMLEntityTypeParameter: CFXMLEntityTypeCode = 0; +pub const kCFXMLEntityTypeParsedInternal: CFXMLEntityTypeCode = 1; +pub const kCFXMLEntityTypeParsedExternal: CFXMLEntityTypeCode = 2; +pub const kCFXMLEntityTypeUnparsed: CFXMLEntityTypeCode = 3; +pub const kCFXMLEntityTypeCharacter: CFXMLEntityTypeCode = 4; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLEntityInfo { + pub entityType: CFXMLEntityTypeCode, + pub replacementText: CFStringRef, + pub entityID: CFXMLExternalID, + pub notationName: CFStringRef, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLEntityReferenceInfo { + pub entityType: CFXMLEntityTypeCode, +} + +extern "C" { + /* + * CFXMLNode.h + */ + pub fn CFXMLNodeGetTypeID() -> CFTypeID; + pub fn CFXMLNodeCreate( + alloc: CFAllocatorRef, + xmlType: CFXMLNodeTypeCode, + dataString: CFStringRef, + additionalInfoPtr: *const c_void, + version: CFIndex, + ) -> CFXMLNodeRef; + pub fn CFXMLNodeCreateCopy(alloc: CFAllocatorRef, origNode: CFXMLNodeRef) -> CFXMLNodeRef; + pub fn CFXMLNodeGetTypeCode(node: CFXMLNodeRef) -> CFXMLNodeTypeCode; + pub fn CFXMLNodeGetString(node: CFXMLNodeRef) -> CFStringRef; + pub fn CFXMLNodeGetInfoPtr(node: CFXMLNodeRef) -> *const c_void; + pub fn CFXMLNodeGetVersion(node: CFXMLNodeRef) -> CFIndex; + pub fn CFXMLTreeCreateWithNode(alloc: CFAllocatorRef, node: CFXMLNodeRef) -> CFXMLTreeRef; + pub fn CFXMLTreeGetNode(xmlTree: CFXMLTreeRef) -> CFXMLNodeRef; +} diff --git a/vendor/core-foundation-sys/src/xml_parser.rs b/vendor/core-foundation-sys/src/xml_parser.rs new file mode 100644 index 000000000..32dc709a6 --- /dev/null +++ b/vendor/core-foundation-sys/src/xml_parser.rs @@ -0,0 +1,174 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::os::raw::c_void; + +use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID}; +use crate::data::CFDataRef; +use crate::dictionary::CFDictionaryRef; +use crate::string::CFStringRef; +use crate::url::CFURLRef; +use crate::xml_node::{CFXMLExternalID, CFXMLNodeRef, CFXMLTreeRef}; + +#[repr(C)] +pub struct __CFXMLParser(c_void); + +pub type CFXMLParserRef = *mut __CFXMLParser; + +pub type CFXMLParserOptions = CFOptionFlags; +pub const kCFXMLParserValidateDocument: CFXMLParserOptions = 1 << 0; +pub const kCFXMLParserSkipMetaData: CFXMLParserOptions = 1 << 1; +pub const kCFXMLParserReplacePhysicalEntities: CFXMLParserOptions = 1 << 2; +pub const kCFXMLParserSkipWhitespace: CFXMLParserOptions = 1 << 3; +pub const kCFXMLParserResolveExternalEntities: CFXMLParserOptions = 1 << 4; +pub const kCFXMLParserAddImpliedAttributes: CFXMLParserOptions = 1 << 5; +pub const kCFXMLParserAllOptions: CFXMLParserOptions = 0x00FFFFFF; +pub const kCFXMLParserNoOptions: CFXMLParserOptions = 0; + +pub type CFXMLParserStatusCode = CFIndex; +pub const kCFXMLStatusParseNotBegun: CFIndex = -2; +pub const kCFXMLStatusParseInProgress: CFIndex = -1; +pub const kCFXMLStatusParseSuccessful: CFIndex = 0; +pub const kCFXMLErrorUnexpectedEOF: CFIndex = 1; +pub const kCFXMLErrorUnknownEncoding: CFIndex = 2; +pub const kCFXMLErrorEncodingConversionFailure: CFIndex = 3; +pub const kCFXMLErrorMalformedProcessingInstruction: CFIndex = 4; +pub const kCFXMLErrorMalformedDTD: CFIndex = 5; +pub const kCFXMLErrorMalformedName: CFIndex = 6; +pub const kCFXMLErrorMalformedCDSect: CFIndex = 7; +pub const kCFXMLErrorMalformedCloseTag: CFIndex = 8; +pub const kCFXMLErrorMalformedStartTag: CFIndex = 9; +pub const kCFXMLErrorMalformedDocument: CFIndex = 10; +pub const kCFXMLErrorElementlessDocument: CFIndex = 11; +pub const kCFXMLErrorMalformedComment: CFIndex = 12; +pub const kCFXMLErrorMalformedCharacterReference: CFIndex = 13; +pub const kCFXMLErrorMalformedParsedCharacterData: CFIndex = 14; +pub const kCFXMLErrorNoData: CFIndex = 15; + +pub type CFXMLParserCreateXMLStructureCallBack = + extern "C" fn(parser: CFXMLParserRef, nodeDesc: CFXMLNodeRef, info: *mut c_void) -> *mut c_void; +pub type CFXMLParserAddChildCallBack = extern "C" fn( + parser: CFXMLParserRef, + parent: *mut c_void, + child: *mut c_void, + info: *mut c_void, +); +pub type CFXMLParserEndXMLStructureCallBack = + extern "C" fn(parser: CFXMLParserRef, xmlType: *mut c_void, info: *mut c_void); +pub type CFXMLParserResolveExternalEntityCallBack = extern "C" fn( + parser: CFXMLParserRef, + extID: *mut CFXMLExternalID, + info: *mut c_void, +) -> CFDataRef; +pub type CFXMLParserHandleErrorCallBack = extern "C" fn( + parser: CFXMLParserRef, + error: CFXMLParserStatusCode, + info: *mut c_void, +) -> Boolean; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLParserCallBacks { + pub version: CFIndex, + pub createXMLStructure: CFXMLParserCreateXMLStructureCallBack, + pub addChild: CFXMLParserAddChildCallBack, + pub endXMLStructure: CFXMLParserEndXMLStructureCallBack, + pub resolveExternalEntity: CFXMLParserResolveExternalEntityCallBack, + pub handleError: CFXMLParserHandleErrorCallBack, +} + +pub type CFXMLParserRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void; +pub type CFXMLParserReleaseCallBack = extern "C" fn(info: *const c_void); +pub type CFXMLParserCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef; + +#[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct CFXMLParserContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: CFXMLParserRetainCallBack, + pub release: CFXMLParserReleaseCallBack, + pub copyDescription: CFXMLParserCopyDescriptionCallBack, +} + +extern "C" { + /* + * CFXMLParser.h + */ + + pub static kCFXMLTreeErrorDescription: CFStringRef; + pub static kCFXMLTreeErrorLineNumber: CFStringRef; + pub static kCFXMLTreeErrorLocation: CFStringRef; + pub static kCFXMLTreeErrorStatusCode: CFStringRef; + + pub fn CFXMLParserGetTypeID() -> CFTypeID; + pub fn CFXMLParserCreate( + allocator: CFAllocatorRef, + xmlData: CFDataRef, + dataSource: CFURLRef, + parseOptions: CFOptionFlags, + versionOfNodes: CFIndex, + callBacks: *mut CFXMLParserCallBacks, + context: *mut CFXMLParserContext, + ) -> CFXMLParserRef; + pub fn CFXMLParserCreateWithDataFromURL( + allocator: CFAllocatorRef, + dataSource: CFURLRef, + parseOptions: CFOptionFlags, + versionOfNodes: CFIndex, + callBacks: *mut CFXMLParserCallBacks, + context: *mut CFXMLParserContext, + ) -> CFXMLParserRef; + pub fn CFXMLParserGetContext(parser: CFXMLParserRef, context: *mut CFXMLParserContext); + pub fn CFXMLParserGetCallBacks(parser: CFXMLParserRef, callBacks: *mut CFXMLParserCallBacks); + pub fn CFXMLParserGetSourceURL(parser: CFXMLParserRef) -> CFURLRef; + pub fn CFXMLParserGetLocation(parser: CFXMLParserRef) -> CFIndex; + pub fn CFXMLParserGetLineNumber(parser: CFXMLParserRef) -> CFIndex; + pub fn CFXMLParserGetDocument(parser: CFXMLParserRef) -> *mut c_void; + pub fn CFXMLParserGetStatusCode(parser: CFXMLParserRef) -> CFXMLParserStatusCode; + pub fn CFXMLParserCopyErrorDescription(parser: CFXMLParserRef) -> CFStringRef; + pub fn CFXMLParserAbort( + parser: CFXMLParserRef, + errorCode: CFXMLParserStatusCode, + errorDescription: CFStringRef, + ); + pub fn CFXMLParserParse(parser: CFXMLParserRef) -> Boolean; + pub fn CFXMLTreeCreateFromData( + allocator: CFAllocatorRef, + xmlData: CFDataRef, + dataSource: CFURLRef, + parseOptions: CFOptionFlags, + versionOfNodes: CFIndex, + ) -> CFXMLTreeRef; + pub fn CFXMLTreeCreateFromDataWithError( + allocator: CFAllocatorRef, + xmlData: CFDataRef, + dataSource: CFURLRef, + parseOptions: CFOptionFlags, + versionOfNodes: CFIndex, + errorDict: *mut CFDictionaryRef, + ) -> CFXMLTreeRef; + pub fn CFXMLTreeCreateWithDataFromURL( + allocator: CFAllocatorRef, + dataSource: CFURLRef, + parseOptions: CFOptionFlags, + versionOfNodes: CFIndex, + ) -> CFXMLTreeRef; + pub fn CFXMLTreeCreateXMLData(allocator: CFAllocatorRef, xmlTree: CFXMLTreeRef) -> CFDataRef; + pub fn CFXMLCreateStringByEscapingEntities( + allocator: CFAllocatorRef, + string: CFStringRef, + entitiesDictionary: CFDictionaryRef, + ) -> CFStringRef; + pub fn CFXMLCreateStringByUnescapingEntities( + allocator: CFAllocatorRef, + string: CFStringRef, + entitiesDictionary: CFDictionaryRef, + ) -> CFStringRef; +} |