2012-08-17 13:47:01 -05:00
|
|
|
// xfail-test - this isn't really a test.
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// select!
|
|
|
|
macro_rules! select_if {
|
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr
|
|
|
|
} => {
|
|
|
|
fail
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr,
|
|
|
|
$port:path => [
|
|
|
|
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
|
|
|
|
-> $next:ident => { $e:expr }),+
|
|
|
|
]
|
|
|
|
$(, $ports:path => [
|
|
|
|
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
|
|
|
|
-> $nexts:ident => { $es:expr }),+
|
|
|
|
] )*
|
|
|
|
} => {
|
|
|
|
if $index == $count {
|
|
|
|
match move pipes::try_recv($port) {
|
|
|
|
$(some($message($($(ref $x,)+)* ref next)) => {
|
|
|
|
// FIXME (#2329) we really want move out of enum here.
|
|
|
|
let $next = unsafe { let x <- *ptr::addr_of(*next); x };
|
|
|
|
$e
|
|
|
|
})+
|
|
|
|
_ => fail
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 19:24:52 -05:00
|
|
|
select_if!(
|
2012-08-17 13:47:01 -05:00
|
|
|
$index,
|
|
|
|
$count + 1
|
|
|
|
$(, $ports => [
|
|
|
|
$(type_this $messages$(($(x $xs),+))dont_type_this*
|
|
|
|
-> $nexts => { $es }),+
|
|
|
|
])*
|
2012-08-22 19:24:52 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! select {
|
|
|
|
{
|
|
|
|
$( $port:path => {
|
|
|
|
$($message:path$(($($x: ident),+))dont_type_this*
|
|
|
|
-> $next:ident $e:expr),+
|
|
|
|
} )+
|
|
|
|
} => {
|
|
|
|
let index = pipes::selecti([$(($port).header()),+]/_);
|
2012-08-22 19:24:52 -05:00
|
|
|
select_if!(index, 0 $(, $port => [
|
2012-08-17 13:47:01 -05:00
|
|
|
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
|
2012-08-22 19:24:52 -05:00
|
|
|
])+)
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|