auto merge of #5456 : graydon/rust/fixups, r=pcwalton

Stage markers for stage3 and a trivial prelude fix.
This commit is contained in:
bors 2013-03-20 18:27:48 -07:00
commit a8527e2e97
7 changed files with 39 additions and 28 deletions

View file

@ -110,6 +110,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
// required.
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
pub impl<T: Owned> Chan<T> {
fn send(&self, x: T) { chan_send(self, x) }
fn try_send(&self, x: T) -> bool { chan_try_send(self, x) }
@ -149,6 +150,7 @@ fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
// Use an inherent impl so that imports are not required:
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
pub impl<T: Owned> Port<T> {
fn recv(&self) -> T { port_recv(self) }
fn try_recv(&self) -> Option<T> { port_try_recv(self) }
@ -226,6 +228,7 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
// Use an inherent impl so that imports are not required:
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
pub impl<T:Owned> PortSet<T> {
fn recv(&self) -> T { port_set_recv(self) }
fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }
@ -301,6 +304,7 @@ pub type SharedChan<T> = unstable::Exclusive<Chan<T>>;
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
pub impl<T: Owned> SharedChan<T> {
fn send(&self, x: T) { shared_chan_send(self, x) }
fn try_send(&self, x: T) -> bool { shared_chan_try_send(self, x) }

View file

@ -21,7 +21,9 @@ use libc;
use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
use libc::consts::os::posix88::*;
use os;
use prelude::*;
use cast;
use path::Path;
use ops::Drop;
use ptr;
use result;
use str;
@ -75,6 +77,7 @@ pub trait Reader {
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
impl Reader for @Reader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.read(bytes, len)
@ -657,6 +660,7 @@ pub trait Writer {
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
impl Writer for @Writer {
fn write(&self, v: &[const u8]) { self.write(v) }
fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }

View file

@ -43,6 +43,7 @@ pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
pub use vec::{CopyableVector, ImmutableVector};
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
pub use vec::{OwnedVector, OwnedCopyableVector};
pub use io::{Reader, ReaderUtil, Writer, WriterUtil};
/* Reexported runtime types */
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};

View file

@ -369,6 +369,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
fn mk_tests(cx: &TestCtxt) -> @ast::item {
let ext_cx = cx.ext_cx;

View file

@ -127,7 +127,7 @@ fn write_page(ctxt: &Ctxt, page: &doc::Page) {
write_item_no_header(ctxt, doc);
}
}
ctxt.w.write_done();
ctxt.w.put_done();
}
#[test]
@ -146,8 +146,8 @@ fn should_request_new_writer_for_each_page() {
}
fn write_title(ctxt: &Ctxt, page: doc::Page) {
ctxt.w.write_line(fmt!("%% %s", make_title(page)));
ctxt.w.write_line(~"");
ctxt.w.put_line(fmt!("%% %s", make_title(page)));
ctxt.w.put_line(~"");
}
fn make_title(page: doc::Page) -> ~str {
@ -198,8 +198,8 @@ fn write_header(ctxt: &Ctxt, lvl: Hlvl, doc: doc::ItemTag) {
fn write_header_(ctxt: &Ctxt, lvl: Hlvl, title: ~str) {
let hashes = str::from_chars(vec::from_elem(lvl as uint, '#'));
ctxt.w.write_line(fmt!("%s %s", hashes, title));
ctxt.w.write_line(~"");
ctxt.w.put_line(fmt!("%s %s", hashes, title));
ctxt.w.put_line(~"");
}
pub fn header_kind(doc: doc::ItemTag) -> ~str {
@ -332,8 +332,8 @@ fn write_desc(
) {
match desc {
Some(desc) => {
ctxt.w.write_line(desc);
ctxt.w.write_line(~"");
ctxt.w.put_line(desc);
ctxt.w.put_line(~"");
}
None => ()
}
@ -347,8 +347,8 @@ fn write_sections(ctxt: &Ctxt, sections: &[doc::Section]) {
fn write_section(ctxt: &Ctxt, section: doc::Section) {
write_header_(ctxt, H4, copy section.header);
ctxt.w.write_line(copy section.body);
ctxt.w.write_line(~"");
ctxt.w.put_line(copy section.body);
ctxt.w.put_line(~"");
}
#[test]
@ -398,7 +398,7 @@ fn write_item_(ctxt: &Ctxt, doc: doc::ItemTag, write_header: bool) {
doc::TraitTag(TraitDoc) => write_trait(ctxt, TraitDoc),
doc::ImplTag(ImplDoc) => write_impl(ctxt, ImplDoc),
doc::TyTag(TyDoc) => write_type(ctxt, TyDoc),
doc::StructTag(StructDoc) => write_struct(ctxt, StructDoc),
doc::StructTag(StructDoc) => put_struct(ctxt, StructDoc),
}
}
@ -428,13 +428,13 @@ fn write_index(ctxt: &Ctxt, index: doc::Index) {
let header = header_text_(entry.kind, entry.name);
let id = copy entry.link;
if entry.brief.is_some() {
ctxt.w.write_line(fmt!("* [%s](%s) - %s",
ctxt.w.put_line(fmt!("* [%s](%s) - %s",
header, id, (&entry.brief).get()));
} else {
ctxt.w.write_line(fmt!("* [%s](%s)", header, id));
ctxt.w.put_line(fmt!("* [%s](%s)", header, id));
}
}
ctxt.w.write_line(~"");
ctxt.w.put_line(~"");
}
#[test]
@ -526,8 +526,8 @@ fn write_fnlike(
fn write_sig(ctxt: &Ctxt, sig: Option<~str>) {
match sig {
Some(sig) => {
ctxt.w.write_line(code_block_indent(sig));
ctxt.w.write_line(~"");
ctxt.w.put_line(code_block_indent(sig));
ctxt.w.put_line(~"");
}
None => fail!(~"unimplemented")
}
@ -641,7 +641,7 @@ fn write_variants(
write_variant(ctxt, copy *variant);
}
ctxt.w.write_line(~"");
ctxt.w.put_line(~"");
}
fn write_variant(ctxt: &Ctxt, doc: doc::VariantDoc) {
@ -649,10 +649,10 @@ fn write_variant(ctxt: &Ctxt, doc: doc::VariantDoc) {
let sig = (&doc.sig).get();
match copy doc.desc {
Some(desc) => {
ctxt.w.write_line(fmt!("* `%s` - %s", sig, desc));
ctxt.w.put_line(fmt!("* `%s` - %s", sig, desc));
}
None => {
ctxt.w.write_line(fmt!("* `%s`", sig));
ctxt.w.put_line(fmt!("* `%s`", sig));
}
}
}
@ -804,7 +804,7 @@ fn should_write_type_signature() {
fail_unless!(str::contains(markdown, ~"\n\n type t = int\n\n"));
}
fn write_struct(
fn put_struct(
ctxt: &Ctxt,
doc: doc::StructDoc
) {
@ -813,7 +813,7 @@ fn write_struct(
}
#[test]
fn should_write_struct_header() {
fn should_put_struct_header() {
let markdown = test::render(~"struct S { field: () }");
fail_unless!(str::contains(markdown, ~"## Struct `S`\n\n"));
}

View file

@ -34,21 +34,21 @@ pub type Writer = ~fn(v: WriteInstr);
pub type WriterFactory = ~fn(page: doc::Page) -> Writer;
pub trait WriterUtils {
fn write_str(&self, +str: ~str);
fn write_line(&self, +str: ~str);
fn write_done(&self);
fn put_str(&self, +str: ~str);
fn put_line(&self, +str: ~str);
fn put_done(&self);
}
impl WriterUtils for Writer {
fn write_str(&self, str: ~str) {
fn put_str(&self, str: ~str) {
(*self)(Write(str));
}
fn write_line(&self, str: ~str) {
self.write_str(str + ~"\n");
fn put_line(&self, str: ~str) {
self.put_str(str + ~"\n");
}
fn write_done(&self) {
fn put_done(&self) {
(*self)(Done)
}
}

View file

@ -28,6 +28,7 @@ pub struct DuplexStream<T, U> {
// Allow these methods to be used without import:
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
fn send(&self, x: T) {
self.chan.send(x)