Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustdoc/astsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use parse;
use util;

use core::pipes::{stream, Chan, SharedChan, Port};
use core::oldcomm;
use core::vec;
use core::ops::Drop;
use rustc::back::link;
Expand Down
34 changes: 17 additions & 17 deletions src/librustdoc/markdown_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ use trim_pass;
use unindent_pass;

use core::iter;
use core::oldcomm;
use core::str;
use core::vec;
use std::par;
use std::cell::Cell;
use syntax;

pub fn mk_pass(writer_factory: WriterFactory) -> Pass {
let writer_factory = Cell(writer_factory);
let f = fn~(move writer_factory,
srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
run(srv, doc, copy writer_factory)
run(srv, doc, writer_factory.take())
};

Pass {
Expand Down Expand Up @@ -155,7 +156,7 @@ fn should_request_new_writer_for_each_page() {
write_markdown(doc, move writer_factory);
// We expect two pages to have been written
for iter::repeat(2) {
oldcomm::recv(po);
po.recv();
}
}

Expand Down Expand Up @@ -186,7 +187,7 @@ fn should_write_title_for_each_page() {
let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc);
write_markdown(doc, move writer_factory);
for iter::repeat(2) {
let (page, markdown) = oldcomm::recv(po);
let (page, markdown) = po.recv();
match page {
doc::CratePage(_) => {
assert str::contains(markdown, ~"% Crate core");
Expand Down Expand Up @@ -331,7 +332,7 @@ fn should_write_full_path_to_mod() {
assert str::contains(markdown, ~"# Module `a::b::c`");
}

fn write_oldcommon(
fn write_common(
ctxt: &Ctxt,
desc: Option<~str>,
sections: &[doc::Section]
Expand Down Expand Up @@ -380,7 +381,7 @@ fn write_mod_contents(
ctxt: &Ctxt,
doc: doc::ModDoc
) {
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
if doc.index.is_some() {
write_index(ctxt, (&doc.index).get());
}
Expand Down Expand Up @@ -483,7 +484,7 @@ fn should_write_index_for_foreign_mods() {
}

fn write_nmod(ctxt: &Ctxt, doc: doc::NmodDoc) {
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
if doc.index.is_some() {
write_index(ctxt, (&doc.index).get());
}
Expand Down Expand Up @@ -534,7 +535,7 @@ fn write_fnlike(
sections: &[doc::Section]
) {
write_sig(ctxt, sig);
write_oldcommon(ctxt, desc, sections);
write_common(ctxt, desc, sections);
}

fn write_sig(ctxt: &Ctxt, sig: Option<~str>) {
Expand Down Expand Up @@ -603,7 +604,7 @@ fn write_const(
doc: doc::ConstDoc
) {
write_sig(ctxt, copy doc.sig);
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
}

#[test]
Expand All @@ -624,7 +625,7 @@ fn write_enum(
ctxt: &Ctxt,
doc: doc::EnumDoc
) {
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
write_variants(ctxt, doc.variants);
}

Expand Down Expand Up @@ -705,7 +706,7 @@ fn should_write_variant_list_with_signatures() {
}

fn write_trait(ctxt: &Ctxt, doc: doc::TraitDoc) {
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
write_methods(ctxt, doc.methods);
}

Expand Down Expand Up @@ -753,7 +754,7 @@ fn should_write_trait_method_signature() {
}

fn write_impl(ctxt: &Ctxt, doc: doc::ImplDoc) {
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
write_methods(ctxt, doc.methods);
}

Expand Down Expand Up @@ -795,7 +796,7 @@ fn write_type(
doc: doc::TyDoc
) {
write_sig(ctxt, copy doc.sig);
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
}

#[test]
Expand All @@ -822,7 +823,7 @@ fn write_struct(
doc: doc::StructDoc
) {
write_sig(ctxt, copy doc.sig);
write_oldcommon(ctxt, doc.desc(), doc.sections());
write_common(ctxt, doc.desc(), doc.sections());
}

#[test]
Expand All @@ -848,7 +849,6 @@ mod test {
use tystr_pass;
use unindent_pass;

use core::oldcomm;
use core::path::Path;
use core::str;

Expand Down Expand Up @@ -900,7 +900,7 @@ mod test {
) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory();
write_markdown(doc, move writer_factory);
return oldcomm::recv(po).second();
return po.recv().second();
}

pub fn write_markdown_str_srv(
Expand All @@ -910,7 +910,7 @@ mod test {
let (writer_factory, po) = markdown_writer::future_writer_factory();
let pass = mk_pass(move writer_factory);
(pass.f)(srv, doc);
return oldcomm::recv(po).second();
return po.recv().second();
}

#[test]
Expand Down
21 changes: 8 additions & 13 deletions src/librustdoc/markdown_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use pass::Pass;
use core::io::ReaderUtil;
use core::io;
use core::libc;
use core::oldcomm;
use core::os;
use core::pipes;
use core::result;
use core::run;
use core::str;
use core::task;
use core::pipes::*;
use std::future;
use syntax;

Expand Down Expand Up @@ -168,12 +168,8 @@ fn readclose(fd: libc::c_int) -> ~str {
}

fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
let (setup_po, setup_ch) = pipes::stream();
let (po, ch) = stream::<WriteInstr>();
do task::spawn |move process, move setup_ch| {
let po: oldcomm::Port<WriteInstr> = oldcomm::Port();
let ch = oldcomm::Chan(&po);
setup_ch.send(ch);

let mut markdown = ~"";
let mut keep_going = true;
while keep_going {
Expand All @@ -184,10 +180,8 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
}
process(move markdown);
};
let ch = setup_po.recv();

fn~(instr: WriteInstr) {
oldcomm::send(ch, instr);
ch.send(instr);
}
}

Expand Down Expand Up @@ -298,16 +292,17 @@ fn write_file(path: &Path, s: ~str) {
}

pub fn future_writer_factory(
) -> (WriterFactory, oldcomm::Port<(doc::Page, ~str)>) {
let markdown_po = oldcomm::Port();
let markdown_ch = oldcomm::Chan(&markdown_po);
) -> (WriterFactory, Port<(doc::Page, ~str)>) {
let (markdown_po, markdown_ch) = stream();
let markdown_ch = SharedChan(markdown_ch);
let writer_factory = fn~(page: doc::Page) -> Writer {
let (writer_po, writer_ch) = pipes::stream();
let markdown_ch = markdown_ch.clone();
do task::spawn |move writer_ch| {
let (writer, future) = future_writer();
writer_ch.send(move writer);
let s = future.get();
oldcomm::send(markdown_ch, (copy page, s));
markdown_ch.send((copy page, s));
}
writer_po.recv()
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/text_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn fold_item(
}

fn apply_to_sections(
+op: NominalOp<Op>,
op: NominalOp<Op>,
sections: ~[doc::Section]
) -> ~[doc::Section] {
par::map(sections, |section, copy op| doc::Section {
Expand Down
25 changes: 0 additions & 25 deletions src/librustdoc/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use core::prelude::*;

use core::oldcomm;
use core::task;

// Just a named container for our op, so it can have impls
Expand All @@ -21,27 +20,3 @@ pub struct NominalOp<T> {
impl<T: Copy> NominalOp<T>: Clone {
fn clone(&self) -> NominalOp<T> { copy *self }
}

pub fn spawn_listener<A: Owned>(
f: fn~(oldcomm::Port<A>)) -> oldcomm::Chan<A> {
let setup_po = oldcomm::Port();
let setup_ch = oldcomm::Chan(&setup_po);
do task::spawn |move f| {
let po = oldcomm::Port();
let ch = oldcomm::Chan(&po);
oldcomm::send(setup_ch, ch);
f(move po);
}
oldcomm::recv(setup_po)
}

pub fn spawn_conversation<A: Owned, B: Owned>
(f: fn~(oldcomm::Port<A>, oldcomm::Chan<B>))
-> (oldcomm::Port<B>, oldcomm::Chan<A>) {
let from_child = oldcomm::Port();
let to_parent = oldcomm::Chan(&from_child);
let to_child = do spawn_listener |move f, from_parent| {
f(from_parent, to_parent)
};
(from_child, to_child)
}