Skip to content

Commit db44dc5

Browse files
committed
De-export gc and io. Part of #3583.
1 parent 8cc61c8 commit db44dc5

File tree

2 files changed

+48
-50
lines changed

2 files changed

+48
-50
lines changed

src/libcore/core.rc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ mod pipes;
248248

249249
// Runtime and language-primitive support
250250

251-
#[legacy_exports]
252251
mod gc;
253-
#[legacy_exports]
254252
mod io;
255253
mod libc;
256254
mod os;

src/libcore/io.rs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type fd_t = c_int;
1717

1818
#[abi = "cdecl"]
1919
extern mod rustrt {
20-
#[legacy_exports];
2120
fn rust_get_stdin() -> *libc::FILE;
2221
fn rust_get_stdout() -> *libc::FILE;
2322
fn rust_get_stderr() -> *libc::FILE;
@@ -27,11 +26,11 @@ extern mod rustrt {
2726

2827
// FIXME (#2004): This is all buffered. We might need an unbuffered variant
2928
// as well
30-
enum SeekStyle { SeekSet, SeekEnd, SeekCur, }
29+
pub enum SeekStyle { SeekSet, SeekEnd, SeekCur, }
3130

3231

3332
// The raw underlying reader trait. All readers must implement this.
34-
trait Reader {
33+
pub trait Reader {
3534
// FIXME (#2004): Seekable really should be orthogonal.
3635

3736
// FIXME (#2982): This should probably return an error.
@@ -45,7 +44,7 @@ trait Reader {
4544

4645
// Generic utility functions defined on readers
4746

48-
trait ReaderUtil {
47+
pub trait ReaderUtil {
4948
fn read_bytes(len: uint) -> ~[u8];
5049
fn read_line() -> ~str;
5150

@@ -267,7 +266,7 @@ fn FILERes(f: *libc::FILE) -> FILERes {
267266
}
268267
}
269268

270-
fn FILE_reader(f: *libc::FILE, cleanup: bool) -> Reader {
269+
pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> Reader {
271270
if cleanup {
272271
{base: f, cleanup: FILERes(f)} as Reader
273272
} else {
@@ -279,9 +278,9 @@ fn FILE_reader(f: *libc::FILE, cleanup: bool) -> Reader {
279278
// top-level functions that take a reader, or a set of default methods on
280279
// reader (which can then be called reader)
281280

282-
fn stdin() -> Reader { rustrt::rust_get_stdin() as Reader }
281+
pub fn stdin() -> Reader { rustrt::rust_get_stdin() as Reader }
283282

284-
fn file_reader(path: &Path) -> Result<Reader, ~str> {
283+
pub fn file_reader(path: &Path) -> Result<Reader, ~str> {
285284
let f = os::as_c_charp(path.to_str(), |pathbuf| {
286285
os::as_c_charp("r", |modebuf|
287286
libc::fopen(pathbuf, modebuf)
@@ -297,7 +296,7 @@ fn file_reader(path: &Path) -> Result<Reader, ~str> {
297296
298297
// Byte buffer readers
299298
300-
type ByteBuf = {buf: &[const u8], mut pos: uint};
299+
pub type ByteBuf = {buf: &[const u8], mut pos: uint};
301300
302301
impl ByteBuf: Reader {
303302
fn read(buf: &[mut u8], len: uint) -> uint {
@@ -326,21 +325,21 @@ impl ByteBuf: Reader {
326325
fn tell() -> uint { self.pos }
327326
}
328327

329-
fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
328+
pub fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
330329
f({buf: bytes, mut pos: 0u} as Reader)
331330
}
332331

333-
fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
332+
pub fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
334333
str::byte_slice(s, |bytes| with_bytes_reader(bytes, f))
335334
}
336335

337336
// Writing
338-
enum FileFlag { Append, Create, Truncate, NoFlag, }
337+
pub enum FileFlag { Append, Create, Truncate, NoFlag, }
339338

340339
// What type of writer are we?
341-
enum WriterType { Screen, File }
340+
pub enum WriterType { Screen, File }
342341

343-
impl WriterType : Eq {
342+
pub impl WriterType : Eq {
344343
pure fn eq(other: &WriterType) -> bool {
345344
match (self, (*other)) {
346345
(Screen, Screen) | (File, File) => true,
@@ -352,7 +351,7 @@ impl WriterType : Eq {
352351

353352
// FIXME (#2004): Seekable really should be orthogonal.
354353
// FIXME (#2004): eventually u64
355-
trait Writer {
354+
pub trait Writer {
356355
fn write(v: &[const u8]);
357356
fn seek(int, SeekStyle);
358357
fn tell() -> uint;
@@ -393,7 +392,7 @@ impl *libc::FILE: Writer {
393392
}
394393
}
395394

396-
fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
395+
pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
397396
if cleanup {
398397
{base: f, cleanup: FILERes(f)} as Writer
399398
} else {
@@ -442,7 +441,7 @@ fn FdRes(fd: fd_t) -> FdRes {
442441
}
443442
}
444443

445-
fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
444+
pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
446445
if cleanup {
447446
{base: fd, cleanup: FdRes(fd)} as Writer
448447
} else {
@@ -451,7 +450,7 @@ fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
451450
}
452451

453452

454-
fn mk_file_writer(path: &Path, flags: &[FileFlag])
453+
pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
455454
-> Result<Writer, ~str> {
456455

457456
#[cfg(windows)]
@@ -481,7 +480,8 @@ fn mk_file_writer(path: &Path, flags: &[FileFlag])
481480
}
482481
}
483482

484-
fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T {
483+
pub fn u64_to_le_bytes<T>(n: u64, size: uint,
484+
f: fn(v: &[u8]) -> T) -> T {
485485
assert size <= 8u;
486486
match size {
487487
1u => f(&[n as u8]),
@@ -512,7 +512,8 @@ fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T {
512512
}
513513
}
514514

515-
fn u64_to_be_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T {
515+
pub fn u64_to_be_bytes<T>(n: u64, size: uint,
516+
f: fn(v: &[u8]) -> T) -> T {
516517
assert size <= 8u;
517518
match size {
518519
1u => f(&[n as u8]),
@@ -543,7 +544,8 @@ fn u64_to_be_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T {
543544
}
544545
}
545546

546-
fn u64_from_be_bytes(data: &[const u8], start: uint, size: uint) -> u64 {
547+
pub fn u64_from_be_bytes(data: &[const u8],
548+
start: uint, size: uint) -> u64 {
547549
let mut sz = size;
548550
assert (sz <= 8u);
549551
let mut val = 0_u64;
@@ -558,7 +560,7 @@ fn u64_from_be_bytes(data: &[const u8], start: uint, size: uint) -> u64 {
558560

559561
// FIXME: #3048 combine trait+impl (or just move these to
560562
// default methods on writer)
561-
trait WriterUtil {
563+
pub trait WriterUtil {
562564
fn write_char(ch: char);
563565
fn write_str(s: &str);
564566
fn write_line(s: &str);
@@ -655,13 +657,13 @@ impl<T: Writer> T : WriterUtil {
655657
}
656658

657659
#[allow(non_implicitly_copyable_typarams)]
658-
fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<Writer, ~str> {
660+
pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<Writer, ~str> {
659661
mk_file_writer(path, flags).chain(|w| result::Ok(w))
660662
}
661663

662664

663665
// FIXME: fileflags // #2004
664-
fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
666+
pub fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
665667
let f = do os::as_c_charp(path.to_str()) |pathbuf| {
666668
do os::as_c_charp("w") |modebuf| {
667669
libc::fopen(pathbuf, modebuf)
@@ -675,13 +677,13 @@ fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
675677
// FIXME (#2004) it would be great if this could be a const
676678
// FIXME (#2004) why are these different from the way stdin() is
677679
// implemented?
678-
fn stdout() -> Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
679-
fn stderr() -> Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
680+
pub fn stdout() -> Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
681+
pub fn stderr() -> Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
680682
681-
fn print(s: &str) { stdout().write_str(s); }
682-
fn println(s: &str) { stdout().write_line(s); }
683+
pub fn print(s: &str) { stdout().write_str(s); }
684+
pub fn println(s: &str) { stdout().write_line(s); }
683685
684-
struct BytesWriter {
686+
pub struct BytesWriter {
685687
buf: DVec<u8>,
686688
mut pos: uint,
687689
}
@@ -725,17 +727,17 @@ impl @BytesWriter : Writer {
725727
fn get_type() -> WriterType { (*self).get_type() }
726728
}
727729
728-
fn BytesWriter() -> BytesWriter {
730+
pub fn BytesWriter() -> BytesWriter {
729731
BytesWriter { buf: DVec(), mut pos: 0u }
730732
}
731733
732-
fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
734+
pub fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
733735
let wr = @BytesWriter();
734736
f(wr as Writer);
735737
wr.buf.check_out(|buf| buf)
736738
}
737739
738-
fn with_str_writer(f: fn(Writer)) -> ~str {
740+
pub fn with_str_writer(f: fn(Writer)) -> ~str {
739741
let mut v = with_bytes_writer(f);
740742
741743
// Make sure the vector has a trailing null and is proper utf8.
@@ -746,7 +748,7 @@ fn with_str_writer(f: fn(Writer)) -> ~str {
746748
}
747749
748750
// Utility functions
749-
fn seek_in_buf(offset: int, pos: uint, len: uint, whence: SeekStyle) ->
751+
pub fn seek_in_buf(offset: int, pos: uint, len: uint, whence: SeekStyle) ->
750752
uint {
751753
let mut bpos = pos as int;
752754
let blen = len as int;
@@ -760,7 +762,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: SeekStyle) ->
760762
}
761763
762764
#[allow(non_implicitly_copyable_typarams)]
763-
fn read_whole_file_str(file: &Path) -> Result<~str, ~str> {
765+
pub fn read_whole_file_str(file: &Path) -> Result<~str, ~str> {
764766
result::chain(read_whole_file(file), |bytes| {
765767
if str::is_utf8(bytes) {
766768
result::Ok(str::from_bytes(bytes))
@@ -773,18 +775,17 @@ fn read_whole_file_str(file: &Path) -> Result<~str, ~str> {
773775
// FIXME (#2004): implement this in a low-level way. Going through the
774776
// abstractions is pointless.
775777
#[allow(non_implicitly_copyable_typarams)]
776-
fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
778+
pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
777779
result::chain(file_reader(file), |rdr| {
778780
result::Ok(rdr.read_whole_stream())
779781
})
780782
}
781783

782784
// fsync related
783785

784-
mod fsync {
785-
#[legacy_exports];
786+
pub mod fsync {
786787

787-
enum Level {
788+
pub enum Level {
788789
// whatever fsync does on that platform
789790
FSync,
790791

@@ -799,7 +800,7 @@ mod fsync {
799800

800801

801802
// Artifacts that need to fsync on destruction
802-
struct Res<t: Copy> {
803+
pub struct Res<t: Copy> {
803804
arg: Arg<t>,
804805
drop {
805806
match self.arg.opt_level {
@@ -812,13 +813,13 @@ mod fsync {
812813
}
813814
}
814815

815-
fn Res<t: Copy>(+arg: Arg<t>) -> Res<t>{
816+
pub fn Res<t: Copy>(+arg: Arg<t>) -> Res<t>{
816817
Res {
817818
arg: move arg
818819
}
819820
}
820821

821-
type Arg<t> = {
822+
pub type Arg<t> = {
822823
val: t,
823824
opt_level: Option<Level>,
824825
fsync_fn: fn@(+f: t, Level) -> int
@@ -827,8 +828,8 @@ mod fsync {
827828
// fsync file after executing blk
828829
// FIXME (#2004) find better way to create resources within lifetime of
829830
// outer res
830-
fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
831-
blk: fn(+v: Res<*libc::FILE>)) {
831+
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
832+
blk: fn(+v: Res<*libc::FILE>)) {
832833
blk(move Res({
833834
val: file.f, opt_level: opt_level,
834835
fsync_fn: fn@(+file: *libc::FILE, l: Level) -> int {
@@ -838,8 +839,8 @@ mod fsync {
838839
}
839840

840841
// fsync fd after executing blk
841-
fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
842-
blk: fn(+v: Res<fd_t>)) {
842+
pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
843+
blk: fn(+v: Res<fd_t>)) {
843844
blk(move Res({
844845
val: fd.fd, opt_level: opt_level,
845846
fsync_fn: fn@(+fd: fd_t, l: Level) -> int {
@@ -849,11 +850,11 @@ mod fsync {
849850
}
850851

851852
// Type of objects that may want to fsync
852-
trait FSyncable { fn fsync(l: Level) -> int; }
853+
pub trait FSyncable { fn fsync(l: Level) -> int; }
853854

854855
// Call o.fsync after executing blk
855-
fn obj_sync(+o: FSyncable, opt_level: Option<Level>,
856-
blk: fn(+v: Res<FSyncable>)) {
856+
pub fn obj_sync(+o: FSyncable, opt_level: Option<Level>,
857+
blk: fn(+v: Res<FSyncable>)) {
857858
blk(Res({
858859
val: o, opt_level: opt_level,
859860
fsync_fn: fn@(+o: FSyncable, l: Level) -> int {
@@ -865,7 +866,6 @@ mod fsync {
865866

866867
#[cfg(test)]
867868
mod tests {
868-
#[legacy_exports];
869869

870870
#[test]
871871
fn test_simple() {

0 commit comments

Comments
 (0)