libs: Remove transitionary material on iter_bytes, add workcache to build.
This commit is contained in:
parent
38ba2c4941
commit
d783f4d7bb
13 changed files with 1 additions and 885 deletions
|
@ -19,7 +19,6 @@ pub type Cb = fn(buf: &[const u8]) -> bool;
|
|||
* modified when default methods and trait inheritence are
|
||||
* completed.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub trait IterBytes {
|
||||
/**
|
||||
* Call the provided callback `f` one or more times with
|
||||
|
@ -35,27 +34,9 @@ pub trait IterBytes {
|
|||
* left-to-right in declaration order, regardless of
|
||||
* underlying memory endianness.
|
||||
*/
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb);
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
pub trait IterBytes {
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb);
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl bool: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(_lsb0: bool, f: Cb) {
|
||||
f([
|
||||
self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl bool: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
|
@ -65,18 +46,6 @@ impl bool: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl u8: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(_lsb0: bool, f: Cb) {
|
||||
f([
|
||||
self
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl u8: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
|
@ -86,26 +55,6 @@ impl u8: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl u16: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
self as u8,
|
||||
(self >> 8) as u8
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(self >> 8) as u8,
|
||||
self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl u16: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -123,30 +72,6 @@ impl u16: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl u32: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
self as u8,
|
||||
(self >> 8) as u8,
|
||||
(self >> 16) as u8,
|
||||
(self >> 24) as u8,
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(self >> 24) as u8,
|
||||
(self >> 16) as u8,
|
||||
(self >> 8) as u8,
|
||||
self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl u32: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -168,38 +93,6 @@ impl u32: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl u64: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
if lsb0 {
|
||||
f([
|
||||
self as u8,
|
||||
(self >> 8) as u8,
|
||||
(self >> 16) as u8,
|
||||
(self >> 24) as u8,
|
||||
(self >> 32) as u8,
|
||||
(self >> 40) as u8,
|
||||
(self >> 48) as u8,
|
||||
(self >> 56) as u8
|
||||
]);
|
||||
} else {
|
||||
f([
|
||||
(self >> 56) as u8,
|
||||
(self >> 48) as u8,
|
||||
(self >> 40) as u8,
|
||||
(self >> 32) as u8,
|
||||
(self >> 24) as u8,
|
||||
(self >> 16) as u8,
|
||||
(self >> 8) as u8,
|
||||
self as u8
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl u64: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -229,16 +122,6 @@ impl u64: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl i8: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl i8: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -246,16 +129,6 @@ impl i8: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl i16: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u16).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl i16: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -263,16 +136,6 @@ impl i16: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl i32: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl i32: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -280,16 +143,6 @@ impl i32: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl i64: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u64).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl i64: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -297,16 +150,6 @@ impl i64: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl char: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl char: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -316,16 +159,6 @@ impl char: IterBytes {
|
|||
|
||||
#[cfg(target_word_size = "32")]
|
||||
pub mod x32 {
|
||||
#[cfg(stage0)]
|
||||
pub impl uint: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u32).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
pub impl uint: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -336,16 +169,6 @@ pub mod x32 {
|
|||
|
||||
#[cfg(target_word_size = "64")]
|
||||
pub mod x64 {
|
||||
#[cfg(stage0)]
|
||||
pub impl uint: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as u64).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
pub impl uint: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -354,16 +177,6 @@ pub mod x64 {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl int: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl int: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -371,20 +184,6 @@ impl int: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> &[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
for self.each |elt| {
|
||||
do elt.iter_bytes(lsb0) |bytes| {
|
||||
f(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> &[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -396,18 +195,6 @@ impl<A: IterBytes> &[A]: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes, B: IterBytes> (A,B): IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
let &(ref a, ref b) = &self;
|
||||
a.iter_bytes(lsb0, f);
|
||||
b.iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes, B: IterBytes> (A,B): IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -417,19 +204,6 @@ impl<A: IterBytes, B: IterBytes> (A,B): IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes, B: IterBytes, C: IterBytes> (A,B,C): IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
let &(ref a, ref b, ref c) = &self;
|
||||
a.iter_bytes(lsb0, f);
|
||||
b.iter_bytes(lsb0, f);
|
||||
c.iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes, B: IterBytes, C: IterBytes> (A,B,C): IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -445,16 +219,6 @@ pure fn borrow<A>(a: &x/[A]) -> &x/[A] {
|
|||
a
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> ~[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
borrow(self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> ~[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -462,16 +226,6 @@ impl<A: IterBytes> ~[A]: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> @[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
borrow(self).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> @[A]: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -582,18 +336,6 @@ pub pure fn iter_bytes_7<A: IterBytes,
|
|||
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl &str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(_lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl &str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
|
@ -603,18 +345,6 @@ impl &str: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl ~str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(_lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl ~str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
|
@ -624,18 +354,6 @@ impl ~str: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl @str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(_lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(self) |bytes| {
|
||||
f(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl @str: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
|
@ -645,19 +363,6 @@ impl @str: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> Option<A>: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
match self {
|
||||
Some(ref a) => iter_bytes_2(&0u8, a, lsb0, f),
|
||||
None => 1u8.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> Option<A>: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -668,16 +373,6 @@ impl<A: IterBytes> Option<A>: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> &A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(*self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> &A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -685,16 +380,6 @@ impl<A: IterBytes> &A: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> @A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(*self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> @A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -702,16 +387,6 @@ impl<A: IterBytes> @A: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A: IterBytes> ~A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(*self).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A: IterBytes> ~A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
@ -719,18 +394,8 @@ impl<A: IterBytes> ~A: IterBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<A> *const A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(lsb0: bool, f: Cb) {
|
||||
(self as uint).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
// NB: raw-pointer IterBytes does _not_ dereference
|
||||
// to the target; it just gives you the pointer-bytes.
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<A> *const A: IterBytes {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue