mirror of https://github.com/roytam1/UXP
496 changed files with 4 additions and 788702 deletions
@ -1,166 +0,0 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- |
||||
# vim: set filetype=python: |
||||
# This Source Code Form is subject to the terms of the Mozilla Public |
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this |
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
||||
|
||||
option('--enable-rust', help='Include Rust language sources') |
||||
|
||||
@depends('--enable-rust') |
||||
def rust_compiler_names(value): |
||||
if value: |
||||
return ['rustc'] |
||||
|
||||
@depends('--enable-rust') |
||||
def cargo_binary_names(value): |
||||
if value: |
||||
return ['cargo'] |
||||
|
||||
rustc = check_prog('RUSTC', rust_compiler_names, allow_missing=True) |
||||
cargo = check_prog('CARGO', cargo_binary_names, allow_missing=True) |
||||
|
||||
@depends_if(rustc) |
||||
@checking('rustc version', lambda info: info.version) |
||||
def rustc_info(rustc): |
||||
out = check_cmd_output(rustc, '--version', '--verbose').splitlines() |
||||
info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:]) |
||||
return namespace( |
||||
version=Version(info.get('release', '0')), |
||||
commit=info.get('commit-hash', 'unknown'), |
||||
) |
||||
|
||||
@depends_if(cargo) |
||||
@checking('cargo support for --frozen') |
||||
@imports('subprocess') |
||||
@imports('os') |
||||
def cargo_supports_frozen(cargo): |
||||
try: |
||||
lines = subprocess.check_output( |
||||
[cargo, 'help', 'build'] |
||||
).splitlines() |
||||
supported = any(' --frozen' in l for l in lines) |
||||
if 'MOZ_AUTOMATION' in os.environ and not supported: |
||||
die('cargo in automation must support --frozen') |
||||
return supported |
||||
except subprocess.CalledProcessError as e: |
||||
die('Failed to call cargo: %s', e.message) |
||||
|
||||
set_config('MOZ_CARGO_SUPPORTS_FROZEN', cargo_supports_frozen) |
||||
|
||||
@depends('--enable-rust', rustc, rustc_info) |
||||
@imports(_from='textwrap', _import='dedent') |
||||
def rust_compiler(value, rustc, rustc_info): |
||||
if value: |
||||
if not rustc: |
||||
die(dedent('''\ |
||||
Rust compiler not found. |
||||
To compile rust language sources, you must have 'rustc' in your path. |
||||
See https//www.rust-lang.org/ for more information. |
||||
''')) |
||||
version = rustc_info.version |
||||
min_version = Version('1.10') |
||||
if version < min_version: |
||||
die(dedent('''\ |
||||
Rust compiler {} is too old. |
||||
To compile Rust language sources please install at least |
||||
version {} of the 'rustc' toolchain and make sure it is |
||||
first in your path. |
||||
You can verify this by typing 'rustc --version'. |
||||
'''.format(version, min_version))) |
||||
return True |
||||
|
||||
set_config('MOZ_RUST', rust_compiler) |
||||
|
||||
@depends(rust_compiler, rustc, target, cross_compiling) |
||||
@imports('os') |
||||
@imports('subprocess') |
||||
@imports(_from='mozbuild.configure.util', _import='LineIO') |
||||
@imports(_from='mozbuild.shellutil', _import='quote') |
||||
@imports(_from='tempfile', _import='mkstemp') |
||||
def rust_target(rust_compiler, rustc, target, cross_compiling): |
||||
if rust_compiler: |
||||
# Rust's --target options are similar to, but not exactly the same |
||||
# as, the autoconf-derived targets we use. An example would be that |
||||
# Rust uses distinct target triples for targetting the GNU C++ ABI |
||||
# and the MSVC C++ ABI on Win32, whereas autoconf has a single |
||||
# triple and relies on the user to ensure that everything is |
||||
# compiled for the appropriate ABI. We need to perform appropriate |
||||
# munging to get the correct option to rustc. |
||||
# |
||||
# The canonical list of targets supported can be derived from: |
||||
# |
||||
# https://github.com/rust-lang/rust/tree/master/mk/cfg |
||||
|
||||
# Avoid having to write out os+kernel for all the platforms where |
||||
# they don't differ. |
||||
os_or_kernel = target.kernel if target.kernel == 'Linux' and target.os != 'Android' else target.os |
||||
rustc_target = { |
||||
# DragonFly |
||||
('x86_64', 'DragonFly'): 'x86_64-unknown-dragonfly', |
||||
# FreeBSD |
||||
('x86', 'FreeBSD'): 'i686-unknown-freebsd', |
||||
('x86_64', 'FreeBSD'): 'x86_64-unknown-freebsd', |
||||
# NetBSD |
||||
('x86_64', 'NetBSD'): 'x86_64-unknown-netbsd', |
||||
# OpenBSD |
||||
('x86_64', 'OpenBSD'): 'x86_64-unknown-openbsd', |
||||
# Linux |
||||
('x86', 'Linux'): 'i586-unknown-linux-gnu', |
||||
# Linux |
||||
('x86_64', 'Linux'): 'x86_64-unknown-linux-gnu', |
||||
# OS X and iOS |
||||
('x86', 'OSX'): 'i686-apple-darwin', |
||||
('x86', 'iOS'): 'i386-apple-ios', |
||||
('x86_64', 'OSX'): 'x86_64-apple-darwin', |
||||
# Android |
||||
('x86', 'Android'): 'i686-linux-android', |
||||
('arm', 'Android'): 'armv7-linux-androideabi', |
||||
# Windows |
||||
# XXX better detection of CXX needed here, to figure out whether |
||||
# we need i686-pc-windows-gnu instead, since mingw32 builds work. |
||||
('x86', 'WINNT'): 'i686-pc-windows-msvc', |
||||
('x86_64', 'WINNT'): 'x86_64-pc-windows-msvc', |
||||
}.get((target.cpu, os_or_kernel), None) |
||||
|
||||
if rustc_target is None: |
||||
die("Don't know how to translate {} for rustc".format(target.alias)) |
||||
|
||||
# Check to see whether our rustc has a reasonably functional stdlib |
||||
# for our chosen target. |
||||
target_arg = '--target=' + rustc_target |
||||
in_fd, in_path = mkstemp(prefix='conftest', suffix='.rs') |
||||
out_fd, out_path = mkstemp(prefix='conftest', suffix='.rlib') |
||||
os.close(out_fd) |
||||
try: |
||||
source = 'pub extern fn hello() { println!("Hello world"); }' |
||||
log.debug('Creating `%s` with content:', in_path) |
||||
with LineIO(lambda l: log.debug('| %s', l)) as out: |
||||
out.write(source) |
||||
|
||||
os.write(in_fd, source) |
||||
os.close(in_fd) |
||||
|
||||
cmd = [ |
||||
rustc, |
||||
'--crate-type', 'staticlib', |
||||
target_arg, |
||||
'-o', out_path, |
||||
in_path, |
||||
] |
||||
def failed(): |
||||
die('Cannot compile for {} with {}'.format(target.alias, rustc)) |
||||
check_cmd_output(*cmd, onerror=failed) |
||||
if not os.path.exists(out_path) or os.path.getsize(out_path) == 0: |
||||
failed() |
||||
finally: |
||||
os.remove(in_path) |
||||
os.remove(out_path) |
||||
# This target is usable. |
||||
return rustc_target |
||||
|
||||
set_config('RUST_TARGET', rust_target) |
||||
|
||||
# Until we remove all the other Rust checks in old-configure. |
||||
add_old_configure_assignment('MOZ_RUST', rust_compiler) |
||||
add_old_configure_assignment('RUSTC', rustc) |
||||
add_old_configure_assignment('RUST_TARGET', rust_target) |
@ -1,10 +0,0 @@
|
||||
# Options to enable rust in automation builds. |
||||
|
||||
# Tell configure to use the tooltool rustc. |
||||
# Assume this is compiled with --enable-rpath so we don't |
||||
# have to set LD_LIBRARY_PATH. |
||||
RUSTC="$topsrcdir/rustc/bin/rustc" |
||||
CARGO="$topsrcdir/cargo/bin/cargo" |
||||
|
||||
# Enable rust in the build. |
||||
ac_add_options --enable-rust |
@ -1,18 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[dependencies] |
||||
deep-crate = { version = "0.1.0", path = "the/depths" } |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,6 +0,0 @@
|
||||
[package] |
||||
name = "shallow-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
@ -1,9 +0,0 @@
|
||||
[package] |
||||
name = "deep-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[dependencies] |
||||
shallow-crate = { path = "../../shallow" } |
@ -1,27 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
Library('test') |
||||
|
||||
DIRS += [ |
||||
'rust1', |
||||
'rust2', |
||||
] |
||||
|
||||
USE_LIBS += [ |
||||
'rust1', |
||||
'rust2', |
||||
] |
@ -1,15 +0,0 @@
|
||||
[package] |
||||
name = "rust1" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,4 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
RustLibrary('rust1') |
@ -1,15 +0,0 @@
|
||||
[package] |
||||
name = "rust2" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,4 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
RustLibrary('rust2') |
@ -1,15 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,15 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["dylib"] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,12 +0,0 @@
|
||||
[package] |
||||
name = "deterministic-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,12 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[profile.dev] |
||||
panic = "abort" |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,12 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[profile.release] |
||||
panic = "abort" |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1,14 +0,0 @@
|
||||
[package] |
||||
name = "random-crate" |
||||
version = "0.1.0" |
||||
authors = [ |
||||
"Nobody <nobody@mozilla.org>", |
||||
] |
||||
|
||||
[lib] |
||||
crate-type = ["staticlib"] |
||||
|
||||
[profile.dev] |
||||
panic = "unwind" |
||||
|
||||
[profile.release] |
@ -1,18 +0,0 @@
|
||||
# Any copyright is dedicated to the Public Domain. |
||||
# http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
@template |
||||
def Library(name): |
||||
'''Template for libraries.''' |
||||
LIBRARY_NAME = name |
||||
|
||||
|
||||
@template |
||||
def RustLibrary(name): |
||||
'''Template for Rust libraries.''' |
||||
Library(name) |
||||
|
||||
IS_RUST_LIBRARY = True |
||||
|
||||
|
||||
RustLibrary('random-crate') |
@ -1 +0,0 @@
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"2879af3c0512f976015d532e2d768f04ff22fdcf8745b69b955b78fda321c3fb",".travis.yml":"81545ce3c6c72111a68434464c3f9fa8df9cbe39759a081fac527628ab21ae0c","COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"a7282931b50dff2e463f82baaed95a9d76636bc0fef3e921acd8ca69eab32b83","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","Makefile":"a45a128685a2ae7d4fa39d310786674417ee113055ef290a11f88002285865fc","README.md":"fbcc46b6d0a585096737f50922818b59016b69d959b05f1b29863b2af8e4da43","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","benches/bench.rs":"f583692d829c8dfe19b1d5b9e968ccf5c74d6733367ca183edff74041a6afedd","session.vim":"95cb1d7caf0ff7fbe76ec911988d908ddd883381c925ba64b537695bc9f021c4","src/lib.rs":"ef9e7a218fa3a4912c47f6840d32b975940d98277b6c9be85e8d7d045552eb87","src/new.rs":"161c21b7ebb5668c7cc70b46b0eb37709e06bb9c854f2fdfc6ce3d3babcbf3de"},"package":"0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"} |
@ -1,6 +0,0 @@
|
||||
.*.swp |
||||
doc |
||||
tags |
||||
build |
||||
target |
||||
Cargo.lock |
@ -1,15 +0,0 @@
|
||||
language: rust |
||||
matrix: |
||||
include: |
||||
- rust: "nightly" |
||||
env: TEST_SUITE=suite_nightly |
||||
- rust: "beta" |
||||
env: TEST_SUITE=suite_beta |
||||
- rust: "stable" |
||||
env: TEST_SUITE=suite_stable |
||||
script: |
||||
- cargo build --verbose |
||||
- cargo test --verbose |
||||
- if [ "$TEST_SUITE" = "suite_nightly" ]; then |
||||
cargo bench --verbose; |
||||
fi |
@ -1,3 +0,0 @@
|
||||
This project is dual-licensed under the Unlicense and MIT licenses. |
||||
|
||||
You may use this code under the terms of either license. |
@ -1,25 +0,0 @@
|
||||
[package] |
||||
name = "byteorder" |
||||
version = "0.5.3" #:version |
||||
authors = ["Andrew Gallant <jamslam@gmail.com>"] |
||||
description = "Library for reading/writing numbers in big-endian and little-endian." |
||||
documentation = "http://burntsushi.net/rustdoc/byteorder/" |
||||
homepage = "https://github.com/BurntSushi/byteorder" |
||||
repository = "https://github.com/BurntSushi/byteorder" |
||||
readme = "README.md" |
||||
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"] |
||||
license = "Unlicense/MIT" |
||||
|
||||
[lib] |
||||
name = "byteorder" |
||||
|
||||
[dev-dependencies] |
||||
quickcheck = "0.2" |
||||
rand = "0.3" |
||||
|
||||
[features] |
||||
default = ["std"] |
||||
std = [] |
||||
|
||||
[profile.bench] |
||||
opt-level = 3 |
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2015 Andrew Gallant |
||||
|
||||
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. |
@ -1,14 +0,0 @@
|
||||
all: |
||||
echo Nothing to do...
|
||||
|
||||
ctags: |
||||
ctags --recurse --options=ctags.rust --languages=Rust
|
||||
|
||||
docs: |
||||
cargo doc
|
||||
in-dir ./target/doc fix-perms
|
||||
rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/
|
||||
|
||||
push: |
||||
git push origin master
|
||||
git push github master
|
@ -1,59 +0,0 @@
|
||||
This crate provides convenience methods for encoding and decoding numbers in |
||||
either big-endian or little-endian order. This is meant to replace the old |
||||
methods defined on the standard library `Reader` and `Writer` traits. |
||||
|
||||
[](https://travis-ci.org/BurntSushi/byteorder) |
||||
[](https://crates.io/crates/byteorder) |
||||
|
||||
Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). |
||||
|
||||
|
||||
### Documentation |
||||
|
||||
[http://burntsushi.net/rustdoc/byteorder/](http://burntsushi.net/rustdoc/byteorder/). |
||||
|
||||
The documentation includes examples. |
||||
|
||||
|
||||
### Installation |
||||
|
||||
This crate works with Cargo and is on |
||||
[crates.io](https://crates.io/crates/byteorder). The package is regularly |
||||
updated. Add it to your `Cargo.toml` like so: |
||||
|
||||
```toml |
||||
[dependencies] |
||||
byteorder = "0.5" |
||||
``` |
||||
|
||||
If you want to augment existing `Read` and `Write` traits, then import the |
||||
extension methods like so: |
||||
|
||||
```rust |
||||
extern crate byteorder; |
||||
|
||||
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian}; |
||||
``` |
||||
|
||||
For example: |
||||
|
||||
```rust |
||||
use std::io::Cursor; |
||||
use byteorder::{BigEndian, ReadBytesExt}; |
||||
|
||||
let mut rdr = Cursor::new(vec![2, 5, 3, 0]); |
||||
// Note that we use type parameters to indicate which kind of byte order |
||||
// we want! |
||||
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap()); |
||||
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap()); |
||||
``` |
||||
|
||||
### `no_std` crates |
||||
|
||||
This crate has a feature, `std`, that is enabled by default. To use this crate |
||||
in a `no_std` context, add the following to your `Cargo.toml`: |
||||
|
||||
```toml |
||||
[dependencies] |
||||
byteorder = { version = "0.5", default-features = false } |
||||
``` |
@ -1,24 +0,0 @@
|
||||
This is free and unencumbered software released into the public domain. |
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or |
||||
distribute this software, either in source code form or as a compiled |
||||
binary, for any purpose, commercial or non-commercial, and by any |
||||
means. |
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors |
||||
of this software dedicate any and all copyright interest in the |
||||
software to the public domain. We make this dedication for the benefit |
||||
of the public at large and to the detriment of our heirs and |
||||
successors. We intend this dedication to be an overt act of |
||||
relinquishment in perpetuity of all present and future rights to this |
||||
software under copyright law. |
||||
|
||||
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 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. |
||||
|
||||
For more information, please refer to <http://unlicense.org/> |
@ -1,148 +0,0 @@
|
||||
#![feature(test)] |
||||
|
||||
extern crate byteorder; |
||||
extern crate test; |
||||
|
||||
macro_rules! bench_num { |
||||
($name:ident, $read:ident, $bytes:expr, $data:expr) => ( |
||||
mod $name { |
||||
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian}; |
||||
use super::test::Bencher; |
||||
use super::test::black_box as bb; |
||||
|
||||
const NITER: usize = 100_000; |
||||
|
||||
#[bench] |
||||
fn read_big_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(BigEndian::$read(&buf, $bytes)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn read_little_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(LittleEndian::$read(&buf, $bytes)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn read_native_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(NativeEndian::$read(&buf, $bytes)); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
); |
||||
($ty:ident, $max:ident, |
||||
$read:ident, $write:ident, $size:expr, $data:expr) => ( |
||||
mod $ty { |
||||
use std::$ty; |
||||
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian}; |
||||
use super::test::Bencher; |
||||
use super::test::black_box as bb; |
||||
|
||||
const NITER: usize = 100_000; |
||||
|
||||
#[bench] |
||||
fn read_big_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(BigEndian::$read(&buf)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn read_little_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(LittleEndian::$read(&buf)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn read_native_endian(b: &mut Bencher) { |
||||
let buf = $data; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(NativeEndian::$read(&buf)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn write_big_endian(b: &mut Bencher) { |
||||
let mut buf = $data; |
||||
let n = $ty::$max; |
||||
b.iter(|| { |
||||
for _ in 0..NITER { |
||||
bb(BigEndian::$write(&mut buf, n)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
#[bench] |
||||
fn |