Skip to content

Commit

Permalink
Removed module macro workaround for signed and unsigned integers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimundi committed Nov 29, 2013
1 parent 0d8ace8 commit 4840064
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 57 deletions.
10 changes: 8 additions & 2 deletions src/libstd/num/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

//! Operations and constants for `i16`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

int_module!(i16, 16)

impl BitCount for i16 {
Expand Down
10 changes: 8 additions & 2 deletions src/libstd/num/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

//! Operations and constants for `i32`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

int_module!(i32, 32)

impl BitCount for i32 {
Expand Down
12 changes: 9 additions & 3 deletions src/libstd/num/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@

//! Operations and constants for `i64`

use num::{BitCount, CheckedAdd, CheckedSub};
#[allow(non_uppercase_statics)];

use prelude::*;

use default::Default;
#[cfg(target_word_size = "64")]
use num::CheckedMul;
use num::{BitCount, CheckedAdd, CheckedSub};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;

pub use self::generated::*;

int_module!(i64, 64)

impl BitCount for i64 {
Expand Down
10 changes: 8 additions & 2 deletions src/libstd/num/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

//! Operations and constants for `i8`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

int_module!(i8, 8)

impl BitCount for i8 {
Expand Down
14 changes: 8 additions & 6 deletions src/libstd/num/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

#[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")] int_module!(int, 32)
#[cfg(target_word_size = "64")] int_module!(int, 64)

#[cfg(target_word_size = "32")]
impl BitCount for int {
Expand Down
16 changes: 2 additions & 14 deletions src/libstd/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,10 @@
// option. This file may not be copied, modified, or distributed
// 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];
#[doc(hidden)];

macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {

#[allow(non_uppercase_statics)];

use default::Default;
use num::{ToStrRadix, FromStrRadix};
use num::{CheckedDiv, Zero, One, strconv};
use prelude::*;
use str;
macro_rules! int_module (($T:ty, $bits:expr) => (

pub static bits : uint = $bits;
pub static bytes : uint = ($bits / 8);
Expand Down Expand Up @@ -781,4 +769,4 @@ mod tests {
}
}

}))
))
11 changes: 9 additions & 2 deletions src/libstd/num/u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@

//! Operations and constants for `u16`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

uint_module!(u16, i16, 16)

impl CheckedAdd for u16 {
Expand Down
11 changes: 9 additions & 2 deletions src/libstd/num/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@

//! Operations and constants for `u32`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

uint_module!(u32, i32, 32)

impl CheckedAdd for u32 {
Expand Down
13 changes: 10 additions & 3 deletions src/libstd/num/u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@

//! 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")]
use num::CheckedMul;
use num::{CheckedAdd, CheckedSub};
use num::{CheckedDiv, Zero, One, strconv};
use num::{ToStrRadix, FromStrRadix};
use option::{Option, Some, None};
use str;
use unstable::intrinsics;

pub use self::generated::*;

uint_module!(u64, i64, 64)

impl CheckedAdd for u64 {
Expand Down
11 changes: 9 additions & 2 deletions src/libstd/num/u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@

//! Operations and constants for `u8`

#[allow(non_uppercase_statics)];

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;

pub use self::generated::*;

uint_module!(u8, i8, 8)

impl CheckedAdd for u8 {
Expand Down
15 changes: 11 additions & 4 deletions src/libstd/num/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@

//! Operations and constants for `uint`

use num;
#[allow(non_uppercase_statics)];

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;
use mem;

pub use self::generated::*;

uint_module!(uint, int, ::int::bits)

Expand Down
17 changes: 2 additions & 15 deletions src/libstd/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,10 @@
// option. This file may not be copied, modified, or distributed
// 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];
#[doc(hidden)];

macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated {

#[allow(non_uppercase_statics)];

use default::Default;
use num::BitCount;
use num::{ToStrRadix, FromStrRadix};
use num::{CheckedDiv, Zero, One, strconv};
use prelude::*;
use str;
macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (

pub static bits : uint = $bits;
pub static bytes : uint = ($bits / 8);
Expand Down Expand Up @@ -554,4 +541,4 @@ mod tests {
}
}

}))
))

5 comments on commit 4840064

@bors
Copy link
Contributor

@bors bors commented on 4840064 Nov 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Kimundi@4840064

@bors
Copy link
Contributor

@bors bors commented on 4840064 Nov 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Kimundi/rust/switch_to_multi_item_macros = 4840064 into auto

@bors
Copy link
Contributor

@bors bors commented on 4840064 Nov 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimundi/rust/switch_to_multi_item_macros = 4840064 merged ok, testing candidate = 80991bb

@bors
Copy link
Contributor

@bors bors commented on 4840064 Nov 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4840064 Nov 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 80991bb

Please sign in to comment.