summaryrefslogtreecommitdiffstats
path: root/third_party/rust/core-foundation
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--third_party/rust/core-foundation-sys/.cargo-checksum.json2
-rw-r--r--third_party/rust/core-foundation-sys/Cargo.toml19
-rw-r--r--third_party/rust/core-foundation-sys/build.rs14
-rw-r--r--third_party/rust/core-foundation-sys/src/array.rs119
-rw-r--r--third_party/rust/core-foundation-sys/src/attributed_string.rs99
-rw-r--r--third_party/rust/core-foundation-sys/src/bag.rs101
-rw-r--r--third_party/rust/core-foundation-sys/src/base.rs88
-rw-r--r--third_party/rust/core-foundation-sys/src/binary_heap.rs83
-rw-r--r--third_party/rust/core-foundation-sys/src/bit_vector.rs74
-rw-r--r--third_party/rust/core-foundation-sys/src/bundle.rs215
-rw-r--r--third_party/rust/core-foundation-sys/src/calendar.rs128
-rw-r--r--third_party/rust/core-foundation-sys/src/characterset.rs102
-rw-r--r--third_party/rust/core-foundation-sys/src/data.rs59
-rw-r--r--third_party/rust/core-foundation-sys/src/date.rs10
-rw-r--r--third_party/rust/core-foundation-sys/src/date_formatter.rs147
-rw-r--r--third_party/rust/core-foundation-sys/src/dictionary.rs124
-rw-r--r--third_party/rust/core-foundation-sys/src/error.rs38
-rw-r--r--third_party/rust/core-foundation-sys/src/file_security.rs71
-rw-r--r--third_party/rust/core-foundation-sys/src/filedescriptor.rs56
-rw-r--r--third_party/rust/core-foundation-sys/src/lib.rs48
-rw-r--r--third_party/rust/core-foundation-sys/src/locale.rs146
-rw-r--r--third_party/rust/core-foundation-sys/src/mach_port.rs63
-rw-r--r--third_party/rust/core-foundation-sys/src/messageport.rs123
-rw-r--r--third_party/rust/core-foundation-sys/src/notification_center.rs89
-rw-r--r--third_party/rust/core-foundation-sys/src/number.rs74
-rw-r--r--third_party/rust/core-foundation-sys/src/number_formatter.rs163
-rw-r--r--third_party/rust/core-foundation-sys/src/plugin.rs99
-rw-r--r--third_party/rust/core-foundation-sys/src/preferences.rs103
-rw-r--r--third_party/rust/core-foundation-sys/src/propertylist.rs102
-rw-r--r--third_party/rust/core-foundation-sys/src/runloop.rs220
-rw-r--r--third_party/rust/core-foundation-sys/src/set.rs64
-rw-r--r--third_party/rust/core-foundation-sys/src/socket.rs188
-rw-r--r--third_party/rust/core-foundation-sys/src/stream.rs281
-rw-r--r--third_party/rust/core-foundation-sys/src/string.rs757
-rw-r--r--third_party/rust/core-foundation-sys/src/string_tokenizer.rs91
-rw-r--r--third_party/rust/core-foundation-sys/src/timezone.rs76
-rw-r--r--third_party/rust/core-foundation-sys/src/tree.rs74
-rw-r--r--third_party/rust/core-foundation-sys/src/url.rs468
-rw-r--r--third_party/rust/core-foundation-sys/src/url_enumerator.rs62
-rw-r--r--third_party/rust/core-foundation-sys/src/user_notification.rs138
-rw-r--r--third_party/rust/core-foundation-sys/src/uuid.rs74
-rw-r--r--third_party/rust/core-foundation-sys/src/xml_node.rs147
-rw-r--r--third_party/rust/core-foundation-sys/src/xml_parser.rs174
-rw-r--r--third_party/rust/core-foundation/.cargo-checksum.json2
-rw-r--r--third_party/rust/core-foundation/Cargo.toml19
-rw-r--r--third_party/rust/core-foundation/src/array.rs97
-rw-r--r--third_party/rust/core-foundation/src/attributed_string.rs51
-rw-r--r--third_party/rust/core-foundation/src/base.rs84
-rw-r--r--third_party/rust/core-foundation/src/boolean.rs17
-rw-r--r--third_party/rust/core-foundation/src/bundle.rs65
-rw-r--r--third_party/rust/core-foundation/src/characterset.rs4
-rw-r--r--third_party/rust/core-foundation/src/data.rs53
-rw-r--r--third_party/rust/core-foundation/src/date.rs25
-rw-r--r--third_party/rust/core-foundation/src/dictionary.rs204
-rw-r--r--third_party/rust/core-foundation/src/error.rs15
-rw-r--r--third_party/rust/core-foundation/src/filedescriptor.rs90
-rw-r--r--third_party/rust/core-foundation/src/lib.rs24
-rw-r--r--third_party/rust/core-foundation/src/mach_port.rs13
-rw-r--r--third_party/rust/core-foundation/src/number.rs54
-rw-r--r--third_party/rust/core-foundation/src/propertylist.rs109
-rw-r--r--third_party/rust/core-foundation/src/runloop.rs128
-rw-r--r--third_party/rust/core-foundation/src/set.rs32
-rw-r--r--third_party/rust/core-foundation/src/string.rs100
-rw-r--r--third_party/rust/core-foundation/src/timezone.rs25
-rw-r--r--third_party/rust/core-foundation/src/url.rs75
-rw-r--r--third_party/rust/core-foundation/src/uuid.rs32
66 files changed, 5429 insertions, 1262 deletions
diff --git a/third_party/rust/core-foundation-sys/.cargo-checksum.json b/third_party/rust/core-foundation-sys/.cargo-checksum.json
index 0bdf990864..7dd167643b 100644
--- a/third_party/rust/core-foundation-sys/.cargo-checksum.json
+++ b/third_party/rust/core-foundation-sys/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"ddcd13ba60bd9368949654be284efac4a55e482b7233e42c9d2fef97ff825eb8","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","build.rs":"9433ed3b20cc99e716dda4c6d8507c29bc04882544cbbea8d4e48ba80fd0fa12","src/array.rs":"40c305658e16b07d86353a5ad34e7b5fb98720f19cc2b5173360d6a61ce2642f","src/attributed_string.rs":"48c2d161d6f54136ae895a9f52efad1f831718ea331b875d25498039158a2d51","src/base.rs":"7b21281e9a01903c79a7891ee4e1865a11504b281b468815d1a3838e1744a3c2","src/bundle.rs":"2a3413e649e1cf5eb1557fa5e3e6d442389caa2978a4a0c2c7afdfa4c388c0bf","src/characterset.rs":"a10bbb42ddc74b3dc50b43ae6a50cc9d9a1cd08b975a1ce1b092be4bf64448a6","src/data.rs":"2b121f102b4c2778475f4902016820c4a70e2f8ac532af53913561d42757fa2e","src/date.rs":"c064ee4c3ebd1927532c34871e2e41179d6e3c3e400f6b409a18ad9e2337477f","src/dictionary.rs":"3327a6f90f1e0db5e3fde1973e2df4143ca896716a816d03f2b17c8e988c5159","src/error.rs":"6205ebeb7631daa8bcd560862b6daa10f640c8c117ce5f6f7184f268dcbcb42a","src/filedescriptor.rs":"49580654b657811fade7adaa256f5f895cb011c9baa4731e2f44a6ec7fdba235","src/lib.rs":"e0b6b9d16f6cae1328de772e056e90003b0a5aa5859f5cde58f6aac4683bb543","src/mach_port.rs":"bd413d44772eaeb24e74e1b7b4f234b159b916caa0896c8e82fe54ce1b9deeb6","src/messageport.rs":"e9227d5907cba8e29cdeea41bcb3ae5c7840220442953ab19aace31a84542f47","src/number.rs":"f28040accfbbec99c4e55f411facac7cde4ad89298af2d7d907312f18e4263bf","src/propertylist.rs":"7ec928438826c4ce40befedf3de0a37c8ecbc0fc17896dfa629d5864000b2cfe","src/runloop.rs":"26ca33e2472d191f583e01c24e8cd262f54de8b542fbe7278f33ab08b2925794","src/set.rs":"116c2f18008bfbeecac570d366dbd95b8fe5b9373e3e1bdd2c1d588314d776c5","src/string.rs":"b2856d0bf7a8583370d18d3f041ac5eb00fd6a1aabc69503e7c11a93d42036d8","src/timezone.rs":"c7dd9557646b7ff2bfd6a98bf92142b8304125b4e78dd651b687abc8da191159","src/url.rs":"4358f756ed3d5e9afd5a7f3e2e9115adc6133b47dc7ce59d6ebb32c6610b0e8f","src/uuid.rs":"82f75efa73d0842dff2e13d299c166c6593a77fcb69c4b7629a2df1c17ae507d"},"package":"5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"} \ No newline at end of file
+{"files":{"Cargo.toml":"f8b5e9fa6c6bbfad4e3c0acfbad03f05cbd98073e664e3ad2fe16a56dd492aa1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"4d469ca3f6aceb42dfaf7b26aa9ef14a8ebce05e02d0beda985fa32f2ec48963","src/attributed_string.rs":"7042f3fbf6904efecb15f01ce2e96eecf84973e0fef9be4c10d14944b0f90a24","src/bag.rs":"dec9ff467ac713526c3be8148ae41b21ab8840f393733bb53c77224ef089787c","src/base.rs":"5d0dee358519712e881e2edbea0ca6d3539958ed1ff3d70aa136af7e25292f22","src/binary_heap.rs":"0565125dbdb1fa578888e00f5b195ab91f0bf65881eabcd39de99ca811d756de","src/bit_vector.rs":"dcdaa573d90b25bdc6b98f2330110e8591b7c329601643dcc6aa23b1b9ec7210","src/bundle.rs":"83ac9d7c45f06161767588c465eed086a773714734da0614d98d000326df3603","src/calendar.rs":"b73796956e50d92f0479479e84246712804537d694e4cdd01d5440e5fbcbd333","src/characterset.rs":"ba60f78884cd860e151df35c1953bcd6eae46d9f27c36584b66e508e2301a7a8","src/data.rs":"fe4e2effbfd9348575507d06aa53cd583808c908f9e03ac1a076b077230c9c01","src/date.rs":"971d681f6eeefa3764d8a43e53cbf7c937c419331207c7bb003a25c9b0b0722f","src/date_formatter.rs":"05e84ac3cf4c0daae2e939a9bedddfd10dd5309ea1536bf8241de41971d11f8a","src/dictionary.rs":"ac23d99208131049c82c13b37a99b4fd129224d1dafcd65ff2f9de200d73e9d1","src/error.rs":"b523faa8c498e1115c72e71a10e7a3bf8bcc01588cb02e70dc9fd45cbdaa35f6","src/file_security.rs":"542c5d8eef22424479abcb448601611d85c9cc96e41cd6cd6de5ea3efe1213a6","src/filedescriptor.rs":"706eebde408713cc49bbab078e86fe51e95fe29b167420bbcbb573847dcf29e2","src/lib.rs":"8ae5082d92ebf6b1a53332211b87986aa7228534f5e341b62100e522b7fcadec","src/locale.rs":"372190a9cb5659fba0b92598c5dcbdaa3f90b29b3440ddcfe77931e85c1f96d9","src/mach_port.rs":"e52c2ce794e82ebeeb0cba170902409f18626b7d9e29d6dcd333e9c13411408a","src/messageport.rs":"d8e342f0eabe47f6f4746fdbf996bf9008b4b5f1fa24e0bc4ecd73b2de81b234","src/notification_center.rs":"0ab30523bc4ac799016970c9c59594cbb3afeda054705c15d0979eb07abb7c7d","src/number.rs":"28b10c9d2361cac18549ef66839f595e98490096e756e9a7f25536b6ceb1f687","src/number_formatter.rs":"024fbd3b2ecaecf19cfdb463e0f0096d1fa28bc4ce636659e53459d1b01af658","src/plugin.rs":"0904b1b4b882e626d5d63ac91c540dfdf65f5f4428cf38c9def6acfc7ed84cd3","src/preferences.rs":"49d8ac0c669a01678fa0dc26d6cb13bc72004c8422e525bf3e26f01feb5a3693","src/propertylist.rs":"f7f12cb8c67098e5b96cb8a63b4a947549a2cbf7a6523ce314141b4f8cc202c4","src/runloop.rs":"8fa6e5e74a013f8101d5a4f6616818573adc7ed197e28b799dca4c3a1cedaac9","src/set.rs":"0e619ec75a6b975be6b6d59ed3b01c803dd635020288b178db949b1c45442d17","src/socket.rs":"b67737b8c04142fa4d198c19f0867fd653837e529bf2665e78750c94f469a793","src/stream.rs":"f9b1099191010a96ce0aadcc22385732710dfc1521873096a9db67ad80472e36","src/string.rs":"fa46e7b7865709494bb05c9c7c6006f165fafa956ab41f053af0e4b41904efa4","src/string_tokenizer.rs":"0da4ae1a841591871602f21cc1c9b51289a0514a255b269e4b61afdeb0097c10","src/timezone.rs":"f584ea76627f12f33eba25d7ea054c2d2c10a2d96474fce12858ccb4bdf688c1","src/tree.rs":"50d513ea1801797c549218c51f5ebf77be4cf80901b12ce3ba0a223c602995d4","src/url.rs":"cb08b0bd24708e6572711f4f82b88370e811aabf4f58f22c34f0f873a44c7486","src/url_enumerator.rs":"bd531f31f6c62b2849d5ccbc82bfc3ae3866c4cdd6768b6c2fe380f24c290540","src/user_notification.rs":"e86b052817028847e62121752e7d58f8ed6f8ad15f5ef947c1fa93bbd0fcbf26","src/uuid.rs":"48af493dc6c8b00d804d6ae92a2fd71eabdae8a2be0500baaa55ce56345c350a","src/xml_node.rs":"c7894a4d08f695ba75d539b3c8d6cc3a90544000786fe3f9cd9c02ad7541213b","src/xml_parser.rs":"ac8a3d2c71ec8ec80603ce5ef214147c0e93bed211c1559a47f14fc31cb0bbaf"},"package":"06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"} \ No newline at end of file
diff --git a/third_party/rust/core-foundation-sys/Cargo.toml b/third_party/rust/core-foundation-sys/Cargo.toml
index bd17103b56..345cbab915 100644
--- a/third_party/rust/core-foundation-sys/Cargo.toml
+++ b/third_party/rust/core-foundation-sys/Cargo.toml
@@ -3,27 +3,30 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
+edition = "2018"
name = "core-foundation-sys"
-version = "0.8.3"
+version = "0.8.6"
authors = ["The Servo Project Developers"]
-build = "build.rs"
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
-license = "MIT / Apache-2.0"
+license = "MIT OR Apache-2.0"
repository = "https://github.com/servo/core-foundation-rs"
+
[package.metadata.docs.rs]
+all-features = true
default-target = "x86_64-apple-darwin"
[dependencies]
[features]
+default = ["link"]
+link = []
mac_os_10_7_support = []
mac_os_10_8_features = []
diff --git a/third_party/rust/core-foundation-sys/build.rs b/third_party/rust/core-foundation-sys/build.rs
deleted file mode 100644
index 1f03b0602e..0000000000
--- a/third_party/rust/core-foundation-sys/build.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2013-2015 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.
-
-fn main() {
- if std::env::var("TARGET").unwrap().contains("-apple") {
- println!("cargo:rustc-link-lib=framework=CoreFoundation");
- }
-}
diff --git a/third_party/rust/core-foundation-sys/src/array.rs b/third_party/rust/core-foundation-sys/src/array.rs
index 5090302fc2..1e521b3e48 100644
--- a/third_party/rust/core-foundation-sys/src/array.rs
+++ b/third_party/rust/core-foundation-sys/src/array.rs
@@ -9,16 +9,19 @@
use std::os::raw::c_void;
-use base::{CFRange, CFIndex, CFAllocatorRef, CFTypeID, Boolean};
-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);
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub struct CFArrayCallBacks {
pub version: CFIndex,
pub retain: CFArrayRetainCallBack,
@@ -31,25 +34,109 @@ pub struct CFArrayCallBacks {
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 CFArrayCreate(allocator: CFAllocatorRef, values: *const *const c_void,
- numValues: CFIndex, callBacks: *const CFArrayCallBacks) -> CFArrayRef;
- pub fn CFArrayCreateCopy(allocator: CFAllocatorRef , theArray: CFArrayRef) -> CFArrayRef;
-
- // CFArrayBSearchValues
- // CFArrayContainsValue
+ /* 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;
- // CFArrayGetCountOfValue
- // CFArrayGetFirstIndexOfValue
- // CFArrayGetLastIndexOfValue
+ 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 CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void;
- // CFArrayApplyFunction
+
+ /* 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 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 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/third_party/rust/core-foundation-sys/src/attributed_string.rs b/third_party/rust/core-foundation-sys/src/attributed_string.rs
index c91bf5be38..54c27ec416 100644
--- a/third_party/rust/core-foundation-sys/src/attributed_string.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/bag.rs b/third_party/rust/core-foundation-sys/src/bag.rs
new file mode 100644
index 0000000000..041caa59c2
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/base.rs b/third_party/rust/core-foundation-sys/src/base.rs
index 52a166fdf6..78e06a65f5 100644
--- a/third_party/rust/core-foundation-sys/src/base.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/binary_heap.rs b/third_party/rust/core-foundation-sys/src/binary_heap.rs
new file mode 100644
index 0000000000..8bcaa8e26e
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/bit_vector.rs b/third_party/rust/core-foundation-sys/src/bit_vector.rs
new file mode 100644
index 0000000000..f270c3d1d3
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/bundle.rs b/third_party/rust/core-foundation-sys/src/bundle.rs
index 29f8e1261f..60aaa4c777 100644
--- a/third_party/rust/core-foundation-sys/src/bundle.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/calendar.rs b/third_party/rust/core-foundation-sys/src/calendar.rs
new file mode 100644
index 0000000000..54c2a00cd2
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/characterset.rs b/third_party/rust/core-foundation-sys/src/characterset.rs
index 6b347a5cdd..8d75679af9 100644
--- a/third_party/rust/core-foundation-sys/src/characterset.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/data.rs b/third_party/rust/core-foundation-sys/src/data.rs
index e5ed0dc9f0..ba87d0c5d3 100644
--- a/third_party/rust/core-foundation-sys/src/data.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/date.rs b/third_party/rust/core-foundation-sys/src/date.rs
index f83ce1dd18..26b55d402a 100644
--- a/third_party/rust/core-foundation-sys/src/date.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/date_formatter.rs b/third_party/rust/core-foundation-sys/src/date_formatter.rs
new file mode 100644
index 0000000000..83c6e1fa76
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/dictionary.rs b/third_party/rust/core-foundation-sys/src/dictionary.rs
index d10e9c1200..8c04d680df 100644
--- a/third_party/rust/core-foundation-sys/src/dictionary.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/error.rs b/third_party/rust/core-foundation-sys/src/error.rs
index 8a4c1d4940..e8ebd6c421 100644
--- a/third_party/rust/core-foundation-sys/src/error.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/file_security.rs b/third_party/rust/core-foundation-sys/src/file_security.rs
new file mode 100644
index 0000000000..a4ec6112b5
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/filedescriptor.rs b/third_party/rust/core-foundation-sys/src/filedescriptor.rs
index 3f51d10729..271adb716c 100644
--- a/third_party/rust/core-foundation-sys/src/filedescriptor.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/lib.rs b/third_party/rust/core-foundation-sys/src/lib.rs
index f9a1884169..948ce807d3 100644
--- a/third_party/rust/core-foundation-sys/src/lib.rs
+++ b/third_party/rust/core-foundation-sys/src/lib.rs
@@ -6,27 +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)]
+#![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
-#![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(
+ 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/third_party/rust/core-foundation-sys/src/locale.rs b/third_party/rust/core-foundation-sys/src/locale.rs
new file mode 100644
index 0000000000..f80e5c4a6a
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/mach_port.rs b/third_party/rust/core-foundation-sys/src/mach_port.rs
index 2341fd4e74..1f47275dec 100644
--- a/third_party/rust/core-foundation-sys/src/mach_port.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/messageport.rs b/third_party/rust/core-foundation-sys/src/messageport.rs
index e33d9aa4bc..4ccdcc8b37 100644
--- a/third_party/rust/core-foundation-sys/src/messageport.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/notification_center.rs b/third_party/rust/core-foundation-sys/src/notification_center.rs
new file mode 100644
index 0000000000..2ed829233e
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/number.rs b/third_party/rust/core-foundation-sys/src/number.rs
index c056a245b0..d822d417d9 100644
--- a/third_party/rust/core-foundation-sys/src/number.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/number_formatter.rs b/third_party/rust/core-foundation-sys/src/number_formatter.rs
new file mode 100644
index 0000000000..cae7b11b00
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/plugin.rs b/third_party/rust/core-foundation-sys/src/plugin.rs
new file mode 100644
index 0000000000..fa236777c2
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/preferences.rs b/third_party/rust/core-foundation-sys/src/preferences.rs
new file mode 100644
index 0000000000..0899938e58
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/propertylist.rs b/third_party/rust/core-foundation-sys/src/propertylist.rs
index 574c4d13f3..d4ceb1b0c0 100644
--- a/third_party/rust/core-foundation-sys/src/propertylist.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/runloop.rs b/third_party/rust/core-foundation-sys/src/runloop.rs
index 53035a2e75..5d5fda7a01 100644
--- a/third_party/rust/core-foundation-sys/src/runloop.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/set.rs b/third_party/rust/core-foundation-sys/src/set.rs
index a5cc1b16f7..8141c5999d 100644
--- a/third_party/rust/core-foundation-sys/src/set.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/socket.rs b/third_party/rust/core-foundation-sys/src/socket.rs
new file mode 100644
index 0000000000..6fb70a1080
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/stream.rs b/third_party/rust/core-foundation-sys/src/stream.rs
new file mode 100644
index 0000000000..922700e489
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/string.rs b/third_party/rust/core-foundation-sys/src/string.rs
index d4f6550784..2cb6ae948a 100644
--- a/third_party/rust/core-foundation-sys/src/string.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/string_tokenizer.rs b/third_party/rust/core-foundation-sys/src/string_tokenizer.rs
new file mode 100644
index 0000000000..b23d6a2d34
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/timezone.rs b/third_party/rust/core-foundation-sys/src/timezone.rs
index 0b279db188..076062a491 100644
--- a/third_party/rust/core-foundation-sys/src/timezone.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/tree.rs b/third_party/rust/core-foundation-sys/src/tree.rs
new file mode 100644
index 0000000000..da6fdd607d
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/url.rs b/third_party/rust/core-foundation-sys/src/url.rs
index 08e7bcd9fe..2274d3608f 100644
--- a/third_party/rust/core-foundation-sys/src/url.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/url_enumerator.rs b/third_party/rust/core-foundation-sys/src/url_enumerator.rs
new file mode 100644
index 0000000000..71b74beb5b
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/user_notification.rs b/third_party/rust/core-foundation-sys/src/user_notification.rs
new file mode 100644
index 0000000000..6432718261
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/uuid.rs b/third_party/rust/core-foundation-sys/src/uuid.rs
index 4253952938..a1714a8a8c 100644
--- a/third_party/rust/core-foundation-sys/src/uuid.rs
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/xml_node.rs b/third_party/rust/core-foundation-sys/src/xml_node.rs
new file mode 100644
index 0000000000..332beec823
--- /dev/null
+++ b/third_party/rust/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/third_party/rust/core-foundation-sys/src/xml_parser.rs b/third_party/rust/core-foundation-sys/src/xml_parser.rs
new file mode 100644
index 0000000000..32dc709a60
--- /dev/null
+++ b/third_party/rust/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;
+}
diff --git a/third_party/rust/core-foundation/.cargo-checksum.json b/third_party/rust/core-foundation/.cargo-checksum.json
index 93d6c58e7c..05422dac50 100644
--- a/third_party/rust/core-foundation/.cargo-checksum.json
+++ b/third_party/rust/core-foundation/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"5909548b679fccc46cd25a91f3784139e4e53bbed284e3b7cc72c599e599e138","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"e5e6ea11e660e5e6676568c9b5b4595633c16fad770755b13bb4fde6c7436a4e","src/attributed_string.rs":"c04c5a3c912b6ab58d3081fa5dfa8fda07957b26396ebc907bba5ad07dc1087d","src/base.rs":"9ed46d59afdb22ecc65504ccd77f1c98108ea0ff96fad568dadb7ed49fde588c","src/boolean.rs":"f5b4d295aaf6cc3681212afebeae2974c5d551125badcc066e6089ac0d2a0873","src/bundle.rs":"c290a87d8bc43d8c9e1935c18e6d7127f46fd211cc2b041ed9e7b618b9df270c","src/characterset.rs":"a3ffb46c5463c99813eebfc177a65794f44a1b9343534e28bbccd262034714c2","src/data.rs":"c8d2ec30d8ac6249ef84afa0f7638d950b5c70d687aeb4ba9e3e46806aa872aa","src/date.rs":"a02f6cca7b6e8fbabc7713177429012658dba5146556e14a08e7baaf81958d83","src/dictionary.rs":"780599de45d64e8f4bca18ad50fc4a909f6e9aab1c3f2cea451f469d766f6782","src/error.rs":"22c21087d9c2c103d1bcb2c4af33b684317bbda5d4747902e510d410f8c1a14b","src/filedescriptor.rs":"022463c6dce8823231dc88064e5d9cffb494b410391388fe1feb50d3419d98b7","src/lib.rs":"2d0b007b264642cbad31e8c901f5f2235ed55515ef73e573a8d86306a7cd4f06","src/mach_port.rs":"87aa8dd28060bbb976197e7cc981eb733762b9bcc29eddd742f44aa8141e71b1","src/number.rs":"5a6cc9036c156e7e9d787864dd671087677abf4175cd840cbf123ccd89abcafe","src/propertylist.rs":"3c964d976709562b96f391265130c0f8fced307267a2b6385bab469048518b55","src/runloop.rs":"514a8ea7b185812fbb6d4835b0f7d26208f3121dadf1553a3a39c5013f2820af","src/set.rs":"da75b31f894bd04c0518211e113ca21a2781cd6ac71018104eeb354dd2f1a19e","src/string.rs":"bea7f3fd2528377442d1bebfeacf7e905d879320ae662fe6a8ef917b6a8e9c36","src/timezone.rs":"6dcf188db76303292b519d6283b71b71c7b3d6ed1afddc28de16d727075f5ef1","src/url.rs":"c544725399d3fbc4de54fd9d1c987e02f81760effd08c5c64c8deacd11478950","src/uuid.rs":"c3457e43fc22ba0f3fcab3ee8108500585ba005dbcbfa7edad0d389701ddf379","tests/use_macro_outside_crate.rs":"ed5e74ac9e988f2609c0b785189f1e6368d693f6401603ad065521f3ab51df94"},"package":"194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"} \ No newline at end of file
+{"files":{"Cargo.toml":"2e85272c5cffb75aadcbb83d8ca1a619af3ccb9d810c1e07349f3b618fa05b7e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"1ec64187ec7c3ff0a9cf9739fb83d1f0b6141d827e4f21a14203b7058ca12056","src/attributed_string.rs":"7c129d266872bf9e0f8cbd9477d8cc27405b806395e59e1647bedf9af06f8949","src/base.rs":"7ec2afcbc200aabaa01687efce2eb27c9effc9eae64d3c579827de731fbd290e","src/boolean.rs":"60aef5be531e867f03524c32a88609100d07d9166184545feab760af9eb3d7ec","src/bundle.rs":"00f7ae30df3cc59079e771da0eda2b1972f52b13cc7bd95ae48b0e9bd1836ff4","src/characterset.rs":"126884d51e75db5be4cb2988f4e97e0e1b592c900e0158082d8c0dda7a453b0f","src/data.rs":"bfaa4427b6bc4c838188506ee154622983bbfcc10641be3f58525b89a854d4cd","src/date.rs":"d1ec3f918cf6c62d0e36d50d495c125d275a9a89442a740eea5d41dcc71a96fa","src/dictionary.rs":"f6d73c08fa9afd30d1df70cceea55dd30c7b81b8a78117d8843f1b3390051dca","src/error.rs":"433982fb7b421f5bf386d7eba22a7ffb8673486bb6455ff3fa30c875b064f718","src/filedescriptor.rs":"d3ece69ff461b215f7ff98dc6139723c4a5a53849a9747cccd24e72c185c4ffd","src/lib.rs":"92502d5f7d0e2ba266ec3531c01dd996e1832f1e6e9e66b10596e6fb870480cb","src/mach_port.rs":"e5400039696a70bdc0e6e14b1a68c493b741136945ce0eb67208cd4d0f895e1b","src/number.rs":"48e2efe219a7eaa4bc7bc3a48fa45f32fbbfd6363620838fef16a98b86e05061","src/propertylist.rs":"23e9a42d506983374d0c3439ab80407bbd472a3487812693a411597ff5eb1bd8","src/runloop.rs":"ff5bbb8a145befa7f244d937161d87f059ea60c9c482ab32e845222ee6fabf34","src/set.rs":"39e41a3d4f9e4dd50864a9c3581508e1b09549dc89d57fa84935964d98469bad","src/string.rs":"3b25b169d0f18dae66e6f123a116a04c79096f9e44e4221d4dbdcea4e152355c","src/timezone.rs":"7b8e46bde9e8aa71a906ab26b8ff7b6251568ebf210bab10d11c6ba0ce64ecd5","src/url.rs":"dc125dd95e9b8386770b89f5437ab904ceff0843e1bf820f548bddfc31e1c40c","src/uuid.rs":"e290c592871b7cea6ec09d2b3e34ec9033968dda725cf49e410535f79d2b41f8","tests/use_macro_outside_crate.rs":"ed5e74ac9e988f2609c0b785189f1e6368d693f6401603ad065521f3ab51df94"},"package":"91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"} \ No newline at end of file
diff --git a/third_party/rust/core-foundation/Cargo.toml b/third_party/rust/core-foundation/Cargo.toml
index 7ea9578156..47cf3f2640 100644
--- a/third_party/rust/core-foundation/Cargo.toml
+++ b/third_party/rust/core-foundation/Cargo.toml
@@ -10,23 +10,32 @@
# See Cargo.toml.orig for the original contents.
[package]
+edition = "2018"
name = "core-foundation"
-version = "0.9.3"
+version = "0.9.4"
authors = ["The Servo Project Developers"]
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
-keywords = ["macos", "framework", "objc"]
+keywords = [
+ "macos",
+ "framework",
+ "objc",
+]
categories = ["os::macos-apis"]
-license = "MIT / Apache-2.0"
+license = "MIT OR Apache-2.0"
repository = "https://github.com/servo/core-foundation-rs"
+
[package.metadata.docs.rs]
+all-features = true
default-target = "x86_64-apple-darwin"
+
[dependencies.chrono]
version = "0.4"
optional = true
[dependencies.core-foundation-sys]
-version = "0.8.3"
+version = "0.8.6"
+default-features = false
[dependencies.libc]
version = "0.2"
@@ -36,6 +45,8 @@ version = "0.5"
optional = true
[features]
+default = ["link"]
+link = ["core-foundation-sys/link"]
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"]
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"]
with-chrono = ["chrono"]
diff --git a/third_party/rust/core-foundation/src/array.rs b/third_party/rust/core-foundation/src/array.rs
index d66ffc5b82..b6f5d5c740 100644
--- a/third_party/rust/core-foundation/src/array.rs
+++ b/third_party/rust/core-foundation/src/array.rs
@@ -9,17 +9,17 @@
//! Heterogeneous immutable arrays.
+use crate::ConcreteCFType;
pub use core_foundation_sys::array::*;
pub use core_foundation_sys::base::CFIndex;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
-use std::mem;
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
use std::marker::PhantomData;
+use std::mem;
use std::os::raw::c_void;
use std::ptr;
-use ConcreteCFType;
-use base::{CFIndexConvertible, TCFType, CFRange};
-use base::{FromVoid, ItemRef};
+use crate::base::{CFIndexConvertible, CFRange, TCFType};
+use crate::base::{FromVoid, ItemRef};
/// A heterogeneous immutable array.
pub struct CFArray<T = *const c_void>(CFArrayRef, PhantomData<T>);
@@ -63,24 +63,34 @@ unsafe impl ConcreteCFType for CFArray<*const c_void> {}
impl<T> CFArray<T> {
/// Creates a new `CFArray` with the given elements, which must implement `Copy`.
- pub fn from_copyable(elems: &[T]) -> CFArray<T> where T: Copy {
+ pub fn from_copyable(elems: &[T]) -> CFArray<T>
+ where
+ T: Copy,
+ {
unsafe {
- let array_ref = CFArrayCreate(kCFAllocatorDefault,
- elems.as_ptr() as *const *const c_void,
- elems.len().to_CFIndex(),
- ptr::null());
+ let array_ref = CFArrayCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr() as *const *const c_void,
+ elems.len().to_CFIndex(),
+ ptr::null(),
+ );
TCFType::wrap_under_create_rule(array_ref)
}
}
/// Creates a new `CFArray` with the given elements, which must be `CFType` objects.
- pub fn from_CFTypes(elems: &[T]) -> CFArray<T> where T: TCFType {
+ pub fn from_CFTypes(elems: &[T]) -> CFArray<T>
+ where
+ T: TCFType,
+ {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
- let array_ref = CFArrayCreate(kCFAllocatorDefault,
- elems.as_ptr(),
- elems.len().to_CFIndex(),
- &kCFTypeArrayCallBacks);
+ let array_ref = CFArrayCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr(),
+ elems.len().to_CFIndex(),
+ &kCFTypeArrayCallBacks,
+ );
TCFType::wrap_under_create_rule(array_ref)
}
}
@@ -105,7 +115,7 @@ impl<T> CFArray<T> {
/// Core Foundation objects (not always true), they need to be wrapped with
/// `TCFType::wrap_under_get_rule()`.
#[inline]
- pub fn iter<'a>(&'a self) -> CFArrayIterator<'a, T> {
+ pub fn iter(&self) -> CFArrayIterator<'_, T> {
CFArrayIterator {
array: self,
index: 0,
@@ -115,20 +125,30 @@ impl<T> CFArray<T> {
#[inline]
pub fn len(&self) -> CFIndex {
- unsafe {
- CFArrayGetCount(self.0)
- }
+ unsafe { CFArrayGetCount(self.0) }
}
+ /// Returns `true` if the array contains no elements.
#[inline]
- pub unsafe fn get_unchecked<'a>(&'a self, index: CFIndex) -> ItemRef<'a, T> where T: FromVoid {
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+
+ #[inline]
+ pub unsafe fn get_unchecked(&self, index: CFIndex) -> ItemRef<'_, T>
+ where
+ T: FromVoid,
+ {
T::from_void(CFArrayGetValueAtIndex(self.0, index))
}
#[inline]
- pub fn get<'a>(&'a self, index: CFIndex) -> Option<ItemRef<'a, T>> where T: FromVoid {
+ pub fn get(&self, index: CFIndex) -> Option<ItemRef<'_, T>>
+ where
+ T: FromVoid,
+ {
if index < self.len() {
- Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) } )
+ Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) })
} else {
None
}
@@ -146,7 +166,7 @@ impl<T> CFArray<T> {
pub fn get_all_values(&self) -> Vec<*const c_void> {
self.get_values(CFRange {
location: 0,
- length: self.len()
+ length: self.len(),
})
}
}
@@ -162,13 +182,15 @@ impl<'a, T: FromVoid> IntoIterator for &'a CFArray<T> {
#[cfg(test)]
mod tests {
+ use crate::number::CFNumber;
+
use super::*;
+ use crate::base::CFType;
use std::mem;
- use base::CFType;
#[test]
fn to_untyped_correct_retain_count() {
- let array = CFArray::<CFType>::from_CFTypes(&[]);
+ let array = CFArray::<CFType>::from_CFTypes(&[CFNumber::from(4).as_CFType()]);
assert_eq!(array.retain_count(), 1);
let untyped_array = array.to_untyped();
@@ -181,7 +203,7 @@ mod tests {
#[test]
fn into_untyped() {
- let array = CFArray::<CFType>::from_CFTypes(&[]);
+ let array = CFArray::<CFType>::from_CFTypes(&[CFNumber::from(4).as_CFType()]);
let array2 = array.to_untyped();
assert_eq!(array.retain_count(), 2);
@@ -194,9 +216,9 @@ mod tests {
#[test]
fn borrow() {
- use string::CFString;
+ use crate::string::CFString;
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let x;
{
@@ -208,7 +230,7 @@ mod tests {
{
x = arr.get(0).unwrap().clone();
assert_eq!(x.retain_count(), 2);
- assert_eq!(x.to_string(), "bar");
+ assert_eq!(x.to_string(), "alongerstring");
}
}
assert_eq!(x.retain_count(), 1);
@@ -216,23 +238,24 @@ mod tests {
#[test]
fn iter_untyped_array() {
- use string::{CFString, CFStringRef};
- use base::TCFTypeRef;
+ use crate::base::TCFTypeRef;
+ use crate::string::{CFString, CFStringRef};
- let cf_string = CFString::from_static_string("bar");
+ let cf_string = CFString::from_static_string("alongerstring");
let array: CFArray = CFArray::from_CFTypes(&[cf_string.clone()]).into_untyped();
- let cf_strings = array.iter().map(|ptr| {
- unsafe { CFString::wrap_under_get_rule(CFStringRef::from_void_ptr(*ptr)) }
- }).collect::<Vec<_>>();
+ let cf_strings = array
+ .iter()
+ .map(|ptr| unsafe { CFString::wrap_under_get_rule(CFStringRef::from_void_ptr(*ptr)) })
+ .collect::<Vec<_>>();
let strings = cf_strings.iter().map(|s| s.to_string()).collect::<Vec<_>>();
assert_eq!(cf_string.retain_count(), 3);
- assert_eq!(&strings[..], &["bar"]);
+ assert_eq!(&strings[..], &["alongerstring"]);
}
#[test]
fn should_box_and_unbox() {
- use number::CFNumber;
+ use crate::number::CFNumber;
let n0 = CFNumber::from(0);
let n1 = CFNumber::from(1);
diff --git a/third_party/rust/core-foundation/src/attributed_string.rs b/third_party/rust/core-foundation/src/attributed_string.rs
index d4a467946d..6a2b349f1a 100644
--- a/third_party/rust/core-foundation/src/attributed_string.rs
+++ b/third_party/rust/core-foundation/src/attributed_string.rs
@@ -9,22 +9,26 @@
pub use core_foundation_sys::attributed_string::*;
-use base::TCFType;
-use core_foundation_sys::base::{CFIndex, CFRange, kCFAllocatorDefault};
+use crate::base::TCFType;
+use crate::string::{CFString, CFStringRef};
+use core_foundation_sys::base::{kCFAllocatorDefault, CFIndex, CFRange};
use std::ptr::null;
-use string::{CFString, CFStringRef};
-declare_TCFType!{
+declare_TCFType! {
CFAttributedString, CFAttributedStringRef
}
-impl_TCFType!(CFAttributedString, CFAttributedStringRef, CFAttributedStringGetTypeID);
+impl_TCFType!(
+ CFAttributedString,
+ CFAttributedStringRef,
+ CFAttributedStringGetTypeID
+);
impl CFAttributedString {
#[inline]
pub fn new(string: &CFString) -> Self {
unsafe {
- let astr_ref = CFAttributedStringCreate(
- kCFAllocatorDefault, string.as_concrete_TypeRef(), null());
+ let astr_ref =
+ CFAttributedStringCreate(kCFAllocatorDefault, string.as_concrete_TypeRef(), null());
CFAttributedString::wrap_under_create_rule(astr_ref)
}
@@ -32,23 +36,24 @@ impl CFAttributedString {
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFAttributedStringGetLength(self.0)
- }
+ unsafe { CFAttributedStringGetLength(self.0) }
}
}
-declare_TCFType!{
+declare_TCFType! {
CFMutableAttributedString, CFMutableAttributedStringRef
}
-impl_TCFType!(CFMutableAttributedString, CFMutableAttributedStringRef, CFAttributedStringGetTypeID);
+impl_TCFType!(
+ CFMutableAttributedString,
+ CFMutableAttributedStringRef,
+ CFAttributedStringGetTypeID
+);
impl CFMutableAttributedString {
#[inline]
pub fn new() -> Self {
unsafe {
- let astr_ref = CFAttributedStringCreateMutable(
- kCFAllocatorDefault, 0);
+ let astr_ref = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFMutableAttributedString::wrap_under_create_rule(astr_ref)
}
@@ -56,24 +61,20 @@ impl CFMutableAttributedString {
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFAttributedStringGetLength(self.0)
- }
+ unsafe { CFAttributedStringGetLength(self.0) }
}
#[inline]
pub fn replace_str(&mut self, string: &CFString, range: CFRange) {
unsafe {
- CFAttributedStringReplaceString(
- self.0, range, string.as_concrete_TypeRef());
+ CFAttributedStringReplaceString(self.0, range, string.as_concrete_TypeRef());
}
}
#[inline]
pub fn set_attribute<T: TCFType>(&mut self, range: CFRange, name: CFStringRef, value: &T) {
unsafe {
- CFAttributedStringSetAttribute(
- self.0, range, name, value.as_CFTypeRef());
+ CFAttributedStringSetAttribute(self.0, range, name, value.as_CFTypeRef());
}
}
}
@@ -84,7 +85,6 @@ impl Default for CFMutableAttributedString {
}
}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -93,6 +93,9 @@ mod tests {
fn attributed_string_type_id_comparison() {
// CFMutableAttributedString TypeID must be equal to CFAttributedString TypeID.
// Compilation must not fail.
- assert_eq!(<CFAttributedString as TCFType>::type_id(), <CFMutableAttributedString as TCFType>::type_id());
+ assert_eq!(
+ <CFAttributedString as TCFType>::type_id(),
+ <CFMutableAttributedString as TCFType>::type_id()
+ );
}
-} \ No newline at end of file
+}
diff --git a/third_party/rust/core-foundation/src/base.rs b/third_party/rust/core-foundation/src/base.rs
index f08f2b2e85..b44c1262ab 100644
--- a/third_party/rust/core-foundation/src/base.rs
+++ b/third_party/rust/core-foundation/src/base.rs
@@ -17,8 +17,8 @@ use std::os::raw::c_void;
pub use core_foundation_sys::base::*;
-use string::CFString;
-use ConcreteCFType;
+use crate::string::CFString;
+use crate::ConcreteCFType;
pub trait CFIndexConvertible {
/// Always use this method to construct a `CFIndex` value. It performs bounds checking to
@@ -37,7 +37,7 @@ impl CFIndexConvertible for usize {
}
}
-declare_TCFType!{
+declare_TCFType! {
/// Superclass of all Core Foundation objects.
CFType, CFTypeRef
}
@@ -111,13 +111,11 @@ impl CFType {
}
impl fmt::Debug for CFType {
- /// Formats the value using [`CFCopyDescription`].
- ///
- /// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc
+ /// Formats the value using [`CFCopyDescription`].
+ ///
+ /// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let desc = unsafe {
- CFString::wrap_under_create_rule(CFCopyDescription(self.0))
- };
+ let desc = unsafe { CFString::wrap_under_create_rule(CFCopyDescription(self.0)) };
desc.fmt(f)
}
}
@@ -125,18 +123,14 @@ impl fmt::Debug for CFType {
impl Clone for CFType {
#[inline]
fn clone(&self) -> CFType {
- unsafe {
- TCFType::wrap_under_get_rule(self.0)
- }
+ unsafe { TCFType::wrap_under_get_rule(self.0) }
}
}
impl PartialEq for CFType {
#[inline]
fn eq(&self, other: &CFType) -> bool {
- unsafe {
- CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0
- }
+ unsafe { CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0 }
}
}
@@ -153,7 +147,6 @@ impl CFAllocator {
}
}
-
/// All Core Foundation types implement this trait. The associated type `Ref` specifies the
/// associated Core Foundation type: e.g. for `CFType` this is `CFTypeRef`; for `CFArray` this is
/// `CFArrayRef`.
@@ -165,7 +158,7 @@ pub trait TCFType {
/// The reference type wrapped inside this type.
type Ref: TCFTypeRef;
- /// Returns the object as its concrete TypeRef.
+ /// Returns the object as its concrete `TypeRef`.
fn as_concrete_TypeRef(&self) -> Self::Ref;
/// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this
@@ -178,9 +171,7 @@ pub trait TCFType {
/// Returns the object as a wrapped `CFType`. The reference count is incremented by one.
#[inline]
fn as_CFType(&self) -> CFType {
- unsafe {
- TCFType::wrap_under_get_rule(self.as_CFTypeRef())
- }
+ unsafe { TCFType::wrap_under_get_rule(self.as_CFTypeRef()) }
}
/// Returns the object as a wrapped `CFType`. Consumes self and avoids changing the reference
@@ -206,27 +197,21 @@ pub trait TCFType {
/// whether the return value of this method is greater than zero.
#[inline]
fn retain_count(&self) -> CFIndex {
- unsafe {
- CFGetRetainCount(self.as_CFTypeRef())
- }
+ unsafe { CFGetRetainCount(self.as_CFTypeRef()) }
}
/// Returns the type ID of this object.
#[inline]
fn type_of(&self) -> CFTypeID {
- unsafe {
- CFGetTypeID(self.as_CFTypeRef())
- }
+ unsafe { CFGetTypeID(self.as_CFTypeRef()) }
}
/// Writes a debugging version of this object on standard error.
fn show(&self) {
- unsafe {
- CFShow(self.as_CFTypeRef())
- }
+ unsafe { CFShow(self.as_CFTypeRef()) }
}
- /// Returns true if this value is an instance of another type.
+ /// Returns `true` if this value is an instance of another type.
#[inline]
fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
@@ -318,9 +303,11 @@ impl<'a, T: PartialEq> PartialEq for ItemMutRef<'a, T> {
}
}
-/// A trait describing how to convert from the stored *mut c_void to the desired T
+/// A trait describing how to convert from the stored `*mut c_void` to the desired `T`
pub unsafe trait FromMutVoid {
- unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> where Self: std::marker::Sized;
+ unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self>
+ where
+ Self: std::marker::Sized;
}
unsafe impl FromMutVoid for u32 {
@@ -337,13 +324,18 @@ unsafe impl FromMutVoid for *const c_void {
unsafe impl<T: TCFType> FromMutVoid for T {
unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> {
- ItemMutRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData)
+ ItemMutRef(
+ ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))),
+ PhantomData,
+ )
}
}
-/// A trait describing how to convert from the stored *const c_void to the desired T
+/// A trait describing how to convert from the stored `*const c_void` to the desired `T`
pub unsafe trait FromVoid {
- unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> where Self: std::marker::Sized;
+ unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self>
+ where
+ Self: std::marker::Sized;
}
unsafe impl FromVoid for u32 {
@@ -362,11 +354,14 @@ unsafe impl FromVoid for *const c_void {
unsafe impl<T: TCFType> FromVoid for T {
unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> {
- ItemRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData)
+ ItemRef(
+ ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))),
+ PhantomData,
+ )
}
}
-/// A trait describing how to convert from the stored *const c_void to the desired T
+/// A trait describing how to convert from the stored `*const c_void` to the desired `T`
pub unsafe trait ToVoid<T> {
fn to_void(&self) -> *const c_void;
}
@@ -395,12 +390,11 @@ unsafe impl ToVoid<CFType> for CFTypeRef {
}
}
-
#[cfg(test)]
mod tests {
use super::*;
+ use crate::boolean::CFBoolean;
use std::mem;
- use boolean::CFBoolean;
#[test]
fn cftype_instance_of() {
@@ -413,7 +407,7 @@ mod tests {
#[test]
fn as_cftype_retain_count() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let cftype = string.as_CFType();
assert_eq!(cftype.retain_count(), 2);
@@ -423,7 +417,7 @@ mod tests {
#[test]
fn into_cftype_retain_count() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let cftype = string.into_CFType();
assert_eq!(cftype.retain_count(), 1);
@@ -431,10 +425,10 @@ mod tests {
#[test]
fn as_cftype_and_downcast() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
let cftype = string.as_CFType();
let string2 = cftype.downcast::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string.retain_count(), 3);
assert_eq!(cftype.retain_count(), 3);
@@ -443,10 +437,10 @@ mod tests {
#[test]
fn into_cftype_and_downcast_into() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
let cftype = string.into_CFType();
let string2 = cftype.downcast_into::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string2.retain_count(), 1);
}
}
diff --git a/third_party/rust/core-foundation/src/boolean.rs b/third_party/rust/core-foundation/src/boolean.rs
index 8c13b907da..e0e2ff762f 100644
--- a/third_party/rust/core-foundation/src/boolean.rs
+++ b/third_party/rust/core-foundation/src/boolean.rs
@@ -9,12 +9,13 @@
//! A Boolean type.
-pub use core_foundation_sys::number::{CFBooleanRef, CFBooleanGetTypeID, kCFBooleanTrue, kCFBooleanFalse};
+pub use core_foundation_sys::number::{
+ kCFBooleanFalse, kCFBooleanTrue, CFBooleanGetTypeID, CFBooleanRef,
+};
-use base::TCFType;
+use crate::base::TCFType;
-
-declare_TCFType!{
+declare_TCFType! {
/// A Boolean type.
///
/// FIXME(pcwalton): Should be a newtype struct, but that fails due to a Rust compiler bug.
@@ -25,15 +26,11 @@ impl_CFTypeDescription!(CFBoolean);
impl CFBoolean {
pub fn true_value() -> CFBoolean {
- unsafe {
- TCFType::wrap_under_get_rule(kCFBooleanTrue)
- }
+ unsafe { TCFType::wrap_under_get_rule(kCFBooleanTrue) }
}
pub fn false_value() -> CFBoolean {
- unsafe {
- TCFType::wrap_under_get_rule(kCFBooleanFalse)
- }
+ unsafe { TCFType::wrap_under_get_rule(kCFBooleanFalse) }
}
}
diff --git a/third_party/rust/core-foundation/src/bundle.rs b/third_party/rust/core-foundation/src/bundle.rs
index b9ab1f65f6..f6d53a991f 100644
--- a/third_party/rust/core-foundation/src/bundle.rs
+++ b/third_party/rust/core-foundation/src/bundle.rs
@@ -14,13 +14,13 @@ pub use core_foundation_sys::bundle::*;
use core_foundation_sys::url::kCFURLPOSIXPathStyle;
use std::path::PathBuf;
-use base::{CFType, TCFType};
-use url::CFURL;
-use dictionary::CFDictionary;
+use crate::base::{CFType, TCFType};
+use crate::dictionary::CFDictionary;
+use crate::string::CFString;
+use crate::url::CFURL;
use std::os::raw::c_void;
-use string::CFString;
-declare_TCFType!{
+declare_TCFType! {
/// A Bundle type.
CFBundle, CFBundleRef
}
@@ -51,8 +51,10 @@ impl CFBundle {
pub fn function_pointer_for_name(&self, function_name: CFString) -> *const c_void {
unsafe {
- CFBundleGetFunctionPointerForName(self.as_concrete_TypeRef(),
- function_name.as_concrete_TypeRef())
+ CFBundleGetFunctionPointerForName(
+ self.as_concrete_TypeRef(),
+ function_name.as_concrete_TypeRef(),
+ )
}
}
@@ -96,7 +98,9 @@ impl CFBundle {
/// Bundle's own location
pub fn path(&self) -> Option<PathBuf> {
let url = self.bundle_url()?;
- Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
+ Some(PathBuf::from(
+ url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
+ ))
}
/// Bundle's resources location
@@ -114,7 +118,9 @@ impl CFBundle {
/// Bundle's resources location
pub fn resources_path(&self) -> Option<PathBuf> {
let url = self.bundle_resources_url()?;
- Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
+ Some(PathBuf::from(
+ url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
+ ))
}
pub fn private_frameworks_url(&self) -> Option<CFURL> {
@@ -140,11 +146,10 @@ impl CFBundle {
}
}
-
#[test]
fn safari_executable_url() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/Applications/Safari.app");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
@@ -152,18 +157,20 @@ fn safari_executable_url() {
.expect("Safari not present")
.executable_url();
assert!(cfurl_executable.is_some());
- assert_eq!(cfurl_executable
- .unwrap()
- .absolute()
- .get_file_system_path(kCFURLPOSIXPathStyle)
- .to_string(),
- "/Applications/Safari.app/Contents/MacOS/Safari");
+ assert_eq!(
+ cfurl_executable
+ .unwrap()
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ "/Applications/Safari.app/Contents/MacOS/Safari"
+ );
}
#[test]
fn safari_private_frameworks_url() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/Applications/Safari.app");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
@@ -171,18 +178,20 @@ fn safari_private_frameworks_url() {
.expect("Safari not present")
.private_frameworks_url();
assert!(cfurl_executable.is_some());
- assert_eq!(cfurl_executable
- .unwrap()
- .absolute()
- .get_file_system_path(kCFURLPOSIXPathStyle)
- .to_string(),
- "/Applications/Safari.app/Contents/Frameworks");
+ assert_eq!(
+ cfurl_executable
+ .unwrap()
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ "/Applications/Safari.app/Contents/Frameworks"
+ );
}
#[test]
fn non_existant_bundle() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/usr/local/foo");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
diff --git a/third_party/rust/core-foundation/src/characterset.rs b/third_party/rust/core-foundation/src/characterset.rs
index d1b9439d6e..2a05a931d4 100644
--- a/third_party/rust/core-foundation/src/characterset.rs
+++ b/third_party/rust/core-foundation/src/characterset.rs
@@ -11,9 +11,9 @@
pub use core_foundation_sys::characterset::*;
-use base::TCFType;
+use crate::base::TCFType;
-declare_TCFType!{
+declare_TCFType! {
/// An immutable set of Unicde characters.
CFCharacterSet, CFCharacterSetRef
}
diff --git a/third_party/rust/core-foundation/src/data.rs b/third_party/rust/core-foundation/src/data.rs
index c510c7434d..9f952199aa 100644
--- a/third_party/rust/core-foundation/src/data.rs
+++ b/third_party/rust/core-foundation/src/data.rs
@@ -9,18 +9,16 @@
//! Core Foundation byte buffers.
-pub use core_foundation_sys::data::*;
+use core_foundation_sys::base::kCFAllocatorDefault;
use core_foundation_sys::base::CFIndex;
-use core_foundation_sys::base::{kCFAllocatorDefault};
+pub use core_foundation_sys::data::*;
use std::ops::Deref;
use std::slice;
use std::sync::Arc;
+use crate::base::{CFIndexConvertible, TCFType};
-use base::{CFIndexConvertible, TCFType};
-
-
-declare_TCFType!{
+declare_TCFType! {
/// A byte buffer.
CFData, CFDataRef
}
@@ -28,20 +26,22 @@ impl_TCFType!(CFData, CFDataRef, CFDataGetTypeID);
impl_CFTypeDescription!(CFData);
impl CFData {
- /// Creates a CFData around a copy `buffer`
+ /// Creates a [`CFData`] around a copy `buffer`
pub fn from_buffer(buffer: &[u8]) -> CFData {
unsafe {
- let data_ref = CFDataCreate(kCFAllocatorDefault,
- buffer.as_ptr(),
- buffer.len().to_CFIndex());
+ let data_ref = CFDataCreate(
+ kCFAllocatorDefault,
+ buffer.as_ptr(),
+ buffer.len().to_CFIndex(),
+ );
TCFType::wrap_under_create_rule(data_ref)
}
}
- /// Creates a CFData referencing `buffer` without creating a copy
+ /// Creates a [`CFData`] referencing `buffer` without creating a copy
pub fn from_arc<T: AsRef<[u8]> + Sync + Send>(buffer: Arc<T>) -> Self {
- use std::os::raw::c_void;
use crate::base::{CFAllocator, CFAllocatorContext};
+ use std::os::raw::c_void;
unsafe {
let ptr = (*buffer).as_ref().as_ptr() as *const _;
@@ -67,8 +67,12 @@ impl CFData {
deallocate: Some(deallocate::<T>),
preferredSize: None,
});
- let data_ref =
- CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, ptr, len, allocator.as_CFTypeRef());
+ let data_ref = CFDataCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ ptr,
+ len,
+ allocator.as_CFTypeRef(),
+ );
TCFType::wrap_under_create_rule(data_ref)
}
}
@@ -76,18 +80,20 @@ impl CFData {
/// Returns a pointer to the underlying bytes in this data. Note that this byte buffer is
/// read-only.
#[inline]
- pub fn bytes<'a>(&'a self) -> &'a [u8] {
- unsafe {
- slice::from_raw_parts(CFDataGetBytePtr(self.0), self.len() as usize)
- }
+ pub fn bytes(&self) -> &[u8] {
+ unsafe { slice::from_raw_parts(CFDataGetBytePtr(self.0), self.len() as usize) }
}
/// Returns the length of this byte buffer.
#[inline]
pub fn len(&self) -> CFIndex {
- unsafe {
- CFDataGetLength(self.0)
- }
+ unsafe { CFDataGetLength(self.0) }
+ }
+
+ /// Returns `true` if this byte buffer is empty.
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
}
}
@@ -133,7 +139,10 @@ mod test {
}
let dropped = Arc::new(AtomicBool::default());
- let l = Arc::new(VecWrapper {inner: vec![5], dropped: dropped.clone() });
+ let l = Arc::new(VecWrapper {
+ inner: vec![5],
+ dropped: dropped.clone(),
+ });
let m = l.clone();
let dp = CFData::from_arc(l);
drop(m);
diff --git a/third_party/rust/core-foundation/src/date.rs b/third_party/rust/core-foundation/src/date.rs
index 57ee7211e6..c27bad25d1 100644
--- a/third_party/rust/core-foundation/src/date.rs
+++ b/third_party/rust/core-foundation/src/date.rs
@@ -9,16 +9,15 @@
//! Core Foundation date objects.
-pub use core_foundation_sys::date::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::date::*;
-use base::TCFType;
+use crate::base::TCFType;
#[cfg(feature = "with-chrono")]
use chrono::NaiveDateTime;
-
-declare_TCFType!{
+declare_TCFType! {
/// A date.
CFDate, CFDateRef
}
@@ -42,16 +41,12 @@ impl CFDate {
#[inline]
pub fn abs_time(&self) -> CFAbsoluteTime {
- unsafe {
- CFDateGetAbsoluteTime(self.0)
- }
+ unsafe { CFDateGetAbsoluteTime(self.0) }
}
#[cfg(feature = "with-chrono")]
pub fn naive_utc(&self) -> NaiveDateTime {
- let ts = unsafe {
- self.abs_time() + kCFAbsoluteTimeIntervalSince1970
- };
+ let ts = unsafe { self.abs_time() + kCFAbsoluteTimeIntervalSince1970 };
let (secs, nanos) = if ts.is_sign_positive() {
(ts.trunc() as i64, ts.fract())
} else {
@@ -65,9 +60,7 @@ impl CFDate {
pub fn from_naive_utc(time: NaiveDateTime) -> CFDate {
let secs = time.timestamp();
let nanos = time.timestamp_subsec_nanos();
- let ts = unsafe {
- secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970
- };
+ let ts = unsafe { secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970 };
CFDate::new(ts)
}
}
@@ -86,7 +79,7 @@ mod test {
let same_sign = a.is_sign_positive() == b.is_sign_positive();
let equal = ((a - b).abs() / f64::min(a.abs() + b.abs(), f64::MAX)) < f64::EPSILON;
- (same_sign && equal)
+ same_sign && equal
}
#[test]
@@ -119,9 +112,7 @@ mod test {
fn date_chrono_conversion_negative() {
use super::kCFAbsoluteTimeIntervalSince1970;
- let ts = unsafe {
- kCFAbsoluteTimeIntervalSince1970 - 420.0
- };
+ let ts = unsafe { kCFAbsoluteTimeIntervalSince1970 - 420.0 };
let date = CFDate::new(ts);
let datetime: NaiveDateTime = date.naive_utc();
let converted = CFDate::from_naive_utc(datetime);
diff --git a/third_party/rust/core-foundation/src/dictionary.rs b/third_party/rust/core-foundation/src/dictionary.rs
index efcbba1178..aad37f3c81 100644
--- a/third_party/rust/core-foundation/src/dictionary.rs
+++ b/third_party/rust/core-foundation/src/dictionary.rs
@@ -11,18 +11,22 @@
pub use core_foundation_sys::dictionary::*;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
+use std::marker::PhantomData;
use std::mem;
use std::os::raw::c_void;
use std::ptr;
-use std::marker::PhantomData;
-use base::{ItemRef, FromVoid, ToVoid};
-use base::{CFIndexConvertible, TCFType};
-use ConcreteCFType;
+use crate::base::{CFIndexConvertible, TCFType};
+use crate::base::{FromVoid, ItemRef, ToVoid};
+use crate::ConcreteCFType;
// consume the type parameters with PhantomDatas
-pub struct CFDictionary<K = *const c_void, V = *const c_void>(CFDictionaryRef, PhantomData<K>, PhantomData<V>);
+pub struct CFDictionary<K = *const c_void, V = *const c_void>(
+ CFDictionaryRef,
+ PhantomData<K>,
+ PhantomData<V>,
+);
impl<K, V> Drop for CFDictionary<K, V> {
fn drop(&mut self) {
@@ -36,19 +40,25 @@ impl_CFTypeDescription!(CFDictionary<K, V>);
unsafe impl ConcreteCFType for CFDictionary<*const c_void, *const c_void> {}
impl<K, V> CFDictionary<K, V> {
- pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFDictionary<K, V> where K: TCFType, V: TCFType {
+ pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFDictionary<K, V>
+ where
+ K: TCFType,
+ V: TCFType,
+ {
let (keys, values): (Vec<CFTypeRef>, Vec<CFTypeRef>) = pairs
.iter()
- .map(|&(ref key, ref value)| (key.as_CFTypeRef(), value.as_CFTypeRef()))
+ .map(|(key, value)| (key.as_CFTypeRef(), value.as_CFTypeRef()))
.unzip();
unsafe {
- let dictionary_ref = CFDictionaryCreate(kCFAllocatorDefault,
- keys.as_ptr(),
- values.as_ptr(),
- keys.len().to_CFIndex(),
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
+ let dictionary_ref = CFDictionaryCreate(
+ kCFAllocatorDefault,
+ keys.as_ptr(),
+ values.as_ptr(),
+ keys.len().to_CFIndex(),
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks,
+ );
TCFType::wrap_under_create_rule(dictionary_ref)
}
}
@@ -76,9 +86,7 @@ impl<K, V> CFDictionary<K, V> {
#[inline]
pub fn len(&self) -> usize {
- unsafe {
- CFDictionaryGetCount(self.0) as usize
- }
+ unsafe { CFDictionaryGetCount(self.0) as usize }
}
#[inline]
@@ -87,12 +95,19 @@ impl<K, V> CFDictionary<K, V> {
}
#[inline]
- pub fn contains_key(&self, key: &K) -> bool where K: ToVoid<K> {
+ pub fn contains_key(&self, key: &K) -> bool
+ where
+ K: ToVoid<K>,
+ {
unsafe { CFDictionaryContainsKey(self.0, key.to_void()) != 0 }
}
#[inline]
- pub fn find<'a, T: ToVoid<K>>(&'a self, key: T) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid<K> {
+ pub fn find<T: ToVoid<K>>(&self, key: T) -> Option<ItemRef<'_, V>>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
unsafe {
let mut value: *const c_void = ptr::null();
if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 {
@@ -108,9 +123,14 @@ impl<K, V> CFDictionary<K, V> {
/// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead
/// of panicking.
#[inline]
- pub fn get<'a, T: ToVoid<K>>(&'a self, key: T) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid<K> {
+ pub fn get<T: ToVoid<K>>(&self, key: T) -> ItemRef<'_, V>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
let ptr = key.to_void();
- self.find(key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
+ self.find(key)
+ .unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
@@ -129,7 +149,11 @@ impl<K, V> CFDictionary<K, V> {
}
// consume the type parameters with PhantomDatas
-pub struct CFMutableDictionary<K = *const c_void, V = *const c_void>(CFMutableDictionaryRef, PhantomData<K>, PhantomData<V>);
+pub struct CFMutableDictionary<K = *const c_void, V = *const c_void>(
+ CFMutableDictionaryRef,
+ PhantomData<K>,
+ PhantomData<V>,
+);
impl<K, V> Drop for CFMutableDictionary<K, V> {
fn drop(&mut self) {
@@ -147,24 +171,31 @@ impl<K, V> CFMutableDictionary<K, V> {
pub fn with_capacity(capacity: isize) -> Self {
unsafe {
- let dictionary_ref = CFDictionaryCreateMutable(kCFAllocatorDefault,
- capacity as _,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
+ let dictionary_ref = CFDictionaryCreateMutable(
+ kCFAllocatorDefault,
+ capacity as _,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks,
+ );
TCFType::wrap_under_create_rule(dictionary_ref)
}
}
pub fn copy_with_capacity(&self, capacity: isize) -> Self {
unsafe {
- let dictionary_ref = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, capacity as _, self.0);
+ let dictionary_ref =
+ CFDictionaryCreateMutableCopy(kCFAllocatorDefault, capacity as _, self.0);
TCFType::wrap_under_get_rule(dictionary_ref)
}
}
- pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFMutableDictionary<K, V> where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFMutableDictionary<K, V>
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
let mut result = Self::with_capacity(pairs.len() as _);
- for &(ref key, ref value) in pairs {
+ for (key, value) in pairs {
result.add(key, value);
}
result
@@ -194,9 +225,7 @@ impl<K, V> CFMutableDictionary<K, V> {
#[inline]
pub fn len(&self) -> usize {
- unsafe {
- CFDictionaryGetCount(self.0) as usize
- }
+ unsafe { CFDictionaryGetCount(self.0) as usize }
}
#[inline]
@@ -206,13 +235,15 @@ impl<K, V> CFMutableDictionary<K, V> {
#[inline]
pub fn contains_key(&self, key: *const c_void) -> bool {
- unsafe {
- CFDictionaryContainsKey(self.0, key) != 0
- }
+ unsafe { CFDictionaryContainsKey(self.0, key) != 0 }
}
#[inline]
- pub fn find<'a>(&'a self, key: &K) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid<K> {
+ pub fn find<'a>(&'a self, key: &K) -> Option<ItemRef<'a, V>>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
unsafe {
let mut value: *const c_void = ptr::null();
if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 {
@@ -228,9 +259,14 @@ impl<K, V> CFMutableDictionary<K, V> {
/// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead
/// of panicking.
#[inline]
- pub fn get<'a>(&'a self, key: &K) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid<K> {
+ pub fn get<'a>(&'a self, key: &K) -> ItemRef<'a, V>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
let ptr = key.to_void();
- self.find(&key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
+ self.find(key)
+ .unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
@@ -251,25 +287,40 @@ impl<K, V> CFMutableDictionary<K, V> {
/// Adds the key-value pair to the dictionary if no such key already exist.
#[inline]
- pub fn add(&mut self, key: &K, value: &V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn add(&mut self, key: &K, value: &V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionaryAddValue(self.0, key.to_void(), value.to_void()) }
}
/// Sets the value of the key in the dictionary.
#[inline]
- pub fn set(&mut self, key: K, value: V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn set(&mut self, key: K, value: V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionarySetValue(self.0, key.to_void(), value.to_void()) }
}
/// Replaces the value of the key in the dictionary.
#[inline]
- pub fn replace(&mut self, key: K, value: V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn replace(&mut self, key: K, value: V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionaryReplaceValue(self.0, key.to_void(), value.to_void()) }
}
/// Removes the value of the key from the dictionary.
#[inline]
- pub fn remove(&mut self, key: K) where K: ToVoid<K> {
+ pub fn remove(&mut self, key: K)
+ where
+ K: ToVoid<K>,
+ {
unsafe { CFDictionaryRemoveValue(self.0, key.to_void()) }
}
@@ -296,15 +347,13 @@ impl<'a, K, V> From<&'a CFDictionary<K, V>> for CFMutableDictionary<K, V> {
}
}
-
#[cfg(test)]
pub mod test {
use super::*;
- use base::{CFType, TCFType};
- use boolean::CFBoolean;
- use number::CFNumber;
- use string::CFString;
-
+ use crate::base::{CFType, TCFType};
+ use crate::boolean::CFBoolean;
+ use crate::number::CFNumber;
+ use crate::string::CFString;
#[test]
fn dictionary() {
@@ -322,8 +371,14 @@ pub mod test {
]);
let (v1, v2) = d.get_keys_and_values();
- assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
- assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
+ assert_eq!(
+ v1,
+ &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]
+ );
+ assert_eq!(
+ v2,
+ &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]
+ );
}
#[test]
@@ -342,8 +397,14 @@ pub mod test {
assert_eq!(d.len(), 3);
let (v1, v2) = d.get_keys_and_values();
- assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
- assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
+ assert_eq!(
+ v1,
+ &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]
+ );
+ assert_eq!(
+ v2,
+ &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]
+ );
d.remove(baz);
assert_eq!(d.len(), 2);
@@ -358,12 +419,10 @@ pub mod test {
#[test]
fn dict_find_and_contains_key() {
- let dict = CFDictionary::from_CFType_pairs(&[
- (
- CFString::from_static_string("hello"),
- CFBoolean::true_value(),
- ),
- ]);
+ let dict = CFDictionary::from_CFType_pairs(&[(
+ CFString::from_static_string("hello"),
+ CFBoolean::true_value(),
+ )]);
let key = CFString::from_static_string("hello");
let invalid_key = CFString::from_static_string("foobar");
@@ -377,17 +436,24 @@ pub mod test {
#[test]
fn convert_immutable_to_mutable_dict() {
- let dict: CFDictionary<CFString, CFBoolean> = CFDictionary::from_CFType_pairs(&[
- (CFString::from_static_string("Foo"), CFBoolean::true_value()),
- ]);
+ let dict: CFDictionary<CFString, CFBoolean> = CFDictionary::from_CFType_pairs(&[(
+ CFString::from_static_string("Foo"),
+ CFBoolean::true_value(),
+ )]);
let mut mut_dict = CFMutableDictionary::from(&dict);
assert_eq!(dict.retain_count(), 1);
assert_eq!(mut_dict.retain_count(), 1);
assert_eq!(mut_dict.len(), 1);
- assert_eq!(*mut_dict.get(&CFString::from_static_string("Foo")), CFBoolean::true_value());
-
- mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value());
+ assert_eq!(
+ *mut_dict.get(&CFString::from_static_string("Foo")),
+ CFBoolean::true_value()
+ );
+
+ mut_dict.add(
+ &CFString::from_static_string("Bar"),
+ &CFBoolean::false_value(),
+ );
assert_eq!(dict.len(), 1);
assert_eq!(mut_dict.len(), 2);
}
@@ -395,13 +461,19 @@ pub mod test {
#[test]
fn mutable_dictionary_as_immutable() {
let mut mut_dict: CFMutableDictionary<CFString, CFBoolean> = CFMutableDictionary::new();
- mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value());
+ mut_dict.add(
+ &CFString::from_static_string("Bar"),
+ &CFBoolean::false_value(),
+ );
assert_eq!(mut_dict.retain_count(), 1);
let dict = mut_dict.to_immutable();
assert_eq!(mut_dict.retain_count(), 2);
assert_eq!(dict.retain_count(), 2);
- assert_eq!(*dict.get(&CFString::from_static_string("Bar")), CFBoolean::false_value());
+ assert_eq!(
+ *dict.get(&CFString::from_static_string("Bar")),
+ CFBoolean::false_value()
+ );
mem::drop(dict);
assert_eq!(mut_dict.retain_count(), 1);
diff --git a/third_party/rust/core-foundation/src/error.rs b/third_party/rust/core-foundation/src/error.rs
index f100171bc9..e5a2242596 100644
--- a/third_party/rust/core-foundation/src/error.rs
+++ b/third_party/rust/core-foundation/src/error.rs
@@ -14,11 +14,10 @@ pub use core_foundation_sys::error::*;
use std::error::Error;
use std::fmt;
-use base::{CFIndex, TCFType};
-use string::CFString;
+use crate::base::{CFIndex, TCFType};
+use crate::string::CFString;
-
-declare_TCFType!{
+declare_TCFType! {
/// An error value.
CFError, CFErrorRef
}
@@ -27,10 +26,10 @@ impl_TCFType!(CFError, CFErrorRef, CFErrorGetTypeID);
impl fmt::Debug for CFError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("CFError")
- .field("domain", &self.domain())
- .field("code", &self.code())
- .field("description", &self.description())
- .finish()
+ .field("domain", &self.domain())
+ .field("code", &self.code())
+ .field("description", &self.description())
+ .finish()
}
}
diff --git a/third_party/rust/core-foundation/src/filedescriptor.rs b/third_party/rust/core-foundation/src/filedescriptor.rs
index e153c70b2f..876d1cec0a 100644
--- a/third_party/rust/core-foundation/src/filedescriptor.rs
+++ b/third_party/rust/core-foundation/src/filedescriptor.rs
@@ -9,33 +9,41 @@
pub use core_foundation_sys::filedescriptor::*;
-use core_foundation_sys::base::{Boolean, CFIndex};
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
+use core_foundation_sys::base::{Boolean, CFIndex};
-use base::TCFType;
-use runloop::CFRunLoopSource;
+use crate::base::TCFType;
+use crate::runloop::CFRunLoopSource;
use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, RawFd};
use std::ptr;
-declare_TCFType!{
+declare_TCFType! {
CFFileDescriptor, CFFileDescriptorRef
}
-impl_TCFType!(CFFileDescriptor, CFFileDescriptorRef, CFFileDescriptorGetTypeID);
+impl_TCFType!(
+ CFFileDescriptor,
+ CFFileDescriptorRef,
+ CFFileDescriptorGetTypeID
+);
impl CFFileDescriptor {
- pub fn new(fd: RawFd,
- closeOnInvalidate: bool,
- callout: CFFileDescriptorCallBack,
- context: Option<&CFFileDescriptorContext>) -> Option<CFFileDescriptor> {
+ pub fn new(
+ fd: RawFd,
+ closeOnInvalidate: bool,
+ callout: CFFileDescriptorCallBack,
+ context: Option<&CFFileDescriptorContext>,
+ ) -> Option<CFFileDescriptor> {
let context = context.map_or(ptr::null(), |c| c as *const _);
unsafe {
- let fd_ref = CFFileDescriptorCreate(kCFAllocatorDefault,
- fd,
- closeOnInvalidate as Boolean,
- callout,
- context);
+ let fd_ref = CFFileDescriptorCreate(
+ kCFAllocatorDefault,
+ fd,
+ closeOnInvalidate as Boolean,
+ callout,
+ context,
+ );
if fd_ref.is_null() {
None
} else {
@@ -53,36 +61,25 @@ impl CFFileDescriptor {
}
pub fn enable_callbacks(&self, callback_types: CFOptionFlags) {
- unsafe {
- CFFileDescriptorEnableCallBacks(self.0, callback_types)
- }
+ unsafe { CFFileDescriptorEnableCallBacks(self.0, callback_types) }
}
pub fn disable_callbacks(&self, callback_types: CFOptionFlags) {
- unsafe {
- CFFileDescriptorDisableCallBacks(self.0, callback_types)
- }
+ unsafe { CFFileDescriptorDisableCallBacks(self.0, callback_types) }
}
pub fn valid(&self) -> bool {
- unsafe {
- CFFileDescriptorIsValid(self.0) != 0
- }
+ unsafe { CFFileDescriptorIsValid(self.0) != 0 }
}
pub fn invalidate(&self) {
- unsafe {
- CFFileDescriptorInvalidate(self.0)
- }
+ unsafe { CFFileDescriptorInvalidate(self.0) }
}
pub fn to_run_loop_source(&self, order: CFIndex) -> Option<CFRunLoopSource> {
unsafe {
- let source_ref = CFFileDescriptorCreateRunLoopSource(
- kCFAllocatorDefault,
- self.0,
- order
- );
+ let source_ref =
+ CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
if source_ref.is_null() {
None
} else {
@@ -94,24 +91,21 @@ impl CFFileDescriptor {
impl AsRawFd for CFFileDescriptor {
fn as_raw_fd(&self) -> RawFd {
- unsafe {
- CFFileDescriptorGetNativeDescriptor(self.0)
- }
+ unsafe { CFFileDescriptorGetNativeDescriptor(self.0) }
}
}
-
#[cfg(test)]
mod test {
extern crate libc;
use super::*;
+ use crate::runloop::CFRunLoop;
+ use core_foundation_sys::base::CFOptionFlags;
+ use core_foundation_sys::runloop::kCFRunLoopDefaultMode;
+ use libc::O_RDWR;
use std::ffi::CString;
use std::os::raw::c_void;
- use core_foundation_sys::base::{CFOptionFlags};
- use core_foundation_sys::runloop::{kCFRunLoopDefaultMode};
- use libc::O_RDWR;
- use runloop::{CFRunLoop};
#[test]
fn test_unconsumed() {
@@ -129,14 +123,16 @@ mod test {
assert_eq!(unsafe { libc::close(raw_fd) }, 0);
}
- extern "C" fn never_callback(_f: CFFileDescriptorRef,
- _callback_types: CFOptionFlags,
- _info_ptr: *mut c_void) {
+ extern "C" fn never_callback(
+ _f: CFFileDescriptorRef,
+ _callback_types: CFOptionFlags,
+ _info_ptr: *mut c_void,
+ ) {
unreachable!();
}
struct TestInfo {
- value: CFOptionFlags
+ value: CFOptionFlags,
}
#[test]
@@ -147,7 +143,7 @@ mod test {
info: &mut info as *mut _ as *mut c_void,
retain: None,
release: None,
- copyDescription: None
+ copyDescription: None,
};
let path = CString::new("/dev/null").unwrap();
@@ -182,7 +178,11 @@ mod test {
assert!(!cf_fd.valid());
}
- extern "C" fn callback(_f: CFFileDescriptorRef, callback_types: CFOptionFlags, info_ptr: *mut c_void) {
+ extern "C" fn callback(
+ _f: CFFileDescriptorRef,
+ callback_types: CFOptionFlags,
+ info_ptr: *mut c_void,
+ ) {
assert!(!info_ptr.is_null());
let info: *mut TestInfo = info_ptr as *mut TestInfo;
diff --git a/third_party/rust/core-foundation/src/lib.rs b/third_party/rust/core-foundation/src/lib.rs
index b935938996..767d45aad1 100644
--- a/third_party/rust/core-foundation/src/lib.rs
+++ b/third_party/rust/core-foundation/src/lib.rs
@@ -21,7 +21,7 @@ extern crate libc;
#[cfg(feature = "with-chrono")]
extern crate chrono;
-use base::TCFType;
+use crate::base::TCFType;
pub unsafe trait ConcreteCFType: TCFType {}
@@ -165,7 +165,6 @@ macro_rules! impl_TCFType {
(@Phantom $x:ident) => { ::std::marker::PhantomData };
}
-
/// Implement `std::fmt::Debug` for the given type.
///
/// This will invoke the implementation of `Debug` for [`CFType`]
@@ -200,7 +199,14 @@ macro_rules! impl_CFComparison {
#[inline]
fn partial_cmp(&self, other: &$ty) -> Option<::std::cmp::Ordering> {
unsafe {
- Some($compare(self.as_concrete_TypeRef(), other.as_concrete_TypeRef(), ::std::ptr::null_mut()).into())
+ Some(
+ $compare(
+ self.as_concrete_TypeRef(),
+ other.as_concrete_TypeRef(),
+ ::std::ptr::null_mut(),
+ )
+ .into(),
+ )
}
}
}
@@ -211,26 +217,26 @@ macro_rules! impl_CFComparison {
self.partial_cmp(other).unwrap()
}
}
- }
+ };
}
pub mod array;
pub mod attributed_string;
pub mod base;
pub mod boolean;
+pub mod bundle;
pub mod characterset;
pub mod data;
pub mod date;
pub mod dictionary;
pub mod error;
pub mod filedescriptor;
+pub mod mach_port;
pub mod number;
-pub mod set;
-pub mod string;
-pub mod url;
-pub mod bundle;
pub mod propertylist;
pub mod runloop;
+pub mod set;
+pub mod string;
pub mod timezone;
+pub mod url;
pub mod uuid;
-pub mod mach_port;
diff --git a/third_party/rust/core-foundation/src/mach_port.rs b/third_party/rust/core-foundation/src/mach_port.rs
index 6112e3aae0..f01847fff1 100644
--- a/third_party/rust/core-foundation/src/mach_port.rs
+++ b/third_party/rust/core-foundation/src/mach_port.rs
@@ -1,9 +1,8 @@
-use base::TCFType;
+use crate::base::TCFType;
+use crate::runloop::CFRunLoopSource;
use core_foundation_sys::base::kCFAllocatorDefault;
-use runloop::CFRunLoopSource;
pub use core_foundation_sys::mach_port::*;
-
declare_TCFType! {
/// An immutable numeric value.
CFMachPort, CFMachPortRef
@@ -12,12 +11,10 @@ impl_TCFType!(CFMachPort, CFMachPortRef, CFMachPortGetTypeID);
impl_CFTypeDescription!(CFMachPort);
impl CFMachPort {
- pub fn create_runloop_source(
- &self,
- order: CFIndex,
- ) -> Result<CFRunLoopSource, ()> {
+ pub fn create_runloop_source(&self, order: CFIndex) -> Result<CFRunLoopSource, ()> {
unsafe {
- let runloop_source_ref = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
+ let runloop_source_ref =
+ CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
if runloop_source_ref.is_null() {
Err(())
} else {
diff --git a/third_party/rust/core-foundation/src/number.rs b/third_party/rust/core-foundation/src/number.rs
index a4b2affaa7..c3b6fab96c 100644
--- a/third_party/rust/core-foundation/src/number.rs
+++ b/third_party/rust/core-foundation/src/number.rs
@@ -13,10 +13,9 @@ use core_foundation_sys::base::kCFAllocatorDefault;
pub use core_foundation_sys::number::*;
use std::os::raw::c_void;
-use base::TCFType;
+use crate::base::TCFType;
-
-declare_TCFType!{
+declare_TCFType! {
/// An immutable numeric value.
CFNumber, CFNumberRef
}
@@ -25,13 +24,20 @@ impl_CFTypeDescription!(CFNumber);
impl_CFComparison!(CFNumber, CFNumberCompare);
impl CFNumber {
-
#[inline]
pub fn to_i32(&self) -> Option<i32> {
unsafe {
let mut value: i32 = 0;
- let ok = CFNumberGetValue(self.0, kCFNumberSInt32Type, &mut value as *mut i32 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberSInt32Type,
+ &mut value as *mut i32 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -39,8 +45,16 @@ impl CFNumber {
pub fn to_i64(&self) -> Option<i64> {
unsafe {
let mut value: i64 = 0;
- let ok = CFNumberGetValue(self.0, kCFNumberSInt64Type, &mut value as *mut i64 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberSInt64Type,
+ &mut value as *mut i64 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -48,8 +62,16 @@ impl CFNumber {
pub fn to_f32(&self) -> Option<f32> {
unsafe {
let mut value: f32 = 0.0;
- let ok = CFNumberGetValue(self.0, kCFNumberFloat32Type, &mut value as *mut f32 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberFloat32Type,
+ &mut value as *mut f32 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -57,8 +79,16 @@ impl CFNumber {
pub fn to_f64(&self) -> Option<f64> {
unsafe {
let mut value: f64 = 0.0;
- let ok = CFNumberGetValue(self.0, kCFNumberFloat64Type, &mut value as *mut f64 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberFloat64Type,
+ &mut value as *mut f64 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
}
diff --git a/third_party/rust/core-foundation/src/propertylist.rs b/third_party/rust/core-foundation/src/propertylist.rs
index e8fceac58d..de5d1d87ba 100644
--- a/third_party/rust/core-foundation/src/propertylist.rs
+++ b/third_party/rust/core-foundation/src/propertylist.rs
@@ -9,30 +9,34 @@
//! Core Foundation property lists
-use std::ptr;
use std::mem;
use std::os::raw::c_void;
+use std::ptr;
-use error::CFError;
-use data::CFData;
-use base::{CFType, TCFType, TCFTypeRef};
+use crate::base::{CFType, TCFType, TCFTypeRef};
+use crate::data::CFData;
+use crate::error::CFError;
-pub use core_foundation_sys::propertylist::*;
+use core_foundation_sys::base::{
+ kCFAllocatorDefault, CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain, CFShow, CFTypeID,
+};
use core_foundation_sys::error::CFErrorRef;
-use core_foundation_sys::base::{CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain,
- CFShow, CFTypeID, kCFAllocatorDefault};
+pub use core_foundation_sys::propertylist::*;
-pub fn create_with_data(data: CFData,
- options: CFPropertyListMutabilityOptions)
- -> Result<(*const c_void, CFPropertyListFormat), CFError> {
+pub fn create_with_data(
+ data: CFData,
+ options: CFPropertyListMutabilityOptions,
+) -> Result<(*const c_void, CFPropertyListFormat), CFError> {
unsafe {
let mut error: CFErrorRef = ptr::null_mut();
let mut format: CFPropertyListFormat = 0;
- let property_list = CFPropertyListCreateWithData(kCFAllocatorDefault,
- data.as_concrete_TypeRef(),
- options,
- &mut format,
- &mut error);
+ let property_list = CFPropertyListCreateWithData(
+ kCFAllocatorDefault,
+ data.as_concrete_TypeRef(),
+ options,
+ &mut format,
+ &mut error,
+ );
if property_list.is_null() {
Err(TCFType::wrap_under_create_rule(error))
} else {
@@ -41,14 +45,14 @@ pub fn create_with_data(data: CFData,
}
}
-pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -> Result<CFData, CFError> {
+pub fn create_data(
+ property_list: *const c_void,
+ format: CFPropertyListFormat,
+) -> Result<CFData, CFError> {
unsafe {
let mut error: CFErrorRef = ptr::null_mut();
- let data_ref = CFPropertyListCreateData(kCFAllocatorDefault,
- property_list,
- format,
- 0,
- &mut error);
+ let data_ref =
+ CFPropertyListCreateData(kCFAllocatorDefault, property_list, format, 0, &mut error);
if data_ref.is_null() {
Err(TCFType::wrap_under_create_rule(error))
} else {
@@ -57,7 +61,6 @@ pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -
}
}
-
/// Trait for all subclasses of [`CFPropertyList`].
///
/// [`CFPropertyList`]: struct.CFPropertyList.html
@@ -84,16 +87,15 @@ pub trait CFPropertyListSubClass: TCFType {
}
}
-impl CFPropertyListSubClass for ::data::CFData {}
-impl CFPropertyListSubClass for ::string::CFString {}
-impl CFPropertyListSubClass for ::array::CFArray {}
-impl CFPropertyListSubClass for ::dictionary::CFDictionary {}
-impl CFPropertyListSubClass for ::date::CFDate {}
-impl CFPropertyListSubClass for ::boolean::CFBoolean {}
-impl CFPropertyListSubClass for ::number::CFNumber {}
-
+impl CFPropertyListSubClass for crate::data::CFData {}
+impl CFPropertyListSubClass for crate::string::CFString {}
+impl CFPropertyListSubClass for crate::array::CFArray {}
+impl CFPropertyListSubClass for crate::dictionary::CFDictionary {}
+impl CFPropertyListSubClass for crate::date::CFDate {}
+impl CFPropertyListSubClass for crate::boolean::CFBoolean {}
+impl CFPropertyListSubClass for crate::number::CFNumber {}
-declare_TCFType!{
+declare_TCFType! {
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
///
@@ -161,8 +163,8 @@ impl CFPropertyList {
unsafe { CFGetRetainCount(self.as_CFTypeRef()) }
}
- /// Returns the type ID of this object. Will be one of CFData, CFString, CFArray, CFDictionary,
- /// CFDate, CFBoolean, or CFNumber.
+ /// Returns the type ID of this object. Will be one of `CFData`, `CFString`, `CFArray`,
+ /// `CFDictionary`, `CFDate`, `CFBoolean`, or `CFNumber`.
#[inline]
pub fn type_of(&self) -> CFTypeID {
unsafe { CFGetTypeID(self.as_CFTypeRef()) }
@@ -173,7 +175,7 @@ impl CFPropertyList {
unsafe { CFShow(self.as_CFTypeRef()) }
}
- /// Returns true if this value is an instance of another type.
+ /// Returns `true` if this value is an instance of another type.
#[inline]
pub fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
@@ -244,33 +246,33 @@ impl CFPropertyList {
}
}
-
-
#[cfg(test)]
pub mod test {
use super::*;
- use string::CFString;
- use boolean::CFBoolean;
+ use crate::boolean::CFBoolean;
+ use crate::string::CFString;
#[test]
fn test_property_list_serialization() {
- use base::{TCFType, CFEqual};
- use boolean::CFBoolean;
- use number::CFNumber;
- use dictionary::CFDictionary;
- use string::CFString;
use super::*;
+ use crate::base::{CFEqual, TCFType};
+ use crate::boolean::CFBoolean;
+ use crate::dictionary::CFDictionary;
+ use crate::number::CFNumber;
+ use crate::string::CFString;
let bar = CFString::from_static_string("Bar");
let baz = CFString::from_static_string("Baz");
let boo = CFString::from_static_string("Boo");
let foo = CFString::from_static_string("Foo");
let tru = CFBoolean::true_value();
- let n42 = CFNumber::from(1i64<<33);
+ let n42 = CFNumber::from(1i64 << 33);
- let dict1 = CFDictionary::from_CFType_pairs(&[(bar.as_CFType(), boo.as_CFType()),
- (baz.as_CFType(), tru.as_CFType()),
- (foo.as_CFType(), n42.as_CFType())]);
+ let dict1 = CFDictionary::from_CFType_pairs(&[
+ (bar.as_CFType(), boo.as_CFType()),
+ (baz.as_CFType(), tru.as_CFType()),
+ (foo.as_CFType(), n42.as_CFType()),
+ ]);
let data = create_data(dict1.as_CFTypeRef(), kCFPropertyListXMLFormat_v1_0).unwrap();
let (dict2, _) = create_with_data(data, kCFPropertyListImmutable).unwrap();
@@ -281,7 +283,7 @@ pub mod test {
#[test]
fn to_propertylist_retain_count() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let propertylist = string.to_CFPropertyList();
@@ -295,7 +297,10 @@ pub mod test {
#[test]
fn downcast_string() {
let propertylist = CFString::from_static_string("Bar").to_CFPropertyList();
- assert_eq!(propertylist.downcast::<CFString>().unwrap().to_string(), "Bar");
+ assert_eq!(
+ propertylist.downcast::<CFString>().unwrap().to_string(),
+ "Bar"
+ );
assert!(propertylist.downcast::<CFBoolean>().is_none());
}
@@ -308,7 +313,7 @@ pub mod test {
#[test]
fn downcast_into_fail() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
@@ -318,12 +323,12 @@ pub mod test {
#[test]
fn downcast_into() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
let string2 = propertylist.downcast_into::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "Bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string2.retain_count(), 2);
}
}
diff --git a/third_party/rust/core-foundation/src/runloop.rs b/third_party/rust/core-foundation/src/runloop.rs
index be06f4ec7f..304c0716df 100644
--- a/third_party/rust/core-foundation/src/runloop.rs
+++ b/third_party/rust/core-foundation/src/runloop.rs
@@ -9,23 +9,26 @@
#![allow(non_upper_case_globals)]
-pub use core_foundation_sys::runloop::*;
use core_foundation_sys::base::CFIndex;
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
+pub use core_foundation_sys::runloop::*;
use core_foundation_sys::string::CFStringRef;
-use base::{TCFType};
-use date::{CFAbsoluteTime, CFTimeInterval};
-use filedescriptor::CFFileDescriptor;
-use string::{CFString};
+use crate::base::TCFType;
+use crate::date::{CFAbsoluteTime, CFTimeInterval};
+use crate::filedescriptor::CFFileDescriptor;
+use crate::string::CFString;
pub type CFRunLoopMode = CFStringRef;
-
declare_TCFType!(CFRunLoop, CFRunLoopRef);
impl_TCFType!(CFRunLoop, CFRunLoopRef, CFRunLoopGetTypeID);
impl_CFTypeDescription!(CFRunLoop);
+// https://github.com/servo/core-foundation-rs/issues/550
+unsafe impl Send for CFRunLoop {}
+unsafe impl Sync for CFRunLoop {}
+
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum CFRunLoopRunResult {
Finished = 1,
@@ -92,9 +95,7 @@ impl CFRunLoop {
}
pub fn contains_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsTimer(self.0, timer.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsTimer(self.0, timer.0, mode) != 0 }
}
pub fn add_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) {
@@ -110,9 +111,7 @@ impl CFRunLoop {
}
pub fn contains_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsSource(self.0, source.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsSource(self.0, source.0, mode) != 0 }
}
pub fn add_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) {
@@ -128,9 +127,7 @@ impl CFRunLoop {
}
pub fn contains_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsObserver(self.0, observer.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsObserver(self.0, observer.0, mode) != 0 }
}
pub fn add_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) {
@@ -144,25 +141,41 @@ impl CFRunLoop {
CFRunLoopRemoveObserver(self.0, observer.0, mode);
}
}
-
}
-
declare_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef);
impl_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef, CFRunLoopTimerGetTypeID);
impl CFRunLoopTimer {
- pub fn new(fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, callout: CFRunLoopTimerCallBack, context: *mut CFRunLoopTimerContext) -> CFRunLoopTimer {
+ pub fn new(
+ fireDate: CFAbsoluteTime,
+ interval: CFTimeInterval,
+ flags: CFOptionFlags,
+ order: CFIndex,
+ callout: CFRunLoopTimerCallBack,
+ context: *mut CFRunLoopTimerContext,
+ ) -> CFRunLoopTimer {
unsafe {
- let timer_ref = CFRunLoopTimerCreate(kCFAllocatorDefault, fireDate, interval, flags, order, callout, context);
+ let timer_ref = CFRunLoopTimerCreate(
+ kCFAllocatorDefault,
+ fireDate,
+ interval,
+ flags,
+ order,
+ callout,
+ context,
+ );
TCFType::wrap_under_create_rule(timer_ref)
}
}
}
-
declare_TCFType!(CFRunLoopSource, CFRunLoopSourceRef);
-impl_TCFType!(CFRunLoopSource, CFRunLoopSourceRef, CFRunLoopSourceGetTypeID);
+impl_TCFType!(
+ CFRunLoopSource,
+ CFRunLoopSourceRef,
+ CFRunLoopSourceGetTypeID
+);
impl CFRunLoopSource {
pub fn from_file_descriptor(fd: &CFFileDescriptor, order: CFIndex) -> Option<CFRunLoopSource> {
@@ -171,15 +184,23 @@ impl CFRunLoopSource {
}
declare_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef);
-impl_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef, CFRunLoopObserverGetTypeID);
+impl_TCFType!(
+ CFRunLoopObserver,
+ CFRunLoopObserverRef,
+ CFRunLoopObserverGetTypeID
+);
#[cfg(test)]
mod test {
use super::*;
- use date::{CFDate, CFAbsoluteTime};
+ use crate::base::Boolean;
+ use crate::date::{CFAbsoluteTime, CFDate};
use std::mem;
use std::os::raw::c_void;
+ use std::ptr::null_mut;
use std::sync::mpsc;
+ use std::thread::spawn;
+ use std::time::Duration;
#[test]
fn wait_200_milliseconds() {
@@ -199,7 +220,8 @@ mod test {
copyDescription: None,
};
- let run_loop_timer = CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context);
+ let run_loop_timer =
+ CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context);
unsafe {
run_loop.add_timer(&run_loop_timer, kCFRunLoopDefaultMode);
}
@@ -221,4 +243,62 @@ mod test {
let _ = unsafe { (*info).elapsed_tx.send(elapsed) };
CFRunLoop::get_current().stop();
}
+
+ extern "C" fn observe(_: CFRunLoopObserverRef, _: CFRunLoopActivity, context: *mut c_void) {
+ let tx: &mpsc::Sender<CFRunLoop> = unsafe { &*(context as *const _) };
+ let _ = tx.send(CFRunLoop::get_current());
+ }
+
+ extern "C" fn observe_timer_popped(_: CFRunLoopTimerRef, _: *mut c_void) {
+ panic!("timer popped unexpectedly");
+ }
+
+ #[test]
+ fn observe_runloop() {
+ let (tx, rx) = mpsc::channel();
+ spawn(move || {
+ let mut context = CFRunLoopObserverContext {
+ version: 0,
+ info: &tx as *const _ as *mut c_void,
+ retain: None,
+ release: None,
+ copyDescription: None,
+ };
+
+ let observer = unsafe {
+ CFRunLoopObserver::wrap_under_create_rule(CFRunLoopObserverCreate(
+ kCFAllocatorDefault,
+ kCFRunLoopEntry,
+ false as Boolean,
+ 0,
+ observe,
+ &mut context,
+ ))
+ };
+
+ let runloop = CFRunLoop::get_current();
+ runloop.add_observer(&observer, unsafe { kCFRunLoopDefaultMode });
+
+ let timer = CFRunLoopTimer::new(
+ CFDate::now().abs_time() + 1f64,
+ 0f64,
+ 0,
+ 0,
+ observe_timer_popped,
+ null_mut(),
+ );
+ runloop.add_timer(&timer, unsafe { kCFRunLoopDefaultMode });
+
+ let result = unsafe {
+ CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, Duration::from_secs(10), false)
+ };
+
+ assert_eq!(result, CFRunLoopRunResult::Stopped);
+
+ drop(tx);
+ });
+
+ let runloop: CFRunLoop = rx.recv().unwrap();
+ runloop.stop();
+ }
}
diff --git a/third_party/rust/core-foundation/src/set.rs b/third_party/rust/core-foundation/src/set.rs
index eb1d357a03..641202de8d 100644
--- a/third_party/rust/core-foundation/src/set.rs
+++ b/third_party/rust/core-foundation/src/set.rs
@@ -9,13 +9,13 @@
//! An immutable bag of elements.
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
pub use core_foundation_sys::set::*;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
-use base::{CFIndexConvertible, TCFType};
+use crate::base::{CFIndexConvertible, TCFType};
-use std::os::raw::c_void;
use std::marker::PhantomData;
+use std::os::raw::c_void;
/// An immutable bag of elements.
pub struct CFSet<T = *const c_void>(CFSetRef, PhantomData<T>);
@@ -31,23 +31,31 @@ impl_CFTypeDescription!(CFSet);
impl CFSet {
/// Creates a new set from a list of `CFType` instances.
- pub fn from_slice<T>(elems: &[T]) -> CFSet<T> where T: TCFType {
+ pub fn from_slice<T>(elems: &[T]) -> CFSet<T>
+ where
+ T: TCFType,
+ {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
- let set_ref = CFSetCreate(kCFAllocatorDefault,
- elems.as_ptr(),
- elems.len().to_CFIndex(),
- &kCFTypeSetCallBacks);
+ let set_ref = CFSetCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr(),
+ elems.len().to_CFIndex(),
+ &kCFTypeSetCallBacks,
+ );
TCFType::wrap_under_create_rule(set_ref)
}
}
}
impl<T> CFSet<T> {
- /// Get the number of elements in the CFSet
+ /// Get the number of elements in the `CFSet`.
pub fn len(&self) -> usize {
- unsafe {
- CFSetGetCount(self.0) as usize
- }
+ unsafe { CFSetGetCount(self.0) as usize }
+ }
+
+ /// Returns `true` if the set contains no elements.
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
}
}
diff --git a/third_party/rust/core-foundation/src/string.rs b/third_party/rust/core-foundation/src/string.rs
index 3f5994bc5a..3358bab552 100644
--- a/third_party/rust/core-foundation/src/string.rs
+++ b/third_party/rust/core-foundation/src/string.rs
@@ -11,18 +11,17 @@
pub use core_foundation_sys::string::*;
-use base::{CFIndexConvertible, TCFType};
+use crate::base::{CFIndexConvertible, TCFType};
-use core_foundation_sys::base::{Boolean, CFIndex, CFRange};
use core_foundation_sys::base::{kCFAllocatorDefault, kCFAllocatorNull};
+use core_foundation_sys::base::{Boolean, CFIndex, CFRange};
use std::borrow::Cow;
+use std::ffi::CStr;
use std::fmt;
-use std::str::{self, FromStr};
use std::ptr;
-use std::ffi::CStr;
-
+use std::str::{self, FromStr};
-declare_TCFType!{
+declare_TCFType! {
/// An immutable string in one of a variety of encodings.
CFString, CFStringRef
}
@@ -31,7 +30,7 @@ impl_TCFType!(CFString, CFStringRef, CFStringGetTypeID);
impl FromStr for CFString {
type Err = ();
- /// See also CFString::new for a variant of this which does not return a Result
+ /// See also [`CFString::new()`] for a variant of this which does not return a `Result`.
#[inline]
fn from_str(string: &str) -> Result<CFString, ()> {
Ok(CFString::new(string))
@@ -58,27 +57,37 @@ impl<'a> From<&'a CFString> for Cow<'a, str> {
// First, ask how big the buffer ought to be.
let mut bytes_required: CFIndex = 0;
- CFStringGetBytes(cf_str.0,
- CFRange { location: 0, length: char_len },
- kCFStringEncodingUTF8,
- 0,
- false as Boolean,
- ptr::null_mut(),
- 0,
- &mut bytes_required);
+ CFStringGetBytes(
+ cf_str.0,
+ CFRange {
+ location: 0,
+ length: char_len,
+ },
+ kCFStringEncodingUTF8,
+ 0,
+ false as Boolean,
+ ptr::null_mut(),
+ 0,
+ &mut bytes_required,
+ );
// Then, allocate the buffer and actually copy.
let mut buffer = vec![b'\x00'; bytes_required as usize];
let mut bytes_used: CFIndex = 0;
- let chars_written = CFStringGetBytes(cf_str.0,
- CFRange { location: 0, length: char_len },
- kCFStringEncodingUTF8,
- 0,
- false as Boolean,
- buffer.as_mut_ptr(),
- buffer.len().to_CFIndex(),
- &mut bytes_used);
+ let chars_written = CFStringGetBytes(
+ cf_str.0,
+ CFRange {
+ location: 0,
+ length: char_len,
+ },
+ kCFStringEncodingUTF8,
+ 0,
+ false as Boolean,
+ buffer.as_mut_ptr(),
+ buffer.len().to_CFIndex(),
+ &mut bytes_used,
+ );
assert_eq!(chars_written, char_len);
// This is dangerous; we over-allocate and null-terminate the string (during
@@ -102,17 +111,18 @@ impl fmt::Debug for CFString {
}
}
-
impl CFString {
/// Creates a new `CFString` instance from a Rust string.
#[inline]
pub fn new(string: &str) -> CFString {
unsafe {
- let string_ref = CFStringCreateWithBytes(kCFAllocatorDefault,
- string.as_ptr(),
- string.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean);
+ let string_ref = CFStringCreateWithBytes(
+ kCFAllocatorDefault,
+ string.as_ptr(),
+ string.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ );
CFString::wrap_under_create_rule(string_ref)
}
}
@@ -122,12 +132,14 @@ impl CFString {
#[inline]
pub fn from_static_string(string: &'static str) -> CFString {
unsafe {
- let string_ref = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
- string.as_ptr(),
- string.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean,
- kCFAllocatorNull);
+ let string_ref = CFStringCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ string.as_ptr(),
+ string.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ kCFAllocatorNull,
+ );
TCFType::wrap_under_create_rule(string_ref)
}
}
@@ -135,21 +147,21 @@ impl CFString {
/// Returns the number of characters in the string.
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFStringGetLength(self.0)
- }
+ unsafe { CFStringGetLength(self.0) }
}
}
impl<'a> PartialEq<&'a str> for CFString {
fn eq(&self, other: &&str) -> bool {
unsafe {
- let temp = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
- other.as_ptr(),
- other.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean,
- kCFAllocatorNull);
+ let temp = CFStringCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ other.as_ptr(),
+ other.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ kCFAllocatorNull,
+ );
self.eq(&CFString::wrap_under_create_rule(temp))
}
}
diff --git a/third_party/rust/core-foundation/src/timezone.rs b/third_party/rust/core-foundation/src/timezone.rs
index a8bb2ed1d2..46123dcc22 100644
--- a/third_party/rust/core-foundation/src/timezone.rs
+++ b/third_party/rust/core-foundation/src/timezone.rs
@@ -9,18 +9,17 @@
//! Core Foundation time zone objects.
-pub use core_foundation_sys::timezone::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::timezone::*;
-use base::TCFType;
-use date::{CFDate, CFTimeInterval};
-use string::CFString;
+use crate::base::TCFType;
+use crate::date::{CFDate, CFTimeInterval};
+use crate::string::CFString;
#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};
-
-declare_TCFType!{
+declare_TCFType! {
/// A time zone.
CFTimeZone, CFTimeZoneRef
}
@@ -54,9 +53,7 @@ impl CFTimeZone {
}
pub fn seconds_from_gmt(&self, date: CFDate) -> CFTimeInterval {
- unsafe {
- CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time())
- }
+ unsafe { CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time()) }
}
#[cfg(feature = "with-chrono")]
@@ -70,12 +67,10 @@ impl CFTimeZone {
CFTimeZone::new(offset.local_minus_utc() as f64)
}
- /// The timezone database ID that identifies the time zone. E.g. "America/Los_Angeles" or
- /// "Europe/Paris".
+ /// The timezone database ID that identifies the time zone. E.g. `"America/Los_Angeles" `or
+ /// `"Europe/Paris"`.
pub fn name(&self) -> CFString {
- unsafe {
- CFString::wrap_under_get_rule(CFTimeZoneGetName(self.0))
- }
+ unsafe { CFString::wrap_under_get_rule(CFTimeZoneGetName(self.0)) }
}
}
@@ -84,7 +79,7 @@ mod test {
use super::CFTimeZone;
#[cfg(feature = "with-chrono")]
- use chrono::{NaiveDateTime, FixedOffset};
+ use chrono::{FixedOffset, NaiveDateTime};
#[test]
fn timezone_comparison() {
diff --git a/third_party/rust/core-foundation/src/url.rs b/third_party/rust/core-foundation/src/url.rs
index 064dd7b5e0..b929844385 100644
--- a/third_party/rust/core-foundation/src/url.rs
+++ b/third_party/rust/core-foundation/src/url.rs
@@ -11,21 +11,20 @@
pub use core_foundation_sys::url::*;
-use base::{TCFType, CFIndex};
-use string::{CFString};
+use crate::base::{CFIndex, TCFType};
+use crate::string::CFString;
use core_foundation_sys::base::{kCFAllocatorDefault, Boolean};
use std::fmt;
-use std::ptr;
use std::path::{Path, PathBuf};
+use std::ptr;
use libc::{c_char, strlen, PATH_MAX};
#[cfg(unix)]
-use std::os::unix::ffi::OsStrExt;
-#[cfg(unix)]
use std::ffi::OsStr;
-
+#[cfg(unix)]
+use std::os::unix::ffi::OsStrExt;
declare_TCFType!(CFURL, CFURLRef);
impl_TCFType!(CFURL, CFURLRef, CFURLGetTypeID);
@@ -35,7 +34,7 @@ impl fmt::Debug for CFURL {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
unsafe {
let string: CFString = TCFType::wrap_under_get_rule(CFURLGetString(self.0));
- write!(f, "{}", string.to_string())
+ write!(f, "{}", string)
}
}
}
@@ -58,7 +57,12 @@ impl CFURL {
}
unsafe {
- let url_ref = CFURLCreateFromFileSystemRepresentation(ptr::null_mut(), path_bytes.as_ptr(), path_bytes.len() as CFIndex, isDirectory as u8);
+ let url_ref = CFURLCreateFromFileSystemRepresentation(
+ ptr::null_mut(),
+ path_bytes.as_ptr(),
+ path_bytes.len() as CFIndex,
+ isDirectory as u8,
+ );
if url_ref.is_null() {
return None;
}
@@ -66,9 +70,18 @@ impl CFURL {
}
}
- pub fn from_file_system_path(filePath: CFString, pathStyle: CFURLPathStyle, isDirectory: bool) -> CFURL {
+ pub fn from_file_system_path(
+ filePath: CFString,
+ pathStyle: CFURLPathStyle,
+ isDirectory: bool,
+ ) -> CFURL {
unsafe {
- let url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, filePath.as_concrete_TypeRef(), pathStyle, isDirectory as u8);
+ let url_ref = CFURLCreateWithFileSystemPath(
+ kCFAllocatorDefault,
+ filePath.as_concrete_TypeRef(),
+ pathStyle,
+ isDirectory as u8,
+ );
TCFType::wrap_under_create_rule(url_ref)
}
}
@@ -78,7 +91,12 @@ impl CFURL {
// implementing this on Windows is more complicated because of the different OsStr representation
unsafe {
let mut buf = [0u8; PATH_MAX as usize];
- let result = CFURLGetFileSystemRepresentation(self.0, true as Boolean, buf.as_mut_ptr(), buf.len() as CFIndex);
+ let result = CFURLGetFileSystemRepresentation(
+ self.0,
+ true as Boolean,
+ buf.as_mut_ptr(),
+ buf.len() as CFIndex,
+ );
if result == false as Boolean {
return None;
}
@@ -89,21 +107,20 @@ impl CFURL {
}
pub fn get_string(&self) -> CFString {
- unsafe {
- TCFType::wrap_under_get_rule(CFURLGetString(self.0))
- }
+ unsafe { TCFType::wrap_under_get_rule(CFURLGetString(self.0)) }
}
pub fn get_file_system_path(&self, pathStyle: CFURLPathStyle) -> CFString {
unsafe {
- TCFType::wrap_under_create_rule(CFURLCopyFileSystemPath(self.as_concrete_TypeRef(), pathStyle))
+ TCFType::wrap_under_create_rule(CFURLCopyFileSystemPath(
+ self.as_concrete_TypeRef(),
+ pathStyle,
+ ))
}
}
pub fn absolute(&self) -> CFURL {
- unsafe {
- TCFType::wrap_under_create_rule(CFURLCopyAbsoluteURL(self.as_concrete_TypeRef()))
- }
+ unsafe { TCFType::wrap_under_create_rule(CFURLCopyAbsoluteURL(self.as_concrete_TypeRef())) }
}
}
@@ -138,18 +155,30 @@ fn absolute_file_url() {
let cfstr_file = CFString::from_static_string(file);
let cfurl_base = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
let cfurl_relative: CFURL = unsafe {
- let url_ref = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorDefault,
+ let url_ref = CFURLCreateWithFileSystemPathRelativeToBase(
+ kCFAllocatorDefault,
cfstr_file.as_concrete_TypeRef(),
kCFURLPOSIXPathStyle,
false as u8,
- cfurl_base.as_concrete_TypeRef());
+ cfurl_base.as_concrete_TypeRef(),
+ );
TCFType::wrap_under_create_rule(url_ref)
};
let mut absolute_path = PathBuf::from(path);
absolute_path.push(file);
- assert_eq!(cfurl_relative.get_file_system_path(kCFURLPOSIXPathStyle).to_string(), file);
- assert_eq!(cfurl_relative.absolute().get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
- absolute_path.to_str().unwrap());
+ assert_eq!(
+ cfurl_relative
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ file
+ );
+ assert_eq!(
+ cfurl_relative
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ absolute_path.to_str().unwrap()
+ );
}
diff --git a/third_party/rust/core-foundation/src/uuid.rs b/third_party/rust/core-foundation/src/uuid.rs
index 6be734dabc..834a6dd9d2 100644
--- a/third_party/rust/core-foundation/src/uuid.rs
+++ b/third_party/rust/core-foundation/src/uuid.rs
@@ -12,15 +12,14 @@
#[cfg(feature = "with-uuid")]
extern crate uuid;
-pub use core_foundation_sys::uuid::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::uuid::*;
-use base::TCFType;
+use crate::base::TCFType;
#[cfg(feature = "with-uuid")]
use self::uuid::Uuid;
-
declare_TCFType! {
/// A UUID.
CFUUID, CFUUIDRef
@@ -45,28 +44,12 @@ impl Default for CFUUID {
}
#[cfg(feature = "with-uuid")]
-impl Into<Uuid> for CFUUID {
- fn into(self) -> Uuid {
- let b = unsafe {
- CFUUIDGetUUIDBytes(self.0)
- };
+impl From<CFUUID> for Uuid {
+ fn from(val: CFUUID) -> Self {
+ let b = unsafe { CFUUIDGetUUIDBytes(val.0) };
let bytes = [
- b.byte0,
- b.byte1,
- b.byte2,
- b.byte3,
- b.byte4,
- b.byte5,
- b.byte6,
- b.byte7,
- b.byte8,
- b.byte9,
- b.byte10,
- b.byte11,
- b.byte12,
- b.byte13,
- b.byte14,
- b.byte15,
+ b.byte0, b.byte1, b.byte2, b.byte3, b.byte4, b.byte5, b.byte6, b.byte7, b.byte8,
+ b.byte9, b.byte10, b.byte11, b.byte12, b.byte13, b.byte14, b.byte15,
];
Uuid::from_bytes(&bytes).unwrap()
}
@@ -101,7 +84,6 @@ impl From<Uuid> for CFUUID {
}
}
-
#[cfg(test)]
#[cfg(feature = "with-uuid")]
mod test {