зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1891754 - Update `wgpu` to revision 2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089. r=webgpu-reviewers,supply-chain-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D207728
This commit is contained in:
Родитель
fffdabc06e
Коммит
726489bed8
|
@ -25,9 +25,14 @@ git = "https://github.com/franziskuskiefer/cose-rust"
|
|||
rev = "43c22248d136c8b38fe42ea709d08da6355cf04b"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4"]
|
||||
[source."git+https://github.com/gfx-rs/metal-rs?rev=ff8fd3d6dc7792852f8a015458d7e6d42d7fb352"]
|
||||
git = "https://github.com/gfx-rs/metal-rs"
|
||||
rev = "ff8fd3d6dc7792852f8a015458d7e6d42d7fb352"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"]
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/glandium/mio?rev=9a2ef335c366044ffe73b1c4acabe50a1daefe05"]
|
||||
|
|
|
@ -43,7 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ce34de545ad29bcc00cb1b87a94c132256dcf83aa7eeb9674482568405a6ff0a"
|
||||
dependencies = [
|
||||
"alsa-sys",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"libc",
|
||||
"nix 0.26.99",
|
||||
]
|
||||
|
@ -427,7 +427,7 @@ version = "0.69.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
|
@ -460,14 +460,14 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
|||
name = "bitflags"
|
||||
version = "1.999.999"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -839,9 +839,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.3"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
|
||||
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
|
@ -849,9 +849,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.3"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
|
@ -868,9 +868,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-graphics-types"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33"
|
||||
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
|
||||
dependencies = [
|
||||
"bitflags 1.999.999",
|
||||
"core-foundation",
|
||||
|
@ -1160,7 +1160,7 @@ source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=7b1021714989bede
|
|||
dependencies = [
|
||||
"atomic",
|
||||
"audio-mixer",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"coreaudio-sys-utils",
|
||||
"cubeb-backend",
|
||||
"float-cmp",
|
||||
|
@ -1196,9 +1196,9 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "d3d12"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4#0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089#2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"libloading",
|
||||
"winapi",
|
||||
]
|
||||
|
@ -1491,7 +1491,7 @@ dependencies = [
|
|||
name = "dom"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2488,7 +2488,7 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"gpu-alloc-types",
|
||||
]
|
||||
|
||||
|
@ -2498,7 +2498,7 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3546,10 +3546,9 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "metal"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25"
|
||||
source = "git+https://github.com/gfx-rs/metal-rs?rev=ff8fd3d6dc7792852f8a015458d7e6d42d7fb352#ff8fd3d6dc7792852f8a015458d7e6d42d7fb352"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"core-graphics-types",
|
||||
"foreign-types",
|
||||
|
@ -3614,7 +3613,7 @@ version = "0.19.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dbc11dfb55b3b7b5684fb16d98e0fc9d1e93a64d6b00bf383eabfc4541aaac2"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"debugid",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
|
@ -3629,7 +3628,7 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "017101620fe5d413ac2d98224ab8b1fff0d4bacaf2803c130ad4a6db3e5d3e70"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"byteorder",
|
||||
"cfg-if 1.0.0",
|
||||
"crash-context",
|
||||
|
@ -3794,7 +3793,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"arrayvec",
|
||||
"bindgen 0.69.4",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"bytes",
|
||||
"cc",
|
||||
"chrono",
|
||||
|
@ -3927,12 +3926,12 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
|
|||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4#0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
version = "0.19.2"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089#2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"codespan-reporting",
|
||||
"hexf-parse",
|
||||
"indexmap 2.999.999",
|
||||
|
@ -4077,7 +4076,7 @@ version = "0.27.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
]
|
||||
|
@ -4137,7 +4136,7 @@ source = "git+https://github.com/mozilla/application-services?rev=e6ccfed09ebe66
|
|||
name = "nsstring"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"encoding_rs",
|
||||
]
|
||||
|
||||
|
@ -4196,16 +4195,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
||||
dependencies = [
|
||||
"malloc_buf",
|
||||
"objc_exception",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc_exception"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4600,7 +4589,7 @@ version = "0.16.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"hex",
|
||||
]
|
||||
|
||||
|
@ -4657,7 +4646,7 @@ name = "pulse"
|
|||
version = "0.3.0"
|
||||
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367#8ff972c8e2ec1782ff262ac4071c0415e69b1367"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"pulse-ffi",
|
||||
]
|
||||
|
||||
|
@ -4875,7 +4864,7 @@ checksum = "2c6d906922d99c677624d2042a93f89b2b7df0f6411032237d5d99a602c2487c"
|
|||
dependencies = [
|
||||
"arrayref",
|
||||
"bincode",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"byteorder",
|
||||
"id-arena",
|
||||
"lazy_static",
|
||||
|
@ -4897,7 +4886,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||
dependencies = [
|
||||
"base64 0.21.3",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
]
|
||||
|
@ -4940,7 +4929,7 @@ version = "0.30.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a78046161564f5e7cd9008aff3b2990b3850dc8e0349119b98e8f251e099f24d"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"fallible-iterator",
|
||||
"fallible-streaming-iterator",
|
||||
"hashlink",
|
||||
|
@ -5015,7 +5004,7 @@ version = "0.38.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
|
@ -5086,7 +5075,7 @@ dependencies = [
|
|||
name = "selectors"
|
||||
version = "0.22.0"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"cssparser",
|
||||
"derive_more 0.99.999",
|
||||
"fxhash",
|
||||
|
@ -5362,7 +5351,7 @@ version = "0.3.0+sdk-1.3.268.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5451,7 +5440,7 @@ dependencies = [
|
|||
"arrayvec",
|
||||
"atomic_refcell",
|
||||
"bindgen 0.69.4",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"byteorder",
|
||||
"cssparser",
|
||||
"derive_more 0.99.999",
|
||||
|
@ -5518,7 +5507,7 @@ name = "style_traits"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"app_units",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"cssparser",
|
||||
"euclid",
|
||||
"lazy_static",
|
||||
|
@ -6511,7 +6500,7 @@ name = "webrender"
|
|||
version = "0.62.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"build-parallel",
|
||||
"byteorder",
|
||||
"derive_more 0.99.999",
|
||||
|
@ -6548,7 +6537,7 @@ name = "webrender_api"
|
|||
version = "0.62.0"
|
||||
dependencies = [
|
||||
"app_units",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"byteorder",
|
||||
"crossbeam-channel",
|
||||
"euclid",
|
||||
|
@ -6595,7 +6584,7 @@ dependencies = [
|
|||
name = "webrender_build"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
]
|
||||
|
@ -6621,12 +6610,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4#0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
version = "0.19.3"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089#2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"cfg_aliases",
|
||||
"codespan-reporting",
|
||||
"document-features",
|
||||
|
@ -6648,14 +6637,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4#0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
version = "0.19.3"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089#2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
"ash",
|
||||
"bit-set",
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"cfg_aliases",
|
||||
"core-graphics-types",
|
||||
|
@ -6687,10 +6676,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=0c5bebca514eb06d9387f87666c1c658f3f673b4#0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
version = "0.19.2"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089#2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"bitflags 2.5.0",
|
||||
"js-sys",
|
||||
"serde",
|
||||
"web-sys",
|
||||
|
|
|
@ -17,7 +17,7 @@ default = []
|
|||
[dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
# TODO: remove the replay feature on the next update containing https://github.com/gfx-rs/wgpu/pull/5182
|
||||
features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"]
|
||||
|
||||
|
@ -26,37 +26,37 @@ features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"
|
|||
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
features = ["metal"]
|
||||
|
||||
# We want the wgpu-core Direct3D backends on Windows.
|
||||
[target.'cfg(windows)'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
features = ["dx12"]
|
||||
|
||||
# We want the wgpu-core Vulkan backend on Linux and Windows.
|
||||
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
features = ["vulkan"]
|
||||
|
||||
[dependencies.wgt]
|
||||
package = "wgpu-types"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
|
||||
[dependencies.wgh]
|
||||
package = "wgpu-hal"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
features = ["windows_rs", "oom_panic", "device_lost_panic", "internal_error_panic"]
|
||||
|
||||
[target.'cfg(windows)'.dependencies.d3d12]
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
rev = "2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.3"
|
||||
|
|
|
@ -20,11 +20,11 @@ origin:
|
|||
|
||||
# Human-readable identifier for this version/release
|
||||
# Generally "version NNN", "tag SSS", "bookmark SSS"
|
||||
release: 0c5bebca514eb06d9387f87666c1c658f3f673b4 (2024-04-02T20:12:28Z).
|
||||
release: commit 2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089
|
||||
|
||||
# Revision to pull in
|
||||
# Must be a long or short commit SHA (long preferred)
|
||||
revision: 0c5bebca514eb06d9387f87666c1c658f3f673b4
|
||||
revision: 2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089
|
||||
|
||||
license: ['MIT', 'Apache-2.0']
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ impl ProgrammableStageDescriptor {
|
|||
wgc::pipeline::ProgrammableStageDescriptor {
|
||||
module: self.module,
|
||||
entry_point: cow_label(&self.entry_point),
|
||||
constants: Cow::Owned(std::collections::HashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -692,7 +693,7 @@ pub extern "C" fn wgpu_client_make_encoder_id(
|
|||
.select(backend)
|
||||
.command_buffers
|
||||
.process(backend)
|
||||
.transmute()
|
||||
.into_command_encoder_id()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -706,7 +707,7 @@ pub extern "C" fn wgpu_client_free_command_encoder_id(
|
|||
.lock()
|
||||
.select(backend)
|
||||
.command_buffers
|
||||
.free(id.transmute())
|
||||
.free(id.into_command_buffer_id())
|
||||
}
|
||||
|
||||
|
||||
|
@ -726,7 +727,7 @@ pub extern "C" fn wgpu_client_create_command_encoder(
|
|||
.select(backend)
|
||||
.command_buffers
|
||||
.process(backend)
|
||||
.transmute();
|
||||
.into_command_encoder_id();
|
||||
|
||||
let action = DeviceAction::CreateCommandEncoder(id, desc.map_label(|_| label));
|
||||
*bb = make_byte_buf(&action);
|
||||
|
|
|
@ -303,7 +303,7 @@ pub unsafe extern "C" fn wgpu_server_adapter_request_device(
|
|||
// TODO: in https://github.com/gfx-rs/wgpu/pull/3626/files#diff-033343814319f5a6bd781494692ea626f06f6c3acc0753a12c867b53a646c34eR97
|
||||
// which introduced the queue id parameter, the queue id is also the device id. I don't know how applicable this is to
|
||||
// other situations (this one in particular).
|
||||
let (_, _, error) = gfx_select!(self_id => global.adapter_request_device(self_id, &desc, trace_path, Some(new_id), Some(new_id.transmute())));
|
||||
let (_, _, error) = gfx_select!(self_id => global.adapter_request_device(self_id, &desc, trace_path, Some(new_id), Some(new_id.into_queue_id())));
|
||||
if let Some(err) = error {
|
||||
error_buf.init(err);
|
||||
}
|
||||
|
|
|
@ -962,6 +962,12 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
|||
criteria = "safe-to-run"
|
||||
delta = "0.16.0 -> 0.16.2"
|
||||
|
||||
[[audits.core-foundation]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.9.3 -> 0.9.4"
|
||||
notes = "I've reviewed every source contribution that was neither authored nor reviewed by Mozilla."
|
||||
|
||||
[[audits.core-graphics]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -972,6 +978,12 @@ who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.1 -> 0.1.2"
|
||||
|
||||
[[audits.core-graphics-types]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.2 -> 0.1.3"
|
||||
notes = "I've reviewed every source contribution that was neither authored nor reviewed by Mozilla."
|
||||
|
||||
[[audits.core-text]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1325,11 +1337,11 @@ who = [
|
|||
"Erich Gubler <egubler@mozilla.com>",
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Nicolas Silva <nical@fastmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.7.0 -> 0.19.0@git:0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
delta = "0.7.0 -> 0.19.0@git:2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
importable = false
|
||||
|
||||
[[audits.darling]]
|
||||
|
@ -2539,6 +2551,11 @@ who = "Nicolas Silva <nical@fastmail.com>, Jim Blandy <jimb@red-bean.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.26.0 -> 0.27.0"
|
||||
|
||||
[[audits.metal]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.27.0 -> 0.27.0@git:ff8fd3d6dc7792852f8a015458d7e6d42d7fb352"
|
||||
|
||||
[[audits.midir]]
|
||||
who = "Bobby Holley <bobbyholley@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -2679,11 +2696,11 @@ delta = "0.13.0 -> 0.14.0"
|
|||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Nicolas Silva <nical@fastmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.14.0 -> 0.19.0@git:0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
delta = "0.14.0 -> 0.19.2@git:2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
importable = false
|
||||
|
||||
[[audits.net2]]
|
||||
|
@ -4498,11 +4515,11 @@ delta = "0.17.0 -> 0.18.0"
|
|||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Nicolas Silva <nical@fastmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.18.0 -> 0.19.0@git:0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
delta = "0.18.0 -> 0.19.3@git:2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
importable = false
|
||||
|
||||
[[audits.wgpu-hal]]
|
||||
|
@ -4552,11 +4569,11 @@ delta = "0.17.0 -> 0.18.0"
|
|||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Nicolas Silva <nical@fastmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.18.0 -> 0.19.0@git:0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
delta = "0.18.0 -> 0.19.3@git:2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
importable = false
|
||||
|
||||
[[audits.wgpu-types]]
|
||||
|
@ -4606,11 +4623,11 @@ delta = "0.17.0 -> 0.18.0"
|
|||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Nicolas Silva <nical@fastmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.18.0 -> 0.19.0@git:0c5bebca514eb06d9387f87666c1c658f3f673b4"
|
||||
delta = "0.18.0 -> 0.19.2@git:2b0e3ed01cfcc4bcccc7fd63b2581b260c00b089"
|
||||
importable = false
|
||||
|
||||
[[audits.whatsys]]
|
||||
|
|
|
@ -100,6 +100,10 @@ notes = "This was originally servo code which Bobby Holley put on crates.io some
|
|||
audit-as-crates-io = false
|
||||
notes = "This is a first-party crate which is also published to crates.io. We certify audits for this crate as part of the documented release process, but that step happens after the version bump lands on central so we don't enforce it here."
|
||||
|
||||
[policy.metal]
|
||||
audit-as-crates-io = true
|
||||
notes = "Part of the gfx org, pinned by wgpu-hal if unreleased functionality is needed."
|
||||
|
||||
[policy.midir]
|
||||
audit-as-crates-io = true
|
||||
notes = "This is a pinned version of the upstream code, presumably to get a fix that hadn't been released yet. We should consider switching to the latest official release."
|
||||
|
|
|
@ -134,6 +134,13 @@ user-id = 2396
|
|||
user-login = "jdm"
|
||||
user-name = "Josh Matthews"
|
||||
|
||||
[[publisher.core-foundation-sys]]
|
||||
version = "0.8.4"
|
||||
when = "2023-04-03"
|
||||
user-id = 5946
|
||||
user-login = "jrmuizel"
|
||||
user-name = "Jeff Muizelaar"
|
||||
|
||||
[[publisher.core-graphics]]
|
||||
version = "0.22.3"
|
||||
when = "2021-11-02"
|
||||
|
@ -846,6 +853,15 @@ criteria = "safe-to-deploy"
|
|||
version = "0.11.1"
|
||||
notes = "This library uses `forbid(unsafe_code)` and has no filesystem or network I/O."
|
||||
|
||||
[[audits.bytecode-alliance.audits.core-foundation-sys]]
|
||||
who = "Dan Gohman <dev@sunfishcode.online>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.8.4 -> 0.8.6"
|
||||
notes = """
|
||||
The changes here are all typical bindings updates: new functions, types, and
|
||||
constants. I have not audited all the bindings for ABI conformance.
|
||||
"""
|
||||
|
||||
[[audits.bytecode-alliance.audits.cpufeatures]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1123,6 +1139,29 @@ version = "0.37.0+1.3.209"
|
|||
notes = "Reviewed on https://fxrev.dev/694269"
|
||||
aggregated-from = "https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/third_party/rust_crates/supply-chain/audits.toml?format=TEXT"
|
||||
|
||||
[[audits.google.audits.bitflags]]
|
||||
who = "Lukasz Anforowicz <lukasza@chromium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "2.4.2"
|
||||
notes = """
|
||||
Audit notes:
|
||||
|
||||
* I've checked for any discussion in Google-internal cl/546819168 (where audit
|
||||
of version 2.3.3 happened)
|
||||
* `src/lib.rs` contains `#![cfg_attr(not(test), forbid(unsafe_code))]`
|
||||
* There are 2 cases of `unsafe` in `src/external.rs` but they seem to be
|
||||
correct in a straightforward way - they just propagate the marker trait's
|
||||
impl (e.g. `impl bytemuck::Pod`) from the inner to the outer type
|
||||
* Additional discussion and/or notes may be found in https://crrev.com/c/5238056
|
||||
"""
|
||||
aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT"
|
||||
|
||||
[[audits.google.audits.bitflags]]
|
||||
who = "Adrian Taylor <adetaylor@chromium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "2.4.2 -> 2.5.0"
|
||||
aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT"
|
||||
|
||||
[[audits.google.audits.fastrand]]
|
||||
who = "George Burgess IV <gbiv@google.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"CHANGELOG.md":"0905d91abfd8162750daeb51b69e1a4add85cd0e8e2b136a4fd20ea28df4da42","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","CONTRIBUTING.md":"6c9f96eacb20af877ae2d16f024904f3038b93448a8488e9dbcac0df7f6439a5","Cargo.lock":"fb581ed64bd34dbdbcc2386c394394d5f46db3186edc7b129f1669cef66a0b57","Cargo.toml":"418f0ef5e370bf88b0d7bd8c3b2f25b533ae2b671036d30f7c524dc39133045c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"a403792a6099aeda15dc7bf3da529409652039b5dd2227dfc5549bd2f3fad7db","SECURITY.md":"68704c8128fa2e776ed7cbda741fbf61ad52f998a96350ee7ee4dbf64c6573bc","benches/parse.rs":"f1390d62322c6880d65bd931e183d49b313f287879a6bfaa36b1cb1921090b51","examples/custom_bits_type.rs":"e53b32051adc5d97860e0b48c8f3a301a041d73b4939c0d7caa5f0cfcc0b9739","examples/custom_derive.rs":"29dd7b845345a103ca31e91b579aeb01fb74935b8223c29184eb42223edadb65","examples/fmt.rs":"87ba37a1fb8528570c74ea26d8e8948e1179c3d867b928bea1080880258e0a99","examples/macro_free.rs":"69e7f284b53b5214d51228a686e87f127b52a3b74711e45537ebfa5583a180e5","examples/serde.rs":"08b21b35d5c10fdca132fe0f36c8067bb44f559e96617a9257ab6316a20cbc75","spec.md":"fcdd939df30c59b0643be09027df664b71cbea9b9989185441482c5576160fed","src/example_generated.rs":"d018caf059f6ffc4c2403b771a6d76679fa5af03c329a91bd9252957df695e7f","src/external.rs":"11599248db17d395c6b45bf2400266f221d3eb1523908e5f17715964bf8d99ed","src/external/arbitrary.rs":"fa8c9187028b9bc54856977b0914676f62101010e7a9450abd577fd78c89552f","src/external/bytemuck.rs":"3afcef382122867040fddd5e4153d633d1ed5596fe5d7dfac66a8e61c2513df5","src/external/serde.rs":"4a09db12534a20fe554a08dc5f1c8124b379292d41fa75628abcd2ca21587573","src/internal.rs":"fd939154cbebf43bfc329a4a3cd08618ca30a6a5f6e6abea07d23f75bf5b3b2d","src/iter.rs":"dbaa6437c1c044f689185ce3fafe43df8796bed19bbdd2c20334a52de5eeee73","src/lib.rs":"e45c07f43b0e142c41e99de8d20ceb909148762c876d765c11ac8b8ceaca0af5","src/parser.rs":"52f6352620ce3d5973bc38b42d56a760307294162c9d5668eb774eb92a6ef941","src/public.rs":"72b41639711bab95e8e75f37401a487088e7be1a427715cea40563fb3f64ed60","src/tests.rs":"b120c27ff0c67a819527de9d8171f1f4c5d37ba4009c54abeb869c70e6035f14","src/traits.rs":"0a8764c3e2378043e2724cf1bfc514d4ff1985026db33509f6451a7897e2675d"},"package":"327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"}
|
||||
{"files":{"CHANGELOG.md":"cb81297fc686539a786805dfef959e6f7c9b5fd55e451150cea68bcacc73ee8c","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","CONTRIBUTING.md":"6c9f96eacb20af877ae2d16f024904f3038b93448a8488e9dbcac0df7f6439a5","Cargo.lock":"04c2a120060e71f281a3a3f26f9be8dbc5a80102204f1f982ae0e2089557e646","Cargo.toml":"ed18e06a8a26ae38abea369bb062b6e6c1b714913ee9e64c060151f5ec966f5b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"e37efef64c50b073d5afcb6d2d43649cec6bf26d4022f32b5d77665bcb4c9049","SECURITY.md":"68704c8128fa2e776ed7cbda741fbf61ad52f998a96350ee7ee4dbf64c6573bc","benches/parse.rs":"f1390d62322c6880d65bd931e183d49b313f287879a6bfaa36b1cb1921090b51","examples/custom_bits_type.rs":"e53b32051adc5d97860e0b48c8f3a301a041d73b4939c0d7caa5f0cfcc0b9739","examples/custom_derive.rs":"29dd7b845345a103ca31e91b579aeb01fb74935b8223c29184eb42223edadb65","examples/fmt.rs":"87ba37a1fb8528570c74ea26d8e8948e1179c3d867b928bea1080880258e0a99","examples/macro_free.rs":"69e7f284b53b5214d51228a686e87f127b52a3b74711e45537ebfa5583a180e5","examples/serde.rs":"08b21b35d5c10fdca132fe0f36c8067bb44f559e96617a9257ab6316a20cbc75","spec.md":"fcdd939df30c59b0643be09027df664b71cbea9b9989185441482c5576160fed","src/example_generated.rs":"d018caf059f6ffc4c2403b771a6d76679fa5af03c329a91bd9252957df695e7f","src/external.rs":"734d3f470e6a669297d2df421ce3976fe613d8aa9c071d5ce6fe3ca890e5b815","src/external/arbitrary.rs":"fa8c9187028b9bc54856977b0914676f62101010e7a9450abd577fd78c89552f","src/external/bytemuck.rs":"3afcef382122867040fddd5e4153d633d1ed5596fe5d7dfac66a8e61c2513df5","src/external/serde.rs":"4a09db12534a20fe554a08dc5f1c8124b379292d41fa75628abcd2ca21587573","src/internal.rs":"645b13af0c7302258df61239073a4b8203d09f27b6c17f8a6f1f8c3e427f5334","src/iter.rs":"dbaa6437c1c044f689185ce3fafe43df8796bed19bbdd2c20334a52de5eeee73","src/lib.rs":"c7ade9eb151425815a8fc5afc558951a256d14143be36c4442bcae477571783b","src/parser.rs":"4e788b29f5d0542c409a8b43c703bcb4a6c2a57c181cadd17f565f0abb39681e","src/public.rs":"d151f7db62fefdb6cd2cad1038a785f02d1ce32eaab4c4cc84376283699182cc","src/tests.rs":"b120c27ff0c67a819527de9d8171f1f4c5d37ba4009c54abeb869c70e6035f14","src/tests/all.rs":"e99a865cd4271a524c2fe95503e96d851b35990570aed6fb2e9dac7a14da31b6","src/tests/bits.rs":"3840c34b2ea5d1802404b9ce5bcc1d3fa6ccd8dfba2e29e6d07c605f817d90df","src/tests/complement.rs":"d0e6d4c3daf49e0a7438c9f1c1ac91fad1b37f258c03593f6cd6a695ee626f5e","src/tests/contains.rs":"58bb3cb8c86550e775d11134da1d4aca85c83f943ea454e3a5f222772c674a24","src/tests/difference.rs":"d0d2b96bb52658b8ac019210da74ca75a53e76622f668855142ea6e97c28cb0e","src/tests/empty.rs":"817d6e93ced7cb7576ff0e334aa1a44703f3f96871ff2c6bdcb8f207e6551f67","src/tests/eq.rs":"b816767680a029e9c163e37af074dd4e604c4a3e4936f829f0ca3774fd5f0e37","src/tests/extend.rs":"5fabb9fd0254c64da019149c24063fceff72da3eb4ad73b57c1cc4c04b008364","src/tests/flags.rs":"2f48d3a25db1cf66fe98c9959abc70875deb9f7b38b2c278dc70c46e0d4ec277","src/tests/fmt.rs":"a2d4148491f3202f030f63633eee941b741e3be29a68cf376f008dbe5cb11e5c","src/tests/from_bits.rs":"d94c65b88bf89961d0cfc1b3152a7f1acc285bae160a1628438effda11b8e2c1","src/tests/from_bits_retain.rs":"980591dfaf91e940f42d9a1ce890f237514dd59d458fc264abcf9ceabbc40677","src/tests/from_bits_truncate.rs":"d3406b5e107ebb6449b98a59eee6cc5d84f947d4aaee1ee7e80dc7202de179f0","src/tests/from_name.rs":"f4a055d1f3c86decef70ef8f3020cef5c4e229718c20b3d59d5a3abc3a8b1298","src/tests/insert.rs":"3fab5da800a6fc0654dfb5f859f95da65a507eb9fda8695083c2712266dff0b9","src/tests/intersection.rs":"baf1454c9e4eba552264870a556ee0032d9f2bb8cac361833d571235e0b52221","src/tests/intersects.rs":"c55e36179fd8bc636f04ea9bbce346dcaafe57915d13f1df28c5b83117dbd08e","src/tests/is_all.rs":"b2f11faa7c954bd85c8fb39999e0c37d983cf7895152bc13c7ddde106aa33b6d","src/tests/is_empty.rs":"11f21323cdca7ff92dd89e09de667dba69e8dce88e2d3e27ea68ace91d15d070","src/tests/iter.rs":"4ba121932b527e787b82745405c7c65c1084c242e2dda3290d475ec160d265e4","src/tests/parser.rs":"fa2fb8dedcf16601af609a5e21d9c5840c7f96a1e3a587f7f2ea3dc8387f7628","src/tests/remove.rs":"6e75f8508d2dc1a2cba89ef691f4387a665a4fd13853bb1dd0fd80c783b89947","src/tests/symmetric_difference.rs":"0a89f084f9de1dd5b1932fe72c3b10a3c93cbaa16832b3a31b6a85e3bbd3ba6e","src/tests/union.rs":"88f398ee4600bb1e59bf6d02d1f6ff33f5f853eab5a6c700bd8a683c6ee4651a","src/traits.rs":"b79d008daec546136fae4497966fc85a33663d86ea2d9213fd23b412d4d77b66"},"package":"cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"}
|
|
@ -1,3 +1,29 @@
|
|||
# 2.5.0
|
||||
|
||||
## What's Changed
|
||||
* Derive `Debug` for `Flag<B>` by @tgross35 in https://github.com/bitflags/bitflags/pull/398
|
||||
* Support truncating or strict-named variants of parsing and formatting by @KodrAus in https://github.com/bitflags/bitflags/pull/400
|
||||
|
||||
## New Contributors
|
||||
* @tgross35 made their first contribution in https://github.com/bitflags/bitflags/pull/398
|
||||
|
||||
**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.2...2.5.0
|
||||
|
||||
# 2.4.2
|
||||
|
||||
## What's Changed
|
||||
* Cargo.toml: Anchor excludes to root of the package by @jamessan in https://github.com/bitflags/bitflags/pull/387
|
||||
* Update error messages by @KodrAus in https://github.com/bitflags/bitflags/pull/390
|
||||
* Add support for impl mode structs to be repr(packed) by @GnomedDev in https://github.com/bitflags/bitflags/pull/388
|
||||
* Remove old `unused_tuple_struct_fields` lint by @dtolnay in https://github.com/bitflags/bitflags/pull/393
|
||||
* Delete use of `local_inner_macros` by @dtolnay in https://github.com/bitflags/bitflags/pull/392
|
||||
|
||||
## New Contributors
|
||||
* @jamessan made their first contribution in https://github.com/bitflags/bitflags/pull/387
|
||||
* @GnomedDev made their first contribution in https://github.com/bitflags/bitflags/pull/388
|
||||
|
||||
**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.1...2.4.2
|
||||
|
||||
# 2.4.1
|
||||
|
||||
## What's Changed
|
||||
|
|
|
@ -4,25 +4,16 @@ version = 3
|
|||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.3.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859"
|
||||
checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110"
|
||||
dependencies = [
|
||||
"derive_arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "basic-toml"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"bytemuck",
|
||||
|
@ -39,18 +30,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.14.0"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
|
||||
checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.5.0"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
|
||||
checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -65,21 +56,27 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "compiler_builtins"
|
||||
version = "0.1.101"
|
||||
version = "0.1.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01a6d58e9c3408138099a396a98fd0d0e6cfb25d723594d2ae48b5004513fd5b"
|
||||
checksum = "d68bc55329711cd719c2687bb147bc06211b0521f97ef398280108ccb23227e9"
|
||||
|
||||
[[package]]
|
||||
name = "derive_arbitrary"
|
||||
version = "1.3.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8"
|
||||
checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
|
@ -87,31 +84,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
name = "hashbrown"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.18.0"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -130,24 +149,24 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
|||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.15"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.189"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.189"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -156,15 +175,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.107"
|
||||
version = "1.0.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
||||
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_test"
|
||||
version = "1.0.176"
|
||||
|
@ -176,9 +204,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.38"
|
||||
version = "2.0.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -187,26 +215,60 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.3.0"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.85"
|
||||
name = "toml"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "196a58260a906cedb9bf6d8034b6379d0c11f552416960452f267402ceeddff1"
|
||||
checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c12219811e0c1ba077867254e5ad62ee2c9c190b0d957110750ac0cda1ae96cd"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2aa6f84ec205ebf87fb7a0abdbcd1467fa5af0e86878eb6d888b78ecbb10b6d5"
|
||||
dependencies = [
|
||||
"basic-toml",
|
||||
"glob",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"termcolor",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -247,10 +309,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.6.4"
|
||||
name = "winnow"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20707b61725734c595e840fb3704378a0cd2b9c74cc9e6e20724838fc6a1e2f9"
|
||||
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive",
|
||||
|
@ -258,9 +329,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.6.4"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56097d5b91d711293a42be9289403896b68654625021732067eac7a4ca388a1f"
|
||||
checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.56.0"
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
authors = ["The Rust Project Developers"]
|
||||
exclude = [
|
||||
"tests",
|
||||
".github",
|
||||
"/tests",
|
||||
"/.github",
|
||||
]
|
||||
description = """
|
||||
A macro to generate structures which behave like bitflags.
|
||||
|
|
|
@ -28,7 +28,7 @@ Add this to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
bitflags = "2.4.1"
|
||||
bitflags = "2.5.0"
|
||||
```
|
||||
|
||||
and this to your source code:
|
||||
|
|
|
@ -14,7 +14,7 @@ Next, re-export the library from the `__private` module here.
|
|||
Next, define a macro like so:
|
||||
|
||||
```rust
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "serde")]
|
||||
macro_rules! __impl_external_bitflags_my_library {
|
||||
|
@ -30,7 +30,7 @@ macro_rules! __impl_external_bitflags_my_library {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "my_library"))]
|
||||
macro_rules! __impl_external_bitflags_my_library {
|
||||
|
@ -77,7 +77,7 @@ pub(crate) mod __private {
|
|||
}
|
||||
|
||||
/// Implements traits from external libraries for the internal bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_external_bitflags {
|
||||
(
|
||||
|
@ -92,7 +92,7 @@ macro_rules! __impl_external_bitflags {
|
|||
// Use `serde` as an example: generate code when the feature is available,
|
||||
// and a no-op when it isn't
|
||||
|
||||
__impl_external_bitflags_serde! {
|
||||
$crate::__impl_external_bitflags_serde! {
|
||||
$InternalBitFlags: $T, $PublicBitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -101,7 +101,7 @@ macro_rules! __impl_external_bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
__impl_external_bitflags_arbitrary! {
|
||||
$crate::__impl_external_bitflags_arbitrary! {
|
||||
$InternalBitFlags: $T, $PublicBitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -110,7 +110,7 @@ macro_rules! __impl_external_bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
__impl_external_bitflags_bytemuck! {
|
||||
$crate::__impl_external_bitflags_bytemuck! {
|
||||
$InternalBitFlags: $T, $PublicBitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -125,7 +125,7 @@ macro_rules! __impl_external_bitflags {
|
|||
pub mod serde;
|
||||
|
||||
/// Implement `Serialize` and `Deserialize` for the internal bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "serde")]
|
||||
macro_rules! __impl_external_bitflags_serde {
|
||||
|
@ -161,7 +161,7 @@ macro_rules! __impl_external_bitflags_serde {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "serde"))]
|
||||
macro_rules! __impl_external_bitflags_serde {
|
||||
|
@ -182,7 +182,7 @@ pub mod arbitrary;
|
|||
mod bytemuck;
|
||||
|
||||
/// Implement `Arbitrary` for the internal bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "arbitrary")]
|
||||
macro_rules! __impl_external_bitflags_arbitrary {
|
||||
|
@ -204,7 +204,7 @@ macro_rules! __impl_external_bitflags_arbitrary {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "arbitrary"))]
|
||||
macro_rules! __impl_external_bitflags_arbitrary {
|
||||
|
@ -219,7 +219,7 @@ macro_rules! __impl_external_bitflags_arbitrary {
|
|||
}
|
||||
|
||||
/// Implement `Pod` and `Zeroable` for the internal bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "bytemuck")]
|
||||
macro_rules! __impl_external_bitflags_bytemuck {
|
||||
|
@ -247,7 +247,7 @@ macro_rules! __impl_external_bitflags_bytemuck {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "bytemuck"))]
|
||||
macro_rules! __impl_external_bitflags_bytemuck {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/// Declare the `bitflags`-facing bitflags struct.
|
||||
///
|
||||
/// This type is part of the `bitflags` crate's public API, but not part of the user's.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __declare_internal_bitflags {
|
||||
(
|
||||
|
@ -25,7 +25,7 @@ macro_rules! __declare_internal_bitflags {
|
|||
///
|
||||
/// Methods and trait implementations can be freely added here without breaking end-users.
|
||||
/// If we want to expose new functionality to `#[derive]`, this is the place to do it.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_internal_bitflags {
|
||||
(
|
||||
|
@ -97,7 +97,7 @@ macro_rules! __impl_internal_bitflags {
|
|||
|
||||
// The internal flags type offers a similar API to the public one
|
||||
|
||||
__impl_public_bitflags! {
|
||||
$crate::__impl_public_bitflags! {
|
||||
$InternalBitFlags: $T, $PublicBitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -106,11 +106,11 @@ macro_rules! __impl_internal_bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
__impl_public_bitflags_ops! {
|
||||
$crate::__impl_public_bitflags_ops! {
|
||||
$InternalBitFlags
|
||||
}
|
||||
|
||||
__impl_public_bitflags_iter! {
|
||||
$crate::__impl_public_bitflags_iter! {
|
||||
$InternalBitFlags: $T, $PublicBitFlags
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Add `bitflags` to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies.bitflags]
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
```
|
||||
|
||||
## Generating flags types
|
||||
|
@ -252,6 +252,8 @@ mod traits;
|
|||
|
||||
#[doc(hidden)]
|
||||
pub mod __private {
|
||||
#[allow(unused_imports)]
|
||||
// Easier than conditionally checking any optional external dependencies
|
||||
pub use crate::{external::__private::*, traits::__private::*};
|
||||
|
||||
pub use core;
|
||||
|
@ -441,7 +443,7 @@ bitflags! {
|
|||
}
|
||||
```
|
||||
*/
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! bitflags {
|
||||
(
|
||||
$(#[$outer:meta])*
|
||||
|
@ -456,13 +458,13 @@ macro_rules! bitflags {
|
|||
) => {
|
||||
// Declared in the scope of the `bitflags!` call
|
||||
// This type appears in the end-user's API
|
||||
__declare_public_bitflags! {
|
||||
$crate::__declare_public_bitflags! {
|
||||
$(#[$outer])*
|
||||
$vis struct $BitFlags
|
||||
}
|
||||
|
||||
// Workaround for: https://github.com/bitflags/bitflags/issues/320
|
||||
__impl_public_bitflags_consts! {
|
||||
$crate::__impl_public_bitflags_consts! {
|
||||
$BitFlags: $T {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -487,11 +489,11 @@ macro_rules! bitflags {
|
|||
const _: () = {
|
||||
// Declared in a "hidden" scope that can't be reached directly
|
||||
// These types don't appear in the end-user's API
|
||||
__declare_internal_bitflags! {
|
||||
$crate::__declare_internal_bitflags! {
|
||||
$vis struct InternalBitFlags: $T
|
||||
}
|
||||
|
||||
__impl_internal_bitflags! {
|
||||
$crate::__impl_internal_bitflags! {
|
||||
InternalBitFlags: $T, $BitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -501,7 +503,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
|
||||
// This is where new library trait implementations can be added
|
||||
__impl_external_bitflags! {
|
||||
$crate::__impl_external_bitflags! {
|
||||
InternalBitFlags: $T, $BitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -510,20 +512,20 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
__impl_public_bitflags_forward! {
|
||||
$crate::__impl_public_bitflags_forward! {
|
||||
$BitFlags: $T, InternalBitFlags
|
||||
}
|
||||
|
||||
__impl_public_bitflags_ops! {
|
||||
$crate::__impl_public_bitflags_ops! {
|
||||
$BitFlags
|
||||
}
|
||||
|
||||
__impl_public_bitflags_iter! {
|
||||
$crate::__impl_public_bitflags_iter! {
|
||||
$BitFlags: $T, $BitFlags
|
||||
}
|
||||
};
|
||||
|
||||
bitflags! {
|
||||
$crate::bitflags! {
|
||||
$($t)*
|
||||
}
|
||||
};
|
||||
|
@ -537,7 +539,7 @@ macro_rules! bitflags {
|
|||
|
||||
$($t:tt)*
|
||||
) => {
|
||||
__impl_public_bitflags_consts! {
|
||||
$crate::__impl_public_bitflags_consts! {
|
||||
$BitFlags: $T {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -558,7 +560,7 @@ macro_rules! bitflags {
|
|||
clippy::iter_without_into_iter,
|
||||
)]
|
||||
const _: () = {
|
||||
__impl_public_bitflags! {
|
||||
$crate::__impl_public_bitflags! {
|
||||
$BitFlags: $T, $BitFlags {
|
||||
$(
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -567,16 +569,16 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
__impl_public_bitflags_ops! {
|
||||
$crate::__impl_public_bitflags_ops! {
|
||||
$BitFlags
|
||||
}
|
||||
|
||||
__impl_public_bitflags_iter! {
|
||||
$crate::__impl_public_bitflags_iter! {
|
||||
$BitFlags: $T, $BitFlags
|
||||
}
|
||||
};
|
||||
|
||||
bitflags! {
|
||||
$crate::bitflags! {
|
||||
$($t)*
|
||||
}
|
||||
};
|
||||
|
@ -587,7 +589,7 @@ macro_rules! bitflags {
|
|||
///
|
||||
/// We need to be careful about adding new methods and trait implementations here because they
|
||||
/// could conflict with items added by the end-user.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_bitflags {
|
||||
(
|
||||
|
@ -796,7 +798,7 @@ macro_rules! __impl_bitflags {
|
|||
///
|
||||
/// If you find yourself with an attribute that should be considered expression-safe
|
||||
/// and isn't, it can be added here.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __bitflags_expr_safe_attrs {
|
||||
// Entrypoint: Move all flags and all attributes into `unprocessed` lists
|
||||
|
@ -805,7 +807,7 @@ macro_rules! __bitflags_expr_safe_attrs {
|
|||
$(#[$inner:ident $($args:tt)*])*
|
||||
{ $e:expr }
|
||||
) => {
|
||||
__bitflags_expr_safe_attrs! {
|
||||
$crate::__bitflags_expr_safe_attrs! {
|
||||
expr: { $e },
|
||||
attrs: {
|
||||
// All attributes start here
|
||||
|
@ -830,7 +832,7 @@ macro_rules! __bitflags_expr_safe_attrs {
|
|||
processed: [$($expr:tt)*],
|
||||
},
|
||||
) => {
|
||||
__bitflags_expr_safe_attrs! {
|
||||
$crate::__bitflags_expr_safe_attrs! {
|
||||
expr: { $e },
|
||||
attrs: {
|
||||
unprocessed: [
|
||||
|
@ -857,7 +859,7 @@ macro_rules! __bitflags_expr_safe_attrs {
|
|||
processed: [$($expr:tt)*],
|
||||
},
|
||||
) => {
|
||||
__bitflags_expr_safe_attrs! {
|
||||
$crate::__bitflags_expr_safe_attrs! {
|
||||
expr: { $e },
|
||||
attrs: {
|
||||
unprocessed: [
|
||||
|
@ -884,7 +886,7 @@ macro_rules! __bitflags_expr_safe_attrs {
|
|||
}
|
||||
|
||||
/// Implement a flag, which may be a wildcard `_`.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __bitflags_flag {
|
||||
(
|
||||
|
|
|
@ -77,8 +77,10 @@ where
|
|||
fmt::Result::Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
pub(crate) struct AsDisplay<'a, B>(pub(crate) &'a B);
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'a, B: Flags> fmt::Display for AsDisplay<'a, B>
|
||||
where
|
||||
B::Bits: WriteHex,
|
||||
|
@ -134,6 +136,89 @@ where
|
|||
Ok(parsed_flags)
|
||||
}
|
||||
|
||||
/**
|
||||
Write a flags value as text, ignoring any unknown bits.
|
||||
*/
|
||||
pub fn to_writer_truncate<B: Flags>(flags: &B, writer: impl Write) -> Result<(), fmt::Error>
|
||||
where
|
||||
B::Bits: WriteHex,
|
||||
{
|
||||
to_writer(&B::from_bits_truncate(flags.bits()), writer)
|
||||
}
|
||||
|
||||
/**
|
||||
Parse a flags value from text.
|
||||
|
||||
This function will fail on any names that don't correspond to defined flags.
|
||||
Unknown bits will be ignored.
|
||||
*/
|
||||
pub fn from_str_truncate<B: Flags>(input: &str) -> Result<B, ParseError>
|
||||
where
|
||||
B::Bits: ParseHex,
|
||||
{
|
||||
Ok(B::from_bits_truncate(from_str::<B>(input)?.bits()))
|
||||
}
|
||||
|
||||
/**
|
||||
Write only the contained, defined, named flags in a flags value as text.
|
||||
*/
|
||||
pub fn to_writer_strict<B: Flags>(flags: &B, mut writer: impl Write) -> Result<(), fmt::Error> {
|
||||
// This is a simplified version of `to_writer` that ignores
|
||||
// any bits not corresponding to a named flag
|
||||
|
||||
let mut first = true;
|
||||
let mut iter = flags.iter_names();
|
||||
for (name, _) in &mut iter {
|
||||
if !first {
|
||||
writer.write_str(" | ")?;
|
||||
}
|
||||
|
||||
first = false;
|
||||
writer.write_str(name)?;
|
||||
}
|
||||
|
||||
fmt::Result::Ok(())
|
||||
}
|
||||
|
||||
/**
|
||||
Parse a flags value from text.
|
||||
|
||||
This function will fail on any names that don't correspond to defined flags.
|
||||
This function will fail to parse hex values.
|
||||
*/
|
||||
pub fn from_str_strict<B: Flags>(input: &str) -> Result<B, ParseError> {
|
||||
// This is a simplified version of `from_str` that ignores
|
||||
// any bits not corresponding to a named flag
|
||||
|
||||
let mut parsed_flags = B::empty();
|
||||
|
||||
// If the input is empty then return an empty set of flags
|
||||
if input.trim().is_empty() {
|
||||
return Ok(parsed_flags);
|
||||
}
|
||||
|
||||
for flag in input.split('|') {
|
||||
let flag = flag.trim();
|
||||
|
||||
// If the flag is empty then we've got missing input
|
||||
if flag.is_empty() {
|
||||
return Err(ParseError::empty_flag());
|
||||
}
|
||||
|
||||
// If the flag starts with `0x` then it's a hex number
|
||||
// These aren't supported in the strict parser
|
||||
if flag.starts_with("0x") {
|
||||
return Err(ParseError::invalid_hex_flag("unsupported hex flag value"));
|
||||
}
|
||||
|
||||
let parsed_flag = B::from_name(flag).ok_or_else(|| ParseError::invalid_named_flag(flag))?;
|
||||
|
||||
parsed_flags.insert(parsed_flag);
|
||||
}
|
||||
|
||||
Ok(parsed_flags)
|
||||
}
|
||||
|
||||
/**
|
||||
Encode a value as a hex string.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/// Declare the user-facing bitflags struct.
|
||||
///
|
||||
/// This type is guaranteed to be a newtype with a `bitflags`-facing type as its single field.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __declare_public_bitflags {
|
||||
(
|
||||
|
@ -22,13 +22,13 @@ macro_rules! __declare_public_bitflags {
|
|||
///
|
||||
/// We need to be careful about adding new methods and trait implementations here because they
|
||||
/// could conflict with items added by the end-user.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_public_bitflags_forward {
|
||||
(
|
||||
$PublicBitFlags:ident: $T:ty, $InternalBitFlags:ident
|
||||
) => {
|
||||
__impl_bitflags! {
|
||||
$crate::__impl_bitflags! {
|
||||
$PublicBitFlags: $T {
|
||||
fn empty() {
|
||||
Self($InternalBitFlags::empty())
|
||||
|
@ -124,7 +124,7 @@ macro_rules! __impl_public_bitflags_forward {
|
|||
///
|
||||
/// We need to be careful about adding new methods and trait implementations here because they
|
||||
/// could conflict with items added by the end-user.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_public_bitflags {
|
||||
(
|
||||
|
@ -135,7 +135,7 @@ macro_rules! __impl_public_bitflags {
|
|||
)*
|
||||
}
|
||||
) => {
|
||||
__impl_bitflags! {
|
||||
$crate::__impl_bitflags! {
|
||||
$BitFlags: $T {
|
||||
fn empty() {
|
||||
Self(<$T as $crate::Bits>::EMPTY)
|
||||
|
@ -146,7 +146,7 @@ macro_rules! __impl_public_bitflags {
|
|||
let mut i = 0;
|
||||
|
||||
$(
|
||||
__bitflags_expr_safe_attrs!(
|
||||
$crate::__bitflags_expr_safe_attrs!(
|
||||
$(#[$inner $($args)*])*
|
||||
{{
|
||||
let flag = <$PublicBitFlags as $crate::Flags>::FLAGS[i].value().bits();
|
||||
|
@ -185,10 +185,10 @@ macro_rules! __impl_public_bitflags {
|
|||
|
||||
fn from_name(name) {
|
||||
$(
|
||||
__bitflags_flag!({
|
||||
$crate::__bitflags_flag!({
|
||||
name: $Flag,
|
||||
named: {
|
||||
__bitflags_expr_safe_attrs!(
|
||||
$crate::__bitflags_expr_safe_attrs!(
|
||||
$(#[$inner $($args)*])*
|
||||
{
|
||||
if name == $crate::__private::core::stringify!($Flag) {
|
||||
|
@ -268,7 +268,7 @@ macro_rules! __impl_public_bitflags {
|
|||
}
|
||||
|
||||
/// Implement iterators on the public (user-facing) bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_public_bitflags_iter {
|
||||
($BitFlags:ident: $T:ty, $PublicBitFlags:ident) => {
|
||||
|
@ -312,7 +312,7 @@ macro_rules! __impl_public_bitflags_iter {
|
|||
}
|
||||
|
||||
/// Implement traits on the public (user-facing) bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_public_bitflags_ops {
|
||||
($PublicBitFlags:ident) => {
|
||||
|
@ -321,7 +321,8 @@ macro_rules! __impl_public_bitflags_ops {
|
|||
&self,
|
||||
f: &mut $crate::__private::core::fmt::Formatter,
|
||||
) -> $crate::__private::core::fmt::Result {
|
||||
$crate::__private::core::fmt::Binary::fmt(&self.0, f)
|
||||
let inner = self.0;
|
||||
$crate::__private::core::fmt::Binary::fmt(&inner, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +331,8 @@ macro_rules! __impl_public_bitflags_ops {
|
|||
&self,
|
||||
f: &mut $crate::__private::core::fmt::Formatter,
|
||||
) -> $crate::__private::core::fmt::Result {
|
||||
$crate::__private::core::fmt::Octal::fmt(&self.0, f)
|
||||
let inner = self.0;
|
||||
$crate::__private::core::fmt::Octal::fmt(&inner, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +341,8 @@ macro_rules! __impl_public_bitflags_ops {
|
|||
&self,
|
||||
f: &mut $crate::__private::core::fmt::Formatter,
|
||||
) -> $crate::__private::core::fmt::Result {
|
||||
$crate::__private::core::fmt::LowerHex::fmt(&self.0, f)
|
||||
let inner = self.0;
|
||||
$crate::__private::core::fmt::LowerHex::fmt(&inner, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +351,8 @@ macro_rules! __impl_public_bitflags_ops {
|
|||
&self,
|
||||
f: &mut $crate::__private::core::fmt::Formatter,
|
||||
) -> $crate::__private::core::fmt::Result {
|
||||
$crate::__private::core::fmt::UpperHex::fmt(&self.0, f)
|
||||
let inner = self.0;
|
||||
$crate::__private::core::fmt::UpperHex::fmt(&inner, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +472,7 @@ macro_rules! __impl_public_bitflags_ops {
|
|||
}
|
||||
|
||||
/// Implement constants on the public (user-facing) bitflags type.
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_public_bitflags_consts {
|
||||
(
|
||||
|
@ -481,7 +485,7 @@ macro_rules! __impl_public_bitflags_consts {
|
|||
) => {
|
||||
impl $PublicBitFlags {
|
||||
$(
|
||||
__bitflags_flag!({
|
||||
$crate::__bitflags_flag!({
|
||||
name: $Flag,
|
||||
named: {
|
||||
$(#[$inner $($args)*])*
|
||||
|
@ -499,10 +503,10 @@ macro_rules! __impl_public_bitflags_consts {
|
|||
impl $crate::Flags for $PublicBitFlags {
|
||||
const FLAGS: &'static [$crate::Flag<$PublicBitFlags>] = &[
|
||||
$(
|
||||
__bitflags_flag!({
|
||||
$crate::__bitflags_flag!({
|
||||
name: $Flag,
|
||||
named: {
|
||||
__bitflags_expr_safe_attrs!(
|
||||
$crate::__bitflags_expr_safe_attrs!(
|
||||
$(#[$inner $($args)*])*
|
||||
{
|
||||
#[allow(
|
||||
|
@ -514,7 +518,7 @@ macro_rules! __impl_public_bitflags_consts {
|
|||
)
|
||||
},
|
||||
unnamed: {
|
||||
__bitflags_expr_safe_attrs!(
|
||||
$crate::__bitflags_expr_safe_attrs!(
|
||||
$(#[$inner $($args)*])*
|
||||
{
|
||||
#[allow(
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(1 | 1 << 1 | 1 << 2, TestFlags::all);
|
||||
|
||||
case(0, TestZero::all);
|
||||
|
||||
case(0, TestEmpty::all);
|
||||
|
||||
case(!0, TestExternal::all);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(expected: T::Bits, inherent: impl FnOnce() -> T)
|
||||
where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(expected, inherent().bits(), "T::all()");
|
||||
assert_eq!(expected, T::all().bits(), "Flags::all()");
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(0, TestFlags::empty(), TestFlags::bits);
|
||||
|
||||
case(1, TestFlags::A, TestFlags::bits);
|
||||
case(1 | 1 << 1 | 1 << 2, TestFlags::ABC, TestFlags::bits);
|
||||
|
||||
case(!0, TestFlags::from_bits_retain(u8::MAX), TestFlags::bits);
|
||||
case(1 << 3, TestFlags::from_bits_retain(1 << 3), TestFlags::bits);
|
||||
|
||||
case(1 << 3, TestZero::from_bits_retain(1 << 3), TestZero::bits);
|
||||
|
||||
case(1 << 3, TestEmpty::from_bits_retain(1 << 3), TestEmpty::bits);
|
||||
|
||||
case(
|
||||
1 << 4 | 1 << 6,
|
||||
TestExternal::from_bits_retain(1 << 4 | 1 << 6),
|
||||
TestExternal::bits,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug>(
|
||||
expected: T::Bits,
|
||||
value: T,
|
||||
inherent: impl FnOnce(&T) -> T::Bits,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(expected, inherent(&value), "{:?}.bits()", value);
|
||||
assert_eq!(expected, Flags::bits(&value), "Flags::bits({:?})", value);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(0, TestFlags::all(), TestFlags::complement);
|
||||
case(0, TestFlags::from_bits_retain(!0), TestFlags::complement);
|
||||
|
||||
case(1 | 1 << 1, TestFlags::C, TestFlags::complement);
|
||||
case(
|
||||
1 | 1 << 1,
|
||||
TestFlags::C | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::complement,
|
||||
);
|
||||
|
||||
case(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
TestFlags::empty(),
|
||||
TestFlags::complement,
|
||||
);
|
||||
case(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::complement,
|
||||
);
|
||||
|
||||
case(0, TestZero::empty(), TestZero::complement);
|
||||
|
||||
case(0, TestEmpty::empty(), TestEmpty::complement);
|
||||
|
||||
case(1 << 2, TestOverlapping::AB, TestOverlapping::complement);
|
||||
|
||||
case(!0, TestExternal::empty(), TestExternal::complement);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + std::ops::Not<Output = T> + Copy>(
|
||||
expected: T::Bits,
|
||||
value: T,
|
||||
inherent: impl FnOnce(T) -> T,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(expected, inherent(value).bits(), "{:?}.complement()", value);
|
||||
assert_eq!(
|
||||
expected,
|
||||
Flags::complement(value).bits(),
|
||||
"Flags::complement({:?})",
|
||||
value
|
||||
);
|
||||
assert_eq!(expected, (!value).bits(), "!{:?}", value);
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::empty(), true),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::empty(), true),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::ABC, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
(TestFlags::from_bits_retain(1 | (1 << 3)), false),
|
||||
],
|
||||
TestFlags::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::ABC,
|
||||
&[
|
||||
(TestFlags::empty(), true),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, true),
|
||||
(TestFlags::C, true),
|
||||
(TestFlags::ABC, true),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
&[
|
||||
(TestFlags::empty(), true),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), true),
|
||||
],
|
||||
TestFlags::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestZero::ZERO,
|
||||
&[(TestZero::ZERO, true)],
|
||||
TestZero::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestOverlapping::AB,
|
||||
&[
|
||||
(TestOverlapping::AB, true),
|
||||
(TestOverlapping::BC, false),
|
||||
(TestOverlapping::from_bits_retain(1 << 1), true),
|
||||
],
|
||||
TestOverlapping::contains,
|
||||
);
|
||||
|
||||
case(
|
||||
TestExternal::all(),
|
||||
&[
|
||||
(TestExternal::A, true),
|
||||
(TestExternal::B, true),
|
||||
(TestExternal::C, true),
|
||||
(TestExternal::from_bits_retain(1 << 5 | 1 << 7), true),
|
||||
],
|
||||
TestExternal::contains,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, bool)],
|
||||
mut inherent: impl FnMut(&T, T) -> bool,
|
||||
) {
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(&value, *input),
|
||||
"{:?}.contains({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::contains(&value, *input),
|
||||
"Flags::contains({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::A | TestFlags::B,
|
||||
&[
|
||||
(TestFlags::A, 1 << 1),
|
||||
(TestFlags::B, 1),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1 | 1 << 1),
|
||||
],
|
||||
TestFlags::difference,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 | 1 << 3),
|
||||
&[
|
||||
(TestFlags::A, 1 << 3),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1),
|
||||
],
|
||||
TestFlags::difference,
|
||||
);
|
||||
|
||||
case(
|
||||
TestExternal::from_bits_retain(!0),
|
||||
&[(TestExternal::A, 0b1111_1110)],
|
||||
TestExternal::difference,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
0b1111_1110,
|
||||
(TestExternal::from_bits_retain(!0) & !TestExternal::A).bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
0b1111_1110,
|
||||
(TestFlags::from_bits_retain(!0).difference(TestFlags::A)).bits()
|
||||
);
|
||||
|
||||
// The `!` operator unsets bits that don't correspond to known flags
|
||||
assert_eq!(
|
||||
1 << 1 | 1 << 2,
|
||||
(TestFlags::from_bits_retain(!0) & !TestFlags::A).bits()
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + std::ops::Sub<Output = T> + std::ops::SubAssign + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent: impl FnMut(T, T) -> T,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(value, *input).bits(),
|
||||
"{:?}.difference({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::difference(value, *input).bits(),
|
||||
"Flags::difference({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
(value - *input).bits(),
|
||||
"{:?} - {:?}",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
value -= *input;
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?} -= {:?}",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(0, TestFlags::empty);
|
||||
|
||||
case(0, TestZero::empty);
|
||||
|
||||
case(0, TestEmpty::empty);
|
||||
|
||||
case(0, TestExternal::empty);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(expected: T::Bits, inherent: impl FnOnce() -> T)
|
||||
where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(expected, inherent().bits(), "T::empty()");
|
||||
assert_eq!(expected, T::empty().bits(), "Flags::empty()");
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
assert_eq!(TestFlags::empty(), TestFlags::empty());
|
||||
assert_eq!(TestFlags::all(), TestFlags::all());
|
||||
|
||||
assert!(TestFlags::from_bits_retain(1) < TestFlags::from_bits_retain(2));
|
||||
assert!(TestFlags::from_bits_retain(2) > TestFlags::from_bits_retain(1));
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
let mut flags = TestFlags::empty();
|
||||
|
||||
flags.extend(TestFlags::A);
|
||||
|
||||
assert_eq!(TestFlags::A, flags);
|
||||
|
||||
flags.extend(TestFlags::A | TestFlags::B | TestFlags::C);
|
||||
|
||||
assert_eq!(TestFlags::ABC, flags);
|
||||
|
||||
flags.extend(TestFlags::from_bits_retain(1 << 5));
|
||||
|
||||
assert_eq!(TestFlags::ABC | TestFlags::from_bits_retain(1 << 5), flags);
|
||||
}
|
||||
|
||||
mod external {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
let mut flags = TestExternal::empty();
|
||||
|
||||
flags.extend(TestExternal::A);
|
||||
|
||||
assert_eq!(TestExternal::A, flags);
|
||||
|
||||
flags.extend(TestExternal::A | TestExternal::B | TestExternal::C);
|
||||
|
||||
assert_eq!(TestExternal::ABC, flags);
|
||||
|
||||
flags.extend(TestExternal::from_bits_retain(1 << 5));
|
||||
|
||||
assert_eq!(
|
||||
TestExternal::ABC | TestExternal::from_bits_retain(1 << 5),
|
||||
flags
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
let flags = TestFlags::FLAGS
|
||||
.iter()
|
||||
.map(|flag| (flag.name(), flag.value().bits()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
vec![
|
||||
("A", 1u8),
|
||||
("B", 1 << 1),
|
||||
("C", 1 << 2),
|
||||
("ABC", 1 | 1 << 1 | 1 << 2),
|
||||
],
|
||||
flags,
|
||||
);
|
||||
|
||||
assert_eq!(0, TestEmpty::FLAGS.iter().count());
|
||||
}
|
||||
|
||||
mod external {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
let flags = TestExternal::FLAGS
|
||||
.iter()
|
||||
.map(|flag| (flag.name(), flag.value().bits()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
vec![
|
||||
("A", 1u8),
|
||||
("B", 1 << 1),
|
||||
("C", 1 << 2),
|
||||
("ABC", 1 | 1 << 1 | 1 << 2),
|
||||
("", !0),
|
||||
],
|
||||
flags,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(TestFlags::empty(), "TestFlags(0x0)", "0", "0", "0", "0");
|
||||
case(TestFlags::A, "TestFlags(A)", "1", "1", "1", "1");
|
||||
case(
|
||||
TestFlags::all(),
|
||||
"TestFlags(A | B | C)",
|
||||
"7",
|
||||
"7",
|
||||
"7",
|
||||
"111",
|
||||
);
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
"TestFlags(0x8)",
|
||||
"8",
|
||||
"8",
|
||||
"10",
|
||||
"1000",
|
||||
);
|
||||
case(
|
||||
TestFlags::A | TestFlags::from_bits_retain(1 << 3),
|
||||
"TestFlags(A | 0x8)",
|
||||
"9",
|
||||
"9",
|
||||
"11",
|
||||
"1001",
|
||||
);
|
||||
|
||||
case(TestZero::ZERO, "TestZero(0x0)", "0", "0", "0", "0");
|
||||
case(
|
||||
TestZero::ZERO | TestZero::from_bits_retain(1),
|
||||
"TestZero(0x1)",
|
||||
"1",
|
||||
"1",
|
||||
"1",
|
||||
"1",
|
||||
);
|
||||
|
||||
case(TestZeroOne::ONE, "TestZeroOne(ONE)", "1", "1", "1", "1");
|
||||
|
||||
case(
|
||||
TestOverlapping::from_bits_retain(1 << 1),
|
||||
"TestOverlapping(0x2)",
|
||||
"2",
|
||||
"2",
|
||||
"2",
|
||||
"10",
|
||||
);
|
||||
|
||||
case(
|
||||
TestExternal::from_bits_retain(1 | 1 << 1 | 1 << 3),
|
||||
"TestExternal(A | B | 0x8)",
|
||||
"B",
|
||||
"b",
|
||||
"13",
|
||||
"1011",
|
||||
);
|
||||
|
||||
case(
|
||||
TestExternal::all(),
|
||||
"TestExternal(A | B | C | 0xf8)",
|
||||
"FF",
|
||||
"ff",
|
||||
"377",
|
||||
"11111111",
|
||||
);
|
||||
|
||||
case(
|
||||
TestExternalFull::all(),
|
||||
"TestExternalFull(0xff)",
|
||||
"FF",
|
||||
"ff",
|
||||
"377",
|
||||
"11111111",
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<
|
||||
T: std::fmt::Debug + std::fmt::UpperHex + std::fmt::LowerHex + std::fmt::Octal + std::fmt::Binary,
|
||||
>(
|
||||
value: T,
|
||||
debug: &str,
|
||||
uhex: &str,
|
||||
lhex: &str,
|
||||
oct: &str,
|
||||
bin: &str,
|
||||
) {
|
||||
assert_eq!(debug, format!("{:?}", value));
|
||||
assert_eq!(uhex, format!("{:X}", value));
|
||||
assert_eq!(lhex, format!("{:x}", value));
|
||||
assert_eq!(oct, format!("{:o}", value));
|
||||
assert_eq!(bin, format!("{:b}", value));
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(Some(0), 0, TestFlags::from_bits);
|
||||
case(Some(1), 1, TestFlags::from_bits);
|
||||
case(
|
||||
Some(1 | 1 << 1 | 1 << 2),
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
TestFlags::from_bits,
|
||||
);
|
||||
|
||||
case(None, 1 << 3, TestFlags::from_bits);
|
||||
case(None, 1 | 1 << 3, TestFlags::from_bits);
|
||||
|
||||
case(Some(1 | 1 << 1), 1 | 1 << 1, TestOverlapping::from_bits);
|
||||
|
||||
case(Some(1 << 1), 1 << 1, TestOverlapping::from_bits);
|
||||
|
||||
case(Some(1 << 5), 1 << 5, TestExternal::from_bits);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(
|
||||
expected: Option<T::Bits>,
|
||||
input: T::Bits,
|
||||
inherent: impl FnOnce(T::Bits) -> Option<T>,
|
||||
) where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
expected,
|
||||
inherent(input).map(|f| f.bits()),
|
||||
"T::from_bits({:?})",
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
T::from_bits(input).map(|f| f.bits()),
|
||||
"Flags::from_bits({:?})",
|
||||
input
|
||||
);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(0, TestFlags::from_bits_retain);
|
||||
case(1, TestFlags::from_bits_retain);
|
||||
case(1 | 1 << 1 | 1 << 2, TestFlags::from_bits_retain);
|
||||
|
||||
case(1 << 3, TestFlags::from_bits_retain);
|
||||
case(1 | 1 << 3, TestFlags::from_bits_retain);
|
||||
|
||||
case(1 | 1 << 1, TestOverlapping::from_bits_retain);
|
||||
|
||||
case(1 << 1, TestOverlapping::from_bits_retain);
|
||||
|
||||
case(1 << 5, TestExternal::from_bits_retain);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(input: T::Bits, inherent: impl FnOnce(T::Bits) -> T)
|
||||
where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
input,
|
||||
inherent(input).bits(),
|
||||
"T::from_bits_retain({:?})",
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
input,
|
||||
T::from_bits_retain(input).bits(),
|
||||
"Flags::from_bits_retain({:?})",
|
||||
input
|
||||
);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(0, 0, TestFlags::from_bits_truncate);
|
||||
case(1, 1, TestFlags::from_bits_truncate);
|
||||
case(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
TestFlags::from_bits_truncate,
|
||||
);
|
||||
|
||||
case(0, 1 << 3, TestFlags::from_bits_truncate);
|
||||
case(1, 1 | 1 << 3, TestFlags::from_bits_truncate);
|
||||
|
||||
case(1 | 1 << 1, 1 | 1 << 1, TestOverlapping::from_bits_truncate);
|
||||
|
||||
case(1 << 1, 1 << 1, TestOverlapping::from_bits_truncate);
|
||||
|
||||
case(1 << 5, 1 << 5, TestExternal::from_bits_truncate);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(expected: T::Bits, input: T::Bits, inherent: impl FnOnce(T::Bits) -> T)
|
||||
where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
expected,
|
||||
inherent(input).bits(),
|
||||
"T::from_bits_truncate({:?})",
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
T::from_bits_truncate(input).bits(),
|
||||
"Flags::from_bits_truncate({:?})",
|
||||
input
|
||||
);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(Some(1), "A", TestFlags::from_name);
|
||||
case(Some(1 << 1), "B", TestFlags::from_name);
|
||||
case(Some(1 | 1 << 1 | 1 << 2), "ABC", TestFlags::from_name);
|
||||
|
||||
case(None, "", TestFlags::from_name);
|
||||
case(None, "a", TestFlags::from_name);
|
||||
case(None, "0x1", TestFlags::from_name);
|
||||
case(None, "A | B", TestFlags::from_name);
|
||||
|
||||
case(Some(0), "ZERO", TestZero::from_name);
|
||||
|
||||
case(Some(2), "二", TestUnicode::from_name);
|
||||
|
||||
case(None, "_", TestExternal::from_name);
|
||||
|
||||
case(None, "", TestExternal::from_name);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags>(expected: Option<T::Bits>, input: &str, inherent: impl FnOnce(&str) -> Option<T>)
|
||||
where
|
||||
<T as Flags>::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
expected,
|
||||
inherent(input).map(|f| f.bits()),
|
||||
"T::from_name({:?})",
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
T::from_name(input).map(|f| f.bits()),
|
||||
"Flags::from_name({:?})",
|
||||
input
|
||||
);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::A, 1),
|
||||
(TestFlags::A | TestFlags::B, 1 | 1 << 1),
|
||||
(TestFlags::empty(), 0),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1 << 3),
|
||||
],
|
||||
TestFlags::insert,
|
||||
TestFlags::set,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::A, 1),
|
||||
(TestFlags::empty(), 1),
|
||||
(TestFlags::B, 1 | 1 << 1),
|
||||
],
|
||||
TestFlags::insert,
|
||||
TestFlags::set,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent_insert: impl FnMut(&mut T, T),
|
||||
mut inherent_set: impl FnMut(&mut T, T, bool),
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
inherent_insert(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.insert({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
Flags::insert(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"Flags::insert({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
inherent_set(&mut value, *input, true);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.set({:?}, true)",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
Flags::set(&mut value, *input, true);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"Flags::set({:?}, {:?}, true)",
|
||||
value,
|
||||
input
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[(TestFlags::empty(), 0), (TestFlags::all(), 0)],
|
||||
TestFlags::intersection,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::all(),
|
||||
&[
|
||||
(TestFlags::all(), 1 | 1 << 1 | 1 << 2),
|
||||
(TestFlags::A, 1),
|
||||
(TestFlags::from_bits_retain(1 << 3), 0),
|
||||
],
|
||||
TestFlags::intersection,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
&[(TestFlags::from_bits_retain(1 << 3), 1 << 3)],
|
||||
TestFlags::intersection,
|
||||
);
|
||||
|
||||
case(
|
||||
TestOverlapping::AB,
|
||||
&[(TestOverlapping::BC, 1 << 1)],
|
||||
TestOverlapping::intersection,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + std::ops::BitAnd<Output = T> + std::ops::BitAndAssign + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent: impl FnMut(T, T) -> T,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(value, *input).bits(),
|
||||
"{:?}.intersection({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::intersection(value, *input).bits(),
|
||||
"Flags::intersection({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
(value & *input).bits(),
|
||||
"{:?} & {:?}",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
value &= *input;
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?} &= {:?}",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::ABC, true),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
(TestFlags::from_bits_retain(1 | (1 << 3)), true),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::ABC,
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, true),
|
||||
(TestFlags::C, true),
|
||||
(TestFlags::ABC, true),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), true),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestOverlapping::AB,
|
||||
&[
|
||||
(TestOverlapping::AB, true),
|
||||
(TestOverlapping::BC, true),
|
||||
(TestOverlapping::from_bits_retain(1 << 1), true),
|
||||
],
|
||||
TestOverlapping::intersects,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, bool)],
|
||||
mut inherent: impl FnMut(&T, T) -> bool,
|
||||
) {
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(&value, *input),
|
||||
"{:?}.intersects({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::intersects(&value, *input),
|
||||
"Flags::intersects({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(false, TestFlags::empty(), TestFlags::is_all);
|
||||
case(false, TestFlags::A, TestFlags::is_all);
|
||||
|
||||
case(true, TestFlags::ABC, TestFlags::is_all);
|
||||
|
||||
case(
|
||||
true,
|
||||
TestFlags::ABC | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::is_all,
|
||||
);
|
||||
|
||||
case(true, TestZero::empty(), TestZero::is_all);
|
||||
|
||||
case(true, TestEmpty::empty(), TestEmpty::is_all);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug>(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) {
|
||||
assert_eq!(expected, inherent(&value), "{:?}.is_all()", value);
|
||||
assert_eq!(
|
||||
expected,
|
||||
Flags::is_all(&value),
|
||||
"Flags::is_all({:?})",
|
||||
value
|
||||
);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(true, TestFlags::empty(), TestFlags::is_empty);
|
||||
|
||||
case(false, TestFlags::A, TestFlags::is_empty);
|
||||
case(false, TestFlags::ABC, TestFlags::is_empty);
|
||||
case(
|
||||
false,
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::is_empty,
|
||||
);
|
||||
|
||||
case(true, TestZero::empty(), TestZero::is_empty);
|
||||
|
||||
case(true, TestEmpty::empty(), TestEmpty::is_empty);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug>(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) {
|
||||
assert_eq!(expected, inherent(&value), "{:?}.is_empty()", value);
|
||||
assert_eq!(
|
||||
expected,
|
||||
Flags::is_empty(&value),
|
||||
"Flags::is_empty({:?})",
|
||||
value
|
||||
);
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
#[cfg(not(miri))] // Very slow in miri
|
||||
fn roundtrip() {
|
||||
for a in 0u8..=255 {
|
||||
for b in 0u8..=255 {
|
||||
let f = TestFlags::from_bits_retain(a | b);
|
||||
|
||||
assert_eq!(f, f.iter().collect::<TestFlags>());
|
||||
assert_eq!(
|
||||
TestFlags::from_bits_truncate(f.bits()),
|
||||
f.iter_names().map(|(_, f)| f).collect::<TestFlags>()
|
||||
);
|
||||
|
||||
let f = TestExternal::from_bits_retain(a | b);
|
||||
|
||||
assert_eq!(f, f.iter().collect::<TestExternal>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod collect {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
assert_eq!(0, [].into_iter().collect::<TestFlags>().bits());
|
||||
|
||||
assert_eq!(1, [TestFlags::A,].into_iter().collect::<TestFlags>().bits());
|
||||
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
[TestFlags::A, TestFlags::B | TestFlags::C,]
|
||||
.into_iter()
|
||||
.collect::<TestFlags>()
|
||||
.bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
1 | 1 << 3,
|
||||
[
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::empty(),
|
||||
TestFlags::A,
|
||||
]
|
||||
.into_iter()
|
||||
.collect::<TestFlags>()
|
||||
.bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
1 << 5 | 1 << 7,
|
||||
[
|
||||
TestExternal::empty(),
|
||||
TestExternal::from_bits_retain(1 << 5),
|
||||
TestExternal::from_bits_retain(1 << 7),
|
||||
]
|
||||
.into_iter()
|
||||
.collect::<TestExternal>()
|
||||
.bits()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod iter {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(&[], TestFlags::empty(), TestFlags::iter);
|
||||
|
||||
case(&[1], TestFlags::A, TestFlags::iter);
|
||||
case(&[1, 1 << 1], TestFlags::A | TestFlags::B, TestFlags::iter);
|
||||
case(
|
||||
&[1, 1 << 1, 1 << 3],
|
||||
TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::iter,
|
||||
);
|
||||
|
||||
case(&[1, 1 << 1, 1 << 2], TestFlags::ABC, TestFlags::iter);
|
||||
case(
|
||||
&[1, 1 << 1, 1 << 2, 1 << 3],
|
||||
TestFlags::ABC | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::iter,
|
||||
);
|
||||
|
||||
case(
|
||||
&[1 | 1 << 1 | 1 << 2],
|
||||
TestFlagsInvert::ABC,
|
||||
TestFlagsInvert::iter,
|
||||
);
|
||||
|
||||
case(&[], TestZero::ZERO, TestZero::iter);
|
||||
|
||||
case(
|
||||
&[1, 1 << 1, 1 << 2, 0b1111_1000],
|
||||
TestExternal::all(),
|
||||
TestExternal::iter,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + IntoIterator<Item = T> + Copy>(
|
||||
expected: &[T::Bits],
|
||||
value: T,
|
||||
inherent: impl FnOnce(&T) -> crate::iter::Iter<T>,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
expected,
|
||||
inherent(&value).map(|f| f.bits()).collect::<Vec<_>>(),
|
||||
"{:?}.iter()",
|
||||
value
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
Flags::iter(&value).map(|f| f.bits()).collect::<Vec<_>>(),
|
||||
"Flags::iter({:?})",
|
||||
value
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
value.into_iter().map(|f| f.bits()).collect::<Vec<_>>(),
|
||||
"{:?}.into_iter()",
|
||||
value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod iter_names {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(&[], TestFlags::empty(), TestFlags::iter_names);
|
||||
|
||||
case(&[("A", 1)], TestFlags::A, TestFlags::iter_names);
|
||||
case(
|
||||
&[("A", 1), ("B", 1 << 1)],
|
||||
TestFlags::A | TestFlags::B,
|
||||
TestFlags::iter_names,
|
||||
);
|
||||
case(
|
||||
&[("A", 1), ("B", 1 << 1)],
|
||||
TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::iter_names,
|
||||
);
|
||||
|
||||
case(
|
||||
&[("A", 1), ("B", 1 << 1), ("C", 1 << 2)],
|
||||
TestFlags::ABC,
|
||||
TestFlags::iter_names,
|
||||
);
|
||||
case(
|
||||
&[("A", 1), ("B", 1 << 1), ("C", 1 << 2)],
|
||||
TestFlags::ABC | TestFlags::from_bits_retain(1 << 3),
|
||||
TestFlags::iter_names,
|
||||
);
|
||||
|
||||
case(
|
||||
&[("ABC", 1 | 1 << 1 | 1 << 2)],
|
||||
TestFlagsInvert::ABC,
|
||||
TestFlagsInvert::iter_names,
|
||||
);
|
||||
|
||||
case(&[], TestZero::ZERO, TestZero::iter_names);
|
||||
|
||||
case(
|
||||
&[("A", 1)],
|
||||
TestOverlappingFull::A,
|
||||
TestOverlappingFull::iter_names,
|
||||
);
|
||||
case(
|
||||
&[("A", 1), ("D", 1 << 1)],
|
||||
TestOverlappingFull::A | TestOverlappingFull::D,
|
||||
TestOverlappingFull::iter_names,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug>(
|
||||
expected: &[(&'static str, T::Bits)],
|
||||
value: T,
|
||||
inherent: impl FnOnce(&T) -> crate::iter::IterNames<T>,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
expected,
|
||||
inherent(&value)
|
||||
.map(|(n, f)| (n, f.bits()))
|
||||
.collect::<Vec<_>>(),
|
||||
"{:?}.iter_names()",
|
||||
value
|
||||
);
|
||||
assert_eq!(
|
||||
expected,
|
||||
Flags::iter_names(&value)
|
||||
.map(|(n, f)| (n, f.bits()))
|
||||
.collect::<Vec<_>>(),
|
||||
"Flags::iter_names({:?})",
|
||||
value
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
use super::*;
|
||||
|
||||
use crate::{parser::*, Flags};
|
||||
|
||||
#[test]
|
||||
#[cfg(not(miri))] // Very slow in miri
|
||||
fn roundtrip() {
|
||||
let mut s = String::new();
|
||||
|
||||
for a in 0u8..=255 {
|
||||
for b in 0u8..=255 {
|
||||
let f = TestFlags::from_bits_retain(a | b);
|
||||
|
||||
s.clear();
|
||||
to_writer(&f, &mut s).unwrap();
|
||||
|
||||
assert_eq!(f, from_str::<TestFlags>(&s).unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(miri))] // Very slow in miri
|
||||
fn roundtrip_truncate() {
|
||||
let mut s = String::new();
|
||||
|
||||
for a in 0u8..=255 {
|
||||
for b in 0u8..=255 {
|
||||
let f = TestFlags::from_bits_retain(a | b);
|
||||
|
||||
s.clear();
|
||||
to_writer_truncate(&f, &mut s).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
TestFlags::from_bits_truncate(f.bits()),
|
||||
from_str_truncate::<TestFlags>(&s).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(miri))] // Very slow in miri
|
||||
fn roundtrip_strict() {
|
||||
let mut s = String::new();
|
||||
|
||||
for a in 0u8..=255 {
|
||||
for b in 0u8..=255 {
|
||||
let f = TestFlags::from_bits_retain(a | b);
|
||||
|
||||
s.clear();
|
||||
to_writer_strict(&f, &mut s).unwrap();
|
||||
|
||||
let mut strict = TestFlags::empty();
|
||||
for (_, flag) in f.iter_names() {
|
||||
strict |= flag;
|
||||
}
|
||||
let f = strict;
|
||||
|
||||
if let Ok(s) = from_str_strict::<TestFlags>(&s) {
|
||||
assert_eq!(f, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod from_str {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn valid() {
|
||||
assert_eq!(0, from_str::<TestFlags>("").unwrap().bits());
|
||||
|
||||
assert_eq!(1, from_str::<TestFlags>("A").unwrap().bits());
|
||||
assert_eq!(1, from_str::<TestFlags>(" A ").unwrap().bits());
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str::<TestFlags>("A | B | C").unwrap().bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str::<TestFlags>("A\n|\tB\r\n| C ").unwrap().bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str::<TestFlags>("A|B|C").unwrap().bits()
|
||||
);
|
||||
|
||||
assert_eq!(1 << 3, from_str::<TestFlags>("0x8").unwrap().bits());
|
||||
assert_eq!(1 | 1 << 3, from_str::<TestFlags>("A | 0x8").unwrap().bits());
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 3,
|
||||
from_str::<TestFlags>("0x1 | 0x8 | B").unwrap().bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
1 | 1 << 1,
|
||||
from_str::<TestUnicode>("一 | 二").unwrap().bits()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid() {
|
||||
assert!(from_str::<TestFlags>("a")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("unrecognized named flag"));
|
||||
assert!(from_str::<TestFlags>("A & B")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("unrecognized named flag"));
|
||||
|
||||
assert!(from_str::<TestFlags>("0xg")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("invalid hex flag"));
|
||||
assert!(from_str::<TestFlags>("0xffffffffffff")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("invalid hex flag"));
|
||||
}
|
||||
}
|
||||
|
||||
mod to_writer {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
assert_eq!("", write(TestFlags::empty()));
|
||||
assert_eq!("A", write(TestFlags::A));
|
||||
assert_eq!("A | B | C", write(TestFlags::all()));
|
||||
assert_eq!("0x8", write(TestFlags::from_bits_retain(1 << 3)));
|
||||
assert_eq!(
|
||||
"A | 0x8",
|
||||
write(TestFlags::A | TestFlags::from_bits_retain(1 << 3))
|
||||
);
|
||||
|
||||
assert_eq!("", write(TestZero::ZERO));
|
||||
|
||||
assert_eq!("ABC", write(TestFlagsInvert::all()));
|
||||
|
||||
assert_eq!("0x1", write(TestOverlapping::from_bits_retain(1)));
|
||||
|
||||
assert_eq!("A", write(TestOverlappingFull::C));
|
||||
assert_eq!(
|
||||
"A | D",
|
||||
write(TestOverlappingFull::C | TestOverlappingFull::D)
|
||||
);
|
||||
}
|
||||
|
||||
fn write<F: Flags>(value: F) -> String
|
||||
where
|
||||
F::Bits: crate::parser::WriteHex,
|
||||
{
|
||||
let mut s = String::new();
|
||||
|
||||
to_writer(&value, &mut s).unwrap();
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
mod from_str_truncate {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn valid() {
|
||||
assert_eq!(0, from_str_truncate::<TestFlags>("").unwrap().bits());
|
||||
|
||||
assert_eq!(1, from_str_truncate::<TestFlags>("A").unwrap().bits());
|
||||
assert_eq!(1, from_str_truncate::<TestFlags>(" A ").unwrap().bits());
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_truncate::<TestFlags>("A | B | C").unwrap().bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_truncate::<TestFlags>("A\n|\tB\r\n| C ")
|
||||
.unwrap()
|
||||
.bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_truncate::<TestFlags>("A|B|C").unwrap().bits()
|
||||
);
|
||||
|
||||
assert_eq!(0, from_str_truncate::<TestFlags>("0x8").unwrap().bits());
|
||||
assert_eq!(1, from_str_truncate::<TestFlags>("A | 0x8").unwrap().bits());
|
||||
assert_eq!(
|
||||
1 | 1 << 1,
|
||||
from_str_truncate::<TestFlags>("0x1 | 0x8 | B")
|
||||
.unwrap()
|
||||
.bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
1 | 1 << 1,
|
||||
from_str_truncate::<TestUnicode>("一 | 二").unwrap().bits()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod to_writer_truncate {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
assert_eq!("", write(TestFlags::empty()));
|
||||
assert_eq!("A", write(TestFlags::A));
|
||||
assert_eq!("A | B | C", write(TestFlags::all()));
|
||||
assert_eq!("", write(TestFlags::from_bits_retain(1 << 3)));
|
||||
assert_eq!(
|
||||
"A",
|
||||
write(TestFlags::A | TestFlags::from_bits_retain(1 << 3))
|
||||
);
|
||||
|
||||
assert_eq!("", write(TestZero::ZERO));
|
||||
|
||||
assert_eq!("ABC", write(TestFlagsInvert::all()));
|
||||
|
||||
assert_eq!("0x1", write(TestOverlapping::from_bits_retain(1)));
|
||||
|
||||
assert_eq!("A", write(TestOverlappingFull::C));
|
||||
assert_eq!(
|
||||
"A | D",
|
||||
write(TestOverlappingFull::C | TestOverlappingFull::D)
|
||||
);
|
||||
}
|
||||
|
||||
fn write<F: Flags>(value: F) -> String
|
||||
where
|
||||
F::Bits: crate::parser::WriteHex,
|
||||
{
|
||||
let mut s = String::new();
|
||||
|
||||
to_writer_truncate(&value, &mut s).unwrap();
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
mod from_str_strict {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn valid() {
|
||||
assert_eq!(0, from_str_strict::<TestFlags>("").unwrap().bits());
|
||||
|
||||
assert_eq!(1, from_str_strict::<TestFlags>("A").unwrap().bits());
|
||||
assert_eq!(1, from_str_strict::<TestFlags>(" A ").unwrap().bits());
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_strict::<TestFlags>("A | B | C").unwrap().bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_strict::<TestFlags>("A\n|\tB\r\n| C ")
|
||||
.unwrap()
|
||||
.bits()
|
||||
);
|
||||
assert_eq!(
|
||||
1 | 1 << 1 | 1 << 2,
|
||||
from_str_strict::<TestFlags>("A|B|C").unwrap().bits()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
1 | 1 << 1,
|
||||
from_str_strict::<TestUnicode>("一 | 二").unwrap().bits()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid() {
|
||||
assert!(from_str_strict::<TestFlags>("a")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("unrecognized named flag"));
|
||||
assert!(from_str_strict::<TestFlags>("A & B")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("unrecognized named flag"));
|
||||
|
||||
assert!(from_str_strict::<TestFlags>("0x1")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("invalid hex flag"));
|
||||
assert!(from_str_strict::<TestFlags>("0xg")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("invalid hex flag"));
|
||||
assert!(from_str_strict::<TestFlags>("0xffffffffffff")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.starts_with("invalid hex flag"));
|
||||
}
|
||||
}
|
||||
|
||||
mod to_writer_strict {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
assert_eq!("", write(TestFlags::empty()));
|
||||
assert_eq!("A", write(TestFlags::A));
|
||||
assert_eq!("A | B | C", write(TestFlags::all()));
|
||||
assert_eq!("", write(TestFlags::from_bits_retain(1 << 3)));
|
||||
assert_eq!(
|
||||
"A",
|
||||
write(TestFlags::A | TestFlags::from_bits_retain(1 << 3))
|
||||
);
|
||||
|
||||
assert_eq!("", write(TestZero::ZERO));
|
||||
|
||||
assert_eq!("ABC", write(TestFlagsInvert::all()));
|
||||
|
||||
assert_eq!("", write(TestOverlapping::from_bits_retain(1)));
|
||||
|
||||
assert_eq!("A", write(TestOverlappingFull::C));
|
||||
assert_eq!(
|
||||
"A | D",
|
||||
write(TestOverlappingFull::C | TestOverlappingFull::D)
|
||||
);
|
||||
}
|
||||
|
||||
fn write<F: Flags>(value: F) -> String
|
||||
where
|
||||
F::Bits: crate::parser::WriteHex,
|
||||
{
|
||||
let mut s = String::new();
|
||||
|
||||
to_writer_strict(&value, &mut s).unwrap();
|
||||
s
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::A, 0),
|
||||
(TestFlags::empty(), 0),
|
||||
(TestFlags::from_bits_retain(1 << 3), 0),
|
||||
],
|
||||
TestFlags::remove,
|
||||
TestFlags::set,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::A, 0),
|
||||
(TestFlags::empty(), 1),
|
||||
(TestFlags::B, 1),
|
||||
],
|
||||
TestFlags::remove,
|
||||
TestFlags::set,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::ABC,
|
||||
&[
|
||||
(TestFlags::A, 1 << 1 | 1 << 2),
|
||||
(TestFlags::A | TestFlags::C, 1 << 1),
|
||||
],
|
||||
TestFlags::remove,
|
||||
TestFlags::set,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent_remove: impl FnMut(&mut T, T),
|
||||
mut inherent_set: impl FnMut(&mut T, T, bool),
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
inherent_remove(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.remove({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
Flags::remove(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"Flags::remove({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
inherent_set(&mut value, *input, false);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.set({:?}, false)",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
Flags::set(&mut value, *input, false);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"Flags::set({:?}, {:?}, false)",
|
||||
value,
|
||||
input
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::empty(), 0),
|
||||
(TestFlags::all(), 1 | 1 << 1 | 1 << 2),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1 << 3),
|
||||
],
|
||||
TestFlags::symmetric_difference,
|
||||
TestFlags::toggle,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::empty(), 1),
|
||||
(TestFlags::A, 0),
|
||||
(TestFlags::all(), 1 << 1 | 1 << 2),
|
||||
],
|
||||
TestFlags::symmetric_difference,
|
||||
TestFlags::toggle,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3),
|
||||
&[
|
||||
(TestFlags::ABC, 1 << 2 | 1 << 3),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1 | 1 << 1),
|
||||
],
|
||||
TestFlags::symmetric_difference,
|
||||
TestFlags::toggle,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + std::ops::BitXor<Output = T> + std::ops::BitXorAssign + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent_sym_diff: impl FnMut(T, T) -> T,
|
||||
mut inherent_toggle: impl FnMut(&mut T, T),
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent_sym_diff(value, *input).bits(),
|
||||
"{:?}.symmetric_difference({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::symmetric_difference(value, *input).bits(),
|
||||
"Flags::symmetric_difference({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
(value ^ *input).bits(),
|
||||
"{:?} ^ {:?}",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
value ^= *input;
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?} ^= {:?}",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
inherent_toggle(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.toggle({:?})",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
Flags::toggle(&mut value, *input);
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?}.toggle({:?})",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::A, 1),
|
||||
(TestFlags::all(), 1 | 1 << 1 | 1 << 2),
|
||||
(TestFlags::empty(), 0),
|
||||
(TestFlags::from_bits_retain(1 << 3), 1 << 3),
|
||||
],
|
||||
TestFlags::union,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A | TestFlags::C,
|
||||
&[
|
||||
(TestFlags::A | TestFlags::B, 1 | 1 << 1 | 1 << 2),
|
||||
(TestFlags::A, 1 | 1 << 2),
|
||||
],
|
||||
TestFlags::union,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + std::ops::BitOr<Output = T> + std::ops::BitOrAssign + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, T::Bits)],
|
||||
mut inherent: impl FnMut(T, T) -> T,
|
||||
) where
|
||||
T::Bits: std::fmt::Debug + PartialEq + Copy,
|
||||
{
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(value, *input).bits(),
|
||||
"{:?}.union({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::union(value, *input).bits(),
|
||||
"Flags::union({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
(value | *input).bits(),
|
||||
"{:?} | {:?}",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
{
|
||||
let mut value = value;
|
||||
value |= *input;
|
||||
value
|
||||
}
|
||||
.bits(),
|
||||
"{:?} |= {:?}",
|
||||
value,
|
||||
input,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ use crate::{
|
|||
/**
|
||||
A defined flags value that may be named or unnamed.
|
||||
*/
|
||||
#[derive(Debug)]
|
||||
pub struct Flag<B> {
|
||||
name: &'static str,
|
||||
value: B,
|
||||
|
|
|
@ -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"}
|
||||
{"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"}
|
|
@ -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 = []
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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 "C" {
|
||||
/*
|
||||
* CFAttributedString.h
|
||||
*/
|
||||
|
||||
extern {
|
||||
/* 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;
|
||||
|
||||
pub fn CFAttributedStringReplaceString(
|
||||
astr: CFMutableAttributedStringRef, range: CFRange, replacement: CFStringRef);
|
||||
|
||||
pub fn CFAttributedStringSetAttribute(
|
||||
astr: 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,
|
||||
attr_name: CFStringRef,
|
||||
attrName: CFStringRef,
|
||||
);
|
||||
pub fn CFAttributedStringReplaceString(
|
||||
aStr: CFMutableAttributedStringRef,
|
||||
range: CFRange,
|
||||
replacement: CFStringRef,
|
||||
);
|
||||
pub fn CFAttributedStringReplaceAttributedString(
|
||||
aStr: CFMutableAttributedStringRef,
|
||||
range: CFRange,
|
||||
replacement: CFAttributedStringRef,
|
||||
);
|
||||
pub fn CFAttributedStringSetAttribute(
|
||||
aStr: CFMutableAttributedStringRef,
|
||||
range: CFRange,
|
||||
attrName: CFStringRef,
|
||||
value: CFTypeRef,
|
||||
);
|
||||
|
||||
pub fn CFAttributedStringSetAttributes(
|
||||
aStr: CFMutableAttributedStringRef,
|
||||
range: CFRange,
|
||||
replacement: CFDictionaryRef,
|
||||
clearOtherAttributes: Boolean,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
*/
|
||||
|
||||
/* 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 CFBundleCopySharedSupportURL(bundle: CFBundleRef) -> CFURLRef;
|
||||
pub fn CFBundleCopyBundleURL(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 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 {
|
||||
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;
|
||||
pub fn CFCharacterSetCreateMutable(alloc: CFAllocatorRef) -> CFMutableCharacterSetRef;
|
||||
pub fn CFCharacterSetCreateCopy(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFCharacterSetRef;
|
||||
pub fn CFCharacterSetCreateMutableCopy(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFMutableCharacterSetRef;
|
||||
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 CFCharacterSetCreateBitmapRepresentation(alloc: CFAllocatorRef, theSet: CFCharacterSetRef) -> CFDataRef;
|
||||
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;
|
||||
|
||||
/* CFMutableCharacterSet */
|
||||
/* Creating a Mutable Character Set */
|
||||
pub fn CFCharacterSetCreateMutable(alloc: CFAllocatorRef) -> CFMutableCharacterSetRef;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
extern {
|
||||
// typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags)
|
||||
pub const kCFDataSearchBackwards: CFDataSearchFlags = 1usize << 0;
|
||||
pub const kCFDataSearchAnchored: CFDataSearchFlags = 1usize << 1;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)+
|
||||
}
|
|
@ -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;
|
||||
|
||||
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 CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex;
|
||||
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);
|
||||
/* 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;
|
||||
|
||||
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);
|
||||
/* Examining a dictionary */
|
||||
pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean;
|
||||
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;
|
||||
|
||||
/* 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,
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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)]
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
|
||||
extern "C" {
|
||||
// CFPropertyList.h
|
||||
//
|
||||
/* 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;
|
||||
|
||||
// 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;
|
||||
extern "C" {
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -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 CFRunLoopAddSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef);
|
||||
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;
|
||||
pub fn CFRunLoopAddTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef);
|
||||
pub fn CFRunLoopRemoveTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef);
|
||||
pub fn CFRunLoopIsWaiting(rl: CFRunLoopRef) -> Boolean;
|
||||
|
||||
pub fn CFRunLoopSourceGetTypeID() -> CFTypeID;
|
||||
pub fn CFRunLoopSourceCreate(allocator: CFAllocatorRef, order: CFIndex, context: *mut CFRunLoopSourceContext) -> CFRunLoopSourceRef;
|
||||
/* 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);
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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)+
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
||||
pub type CFStringEncodings = CFIndex;
|
||||
|
||||
// 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 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 const kCFStringEncodingInvalidId: u32 = 0xffffffff;
|
||||
|
||||
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;
|
||||
|
||||
extern {
|
||||
/* 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 "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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 CFTimeZoneGetSecondsFromGMT(tz: CFTimeZoneRef, time: CFAbsoluteTime) -> CFTimeInterval;
|
||||
pub fn CFTimeZoneCopySystem() -> CFTimeZoneRef;
|
||||
pub fn CFTimeZoneSetDefault(tz: CFTimeZoneRef);
|
||||
pub fn CFTimeZoneCopyKnownNames() -> CFArrayRef;
|
||||
pub fn CFTimeZoneResetSystem();
|
||||
pub fn CFTimeZoneSetAbbreviationDictionary(dict: CFDictionaryRef);
|
||||
|
||||
pub fn CFTimeZoneGetTypeID() -> CFTypeID;
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
extern {
|
||||
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;
|
||||
|
||||
/* 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 };
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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"}
|
||||
{"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"}
|
|
@ -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"]
|
||||
|
|
|
@ -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 fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn get_unchecked<'a>(&'a self, index: CFIndex) -> ItemRef<'a, T> where T: FromVoid {
|
||||
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);
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
assert_eq!(
|
||||
*mut_dict.get(&CFString::from_static_string("Foo")),
|
||||
CFBoolean::true_value()
|
||||
);
|
||||
|
||||
mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_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);
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче