1
Fork 0

De-export std::{time, prettyprint{,2}, arena}. Part of #3583.

This commit is contained in:
Graydon Hoare 2012-09-28 16:24:57 -07:00
parent 1948ddf583
commit e17d998e95
4 changed files with 17 additions and 39 deletions

View file

@ -24,8 +24,6 @@
#[forbid(deprecated_mode)]; #[forbid(deprecated_mode)];
export Arena, arena_with_size;
use list::{List, Cons, Nil}; use list::{List, Cons, Nil};
use cast::reinterpret_cast; use cast::reinterpret_cast;
use sys::TypeDesc; use sys::TypeDesc;
@ -33,12 +31,10 @@ use libc::size_t;
#[abi = "rust-intrinsic"] #[abi = "rust-intrinsic"]
extern mod rusti { extern mod rusti {
#[legacy_exports];
fn move_val_init<T>(&dst: T, -src: T); fn move_val_init<T>(&dst: T, -src: T);
fn needs_drop<T>() -> bool; fn needs_drop<T>() -> bool;
} }
extern mod rustrt { extern mod rustrt {
#[legacy_exports];
#[rust_stack] #[rust_stack]
fn rust_call_tydesc_glue(root: *u8, tydesc: *TypeDesc, field: size_t); fn rust_call_tydesc_glue(root: *u8, tydesc: *TypeDesc, field: size_t);
} }
@ -51,7 +47,7 @@ const tydesc_drop_glue_index: size_t = 3 as size_t;
// will always stay at 0. // will always stay at 0.
type Chunk = {data: @[u8], mut fill: uint, is_pod: bool}; type Chunk = {data: @[u8], mut fill: uint, is_pod: bool};
struct Arena { pub struct Arena {
// The head is seperated out from the list as a unbenchmarked // The head is seperated out from the list as a unbenchmarked
// microoptimization, to avoid needing to case on the list to // microoptimization, to avoid needing to case on the list to
// access the head. // access the head.
@ -74,13 +70,13 @@ fn chunk(size: uint, is_pod: bool) -> Chunk {
{ data: unsafe { cast::transmute(v) }, mut fill: 0u, is_pod: is_pod } { data: unsafe { cast::transmute(v) }, mut fill: 0u, is_pod: is_pod }
} }
fn arena_with_size(initial_size: uint) -> Arena { pub fn arena_with_size(initial_size: uint) -> Arena {
return Arena {mut head: chunk(initial_size, false), return Arena {mut head: chunk(initial_size, false),
mut pod_head: chunk(initial_size, true), mut pod_head: chunk(initial_size, true),
mut chunks: @Nil}; mut chunks: @Nil};
} }
fn Arena() -> Arena { pub fn Arena() -> Arena {
arena_with_size(32u) arena_with_size(32u)
} }

View file

@ -4,11 +4,11 @@ use io::Writer;
use io::WriterUtil; use io::WriterUtil;
use serialization2; use serialization2;
struct Serializer { pub struct Serializer {
wr: io::Writer, wr: io::Writer,
} }
fn Serializer(wr: io::Writer) -> Serializer { pub fn Serializer(wr: io::Writer) -> Serializer {
Serializer { wr: wr } Serializer { wr: wr }
} }

View file

@ -111,13 +111,9 @@ mod sha1;
mod md4; mod md4;
mod tempfile; mod tempfile;
mod term; mod term;
#[legacy_exports]
mod time; mod time;
#[legacy_exports]
mod prettyprint; mod prettyprint;
#[legacy_exports]
mod prettyprint2; mod prettyprint2;
#[legacy_exports]
mod arena; mod arena;
mod par; mod par;
mod cmp; mod cmp;

View file

@ -5,20 +5,6 @@ use libc::{c_char, c_int, c_long, size_t, time_t};
use io::{Reader, ReaderUtil}; use io::{Reader, ReaderUtil};
use result::{Result, Ok, Err}; use result::{Result, Ok, Err};
export
Timespec,
get_time,
precise_time_ns,
precise_time_s,
tzset,
Tm,
empty_tm,
now,
at,
now_utc,
at_utc,
strptime;
#[abi = "cdecl"] #[abi = "cdecl"]
extern mod rustrt { extern mod rustrt {
#[legacy_exports]; #[legacy_exports];
@ -34,7 +20,7 @@ extern mod rustrt {
} }
/// A record specifying a time value in seconds and nanoseconds. /// A record specifying a time value in seconds and nanoseconds.
type Timespec = {sec: i64, nsec: i32}; pub type Timespec = {sec: i64, nsec: i32};
impl Timespec : Eq { impl Timespec : Eq {
pure fn eq(other: &Timespec) -> bool { pure fn eq(other: &Timespec) -> bool {
@ -47,7 +33,7 @@ impl Timespec : Eq {
* Returns the current time as a `timespec` containing the seconds and * Returns the current time as a `timespec` containing the seconds and
* nanoseconds since 1970-01-01T00:00:00Z. * nanoseconds since 1970-01-01T00:00:00Z.
*/ */
fn get_time() -> Timespec { pub fn get_time() -> Timespec {
let mut sec = 0i64; let mut sec = 0i64;
let mut nsec = 0i32; let mut nsec = 0i32;
rustrt::get_time(sec, nsec); rustrt::get_time(sec, nsec);
@ -58,7 +44,7 @@ fn get_time() -> Timespec {
* Returns the current value of a high-resolution performance counter * Returns the current value of a high-resolution performance counter
* in nanoseconds since an unspecified epoch. * in nanoseconds since an unspecified epoch.
*/ */
fn precise_time_ns() -> u64 { pub fn precise_time_ns() -> u64 {
let mut ns = 0u64; let mut ns = 0u64;
rustrt::precise_time_ns(ns); rustrt::precise_time_ns(ns);
ns ns
@ -68,11 +54,11 @@ fn precise_time_ns() -> u64 {
* Returns the current value of a high-resolution performance counter * Returns the current value of a high-resolution performance counter
* in seconds since an unspecified epoch. * in seconds since an unspecified epoch.
*/ */
fn precise_time_s() -> float { pub fn precise_time_s() -> float {
return (precise_time_ns() as float) / 1000000000.; return (precise_time_ns() as float) / 1000000000.;
} }
fn tzset() { pub fn tzset() {
rustrt::rust_tzset(); rustrt::rust_tzset();
} }
@ -109,7 +95,7 @@ impl Tm_ : Eq {
pure fn ne(other: &Tm_) -> bool { !self.eq(other) } pure fn ne(other: &Tm_) -> bool { !self.eq(other) }
} }
enum Tm { pub enum Tm {
Tm_(Tm_) Tm_(Tm_)
} }
@ -118,7 +104,7 @@ impl Tm : Eq {
pure fn ne(other: &Tm) -> bool { *self != *(*other) } pure fn ne(other: &Tm) -> bool { *self != *(*other) }
} }
fn empty_tm() -> Tm { pub fn empty_tm() -> Tm {
Tm_({ Tm_({
tm_sec: 0_i32, tm_sec: 0_i32,
tm_min: 0_i32, tm_min: 0_i32,
@ -136,7 +122,7 @@ fn empty_tm() -> Tm {
} }
/// Returns the specified time in UTC /// Returns the specified time in UTC
fn at_utc(clock: Timespec) -> Tm { pub fn at_utc(clock: Timespec) -> Tm {
let mut {sec, nsec} = clock; let mut {sec, nsec} = clock;
let mut tm = empty_tm(); let mut tm = empty_tm();
rustrt::rust_gmtime(sec, nsec, tm); rustrt::rust_gmtime(sec, nsec, tm);
@ -144,12 +130,12 @@ fn at_utc(clock: Timespec) -> Tm {
} }
/// Returns the current time in UTC /// Returns the current time in UTC
fn now_utc() -> Tm { pub fn now_utc() -> Tm {
at_utc(get_time()) at_utc(get_time())
} }
/// Returns the specified time in the local timezone /// Returns the specified time in the local timezone
fn at(clock: Timespec) -> Tm { pub fn at(clock: Timespec) -> Tm {
let mut {sec, nsec} = clock; let mut {sec, nsec} = clock;
let mut tm = empty_tm(); let mut tm = empty_tm();
rustrt::rust_localtime(sec, nsec, tm); rustrt::rust_localtime(sec, nsec, tm);
@ -157,12 +143,12 @@ fn at(clock: Timespec) -> Tm {
} }
/// Returns the current time in the local timezone /// Returns the current time in the local timezone
fn now() -> Tm { pub fn now() -> Tm {
at(get_time()) at(get_time())
} }
/// Parses the time from the string according to the format string. /// Parses the time from the string according to the format string.
fn strptime(s: &str, format: &str) -> Result<Tm, ~str> { pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
type TmMut = { type TmMut = {
mut tm_sec: i32, mut tm_sec: i32,
mut tm_min: i32, mut tm_min: i32,