From 86041c421dc5782bf48cdac4a4bc49dc1e50b360 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 27 Sep 2012 18:03:00 -0700 Subject: [PATCH] De-export std::{dbg,sha1,md4,tempfile,term}. Part of #3583. --- src/libstd/dbg.rs | 21 ++++++------------ src/libstd/md4.rs | 6 +++--- src/libstd/sha1.rs | 3 +-- src/libstd/std.rc | 5 ----- src/libstd/tempfile.rs | 2 +- src/libstd/term.rs | 48 +++++++++++++++++++++--------------------- 6 files changed, 36 insertions(+), 49 deletions(-) diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 2b9df33b2d4..ac343053bed 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -4,13 +4,6 @@ use cast::reinterpret_cast; -export debug_tydesc; -export debug_opaque; -export debug_box; -export debug_tag; -export debug_fn; -export ptr_cast; -export breakpoint; #[abi = "cdecl"] extern mod rustrt { @@ -24,34 +17,34 @@ extern mod rustrt { fn rust_dbg_breakpoint(); } -fn debug_tydesc() { +pub fn debug_tydesc() { rustrt::debug_tydesc(sys::get_type_desc::()); } -fn debug_opaque(+x: T) { +pub fn debug_opaque(+x: T) { rustrt::debug_opaque(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_box(x: @T) { +pub fn debug_box(x: @T) { rustrt::debug_box(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_tag(+x: T) { +pub fn debug_tag(+x: T) { rustrt::debug_tag(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_fn(+x: T) { +pub fn debug_fn(+x: T) { rustrt::debug_fn(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -unsafe fn ptr_cast(x: @T) -> @U { +pub unsafe fn ptr_cast(x: @T) -> @U { reinterpret_cast( &rustrt::debug_ptrcast(sys::get_type_desc::(), reinterpret_cast(&x))) } /// Triggers a debugger breakpoint -fn breakpoint() { +pub fn breakpoint() { rustrt::rust_dbg_breakpoint(); } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 0bf4f6f8610..6de6ea8b16c 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -1,7 +1,7 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; -fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { +pub fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { // subtle: if orig_len is merely uint, then the code below // which performs shifts by 32 bits or more has undefined // results. @@ -85,7 +85,7 @@ fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { return {a: a, b: b, c: c, d: d}; } -fn md4_str(msg: &[u8]) -> ~str { +pub fn md4_str(msg: &[u8]) -> ~str { let {a, b, c, d} = md4(msg); fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); @@ -103,7 +103,7 @@ fn md4_str(msg: &[u8]) -> ~str { result } -fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } +pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } #[test] fn test_md4() { diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index a40db2c1f1f..178bf2be7fe 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -20,7 +20,6 @@ * implementation, which is written for clarity, not speed. At some * point this will want to be rewritten. */ -export sha1; /// The SHA-1 interface trait Sha1 { @@ -53,7 +52,7 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object -fn sha1() -> Sha1 { +pub fn sha1() -> Sha1 { type Sha1State = {h: ~[mut u32], mut len_low: u32, diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 2f75ae07c84..fba3f85ae5d 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -110,19 +110,14 @@ mod treemap; mod ebml; #[legacy_exports] mod ebml2; -#[legacy_exports] mod dbg; #[legacy_exports] mod getopts; #[legacy_exports] mod json; -#[legacy_exports] mod sha1; -#[legacy_exports] mod md4; -#[legacy_exports] mod tempfile; -#[legacy_exports] mod term; #[legacy_exports] mod time; diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 8b6b306d6b6..5c59bc02cb7 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -6,7 +6,7 @@ use core::option; use option::{None, Some}; -fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { +pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { let r = rand::Rng(); let mut i = 0u; while (i < 1000u) { diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 6a264161bc7..af7fde5a174 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -6,35 +6,35 @@ use core::Option; // FIXME (#2807): Windows support. -const color_black: u8 = 0u8; -const color_red: u8 = 1u8; -const color_green: u8 = 2u8; -const color_yellow: u8 = 3u8; -const color_blue: u8 = 4u8; -const color_magenta: u8 = 5u8; -const color_cyan: u8 = 6u8; -const color_light_gray: u8 = 7u8; -const color_light_grey: u8 = 7u8; -const color_dark_gray: u8 = 8u8; -const color_dark_grey: u8 = 8u8; -const color_bright_red: u8 = 9u8; -const color_bright_green: u8 = 10u8; -const color_bright_yellow: u8 = 11u8; -const color_bright_blue: u8 = 12u8; -const color_bright_magenta: u8 = 13u8; -const color_bright_cyan: u8 = 14u8; -const color_bright_white: u8 = 15u8; +pub const color_black: u8 = 0u8; +pub const color_red: u8 = 1u8; +pub const color_green: u8 = 2u8; +pub const color_yellow: u8 = 3u8; +pub const color_blue: u8 = 4u8; +pub const color_magenta: u8 = 5u8; +pub const color_cyan: u8 = 6u8; +pub const color_light_gray: u8 = 7u8; +pub const color_light_grey: u8 = 7u8; +pub const color_dark_gray: u8 = 8u8; +pub const color_dark_grey: u8 = 8u8; +pub const color_bright_red: u8 = 9u8; +pub const color_bright_green: u8 = 10u8; +pub const color_bright_yellow: u8 = 11u8; +pub const color_bright_blue: u8 = 12u8; +pub const color_bright_magenta: u8 = 13u8; +pub const color_bright_cyan: u8 = 14u8; +pub const color_bright_white: u8 = 15u8; -fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } +pub fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } /// Reset the foreground and background colors to default -fn reset(writer: io::Writer) { +pub fn reset(writer: io::Writer) { esc(writer); writer.write(~['0' as u8, 'm' as u8]); } /// Returns true if the terminal supports color -fn color_supported() -> bool { +pub fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; return match os::getenv(~"TERM") { @@ -48,7 +48,7 @@ fn color_supported() -> bool { }; } -fn set_color(writer: io::Writer, first_char: u8, color: u8) { +pub fn set_color(writer: io::Writer, first_char: u8, color: u8) { assert (color < 16u8); esc(writer); let mut color = color; @@ -57,12 +57,12 @@ fn set_color(writer: io::Writer, first_char: u8, color: u8) { } /// Set the foreground color -fn fg(writer: io::Writer, color: u8) { +pub fn fg(writer: io::Writer, color: u8) { return set_color(writer, '3' as u8, color); } /// Set the background color -fn bg(writer: io::Writer, color: u8) { +pub fn bg(writer: io::Writer, color: u8) { return set_color(writer, '4' as u8, color); }