Bug 1433567 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel

MozReview-Commit-ID: HpOX4MTdU9Z

--HG--
extra : rebase_source : c9da41ea1c96097fb51e55d5227cde66e5e6c47b
This commit is contained in:
Kartikaya Gupta 2018-01-30 10:22:30 -05:00
parent c13256c877
commit 063a144958
44 changed files with 1646 additions and 491 deletions

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"25d7d7f3e09bad757c9ae1de8933fe75265990d0969bd92435934ff06d85e318","build.rs":"9433ed3b20cc99e716dda4c6d8507c29bc04882544cbbea8d4e48ba80fd0fa12","src/array.rs":"c70be1c0485612ac327a4fc9ca87098034e13df80dead23167560a38471fb823","src/base.rs":"d2b0474725a28731ac29bedb657c1382f100b47a8b3078bee1bee9ace6060411","src/bundle.rs":"1b6df1e2a112c1965c5b5ae095634444b771eb078e78bc5b251714b9ccc3d8e0","src/data.rs":"21e968951fe56e080d33474f4438de2dfb7e0c8af426a6dfb100efdd6c530eec","src/date.rs":"90f29b07d3bd1549a3ab64adaaf153aff5ba546c1cd449f7248479d26bce9687","src/dictionary.rs":"35a9e190eb8c81bc923cabf8da869c8d69249d911108f173bd936f2fe06804cd","src/error.rs":"61bc31a401ec6c8495668175eade9284e257da056fc666af74a5555af5daf33f","src/lib.rs":"74737fc5bd7ffc7a2e6446363aaf94909492d0d3163408c9d12c5fd8ac3bfd65","src/messageport.rs":"59ba92ca90bb9b3162b6df44188fac18cd979250f33a52361144c902e86529bd","src/number.rs":"4e69c688f24a1226fb40faec7d18861b5a617afcedbb352331c45a8e4eff292a","src/propertylist.rs":"cc2b27f8f8ebc80c03871b7b1ad50ee348539b016078ce721c86b8cd5f9d75bd","src/runloop.rs":"7feab3bbb9913c3b40285bc37b920f9fe4d937d1db08d8ae69a2ec9597713598","src/set.rs":"22055b5ce6a2ce37847ee955f5e6e517348a351770d335373704776bc5412b9f","src/string.rs":"0e9373c6e48c97d7cbdb2ceaa07bc0af4e5d25ab0f91b138b4f8667cff337f4e","src/timezone.rs":"6711924b967d96ba88be4976cf17dfd3f9573033115da8e61ad07e8b0f26cdb7","src/url.rs":"b85110fe203c685719ba92517ff3c09ce0fe358e15380ecc0bd18356ac3573ed","src/uuid.rs":"e591e0bac875832acc15ea7ee0c9bff296543f4f77470101de0602ee69c2e527"},"package":"152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5"}
{"files":{"Cargo.toml":"08b77adecca4222d97b0fb359b1c9ce97983e0e0914a4418834c032395af76ea","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","build.rs":"9433ed3b20cc99e716dda4c6d8507c29bc04882544cbbea8d4e48ba80fd0fa12","src/array.rs":"c70be1c0485612ac327a4fc9ca87098034e13df80dead23167560a38471fb823","src/base.rs":"37ad5b765d9e70f043f70a26da65cc46f0af5f1361e431e6f8591a143a31da31","src/bundle.rs":"b4e0e9b7ca2e35e3dc9bee316690538a5d17a470f8173f6b80c6816c847d12ec","src/data.rs":"21e968951fe56e080d33474f4438de2dfb7e0c8af426a6dfb100efdd6c530eec","src/date.rs":"90f29b07d3bd1549a3ab64adaaf153aff5ba546c1cd449f7248479d26bce9687","src/dictionary.rs":"37d881fbcf3232f90ab8648084b0f26b45ffee882b95e76831ac206f3e35f7de","src/error.rs":"61bc31a401ec6c8495668175eade9284e257da056fc666af74a5555af5daf33f","src/filedescriptor.rs":"14800c805b66f1fd6f995a6e73138d65a724163acb8a3f8f2539c807d333473d","src/lib.rs":"1038a1292f6f6c790ae055242015b8e3b91c2cccce34bfba240403399149f64c","src/messageport.rs":"f22b8552ff8b8e1edf25fe322eeabd9d7e5472b11514b95bc936387e4fa51b2a","src/number.rs":"4e69c688f24a1226fb40faec7d18861b5a617afcedbb352331c45a8e4eff292a","src/propertylist.rs":"cc2b27f8f8ebc80c03871b7b1ad50ee348539b016078ce721c86b8cd5f9d75bd","src/runloop.rs":"1d4aba9425669ef32450396c31655a90daf0e67d579e4617465fb7abe23c047f","src/set.rs":"22055b5ce6a2ce37847ee955f5e6e517348a351770d335373704776bc5412b9f","src/string.rs":"0e9373c6e48c97d7cbdb2ceaa07bc0af4e5d25ab0f91b138b4f8667cff337f4e","src/timezone.rs":"6711924b967d96ba88be4976cf17dfd3f9573033115da8e61ad07e8b0f26cdb7","src/url.rs":"b85110fe203c685719ba92517ff3c09ce0fe358e15380ecc0bd18356ac3573ed","src/uuid.rs":"e591e0bac875832acc15ea7ee0c9bff296543f4f77470101de0602ee69c2e527"},"package":"716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"}

View File

@ -12,7 +12,7 @@
[package]
name = "core-foundation-sys"
version = "0.4.6"
version = "0.5.1"
authors = ["The Servo Project Developers"]
build = "build.rs"
description = "Bindings to Core Foundation for OS X"

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,25 @@
Copyright (c) 2012-2013 Mozilla Foundation
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -80,6 +80,33 @@ pub struct CFAllocatorContext {
pub preferredSize: CFAllocatorPreferredSizeCallBack
}
/// Trait for all types which are Core Foundation reference types.
pub trait TCFTypeRef {
fn as_void_ptr(&self) -> *const c_void;
unsafe fn from_void_ptr(ptr: *const c_void) -> Self;
}
impl<T> TCFTypeRef for *const T {
fn as_void_ptr(&self) -> *const c_void {
(*self) as *const c_void
}
unsafe fn from_void_ptr(ptr: *const c_void) -> Self {
ptr as *const T
}
}
impl<T> TCFTypeRef for *mut T {
fn as_void_ptr(&self) -> *const c_void {
(*self) as *const T as *const c_void
}
unsafe fn from_void_ptr(ptr: *const c_void) -> Self {
ptr as *const T as *mut T
}
}
extern {
/*
* CFBase.h

View File

@ -17,7 +17,7 @@ use string::CFStringRef;
#[repr(C)]
pub struct __CFBundle(c_void);
pub type CFBundleRef = *const __CFBundle;
pub type CFBundleRef = *mut __CFBundle;
extern {
/*

View File

@ -45,7 +45,7 @@ pub struct CFDictionaryValueCallBacks {
pub struct __CFDictionary(c_void);
pub type CFDictionaryRef = *const __CFDictionary;
pub type CFMutableDictionaryRef = *const __CFDictionary;
pub type CFMutableDictionaryRef = *mut __CFDictionary;
extern {
/*
@ -67,11 +67,25 @@ extern {
pub fn CFDictionaryApplyFunction(theDict: CFDictionaryRef,
applier: CFDictionaryApplierFunction,
context: *mut c_void);
pub fn CFDictionarySetValue(theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void);
pub fn CFDictionaryGetKeysAndValues(theDict: CFDictionaryRef,
keys: *mut *const c_void,
values: *mut *const c_void);
pub fn CFDictionaryCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex,
keyCallbacks: *const CFDictionaryKeyCallBacks,
valueCallbacks: *const CFDictionaryValueCallBacks) -> CFMutableDictionaryRef;
pub fn CFDictionaryCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex,
theDict: CFDictionaryRef) -> CFMutableDictionaryRef;
pub fn CFDictionaryAddValue(theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void);
pub fn CFDictionarySetValue(theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void);
pub fn CFDictionaryReplaceValue(theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void);
pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef,
key: *const c_void);
pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef);
}

View File

@ -0,0 +1,48 @@
use libc::{c_void, c_int};
use base::{Boolean, CFIndex, CFTypeID, CFOptionFlags, CFAllocatorRef};
use string::CFStringRef;
use runloop::CFRunLoopSourceRef;
pub type CFFileDescriptorNativeDescriptor = c_int;
#[repr(C)]
pub struct __CFFileDescriptor(c_void);
pub type CFFileDescriptorRef = *mut __CFFileDescriptor;
/* Callback Reason Types */
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);
#[repr(C)]
#[derive(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>,
}
extern {
/*
* CFFileDescriptor.h
*/
pub fn CFFileDescriptorGetTypeID() -> CFTypeID;
pub fn CFFileDescriptorCreate(allocator: CFAllocatorRef, fd: CFFileDescriptorNativeDescriptor, closeOnInvalidate: Boolean, callout: CFFileDescriptorCallBack, context: *const CFFileDescriptorContext) -> CFFileDescriptorRef;
pub fn CFFileDescriptorGetNativeDescriptor(f: CFFileDescriptorRef) -> CFFileDescriptorNativeDescriptor;
pub fn CFFileDescriptorGetContext(f: CFFileDescriptorRef, context: *mut CFFileDescriptorContext);
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;
pub fn CFFileDescriptorCreateRunLoopSource(allocator: CFAllocatorRef, f: CFFileDescriptorRef, order: CFIndex) -> CFRunLoopSourceRef;
}

View File

@ -19,6 +19,7 @@ pub mod data;
pub mod date;
pub mod dictionary;
pub mod error;
pub mod filedescriptor;
pub mod messageport;
pub mod number;
pub mod propertylist;

View File

@ -38,7 +38,7 @@ pub type CFMessagePortInvalidationCallBack = Option<
#[repr(C)]
pub struct __CFMessagePort(c_void);
pub type CFMessagePortRef = *const __CFMessagePort;
pub type CFMessagePortRef = *mut __CFMessagePort;
extern {
/*

View File

@ -17,17 +17,17 @@ use string::CFStringRef;
#[repr(C)]
pub struct __CFRunLoop(c_void);
pub type CFRunLoopRef = *const __CFRunLoop;
pub type CFRunLoopRef = *mut __CFRunLoop;
#[repr(C)]
pub struct __CFRunLoopSource(c_void);
pub type CFRunLoopSourceRef = *const __CFRunLoopSource;
pub type CFRunLoopSourceRef = *mut __CFRunLoopSource;
#[repr(C)]
pub struct __CFRunLoopObserver(c_void);
pub type CFRunLoopObserverRef = *const __CFRunLoopObserver;
pub type CFRunLoopObserverRef = *mut __CFRunLoopObserver;
// Reasons for CFRunLoopRunInMode() to Return
pub const kCFRunLoopRunFinished: i32 = 1;
@ -99,7 +99,7 @@ pub type CFRunLoopTimerCallBack = extern "C" fn (timer: CFRunLoopTimerRef, info:
#[repr(C)]
pub struct __CFRunLoopTimer;
pub type CFRunLoopTimerRef = *const __CFRunLoopTimer;
pub type CFRunLoopTimerRef = *mut __CFRunLoopTimer;
extern {
/*

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"2e10fc485f55e677435630e84c40ea2d6c43819b861982dfb54e5e9d75662cf7","src/array.rs":"dda1a99634934f215e522a4add77e1fcf286249cbe26b44353676281bb3e060a","src/base.rs":"4142d73825fd273fb693756adc93fb3758bc6fc628d2aad3635c7544e447e148","src/boolean.rs":"809f988f45178056682379ec6a2f5f279bdc721e97b8a313118eadc82a36ffb1","src/bundle.rs":"69fa69ec2d8ea8e897363e2351d947235d040eaa5f5ff562e280e59399f56769","src/data.rs":"66dd852ef988dc4f996b18bb1e3e9cb17143e5bb1312e38d209fb728a53f8881","src/date.rs":"b4f562487baa53522071a574c53e80337067be0ca678a5dcf3c4e15d65341627","src/dictionary.rs":"31a1d2fd20ced092df127cb72472a6545344852723a3e922fc7ac0071ec994ee","src/error.rs":"0edbf66bcaa8a68f1de77b9056696b6be4f2dc773f4561f4279e6494cc38453a","src/lib.rs":"47b11c4119aedf01c4b1fb1b391820de6edd4560b45bef7edc6f328b1bc3f588","src/number.rs":"12d3ef89e9e5c2c077b7c3c426fce0249d7fa936dcea75f129b1455699469643","src/propertylist.rs":"e87ca9556b94bfc25fa859994a2d84e8c627c78a9ba628fa4a02998b84eaf04e","src/runloop.rs":"ed161c100f950d59d218bacb79d47aa51481d9614d6261bb4915464f8f74d210","src/set.rs":"6fd12fbbc97b1fb8bdbd934b979c9b081613d14e5f6e85a63cd4d9326ba0bda4","src/string.rs":"4a117f4080b3b953076644d9b102e60d72c31d3a4cfa8bd17d714d5c79844281","src/timezone.rs":"afab0cc4815936d39966bc96e07f5bf2709e5fbc2f18f8361ae6c70fda204e84","src/url.rs":"2d4bcd40ea6717484af878700ec6385bb408357ecee460dbe8b6c8bf48b733f2","src/uuid.rs":"0f0898044cd4187e4b6ee1d0f170d974c0251280fab466c8adf348cb49c42577"},"package":"8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e"}
{"files":{"Cargo.toml":"01f34fc5a612332c1a3aca9fcd89cd254afa02a27e6e538b0a2fa4280ef4fa66","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"d7af185408d937354f484e3ef97cb1a56e06b39965cbdc89de4bcdafb1d57f06","src/base.rs":"3032ea5253b2d4bd323d0656fc863d1e787642121702ad741c6055d96d0b3d5c","src/boolean.rs":"f5b4d295aaf6cc3681212afebeae2974c5d551125badcc066e6089ac0d2a0873","src/bundle.rs":"de092198bbc3486f617131e9f5f321812c4839da505409abaa70217f05f40450","src/data.rs":"a1d7e6430c745731fc7b2aee49af9f14e79c8a288951c82ea6507689a3356af8","src/date.rs":"a02f6cca7b6e8fbabc7713177429012658dba5146556e14a08e7baaf81958d83","src/dictionary.rs":"429005bc00890b655c8bdf0d7361eb20187ba8725552261aeaf52690c3f2683f","src/error.rs":"22c21087d9c2c103d1bcb2c4af33b684317bbda5d4747902e510d410f8c1a14b","src/filedescriptor.rs":"6ecd8570fad620fc20726539fe11e9f914e3742af9f3208a31727e89a4cd92ba","src/lib.rs":"900179d9ada4b8f000ced4121a9981cdf5ea83277e812177f4126779b818f50c","src/number.rs":"0c2842b8ea973a2c12173a13544b7d49472df11e166540ca5c28f38f54a746f6","src/propertylist.rs":"2ef4b1f44f688fd49ab810a0c8eccc7c40320fa16f93ff1453edcd2fd0d7200f","src/runloop.rs":"bb400ffe84949c4faa4a91f196aeb0a88b31984d206cd236c9daf27005b7744a","src/set.rs":"f23edb8fc009c24600f017131ab734e91129907248713618be89a0719622a9e9","src/string.rs":"50c08f0504c718576e4f2397218a963ab701de0214422dc82e1991d4ab9a00e3","src/timezone.rs":"65859378232ee55f04bc4544b88f5dbc21f5db01bd16f2df3e82136ee3ce26b4","src/url.rs":"ee5370a1ba88823ee0eaa8615c5dafd55cedd7bd50172e9f2caa52ed305e2233","src/uuid.rs":"c532363a1a322a88e195f8606e613a68012708454b0d61ffe7abce432ec68596","tests/use_macro_outside_crate.rs":"452a1329d304bf0301929278aab275cc9b6d57e4ae799b4acd6f2210b1ed0a49"},"package":"286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"}

View File

@ -12,7 +12,7 @@
[package]
name = "core-foundation"
version = "0.4.6"
version = "0.5.1"
authors = ["The Servo Project Developers"]
description = "Bindings to Core Foundation for OS X"
homepage = "https://github.com/servo/core-foundation-rs"
@ -23,7 +23,7 @@ version = "0.4"
optional = true
[dependencies.core-foundation-sys]
version = "0.4.6"
version = "0.5.1"
[dependencies.libc]
version = "0.2"

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,25 @@
Copyright (c) 2012-2013 Mozilla Foundation
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -10,62 +10,77 @@
//! Heterogeneous immutable arrays.
pub use core_foundation_sys::array::*;
pub use core_foundation_sys::base::{CFIndex, CFRelease};
use core_foundation_sys::base::{CFTypeRef, kCFAllocatorDefault};
use base::CFType;
pub use core_foundation_sys::base::CFIndex;
use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
use libc::c_void;
use std::mem;
use std::mem::ManuallyDrop;
use std::marker::PhantomData;
use std;
use std::ops::Deref;
use std::fmt::{Debug, Formatter};
use base::{CFIndexConvertible, TCFType, CFRange};
use base::{CFIndexConvertible, TCFType, TCFTypeRef, CFRange};
/// A heterogeneous immutable array.
pub struct CFArray<T = *const c_void>(CFArrayRef, PhantomData<T>);
/// A reference to an element inside the array
pub struct ItemRef<'a, T: 'a>(ManuallyDrop<T>, PhantomData<&'a T>);
impl<'a, T> Deref for ItemRef<'a, T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<'a, T: Debug> Debug for ItemRef<'a, T> {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
self.0.fmt(f)
}
}
/// A trait describing how to convert from the stored *const c_void to the desired T
pub unsafe trait FromVoid {
unsafe fn from_void(x: *const c_void) -> Self;
unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> where Self: std::marker::Sized;
}
unsafe impl FromVoid for u32 {
unsafe fn from_void(x: *const c_void) -> u32 {
x as usize as u32
unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> {
// Functions like CGFontCopyTableTags treat the void*'s as u32's
// so we convert by casting directly
ItemRef(ManuallyDrop::new(x as u32), PhantomData)
}
}
unsafe impl FromVoid for *const c_void {
unsafe fn from_void(x: *const c_void) -> *const c_void {
x
}
}
unsafe impl FromVoid for CFType {
unsafe fn from_void(x: *const c_void) -> CFType {
TCFType::wrap_under_get_rule(mem::transmute(x))
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)
}
}
impl<T> Drop for CFArray<T> {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
unsafe { CFRelease(self.as_CFTypeRef()) }
}
}
pub struct CFArrayIterator<'a, T: 'a> {
array: &'a CFArray<T>,
index: CFIndex,
len: CFIndex,
}
impl<'a, T: FromVoid> Iterator for CFArrayIterator<'a, T> {
type Item = T;
type Item = ItemRef<'a, T>;
fn next(&mut self) -> Option<T> {
if self.index >= self.array.len() {
fn next(&mut self) -> Option<ItemRef<'a, T>> {
if self.index >= self.len {
None
} else {
let value = self.array.get(self.index);
let value = unsafe { self.array.get_unchecked(self.index) };
self.index += 1;
Some(value)
}
@ -83,7 +98,7 @@ impl_CFTypeDescriptionGeneric!(CFArray);
impl<T> CFArray<T> {
/// Creates a new `CFArray` with the given elements, which must be `CFType` objects.
pub fn from_CFTypes<R>(elems: &[T]) -> CFArray<T> where T: TCFType<R> {
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,
@ -94,13 +109,18 @@ impl<T> CFArray<T> {
}
}
#[deprecated(note = "please use `as_untyped` instead")]
pub fn to_untyped(self) -> CFArray {
#[inline]
pub fn to_untyped(&self) -> CFArray {
unsafe { CFArray::wrap_under_get_rule(self.0) }
}
pub fn as_untyped(&self) -> CFArray {
unsafe { CFArray::wrap_under_get_rule(self.0) }
/// Returns the same array, but with the type reset to void pointers.
/// Equal to `to_untyped`, but is faster since it does not increment the retain count.
#[inline]
pub fn into_untyped(self) -> CFArray {
let reference = self.0;
mem::forget(self);
unsafe { CFArray::wrap_under_create_rule(reference) }
}
/// Iterates over the elements of this `CFArray`.
@ -112,7 +132,8 @@ impl<T> CFArray<T> {
pub fn iter<'a>(&'a self) -> CFArrayIterator<'a, T> {
CFArrayIterator {
array: self,
index: 0
index: 0,
len: self.len(),
}
}
@ -124,9 +145,17 @@ impl<T> CFArray<T> {
}
#[inline]
pub fn get(&self, index: CFIndex) -> T where T: FromVoid {
assert!(index < self.len());
unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) }
pub unsafe fn get_unchecked<'a>(&'a self, index: CFIndex) -> ItemRef<'a, 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 {
if index < self.len() {
Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) } )
} else {
None
}
}
pub fn get_values(&self, range: CFRange) -> Vec<*const c_void> {
@ -147,7 +176,7 @@ impl<T> CFArray<T> {
}
impl<'a, T: FromVoid> IntoIterator for &'a CFArray<T> {
type Item = T;
type Item = ItemRef<'a, T>;
type IntoIter = CFArrayIterator<'a, T>;
fn into_iter(self) -> CFArrayIterator<'a, T> {
@ -159,6 +188,7 @@ impl<'a, T: FromVoid> IntoIterator for &'a CFArray<T> {
mod tests {
use super::*;
use std::mem;
use base::CFType;
#[test]
fn to_untyped_correct_retain_count() {
@ -166,15 +196,6 @@ mod tests {
assert_eq!(array.retain_count(), 1);
let untyped_array = array.to_untyped();
assert_eq!(untyped_array.retain_count(), 1);
}
#[test]
fn as_untyped_correct_retain_count() {
let array = CFArray::<CFType>::from_CFTypes(&[]);
assert_eq!(array.retain_count(), 1);
let untyped_array = array.as_untyped();
assert_eq!(array.retain_count(), 2);
assert_eq!(untyped_array.retain_count(), 2);
@ -182,6 +203,41 @@ mod tests {
assert_eq!(untyped_array.retain_count(), 1);
}
#[test]
fn into_untyped() {
let array = CFArray::<CFType>::from_CFTypes(&[]);
let array2 = array.to_untyped();
assert_eq!(array.retain_count(), 2);
let untyped_array = array.into_untyped();
assert_eq!(untyped_array.retain_count(), 2);
mem::drop(array2);
assert_eq!(untyped_array.retain_count(), 1);
}
#[test]
fn borrow() {
use string::CFString;
let string = CFString::from_static_string("bar");
assert_eq!(string.retain_count(), 1);
let x;
{
let arr: CFArray<CFString> = CFArray::from_CFTypes(&[string]);
{
let p = arr.get(0).unwrap();
assert_eq!(p.retain_count(), 1);
}
{
x = arr.get(0).unwrap().clone();
assert_eq!(x.retain_count(), 2);
assert_eq!(x.to_string(), "bar");
}
}
assert_eq!(x.retain_count(), 1);
}
#[test]
fn should_box_and_unbox() {
use number::CFNumber;
@ -209,27 +265,25 @@ mod tests {
n4.as_CFTypeRef(),
n5.as_CFTypeRef()]);
unsafe {
let mut sum = 0;
let mut sum = 0;
let mut iter = arr.iter();
assert_eq!(iter.len(), 6);
assert!(iter.next().is_some());
assert_eq!(iter.len(), 5);
let mut iter = arr.iter();
assert_eq!(iter.len(), 6);
assert!(iter.next().is_some());
assert_eq!(iter.len(), 5);
for elem in iter {
let number: CFNumber = TCFType::wrap_under_get_rule(mem::transmute(elem));
sum += number.to_i64().unwrap()
}
assert!(sum == 15);
for elem in arr.iter() {
let number: CFNumber = TCFType::wrap_under_get_rule(mem::transmute(elem));
sum += number.to_i64().unwrap()
}
assert!(sum == 30);
for elem in iter {
let number: CFNumber = elem.downcast::<CFNumber>().unwrap();
sum += number.to_i64().unwrap()
}
assert!(sum == 15);
for elem in arr.iter() {
let number: CFNumber = elem.downcast::<CFNumber>().unwrap();
sum += number.to_i64().unwrap()
}
assert!(sum == 30);
}
}

View File

@ -8,6 +8,7 @@
// except according to those terms.
use std::fmt;
use std::mem;
pub use core_foundation_sys::base::*;
@ -30,8 +31,63 @@ impl CFIndexConvertible for usize {
}
}
/// Superclass of all Core Foundation objects.
pub struct CFType(CFTypeRef);
declare_TCFType!{
/// Superclass of all Core Foundation objects.
CFType, CFTypeRef
}
impl CFType {
/// Try to downcast the `CFType` to a subclass. Checking if the instance is the
/// correct subclass happens at runtime and `None` is returned if it is not the correct type.
/// Works similar to [`Box::downcast`] and [`CFPropertyList::downcast`].
///
/// # Examples
///
/// ```
/// # use core_foundation::string::CFString;
/// # use core_foundation::boolean::CFBoolean;
/// # use core_foundation::base::{CFType, TCFType};
/// #
/// // Create a string.
/// let string: CFString = CFString::from_static_string("FooBar");
/// // Cast it up to a CFType.
/// let cf_type: CFType = string.as_CFType();
/// // Cast it down again.
/// assert!(cf_type.downcast::<CFString>().unwrap().to_string() == "FooBar");
/// // Casting it to some other type will yield `None`
/// assert!(cf_type.downcast::<CFBoolean>().is_none());
/// ```
///
/// [`Box::downcast`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.downcast
/// [`CFPropertyList::downcast`]: ../propertylist/struct.CFPropertyList.html#method.downcast
#[inline]
pub fn downcast<T: TCFType>(&self) -> Option<T> {
if self.instance_of::<T>() {
unsafe {
let reference = T::Ref::from_void_ptr(self.0);
Some(T::wrap_under_get_rule(reference))
}
} else {
None
}
}
/// Similar to [`downcast`], but consumes self and can thus avoid touching the retain count.
///
/// [`downcast`]: #method.downcast
#[inline]
pub fn downcast_into<T: TCFType>(self) -> Option<T> {
if self.instance_of::<T>() {
unsafe {
let reference = T::Ref::from_void_ptr(self.0);
mem::forget(self);
Some(T::wrap_under_create_rule(reference))
}
} else {
None
}
}
}
impl fmt::Debug for CFType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -60,25 +116,7 @@ impl PartialEq for CFType {
}
}
impl Drop for CFType {
fn drop(&mut self) {
unsafe {
CFRelease(self.0)
}
}
}
/// An allocator for Core Foundation objects.
pub struct CFAllocator(CFAllocatorRef);
impl Drop for CFAllocator {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
declare_TCFType!(CFAllocator, CFAllocatorRef);
impl_TCFType!(CFAllocator, CFAllocatorRef, CFAllocatorGetTypeID);
impl CFAllocator {
@ -91,16 +129,20 @@ impl CFAllocator {
}
}
/// All Core Foundation types implement this trait. The type parameter `TypeRef` specifies the
/// 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`.
pub trait TCFType<ConcreteTypeRef> {
pub trait TCFType {
/// The reference type wrapped inside this type.
type Ref: TCFTypeRef;
/// Returns the object as its concrete TypeRef.
fn as_concrete_TypeRef(&self) -> ConcreteTypeRef;
fn as_concrete_TypeRef(&self) -> Self::Ref;
/// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this
/// when following Core Foundation's "Create Rule". The reference count is *not* bumped.
unsafe fn wrap_under_create_rule(obj: ConcreteTypeRef) -> Self;
unsafe fn wrap_under_create_rule(obj: Self::Ref) -> Self;
/// Returns the type ID for this class.
fn type_id() -> CFTypeID;
@ -113,12 +155,24 @@ pub trait TCFType<ConcreteTypeRef> {
}
}
/// Returns the object as a wrapped `CFType`. Consumes self and avoids changing the reference
/// count.
#[inline]
fn into_CFType(self) -> CFType
where
Self: Sized,
{
let reference = self.as_CFTypeRef();
mem::forget(self);
unsafe { TCFType::wrap_under_create_rule(reference) }
}
/// Returns the object as a raw `CFTypeRef`. The reference count is not adjusted.
fn as_CFTypeRef(&self) -> CFTypeRef;
/// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this
/// when following Core Foundation's "Get Rule". The reference count *is* bumped.
unsafe fn wrap_under_get_rule(reference: ConcreteTypeRef) -> Self;
unsafe fn wrap_under_get_rule(reference: Self::Ref) -> Self;
/// Returns the reference count of the object. It is unwise to do anything other than test
/// whether the return value of this method is greater than zero.
@ -146,12 +200,14 @@ pub trait TCFType<ConcreteTypeRef> {
/// Returns true if this value is an instance of another type.
#[inline]
fn instance_of<OtherConcreteTypeRef,OtherCFType:TCFType<OtherConcreteTypeRef>>(&self) -> bool {
self.type_of() == <OtherCFType as TCFType<_>>::type_id()
fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
}
}
impl TCFType<CFTypeRef> for CFType {
impl TCFType for CFType {
type Ref = CFTypeRef;
#[inline]
fn as_concrete_TypeRef(&self) -> CFTypeRef {
self.0
@ -184,6 +240,7 @@ impl TCFType<CFTypeRef> for CFType {
#[cfg(test)]
mod tests {
use super::*;
use std::mem;
use boolean::CFBoolean;
#[test]
@ -191,7 +248,46 @@ mod tests {
let string = CFString::from_static_string("foo");
let cftype = string.as_CFType();
assert!(cftype.instance_of::<_, CFString>());
assert!(!cftype.instance_of::<_, CFBoolean>());
assert!(cftype.instance_of::<CFString>());
assert!(!cftype.instance_of::<CFBoolean>());
}
#[test]
fn as_cftype_retain_count() {
let string = CFString::from_static_string("bar");
assert_eq!(string.retain_count(), 1);
let cftype = string.as_CFType();
assert_eq!(cftype.retain_count(), 2);
mem::drop(string);
assert_eq!(cftype.retain_count(), 1);
}
#[test]
fn into_cftype_retain_count() {
let string = CFString::from_static_string("bar");
assert_eq!(string.retain_count(), 1);
let cftype = string.into_CFType();
assert_eq!(cftype.retain_count(), 1);
}
#[test]
fn as_cftype_and_downcast() {
let string = CFString::from_static_string("bar");
let cftype = string.as_CFType();
let string2 = cftype.downcast::<CFString>().unwrap();
assert_eq!(string2.to_string(), "bar");
assert_eq!(string.retain_count(), 3);
assert_eq!(cftype.retain_count(), 3);
assert_eq!(string2.retain_count(), 3);
}
#[test]
fn into_cftype_and_downcast_into() {
let string = CFString::from_static_string("bar");
let cftype = string.into_CFType();
let string2 = cftype.downcast_into::<CFString>().unwrap();
assert_eq!(string2.to_string(), "bar");
assert_eq!(string2.retain_count(), 1);
}
}

View File

@ -9,24 +9,17 @@
//! A Boolean type.
use core_foundation_sys::base::{CFRelease};
pub use core_foundation_sys::number::{CFBooleanRef, CFBooleanGetTypeID, kCFBooleanTrue, kCFBooleanFalse};
use base::TCFType;
/// A Boolean type.
///
/// FIXME(pcwalton): Should be a newtype struct, but that fails due to a Rust compiler bug.
pub struct CFBoolean(CFBooleanRef);
impl Drop for CFBoolean {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// A Boolean type.
///
/// FIXME(pcwalton): Should be a newtype struct, but that fails due to a Rust compiler bug.
CFBoolean, CFBooleanRef
}
impl_TCFType!(CFBoolean, CFBooleanRef, CFBooleanGetTypeID);
impl_CFTypeDescription!(CFBoolean);

View File

@ -10,22 +10,18 @@
//! Core Foundation Bundle Type
pub use core_foundation_sys::bundle::*;
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::base::kCFAllocatorDefault;
use base::TCFType;
use url::CFURL;
use dictionary::CFDictionary;
/// A Bundle type.
pub struct CFBundle(CFBundleRef);
impl Drop for CFBundle {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// A Bundle type.
CFBundle, CFBundleRef
}
impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID);
impl CFBundle {
pub fn new(bundleURL: CFURL) -> Option<CFBundle> {
@ -76,7 +72,6 @@ impl CFBundle {
}
}
impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID);
#[test]
fn safari_executable_url() {

View File

@ -10,24 +10,18 @@
//! Core Foundation byte buffers.
pub use core_foundation_sys::data::*;
use core_foundation_sys::base::{CFIndex, CFRelease};
use core_foundation_sys::base::CFIndex;
use core_foundation_sys::base::{kCFAllocatorDefault};
use std::ops::Deref;
use std::slice;
use base::{CFIndexConvertible, TCFType};
/// A byte buffer.
pub struct CFData(CFDataRef);
impl Drop for CFData {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// A byte buffer.
CFData, CFDataRef
}
impl_TCFType!(CFData, CFDataRef, CFDataGetTypeID);
impl_CFTypeDescription!(CFData);

View File

@ -10,24 +10,18 @@
//! Core Foundation date objects.
pub use core_foundation_sys::date::*;
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::base::kCFAllocatorDefault;
use base::TCFType;
#[cfg(feature = "with-chrono")]
use chrono::NaiveDateTime;
/// A date.
pub struct CFDate(CFDateRef);
impl Drop for CFDate {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// A date.
CFDate, CFDateRef
}
impl_TCFType!(CFDate, CFDateRef, CFDateGetTypeID);
impl_CFTypeDescription!(CFDate);
impl_CFComparison!(CFDate, CFDateCompare);

View File

@ -10,33 +10,26 @@
//! Dictionaries of key-value pairs.
pub use core_foundation_sys::dictionary::*;
use core_foundation_sys::base::CFRelease;
use core_foundation_sys::base::{CFTypeRef, kCFAllocatorDefault};
use libc::c_void;
use std::mem;
use std::ptr;
use base::{CFType, CFIndexConvertible, TCFType};
use base::{CFType, CFIndexConvertible, TCFType, TCFTypeRef};
/// An immutable dictionary of key-value pairs.
pub struct CFDictionary(CFDictionaryRef);
impl Drop for CFDictionary {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// An immutable dictionary of key-value pairs.
CFDictionary, CFDictionaryRef
}
impl_TCFType!(CFDictionary, CFDictionaryRef, CFDictionaryGetTypeID);
impl_CFTypeDescription!(CFDictionary);
impl CFDictionary {
pub fn from_CFType_pairs<R1, R2, K, V>(pairs: &[(K, V)]) -> CFDictionary
where K: TCFType<R1>, V: TCFType<R2> {
let (keys, values): (Vec<CFTypeRef>,Vec<CFTypeRef>) =
pairs.iter()
pub fn from_CFType_pairs<K: TCFType, V: TCFType>(pairs: &[(K, V)]) -> CFDictionary {
let (keys, values): (Vec<CFTypeRef>, Vec<CFTypeRef>) = pairs
.iter()
.map(|&(ref key, ref value)| (key.as_CFTypeRef(), value.as_CFTypeRef()))
.unzip();
@ -65,16 +58,14 @@ impl CFDictionary {
#[inline]
pub fn contains_key(&self, key: *const c_void) -> bool {
unsafe {
CFDictionaryContainsKey(self.0, key) != 0
}
unsafe { CFDictionaryContainsKey(self.0, key) != 0 }
}
/// Similar to `contains_key` but acts on a higher level, automatically converting from any
/// `TCFType` to the raw pointer of its concrete TypeRef.
#[inline]
pub fn contains_key2<X, K: TCFType<*const X>>(&self, key: &K) -> bool {
self.contains_key(key.as_concrete_TypeRef() as *const c_void)
pub fn contains_key2<K: TCFType>(&self, key: &K) -> bool {
self.contains_key(key.as_concrete_TypeRef().as_void_ptr())
}
#[inline]
@ -92,8 +83,8 @@ impl CFDictionary {
/// Similar to `find` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn find2<X, K: TCFType<*const X>>(&self, key: &K) -> Option<*const c_void> {
self.find(key.as_concrete_TypeRef() as *const c_void)
pub fn find2<K: TCFType>(&self, key: &K) -> Option<*const c_void> {
self.find(key.as_concrete_TypeRef().as_void_ptr())
}
/// # Panics
@ -112,9 +103,122 @@ impl CFDictionary {
TCFType::wrap_under_get_rule(value)
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
let length = self.len();
let mut keys = Vec::with_capacity(length);
let mut values = Vec::with_capacity(length);
unsafe {
CFDictionaryGetKeysAndValues(self.0, keys.as_mut_ptr(), values.as_mut_ptr());
keys.set_len(length);
values.set_len(length);
}
(keys, values)
}
}
declare_TCFType!{
/// An mutable dictionary of key-value pairs.
CFMutableDictionary, CFMutableDictionaryRef
}
impl_TCFType!(CFMutableDictionary, CFMutableDictionaryRef, CFDictionaryGetTypeID);
impl_CFTypeDescription!(CFMutableDictionary);
impl CFMutableDictionary {
pub fn new() -> Self {
Self::with_capacity(0)
}
pub fn with_capacity(capacity: isize) -> Self {
unsafe {
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);
TCFType::wrap_under_get_rule(dictionary_ref)
}
}
pub fn from_CFType_pairs<K: TCFType, V: TCFType>(pairs: &[(K, V)]) -> CFMutableDictionary {
let result = Self::with_capacity(pairs.len() as _);
unsafe {
for &(ref key, ref value) in pairs {
result.add(key.as_CFTypeRef(), value.as_CFTypeRef());
}
}
result
}
// Immutable interface
#[inline]
pub unsafe fn set_value(&self, key: *const c_void, value: *const c_void) {
CFDictionarySetValue(self.0, key, value)
pub fn len(&self) -> usize {
unsafe {
CFDictionaryGetCount(self.0) as usize
}
}
#[inline]
pub fn is_empty(&self) -> bool {
self.len() == 0
}
#[inline]
pub fn contains_key(&self, key: *const c_void) -> bool {
unsafe {
CFDictionaryContainsKey(self.0, key) != 0
}
}
/// Similar to `contains_key` but acts on a higher level, automatically converting from any
/// `TCFType` to the raw pointer of its concrete TypeRef.
#[inline]
pub fn contains_key2<K: TCFType>(&self, key: &K) -> bool {
self.contains_key(key.as_concrete_TypeRef().as_void_ptr())
}
#[inline]
pub fn find(&self, key: *const c_void) -> Option<*const c_void> {
unsafe {
let mut value: *const c_void = ptr::null();
if CFDictionaryGetValueIfPresent(self.0, key, &mut value) != 0 {
Some(value)
} else {
None
}
}
}
/// Similar to `find` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn find2<K: TCFType>(&self, key: &K) -> Option<*const c_void> {
self.find(key.as_concrete_TypeRef().as_void_ptr())
}
/// # Panics
///
/// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead
/// of panicking.
#[inline]
pub fn get(&self, key: *const c_void) -> *const c_void {
self.find(key).expect(&format!("No entry found for key {:p}", key))
}
/// A convenience function to retrieve `CFType` instances.
#[inline]
pub unsafe fn get_CFType(&self, key: *const c_void) -> CFType {
let value: CFTypeRef = mem::transmute(self.get(key));
TCFType::wrap_under_get_rule(value)
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
@ -130,4 +234,158 @@ impl CFDictionary {
(keys, values)
}
// Mutable interface
/// Adds the key-value pair to the dictionary if no such key already exist.
#[inline]
pub unsafe fn add(&self, key: *const c_void, value: *const c_void) {
CFDictionaryAddValue(self.0, key, value)
}
/// Similar to `add` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn add2<K: TCFType, V: TCFType>(&self, key: &K, value: &V) {
unsafe {
self.add(
key.as_concrete_TypeRef().as_void_ptr(),
value.as_concrete_TypeRef().as_void_ptr(),
)
}
}
/// Sets the value of the key in the dictionary.
#[inline]
pub unsafe fn set(&self, key: *const c_void, value: *const c_void) {
CFDictionarySetValue(self.0, key, value)
}
/// Similar to `set` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn set2<K: TCFType, V: TCFType>(&self, key: &K, value: &V) {
unsafe {
self.set(
key.as_concrete_TypeRef().as_void_ptr(),
value.as_concrete_TypeRef().as_void_ptr(),
)
}
}
/// Replaces the value of the key in the dictionary.
#[inline]
pub unsafe fn replace(&self, key: *const c_void, value: *const c_void) {
CFDictionaryReplaceValue(self.0, key, value)
}
/// Similar to `replace` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn replace2<K: TCFType, V: TCFType>(&self, key: &K, value: &V) {
unsafe {
self.replace(
key.as_concrete_TypeRef().as_void_ptr(),
value.as_concrete_TypeRef().as_void_ptr(),
)
}
}
/// Removes the value of the key from the dictionary.
#[inline]
pub unsafe fn remove(&self, key: *const c_void) {
CFDictionaryRemoveValue(self.0, key);
}
/// Similar to `remove` but acts on a higher level, automatically converting from any `TCFType`
/// to the raw pointer of its concrete TypeRef.
#[inline]
pub fn remove2<K: TCFType>(&self, key: &K) {
unsafe { self.remove(key.as_concrete_TypeRef().as_void_ptr()) }
}
#[inline]
pub fn remove_all(&self) {
unsafe { CFDictionaryRemoveAllValues(self.0) }
}
}
#[cfg(test)]
pub mod test {
use super::*;
use base::TCFType;
use boolean::{CFBoolean, CFBooleanRef};
use number::CFNumber;
use string::CFString;
#[test]
fn dictionary() {
let bar = CFString::from_static_string("Bar");
let baz = CFString::from_static_string("Baz");
let boo = CFString::from_static_string("Boo");
let foo = CFString::from_static_string("Foo");
let tru = CFBoolean::true_value();
let n42 = CFNumber::from(42);
let d = CFDictionary::from_CFType_pairs(&[
(bar.as_CFType(), boo.as_CFType()),
(baz.as_CFType(), tru.as_CFType()),
(foo.as_CFType(), n42.as_CFType()),
]);
let (v1, v2) = d.get_keys_and_values();
assert!(v1 == &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
assert!(v2 == &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
}
#[test]
fn mutable_dictionary() {
let bar = CFString::from_static_string("Bar");
let baz = CFString::from_static_string("Baz");
let boo = CFString::from_static_string("Boo");
let foo = CFString::from_static_string("Foo");
let tru = CFBoolean::true_value();
let n42 = CFNumber::from(42);
let d = CFMutableDictionary::new();
d.add2(&bar, &boo);
d.add2(&baz, &tru);
d.add2(&foo, &n42);
assert_eq!(d.len(), 3);
let (v1, v2) = d.get_keys_and_values();
assert!(v1 == &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
assert!(v2 == &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
d.remove2(&baz);
assert_eq!(d.len(), 2);
let (v1, v2) = d.get_keys_and_values();
assert!(v1 == &[bar.as_CFTypeRef(), foo.as_CFTypeRef()]);
assert!(v2 == &[boo.as_CFTypeRef(), n42.as_CFTypeRef()]);
d.remove_all();
assert_eq!(d.len(), 0)
}
#[test]
fn dict_find2_and_contains_key2() {
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");
assert!(dict.contains_key2(&key));
assert!(!dict.contains_key2(&invalid_key));
let value = unsafe { CFBoolean::wrap_under_get_rule(dict.find2(&key).unwrap() as CFBooleanRef) };
assert_eq!(value, CFBoolean::true_value());
assert_eq!(dict.find2(&invalid_key), None);
}
}

View File

@ -9,25 +9,19 @@
//! Core Foundation errors.
use core_foundation_sys::error::*;
use core_foundation_sys::base::CFRelease;
pub use core_foundation_sys::error::*;
use std::error::Error;
use std::fmt;
use base::{CFIndex, TCFType};
use string::CFString;
/// An error value.
pub struct CFError(CFErrorRef);
impl Drop for CFError {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// An error value.
CFError, CFErrorRef
}
impl_TCFType!(CFError, CFErrorRef, CFErrorGetTypeID);
impl fmt::Debug for CFError {

View File

@ -0,0 +1,200 @@
pub use core_foundation_sys::filedescriptor::*;
use core_foundation_sys::base::{Boolean, CFIndex};
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
use base::TCFType;
use runloop::CFRunLoopSource;
use std::mem;
use std::os::unix::io::{AsRawFd, RawFd};
use std::ptr;
declare_TCFType!{
CFFileDescriptor, CFFileDescriptorRef
}
impl_TCFType!(CFFileDescriptor, CFFileDescriptorRef, CFFileDescriptorGetTypeID);
impl 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);
if fd_ref.is_null() {
None
} else {
Some(TCFType::wrap_under_create_rule(fd_ref))
}
}
}
pub fn context(&self) -> CFFileDescriptorContext {
unsafe {
let mut context: CFFileDescriptorContext = mem::uninitialized();
CFFileDescriptorGetContext(self.0, &mut context);
context
}
}
pub fn enable_callbacks(&self, callback_types: CFOptionFlags) {
unsafe {
CFFileDescriptorEnableCallBacks(self.0, callback_types)
}
}
pub fn disable_callbacks(&self, callback_types: CFOptionFlags) {
unsafe {
CFFileDescriptorDisableCallBacks(self.0, callback_types)
}
}
pub fn valid(&self) -> bool {
unsafe {
CFFileDescriptorIsValid(self.0) != 0
}
}
pub fn invalidate(&self) {
unsafe {
CFFileDescriptorInvalidate(self.0)
}
}
pub fn to_run_loop_source(&self, order: CFIndex) -> Option<CFRunLoopSource> {
unsafe {
let source_ref = CFFileDescriptorCreateRunLoopSource(
kCFAllocatorDefault,
self.0,
order
);
if source_ref.is_null() {
None
} else {
Some(TCFType::wrap_under_create_rule(source_ref))
}
}
}
}
impl AsRawFd for CFFileDescriptor {
fn as_raw_fd(&self) -> RawFd {
unsafe {
CFFileDescriptorGetNativeDescriptor(self.0)
}
}
}
#[cfg(test)]
mod test {
extern crate libc;
use super::*;
use std::ffi::CString;
use libc::{c_void, O_RDWR};
use core_foundation_sys::base::{CFOptionFlags};
use core_foundation_sys::runloop::{kCFRunLoopDefaultMode};
use runloop::{CFRunLoop};
#[test]
fn test_consumed() {
let path = CString::new("/dev/null").unwrap();
let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) };
let cf_fd = CFFileDescriptor::new(raw_fd, true, never_callback, None);
assert!(cf_fd.is_some());
let cf_fd = cf_fd.unwrap();
assert!(cf_fd.valid());
cf_fd.invalidate();
assert!(!cf_fd.valid());
// close() should fail
assert_eq!(unsafe { libc::close(raw_fd) }, -1);
}
#[test]
fn test_unconsumed() {
let path = CString::new("/dev/null").unwrap();
let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) };
let cf_fd = CFFileDescriptor::new(raw_fd, false, never_callback, None);
assert!(cf_fd.is_some());
let cf_fd = cf_fd.unwrap();
assert!(cf_fd.valid());
cf_fd.invalidate();
assert!(!cf_fd.valid());
// close() should succeed
assert_eq!(unsafe { libc::close(raw_fd) }, 0);
}
extern "C" fn never_callback(_f: CFFileDescriptorRef,
_callback_types: CFOptionFlags,
_info_ptr: *mut c_void) {
unreachable!();
}
struct TestInfo {
value: CFOptionFlags
}
#[test]
fn test_callback() {
let mut info = TestInfo { value: 0 };
let context = CFFileDescriptorContext {
version: 0,
info: &mut info as *mut _ as *mut c_void,
retain: None,
release: None,
copyDescription: None
};
let path = CString::new("/dev/null").unwrap();
let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) };
let cf_fd = CFFileDescriptor::new(raw_fd, true, callback, Some(&context));
assert!(cf_fd.is_some());
let cf_fd = cf_fd.unwrap();
assert!(cf_fd.valid());
let run_loop = CFRunLoop::get_current();
let source = CFRunLoopSource::from_file_descriptor(&cf_fd, 0);
assert!(source.is_some());
unsafe {
run_loop.add_source(&source.unwrap(), kCFRunLoopDefaultMode);
}
info.value = 0;
cf_fd.enable_callbacks(kCFFileDescriptorReadCallBack);
CFRunLoop::run_current();
assert_eq!(info.value, kCFFileDescriptorReadCallBack);
info.value = 0;
cf_fd.enable_callbacks(kCFFileDescriptorWriteCallBack);
CFRunLoop::run_current();
assert_eq!(info.value, kCFFileDescriptorWriteCallBack);
info.value = 0;
cf_fd.disable_callbacks(kCFFileDescriptorReadCallBack | kCFFileDescriptorWriteCallBack);
cf_fd.invalidate();
assert!(!cf_fd.valid());
}
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;
unsafe { (*info).value = callback_types };
CFRunLoop::get_current().stop();
}
}

View File

@ -14,35 +14,55 @@ extern crate libc;
#[cfg(feature = "with-chrono")]
extern crate chrono;
#[macro_export]
macro_rules! declare_TCFType {
(
$(#[$doc:meta])*
$ty:ident, $raw:ident
) => {
$(#[$doc])*
pub struct $ty($raw);
impl Drop for $ty {
fn drop(&mut self) {
unsafe { $crate::base::CFRelease(self.as_CFTypeRef()) }
}
}
}
}
#[macro_export]
macro_rules! impl_TCFType {
($ty:ident, $raw:ident, $ty_id:ident) => {
impl $crate::base::TCFType<$raw> for $ty {
($ty:ident, $ty_ref:ident, $ty_id:ident) => {
impl $crate::base::TCFType for $ty {
type Ref = $ty_ref;
#[inline]
fn as_concrete_TypeRef(&self) -> $raw {
fn as_concrete_TypeRef(&self) -> $ty_ref {
self.0
}
#[inline]
unsafe fn wrap_under_get_rule(reference: $raw) -> $ty {
let reference = ::std::mem::transmute(::core_foundation_sys::base::CFRetain(::std::mem::transmute(reference)));
unsafe fn wrap_under_get_rule(reference: $ty_ref) -> $ty {
use std::mem;
let reference = mem::transmute($crate::base::CFRetain(mem::transmute(reference)));
$crate::base::TCFType::wrap_under_create_rule(reference)
}
#[inline]
fn as_CFTypeRef(&self) -> ::core_foundation_sys::base::CFTypeRef {
fn as_CFTypeRef(&self) -> $crate::base::CFTypeRef {
unsafe {
::std::mem::transmute(self.as_concrete_TypeRef())
}
}
#[inline]
unsafe fn wrap_under_create_rule(obj: $raw) -> $ty {
$ty(obj)
unsafe fn wrap_under_create_rule(reference: $ty_ref) -> $ty {
$ty(reference)
}
#[inline]
fn type_id() -> ::core_foundation_sys::base::CFTypeID {
fn type_id() -> $crate::base::CFTypeID {
unsafe {
$ty_id()
}
@ -73,16 +93,19 @@ macro_rules! impl_TCFType {
// think of a clean way to have them share code
#[macro_export]
macro_rules! impl_TCFTypeGeneric {
($ty:ident, $raw:ident, $ty_id:ident) => {
impl<T> $crate::base::TCFType<$raw> for $ty<T> {
($ty:ident, $ty_ref:ident, $ty_id:ident) => {
impl<T> $crate::base::TCFType for $ty<T> {
type Ref = $ty_ref;
#[inline]
fn as_concrete_TypeRef(&self) -> $raw {
fn as_concrete_TypeRef(&self) -> $ty_ref {
self.0
}
#[inline]
unsafe fn wrap_under_get_rule(reference: $raw) -> $ty<T> {
let reference = ::std::mem::transmute(::core_foundation_sys::base::CFRetain(::std::mem::transmute(reference)));
unsafe fn wrap_under_get_rule(reference: $ty_ref) -> $ty<T> {
use std::mem;
let reference = mem::transmute($crate::base::CFRetain(mem::transmute(reference)));
$crate::base::TCFType::wrap_under_create_rule(reference)
}
@ -94,7 +117,7 @@ macro_rules! impl_TCFTypeGeneric {
}
#[inline]
unsafe fn wrap_under_create_rule(obj: $raw) -> $ty<T> {
unsafe fn wrap_under_create_rule(obj: $ty_ref) -> $ty<T> {
$ty(obj, PhantomData)
}
@ -177,6 +200,7 @@ pub mod data;
pub mod date;
pub mod dictionary;
pub mod error;
pub mod filedescriptor;
pub mod number;
pub mod set;
pub mod string;
@ -186,37 +210,3 @@ pub mod propertylist;
pub mod runloop;
pub mod timezone;
pub mod uuid;
#[cfg(test)]
pub mod test {
#[test]
fn test_stuff() {
use base::TCFType;
use boolean::CFBoolean;
use number::CFNumber;
use dictionary::CFDictionary;
use string::CFString;
/*let n = CFNumber::new_number(42 as i32);
io::println(format!("%d", (&n).retain_count() as int));
(&n).show();*/
let bar = CFString::from_static_string("Bar");
let baz = CFString::from_static_string("Baz");
let boo = CFString::from_static_string("Boo");
let foo = CFString::from_static_string("Foo");
let tru = CFBoolean::true_value();
let n42 = CFNumber::from(42);
let d = CFDictionary::from_CFType_pairs(&[
(bar.as_CFType(), boo.as_CFType()),
(baz.as_CFType(), tru.as_CFType()),
(foo.as_CFType(), n42.as_CFType()),
]);
let (v1, v2) = d.get_keys_and_values();
assert!(v1 == &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
assert!(v2 == &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
}
}

View File

@ -9,23 +9,17 @@
//! Immutable numbers.
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::base::kCFAllocatorDefault;
pub use core_foundation_sys::number::*;
use std::mem;
use base::{TCFType};
use base::TCFType;
/// An immutable numeric value.
pub struct CFNumber(CFNumberRef);
impl Drop for CFNumber {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// An immutable numeric value.
CFNumber, CFNumberRef
}
impl_TCFType!(CFNumber, CFNumberRef, CFNumberGetTypeID);
impl_CFTypeDescription!(CFNumber);
impl_CFComparison!(CFNumber, CFNumberCompare);
@ -57,30 +51,6 @@ impl CFNumber {
if ok { Some(value) } else { None }
}
}
#[deprecated(note = "please use `CFNumber::from` instead")]
#[inline]
pub fn from_i32(value: i32) -> CFNumber {
CFNumber::from(value)
}
#[deprecated(note = "please use `CFNumber::from` instead")]
#[inline]
pub fn from_i64(value: i64) -> CFNumber {
Self::from(value)
}
#[deprecated(note = "please use `CFNumber::from` instead")]
#[inline]
pub fn from_f32(value: f32) -> CFNumber {
Self::from(value)
}
#[deprecated(note = "please use `CFNumber::from` instead")]
#[inline]
pub fn from_f64(value: f64) -> CFNumber {
Self::from(value)
}
}
impl From<i32> for CFNumber {
@ -138,9 +108,3 @@ impl From<f64> for CFNumber {
}
}
}
/// A convenience function to create CFNumbers.
#[deprecated(note = "please use `CFNumber::from` instead")]
pub fn number(value: i64) -> CFNumber {
CFNumber::from(value)
}

View File

@ -16,11 +16,11 @@ use libc::c_void;
use error::CFError;
use data::CFData;
use base::{CFType, TCFType};
use base::{CFType, TCFType, TCFTypeRef};
pub use core_foundation_sys::propertylist::*;
use core_foundation_sys::error::CFErrorRef;
use core_foundation_sys::base::{CFGetRetainCount, CFGetTypeID, CFIndex, CFRelease, CFRetain,
use core_foundation_sys::base::{CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain,
CFShow, CFTypeID, kCFAllocatorDefault};
pub fn create_with_data(data: CFData,
@ -62,45 +62,56 @@ pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -
/// Trait for all subclasses of [`CFPropertyList`].
///
/// [`CFPropertyList`]: struct.CFPropertyList.html
pub trait CFPropertyListSubClass<Raw>: TCFType<*const Raw> {
pub trait CFPropertyListSubClass: TCFType {
/// Create an instance of the superclass type [`CFPropertyList`] for this instance.
///
/// [`CFPropertyList`]: struct.CFPropertyList.html
#[inline]
fn to_CFPropertyList(&self) -> CFPropertyList {
unsafe { CFPropertyList::wrap_under_get_rule(self.as_concrete_TypeRef() as *const c_void) }
unsafe { CFPropertyList::wrap_under_get_rule(self.as_concrete_TypeRef().as_void_ptr()) }
}
/// Equal to [`to_CFPropertyList`], but consumes self and avoids changing the reference count.
///
/// [`to_CFPropertyList`]: #method.to_CFPropertyList
#[inline]
fn into_CFPropertyList(self) -> CFPropertyList
where
Self: Sized,
{
let reference = self.as_concrete_TypeRef().as_void_ptr();
mem::forget(self);
unsafe { CFPropertyList::wrap_under_create_rule(reference) }
}
}
impl CFPropertyListSubClass<::data::__CFData> for ::data::CFData {}
impl CFPropertyListSubClass<::string::__CFString> for ::string::CFString {}
impl CFPropertyListSubClass<::array::__CFArray> for ::array::CFArray {}
impl CFPropertyListSubClass<::dictionary::__CFDictionary> for ::dictionary::CFDictionary {}
impl CFPropertyListSubClass<::date::__CFDate> for ::date::CFDate {}
impl CFPropertyListSubClass<::number::__CFBoolean> for ::boolean::CFBoolean {}
impl CFPropertyListSubClass<::number::__CFNumber> for ::number::CFNumber {}
impl CFPropertyListSubClass for ::data::CFData {}
impl CFPropertyListSubClass for ::string::CFString {}
impl CFPropertyListSubClass for ::array::CFArray {}
impl CFPropertyListSubClass for ::dictionary::CFDictionary {}
impl CFPropertyListSubClass for ::date::CFDate {}
impl CFPropertyListSubClass for ::boolean::CFBoolean {}
impl CFPropertyListSubClass for ::number::CFNumber {}
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
///
/// This superclass type does not have its own `CFTypeID`, instead each instance has the `CFTypeID`
/// of the subclass it is an instance of. Thus, this type cannot implement the [`TCFType`] trait,
/// since it cannot implement the static [`TCFType::type_id()`] method.
///
/// [`CFData`]: ../data/struct.CFData.html
/// [`CFString`]: ../string/struct.CFString.html
/// [`CFArray`]: ../array/struct.CFArray.html
/// [`CFDictionary`]: ../dictionary/struct.CFDictionary.html
/// [`CFDate`]: ../date/struct.CFDate.html
/// [`CFBoolean`]: ../boolean/struct.CFBoolean.html
/// [`CFNumber`]: ../number/struct.CFNumber.html
/// [`TCFType`]: ../base/trait.TCFType.html
/// [`TCFType::type_id()`]: ../base/trait.TCFType.html#method.type_of
pub struct CFPropertyList(CFPropertyListRef);
impl Drop for CFPropertyList {
fn drop(&mut self) {
unsafe { CFRelease(self.as_CFTypeRef()) }
}
declare_TCFType!{
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
///
/// This superclass type does not have its own `CFTypeID`, instead each instance has the `CFTypeID`
/// of the subclass it is an instance of. Thus, this type cannot implement the [`TCFType`] trait,
/// since it cannot implement the static [`TCFType::type_id()`] method.
///
/// [`CFData`]: ../data/struct.CFData.html
/// [`CFString`]: ../string/struct.CFString.html
/// [`CFArray`]: ../array/struct.CFArray.html
/// [`CFDictionary`]: ../dictionary/struct.CFDictionary.html
/// [`CFDate`]: ../date/struct.CFDate.html
/// [`CFBoolean`]: ../boolean/struct.CFBoolean.html
/// [`CFNumber`]: ../number/struct.CFNumber.html
/// [`TCFType`]: ../base/trait.TCFType.html
/// [`TCFType::type_id()`]: ../base/trait.TCFType.html#method.type_of
CFPropertyList, CFPropertyListRef
}
impl CFPropertyList {
@ -120,6 +131,16 @@ impl CFPropertyList {
unsafe { CFType::wrap_under_get_rule(self.as_CFTypeRef()) }
}
#[inline]
pub fn into_CFType(self) -> CFType
where
Self: Sized,
{
let reference = self.as_CFTypeRef();
mem::forget(self);
unsafe { TCFType::wrap_under_create_rule(reference) }
}
#[inline]
pub fn as_CFTypeRef(&self) -> ::core_foundation_sys::base::CFTypeRef {
unsafe { mem::transmute(self.as_concrete_TypeRef()) }
@ -151,10 +172,8 @@ impl CFPropertyList {
/// Returns true if this value is an instance of another type.
#[inline]
pub fn instance_of<OtherConcreteTypeRef, OtherCFType: TCFType<OtherConcreteTypeRef>>(
&self,
) -> bool {
self.type_of() == <OtherCFType as TCFType<_>>::type_id()
pub fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
}
}
@ -175,9 +194,9 @@ impl PartialEq for CFPropertyList {
impl Eq for CFPropertyList {}
impl CFPropertyList {
/// Try to downcast the [`CFPropertyList`] to a subclass. Checking if the instance is the correct
/// subclass happens at runtime and an error is returned if it is not the correct type.
/// Works similar to [`Box::downcast`].
/// Try to downcast the [`CFPropertyList`] to a subclass. Checking if the instance is the
/// correct subclass happens at runtime and `None` is returned if it is not the correct type.
/// Works similar to [`Box::downcast`] and [`CFType::downcast`].
///
/// # Examples
///
@ -190,14 +209,32 @@ impl CFPropertyList {
/// // Cast it up to a property list.
/// let propertylist: CFPropertyList = string.to_CFPropertyList();
/// // Cast it down again.
/// assert!(propertylist.downcast::<_, CFString>().unwrap().to_string() == "FooBar");
/// assert!(propertylist.downcast::<CFString>().unwrap().to_string() == "FooBar");
/// ```
///
/// [`CFPropertyList`]: struct.CFPropertyList.html
/// [`Box::downcast`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.downcast
pub fn downcast<Raw, T: CFPropertyListSubClass<Raw>>(&self) -> Option<T> {
if self.instance_of::<_, T>() {
Some(unsafe { T::wrap_under_get_rule(self.0 as *const Raw) })
pub fn downcast<T: CFPropertyListSubClass>(&self) -> Option<T> {
if self.instance_of::<T>() {
unsafe {
let subclass_ref = T::Ref::from_void_ptr(self.0);
Some(T::wrap_under_get_rule(subclass_ref))
}
} else {
None
}
}
/// Similar to [`downcast`], but consumes self and can thus avoid touching the retain count.
///
/// [`downcast`]: #method.downcast
pub fn downcast_into<T: CFPropertyListSubClass>(self) -> Option<T> {
if self.instance_of::<T>() {
unsafe {
let subclass_ref = T::Ref::from_void_ptr(self.0);
mem::forget(self);
Some(T::wrap_under_create_rule(subclass_ref))
}
} else {
None
}
@ -239,17 +276,51 @@ pub mod test {
}
}
#[test]
fn to_propertylist_retain_count() {
let string = CFString::from_static_string("Bar");
assert_eq!(string.retain_count(), 1);
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
assert_eq!(propertylist.retain_count(), 2);
mem::drop(string);
assert_eq!(propertylist.retain_count(), 1);
}
#[test]
fn downcast_string() {
let propertylist = CFString::from_static_string("Bar").to_CFPropertyList();
assert!(propertylist.downcast::<_, CFString>().unwrap().to_string() == "Bar");
assert!(propertylist.downcast::<_, CFBoolean>().is_none());
assert!(propertylist.downcast::<CFString>().unwrap().to_string() == "Bar");
assert!(propertylist.downcast::<CFBoolean>().is_none());
}
#[test]
fn downcast_boolean() {
let propertylist = CFBoolean::true_value().to_CFPropertyList();
assert!(propertylist.downcast::<_, CFBoolean>().is_some());
assert!(propertylist.downcast::<_, CFString>().is_none());
assert!(propertylist.downcast::<CFBoolean>().is_some());
assert!(propertylist.downcast::<CFString>().is_none());
}
#[test]
fn downcast_into_fail() {
let string = CFString::from_static_string("Bar");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
assert!(propertylist.downcast_into::<CFBoolean>().is_none());
assert_eq!(string.retain_count(), 1);
}
#[test]
fn downcast_into() {
let string = CFString::from_static_string("Bar");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
let string2 = propertylist.downcast_into::<CFString>().unwrap();
assert!(string2.to_string() == "Bar");
assert_eq!(string2.retain_count(), 2);
}
}

View File

@ -10,26 +10,19 @@
#![allow(non_upper_case_globals)]
pub use core_foundation_sys::runloop::*;
use core_foundation_sys::base::{CFIndex, CFRelease};
use core_foundation_sys::base::CFIndex;
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
use core_foundation_sys::string::CFStringRef;
use base::{TCFType};
use date::{CFAbsoluteTime, CFTimeInterval};
use filedescriptor::CFFileDescriptor;
use string::{CFString};
pub type CFRunLoopMode = CFStringRef;
pub struct CFRunLoop(CFRunLoopRef);
impl Drop for CFRunLoop {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
declare_TCFType!(CFRunLoop, CFRunLoopRef);
impl_TCFType!(CFRunLoop, CFRunLoopRef, CFRunLoopGetTypeID);
impl_CFTypeDescription!(CFRunLoop);
@ -128,16 +121,8 @@ impl CFRunLoop {
}
pub struct CFRunLoopTimer(CFRunLoopTimerRef);
impl Drop for CFRunLoopTimer {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
declare_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef);
impl_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef, CFRunLoopTimerGetTypeID);
impl CFRunLoopTimer {
@ -150,29 +135,16 @@ impl CFRunLoopTimer {
}
pub struct CFRunLoopSource(CFRunLoopSourceRef);
impl Drop for CFRunLoopSource {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
declare_TCFType!(CFRunLoopSource, CFRunLoopSourceRef);
impl_TCFType!(CFRunLoopSource, CFRunLoopSourceRef, CFRunLoopSourceGetTypeID);
pub struct CFRunLoopObserver(CFRunLoopObserverRef);
impl Drop for CFRunLoopObserver {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
impl CFRunLoopSource {
pub fn from_file_descriptor(fd: &CFFileDescriptor, order: CFIndex) -> Option<CFRunLoopSource> {
fd.to_run_loop_source(order)
}
}
declare_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef);
impl_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef, CFRunLoopObserverGetTypeID);
#[cfg(test)]
@ -181,14 +153,21 @@ mod test {
use date::{CFDate, CFAbsoluteTime};
use std::mem;
use libc::c_void;
use std::sync::mpsc;
#[test]
fn wait_200_milliseconds() {
let run_loop = CFRunLoop::get_current();
let mut now = CFDate::now().abs_time();
let now = CFDate::now().abs_time();
let (elapsed_tx, elapsed_rx) = mpsc::channel();
let mut info = Info {
start_time: now,
elapsed_tx,
};
let mut context = unsafe { CFRunLoopTimerContext {
version: 0,
info: mem::transmute(&mut now),
info: &mut info as *mut _ as *mut c_void,
retain: mem::zeroed(),
release: mem::zeroed(),
copyDescription: mem::zeroed(),
@ -200,13 +179,21 @@ mod test {
run_loop.add_timer(&run_loop_timer, kCFRunLoopDefaultMode);
}
CFRunLoop::run_current();
let elapsed = elapsed_rx.try_recv().unwrap();
println!("wait_200_milliseconds, elapsed: {}", elapsed);
assert!(elapsed > 0.19 && elapsed < 0.30);
}
extern "C" fn timer_popped(_timer: CFRunLoopTimerRef, info: *mut c_void) {
let previous_now_ptr: *const CFAbsoluteTime = unsafe { mem::transmute(info) };
let previous_now = unsafe { *previous_now_ptr };
struct Info {
start_time: CFAbsoluteTime,
elapsed_tx: mpsc::Sender<f64>,
}
extern "C" fn timer_popped(_timer: CFRunLoopTimerRef, raw_info: *mut c_void) {
let info: *mut Info = unsafe { mem::transmute(raw_info) };
let now = CFDate::now().abs_time();
assert!(now - previous_now > 0.19 && now - previous_now < 0.21);
let elapsed = now - unsafe { (*info).start_time };
let _ = unsafe { (*info).elapsed_tx.send(elapsed) };
CFRunLoop::get_current().stop();
}
}

View File

@ -10,30 +10,23 @@
//! An immutable bag of elements.
pub use core_foundation_sys::set::*;
use core_foundation_sys::base::CFRelease;
use core_foundation_sys::base::{CFTypeRef, kCFAllocatorDefault};
use base::{CFIndexConvertible, TCFType};
use std::mem;
/// An immutable bag of elements.
pub struct CFSet(CFSetRef);
impl Drop for CFSet {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// An immutable bag of elements.
CFSet, CFSetRef
}
impl_TCFType!(CFSet, CFSetRef, CFSetGetTypeID);
impl_CFTypeDescription!(CFSet);
impl CFSet {
/// Creates a new set from a list of `CFType` instances.
pub fn from_slice<R, T>(elems: &[T]) -> CFSet where T: TCFType<R> {
pub fn from_slice<T>(elems: &[T]) -> CFSet where T: TCFType {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
let set_ref = CFSetCreate(kCFAllocatorDefault,

View File

@ -13,24 +13,18 @@ pub use core_foundation_sys::string::*;
use base::{CFIndexConvertible, TCFType};
use core_foundation_sys::base::{Boolean, CFIndex, CFRange, CFRelease};
use core_foundation_sys::base::{Boolean, CFIndex, CFRange};
use core_foundation_sys::base::{kCFAllocatorDefault, kCFAllocatorNull};
use std::fmt;
use std::str::{self, FromStr};
use std::ptr;
use std::ffi::CStr;
/// An immutable string in one of a variety of encodings.
pub struct CFString(CFStringRef);
impl Drop for CFString {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// An immutable string in one of a variety of encodings.
CFString, CFStringRef
}
impl_TCFType!(CFString, CFStringRef, CFStringGetTypeID);
impl FromStr for CFString {

View File

@ -10,7 +10,7 @@
//! Core Foundation time zone objects.
pub use core_foundation_sys::timezone::*;
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::base::kCFAllocatorDefault;
use base::TCFType;
use date::{CFDate, CFTimeInterval};
@ -18,17 +18,11 @@ use date::{CFDate, CFTimeInterval};
#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};
/// A time zone.
pub struct CFTimeZone(CFTimeZoneRef);
impl Drop for CFTimeZone {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType!{
/// A time zone.
CFTimeZone, CFTimeZoneRef
}
impl_TCFType!(CFTimeZone, CFTimeZoneRef, CFTimeZoneGetTypeID);
impl_CFTypeDescription!(CFTimeZone);

View File

@ -14,7 +14,7 @@ pub use core_foundation_sys::url::*;
use base::{TCFType, CFIndex};
use string::{CFString};
use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, Boolean};
use core_foundation_sys::base::{kCFAllocatorDefault, Boolean};
use std::fmt;
use std::ptr;
use std::path::{Path, PathBuf};
@ -27,16 +27,8 @@ use std::os::unix::ffi::OsStrExt;
#[cfg(unix)]
use std::ffi::OsStr;
pub struct CFURL(CFURLRef);
impl Drop for CFURL {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
declare_TCFType!(CFURL, CFURLRef);
impl_TCFType!(CFURL, CFURLRef, CFURLGetTypeID);
impl fmt::Debug for CFURL {

View File

@ -13,24 +13,18 @@
extern crate uuid;
pub use core_foundation_sys::uuid::*;
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::base::kCFAllocatorDefault;
use base::TCFType;
#[cfg(feature = "with-uuid")]
use self::uuid::Uuid;
/// A UUID.
pub struct CFUUID(CFUUIDRef);
impl Drop for CFUUID {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
declare_TCFType! {
/// A UUID.
CFUUID, CFUUIDRef
}
impl_TCFType!(CFUUID, CFUUIDRef, CFUUIDGetTypeID);
impl_CFTypeDescription!(CFUUID);

View File

@ -0,0 +1,29 @@
#[macro_use]
extern crate core_foundation;
extern crate libc;
use core_foundation::base::{CFComparisonResult, TCFType};
use libc::c_void;
// sys equivalent stuff that must be declared
#[repr(C)]
pub struct __CFFooBar(c_void);
pub type CFFooBarRef = *const __CFFooBar;
extern "C" {
pub fn CFFooBarGetTypeID() -> core_foundation::base::CFTypeID;
pub fn fake_compare(
this: CFFooBarRef,
other: CFFooBarRef,
context: *mut c_void,
) -> CFComparisonResult;
}
// Try to use the macros outside of the crate
declare_TCFType!(CFFooBar, CFFooBarRef);
impl_TCFType!(CFFooBar, CFFooBarRef, CFFooBarGetTypeID);
impl_CFTypeDescription!(CFFooBar);
impl_CFComparison!(CFFooBar, fake_compare);

View File

@ -1 +1 @@
{"files":{".travis.yml":"b71b9a6f84b9263b2b89be6ec90dff5920ee68cf9e5768d73ed71957de2d0670","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7391fc331e49b10143113e243bab8301c1df67488078189b7f83576944f007ac","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"10f3eeae06c6dd25cdf3e11b7e2fbbe5d003469ebb4aa1b069625a1637633879","src/color_space.rs":"bada04ad391869474428070ad9ae5dbb5e7f5e03646226fab0b03e8e84240bfa","src/context.rs":"601cb85abd122422abdbcbd8f6116ee4622009aee717cb478f6f0937d481b212","src/data_provider.rs":"78e9fc5c1c609bfb6a29136cd334575b77c6f4c994e444291dbccc52cfd35363","src/display.rs":"1c1a2fe5e52ba31437d5155adcc73f103a62bdaabca55ba290ec0b0b15cb9c7e","src/event.rs":"5f2a645cbd9582cc6861236a3696b9fa1655457bed884fdc218fc8b5b75921cb","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"d47701d76ca3aa7b0f47d31ccf6c7a0fd7c2141767a0e0d36058309d6692f513","src/geometry.rs":"b94e50a16b8540dc6f37bfe4b1549ac68974cd6ba6c0bbd9209559f8a46d86eb","src/image.rs":"fb77ae359b918cf3341662cb858cde6111eaa358f60fdd1ebbf264e023d25401","src/lib.rs":"19d5e558cec5596d546f1753529a8e3cf951993f4500ee12fad0d7eb2dc86bc8","src/path.rs":"d8dccd0bc2a1888a0a598fcca25067e932451e220dbec75999982cef9477d3ab","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"27e00f7ad7645af05014f35939128833456cac766a2978c5da295c3757708a86"},"package":"5dc0a78ab2ac23b6ea7b3fe5fe93b227900dc0956979735b8f68032417976dd4"}
{"files":{".travis.yml":"b71b9a6f84b9263b2b89be6ec90dff5920ee68cf9e5768d73ed71957de2d0670","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"3ff1a11a530609452fd321f65e6d3eb0a504ea3dd1c9b9b575ead73dbfd32072","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"10f3eeae06c6dd25cdf3e11b7e2fbbe5d003469ebb4aa1b069625a1637633879","src/color_space.rs":"bada04ad391869474428070ad9ae5dbb5e7f5e03646226fab0b03e8e84240bfa","src/context.rs":"601cb85abd122422abdbcbd8f6116ee4622009aee717cb478f6f0937d481b212","src/data_provider.rs":"78e9fc5c1c609bfb6a29136cd334575b77c6f4c994e444291dbccc52cfd35363","src/display.rs":"1c1a2fe5e52ba31437d5155adcc73f103a62bdaabca55ba290ec0b0b15cb9c7e","src/event.rs":"5f2a645cbd9582cc6861236a3696b9fa1655457bed884fdc218fc8b5b75921cb","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"5ddb75ccb23af98bfc82deefa3100288baf5ea0e4827242d878219d3251d6d55","src/geometry.rs":"b94e50a16b8540dc6f37bfe4b1549ac68974cd6ba6c0bbd9209559f8a46d86eb","src/image.rs":"fb77ae359b918cf3341662cb858cde6111eaa358f60fdd1ebbf264e023d25401","src/lib.rs":"19d5e558cec5596d546f1753529a8e3cf951993f4500ee12fad0d7eb2dc86bc8","src/path.rs":"d8dccd0bc2a1888a0a598fcca25067e932451e220dbec75999982cef9477d3ab","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"27e00f7ad7645af05014f35939128833456cac766a2978c5da295c3757708a86"},"package":"fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"}

View File

@ -12,7 +12,7 @@
[package]
name = "core-graphics"
version = "0.12.3"
version = "0.13.0"
authors = ["The Servo Project Developers"]
description = "Bindings to Core Graphics for OS X"
homepage = "https://github.com/servo/core-graphics-rs"
@ -22,7 +22,7 @@ repository = "https://github.com/servo/core-graphics-rs"
version = "1.0"
[dependencies.core-foundation]
version = "0.4"
version = "0.5"
[dependencies.foreign-types]
version = "0.3.0"

View File

@ -7,7 +7,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::ptr;
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType};
use core_foundation::array::{CFArray, CFArrayRef};
use core_foundation::data::{CFData, CFDataRef};
use core_foundation::string::{CFString, CFStringRef};
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
use data_provider::CGDataProvider;
@ -104,6 +107,21 @@ impl CGFont {
CGFontGetUnitsPerEm(self.as_ptr())
}
}
pub fn copy_table_tags(&self) -> CFArray<u32> {
unsafe {
TCFType::wrap_under_create_rule(CGFontCopyTableTags(self.as_ptr()))
}
}
pub fn copy_table_for_tag(&self, tag: u32) -> Option<CFData> {
let data_ref = unsafe { CGFontCopyTableForTag(self.as_ptr(), tag) };
if data_ref != ptr::null() {
Some(unsafe { TCFType::wrap_under_create_rule(data_ref) })
} else {
None
}
}
}
#[link(name = "CoreGraphics", kind = "framework")]
@ -132,4 +150,7 @@ extern {
advances: *mut c_int)
-> bool;
fn CGFontGetUnitsPerEm(font: ::sys::CGFontRef) -> c_int;
fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef;
fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef;
}

View File

@ -1 +1 @@
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"dbf9d3ddfff7cc11bbff7b477652dab547a7f1afaa5cc0706cdb04d812663c86","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"39f65fd202feb019b184c69570866050d0379f2d6adf1e1609010f1b980e2ef2","src/font_collection.rs":"5a8f5a17aec1dccf858ef1205c21d035fc5a8c7ac8ed7c089896a1f779bef126","src/font_descriptor.rs":"f932e5626ad8f93d88d82ed3bec9b249bdeccf3c44b1d5abfaed91e018e537d9","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"dfff85c1e4dbbc5d360dd022a8e539be4e5f195d8695467e1dcb25bd0bac4f47"},"package":"bcad23756dd1dc4b47bf6a914ace27aadb8fa68889db5837af2308d018d0467c"}
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7b694b4c2584d66e353968c93b4d639b7cbee87595b7323d721338299c2f80ec","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"de24c0023079289752a2fdb435012ba77982c108695d931926e6b629f0a7863a","src/font_collection.rs":"640402b679756d4cbf868d2cb96bb8c77f363ee36c42f7584d831a923c9006a2","src/font_descriptor.rs":"71781af6b428278bd1ed2a13e3aafa4be8f263e835c879016e697c5bc4104de8","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"dfff85c1e4dbbc5d360dd022a8e539be4e5f195d8695467e1dcb25bd0bac4f47"},"package":"2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"}

View File

@ -12,23 +12,23 @@
[package]
name = "core-text"
version = "8.0.0"
version = "9.0.0"
authors = ["The Servo Project Developers"]
description = "Bindings to the Core Text framework."
license = "MIT/Apache-2.0"
repository = "https://github.com/servo/core-text-rs"
[dependencies.core-graphics]
version = "0.12.1"
[dependencies.core-foundation]
version = "0.4"
version = "0.5"
[dependencies.libc]
version = "0.2"
[dependencies.core-graphics]
version = "0.13"
[dependencies.foreign-types]
version = "0.3"
[dependencies.libc]
version = "0.2"
[features]
default = ["mountainlion"]
mountainlion = []

View File

@ -102,7 +102,9 @@ impl Clone for CTFont {
}
}
impl TCFType<CTFontRef> for CTFont {
impl TCFType for CTFont {
type Ref = CTFontRef;
#[inline]
fn as_concrete_TypeRef(&self) -> CTFontRef {
self.obj
@ -408,7 +410,7 @@ pub fn debug_font_traits(font: &CTFont) {
}
#[cfg(feature = "mountainlion")]
pub fn cascade_list_for_languages(font: &CTFont, language_pref_list: &CFArray) -> CFArray {
pub fn cascade_list_for_languages(font: &CTFont, language_pref_list: &CFArray<CFString>) -> CFArray<CTFontDescriptor> {
unsafe {
let font_collection_ref =
CTFontCopyDefaultCascadeListForLanguages(font.as_concrete_TypeRef(),

View File

@ -40,7 +40,9 @@ impl Drop for CTFontCollection {
}
}
impl TCFType<CTFontCollectionRef> for CTFontCollection {
impl TCFType for CTFontCollection {
type Ref = CTFontCollectionRef;
#[inline]
fn as_concrete_TypeRef(&self) -> CTFontCollectionRef {
self.obj
@ -75,7 +77,7 @@ impl TCFType<CTFontCollectionRef> for CTFontCollection {
}
impl CTFontCollection {
pub fn get_descriptors(&self) -> CFArray {
pub fn get_descriptors(&self) -> CFArray<CTFontDescriptor> {
// surprise! this function follows the Get rule, despite being named *Create*.
// So we have to addRef it to avoid CTFontCollection from double freeing it later.
unsafe {
@ -84,10 +86,10 @@ impl CTFontCollection {
}
}
pub fn new_from_descriptors(descs: &CFArray) -> CTFontCollection {
pub fn new_from_descriptors(descs: &CFArray<CTFontDescriptor>) -> CTFontCollection {
unsafe {
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
let value = CFNumber::from_i64(1);
let value = CFNumber::from(1i64);
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
let font_collection_ref =
CTFontCollectionCreateWithFontDescriptors(descs.as_concrete_TypeRef(),
@ -99,7 +101,7 @@ pub fn new_from_descriptors(descs: &CFArray) -> CTFontCollection {
pub fn create_for_all_families() -> CTFontCollection {
unsafe {
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
let value = CFNumber::from_i64(1);
let value = CFNumber::from(1i64);
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
let font_collection_ref =
CTFontCollectionCreateFromAvailableFonts(options.as_concrete_TypeRef());
@ -126,14 +128,14 @@ pub fn create_for_family(family: &str) -> Option<CTFontCollection> {
if matched_descs == ptr::null() {
return None;
}
let matched_descs: CFArray = TCFType::wrap_under_create_rule(matched_descs);
let matched_descs: CFArray<CTFontDescriptor> = TCFType::wrap_under_create_rule(matched_descs);
// I suppose one doesn't even need the CTFontCollection object at this point.
// But we stick descriptors into and out of it just to provide a nice wrapper API.
Some(new_from_descriptors(&matched_descs))
}
}
pub fn get_family_names() -> CFArray {
pub fn get_family_names() -> CFArray<CFString> {
unsafe {
TCFType::wrap_under_create_rule(CTFontManagerCopyAvailableFontFamilyNames())
}

View File

@ -15,7 +15,7 @@ use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
use core_foundation::number::{CFNumber, CFNumberRef};
use core_foundation::set::CFSetRef;
use core_foundation::string::{CFString, CFStringRef};
use core_foundation::url::{CFURL, CFURLRef};
use core_foundation::url::CFURL;
use core_graphics::base::CGFloat;
use libc::c_void;
@ -85,7 +85,7 @@ pub trait StylisticClassAccessors {
impl StylisticClassAccessors for CTFontStylisticClass {
fn is_serif(&self) -> bool {
let any_serif_class = kCTFontOldStyleSerifsClass
let any_serif_class = kCTFontOldStyleSerifsClass
| kCTFontTransitionalSerifsClass
| kCTFontModernSerifsClass
| kCTFontClarendonSerifsClass
@ -130,7 +130,7 @@ trait TraitAccessorPrivate {
impl TraitAccessorPrivate for CTFontTraits {
unsafe fn extract_number_for_key(&self, key: CFStringRef) -> CFNumber {
let cftype = self.get_CFType(mem::transmute(key));
assert!(cftype.instance_of::<CFNumberRef,CFNumber>());
assert!(cftype.instance_of::<CFNumber>());
TCFType::wrap_under_get_rule(mem::transmute(cftype.as_CFTypeRef()))
}
@ -200,7 +200,9 @@ impl Drop for CTFontDescriptor {
}
}
impl TCFType<CTFontDescriptorRef> for CTFontDescriptor {
impl TCFType for CTFontDescriptor {
type Ref = CTFontDescriptorRef;
#[inline]
fn as_concrete_TypeRef(&self) -> CTFontDescriptorRef {
self.obj
@ -243,7 +245,7 @@ impl CTFontDescriptor {
}
let value: CFType = TCFType::wrap_under_get_rule(value);
assert!(value.instance_of::<CFStringRef,CFString>());
assert!(value.instance_of::<CFString>());
let s: CFString = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(s.to_string())
}
@ -254,8 +256,8 @@ impl CTFontDescriptor {
impl CTFontDescriptor {
pub fn family_name(&self) -> String {
unsafe {
let value = self.get_string_attribute(kCTFontDisplayNameAttribute);
value.expect("A font2 must have a non-null font family name.")
let value = self.get_string_attribute(kCTFontFamilyNameAttribute);
value.expect("A font must have a non-null family name.")
}
}
@ -288,7 +290,7 @@ impl CTFontDescriptor {
}
let value: CFType = TCFType::wrap_under_get_rule(value);
assert!(value.instance_of::<CFURLRef,CFURL>());
assert!(value.instance_of::<CFURL>());
let url: CFURL = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(format!("{:?}", url))
}
@ -359,12 +361,12 @@ extern {
pub fn CTFontDescriptorCopyLocalizedAttribute(descriptor: CTFontDescriptorRef,
attribute: CFStringRef,
language: *mut CFStringRef) -> CFTypeRef;
pub fn CTFontDescriptorCreateCopyWithAttributes(original: CTFontDescriptorRef,
pub fn CTFontDescriptorCreateCopyWithAttributes(original: CTFontDescriptorRef,
attributes: CFDictionaryRef) -> CTFontDescriptorRef;
pub fn CTFontDescriptorCreateCopyWithFeature(original: CTFontDescriptorRef,
featureTypeIdentifier: CFNumberRef,
featureSelectorIdentifier: CFNumberRef) -> CTFontDescriptorRef;
pub fn CTFontDescriptorCreateCopyWithVariation(original: CTFontDescriptorRef,
pub fn CTFontDescriptorCreateCopyWithVariation(original: CTFontDescriptorRef,
variationIdentifier: CFNumberRef,
variationValue: CGFloat) -> CTFontDescriptorRef;
pub fn CTFontDescriptorCreateMatchingFontDescriptor(descriptor: CTFontDescriptorRef,

View File

@ -226,10 +226,10 @@ dependencies = [
[[package]]
name = "core-foundation"
version = "0.4.6"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -243,7 +243,7 @@ dependencies = [
[[package]]
name = "core-foundation-sys"
version = "0.4.6"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@ -251,22 +251,22 @@ dependencies = [
[[package]]
name = "core-graphics"
version = "0.12.3"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-text"
version = "8.0.0"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1538,15 +1538,15 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.56.1"
version = "0.57.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1562,19 +1562,19 @@ dependencies = [
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.56.1",
"webrender_api 0.57.0",
]
[[package]]
name = "webrender_api"
version = "0.56.1"
version = "0.57.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1587,8 +1587,8 @@ name = "webrender_bindings"
version = "0.1.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1596,7 +1596,7 @@ dependencies = [
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.56.1",
"webrender 0.57.0",
]
[[package]]
@ -1685,11 +1685,11 @@ dependencies = [
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e"
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
"checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5"
"checksum core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc0a78ab2ac23b6ea7b3fe5fe93b227900dc0956979735b8f68032417976dd4"
"checksum core-text 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcad23756dd1dc4b47bf6a914ace27aadb8fa68889db5837af2308d018d0467c"
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
"checksum core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"
"checksum core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"
"checksum cose 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72fa26cb151d3ae4b70f63d67d0fed57ce04220feafafbae7f503bef7aae590d"
"checksum cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "49726015ab0ca765144fcca61e4a7a543a16b795a777fa53f554da2fffff9a94"
"checksum cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a807ac3ab7a217829c2a3b65732b926b2befe6a35f33b4bf8b503692430f223"

View File

@ -226,10 +226,10 @@ dependencies = [
[[package]]
name = "core-foundation"
version = "0.4.6"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -243,7 +243,7 @@ dependencies = [
[[package]]
name = "core-foundation-sys"
version = "0.4.6"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@ -251,22 +251,22 @@ dependencies = [
[[package]]
name = "core-graphics"
version = "0.12.3"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-text"
version = "8.0.0"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1549,15 +1549,15 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.56.1"
version = "0.57.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1573,19 +1573,19 @@ dependencies = [
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.56.1",
"webrender_api 0.57.0",
]
[[package]]
name = "webrender_api"
version = "0.56.1"
version = "0.57.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1598,8 +1598,8 @@ name = "webrender_bindings"
version = "0.1.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1607,7 +1607,7 @@ dependencies = [
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.56.1",
"webrender 0.57.0",
]
[[package]]
@ -1687,11 +1687,11 @@ dependencies = [
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e"
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
"checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5"
"checksum core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc0a78ab2ac23b6ea7b3fe5fe93b227900dc0956979735b8f68032417976dd4"
"checksum core-text 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcad23756dd1dc4b47bf6a914ace27aadb8fa68889db5837af2308d018d0467c"
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
"checksum core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"
"checksum core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"
"checksum cose 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72fa26cb151d3ae4b70f63d67d0fed57ce04220feafafbae7f503bef7aae590d"
"checksum cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "49726015ab0ca765144fcca61e4a7a543a16b795a777fa53f554da2fffff9a94"
"checksum cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a807ac3ab7a217829c2a3b65732b926b2befe6a35f33b4bf8b503692430f223"