From 7abf6eb7c67dfb43540fdcafd6f1e69bdd2a6849 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 2 Nov 2010 17:20:57 -0700 Subject: Shift obj, type, param decls to have strata rather than effects. --- src/lib/_io.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/lib') diff --git a/src/lib/_io.rs b/src/lib/_io.rs index 0d968c5c..bbf5550d 100644 --- a/src/lib/_io.rs +++ b/src/lib/_io.rs @@ -3,13 +3,13 @@ import std._str; import std._vec; -type stdio_reader = unsafe obj { - fn getc() -> int; - fn ungetc(int i); +type stdio_reader = state obj { + fn getc() -> int; + fn ungetc(int i); }; fn new_stdio_reader(str path) -> stdio_reader { - unsafe obj stdio_FILE_reader(os.libc.FILE f) { + state obj stdio_FILE_reader(os.libc.FILE f) { fn getc() -> int { ret os.libc.fgetc(f); } @@ -25,12 +25,12 @@ fn new_stdio_reader(str path) -> stdio_reader { } -type buf_reader = unsafe obj { - fn read() -> vec[u8]; +type buf_reader = state obj { + fn read() -> vec[u8]; }; -type buf_writer = unsafe obj { - fn write(vec[u8] v); +type buf_writer = state obj { + fn write(vec[u8] v); }; fn default_bufsz() -> uint { @@ -43,7 +43,7 @@ fn new_buf() -> vec[u8] { fn new_buf_reader(str path) -> buf_reader { - unsafe obj fd_buf_reader(int fd, mutable vec[u8] buf) { + state obj fd_buf_reader(int fd, mutable vec[u8] buf) { fn read() -> vec[u8] { @@ -99,7 +99,7 @@ fn truncate() -> uint { ret 2u; } fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer { - unsafe obj fd_buf_writer(int fd) { + state obj fd_buf_writer(int fd) { fn write(vec[u8] v) { auto len = _vec.len[u8](v); @@ -152,17 +152,17 @@ fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer { } type writer = - unsafe obj { - fn write_str(str s); - fn write_int(int n); - fn write_uint(uint n); + state obj { + fn write_str(str s); + fn write_int(int n); + fn write_uint(uint n); }; fn file_writer(str path, vec[fileflag] flags) -> writer { - unsafe obj fw(buf_writer out) { + state obj fw(buf_writer out) { fn write_str(str s) { out.write(_str.bytes(s)); } fn write_int(int n) { out.write(_str.bytes(_int.to_str(n, 10u))); } fn write_uint(uint n) { out.write(_str.bytes(_uint.to_str(n, 10u))); } -- cgit v1.2.3