зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374730 - Update Cargo.lock files and revendor rust dependencies. r=jrmuizel
MozReview-Commit-ID: AoLr2W2NGhP --HG-- extra : rebase_source : 892ea94c01f575b7f33d7cb740a74af5b58b02b0
This commit is contained in:
Родитель
43d050abae
Коммит
7c916dff61
|
@ -0,0 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"793de473e858941a0d41e0c4e114373bca6b822737cdcf5ff8f36238a9b51837","Cargo.toml":"98d1298b1d79ccc587957062cf1c56712f68ee2796bed5f39c8d334133d9c562","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"1cce1c9c1fe2cf40ec1c6a0384f8cc2f0c5c40ece4acfedd64330ed95ef74e44","src/lib.rs":"006a631d800f713e2ffc74e33f65fd47505eec1b047c109e180905a9dcb7e973","tests/external.rs":"546e549ec831876a5dc272bd0537adc9e9886c6da54656c825e7bffc079e2c74","tests/external_no_std.rs":"48929f5109aabc156442d5ae2ab07b4bce5d648488bf49dba725f6ab23bcb48a","tests/i128_bitflags.rs":"fb1bf9e01f528478539c52de94e82a96b2639dc271ea242fea6ebb32dcb0f99e"},"package":"1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"}
|
|
@ -0,0 +1,24 @@
|
|||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
sudo: false
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- cargo test --verbose
|
||||
- travis-cargo --only nightly test
|
||||
- cargo doc --no-deps
|
||||
after_success:
|
||||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: "DoZ8g8iPs+X3xEEucke0Ae02JbkQ1qd1SSv/L2aQqxULmREtRcbzRauhiT+ToQO5Ft1Lul8uck14nPfs4gMr/O3jFFBhEBVpSlbkJx7eNL3kwUdp95UNroA8I43xPN/nccJaHDN6TMTD3+uajTQTje2SyzOQP+1gvdKg17kguvE="
|
||||
|
||||
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
|
||||
name = "bitflags"
|
||||
version = "0.8.2"
|
||||
authors = ["The Rust Project Developers"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/rust-lang/bitflags"
|
||||
homepage = "https://github.com/rust-lang/bitflags"
|
||||
documentation = "https://doc.rust-lang.org/bitflags"
|
||||
description = """
|
||||
A macro to generate structures which behave like bitflags.
|
||||
"""
|
||||
|
||||
[features]
|
||||
i128 = []
|
||||
unstable = ["i128"]
|
|
@ -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.
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2014 The Rust Project Developers
|
||||
|
||||
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.
|
|
@ -0,0 +1,43 @@
|
|||
bitflags
|
||||
========
|
||||
|
||||
A Rust macro to generate structures which behave like a set of bitflags
|
||||
|
||||
[![Build Status](https://travis-ci.org/rust-lang-nursery/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/bitflags)
|
||||
|
||||
[Documentation](https://doc.rust-lang.org/bitflags)
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
bitflags = "0.7"
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
```
|
||||
|
||||
## 128-bit integer bitflags (nightly only)
|
||||
|
||||
Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies.bitflags]
|
||||
version = "0.7"
|
||||
features = ["i128"]
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
||||
```rust
|
||||
#![feature(i128_type)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
```
|
|
@ -0,0 +1,840 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! A typesafe bitmask flag generator.
|
||||
|
||||
#![no_std]
|
||||
|
||||
#![cfg_attr(feature = "i128", feature(i128_type))]
|
||||
|
||||
// When compiled for the rustc compiler itself we want to make sure that this is
|
||||
// an unstable crate.
|
||||
#![cfg_attr(rustbuild, feature(staged_api))]
|
||||
#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
|
||||
// Re-export libstd/libcore using an alias so that the macros can work in no_std
|
||||
// crates while remaining compatible with normal crates.
|
||||
#[allow(private_in_public)]
|
||||
#[doc(hidden)]
|
||||
pub use core as __core;
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
pub type __BitFlagsWidth = u128;
|
||||
#[cfg(not(feature = "i128"))]
|
||||
pub type __BitFlagsWidth = u64;
|
||||
|
||||
/// The `bitflags!` macro generates a `struct` that holds a set of C-style
|
||||
/// bitmask flags. It is useful for creating typesafe wrappers for C APIs.
|
||||
///
|
||||
/// The flags should only be defined for integer types, otherwise unexpected
|
||||
/// type errors may occur at compile time.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```{.rust}
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// bitflags! {
|
||||
/// flags Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// const FLAG_C = 0b00000100,
|
||||
/// const FLAG_ABC = FLAG_A.bits
|
||||
/// | FLAG_B.bits
|
||||
/// | FLAG_C.bits,
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let e1 = FLAG_A | FLAG_C;
|
||||
/// let e2 = FLAG_B | FLAG_C;
|
||||
/// assert_eq!((e1 | e2), FLAG_ABC); // union
|
||||
/// assert_eq!((e1 & e2), FLAG_C); // intersection
|
||||
/// assert_eq!((e1 - e2), FLAG_A); // set difference
|
||||
/// assert_eq!(!e2, FLAG_A); // set complement
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// The generated `struct`s can also be extended with type and trait
|
||||
/// implementations:
|
||||
///
|
||||
/// ```{.rust}
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// use std::fmt;
|
||||
///
|
||||
/// bitflags! {
|
||||
/// flags Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl Flags {
|
||||
/// pub fn clear(&mut self) {
|
||||
/// self.bits = 0; // The `bits` field can be accessed from within the
|
||||
/// // same module where the `bitflags!` macro was invoked.
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl fmt::Display for Flags {
|
||||
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
/// write!(f, "hi!")
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let mut flags = FLAG_A | FLAG_B;
|
||||
/// flags.clear();
|
||||
/// assert!(flags.is_empty());
|
||||
/// assert_eq!(format!("{}", flags), "hi!");
|
||||
/// assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
|
||||
/// assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Visibility
|
||||
///
|
||||
/// The generated struct and its associated flag constants are not exported
|
||||
/// out of the current module by default. A definition can be exported out of
|
||||
/// the current module by adding `pub` before `flags`:
|
||||
///
|
||||
/// ```{.rust},ignore
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// mod example {
|
||||
/// bitflags! {
|
||||
/// pub flags Flags1: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// }
|
||||
/// }
|
||||
/// bitflags! {
|
||||
/// flags Flags2: u32 {
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let flag1 = example::FLAG_A;
|
||||
/// let flag2 = example::FLAG_B; // error: const `FLAG_B` is private
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Attributes
|
||||
///
|
||||
/// Attributes can be attached to the generated `struct` by placing them
|
||||
/// before the `flags` keyword.
|
||||
///
|
||||
/// # Trait implementations
|
||||
///
|
||||
/// The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash`
|
||||
/// traits automatically derived for the `struct` using the `derive` attribute.
|
||||
/// Additional traits can be derived by providing an explicit `derive`
|
||||
/// attribute on `flags`.
|
||||
///
|
||||
/// The `Extend` and `FromIterator` traits are implemented for the `struct`,
|
||||
/// too: `Extend` adds the union of the instances of the `struct` iterated over,
|
||||
/// while `FromIterator` calculates the union.
|
||||
///
|
||||
/// The `Debug` trait is also implemented by displaying the bits value of the
|
||||
/// internal struct.
|
||||
///
|
||||
/// ## Operators
|
||||
///
|
||||
/// The following operator traits are implemented for the generated `struct`:
|
||||
///
|
||||
/// - `BitOr` and `BitOrAssign`: union
|
||||
/// - `BitAnd` and `BitAndAssign`: intersection
|
||||
/// - `BitXor` and `BitXorAssign`: toggle
|
||||
/// - `Sub` and `SubAssign`: set difference
|
||||
/// - `Not`: set complement
|
||||
///
|
||||
/// As long as the assignment operators are unstable rust feature they are only
|
||||
/// available with the crate feature `assignment_ops` enabled.
|
||||
///
|
||||
/// # Methods
|
||||
///
|
||||
/// The following methods are defined for the generated `struct`:
|
||||
///
|
||||
/// - `empty`: an empty set of flags
|
||||
/// - `all`: the set of all flags
|
||||
/// - `bits`: the raw value of the flags currently stored
|
||||
/// - `from_bits`: convert from underlying bit representation, unless that
|
||||
/// representation contains bits that do not correspond to a flag
|
||||
/// - `from_bits_truncate`: convert from underlying bit representation, dropping
|
||||
/// any bits that do not correspond to flags
|
||||
/// - `is_empty`: `true` if no flags are currently stored
|
||||
/// - `is_all`: `true` if all flags are currently set
|
||||
/// - `intersects`: `true` if there are flags common to both `self` and `other`
|
||||
/// - `contains`: `true` all of the flags in `other` are contained within `self`
|
||||
/// - `insert`: inserts the specified flags in-place
|
||||
/// - `remove`: removes the specified flags in-place
|
||||
/// - `toggle`: the specified flags will be inserted if not present, and removed
|
||||
/// if they are.
|
||||
#[macro_export]
|
||||
macro_rules! bitflags {
|
||||
($(#[$attr:meta])* pub flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
}) => {
|
||||
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
|
||||
$(#[$attr])*
|
||||
pub struct $BitFlags {
|
||||
bits: $T,
|
||||
}
|
||||
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+
|
||||
|
||||
bitflags! {
|
||||
@_impl flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
}) => {
|
||||
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
|
||||
$(#[$attr])*
|
||||
struct $BitFlags {
|
||||
bits: $T,
|
||||
}
|
||||
|
||||
$($(#[$Flag_attr])* const $Flag: $BitFlags = $BitFlags { bits: $value };)+
|
||||
|
||||
bitflags! {
|
||||
@_impl flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
(@_impl flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
}) => {
|
||||
impl $crate::__core::fmt::Debug for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::__core::fmt::Formatter) -> $crate::__core::fmt::Result {
|
||||
// This convoluted approach is to handle #[cfg]-based flag
|
||||
// omission correctly. Some of the $Flag variants may not be
|
||||
// defined in this module so we create an inner module which
|
||||
// defines *all* flags to the value of 0. We then create a
|
||||
// second inner module that defines all of the flags with #[cfg]
|
||||
// to their real values. Afterwards the glob will import
|
||||
// variants from the second inner module, shadowing all
|
||||
// defined variants, leaving only the undefined ones with the
|
||||
// bit value of 0.
|
||||
#[allow(dead_code)]
|
||||
#[allow(unused_assignments)]
|
||||
mod dummy {
|
||||
// We can't use the real $BitFlags struct because it may be
|
||||
// private, which prevents us from using it to define
|
||||
// public constants.
|
||||
pub struct $BitFlags {
|
||||
bits: $crate::__BitFlagsWidth,
|
||||
}
|
||||
mod real_flags {
|
||||
use super::$BitFlags;
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags {
|
||||
bits: super::super::$Flag.bits as $crate::__BitFlagsWidth
|
||||
};)+
|
||||
}
|
||||
// Now we define the "undefined" versions of the flags.
|
||||
// This way, all the names exist, even if some are #[cfg]ed
|
||||
// out.
|
||||
$(const $Flag: $BitFlags = $BitFlags { bits: 0 };)+
|
||||
|
||||
#[inline]
|
||||
pub fn fmt(self_: $crate::__BitFlagsWidth,
|
||||
f: &mut $crate::__core::fmt::Formatter)
|
||||
-> $crate::__core::fmt::Result {
|
||||
// Now we import the real values for the flags.
|
||||
// Only ones that are #[cfg]ed out will be 0.
|
||||
use self::real_flags::*;
|
||||
|
||||
let mut first = true;
|
||||
$(
|
||||
// $Flag.bits == 0 means that $Flag doesn't exist
|
||||
if $Flag.bits != 0 && self_ & $Flag.bits as $crate::__BitFlagsWidth ==
|
||||
$Flag.bits as $crate::__BitFlagsWidth {
|
||||
if !first {
|
||||
try!(f.write_str(" | "));
|
||||
}
|
||||
first = false;
|
||||
try!(f.write_str(stringify!($Flag)));
|
||||
}
|
||||
)+
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
dummy::fmt(self.bits as $crate::__BitFlagsWidth, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl $BitFlags {
|
||||
/// Returns an empty set of flags.
|
||||
#[inline]
|
||||
pub fn empty() -> $BitFlags {
|
||||
$BitFlags { bits: 0 }
|
||||
}
|
||||
|
||||
/// Returns the set containing all flags.
|
||||
#[inline]
|
||||
pub fn all() -> $BitFlags {
|
||||
// See above `dummy` module for why this approach is taken.
|
||||
#[allow(dead_code)]
|
||||
mod dummy {
|
||||
pub struct $BitFlags {
|
||||
bits: $crate::__BitFlagsWidth,
|
||||
}
|
||||
mod real_flags {
|
||||
use super::$BitFlags;
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags {
|
||||
bits: super::super::$Flag.bits as $crate::__BitFlagsWidth
|
||||
};)+
|
||||
}
|
||||
$(const $Flag: $BitFlags = $BitFlags { bits: 0 };)+
|
||||
|
||||
#[inline]
|
||||
pub fn all() -> $crate::__BitFlagsWidth {
|
||||
use self::real_flags::*;
|
||||
$($Flag.bits)|+
|
||||
}
|
||||
}
|
||||
$BitFlags { bits: dummy::all() as $T }
|
||||
}
|
||||
|
||||
/// Returns the raw value of the flags currently stored.
|
||||
#[inline]
|
||||
pub fn bits(&self) -> $T {
|
||||
self.bits
|
||||
}
|
||||
|
||||
/// Convert from underlying bit representation, unless that
|
||||
/// representation contains bits that do not correspond to a flag.
|
||||
#[inline]
|
||||
pub fn from_bits(bits: $T) -> $crate::__core::option::Option<$BitFlags> {
|
||||
if (bits & !$BitFlags::all().bits()) == 0 {
|
||||
$crate::__core::option::Option::Some($BitFlags { bits: bits })
|
||||
} else {
|
||||
$crate::__core::option::Option::None
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert from underlying bit representation, dropping any bits
|
||||
/// that do not correspond to flags.
|
||||
#[inline]
|
||||
pub fn from_bits_truncate(bits: $T) -> $BitFlags {
|
||||
$BitFlags { bits: bits } & $BitFlags::all()
|
||||
}
|
||||
|
||||
/// Returns `true` if no flags are currently stored.
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
*self == $BitFlags::empty()
|
||||
}
|
||||
|
||||
/// Returns `true` if all flags are currently set.
|
||||
#[inline]
|
||||
pub fn is_all(&self) -> bool {
|
||||
*self == $BitFlags::all()
|
||||
}
|
||||
|
||||
/// Returns `true` if there are flags common to both `self` and `other`.
|
||||
#[inline]
|
||||
pub fn intersects(&self, other: $BitFlags) -> bool {
|
||||
!(*self & other).is_empty()
|
||||
}
|
||||
|
||||
/// Returns `true` all of the flags in `other` are contained within `self`.
|
||||
#[inline]
|
||||
pub fn contains(&self, other: $BitFlags) -> bool {
|
||||
(*self & other) == other
|
||||
}
|
||||
|
||||
/// Inserts the specified flags in-place.
|
||||
#[inline]
|
||||
pub fn insert(&mut self, other: $BitFlags) {
|
||||
self.bits |= other.bits;
|
||||
}
|
||||
|
||||
/// Removes the specified flags in-place.
|
||||
#[inline]
|
||||
pub fn remove(&mut self, other: $BitFlags) {
|
||||
self.bits &= !other.bits;
|
||||
}
|
||||
|
||||
/// Toggles the specified flags in-place.
|
||||
#[inline]
|
||||
pub fn toggle(&mut self, other: $BitFlags) {
|
||||
self.bits ^= other.bits;
|
||||
}
|
||||
|
||||
/// Inserts or removes the specified flags depending on the passed value.
|
||||
#[inline]
|
||||
pub fn set(&mut self, other: $BitFlags, value: bool) {
|
||||
if value {
|
||||
self.insert(other);
|
||||
} else {
|
||||
self.remove(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitOr for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the union of the two sets of flags.
|
||||
#[inline]
|
||||
fn bitor(self, other: $BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits | other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitOrAssign for $BitFlags {
|
||||
|
||||
/// Adds the set of flags.
|
||||
#[inline]
|
||||
fn bitor_assign(&mut self, other: $BitFlags) {
|
||||
self.bits |= other.bits;
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitXor for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the left flags, but with all the right flags toggled.
|
||||
#[inline]
|
||||
fn bitxor(self, other: $BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits ^ other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitXorAssign for $BitFlags {
|
||||
|
||||
/// Toggles the set of flags.
|
||||
#[inline]
|
||||
fn bitxor_assign(&mut self, other: $BitFlags) {
|
||||
self.bits ^= other.bits;
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitAnd for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the intersection between the two sets of flags.
|
||||
#[inline]
|
||||
fn bitand(self, other: $BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits & other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitAndAssign for $BitFlags {
|
||||
|
||||
/// Disables all flags disabled in the set.
|
||||
#[inline]
|
||||
fn bitand_assign(&mut self, other: $BitFlags) {
|
||||
self.bits &= other.bits;
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::Sub for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the set difference of the two sets of flags.
|
||||
#[inline]
|
||||
fn sub(self, other: $BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits & !other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::SubAssign for $BitFlags {
|
||||
|
||||
/// Disables all flags enabled in the set.
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, other: $BitFlags) {
|
||||
self.bits &= !other.bits;
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::Not for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the complement of this set of flags.
|
||||
#[inline]
|
||||
fn not(self) -> $BitFlags {
|
||||
$BitFlags { bits: !self.bits } & $BitFlags::all()
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::iter::Extend<$BitFlags> for $BitFlags {
|
||||
fn extend<T: $crate::__core::iter::IntoIterator<Item=$BitFlags>>(&mut self, iterator: T) {
|
||||
for item in iterator {
|
||||
self.insert(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::iter::FromIterator<$BitFlags> for $BitFlags {
|
||||
fn from_iter<T: $crate::__core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
|
||||
let mut result = Self::empty();
|
||||
result.extend(iterator);
|
||||
result
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* pub flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+,
|
||||
}) => {
|
||||
bitflags! {
|
||||
$(#[$attr])*
|
||||
pub flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+,
|
||||
}) => {
|
||||
bitflags! {
|
||||
$(#[$attr])*
|
||||
flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(non_upper_case_globals, dead_code)]
|
||||
mod tests {
|
||||
use std::hash::{SipHasher, Hash, Hasher};
|
||||
|
||||
bitflags! {
|
||||
#[doc = "> The first principle is that you must not fool yourself — and"]
|
||||
#[doc = "> you are the easiest person to fool."]
|
||||
#[doc = "> "]
|
||||
#[doc = "> - Richard Feynman"]
|
||||
flags Flags: u32 {
|
||||
const FlagA = 0b00000001,
|
||||
#[doc = "<pcwalton> macros are way better at generating code than trans is"]
|
||||
const FlagB = 0b00000010,
|
||||
const FlagC = 0b00000100,
|
||||
#[doc = "* cmr bed"]
|
||||
#[doc = "* strcat table"]
|
||||
#[doc = "<strcat> wait what?"]
|
||||
const FlagABC = FlagA.bits
|
||||
| FlagB.bits
|
||||
| FlagC.bits,
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
flags _CfgFlags: u32 {
|
||||
#[cfg(windows)]
|
||||
const _CfgA = 0b01,
|
||||
#[cfg(unix)]
|
||||
const _CfgB = 0b01,
|
||||
#[cfg(windows)]
|
||||
const _CfgC = _CfgA.bits | 0b10,
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
flags AnotherSetOfFlags: i8 {
|
||||
const AnotherFlag = -1_i8,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bits(){
|
||||
assert_eq!(Flags::empty().bits(), 0b00000000);
|
||||
assert_eq!(FlagA.bits(), 0b00000001);
|
||||
assert_eq!(FlagABC.bits(), 0b00000111);
|
||||
|
||||
assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
|
||||
assert_eq!(AnotherFlag.bits(), !0_i8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_bits() {
|
||||
assert_eq!(Flags::from_bits(0), Some(Flags::empty()));
|
||||
assert_eq!(Flags::from_bits(0b1), Some(FlagA));
|
||||
assert_eq!(Flags::from_bits(0b10), Some(FlagB));
|
||||
assert_eq!(Flags::from_bits(0b11), Some(FlagA | FlagB));
|
||||
assert_eq!(Flags::from_bits(0b1000), None);
|
||||
|
||||
assert_eq!(AnotherSetOfFlags::from_bits(!0_i8), Some(AnotherFlag));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_bits_truncate() {
|
||||
assert_eq!(Flags::from_bits_truncate(0), Flags::empty());
|
||||
assert_eq!(Flags::from_bits_truncate(0b1), FlagA);
|
||||
assert_eq!(Flags::from_bits_truncate(0b10), FlagB);
|
||||
assert_eq!(Flags::from_bits_truncate(0b11), (FlagA | FlagB));
|
||||
assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty());
|
||||
assert_eq!(Flags::from_bits_truncate(0b1001), FlagA);
|
||||
|
||||
assert_eq!(AnotherSetOfFlags::from_bits_truncate(0_i8), AnotherSetOfFlags::empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_empty(){
|
||||
assert!(Flags::empty().is_empty());
|
||||
assert!(!FlagA.is_empty());
|
||||
assert!(!FlagABC.is_empty());
|
||||
|
||||
assert!(!AnotherFlag.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_all() {
|
||||
assert!(Flags::all().is_all());
|
||||
assert!(!FlagA.is_all());
|
||||
assert!(FlagABC.is_all());
|
||||
|
||||
assert!(AnotherFlag.is_all());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_two_empties_do_not_intersect() {
|
||||
let e1 = Flags::empty();
|
||||
let e2 = Flags::empty();
|
||||
assert!(!e1.intersects(e2));
|
||||
|
||||
assert!(AnotherFlag.intersects(AnotherFlag));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_does_not_intersect_with_full() {
|
||||
let e1 = Flags::empty();
|
||||
let e2 = FlagABC;
|
||||
assert!(!e1.intersects(e2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_disjoint_intersects() {
|
||||
let e1 = FlagA;
|
||||
let e2 = FlagB;
|
||||
assert!(!e1.intersects(e2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_overlapping_intersects() {
|
||||
let e1 = FlagA;
|
||||
let e2 = FlagA | FlagB;
|
||||
assert!(e1.intersects(e2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_contains() {
|
||||
let e1 = FlagA;
|
||||
let e2 = FlagA | FlagB;
|
||||
assert!(!e1.contains(e2));
|
||||
assert!(e2.contains(e1));
|
||||
assert!(FlagABC.contains(e2));
|
||||
|
||||
assert!(AnotherFlag.contains(AnotherFlag));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_insert(){
|
||||
let mut e1 = FlagA;
|
||||
let e2 = FlagA | FlagB;
|
||||
e1.insert(e2);
|
||||
assert_eq!(e1, e2);
|
||||
|
||||
let mut e3 = AnotherSetOfFlags::empty();
|
||||
e3.insert(AnotherFlag);
|
||||
assert_eq!(e3, AnotherFlag);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove(){
|
||||
let mut e1 = FlagA | FlagB;
|
||||
let e2 = FlagA | FlagC;
|
||||
e1.remove(e2);
|
||||
assert_eq!(e1, FlagB);
|
||||
|
||||
let mut e3 = AnotherFlag;
|
||||
e3.remove(AnotherFlag);
|
||||
assert_eq!(e3, AnotherSetOfFlags::empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_operators() {
|
||||
let e1 = FlagA | FlagC;
|
||||
let e2 = FlagB | FlagC;
|
||||
assert_eq!((e1 | e2), FlagABC); // union
|
||||
assert_eq!((e1 & e2), FlagC); // intersection
|
||||
assert_eq!((e1 - e2), FlagA); // set difference
|
||||
assert_eq!(!e2, FlagA); // set complement
|
||||
assert_eq!(e1 ^ e2, FlagA | FlagB); // toggle
|
||||
let mut e3 = e1;
|
||||
e3.toggle(e2);
|
||||
assert_eq!(e3, FlagA | FlagB);
|
||||
|
||||
let mut m4 = AnotherSetOfFlags::empty();
|
||||
m4.toggle(AnotherSetOfFlags::empty());
|
||||
assert_eq!(m4, AnotherSetOfFlags::empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set() {
|
||||
let mut e1 = FlagA | FlagC;
|
||||
e1.set(FlagB, true);
|
||||
e1.set(FlagC, false);
|
||||
|
||||
assert_eq!(e1, FlagA | FlagB);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assignment_operators() {
|
||||
let mut m1 = Flags::empty();
|
||||
let e1 = FlagA | FlagC;
|
||||
// union
|
||||
m1 |= FlagA;
|
||||
assert_eq!(m1, FlagA);
|
||||
// intersection
|
||||
m1 &= e1;
|
||||
assert_eq!(m1, FlagA);
|
||||
// set difference
|
||||
m1 -= m1;
|
||||
assert_eq!(m1, Flags::empty());
|
||||
// toggle
|
||||
m1 ^= e1;
|
||||
assert_eq!(m1, e1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extend() {
|
||||
let mut flags;
|
||||
|
||||
flags = Flags::empty();
|
||||
flags.extend([].iter().cloned());
|
||||
assert_eq!(flags, Flags::empty());
|
||||
|
||||
flags = Flags::empty();
|
||||
flags.extend([FlagA, FlagB].iter().cloned());
|
||||
assert_eq!(flags, FlagA | FlagB);
|
||||
|
||||
flags = FlagA;
|
||||
flags.extend([FlagA, FlagB].iter().cloned());
|
||||
assert_eq!(flags, FlagA | FlagB);
|
||||
|
||||
flags = FlagB;
|
||||
flags.extend([FlagA, FlagABC].iter().cloned());
|
||||
assert_eq!(flags, FlagABC);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_iterator() {
|
||||
assert_eq!([].iter().cloned().collect::<Flags>(), Flags::empty());
|
||||
assert_eq!([FlagA, FlagB].iter().cloned().collect::<Flags>(), FlagA | FlagB);
|
||||
assert_eq!([FlagA, FlagABC].iter().cloned().collect::<Flags>(), FlagABC);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lt() {
|
||||
let mut a = Flags::empty();
|
||||
let mut b = Flags::empty();
|
||||
|
||||
assert!(!(a < b) && !(b < a));
|
||||
b = FlagB;
|
||||
assert!(a < b);
|
||||
a = FlagC;
|
||||
assert!(!(a < b) && b < a);
|
||||
b = FlagC | FlagB;
|
||||
assert!(a < b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ord() {
|
||||
let mut a = Flags::empty();
|
||||
let mut b = Flags::empty();
|
||||
|
||||
assert!(a <= b && a >= b);
|
||||
a = FlagA;
|
||||
assert!(a > b && a >= b);
|
||||
assert!(b < a && b <= a);
|
||||
b = FlagB;
|
||||
assert!(b > a && b >= a);
|
||||
assert!(a < b && a <= b);
|
||||
}
|
||||
|
||||
fn hash<T: Hash>(t: &T) -> u64 {
|
||||
let mut s = SipHasher::new_with_keys(0, 0);
|
||||
t.hash(&mut s);
|
||||
s.finish()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hash() {
|
||||
let mut x = Flags::empty();
|
||||
let mut y = Flags::empty();
|
||||
assert_eq!(hash(&x), hash(&y));
|
||||
x = Flags::all();
|
||||
y = FlagABC;
|
||||
assert_eq!(hash(&x), hash(&y));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug() {
|
||||
assert_eq!(format!("{:?}", FlagA | FlagB), "FlagA | FlagB");
|
||||
assert_eq!(format!("{:?}", FlagABC), "FlagA | FlagB | FlagC | FlagABC");
|
||||
}
|
||||
|
||||
mod submodule {
|
||||
bitflags! {
|
||||
pub flags PublicFlags: i8 {
|
||||
const FlagX = 0,
|
||||
}
|
||||
}
|
||||
bitflags! {
|
||||
flags PrivateFlags: i8 {
|
||||
const FlagY = 0,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_private() {
|
||||
let _ = FlagY;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_public() {
|
||||
let _ = submodule::FlagX;
|
||||
}
|
||||
|
||||
mod t1 {
|
||||
mod foo {
|
||||
pub type Bar = i32;
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: foo::Bar {
|
||||
const A = 0b00000001,
|
||||
#[cfg(foo)]
|
||||
const B = 0b00000010,
|
||||
#[cfg(foo)]
|
||||
const C = 0b00000010,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: u32 {
|
||||
const A = 0b00000001,
|
||||
#[doc = "bar"]
|
||||
const B = 0b00000010,
|
||||
const C = 0b00000100,
|
||||
#[doc = "foo"]
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
assert_eq!(ABC, A | B | C);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#![allow(dead_code)]
|
||||
#![no_std]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: u32 {
|
||||
const A = 0b00000001,
|
||||
#[doc = "bar"]
|
||||
const B = 0b00000010,
|
||||
const C = 0b00000100,
|
||||
#[doc = "foo"]
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
assert_eq!(ABC, A | B | C);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#![allow(dead_code, unused_imports)]
|
||||
#![cfg_attr(feature = "i128", feature(i128_type))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags128: u128 {
|
||||
const A = 0x0000_0000_0000_0000_0000_0000_0000_0001,
|
||||
const B = 0x0000_0000_0000_1000_0000_0000_0000_0000,
|
||||
const C = 0x8000_0000_0000_0000_0000_0000_0000_0000,
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
#[test]
|
||||
fn test_i128_bitflags() {
|
||||
assert_eq!(ABC, A | B | C);
|
||||
assert_eq!(A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
|
||||
assert_eq!(B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
|
||||
assert_eq!(C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
|
||||
assert_eq!(ABC.bits, 0x8000_0000_0000_1000_0000_0000_0000_0001);
|
||||
assert_eq!(format!("{:?}", A), "A");
|
||||
assert_eq!(format!("{:?}", B), "B");
|
||||
assert_eq!(format!("{:?}", C), "C");
|
||||
assert_eq!(format!("{:?}", ABC), "A | B | C | ABC");
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"793de473e858941a0d41e0c4e114373bca6b822737cdcf5ff8f36238a9b51837","Cargo.toml":"98d1298b1d79ccc587957062cf1c56712f68ee2796bed5f39c8d334133d9c562","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"1cce1c9c1fe2cf40ec1c6a0384f8cc2f0c5c40ece4acfedd64330ed95ef74e44","src/lib.rs":"006a631d800f713e2ffc74e33f65fd47505eec1b047c109e180905a9dcb7e973","tests/external.rs":"546e549ec831876a5dc272bd0537adc9e9886c6da54656c825e7bffc079e2c74","tests/external_no_std.rs":"48929f5109aabc156442d5ae2ab07b4bce5d648488bf49dba725f6ab23bcb48a","tests/i128_bitflags.rs":"fb1bf9e01f528478539c52de94e82a96b2639dc271ea242fea6ebb32dcb0f99e"},"package":"1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"e7a77c1800f9852e4c9a2acb9df041773ecd0bc005bd1b0657ae0512c67100ac","Cargo.toml":"f35826eec96c765ae8aee4f8a66c6b3cb0d918b49935baf05bae79b6df8e1077","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"602c63819e332e93c85dc8426db4855f18fe0fabbd642c5b2303ed83f1ba926f","src/example_generated.rs":"161b69d92cf6e5fa4b5dc30f06031f3a0fb590b44be2bcf0f31cb8be4fab36fa","src/lib.rs":"56e86a16356d9322fa6b4e9b910041e2e7558c08b52ffbdacc647eba36b37abc","tests/conflicting_trait_impls.rs":"79993ea67ef09a5f99fddd69d8b73b1c137e41d0e8f8535f03865d6766dcc498","tests/external.rs":"15f7901698e286197666ccd309ad1debd3c35eaff680ca090368494e8b06ccf2","tests/external_no_std.rs":"c3556fd19dd91d1b093eb6a65d09a9d0985544f0377ba3d30c0e265c956f7237","tests/i128_bitflags.rs":"c955ef2c9fd385848195bb416e660e946ccbe59acc87862ef2646eb082d82e3f"},"package":"4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"}
|
|
@ -1,3 +1,6 @@
|
|||
os:
|
||||
- linux
|
||||
- osx
|
||||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
|
@ -5,7 +8,8 @@ rust:
|
|||
- nightly
|
||||
sudo: false
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
- pip install -v 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
- if [[ -e ~/Library/Python/2.7/bin ]]; then export PATH=~/Library/Python/2.7/bin:$PATH; fi
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- cargo test --verbose
|
||||
|
@ -15,7 +19,8 @@ after_success:
|
|||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: "DoZ8g8iPs+X3xEEucke0Ae02JbkQ1qd1SSv/L2aQqxULmREtRcbzRauhiT+ToQO5Ft1Lul8uck14nPfs4gMr/O3jFFBhEBVpSlbkJx7eNL3kwUdp95UNroA8I43xPN/nccJaHDN6TMTD3+uajTQTje2SyzOQP+1gvdKg17kguvE="
|
||||
- TRAVIS_CARGO_NIGHTLY_FEATURE=unstable_testing
|
||||
- secure: "DoZ8g8iPs+X3xEEucke0Ae02JbkQ1qd1SSv/L2aQqxULmREtRcbzRauhiT+ToQO5Ft1Lul8uck14nPfs4gMr/O3jFFBhEBVpSlbkJx7eNL3kwUdp95UNroA8I43xPN/nccJaHDN6TMTD3+uajTQTje2SyzOQP+1gvdKg17kguvE="
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,31 @@
|
|||
[package]
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "bitflags"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
authors = ["The Rust Project Developers"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A macro to generate structures which behave like bitflags.\n"
|
||||
homepage = "https://github.com/rust-lang-nursery/bitflags"
|
||||
documentation = "https://docs.rs/bitflags"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/rust-lang/bitflags"
|
||||
homepage = "https://github.com/rust-lang/bitflags"
|
||||
documentation = "https://doc.rust-lang.org/bitflags"
|
||||
description = """
|
||||
A macro to generate structures which behave like bitflags.
|
||||
"""
|
||||
keywords = ["bit", "bitmask", "bitflags"]
|
||||
categories = ["no-std"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/rust-lang-nursery/bitflags"
|
||||
|
||||
[features]
|
||||
i128 = []
|
||||
unstable = ["i128"]
|
||||
example_generated = []
|
||||
unstable_testing = []
|
||||
default = ["example_generated"]
|
||||
[badges.travis-ci]
|
||||
repository = "rust-lang-nursery/bitflags"
|
||||
|
|
|
@ -5,7 +5,7 @@ A Rust macro to generate structures which behave like a set of bitflags
|
|||
|
||||
[![Build Status](https://travis-ci.org/rust-lang-nursery/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/bitflags)
|
||||
|
||||
[Documentation](https://doc.rust-lang.org/bitflags)
|
||||
[Documentation](https://docs.rs/bitflags)
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -13,7 +13,7 @@ Add this to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
bitflags = "0.7"
|
||||
bitflags = "0.9"
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
@ -22,22 +22,3 @@ and this to your crate root:
|
|||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
```
|
||||
|
||||
## 128-bit integer bitflags (nightly only)
|
||||
|
||||
Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies.bitflags]
|
||||
version = "0.7"
|
||||
features = ["i128"]
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
||||
```rust
|
||||
#![feature(i128_type)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
```
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS
|
||||
//! CRATE**.
|
||||
|
||||
bitflags! {
|
||||
/// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
|
||||
/// Note that this struct is just for documentation purposes only, it must not be used outside
|
||||
/// this crate.
|
||||
pub struct Flags: u32 {
|
||||
const FLAG_A = 0b00000001;
|
||||
const FLAG_B = 0b00000010;
|
||||
const FLAG_C = 0b00000100;
|
||||
const FLAG_ABC = FLAG_A.bits
|
||||
| FLAG_B.bits
|
||||
| FLAG_C.bits;
|
||||
}
|
||||
}
|
|
@ -8,12 +8,217 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! A typesafe bitmask flag generator.
|
||||
//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags.
|
||||
//! It can be used for creating typesafe wrappers around C APIs.
|
||||
//!
|
||||
//! The `bitflags!` macro generates a `struct` that manages a set of flags. The
|
||||
//! flags should only be defined for integer types, otherwise unexpected type
|
||||
//! errors may occur at compile time.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate bitflags;
|
||||
//!
|
||||
//! bitflags! {
|
||||
//! struct Flags: u32 {
|
||||
//! const FLAG_A = 0b00000001;
|
||||
//! const FLAG_B = 0b00000010;
|
||||
//! const FLAG_C = 0b00000100;
|
||||
//! const FLAG_ABC = FLAG_A.bits
|
||||
//! | FLAG_B.bits
|
||||
//! | FLAG_C.bits;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let e1 = FLAG_A | FLAG_C;
|
||||
//! let e2 = FLAG_B | FLAG_C;
|
||||
//! assert_eq!((e1 | e2), FLAG_ABC); // union
|
||||
//! assert_eq!((e1 & e2), FLAG_C); // intersection
|
||||
//! assert_eq!((e1 - e2), FLAG_A); // set difference
|
||||
//! assert_eq!(!e2, FLAG_A); // set complement
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code
|
||||
//! generated by the above `bitflags!` expansion.
|
||||
//!
|
||||
//! The generated `struct`s can also be extended with type and trait
|
||||
//! implementations:
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate bitflags;
|
||||
//!
|
||||
//! use std::fmt;
|
||||
//!
|
||||
//! bitflags! {
|
||||
//! struct Flags: u32 {
|
||||
//! const FLAG_A = 0b00000001;
|
||||
//! const FLAG_B = 0b00000010;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! impl Flags {
|
||||
//! pub fn clear(&mut self) {
|
||||
//! self.bits = 0; // The `bits` field can be accessed from within the
|
||||
//! // same module where the `bitflags!` macro was invoked.
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! impl fmt::Display for Flags {
|
||||
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
//! write!(f, "hi!")
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let mut flags = FLAG_A | FLAG_B;
|
||||
//! flags.clear();
|
||||
//! assert!(flags.is_empty());
|
||||
//! assert_eq!(format!("{}", flags), "hi!");
|
||||
//! assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
|
||||
//! assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Visibility
|
||||
//!
|
||||
//! The generated struct and its associated flag constants are not exported
|
||||
//! out of the current module by default. A definition can be exported out of
|
||||
//! the current module by adding `pub` before `flags`:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! #[macro_use]
|
||||
//! extern crate bitflags;
|
||||
//!
|
||||
//! mod example {
|
||||
//! bitflags! {
|
||||
//! pub struct Flags1: u32 {
|
||||
//! const FLAG_A = 0b00000001;
|
||||
//! }
|
||||
//! }
|
||||
//! bitflags! {
|
||||
//! struct Flags2: u32 {
|
||||
//! const FLAG_B = 0b00000010;
|
||||
//! }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let flag1 = example::FLAG_A;
|
||||
//! let flag2 = example::FLAG_B; // error: const `FLAG_B` is private
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Attributes
|
||||
//!
|
||||
//! Attributes can be attached to the generated `struct` by placing them
|
||||
//! before the `flags` keyword.
|
||||
//!
|
||||
//! # Trait implementations
|
||||
//!
|
||||
//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash`
|
||||
//! traits automatically derived for the `struct` using the `derive` attribute.
|
||||
//! Additional traits can be derived by providing an explicit `derive`
|
||||
//! attribute on `flags`.
|
||||
//!
|
||||
//! The `Extend` and `FromIterator` traits are implemented for the `struct`,
|
||||
//! too: `Extend` adds the union of the instances of the `struct` iterated over,
|
||||
//! while `FromIterator` calculates the union.
|
||||
//!
|
||||
//! The `Binary`, `Debug`, `LowerExp`, `Octal` and `UpperExp` trait is also
|
||||
//! implemented by displaying the bits value of the internal struct.
|
||||
//!
|
||||
//! ## Operators
|
||||
//!
|
||||
//! The following operator traits are implemented for the generated `struct`:
|
||||
//!
|
||||
//! - `BitOr` and `BitOrAssign`: union
|
||||
//! - `BitAnd` and `BitAndAssign`: intersection
|
||||
//! - `BitXor` and `BitXorAssign`: toggle
|
||||
//! - `Sub` and `SubAssign`: set difference
|
||||
//! - `Not`: set complement
|
||||
//!
|
||||
//! # Methods
|
||||
//!
|
||||
//! The following methods are defined for the generated `struct`:
|
||||
//!
|
||||
//! - `empty`: an empty set of flags
|
||||
//! - `all`: the set of all flags
|
||||
//! - `bits`: the raw value of the flags currently stored
|
||||
//! - `from_bits`: convert from underlying bit representation, unless that
|
||||
//! representation contains bits that do not correspond to a flag
|
||||
//! - `from_bits_truncate`: convert from underlying bit representation, dropping
|
||||
//! any bits that do not correspond to flags
|
||||
//! - `is_empty`: `true` if no flags are currently stored
|
||||
//! - `is_all`: `true` if all flags are currently set
|
||||
//! - `intersects`: `true` if there are flags common to both `self` and `other`
|
||||
//! - `contains`: `true` all of the flags in `other` are contained within `self`
|
||||
//! - `insert`: inserts the specified flags in-place
|
||||
//! - `remove`: removes the specified flags in-place
|
||||
//! - `toggle`: the specified flags will be inserted if not present, and removed
|
||||
//! if they are.
|
||||
//!
|
||||
//! ## Default
|
||||
//!
|
||||
//! The `Default` trait is not automatically implemented for the generated struct.
|
||||
//!
|
||||
//! If your default value is equal to `0` (which is the same value as calling `empty()`
|
||||
//! on the generated struct), you can simply derive `Default`:
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate bitflags;
|
||||
//!
|
||||
//! bitflags! {
|
||||
//! // Results in default value with bits: 0
|
||||
//! #[derive(Default)]
|
||||
//! struct Flags: u32 {
|
||||
//! const FLAG_A = 0b00000001;
|
||||
//! const FLAG_B = 0b00000010;
|
||||
//! const FLAG_C = 0b00000100;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let derived_default: Flags = Default::default();
|
||||
//! assert_eq!(derived_default.bits(), 0);
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! If your default value is not equal to `0` you need to implement `Default` yourself:
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate bitflags;
|
||||
//!
|
||||
//! bitflags! {
|
||||
//! struct Flags: u32 {
|
||||
//! const FLAG_A = 0b00000001;
|
||||
//! const FLAG_B = 0b00000010;
|
||||
//! const FLAG_C = 0b00000100;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! // explicit `Default` implementation
|
||||
//! impl Default for Flags {
|
||||
//! fn default() -> Flags {
|
||||
//! FLAG_A | FLAG_C
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let implemented_default: Flags = Default::default();
|
||||
//! assert_eq!(implemented_default, (FLAG_A | FLAG_C));
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
#![no_std]
|
||||
|
||||
#![cfg_attr(feature = "i128", feature(i128_type))]
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/bitflags/0.9.1")]
|
||||
// When compiled for the rustc compiler itself we want to make sure that this is
|
||||
// an unstable crate.
|
||||
#![cfg_attr(rustbuild, feature(staged_api))]
|
||||
|
@ -25,35 +230,27 @@ extern crate std;
|
|||
|
||||
// Re-export libstd/libcore using an alias so that the macros can work in no_std
|
||||
// crates while remaining compatible with normal crates.
|
||||
#[allow(private_in_public)]
|
||||
#[doc(hidden)]
|
||||
pub use core as __core;
|
||||
pub extern crate core as _core;
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
pub type __BitFlagsWidth = u128;
|
||||
#[cfg(not(feature = "i128"))]
|
||||
pub type __BitFlagsWidth = u64;
|
||||
|
||||
/// The `bitflags!` macro generates a `struct` that holds a set of C-style
|
||||
/// bitmask flags. It is useful for creating typesafe wrappers for C APIs.
|
||||
/// The macro used to generate the flag structure.
|
||||
///
|
||||
/// The flags should only be defined for integer types, otherwise unexpected
|
||||
/// type errors may occur at compile time.
|
||||
/// See the [crate level docs](../bitflags/index.html) for complete documentation.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```{.rust}
|
||||
/// ```
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// bitflags! {
|
||||
/// flags Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// const FLAG_C = 0b00000100,
|
||||
/// struct Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001;
|
||||
/// const FLAG_B = 0b00000010;
|
||||
/// const FLAG_C = 0b00000100;
|
||||
/// const FLAG_ABC = FLAG_A.bits
|
||||
/// | FLAG_B.bits
|
||||
/// | FLAG_C.bits,
|
||||
/// | FLAG_C.bits;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
|
@ -70,16 +267,16 @@ pub type __BitFlagsWidth = u64;
|
|||
/// The generated `struct`s can also be extended with type and trait
|
||||
/// implementations:
|
||||
///
|
||||
/// ```{.rust}
|
||||
/// ```
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// use std::fmt;
|
||||
///
|
||||
/// bitflags! {
|
||||
/// flags Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// struct Flags: u32 {
|
||||
/// const FLAG_A = 0b00000001;
|
||||
/// const FLAG_B = 0b00000010;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
|
@ -105,91 +302,10 @@ pub type __BitFlagsWidth = u64;
|
|||
/// assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Visibility
|
||||
///
|
||||
/// The generated struct and its associated flag constants are not exported
|
||||
/// out of the current module by default. A definition can be exported out of
|
||||
/// the current module by adding `pub` before `flags`:
|
||||
///
|
||||
/// ```{.rust},ignore
|
||||
/// #[macro_use]
|
||||
/// extern crate bitflags;
|
||||
///
|
||||
/// mod example {
|
||||
/// bitflags! {
|
||||
/// pub flags Flags1: u32 {
|
||||
/// const FLAG_A = 0b00000001,
|
||||
/// }
|
||||
/// }
|
||||
/// bitflags! {
|
||||
/// flags Flags2: u32 {
|
||||
/// const FLAG_B = 0b00000010,
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let flag1 = example::FLAG_A;
|
||||
/// let flag2 = example::FLAG_B; // error: const `FLAG_B` is private
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Attributes
|
||||
///
|
||||
/// Attributes can be attached to the generated `struct` by placing them
|
||||
/// before the `flags` keyword.
|
||||
///
|
||||
/// # Trait implementations
|
||||
///
|
||||
/// The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash`
|
||||
/// traits automatically derived for the `struct` using the `derive` attribute.
|
||||
/// Additional traits can be derived by providing an explicit `derive`
|
||||
/// attribute on `flags`.
|
||||
///
|
||||
/// The `Extend` and `FromIterator` traits are implemented for the `struct`,
|
||||
/// too: `Extend` adds the union of the instances of the `struct` iterated over,
|
||||
/// while `FromIterator` calculates the union.
|
||||
///
|
||||
/// The `Debug` trait is also implemented by displaying the bits value of the
|
||||
/// internal struct.
|
||||
///
|
||||
/// ## Operators
|
||||
///
|
||||
/// The following operator traits are implemented for the generated `struct`:
|
||||
///
|
||||
/// - `BitOr` and `BitOrAssign`: union
|
||||
/// - `BitAnd` and `BitAndAssign`: intersection
|
||||
/// - `BitXor` and `BitXorAssign`: toggle
|
||||
/// - `Sub` and `SubAssign`: set difference
|
||||
/// - `Not`: set complement
|
||||
///
|
||||
/// As long as the assignment operators are unstable rust feature they are only
|
||||
/// available with the crate feature `assignment_ops` enabled.
|
||||
///
|
||||
/// # Methods
|
||||
///
|
||||
/// The following methods are defined for the generated `struct`:
|
||||
///
|
||||
/// - `empty`: an empty set of flags
|
||||
/// - `all`: the set of all flags
|
||||
/// - `bits`: the raw value of the flags currently stored
|
||||
/// - `from_bits`: convert from underlying bit representation, unless that
|
||||
/// representation contains bits that do not correspond to a flag
|
||||
/// - `from_bits_truncate`: convert from underlying bit representation, dropping
|
||||
/// any bits that do not correspond to flags
|
||||
/// - `is_empty`: `true` if no flags are currently stored
|
||||
/// - `is_all`: `true` if all flags are currently set
|
||||
/// - `intersects`: `true` if there are flags common to both `self` and `other`
|
||||
/// - `contains`: `true` all of the flags in `other` are contained within `self`
|
||||
/// - `insert`: inserts the specified flags in-place
|
||||
/// - `remove`: removes the specified flags in-place
|
||||
/// - `toggle`: the specified flags will be inserted if not present, and removed
|
||||
/// if they are.
|
||||
#[macro_export]
|
||||
macro_rules! bitflags {
|
||||
($(#[$attr:meta])* pub flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
($(#[$attr:meta])* pub struct $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
|
||||
}) => {
|
||||
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
|
||||
$(#[$attr])*
|
||||
|
@ -199,14 +315,14 @@ macro_rules! bitflags {
|
|||
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+
|
||||
|
||||
bitflags! {
|
||||
@_impl flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
__impl_bitflags! {
|
||||
struct $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value;)+
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
($(#[$attr:meta])* struct $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
|
||||
}) => {
|
||||
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
|
||||
$(#[$attr])*
|
||||
|
@ -216,70 +332,83 @@ macro_rules! bitflags {
|
|||
|
||||
$($(#[$Flag_attr])* const $Flag: $BitFlags = $BitFlags { bits: $value };)+
|
||||
|
||||
bitflags! {
|
||||
@_impl flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
__impl_bitflags! {
|
||||
struct $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value;)+
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
(@_impl flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __impl_bitflags {
|
||||
(struct $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
|
||||
}) => {
|
||||
impl $crate::__core::fmt::Debug for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::__core::fmt::Formatter) -> $crate::__core::fmt::Result {
|
||||
impl $crate::_core::fmt::Debug for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
|
||||
// This convoluted approach is to handle #[cfg]-based flag
|
||||
// omission correctly. Some of the $Flag variants may not be
|
||||
// defined in this module so we create an inner module which
|
||||
// defines *all* flags to the value of 0. We then create a
|
||||
// second inner module that defines all of the flags with #[cfg]
|
||||
// to their real values. Afterwards the glob will import
|
||||
// variants from the second inner module, shadowing all
|
||||
// defined variants, leaving only the undefined ones with the
|
||||
// bit value of 0.
|
||||
#[allow(dead_code)]
|
||||
#[allow(unused_assignments)]
|
||||
mod dummy {
|
||||
// We can't use the real $BitFlags struct because it may be
|
||||
// private, which prevents us from using it to define
|
||||
// public constants.
|
||||
pub struct $BitFlags {
|
||||
bits: $crate::__BitFlagsWidth,
|
||||
}
|
||||
mod real_flags {
|
||||
use super::$BitFlags;
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags {
|
||||
bits: super::super::$Flag.bits as $crate::__BitFlagsWidth
|
||||
};)+
|
||||
}
|
||||
// Now we define the "undefined" versions of the flags.
|
||||
// This way, all the names exist, even if some are #[cfg]ed
|
||||
// out.
|
||||
$(const $Flag: $BitFlags = $BitFlags { bits: 0 };)+
|
||||
// omission correctly. For example it needs to support:
|
||||
//
|
||||
// #[cfg(unix)] const A: Flag = /* ... */;
|
||||
// #[cfg(windows)] const B: Flag = /* ... */;
|
||||
|
||||
#[inline]
|
||||
pub fn fmt(self_: $crate::__BitFlagsWidth,
|
||||
f: &mut $crate::__core::fmt::Formatter)
|
||||
-> $crate::__core::fmt::Result {
|
||||
// Now we import the real values for the flags.
|
||||
// Only ones that are #[cfg]ed out will be 0.
|
||||
use self::real_flags::*;
|
||||
|
||||
let mut first = true;
|
||||
$(
|
||||
// $Flag.bits == 0 means that $Flag doesn't exist
|
||||
if $Flag.bits != 0 && self_ & $Flag.bits as $crate::__BitFlagsWidth ==
|
||||
$Flag.bits as $crate::__BitFlagsWidth {
|
||||
if !first {
|
||||
try!(f.write_str(" | "));
|
||||
}
|
||||
first = false;
|
||||
try!(f.write_str(stringify!($Flag)));
|
||||
}
|
||||
)+
|
||||
Ok(())
|
||||
}
|
||||
// Unconditionally define a check for every flag, even disabled
|
||||
// ones.
|
||||
#[allow(non_snake_case)]
|
||||
trait __BitFlags {
|
||||
$(
|
||||
fn $Flag(&self) -> bool { false }
|
||||
)+
|
||||
}
|
||||
dummy::fmt(self.bits as $crate::__BitFlagsWidth, f)
|
||||
|
||||
// Conditionally override the check for just those flags that
|
||||
// are not #[cfg]ed away.
|
||||
impl __BitFlags for $BitFlags {
|
||||
$(
|
||||
$(#[$Flag_attr])*
|
||||
fn $Flag(&self) -> bool {
|
||||
self.bits & $Flag.bits == $Flag.bits
|
||||
}
|
||||
)+
|
||||
}
|
||||
|
||||
let mut first = true;
|
||||
$(
|
||||
if <$BitFlags as __BitFlags>::$Flag(self) {
|
||||
if !first {
|
||||
try!(f.write_str(" | "));
|
||||
}
|
||||
first = false;
|
||||
try!(f.write_str(stringify!($Flag)));
|
||||
}
|
||||
)+
|
||||
if first {
|
||||
try!(f.write_str("(empty)"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
impl $crate::_core::fmt::Binary for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
|
||||
$crate::_core::fmt::Binary::fmt(&self.bits, f)
|
||||
}
|
||||
}
|
||||
impl $crate::_core::fmt::Octal for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
|
||||
$crate::_core::fmt::Octal::fmt(&self.bits, f)
|
||||
}
|
||||
}
|
||||
impl $crate::_core::fmt::LowerHex for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
|
||||
$crate::_core::fmt::LowerHex::fmt(&self.bits, f)
|
||||
}
|
||||
}
|
||||
impl $crate::_core::fmt::UpperHex for $BitFlags {
|
||||
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
|
||||
$crate::_core::fmt::UpperHex::fmt(&self.bits, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,27 +423,20 @@ macro_rules! bitflags {
|
|||
/// Returns the set containing all flags.
|
||||
#[inline]
|
||||
pub fn all() -> $BitFlags {
|
||||
// See above `dummy` module for why this approach is taken.
|
||||
#[allow(dead_code)]
|
||||
mod dummy {
|
||||
pub struct $BitFlags {
|
||||
bits: $crate::__BitFlagsWidth,
|
||||
}
|
||||
mod real_flags {
|
||||
use super::$BitFlags;
|
||||
$($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags {
|
||||
bits: super::super::$Flag.bits as $crate::__BitFlagsWidth
|
||||
};)+
|
||||
}
|
||||
$(const $Flag: $BitFlags = $BitFlags { bits: 0 };)+
|
||||
|
||||
#[inline]
|
||||
pub fn all() -> $crate::__BitFlagsWidth {
|
||||
use self::real_flags::*;
|
||||
$($Flag.bits)|+
|
||||
}
|
||||
// See `Debug::fmt` for why this approach is taken.
|
||||
#[allow(non_snake_case)]
|
||||
trait __BitFlags {
|
||||
$(
|
||||
fn $Flag() -> $T { 0 }
|
||||
)+
|
||||
}
|
||||
$BitFlags { bits: dummy::all() as $T }
|
||||
impl __BitFlags for $BitFlags {
|
||||
$(
|
||||
$(#[$Flag_attr])*
|
||||
fn $Flag() -> $T { $Flag.bits }
|
||||
)+
|
||||
}
|
||||
$BitFlags { bits: $(<$BitFlags as __BitFlags>::$Flag())|+ }
|
||||
}
|
||||
|
||||
/// Returns the raw value of the flags currently stored.
|
||||
|
@ -326,11 +448,11 @@ macro_rules! bitflags {
|
|||
/// Convert from underlying bit representation, unless that
|
||||
/// representation contains bits that do not correspond to a flag.
|
||||
#[inline]
|
||||
pub fn from_bits(bits: $T) -> $crate::__core::option::Option<$BitFlags> {
|
||||
pub fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> {
|
||||
if (bits & !$BitFlags::all().bits()) == 0 {
|
||||
$crate::__core::option::Option::Some($BitFlags { bits: bits })
|
||||
$crate::_core::option::Option::Some($BitFlags { bits: bits })
|
||||
} else {
|
||||
$crate::__core::option::Option::None
|
||||
$crate::_core::option::Option::None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,7 +516,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitOr for $BitFlags {
|
||||
impl $crate::_core::ops::BitOr for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the union of the two sets of flags.
|
||||
|
@ -404,7 +526,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitOrAssign for $BitFlags {
|
||||
impl $crate::_core::ops::BitOrAssign for $BitFlags {
|
||||
|
||||
/// Adds the set of flags.
|
||||
#[inline]
|
||||
|
@ -413,7 +535,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitXor for $BitFlags {
|
||||
impl $crate::_core::ops::BitXor for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the left flags, but with all the right flags toggled.
|
||||
|
@ -423,7 +545,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitXorAssign for $BitFlags {
|
||||
impl $crate::_core::ops::BitXorAssign for $BitFlags {
|
||||
|
||||
/// Toggles the set of flags.
|
||||
#[inline]
|
||||
|
@ -432,7 +554,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitAnd for $BitFlags {
|
||||
impl $crate::_core::ops::BitAnd for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the intersection between the two sets of flags.
|
||||
|
@ -442,7 +564,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::BitAndAssign for $BitFlags {
|
||||
impl $crate::_core::ops::BitAndAssign for $BitFlags {
|
||||
|
||||
/// Disables all flags disabled in the set.
|
||||
#[inline]
|
||||
|
@ -451,7 +573,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::Sub for $BitFlags {
|
||||
impl $crate::_core::ops::Sub for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the set difference of the two sets of flags.
|
||||
|
@ -461,7 +583,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::SubAssign for $BitFlags {
|
||||
impl $crate::_core::ops::SubAssign for $BitFlags {
|
||||
|
||||
/// Disables all flags enabled in the set.
|
||||
#[inline]
|
||||
|
@ -470,7 +592,7 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::ops::Not for $BitFlags {
|
||||
impl $crate::_core::ops::Not for $BitFlags {
|
||||
type Output = $BitFlags;
|
||||
|
||||
/// Returns the complement of this set of flags.
|
||||
|
@ -480,82 +602,72 @@ macro_rules! bitflags {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::iter::Extend<$BitFlags> for $BitFlags {
|
||||
fn extend<T: $crate::__core::iter::IntoIterator<Item=$BitFlags>>(&mut self, iterator: T) {
|
||||
impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags {
|
||||
fn extend<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(&mut self, iterator: T) {
|
||||
for item in iterator {
|
||||
self.insert(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::__core::iter::FromIterator<$BitFlags> for $BitFlags {
|
||||
fn from_iter<T: $crate::__core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
|
||||
impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags {
|
||||
fn from_iter<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
|
||||
let mut result = Self::empty();
|
||||
result.extend(iterator);
|
||||
result
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* pub flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+,
|
||||
}) => {
|
||||
bitflags! {
|
||||
$(#[$attr])*
|
||||
pub flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
|
||||
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+,
|
||||
}) => {
|
||||
bitflags! {
|
||||
$(#[$attr])*
|
||||
flags $BitFlags: $T {
|
||||
$($(#[$Flag_attr])* const $Flag = $value),+
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "example_generated")]
|
||||
pub mod example_generated;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(non_upper_case_globals, dead_code)]
|
||||
mod tests {
|
||||
use std::hash::{SipHasher, Hash, Hasher};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
|
||||
bitflags! {
|
||||
#[doc = "> The first principle is that you must not fool yourself — and"]
|
||||
#[doc = "> you are the easiest person to fool."]
|
||||
#[doc = "> "]
|
||||
#[doc = "> - Richard Feynman"]
|
||||
flags Flags: u32 {
|
||||
const FlagA = 0b00000001,
|
||||
struct Flags: u32 {
|
||||
const FlagA = 0b00000001;
|
||||
#[doc = "<pcwalton> macros are way better at generating code than trans is"]
|
||||
const FlagB = 0b00000010,
|
||||
const FlagC = 0b00000100,
|
||||
const FlagB = 0b00000010;
|
||||
const FlagC = 0b00000100;
|
||||
#[doc = "* cmr bed"]
|
||||
#[doc = "* strcat table"]
|
||||
#[doc = "<strcat> wait what?"]
|
||||
const FlagABC = FlagA.bits
|
||||
| FlagB.bits
|
||||
| FlagC.bits,
|
||||
| FlagC.bits;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
flags _CfgFlags: u32 {
|
||||
struct _CfgFlags: u32 {
|
||||
#[cfg(windows)]
|
||||
const _CfgA = 0b01,
|
||||
const _CfgA = 0b01;
|
||||
#[cfg(unix)]
|
||||
const _CfgB = 0b01,
|
||||
const _CfgB = 0b01;
|
||||
#[cfg(windows)]
|
||||
const _CfgC = _CfgA.bits | 0b10,
|
||||
const _CfgC = _CfgA.bits | 0b10;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
flags AnotherSetOfFlags: i8 {
|
||||
const AnotherFlag = -1_i8,
|
||||
struct AnotherSetOfFlags: i8 {
|
||||
const AnotherFlag = -1_i8;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
struct LongFlags: u32 {
|
||||
const LongFlagA = 0b1111111111111111;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -777,7 +889,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn hash<T: Hash>(t: &T) -> u64 {
|
||||
let mut s = SipHasher::new_with_keys(0, 0);
|
||||
let mut s = DefaultHasher::new();
|
||||
t.hash(&mut s);
|
||||
s.finish()
|
||||
}
|
||||
|
@ -795,18 +907,43 @@ mod tests {
|
|||
#[test]
|
||||
fn test_debug() {
|
||||
assert_eq!(format!("{:?}", FlagA | FlagB), "FlagA | FlagB");
|
||||
assert_eq!(format!("{:?}", Flags::empty()), "(empty)");
|
||||
assert_eq!(format!("{:?}", FlagABC), "FlagA | FlagB | FlagC | FlagABC");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_binary() {
|
||||
assert_eq!(format!("{:b}", FlagABC), "111");
|
||||
assert_eq!(format!("{:#b}", FlagABC), "0b111");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_octal() {
|
||||
assert_eq!(format!("{:o}", LongFlagA), "177777");
|
||||
assert_eq!(format!("{:#o}", LongFlagA), "0o177777");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lowerhex() {
|
||||
assert_eq!(format!("{:x}", LongFlagA), "ffff");
|
||||
assert_eq!(format!("{:#x}", LongFlagA), "0xffff");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_upperhex() {
|
||||
assert_eq!(format!("{:X}", LongFlagA), "FFFF");
|
||||
assert_eq!(format!("{:#X}", LongFlagA), "0xFFFF");
|
||||
}
|
||||
|
||||
mod submodule {
|
||||
bitflags! {
|
||||
pub flags PublicFlags: i8 {
|
||||
const FlagX = 0,
|
||||
pub struct PublicFlags: i8 {
|
||||
const FlagX = 0;
|
||||
}
|
||||
}
|
||||
bitflags! {
|
||||
flags PrivateFlags: i8 {
|
||||
const FlagY = 0,
|
||||
struct PrivateFlags: i8 {
|
||||
const FlagY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -828,13 +965,26 @@ mod tests {
|
|||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: foo::Bar {
|
||||
const A = 0b00000001,
|
||||
struct Flags: foo::Bar {
|
||||
const A = 0b00000001;
|
||||
#[cfg(foo)]
|
||||
const B = 0b00000010,
|
||||
const B = 0b00000010;
|
||||
#[cfg(foo)]
|
||||
const C = 0b00000010,
|
||||
const C = 0b00000010;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_in_function() {
|
||||
bitflags! {
|
||||
struct Flags: u8 {
|
||||
const A = 1;
|
||||
#[cfg(any())] // false
|
||||
const B = 2;
|
||||
}
|
||||
}
|
||||
assert_eq!(Flags::all(), A);
|
||||
assert_eq!(format!("{:?}", A), "A");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#![allow(dead_code)]
|
||||
#![no_std]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use core::fmt::Display;
|
||||
|
||||
bitflags! {
|
||||
/// baz
|
||||
struct Flags: u32 {
|
||||
const A = 0b00000001;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn main() {
|
||||
|
||||
}
|
|
@ -5,13 +5,13 @@ extern crate bitflags;
|
|||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: u32 {
|
||||
const A = 0b00000001,
|
||||
struct Flags: u32 {
|
||||
const A = 0b00000001;
|
||||
#[doc = "bar"]
|
||||
const B = 0b00000010,
|
||||
const C = 0b00000100,
|
||||
const B = 0b00000010;
|
||||
const C = 0b00000100;
|
||||
#[doc = "foo"]
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
const ABC = A.bits | B.bits | C.bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ extern crate bitflags;
|
|||
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags: u32 {
|
||||
const A = 0b00000001,
|
||||
struct Flags: u32 {
|
||||
const A = 0b00000001;
|
||||
#[doc = "bar"]
|
||||
const B = 0b00000010,
|
||||
const C = 0b00000100,
|
||||
const B = 0b00000010;
|
||||
const C = 0b00000100;
|
||||
#[doc = "foo"]
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
const ABC = A.bits | B.bits | C.bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
#![cfg(feature = "unstable_testing")]
|
||||
|
||||
#![allow(dead_code, unused_imports)]
|
||||
#![cfg_attr(feature = "i128", feature(i128_type))]
|
||||
#![feature(i128_type)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
bitflags! {
|
||||
/// baz
|
||||
flags Flags128: u128 {
|
||||
const A = 0x0000_0000_0000_0000_0000_0000_0000_0001,
|
||||
const B = 0x0000_0000_0000_1000_0000_0000_0000_0000,
|
||||
const C = 0x8000_0000_0000_0000_0000_0000_0000_0000,
|
||||
const ABC = A.bits | B.bits | C.bits,
|
||||
struct Flags128: u128 {
|
||||
const A = 0x0000_0000_0000_0000_0000_0000_0000_0001;
|
||||
const B = 0x0000_0000_0000_1000_0000_0000_0000_0000;
|
||||
const C = 0x8000_0000_0000_0000_0000_0000_0000_0000;
|
||||
const ABC = A.bits | B.bits | C.bits;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "i128")]
|
||||
#[test]
|
||||
fn test_i128_bitflags() {
|
||||
assert_eq!(ABC, A | B | C);
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"07a831442ac5cc809c77c9d80a31b7c7cd023f439f924257be2caf5d5d005f4c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"c45bf95ecb4961e085f5bd4b81f0365f15a99896bb889ab9706f56f613978da4","src/font_collection.rs":"d4ca7f741fd54b4b22b823833dfa1f1ccd78a26cf112119ae992572835e48df6","src/font_descriptor.rs":"42be4c958abef1dc914c2815193862e56a23729fe7df7e1483b1b32330d1b7bb","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"b1fc720a9ab7ae4f054f0767e05ba5640b2d9fc8c34d05ae04f25b9dd44f6b81"},"package":"7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"9e9639b287ac1c3d14c28a4467d029a9d642f5d996297dc557f6274eaa05a8f3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"d73139838b7dc15319645a3b03bd3692a3b453fcd6304c7ebdeb454166e22db2","src/font_collection.rs":"5a8f5a17aec1dccf858ef1205c21d035fc5a8c7ac8ed7c089896a1f779bef126","src/font_descriptor.rs":"f932e5626ad8f93d88d82ed3bec9b249bdeccf3c44b1d5abfaed91e018e537d9","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"b1fc720a9ab7ae4f054f0767e05ba5640b2d9fc8c34d05ae04f25b9dd44f6b81"},"package":"16ce16d9ed00181016c11ff48e561314bec92bfbce9fe48f319366618d4e5de6"}
|
|
@ -1,30 +1,20 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "core-text"
|
||||
version = "5.0.1"
|
||||
version = "6.1.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.libc]
|
||||
version = "0.2"
|
||||
|
||||
[features]
|
||||
lion = []
|
||||
default = []
|
||||
[target.x86_64-apple-darwin.dependencies.core-graphics]
|
||||
version = "0.8"
|
||||
default = ["mountainlion"]
|
||||
# For OS X 10.7 compat, exclude this feature. It will exclude some things from
|
||||
# the exposed APIs in the crate.
|
||||
mountainlion = []
|
||||
|
||||
[target.x86_64-apple-darwin.dependencies.core-foundation]
|
||||
version = "0.3"
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[target.x86_64-apple-darwin.dependencies]
|
||||
core-foundation = "0.3"
|
||||
core-graphics = "0.8"
|
||||
|
|
|
@ -23,7 +23,7 @@ use core_graphics::context::{CGContext, CGContextRef};
|
|||
use core_graphics::font::{CGGlyph, CGFont, CGFontRef};
|
||||
use core_graphics::geometry::{CGPoint, CGRect, CGSize};
|
||||
|
||||
use libc::{self, size_t};
|
||||
use libc::{self, size_t, c_void};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
|
@ -70,7 +70,7 @@ pub const kCTFontOptionsPreventAutoActivation: CTFontOptions = (1 << 0);
|
|||
pub const kCTFontOptionsPreferSystemFont: CTFontOptions = (1 << 2);
|
||||
|
||||
#[repr(C)]
|
||||
struct __CTFont;
|
||||
pub struct __CTFont(c_void);
|
||||
|
||||
pub type CTFontRef = *const __CTFont;
|
||||
|
||||
|
@ -193,23 +193,31 @@ impl CTFont {
|
|||
|
||||
// Names
|
||||
pub fn family_name(&self) -> String {
|
||||
let value = get_string_by_name_key(self, kCTFontFamilyNameKey);
|
||||
value.expect("Fonts should always have a family name.")
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontFamilyNameKey);
|
||||
value.expect("Fonts should always have a family name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn face_name(&self) -> String {
|
||||
let value = get_string_by_name_key(self, kCTFontSubFamilyNameKey);
|
||||
value.expect("Fonts should always have a face name.")
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontSubFamilyNameKey);
|
||||
value.expect("Fonts should always have a face name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unique_name(&self) -> String {
|
||||
let value = get_string_by_name_key(self, kCTFontUniqueNameKey);
|
||||
value.expect("Fonts should always have a unique name.")
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontUniqueNameKey);
|
||||
value.expect("Fonts should always have a unique name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn postscript_name(&self) -> String {
|
||||
let value = get_string_by_name_key(self, kCTFontPostScriptNameKey);
|
||||
value.expect("Fonts should always have a PostScript name.")
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontPostScriptNameKey);
|
||||
value.expect("Fonts should always have a PostScript name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_traits(&self) -> CTFontTraits {
|
||||
|
@ -307,11 +315,11 @@ impl CTFont {
|
|||
pub fn get_bounding_rects_for_glyphs(&self, orientation: CTFontOrientation, glyphs: &[CGGlyph])
|
||||
-> CGRect {
|
||||
unsafe {
|
||||
let mut result = CTFontGetBoundingRectsForGlyphs(self.as_concrete_TypeRef(),
|
||||
orientation,
|
||||
glyphs.as_ptr(),
|
||||
ptr::null_mut(),
|
||||
glyphs.len() as CFIndex);
|
||||
let result = CTFontGetBoundingRectsForGlyphs(self.as_concrete_TypeRef(),
|
||||
orientation,
|
||||
glyphs.as_ptr(),
|
||||
ptr::null_mut(),
|
||||
glyphs.len() as CFIndex);
|
||||
result
|
||||
}
|
||||
}
|
||||
|
@ -357,12 +365,14 @@ pub fn debug_font_names(font: &CTFont) {
|
|||
get_string_by_name_key(font, key).unwrap()
|
||||
}
|
||||
|
||||
println!("kCTFontFamilyNameKey: {}", get_key(font, kCTFontFamilyNameKey));
|
||||
println!("kCTFontSubFamilyNameKey: {}", get_key(font, kCTFontSubFamilyNameKey));
|
||||
println!("kCTFontStyleNameKey: {}", get_key(font, kCTFontStyleNameKey));
|
||||
println!("kCTFontUniqueNameKey: {}", get_key(font, kCTFontUniqueNameKey));
|
||||
println!("kCTFontFullNameKey: {}", get_key(font, kCTFontFullNameKey));
|
||||
println!("kCTFontPostScriptNameKey: {}", get_key(font, kCTFontPostScriptNameKey));
|
||||
unsafe {
|
||||
println!("kCTFontFamilyNameKey: {}", get_key(font, kCTFontFamilyNameKey));
|
||||
println!("kCTFontSubFamilyNameKey: {}", get_key(font, kCTFontSubFamilyNameKey));
|
||||
println!("kCTFontStyleNameKey: {}", get_key(font, kCTFontStyleNameKey));
|
||||
println!("kCTFontUniqueNameKey: {}", get_key(font, kCTFontUniqueNameKey));
|
||||
println!("kCTFontFullNameKey: {}", get_key(font, kCTFontFullNameKey));
|
||||
println!("kCTFontPostScriptNameKey: {}", get_key(font, kCTFontPostScriptNameKey));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug_font_traits(font: &CTFont) {
|
||||
|
@ -379,7 +389,7 @@ pub fn debug_font_traits(font: &CTFont) {
|
|||
// println!("kCTFontSlantTrait: {}", traits.normalized_slant());
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "lion"))]
|
||||
#[cfg(feature = "mountainlion")]
|
||||
pub fn cascade_list_for_languages(font: &CTFont, language_pref_list: &CFArray) -> CFArray {
|
||||
unsafe {
|
||||
let font_collection_ref =
|
||||
|
@ -464,7 +474,7 @@ extern {
|
|||
fn CTFontCopyName(font: CTFontRef, nameKey: CFStringRef) -> CFStringRef;
|
||||
//fn CTFontCopyLocalizedName(font: CTFontRef, nameKey: CFStringRef,
|
||||
// language: *CFStringRef) -> CFStringRef;
|
||||
#[cfg(not(feature = "lion"))]
|
||||
#[cfg(feature = "mountainlion")]
|
||||
fn CTFontCopyDefaultCascadeListForLanguages(font: CTFontRef, languagePrefList: CFArrayRef) -> CFArrayRef;
|
||||
|
||||
|
||||
|
|
|
@ -18,11 +18,12 @@ use core_foundation::number::CFNumber;
|
|||
use core_foundation::set::CFSet;
|
||||
use core_foundation::string::{CFString, CFStringRef};
|
||||
|
||||
use libc::c_void;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
#[repr(C)]
|
||||
struct __CTFontCollection;
|
||||
pub struct __CTFontCollection(c_void);
|
||||
|
||||
pub type CTFontCollectionRef = *const __CTFontCollection;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use core_foundation::string::{CFString, CFStringRef};
|
|||
use core_foundation::url::{CFURL, CFURLRef};
|
||||
use core_graphics::base::CGFloat;
|
||||
|
||||
use libc::c_void;
|
||||
use std::mem;
|
||||
|
||||
/*
|
||||
|
@ -182,7 +183,7 @@ pub const kCTFontPriorityDynamic: CTFontPriority = 50000;
|
|||
pub const kCTFontPriorityProcess: CTFontPriority = 60000;
|
||||
|
||||
#[repr(C)]
|
||||
struct __CTFontDescriptor;
|
||||
pub struct __CTFontDescriptor(c_void);
|
||||
|
||||
pub type CTFontDescriptorRef = *const __CTFontDescriptor;
|
||||
|
||||
|
@ -252,29 +253,37 @@ impl CTFontDescriptor {
|
|||
|
||||
impl CTFontDescriptor {
|
||||
pub fn family_name(&self) -> String {
|
||||
let value = self.get_string_attribute(kCTFontDisplayNameAttribute);
|
||||
value.expect("A font2 must have a non-null font family name.")
|
||||
unsafe {
|
||||
let value = self.get_string_attribute(kCTFontDisplayNameAttribute);
|
||||
value.expect("A font2 must have a non-null font family name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn font_name(&self) -> String {
|
||||
let value = self.get_string_attribute(kCTFontNameAttribute);
|
||||
value.expect("A font must have a non-null name.")
|
||||
unsafe {
|
||||
let value = self.get_string_attribute(kCTFontNameAttribute);
|
||||
value.expect("A font must have a non-null name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn style_name(&self) -> String {
|
||||
let value = self.get_string_attribute(kCTFontStyleNameAttribute);
|
||||
value.expect("A font must have a non-null style name.")
|
||||
unsafe {
|
||||
let value = self.get_string_attribute(kCTFontStyleNameAttribute);
|
||||
value.expect("A font must have a non-null style name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn display_name(&self) -> String {
|
||||
let value = self.get_string_attribute(kCTFontDisplayNameAttribute);
|
||||
value.expect("A font must have a non-null display name.")
|
||||
unsafe {
|
||||
let value = self.get_string_attribute(kCTFontDisplayNameAttribute);
|
||||
value.expect("A font must have a non-null display name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn font_path(&self) -> Option<String> {
|
||||
unsafe {
|
||||
let value = CTFontDescriptorCopyAttribute(self.obj, kCTFontURLAttribute);
|
||||
if (value.is_null()) {
|
||||
if value.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"56843ecfd2b71797b648b8e537623e84af3c638ea4b8472ed27c55f097bce3dc","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"c46d5e4fd426f8ed307ee11f6b9019537020cb84a52902aa1efd1363d8df0a66","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6cf810ad389c73a27141a7a67454ed12d4b01c3c16605b9a7414b389bc0615dd","src/length.rs":"73b0aed12a0c9acfd77a6b9ac0cd3a7ec522c41ffafad4448753cb6bba47b6a4","src/lib.rs":"4d0961f56e4232ae09b41da4838324af21efc318555f625b4151a81fe99a0217","src/macros.rs":"a3f4deaa4323da6398546720548dda20b0b39427603ccc35ab49d220a83467a8","src/num.rs":"749b201289fc6663199160a2f9204e17925fd3053f8ab7779e7bfb377ad06227","src/point.rs":"b34275cfce38f07158396d35cfd1560a50be2f0683e09b53198e7f55206a6c56","src/rect.rs":"34dfc28c3d83e2d477108b661f9776d8195c3ef6ed2d61ec90fa1e5a2f3775b2","src/scale_factor.rs":"b093243256df3f2b8a2e2bf98236e6ec1032c3d358596f384313614dbefaca49","src/side_offsets.rs":"fd95ffc9a74e9e84314875c388e763d0780486eb7f9034423e3a22048361e379","src/size.rs":"d9a6fb1f080a06e1332b2e804f8334e086e6d6f17a4288f35133d80b2e2da765","src/transform2d.rs":"4fe4fef7266b06b7790cd400d990ad02e6e605499a1a33c8e39b5e00364389ba","src/transform3d.rs":"cd8a08dd341fcea4c5b10e00d029424e382f3b0002dd8341f302be7f1c12c4fc","src/trig.rs":"ef290927af252ca90a29ba9f17158b591ed591604e66cb9df045dd47b9cfdca5","src/vector.rs":"c087700ad35c3e18e0f5722573f6a24ed2b0452e044c1f0bbb6466c993c560f1"},"package":"afc5fcf274fa860e18379115ac336e9b41553f61c9ed34ad09e8101ed3defae2"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"13574ca06216b94913348afb2beae9db9929f8964fbc45b3c00344ee281e1f52","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"931d041ace1a24527525c8aee375fc9b562d372f1d92aabeef0822904068cd77","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6cf810ad389c73a27141a7a67454ed12d4b01c3c16605b9a7414b389bc0615dd","src/length.rs":"73b0aed12a0c9acfd77a6b9ac0cd3a7ec522c41ffafad4448753cb6bba47b6a4","src/lib.rs":"4d0961f56e4232ae09b41da4838324af21efc318555f625b4151a81fe99a0217","src/macros.rs":"a3f4deaa4323da6398546720548dda20b0b39427603ccc35ab49d220a83467a8","src/num.rs":"749b201289fc6663199160a2f9204e17925fd3053f8ab7779e7bfb377ad06227","src/point.rs":"b34275cfce38f07158396d35cfd1560a50be2f0683e09b53198e7f55206a6c56","src/rect.rs":"00ef63d706d5ccd8a6fb377e2bcc58b1453080fbbdc8e41a2c6c6a1a42a76085","src/scale_factor.rs":"b093243256df3f2b8a2e2bf98236e6ec1032c3d358596f384313614dbefaca49","src/side_offsets.rs":"fd95ffc9a74e9e84314875c388e763d0780486eb7f9034423e3a22048361e379","src/size.rs":"d9a6fb1f080a06e1332b2e804f8334e086e6d6f17a4288f35133d80b2e2da765","src/transform2d.rs":"4fe4fef7266b06b7790cd400d990ad02e6e605499a1a33c8e39b5e00364389ba","src/transform3d.rs":"cd8a08dd341fcea4c5b10e00d029424e382f3b0002dd8341f302be7f1c12c4fc","src/trig.rs":"ef290927af252ca90a29ba9f17158b591ed591604e66cb9df045dd47b9cfdca5","src/vector.rs":"c087700ad35c3e18e0f5722573f6a24ed2b0452e044c1f0bbb6466c993c560f1"},"package":"7be9fcb1ce77782eb620253eb02bc1f000545f3c360841a26cda572f10fad4ff"}
|
|
@ -1,6 +1,6 @@
|
|||
language: rust
|
||||
rust:
|
||||
- 1.15.1
|
||||
- 1.17.0
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "euclid"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Geometry primitives"
|
||||
documentation = "https://docs.rs/euclid/"
|
||||
|
@ -20,23 +20,23 @@ keywords = ["matrix", "vector", "linear-algebra", "geometry"]
|
|||
categories = ["science"]
|
||||
license = "MIT / Apache-2.0"
|
||||
repository = "https://github.com/servo/euclid"
|
||||
[dependencies.num-traits]
|
||||
version = "0.1.32"
|
||||
default-features = false
|
||||
|
||||
[dependencies.heapsize]
|
||||
version = "0.4"
|
||||
|
||||
[dependencies.log]
|
||||
version = "0.3.1"
|
||||
|
||||
[dependencies.num-traits]
|
||||
version = "0.1.32"
|
||||
default-features = false
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
[dev-dependencies.serde_test]
|
||||
version = "1.0"
|
||||
|
||||
[dev-dependencies.rand]
|
||||
version = "0.3.7"
|
||||
|
||||
[dev-dependencies.serde_test]
|
||||
version = "1.0"
|
||||
|
||||
[features]
|
||||
unstable = []
|
||||
|
|
|
@ -24,6 +24,7 @@ use std::hash::{Hash, Hasher};
|
|||
use std::ops::{Add, Sub, Mul, Div};
|
||||
|
||||
/// A 2d Rectangle optionally tagged with a unit.
|
||||
#[repr(C)]
|
||||
pub struct TypedRect<T, U = UnknownUnit> {
|
||||
pub origin: TypedPoint2D<T, U>,
|
||||
pub size: TypedSize2D<T, U>,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"29b74b95210896ce634c11a9037638668473b5a1b3b1716c505cb04dbb6341fa","COPYING":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"3f5176487c0bdc07d6deb54137d671b37db706a394ec9c3820fb9c7e4c6f97a3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"2de24b7458d6b88f20324303a48acf64a4f2bbfb83d2ec4d6ff2b4f4a1fd2275","build.rs":"a9e320b7ebeb61be7f1ae594a0dcc022a6629f18c335e1b9ace11f573201c610","src/gl.rs":"4091686fedd22df293746008e1896ead67e769ff8b77eaad027e86d8692028d3","src/gl_fns.rs":"58a83def91e9d47b3cd10d9f61fa4640a0293384d9617a80c5a7de2eab3a097e","src/gles_fns.rs":"43f98589569002315cdce7835c91b71124d003d8b605924f98c9632a4a9a7c2e","src/lib.rs":"16610c19b45a3f26d56b379a3591aa2e4fc9477e7bd88f86b31c6ea32e834861"},"package":"a86944a6a4d7f54507f8ee930192d971f18a7b1da526ff529b7a0d4043935380"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"29b74b95210896ce634c11a9037638668473b5a1b3b1716c505cb04dbb6341fa","COPYING":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"98159f496b062589f85ed3e35942258cba1ef0392531e424e422a1cba678707f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"2de24b7458d6b88f20324303a48acf64a4f2bbfb83d2ec4d6ff2b4f4a1fd2275","build.rs":"a9e320b7ebeb61be7f1ae594a0dcc022a6629f18c335e1b9ace11f573201c610","src/gl.rs":"3d1fc5c9f4603a281f8793818cca50ec543ab938bb38a649a3d133df47a13bd3","src/gl_fns.rs":"8a5c0ec763d83ba241f596acb9fcc05bd73daefa94a7165ba5dc1d48404dbe7f","src/gles_fns.rs":"8d2129a1917bc2af3d7d2783de330cb2427777d037ae919b94fb0ee88bc57ebb","src/lib.rs":"16610c19b45a3f26d56b379a3591aa2e4fc9477e7bd88f86b31c6ea32e834861"},"package":"917ee404f414ed77756c12cb44fdcc7cd02f207bf91e1dc91a3ce7da794ec361"}
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gleam"
|
||||
version = "0.4.5"
|
||||
version = "0.4.7"
|
||||
license = "Apache-2.0/MIT"
|
||||
authors = ["The Servo Project Developers"]
|
||||
build = "build.rs"
|
||||
|
|
|
@ -214,6 +214,16 @@ pub trait Gl {
|
|||
format: GLenum,
|
||||
ty: GLenum,
|
||||
data: &[u8]);
|
||||
fn tex_sub_image_2d_pbo(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
xoffset: GLint,
|
||||
yoffset: GLint,
|
||||
width: GLsizei,
|
||||
height: GLsizei,
|
||||
format: GLenum,
|
||||
ty: GLenum,
|
||||
offset: usize);
|
||||
fn tex_sub_image_3d(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
|
@ -388,6 +398,10 @@ pub trait Gl {
|
|||
fn insert_event_marker_ext(&self, message: &str);
|
||||
fn push_group_marker_ext(&self, message: &str);
|
||||
fn pop_group_marker_ext(&self);
|
||||
fn fence_sync(&self, condition: GLenum, flags: GLbitfield) -> GLsync;
|
||||
fn client_wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64);
|
||||
fn wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64);
|
||||
fn delete_sync(&self, sync: GLsync);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -508,6 +508,21 @@ impl Gl for GlFns {
|
|||
}
|
||||
}
|
||||
|
||||
fn tex_sub_image_2d_pbo(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
xoffset: GLint,
|
||||
yoffset: GLint,
|
||||
width: GLsizei,
|
||||
height: GLsizei,
|
||||
format: GLenum,
|
||||
ty: GLenum,
|
||||
offset: usize) {
|
||||
unsafe {
|
||||
self.ffi_gl_.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, ty, offset as *const c_void);
|
||||
}
|
||||
}
|
||||
|
||||
fn tex_sub_image_3d(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
|
@ -1361,5 +1376,29 @@ impl Gl for GlFns {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fence_sync(&self, condition: GLenum, flags: GLbitfield) -> GLsync {
|
||||
unsafe {
|
||||
self.ffi_gl_.FenceSync(condition, flags) as *const _
|
||||
}
|
||||
}
|
||||
|
||||
fn client_wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64) {
|
||||
unsafe {
|
||||
self.ffi_gl_.ClientWaitSync(sync as *const _, flags, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
fn wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64) {
|
||||
unsafe {
|
||||
self.ffi_gl_.WaitSync(sync as *const _, flags, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
fn delete_sync(&self, sync: GLsync) {
|
||||
unsafe {
|
||||
self.ffi_gl_.DeleteSync(sync as *const _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -486,6 +486,21 @@ impl Gl for GlesFns {
|
|||
}
|
||||
}
|
||||
|
||||
fn tex_sub_image_2d_pbo(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
xoffset: GLint,
|
||||
yoffset: GLint,
|
||||
width: GLsizei,
|
||||
height: GLsizei,
|
||||
format: GLenum,
|
||||
ty: GLenum,
|
||||
offset: usize) {
|
||||
unsafe {
|
||||
self.ffi_gl_.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, ty, offset as *const c_void);
|
||||
}
|
||||
}
|
||||
|
||||
fn tex_sub_image_3d(&self,
|
||||
target: GLenum,
|
||||
level: GLint,
|
||||
|
@ -1315,5 +1330,29 @@ impl Gl for GlesFns {
|
|||
#[allow(unused_variables)]
|
||||
fn pop_group_marker_ext(&self) {
|
||||
}
|
||||
|
||||
fn fence_sync(&self, condition: GLenum, flags: GLbitfield) -> GLsync {
|
||||
unsafe {
|
||||
self.ffi_gl_.FenceSync(condition, flags) as *const _
|
||||
}
|
||||
}
|
||||
|
||||
fn client_wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64) {
|
||||
unsafe {
|
||||
self.ffi_gl_.ClientWaitSync(sync as *const _, flags, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
fn wait_sync(&self, sync: GLsync, flags: GLbitfield, timeout: GLuint64) {
|
||||
unsafe {
|
||||
self.ffi_gl_.WaitSync(sync as *const _, flags, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
fn delete_sync(&self, sync: GLsync) {
|
||||
unsafe {
|
||||
self.ffi_gl_.DeleteSync(sync as *const _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,11 @@ name = "bitflags"
|
|||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitreader"
|
||||
version = "0.3.0"
|
||||
|
@ -217,7 +222,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "5.0.1"
|
||||
version = "6.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -322,7 +327,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "euclid"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -409,7 +414,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gleam"
|
||||
version = "0.4.5"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -678,7 +683,7 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -915,7 +920,7 @@ dependencies = [
|
|||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -960,7 +965,7 @@ dependencies = [
|
|||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
]
|
||||
|
||||
|
@ -1163,21 +1168,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.43.0"
|
||||
version = "0.47.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1185,25 +1190,12 @@ dependencies = [
|
|||
"rayon 0.8.1 (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.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_traits 0.43.0",
|
||||
"webrender_api 0.47.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_bindings"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (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.43.0",
|
||||
"webrender_traits 0.43.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.43.0"
|
||||
name = "webrender_api"
|
||||
version = "0.47.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1211,13 +1203,26 @@ dependencies = [
|
|||
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_bindings"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (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.47.0",
|
||||
"webrender_api 0.47.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
|
@ -1252,6 +1257,7 @@ dependencies = [
|
|||
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
|
||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
"checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
|
||||
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
|
||||
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
|
||||
|
@ -1262,7 +1268,7 @@ dependencies = [
|
|||
"checksum core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f51ce3b8ebe311c56de14231eb57572c15abebd2d32b3bcb99bcdb9c101f5ac3"
|
||||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
||||
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
||||
"checksum core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ce16d9ed00181016c11ff48e561314bec92bfbce9fe48f319366618d4e5de6"
|
||||
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
|
||||
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
||||
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
||||
|
@ -1270,14 +1276,14 @@ dependencies = [
|
|||
"checksum encoding_c 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1e563195f16d7439103c49281b8b00bd0f223c16e19f0d500448239a27712570"
|
||||
"checksum encoding_rs 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e00a1b1e95eb46988805ceee6f34cd95c46a6753e290cb3ff0486931989d4a4c"
|
||||
"checksum env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed39959122ea027670b704fb70539f4286ddf4a49eefede23bf0b4b2a069ec03"
|
||||
"checksum euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5fcf274fa860e18379115ac336e9b41553f61c9ed34ad09e8101ed3defae2"
|
||||
"checksum euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7be9fcb1ce77782eb620253eb02bc1f000545f3c360841a26cda572f10fad4ff"
|
||||
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
|
||||
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
|
||||
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
|
||||
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
|
||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
|
||||
"checksum gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86944a6a4d7f54507f8ee930192d971f18a7b1da526ff529b7a0d4043935380"
|
||||
"checksum gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "917ee404f414ed77756c12cb44fdcc7cd02f207bf91e1dc91a3ce7da794ec361"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
|
||||
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
|
||||
|
|
|
@ -128,6 +128,11 @@ name = "bitflags"
|
|||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitreader"
|
||||
version = "0.3.0"
|
||||
|
@ -215,7 +220,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "5.0.1"
|
||||
version = "6.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -320,7 +325,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "euclid"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -407,7 +412,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gleam"
|
||||
version = "0.4.5"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -665,7 +670,7 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -902,7 +907,7 @@ dependencies = [
|
|||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -947,7 +952,7 @@ dependencies = [
|
|||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
]
|
||||
|
||||
|
@ -1150,21 +1155,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.43.0"
|
||||
version = "0.47.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1172,25 +1177,12 @@ dependencies = [
|
|||
"rayon 0.8.1 (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.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_traits 0.43.0",
|
||||
"webrender_api 0.47.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_bindings"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (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.43.0",
|
||||
"webrender_traits 0.43.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.43.0"
|
||||
name = "webrender_api"
|
||||
version = "0.47.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1198,13 +1190,26 @@ dependencies = [
|
|||
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_bindings"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (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.47.0",
|
||||
"webrender_api 0.47.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
|
@ -1239,6 +1244,7 @@ dependencies = [
|
|||
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
|
||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
"checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
|
||||
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
|
||||
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
|
||||
|
@ -1249,7 +1255,7 @@ dependencies = [
|
|||
"checksum core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f51ce3b8ebe311c56de14231eb57572c15abebd2d32b3bcb99bcdb9c101f5ac3"
|
||||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
||||
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
||||
"checksum core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ce16d9ed00181016c11ff48e561314bec92bfbce9fe48f319366618d4e5de6"
|
||||
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
|
||||
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
||||
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
||||
|
@ -1257,14 +1263,14 @@ dependencies = [
|
|||
"checksum encoding_c 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1e563195f16d7439103c49281b8b00bd0f223c16e19f0d500448239a27712570"
|
||||
"checksum encoding_rs 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e00a1b1e95eb46988805ceee6f34cd95c46a6753e290cb3ff0486931989d4a4c"
|
||||
"checksum env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed39959122ea027670b704fb70539f4286ddf4a49eefede23bf0b4b2a069ec03"
|
||||
"checksum euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5fcf274fa860e18379115ac336e9b41553f61c9ed34ad09e8101ed3defae2"
|
||||
"checksum euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7be9fcb1ce77782eb620253eb02bc1f000545f3c360841a26cda572f10fad4ff"
|
||||
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
|
||||
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
|
||||
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
|
||||
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
|
||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
|
||||
"checksum gleam 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86944a6a4d7f54507f8ee930192d971f18a7b1da526ff529b7a0d4043935380"
|
||||
"checksum gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "917ee404f414ed77756c12cb44fdcc7cd02f207bf91e1dc91a3ce7da794ec361"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
|
||||
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
|
||||
|
|
Загрузка…
Ссылка в новой задаче