Modify pipec to not emit calls to some and none
This commit is contained in:
@@ -97,6 +97,9 @@ export stream, port, chan, shared_chan, port_set, channel;
|
|||||||
export oneshot, chan_one, port_one;
|
export oneshot, chan_one, port_one;
|
||||||
export recv_one, try_recv_one, send_one, try_send_one;
|
export recv_one, try_recv_one, send_one, try_send_one;
|
||||||
|
|
||||||
|
// Functions used by the protocol compiler
|
||||||
|
export rt;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
const SPIN_COUNT: uint = 0;
|
const SPIN_COUNT: uint = 0;
|
||||||
|
|
||||||
@@ -1194,6 +1197,13 @@ fn try_send_one<T: send>(+chan: chan_one<T>, +data: T)
|
|||||||
oneshot::client::try_send(chan, data).is_some()
|
oneshot::client::try_send(chan, data).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod rt {
|
||||||
|
// These are used to hide the option constructors from the
|
||||||
|
// compiler because their names are changing
|
||||||
|
fn make_some<T>(+val: T) -> option<T> { some(val) }
|
||||||
|
fn make_none<T>() -> option<T> { none }
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ impl message: gen_send {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
body += fmt!("if pipes::send(pipe, message) {\n \
|
body += fmt!("if pipes::send(pipe, message) {\n \
|
||||||
some(c) \
|
pipes::rt::make_some(c) \
|
||||||
} else { none } }");
|
} else { pipes::rt::make_none() } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = cx.parse_expr(body);
|
let body = cx.parse_expr(body);
|
||||||
@@ -163,8 +163,8 @@ impl message: gen_send {
|
|||||||
body += ~" }";
|
body += ~" }";
|
||||||
} else {
|
} else {
|
||||||
body += fmt!("if pipes::send(pipe, message) { \
|
body += fmt!("if pipes::send(pipe, message) { \
|
||||||
some(()) \
|
pipes::rt::make_some(()) \
|
||||||
} else { none } }");
|
} else { pipes::rt::make_none() } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = cx.parse_expr(body);
|
let body = cx.parse_expr(body);
|
||||||
|
|||||||
Reference in New Issue
Block a user