2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-08-17 13:47:01 -05:00
|
|
|
// xfail-test - this isn't really a test.
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// select!
|
2012-08-22 19:47:11 -05:00
|
|
|
macro_rules! select_if (
|
2012-08-17 13:47:01 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr
|
|
|
|
} => {
|
2013-02-11 21:26:38 -06:00
|
|
|
fail!()
|
2012-08-17 13:47:01 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr,
|
|
|
|
$port:path => [
|
|
|
|
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
|
2013-02-15 04:44:18 -06:00
|
|
|
-> $next:ident => { $e:expr }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
]
|
|
|
|
$(, $ports:path => [
|
|
|
|
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
|
2013-02-15 04:44:18 -06:00
|
|
|
-> $nexts:ident => { $es:expr }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
] )*
|
|
|
|
} => {
|
|
|
|
if $index == $count {
|
2013-02-15 04:44:18 -06:00
|
|
|
match pipes::try_recv($port) {
|
|
|
|
$(Some($message($($($x,)+)* next)) => {
|
|
|
|
let $next = next;
|
|
|
|
$e
|
2012-08-17 13:47:01 -05:00
|
|
|
})+
|
2013-02-11 21:26:38 -06:00
|
|
|
_ => fail!()
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
|
|
|
} 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*
|
2013-02-15 04:44:18 -06:00
|
|
|
-> $nexts => { $es }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
])*
|
2012-08-22 19:24:52 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
|
|
|
};
|
2012-08-22 19:47:11 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
|
2012-08-22 19:47:11 -05:00
|
|
|
macro_rules! select (
|
2012-08-17 13:47:01 -05:00
|
|
|
{
|
|
|
|
$( $port:path => {
|
|
|
|
$($message:path$(($($x: ident),+))dont_type_this*
|
|
|
|
-> $next:ident $e:expr),+
|
|
|
|
} )+
|
|
|
|
} => {
|
2012-10-09 23:28:04 -05:00
|
|
|
let index = pipes::selecti([$(($port).header()),+]);
|
2012-08-22 19:24:52 -05:00
|
|
|
select_if!(index, 0 $(, $port => [
|
2013-02-15 04:44:18 -06: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
|
|
|
}
|
2012-08-22 19:47:11 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
|
|
|
|
}
|