Removed module macro workaround for signed and unsigned integers

This commit is contained in:
Marvin Löbel 2013-11-29 20:30:31 +01:00
parent 0d8ace823b
commit 4840064f85
12 changed files with 107 additions and 71 deletions

View File

@ -10,11 +10,17 @@
//! Operations and constants for `i16` //! Operations and constants for `i16`
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
int_module!(i16, 16) int_module!(i16, 16)

View File

@ -10,11 +10,17 @@
//! Operations and constants for `i32` //! Operations and constants for `i32`
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
int_module!(i32, 32) int_module!(i32, 32)

View File

@ -10,14 +10,20 @@
//! Operations and constants for `i64` //! Operations and constants for `i64`
use num::{BitCount, CheckedAdd, CheckedSub}; #[allow(non_uppercase_statics)];
use prelude::*;
use default::Default;
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
use num::CheckedMul; use num::CheckedMul;
use num::{BitCount, CheckedAdd, CheckedSub};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None}; use option::{Option, Some, None};
use str;
use unstable::intrinsics; use unstable::intrinsics;
pub use self::generated::*;
int_module!(i64, 64) int_module!(i64, 64)
impl BitCount for i64 { impl BitCount for i64 {

View File

@ -10,11 +10,17 @@
//! Operations and constants for `i8` //! Operations and constants for `i8`
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
int_module!(i8, 8) int_module!(i8, 8)

View File

@ -12,16 +12,18 @@
#[allow(non_uppercase_statics)]; #[allow(non_uppercase_statics)];
use prelude::*;
use default::Default;
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None}; use option::{Option, Some, None};
use str;
use unstable::intrinsics; use unstable::intrinsics;
pub use self::generated::*; #[cfg(target_word_size = "32")] int_module!(int, 32)
#[cfg(target_word_size = "64")] int_module!(int, 64)
#[cfg(target_word_size = "32")] pub static bits: uint = 32;
#[cfg(target_word_size = "64")] pub static bits: uint = 64;
int_module!(int, super::bits)
#[cfg(target_word_size = "32")] #[cfg(target_word_size = "32")]
impl BitCount for int { impl BitCount for int {

View File

@ -8,22 +8,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// FIXME(#4375): This shouldn't have to be a nested module named 'generated'...
// FIXME(#10716): ... but now that we could solve that, the import lines and
// attributes still prevent a removal of that module.
#[macro_escape]; #[macro_escape];
#[doc(hidden)]; #[doc(hidden)];
macro_rules! int_module (($T:ty, $bits:expr) => (mod generated { macro_rules! int_module (($T:ty, $bits:expr) => (
#[allow(non_uppercase_statics)];
use default::Default;
use num::{ToStrRadix, FromStrRadix};
use num::{CheckedDiv, Zero, One, strconv};
use prelude::*;
use str;
pub static bits : uint = $bits; pub static bits : uint = $bits;
pub static bytes : uint = ($bits / 8); pub static bytes : uint = ($bits / 8);
@ -781,4 +769,4 @@ mod tests {
} }
} }
})) ))

View File

@ -10,11 +10,18 @@
//! Operations and constants for `u16` //! Operations and constants for `u16`
use num::{CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::BitCount;
use num::{CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
uint_module!(u16, i16, 16) uint_module!(u16, i16, 16)

View File

@ -10,11 +10,18 @@
//! Operations and constants for `u32` //! Operations and constants for `u32`
use num::{CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::BitCount;
use num::{CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
uint_module!(u32, i32, 32) uint_module!(u32, i32, 32)

View File

@ -10,14 +10,21 @@
//! Operations and constants for `u64` //! Operations and constants for `u64`
use num::{CheckedAdd, CheckedSub}; #[allow(non_uppercase_statics)];
use prelude::*;
use default::Default;
use num::BitCount;
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
use num::CheckedMul; use num::CheckedMul;
use num::{CheckedAdd, CheckedSub};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None}; use option::{Option, Some, None};
use str;
use unstable::intrinsics; use unstable::intrinsics;
pub use self::generated::*;
uint_module!(u64, i64, 64) uint_module!(u64, i64, 64)
impl CheckedAdd for u64 { impl CheckedAdd for u64 {

View File

@ -10,11 +10,18 @@
//! Operations and constants for `u8` //! Operations and constants for `u8`
use num::{CheckedAdd, CheckedSub, CheckedMul}; #[allow(non_uppercase_statics)];
use option::{Option, Some, None};
use unstable::intrinsics;
pub use self::generated::*; use prelude::*;
use default::Default;
use num::BitCount;
use num::{CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
uint_module!(u8, i8, 8) uint_module!(u8, i8, 8)

View File

@ -10,13 +10,20 @@
//! Operations and constants for `uint` //! Operations and constants for `uint`
use num; #[allow(non_uppercase_statics)];
use num::{CheckedAdd, CheckedSub, CheckedMul};
use option::{Option, Some, None};
use unstable::intrinsics;
use mem;
pub use self::generated::*; use prelude::*;
use default::Default;
use mem;
use num::BitCount;
use num::{CheckedAdd, CheckedSub, CheckedMul};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use num;
use option::{Option, Some, None};
use str;
use unstable::intrinsics;
uint_module!(uint, int, ::int::bits) uint_module!(uint, int, ::int::bits)

View File

@ -8,23 +8,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// FIXME(#4375): This shouldn't have to be a nested module named 'generated'...
// FIXME(#10716): ... but now that we could solve that, the import lines and
// attributes still prevent a removal of that module.
#[macro_escape]; #[macro_escape];
#[doc(hidden)]; #[doc(hidden)];
macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated { macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (
#[allow(non_uppercase_statics)];
use default::Default;
use num::BitCount;
use num::{ToStrRadix, FromStrRadix};
use num::{CheckedDiv, Zero, One, strconv};
use prelude::*;
use str;
pub static bits : uint = $bits; pub static bits : uint = $bits;
pub static bytes : uint = ($bits / 8); pub static bytes : uint = ($bits / 8);
@ -554,4 +541,4 @@ mod tests {
} }
} }
})) ))