Remove by-copy mode from std, mostly
One instance remains in net_tcp due to a foreign fn. Lots of instances remain in serialization.rs, but IIRC that is being removed. I had to do unholy things to task-perf-word-count-generic to get it to compile after demoding pipes. I may well have messed up its performance, but it passes.
This commit is contained in:
@@ -87,7 +87,7 @@ pub fn from_port<A:Send>(port: future_pipe::client::waiting<A>) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_fn<A>(+f: ~fn() -> A) -> Future<A> {
|
pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
|
||||||
/*!
|
/*!
|
||||||
* Create a future from a function.
|
* Create a future from a function.
|
||||||
*
|
*
|
||||||
@@ -99,7 +99,7 @@ pub fn from_fn<A>(+f: ~fn() -> A) -> Future<A> {
|
|||||||
Future {state: Pending(move f)}
|
Future {state: Pending(move f)}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn<A:Send>(+blk: fn~() -> A) -> Future<A> {
|
pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
|
||||||
/*!
|
/*!
|
||||||
* Create a future from a unique closure.
|
* Create a future from a unique closure.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -860,7 +860,7 @@ endpoint is passed to the new task.
|
|||||||
pub fn spawn_service<T: Send, Tb: Send>(
|
pub fn spawn_service<T: Send, Tb: Send>(
|
||||||
init: extern fn() -> (SendPacketBuffered<T, Tb>,
|
init: extern fn() -> (SendPacketBuffered<T, Tb>,
|
||||||
RecvPacketBuffered<T, Tb>),
|
RecvPacketBuffered<T, Tb>),
|
||||||
+service: fn~(v: RecvPacketBuffered<T, Tb>))
|
service: fn~(v: RecvPacketBuffered<T, Tb>))
|
||||||
-> SendPacketBuffered<T, Tb>
|
-> SendPacketBuffered<T, Tb>
|
||||||
{
|
{
|
||||||
let (client, server) = init();
|
let (client, server) = init();
|
||||||
@@ -884,7 +884,7 @@ receive state.
|
|||||||
pub fn spawn_service_recv<T: Send, Tb: Send>(
|
pub fn spawn_service_recv<T: Send, Tb: Send>(
|
||||||
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
|
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
|
||||||
SendPacketBuffered<T, Tb>),
|
SendPacketBuffered<T, Tb>),
|
||||||
+service: fn~(v: SendPacketBuffered<T, Tb>))
|
service: fn~(v: SendPacketBuffered<T, Tb>))
|
||||||
-> RecvPacketBuffered<T, Tb>
|
-> RecvPacketBuffered<T, Tb>
|
||||||
{
|
{
|
||||||
let (client, server) = init();
|
let (client, server) = init();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type GlobalPtr = *libc::uintptr_t;
|
|||||||
pub unsafe fn chan_from_global_ptr<T: Send>(
|
pub unsafe fn chan_from_global_ptr<T: Send>(
|
||||||
global: GlobalPtr,
|
global: GlobalPtr,
|
||||||
task_fn: fn() -> task::TaskBuilder,
|
task_fn: fn() -> task::TaskBuilder,
|
||||||
+f: fn~(comm::Port<T>)
|
f: fn~(comm::Port<T>)
|
||||||
) -> comm::Chan<T> {
|
) -> comm::Chan<T> {
|
||||||
|
|
||||||
enum Msg {
|
enum Msg {
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ pub type TaskOpts = {
|
|||||||
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
|
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
|
||||||
pub enum TaskBuilder = {
|
pub enum TaskBuilder = {
|
||||||
opts: TaskOpts,
|
opts: TaskOpts,
|
||||||
gen_body: fn@(+v: fn~()) -> fn~(),
|
gen_body: fn@(v: fn~()) -> fn~(),
|
||||||
can_not_copy: Option<util::NonCopyable>,
|
can_not_copy: Option<util::NonCopyable>,
|
||||||
mut consumed: bool,
|
mut consumed: bool,
|
||||||
};
|
};
|
||||||
@@ -233,7 +233,7 @@ pub enum TaskBuilder = {
|
|||||||
pub fn task() -> TaskBuilder {
|
pub fn task() -> TaskBuilder {
|
||||||
TaskBuilder({
|
TaskBuilder({
|
||||||
opts: default_task_opts(),
|
opts: default_task_opts(),
|
||||||
gen_body: |+body| move body, // Identity function
|
gen_body: |body| move body, // Identity function
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
mut consumed: false,
|
mut consumed: false,
|
||||||
})
|
})
|
||||||
@@ -410,7 +410,7 @@ impl TaskBuilder {
|
|||||||
* generator by applying the task body which results from the
|
* generator by applying the task body which results from the
|
||||||
* existing body generator to the new body generator.
|
* existing body generator to the new body generator.
|
||||||
*/
|
*/
|
||||||
fn add_wrapper(wrapper: fn@(+v: fn~()) -> fn~()) -> TaskBuilder {
|
fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> TaskBuilder {
|
||||||
let prev_gen_body = self.gen_body;
|
let prev_gen_body = self.gen_body;
|
||||||
let notify_chan = if self.opts.notify_chan.is_none() {
|
let notify_chan = if self.opts.notify_chan.is_none() {
|
||||||
None
|
None
|
||||||
@@ -442,7 +442,7 @@ impl TaskBuilder {
|
|||||||
* When spawning into a new scheduler, the number of threads requested
|
* When spawning into a new scheduler, the number of threads requested
|
||||||
* must be greater than zero.
|
* must be greater than zero.
|
||||||
*/
|
*/
|
||||||
fn spawn(+f: fn~()) {
|
fn spawn(f: fn~()) {
|
||||||
let notify_chan = if self.opts.notify_chan.is_none() {
|
let notify_chan = if self.opts.notify_chan.is_none() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
@@ -460,7 +460,7 @@ impl TaskBuilder {
|
|||||||
spawn::spawn_raw(move opts, x.gen_body(move f));
|
spawn::spawn_raw(move opts, x.gen_body(move f));
|
||||||
}
|
}
|
||||||
/// Runs a task, while transfering ownership of one argument to the child.
|
/// Runs a task, while transfering ownership of one argument to the child.
|
||||||
fn spawn_with<A: Send>(arg: A, +f: fn~(+v: A)) {
|
fn spawn_with<A: Send>(arg: A, f: fn~(v: A)) {
|
||||||
let arg = ~mut Some(move arg);
|
let arg = ~mut Some(move arg);
|
||||||
do self.spawn |move arg, move f| {
|
do self.spawn |move arg, move f| {
|
||||||
f(option::swap_unwrap(arg))
|
f(option::swap_unwrap(arg))
|
||||||
@@ -478,7 +478,7 @@ impl TaskBuilder {
|
|||||||
* otherwise be required to establish communication from the parent
|
* otherwise be required to establish communication from the parent
|
||||||
* to the child.
|
* to the child.
|
||||||
*/
|
*/
|
||||||
fn spawn_listener<A: Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
fn spawn_listener<A: Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
||||||
let setup_po = comm::Port();
|
let setup_po = comm::Port();
|
||||||
let setup_ch = comm::Chan(&setup_po);
|
let setup_ch = comm::Chan(&setup_po);
|
||||||
do self.spawn |move f| {
|
do self.spawn |move f| {
|
||||||
@@ -494,7 +494,7 @@ impl TaskBuilder {
|
|||||||
* Runs a new task, setting up communication in both directions
|
* Runs a new task, setting up communication in both directions
|
||||||
*/
|
*/
|
||||||
fn spawn_conversation<A: Send, B: Send>
|
fn spawn_conversation<A: Send, B: Send>
|
||||||
(+f: fn~(comm::Port<A>, comm::Chan<B>))
|
(f: fn~(comm::Port<A>, comm::Chan<B>))
|
||||||
-> (comm::Port<B>, comm::Chan<A>) {
|
-> (comm::Port<B>, comm::Chan<A>) {
|
||||||
let from_child = comm::Port();
|
let from_child = comm::Port();
|
||||||
let to_parent = comm::Chan(&from_child);
|
let to_parent = comm::Chan(&from_child);
|
||||||
@@ -517,7 +517,7 @@ impl TaskBuilder {
|
|||||||
* # Failure
|
* # Failure
|
||||||
* Fails if a future_result was already set for this task.
|
* Fails if a future_result was already set for this task.
|
||||||
*/
|
*/
|
||||||
fn try<T: Send>(+f: fn~() -> T) -> Result<T,()> {
|
fn try<T: Send>(f: fn~() -> T) -> Result<T,()> {
|
||||||
let po = comm::Port();
|
let po = comm::Port();
|
||||||
let ch = comm::Chan(&po);
|
let ch = comm::Chan(&po);
|
||||||
let mut result = None;
|
let mut result = None;
|
||||||
@@ -556,7 +556,7 @@ pub fn default_task_opts() -> TaskOpts {
|
|||||||
|
|
||||||
/* Spawn convenience functions */
|
/* Spawn convenience functions */
|
||||||
|
|
||||||
pub fn spawn(+f: fn~()) {
|
pub fn spawn(f: fn~()) {
|
||||||
/*!
|
/*!
|
||||||
* Creates and executes a new child task
|
* Creates and executes a new child task
|
||||||
*
|
*
|
||||||
@@ -569,7 +569,7 @@ pub fn spawn(+f: fn~()) {
|
|||||||
task().spawn(move f)
|
task().spawn(move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_unlinked(+f: fn~()) {
|
pub fn spawn_unlinked(f: fn~()) {
|
||||||
/*!
|
/*!
|
||||||
* Creates a child task unlinked from the current one. If either this
|
* Creates a child task unlinked from the current one. If either this
|
||||||
* task or the child task fails, the other will not be killed.
|
* task or the child task fails, the other will not be killed.
|
||||||
@@ -578,7 +578,7 @@ pub fn spawn_unlinked(+f: fn~()) {
|
|||||||
task().unlinked().spawn(move f)
|
task().unlinked().spawn(move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_supervised(+f: fn~()) {
|
pub fn spawn_supervised(f: fn~()) {
|
||||||
/*!
|
/*!
|
||||||
* Creates a child task unlinked from the current one. If either this
|
* Creates a child task unlinked from the current one. If either this
|
||||||
* task or the child task fails, the other will not be killed.
|
* task or the child task fails, the other will not be killed.
|
||||||
@@ -587,7 +587,7 @@ pub fn spawn_supervised(+f: fn~()) {
|
|||||||
task().supervised().spawn(move f)
|
task().supervised().spawn(move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
|
pub fn spawn_with<A:Send>(arg: A, f: fn~(v: A)) {
|
||||||
/*!
|
/*!
|
||||||
* Runs a task, while transfering ownership of one argument to the
|
* Runs a task, while transfering ownership of one argument to the
|
||||||
* child.
|
* child.
|
||||||
@@ -601,7 +601,7 @@ pub fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
|
|||||||
task().spawn_with(move arg, move f)
|
task().spawn_with(move arg, move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
pub fn spawn_listener<A:Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
||||||
/*!
|
/*!
|
||||||
* Runs a new task while providing a channel from the parent to the child
|
* Runs a new task while providing a channel from the parent to the child
|
||||||
*
|
*
|
||||||
@@ -612,7 +612,7 @@ pub fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_conversation<A: Send, B: Send>
|
pub fn spawn_conversation<A: Send, B: Send>
|
||||||
(+f: fn~(comm::Port<A>, comm::Chan<B>))
|
(f: fn~(comm::Port<A>, comm::Chan<B>))
|
||||||
-> (comm::Port<B>, comm::Chan<A>) {
|
-> (comm::Port<B>, comm::Chan<A>) {
|
||||||
/*!
|
/*!
|
||||||
* Runs a new task, setting up communication in both directions
|
* Runs a new task, setting up communication in both directions
|
||||||
@@ -623,7 +623,7 @@ pub fn spawn_conversation<A: Send, B: Send>
|
|||||||
task().spawn_conversation(move f)
|
task().spawn_conversation(move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_sched(mode: SchedMode, +f: fn~()) {
|
pub fn spawn_sched(mode: SchedMode, f: fn~()) {
|
||||||
/*!
|
/*!
|
||||||
* Creates a new scheduler and executes a task on it
|
* Creates a new scheduler and executes a task on it
|
||||||
*
|
*
|
||||||
@@ -640,7 +640,7 @@ pub fn spawn_sched(mode: SchedMode, +f: fn~()) {
|
|||||||
task().sched_mode(mode).spawn(move f)
|
task().sched_mode(mode).spawn(move f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
|
pub fn try<T:Send>(f: fn~() -> T) -> Result<T,()> {
|
||||||
/*!
|
/*!
|
||||||
* Execute a function in another task and return either the return value
|
* Execute a function in another task and return either the return value
|
||||||
* of the function or result::err.
|
* of the function or result::err.
|
||||||
@@ -1127,7 +1127,7 @@ fn test_spawn_sched_blocking() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) {
|
fn avoid_copying_the_body(spawnfn: fn(v: fn~())) {
|
||||||
let p = comm::Port::<uint>();
|
let p = comm::Port::<uint>();
|
||||||
let ch = comm::Chan(&p);
|
let ch = comm::Chan(&p);
|
||||||
|
|
||||||
@@ -1150,7 +1150,7 @@ fn test_avoid_copying_the_body_spawn() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_avoid_copying_the_body_spawn_listener() {
|
fn test_avoid_copying_the_body_spawn_listener() {
|
||||||
do avoid_copying_the_body |+f| {
|
do avoid_copying_the_body |f| {
|
||||||
spawn_listener(fn~(move f, _po: comm::Port<int>) {
|
spawn_listener(fn~(move f, _po: comm::Port<int>) {
|
||||||
f();
|
f();
|
||||||
});
|
});
|
||||||
@@ -1168,7 +1168,7 @@ fn test_avoid_copying_the_body_task_spawn() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_avoid_copying_the_body_spawn_listener_1() {
|
fn test_avoid_copying_the_body_spawn_listener_1() {
|
||||||
do avoid_copying_the_body |+f| {
|
do avoid_copying_the_body |f| {
|
||||||
task().spawn_listener(fn~(move f, _po: comm::Port<int>) {
|
task().spawn_listener(fn~(move f, _po: comm::Port<int>) {
|
||||||
f();
|
f();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_raw(opts: TaskOpts, +f: fn~()) {
|
pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
|
||||||
let (child_tg, ancestors, is_main) =
|
let (child_tg, ancestors, is_main) =
|
||||||
gen_child_taskgroup(opts.linked, opts.supervised);
|
gen_child_taskgroup(opts.linked, opts.supervised);
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ pub fn spawn_raw(opts: TaskOpts, +f: fn~()) {
|
|||||||
fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
|
fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
|
||||||
ancestors: AncestorList, is_main: bool,
|
ancestors: AncestorList, is_main: bool,
|
||||||
notify_chan: Option<Chan<Notification>>,
|
notify_chan: Option<Chan<Notification>>,
|
||||||
+f: fn~()) -> fn~() {
|
f: fn~()) -> fn~() {
|
||||||
let child_data = ~mut Some((move child_arc, move ancestors));
|
let child_data = ~mut Some((move child_arc, move ancestors));
|
||||||
return fn~(move notify_chan, move child_data, move f) {
|
return fn~(move notify_chan, move child_data, move f) {
|
||||||
// Agh. Get move-mode items into the closure. FIXME (#2829)
|
// Agh. Get move-mode items into the closure. FIXME (#2829)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// NB: transitionary, de-mode-ing.
|
// NB: transitionary, de-mode-ing.
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
/**
|
/**
|
||||||
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
|
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
|
||||||
* between tasks.
|
* between tasks.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use vec::{to_mut, from_elem};
|
use vec::{to_mut, from_elem};
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; }
|
|||||||
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
|
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
|
||||||
|
|
||||||
impl Bitv: ops::Index<uint,bool> {
|
impl Bitv: ops::Index<uint,bool> {
|
||||||
pure fn index(+i: uint) -> bool {
|
pure fn index(i: uint) -> bool {
|
||||||
self.get(i)
|
self.get(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
* great care must be taken to ensure that a reference to the c_vec::t is
|
* great care must be taken to ensure that a reference to the c_vec::t is
|
||||||
* still held if needed.
|
* still held if needed.
|
||||||
*/
|
*/
|
||||||
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type representing a foreign chunk of memory
|
* The type representing a foreign chunk of memory
|
||||||
@@ -111,7 +112,7 @@ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
|
|||||||
*
|
*
|
||||||
* Fails if `ofs` is greater or equal to the length of the vector
|
* Fails if `ofs` is greater or equal to the length of the vector
|
||||||
*/
|
*/
|
||||||
pub fn set<T: Copy>(t: CVec<T>, ofs: uint, +v: T) {
|
pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
|
||||||
assert ofs < len(t);
|
assert ofs < len(t);
|
||||||
unsafe { *ptr::mut_offset((*t).base, ofs) = v };
|
unsafe { *ptr::mut_offset((*t).base, ofs) = v };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
/// A dynamic, mutable location.
|
/// A dynamic, mutable location.
|
||||||
///
|
///
|
||||||
/// Similar to a mutable option type, but friendlier.
|
/// Similar to a mutable option type, but friendlier.
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ pub struct DuplexStream<T: Send, U: Send> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Send, U: Send> DuplexStream<T, U> : Channel<T> {
|
impl<T: Send, U: Send> DuplexStream<T, U> : Channel<T> {
|
||||||
fn send(+x: T) {
|
fn send(x: T) {
|
||||||
self.chan.send(move x)
|
self.chan.send(move x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_send(+x: T) -> bool {
|
fn try_send(x: T) -> bool {
|
||||||
self.chan.try_send(move x)
|
self.chan.try_send(move x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
//! Unsafe debugging functions for inspecting values.
|
//! Unsafe debugging functions for inspecting values.
|
||||||
|
|
||||||
use cast::reinterpret_cast;
|
use cast::reinterpret_cast;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! A deque. Untested as of yet. Likely buggy
|
//! A deque. Untested as of yet. Likely buggy
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
#[forbid(non_camel_case_types)];
|
#[forbid(non_camel_case_types)];
|
||||||
|
|
||||||
use option::{Some, None};
|
use option::{Some, None};
|
||||||
@@ -200,7 +200,7 @@ mod tests {
|
|||||||
assert (deq.get(3) == d);
|
assert (deq.get(3) == d);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_parameterized<T: Copy Eq Owned>(a: T, +b: T, +c: T, +d: T) {
|
fn test_parameterized<T: Copy Eq Owned>(a: T, b: T, c: T, d: T) {
|
||||||
let deq: deque::Deque<T> = deque::create::<T>();
|
let deq: deque::Deque<T> = deque::create::<T>();
|
||||||
assert (deq.size() == 0u);
|
assert (deq.size() == 0u);
|
||||||
deq.add_front(a);
|
deq.add_front(a);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#[forbid(deprecated_mode)];
|
||||||
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
|
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
|
||||||
// cursor model. See the specification here:
|
// cursor model. See the specification here:
|
||||||
// http://www.matroska.org/technical/specs/rfc/index.html
|
// http://www.matroska.org/technical/specs/rfc/index.html
|
||||||
@@ -17,7 +18,7 @@ pub type Doc = {data: @~[u8], start: uint, end: uint};
|
|||||||
type TaggedDoc = {tag: uint, doc: Doc};
|
type TaggedDoc = {tag: uint, doc: Doc};
|
||||||
|
|
||||||
impl Doc: ops::Index<uint,Doc> {
|
impl Doc: ops::Index<uint,Doc> {
|
||||||
pure fn index(+tag: uint) -> Doc {
|
pure fn index(tag: uint) -> Doc {
|
||||||
unsafe {
|
unsafe {
|
||||||
get_doc(self, tag)
|
get_doc(self, tag)
|
||||||
}
|
}
|
||||||
@@ -563,11 +564,11 @@ impl EbmlDeserializer: serialization::Deserializer {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_option_int() {
|
fn test_option_int() {
|
||||||
fn serialize_1<S: serialization::Serializer>(&&s: S, v: int) {
|
fn serialize_1<S: serialization::Serializer>(s: &S, v: int) {
|
||||||
s.emit_i64(v as i64);
|
s.emit_i64(v as i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_0<S: serialization::Serializer>(&&s: S, v: Option<int>) {
|
fn serialize_0<S: serialization::Serializer>(s: &S, v: Option<int>) {
|
||||||
do s.emit_enum(~"core::option::t") {
|
do s.emit_enum(~"core::option::t") {
|
||||||
match v {
|
match v {
|
||||||
None => s.emit_enum_variant(
|
None => s.emit_enum_variant(
|
||||||
@@ -581,11 +582,11 @@ fn test_option_int() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_1<S: serialization::Deserializer>(&&s: S) -> int {
|
fn deserialize_1<S: serialization::Deserializer>(s: &S) -> int {
|
||||||
s.read_i64() as int
|
s.read_i64() as int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_0<S: serialization::Deserializer>(&&s: S) -> Option<int> {
|
fn deserialize_0<S: serialization::Deserializer>(s: &S) -> Option<int> {
|
||||||
do s.read_enum(~"core::option::t") {
|
do s.read_enum(~"core::option::t") {
|
||||||
do s.read_enum_variant |i| {
|
do s.read_enum_variant |i| {
|
||||||
match i {
|
match i {
|
||||||
@@ -608,11 +609,11 @@ fn test_option_int() {
|
|||||||
debug!("v == %?", v);
|
debug!("v == %?", v);
|
||||||
let bytes = do io::with_bytes_writer |wr| {
|
let bytes = do io::with_bytes_writer |wr| {
|
||||||
let ebml_w = ebml::Writer(wr);
|
let ebml_w = ebml::Writer(wr);
|
||||||
serialize_0(ebml_w, v);
|
serialize_0(&ebml_w, v);
|
||||||
};
|
};
|
||||||
let ebml_doc = ebml::Doc(@bytes);
|
let ebml_doc = ebml::Doc(@bytes);
|
||||||
let deser = ebml_deserializer(ebml_doc);
|
let deser = ebml_deserializer(ebml_doc);
|
||||||
let v1 = deserialize_0(deser);
|
let v1 = deserialize_0(&deser);
|
||||||
debug!("v1 == %?", v1);
|
debug!("v1 == %?", v1);
|
||||||
assert v == v1;
|
assert v == v1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#[forbid(deprecated_mode)];
|
||||||
use serialization2;
|
use serialization2;
|
||||||
|
|
||||||
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
|
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
|
||||||
@@ -31,7 +32,7 @@ struct TaggedDoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Doc: ops::Index<uint,Doc> {
|
impl Doc: ops::Index<uint,Doc> {
|
||||||
pure fn index(+tag: uint) -> Doc {
|
pure fn index(tag: uint) -> Doc {
|
||||||
unsafe {
|
unsafe {
|
||||||
get_doc(self, tag)
|
get_doc(self, tag)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[warn(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* A functional key,value store that works on anything.
|
* A functional key,value store that works on anything.
|
||||||
@@ -26,7 +26,7 @@ enum TreeNode<K, V> {
|
|||||||
pub fn init<K, V>() -> Treemap<K, V> { @Empty }
|
pub fn init<K, V>() -> Treemap<K, V> { @Empty }
|
||||||
|
|
||||||
/// Insert a value into the map
|
/// Insert a value into the map
|
||||||
pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
|
pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, k: K, v: V)
|
||||||
-> Treemap<K, V> {
|
-> Treemap<K, V> {
|
||||||
@match m {
|
@match m {
|
||||||
@Empty => Node(@k, @v, @Empty, @Empty),
|
@Empty => Node(@k, @v, @Empty, @Empty),
|
||||||
@@ -41,7 +41,7 @@ pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Find a value based on the key
|
/// Find a value based on the key
|
||||||
pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
|
pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
|
||||||
match *m {
|
match *m {
|
||||||
Empty => None,
|
Empty => None,
|
||||||
Node(@ref kk, @copy v, left, right) => {
|
Node(@ref kk, @copy v, left, right) => {
|
||||||
|
|||||||
@@ -61,8 +61,7 @@
|
|||||||
* do_work(input, output);
|
* do_work(input, output);
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
#[forbid(deprecated_mode)];
|
||||||
// tjc: forbid deprecated modes again after snap
|
|
||||||
|
|
||||||
use core::cmp::Eq;
|
use core::cmp::Eq;
|
||||||
use core::result::{Err, Ok};
|
use core::result::{Err, Ok};
|
||||||
@@ -162,7 +161,7 @@ fn name_str(nm: &Name) -> ~str {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_opt(opts: &[Opt], +nm: Name) -> Option<uint> {
|
fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
|
||||||
vec::position(opts, |opt| opt.name == nm)
|
vec::position(opts, |opt| opt.name == nm)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +213,7 @@ pub type Result = result::Result<Matches, Fail_>;
|
|||||||
*/
|
*/
|
||||||
pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
||||||
let n_opts = vec::len::<Opt>(opts);
|
let n_opts = vec::len::<Opt>(opts);
|
||||||
fn f(+_x: uint) -> ~[Optval] { return ~[]; }
|
fn f(_x: uint) -> ~[Optval] { return ~[]; }
|
||||||
let vals = vec::to_mut(vec::from_fn(n_opts, f));
|
let vals = vec::to_mut(vec::from_fn(n_opts, f));
|
||||||
let mut free: ~[~str] = ~[];
|
let mut free: ~[~str] = ~[];
|
||||||
let l = vec::len(args);
|
let l = vec::len(args);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Rust JSON serialization library
|
// Rust JSON serialization library
|
||||||
// Copyright (c) 2011 Google Inc.
|
// Copyright (c) 2011 Google Inc.
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
#[forbid(non_camel_case_types)];
|
#[forbid(non_camel_case_types)];
|
||||||
|
|
||||||
//! json serialization
|
//! json serialization
|
||||||
@@ -399,7 +399,7 @@ priv impl Parser {
|
|||||||
while char::is_whitespace(self.ch) { self.bump(); }
|
while char::is_whitespace(self.ch) { self.bump(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ident(ident: &str, +value: Json) -> Result<Json, Error> {
|
fn parse_ident(ident: &str, value: Json) -> Result<Json, Error> {
|
||||||
if str::all(ident, |c| c == self.next_char()) {
|
if str::all(ident, |c| c == self.next_char()) {
|
||||||
self.bump();
|
self.bump();
|
||||||
Ok(move value)
|
Ok(move value)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! A standard linked list
|
//! A standard linked list
|
||||||
#[warn(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::cmp::Eq;
|
use core::cmp::Eq;
|
||||||
use core::option;
|
use core::option;
|
||||||
@@ -56,7 +56,7 @@ pub fn find<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if a list contains an element with the given value
|
/// Returns true if a list contains an element with the given value
|
||||||
pub fn has<T: Copy Eq>(ls: @List<T>, +elt: T) -> bool {
|
pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool {
|
||||||
for each(ls) |e| {
|
for each(ls) |e| {
|
||||||
if *e == elt { return true; }
|
if *e == elt { return true; }
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> {
|
|||||||
/*
|
/*
|
||||||
/// Push one element into the front of a list, returning a new list
|
/// Push one element into the front of a list, returning a new list
|
||||||
/// THIS VERSION DOESN'T ACTUALLY WORK
|
/// THIS VERSION DOESN'T ACTUALLY WORK
|
||||||
pure fn push<T: Copy>(ll: &mut @list<T>, +vv: T) {
|
pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
|
||||||
ll = &mut @cons(vv, *ll)
|
ll = &mut @cons(vv, *ll)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//! A map type
|
//! A map type
|
||||||
|
#[forbid(deprecated_mode)];
|
||||||
// tjc: forbid deprecated modes again after snap
|
|
||||||
|
|
||||||
use io::WriterUtil;
|
use io::WriterUtil;
|
||||||
use to_str::ToStr;
|
use to_str::ToStr;
|
||||||
@@ -28,7 +27,7 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
|
|||||||
*
|
*
|
||||||
* Returns true if the key did not already exist in the map
|
* Returns true if the key did not already exist in the map
|
||||||
*/
|
*/
|
||||||
fn insert(v: K, +v: V) -> bool;
|
fn insert(v: K, v: V) -> bool;
|
||||||
|
|
||||||
/// Returns true if the map contains a value for the specified key
|
/// Returns true if the map contains a value for the specified key
|
||||||
fn contains_key(key: K) -> bool;
|
fn contains_key(key: K) -> bool;
|
||||||
@@ -59,7 +58,7 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
|
|||||||
fn clear();
|
fn clear();
|
||||||
|
|
||||||
/// Iterate over all the key/value pairs in the map by value
|
/// Iterate over all the key/value pairs in the map by value
|
||||||
pure fn each(fn(key: K, +value: V) -> bool);
|
pure fn each(fn(key: K, value: V) -> bool);
|
||||||
|
|
||||||
/// Iterate over all the keys in the map by value
|
/// Iterate over all the keys in the map by value
|
||||||
pure fn each_key(fn(key: K) -> bool);
|
pure fn each_key(fn(key: K) -> bool);
|
||||||
@@ -213,7 +212,7 @@ pub mod chained {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert(k: K, +v: V) -> bool {
|
fn insert(k: K, v: V) -> bool {
|
||||||
let hash = k.hash_keyed(0,0) as uint;
|
let hash = k.hash_keyed(0,0) as uint;
|
||||||
match self.search_tbl(&k, hash) {
|
match self.search_tbl(&k, hash) {
|
||||||
NotFound => {
|
NotFound => {
|
||||||
@@ -294,7 +293,7 @@ pub mod chained {
|
|||||||
self.chains = chains(initial_capacity);
|
self.chains = chains(initial_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn each(blk: fn(key: K, +value: V) -> bool) {
|
pure fn each(blk: fn(key: K, value: V) -> bool) {
|
||||||
self.each_ref(|k, v| blk(*k, *v))
|
self.each_ref(|k, v| blk(*k, *v))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +347,7 @@ pub mod chained {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> {
|
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> {
|
||||||
pure fn index(+k: K) -> V {
|
pure fn index(k: K) -> V {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.get(k)
|
self.get(k)
|
||||||
}
|
}
|
||||||
@@ -459,7 +458,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn each(op: fn(key: K, +value: V) -> bool) {
|
pure fn each(op: fn(key: K, value: V) -> bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
do self.borrow_imm |p| {
|
do self.borrow_imm |p| {
|
||||||
p.each(|k, v| op(*k, *v))
|
p.each(|k, v| op(*k, *v))
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
//! High-level interface to libuv's TCP functionality
|
//! High-level interface to libuv's TCP functionality
|
||||||
|
#[warn(deprecated_mode)];
|
||||||
|
|
||||||
use ip = net_ip;
|
use ip = net_ip;
|
||||||
use uv::iotask;
|
use uv::iotask;
|
||||||
@@ -324,7 +325,7 @@ pub fn read_start(sock: &TcpSocket)
|
|||||||
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
|
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
|
||||||
*/
|
*/
|
||||||
pub fn read_stop(sock: &TcpSocket,
|
pub fn read_stop(sock: &TcpSocket,
|
||||||
+read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
|
read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
|
||||||
result::Result<(), TcpErrData> unsafe {
|
result::Result<(), TcpErrData> unsafe {
|
||||||
log(debug, fmt!("taking the read_port out of commission %?", read_port));
|
log(debug, fmt!("taking the read_port out of commission %?", read_port));
|
||||||
let socket_data = ptr::addr_of(&(*sock.socket_data));
|
let socket_data = ptr::addr_of(&(*sock.socket_data));
|
||||||
@@ -558,8 +559,8 @@ pub fn accept(new_conn: TcpNewConnection)
|
|||||||
*/
|
*/
|
||||||
pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||||
iotask: IoTask,
|
iotask: IoTask,
|
||||||
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
|
on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
|
||||||
+new_connect_cb: fn~(TcpNewConnection,
|
new_connect_cb: fn~(TcpNewConnection,
|
||||||
comm::Chan<Option<TcpErrData>>))
|
comm::Chan<Option<TcpErrData>>))
|
||||||
-> result::Result<(), TcpListenErrData> unsafe {
|
-> result::Result<(), TcpListenErrData> unsafe {
|
||||||
do listen_common(move host_ip, port, backlog, iotask, on_establish_cb)
|
do listen_common(move host_ip, port, backlog, iotask, on_establish_cb)
|
||||||
@@ -575,8 +576,8 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
|||||||
|
|
||||||
fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||||
iotask: IoTask,
|
iotask: IoTask,
|
||||||
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
|
on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
|
||||||
+on_connect_cb: fn~(*uv::ll::uv_tcp_t))
|
on_connect_cb: fn~(*uv::ll::uv_tcp_t))
|
||||||
-> result::Result<(), TcpListenErrData> unsafe {
|
-> result::Result<(), TcpListenErrData> unsafe {
|
||||||
let stream_closed_po = core::comm::Port::<()>();
|
let stream_closed_po = core::comm::Port::<()>();
|
||||||
let kill_po = core::comm::Port::<Option<TcpErrData>>();
|
let kill_po = core::comm::Port::<Option<TcpErrData>>();
|
||||||
@@ -749,7 +750,7 @@ impl TcpSocket {
|
|||||||
|
|
||||||
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
|
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
|
||||||
impl TcpSocketBuf: io::Reader {
|
impl TcpSocketBuf: io::Reader {
|
||||||
fn read(buf: &[mut u8], +len: uint) -> uint {
|
fn read(buf: &[mut u8], len: uint) -> uint {
|
||||||
// Loop until our buffer has enough data in it for us to read from.
|
// Loop until our buffer has enough data in it for us to read from.
|
||||||
while self.data.buf.len() < len {
|
while self.data.buf.len() < len {
|
||||||
let read_result = read(&self.data.sock, 0u);
|
let read_result = read(&self.data.sock, 0u);
|
||||||
@@ -785,13 +786,13 @@ impl TcpSocketBuf: io::Reader {
|
|||||||
let mut bytes = ~[0];
|
let mut bytes = ~[0];
|
||||||
if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int }
|
if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int }
|
||||||
}
|
}
|
||||||
fn unread_byte(+amt: int) {
|
fn unread_byte(amt: int) {
|
||||||
self.data.buf.unshift(amt as u8);
|
self.data.buf.unshift(amt as u8);
|
||||||
}
|
}
|
||||||
fn eof() -> bool {
|
fn eof() -> bool {
|
||||||
false // noop
|
false // noop
|
||||||
}
|
}
|
||||||
fn seek(+dist: int, +seek: io::SeekStyle) {
|
fn seek(dist: int, seek: io::SeekStyle) {
|
||||||
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
|
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
@@ -813,7 +814,7 @@ impl TcpSocketBuf: io::Writer {
|
|||||||
err_data.err_name, err_data.err_msg));
|
err_data.err_name, err_data.err_msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn seek(+dist: int, +seek: io::SeekStyle) {
|
fn seek(dist: int, seek: io::SeekStyle) {
|
||||||
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
|
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
@@ -1474,7 +1475,7 @@ mod test {
|
|||||||
str::from_bytes(new_bytes)
|
str::from_bytes(new_bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_tcp_test_server(server_ip: &str, server_port: uint, +resp: ~str,
|
fn run_tcp_test_server(server_ip: &str, server_port: uint, resp: ~str,
|
||||||
server_ch: comm::Chan<~str>,
|
server_ch: comm::Chan<~str>,
|
||||||
cont_ch: comm::Chan<()>,
|
cont_ch: comm::Chan<()>,
|
||||||
iotask: IoTask) -> ~str {
|
iotask: IoTask) -> ~str {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Types/fns concerning URLs (see RFC 3986)
|
//! Types/fns concerning URLs (see RFC 3986)
|
||||||
// tjc: forbid deprecated modes again after a snapshot
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::cmp::Eq;
|
use core::cmp::Eq;
|
||||||
use map::HashMap;
|
use map::HashMap;
|
||||||
@@ -27,15 +27,15 @@ type UserInfo = {
|
|||||||
|
|
||||||
pub type Query = ~[(~str, ~str)];
|
pub type Query = ~[(~str, ~str)];
|
||||||
|
|
||||||
pub fn Url(scheme: ~str, +user: Option<UserInfo>, +host: ~str,
|
pub fn Url(scheme: ~str, user: Option<UserInfo>, host: ~str,
|
||||||
+port: Option<~str>, +path: ~str, +query: Query,
|
port: Option<~str>, path: ~str, query: Query,
|
||||||
+fragment: Option<~str>) -> Url {
|
fragment: Option<~str>) -> Url {
|
||||||
Url { scheme: move scheme, user: move user, host: move host,
|
Url { scheme: move scheme, user: move user, host: move host,
|
||||||
port: move port, path: move path, query: move query,
|
port: move port, path: move path, query: move query,
|
||||||
fragment: move fragment }
|
fragment: move fragment }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn UserInfo(user: ~str, +pass: Option<~str>) -> UserInfo {
|
fn UserInfo(user: ~str, pass: Option<~str>) -> UserInfo {
|
||||||
{user: move user, pass: move pass}
|
{user: move user, pass: move pass}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,7 +726,7 @@ impl Url : Eq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Url: IterBytes {
|
impl Url: IterBytes {
|
||||||
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
|
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
|
||||||
unsafe { self.to_str() }.iter_bytes(lsb0, f)
|
unsafe { self.to_str() }.iter_bytes(lsb0, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use future_spawn = future::spawn;
|
use future_spawn = future::spawn;
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ fn map_slices<A: Copy Send, B: Copy Send>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A parallel version of map.
|
/// A parallel version of map.
|
||||||
pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], +f: fn~((&A)) -> B) -> ~[B] {
|
pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], f: fn~((&A)) -> B) -> ~[B] {
|
||||||
vec::concat(map_slices(xs, || {
|
vec::concat(map_slices(xs, || {
|
||||||
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
|
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
|
||||||
vec::map(slice, |x| f(x))
|
vec::map(slice, |x| f(x))
|
||||||
@@ -82,7 +84,7 @@ pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], +f: fn~((&A)) -> B) -> ~[B] {
|
|||||||
|
|
||||||
/// A parallel version of mapi.
|
/// A parallel version of mapi.
|
||||||
pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
|
pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
|
||||||
+f: fn~(uint, (&A)) -> B) -> ~[B] {
|
f: fn~(uint, (&A)) -> B) -> ~[B] {
|
||||||
let slices = map_slices(xs, || {
|
let slices = map_slices(xs, || {
|
||||||
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
|
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
|
||||||
vec::mapi(slice, |i, x| {
|
vec::mapi(slice, |i, x| {
|
||||||
@@ -119,7 +121,7 @@ pub fn mapi_factory<A: Copy Send, B: Copy Send>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the function holds for all elements in the vector.
|
/// Returns true if the function holds for all elements in the vector.
|
||||||
pub fn alli<A: Copy Send>(xs: &[A], +f: fn~(uint, (&A)) -> bool) -> bool {
|
pub fn alli<A: Copy Send>(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool {
|
||||||
do vec::all(map_slices(xs, || {
|
do vec::all(map_slices(xs, || {
|
||||||
fn~(base: uint, slice : &[A], copy f) -> bool {
|
fn~(base: uint, slice : &[A], copy f) -> bool {
|
||||||
vec::alli(slice, |i, x| {
|
vec::alli(slice, |i, x| {
|
||||||
@@ -130,7 +132,7 @@ pub fn alli<A: Copy Send>(xs: &[A], +f: fn~(uint, (&A)) -> bool) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the function holds for any elements in the vector.
|
/// Returns true if the function holds for any elements in the vector.
|
||||||
pub fn any<A: Copy Send>(xs: &[A], +f: fn~(&(A)) -> bool) -> bool {
|
pub fn any<A: Copy Send>(xs: &[A], f: fn~(&(A)) -> bool) -> bool {
|
||||||
do vec::any(map_slices(xs, || {
|
do vec::any(map_slices(xs, || {
|
||||||
fn~(_base : uint, slice: &[A], copy f) -> bool {
|
fn~(_base : uint, slice: &[A], copy f) -> bool {
|
||||||
vec::any(slice, |x| f(x))
|
vec::any(slice, |x| f(x))
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* A simple map based on a vector for small integer keys. Space requirements
|
* A simple map based on a vector for small integer keys. Space requirements
|
||||||
* are O(highest integer key).
|
* are O(highest integer key).
|
||||||
*/
|
*/
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::option;
|
use core::option;
|
||||||
use core::option::{Some, None};
|
use core::option::{Some, None};
|
||||||
@@ -103,7 +103,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
|
|||||||
pure fn find(key: uint) -> Option<V> { find(self, key) }
|
pure fn find(key: uint) -> Option<V> { find(self, key) }
|
||||||
fn rehash() { fail }
|
fn rehash() { fail }
|
||||||
|
|
||||||
pure fn each(it: fn(key: uint, +value: V) -> bool) {
|
pure fn each(it: fn(key: uint, value: V) -> bool) {
|
||||||
self.each_ref(|k, v| it(*k, *v))
|
self.each_ref(|k, v| it(*k, *v))
|
||||||
}
|
}
|
||||||
pure fn each_key(it: fn(key: uint) -> bool) {
|
pure fn each_key(it: fn(key: uint) -> bool) {
|
||||||
@@ -131,7 +131,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
|
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
|
||||||
pure fn index(+key: uint) -> V {
|
pure fn index(key: uint) -> V {
|
||||||
unsafe {
|
unsafe {
|
||||||
get(self, key)
|
get(self, key)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ not required in or otherwise suitable for the core library.
|
|||||||
|
|
||||||
#[allow(vecs_implicitly_copyable)];
|
#[allow(vecs_implicitly_copyable)];
|
||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
|
#[warn(deprecated_mode)];
|
||||||
#[forbid(deprecated_pattern)];
|
#[forbid(deprecated_pattern)];
|
||||||
|
|
||||||
extern mod core(vers = "0.4");
|
extern mod core(vers = "0.4");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// NB: transitionary, de-mode-ing.
|
// NB: transitionary, de-mode-ing.
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
/**
|
/**
|
||||||
* The concurrency primitives you know and love.
|
* The concurrency primitives you know and love.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// simplest interface possible for representing and running tests
|
// simplest interface possible for representing and running tests
|
||||||
// while providing a base that other test frameworks may build off of.
|
// while providing a base that other test frameworks may build off of.
|
||||||
|
|
||||||
#[warn(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::cmp::Eq;
|
use core::cmp::Eq;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::cmp::Eq;
|
use core::cmp::Eq;
|
||||||
use libc::{c_char, c_int, c_long, size_t, time_t};
|
use libc::{c_char, c_int, c_long, size_t, time_t};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Utilities that leverage libuv's `uv_timer_*` API
|
//! Utilities that leverage libuv's `uv_timer_*` API
|
||||||
|
|
||||||
// tjc: forbid deprecated modes again after snap
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use uv = uv;
|
use uv = uv;
|
||||||
use uv::iotask;
|
use uv::iotask;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* very naive algorithm, but it will probably be updated to be a
|
* very naive algorithm, but it will probably be updated to be a
|
||||||
* red-black tree or something else.
|
* red-black tree or something else.
|
||||||
*/
|
*/
|
||||||
#[warn(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use core::cmp::{Eq, Ord};
|
use core::cmp::{Eq, Ord};
|
||||||
use core::option::{Some, None};
|
use core::option::{Some, None};
|
||||||
@@ -26,7 +26,7 @@ enum TreeNode<K, V> = {
|
|||||||
pub fn TreeMap<K, V>() -> TreeMap<K, V> { @mut None }
|
pub fn TreeMap<K, V>() -> TreeMap<K, V> { @mut None }
|
||||||
|
|
||||||
/// Insert a value into the map
|
/// Insert a value into the map
|
||||||
pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
|
pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, k: K, v: V) {
|
||||||
match copy *m {
|
match copy *m {
|
||||||
None => {
|
None => {
|
||||||
*m = Some(@TreeNode({key: k,
|
*m = Some(@TreeNode({key: k,
|
||||||
@@ -48,7 +48,7 @@ pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Find a value based on the key
|
/// Find a value based on the key
|
||||||
pub fn find<K: Copy Eq Ord, V: Copy>(m: &const TreeEdge<K, V>, +k: K)
|
pub fn find<K: Copy Eq Ord, V: Copy>(m: &const TreeEdge<K, V>, k: K)
|
||||||
-> Option<V> {
|
-> Option<V> {
|
||||||
match copy *m {
|
match copy *m {
|
||||||
None => None,
|
None => None,
|
||||||
@@ -121,7 +121,7 @@ mod tests {
|
|||||||
insert(m, 1, ());
|
insert(m, 1, ());
|
||||||
|
|
||||||
let n = @mut 0;
|
let n = @mut 0;
|
||||||
fn t(n: @mut int, +k: int, +_v: ()) {
|
fn t(n: @mut int, k: int, _v: ()) {
|
||||||
assert (*n == k); *n += 1;
|
assert (*n == k); *n += 1;
|
||||||
}
|
}
|
||||||
traverse(m, |x,y| t(n, *x, *y));
|
traverse(m, |x,y| t(n, *x, *y));
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
* The I/O task runs in its own single-threaded scheduler. By using the
|
* The I/O task runs in its own single-threaded scheduler. By using the
|
||||||
* `interact` function you can execute code in a uv callback.
|
* `interact` function you can execute code in a uv callback.
|
||||||
*/
|
*/
|
||||||
|
#[forbid(deprecated_mode)];
|
||||||
// tjc: forbid deprecated modes again after a snapshot
|
|
||||||
|
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use ptr::addr_of;
|
use ptr::addr_of;
|
||||||
@@ -60,7 +59,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask {
|
|||||||
* via ports/chans.
|
* via ports/chans.
|
||||||
*/
|
*/
|
||||||
pub unsafe fn interact(iotask: IoTask,
|
pub unsafe fn interact(iotask: IoTask,
|
||||||
+cb: fn~(*c_void)) {
|
cb: fn~(*c_void)) {
|
||||||
send_msg(iotask, Interaction(move cb));
|
send_msg(iotask, Interaction(move cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ type IoTaskLoopData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn send_msg(iotask: IoTask,
|
fn send_msg(iotask: IoTask,
|
||||||
+msg: IoTaskMsg) unsafe {
|
msg: IoTaskMsg) unsafe {
|
||||||
iotask.op_chan.send(move msg);
|
iotask.op_chan.send(move msg);
|
||||||
ll::async_send(iotask.async_handle);
|
ll::async_send(iotask.async_handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* This module's implementation will hopefully be, eventually, replaced
|
* This module's implementation will hopefully be, eventually, replaced
|
||||||
* with per-platform, generated source files from rust-bindgen.
|
* with per-platform, generated source files from rust-bindgen.
|
||||||
*/
|
*/
|
||||||
|
#[warn(deprecated_mode)];
|
||||||
#[allow(non_camel_case_types)]; // C types
|
#[allow(non_camel_case_types)]; // C types
|
||||||
|
|
||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
@@ -642,7 +642,7 @@ extern mod rustrt {
|
|||||||
fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in;
|
fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in;
|
||||||
fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6;
|
fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6;
|
||||||
fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8;
|
fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8;
|
||||||
fn rust_uv_free_base_of_buf(++buf: uv_buf_t);
|
fn rust_uv_free_base_of_buf(+buf: uv_buf_t);
|
||||||
fn rust_uv_get_stream_handle_from_connect_req(
|
fn rust_uv_get_stream_handle_from_connect_req(
|
||||||
connect_req: *uv_connect_t)
|
connect_req: *uv_connect_t)
|
||||||
-> *uv_stream_t;
|
-> *uv_stream_t;
|
||||||
@@ -661,8 +661,8 @@ extern mod rustrt {
|
|||||||
fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void;
|
fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void;
|
||||||
fn rust_uv_set_data_for_req(req: *libc::c_void,
|
fn rust_uv_set_data_for_req(req: *libc::c_void,
|
||||||
data: *libc::c_void);
|
data: *libc::c_void);
|
||||||
fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8;
|
fn rust_uv_get_base_from_buf(+buf: uv_buf_t) -> *u8;
|
||||||
fn rust_uv_get_len_from_buf(++buf: uv_buf_t) -> libc::size_t;
|
fn rust_uv_get_len_from_buf(+buf: uv_buf_t) -> libc::size_t;
|
||||||
|
|
||||||
// sizeof testing helpers
|
// sizeof testing helpers
|
||||||
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
|
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
|
||||||
@@ -1357,8 +1357,8 @@ pub mod test {
|
|||||||
|
|
||||||
fn impl_uv_tcp_server(server_ip: &str,
|
fn impl_uv_tcp_server(server_ip: &str,
|
||||||
server_port: int,
|
server_port: int,
|
||||||
+kill_server_msg: ~str,
|
kill_server_msg: ~str,
|
||||||
+server_resp_msg: ~str,
|
server_resp_msg: ~str,
|
||||||
server_chan: *comm::Chan<~str>,
|
server_chan: *comm::Chan<~str>,
|
||||||
continue_chan: *comm::Chan<bool>) unsafe {
|
continue_chan: *comm::Chan<bool>) unsafe {
|
||||||
let test_loop = loop_new();
|
let test_loop = loop_new();
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ trait ext_ctxt_ast_builder {
|
|||||||
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
||||||
-> ast::ty_param;
|
-> ast::ty_param;
|
||||||
fn arg(name: ident, ty: @ast::ty) -> ast::arg;
|
fn arg(name: ident, ty: @ast::ty) -> ast::arg;
|
||||||
fn arg_mode(name: ident, ty: @ast::ty, mode: ast::rmode) -> ast::arg;
|
|
||||||
fn expr_block(e: @ast::expr) -> ast::blk;
|
fn expr_block(e: @ast::expr) -> ast::blk;
|
||||||
fn fn_decl(+inputs: ~[ast::arg], output: @ast::ty) -> ast::fn_decl;
|
fn fn_decl(+inputs: ~[ast::arg], output: @ast::ty) -> ast::fn_decl;
|
||||||
fn item(name: ident, span: span, +node: ast::item_) -> @ast::item;
|
fn item(name: ident, span: span, +node: ast::item_) -> @ast::item;
|
||||||
@@ -177,13 +176,6 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
|||||||
id: self.next_id()}
|
id: self.next_id()}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_mode(name: ident, ty: @ast::ty, mode: ast::rmode) -> ast::arg {
|
|
||||||
{mode: ast::expl(mode),
|
|
||||||
ty: ty,
|
|
||||||
ident: name,
|
|
||||||
id: self.next_id()}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
|
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
|
||||||
let blk = {view_items: ~[],
|
let blk = {view_items: ~[],
|
||||||
stmts: stmts,
|
stmts: stmts,
|
||||||
|
|||||||
@@ -47,16 +47,15 @@ impl message: gen_send {
|
|||||||
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
|
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
|
||||||
|
|
||||||
let args_ast = (arg_names, tys).map(
|
let args_ast = (arg_names, tys).map(
|
||||||
|n, t| cx.arg_mode(*n, *t, ast::by_copy)
|
|n, t| cx.arg(*n, *t)
|
||||||
);
|
);
|
||||||
|
|
||||||
let pipe_ty = cx.ty_path_ast_builder(
|
let pipe_ty = cx.ty_path_ast_builder(
|
||||||
path(~[this.data_name()], span)
|
path(~[this.data_name()], span)
|
||||||
.add_tys(cx.ty_vars(this.ty_params)));
|
.add_tys(cx.ty_vars(this.ty_params)));
|
||||||
let args_ast = vec::append(
|
let args_ast = vec::append(
|
||||||
~[cx.arg_mode(cx.ident_of(~"pipe"),
|
~[cx.arg(cx.ident_of(~"pipe"),
|
||||||
pipe_ty,
|
pipe_ty)],
|
||||||
ast::by_copy)],
|
|
||||||
args_ast);
|
args_ast);
|
||||||
|
|
||||||
let mut body = ~"{\n";
|
let mut body = ~"{\n";
|
||||||
@@ -129,15 +128,14 @@ impl message: gen_send {
|
|||||||
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
|
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
|
||||||
|
|
||||||
let args_ast = (arg_names, tys).map(
|
let args_ast = (arg_names, tys).map(
|
||||||
|n, t| cx.arg_mode(cx.ident_of(*n), *t, ast::by_copy)
|
|n, t| cx.arg(cx.ident_of(*n), *t)
|
||||||
);
|
);
|
||||||
|
|
||||||
let args_ast = vec::append(
|
let args_ast = vec::append(
|
||||||
~[cx.arg_mode(cx.ident_of(~"pipe"),
|
~[cx.arg(cx.ident_of(~"pipe"),
|
||||||
cx.ty_path_ast_builder(
|
cx.ty_path_ast_builder(
|
||||||
path(~[this.data_name()], span)
|
path(~[this.data_name()], span)
|
||||||
.add_tys(cx.ty_vars(this.ty_params))),
|
.add_tys(cx.ty_vars(this.ty_params))))],
|
||||||
ast::by_copy)],
|
|
||||||
args_ast);
|
args_ast);
|
||||||
|
|
||||||
let message_args = if arg_names.len() == 0 {
|
let message_args = if arg_names.len() == 0 {
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ use syntax::diagnostic;
|
|||||||
use rustc::driver::session;
|
use rustc::driver::session;
|
||||||
use rustc::middle::lint;
|
use rustc::middle::lint;
|
||||||
|
|
||||||
fn version(argv0: ~str) {
|
fn version(argv0: &str) {
|
||||||
let mut vers = ~"unknown version";
|
let mut vers = ~"unknown version";
|
||||||
let env_vers = env!("CFG_VERSION");
|
let env_vers = env!("CFG_VERSION");
|
||||||
if str::len(env_vers) != 0u { vers = env_vers; }
|
if env_vers.len() != 0 { vers = env_vers; }
|
||||||
io::println(fmt!("%s %s", argv0, vers));
|
io::println(fmt!("%s %s", argv0, vers));
|
||||||
io::println(fmt!("host: %s", host_triple()));
|
io::println(fmt!("host: %s", host_triple()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(argv0: ~str) {
|
fn usage(argv0: &str) {
|
||||||
io::println(fmt!("Usage: %s [options] <input>\n", argv0) +
|
io::println(fmt!("Usage: %s [options] <input>\n", argv0) +
|
||||||
~"
|
~"
|
||||||
Options:
|
Options:
|
||||||
@@ -86,7 +86,7 @@ fn describe_warnings() {
|
|||||||
let lint_dict = lint::get_lint_dict();
|
let lint_dict = lint::get_lint_dict();
|
||||||
let mut max_key = 0;
|
let mut max_key = 0;
|
||||||
for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
|
for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
|
||||||
fn padded(max: uint, s: ~str) -> ~str {
|
fn padded(max: uint, s: &str) -> ~str {
|
||||||
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
||||||
}
|
}
|
||||||
io::println(fmt!("\nAvailable lint checks:\n"));
|
io::println(fmt!("\nAvailable lint checks:\n"));
|
||||||
@@ -117,14 +117,14 @@ fn describe_debug_flags() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
|
fn run_compiler(args: &~[~str], demitter: diagnostic::emitter) {
|
||||||
// Don't display log spew by default. Can override with RUST_LOG.
|
// Don't display log spew by default. Can override with RUST_LOG.
|
||||||
logging::console_off();
|
logging::console_off();
|
||||||
|
|
||||||
let mut args = args;
|
let mut args = *args;
|
||||||
let binary = args.shift();
|
let binary = args.shift();
|
||||||
|
|
||||||
if vec::len(args) == 0u { usage(binary); return; }
|
if args.is_empty() { usage(binary); return; }
|
||||||
|
|
||||||
let matches =
|
let matches =
|
||||||
match getopts::getopts(args, opts()) {
|
match getopts::getopts(args, opts()) {
|
||||||
@@ -278,9 +278,9 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = os::args();
|
let mut args = os::args();
|
||||||
do monitor |demitter| {
|
do monitor |move args, demitter| {
|
||||||
run_compiler(args, demitter);
|
run_compiler(&args, demitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
// xfail-pretty
|
// xfail-pretty
|
||||||
|
|
||||||
#[legacy_modes];
|
|
||||||
|
|
||||||
extern mod std;
|
extern mod std;
|
||||||
|
|
||||||
use option = option;
|
use option = option;
|
||||||
@@ -70,18 +68,18 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) {
|
|||||||
let f = f();
|
let f = f();
|
||||||
loop {
|
loop {
|
||||||
match f.read_word() {
|
match f.read_word() {
|
||||||
Some(w) => { emit(w, 1); }
|
Some(w) => { emit(&w, 1); }
|
||||||
None => { break; }
|
None => { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reduce(&&word: ~str, get: map_reduce::getter<int>) {
|
fn reduce(word: &~str, get: map_reduce::getter<int>) {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
|
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
|
||||||
|
|
||||||
io::println(fmt!("%s\t%?", word, count));
|
io::println(fmt!("%s\t%?", *word, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct box<T> {
|
struct box<T> {
|
||||||
@@ -116,13 +114,13 @@ mod map_reduce {
|
|||||||
export reducer;
|
export reducer;
|
||||||
export map_reduce;
|
export map_reduce;
|
||||||
|
|
||||||
type putter<K: Send, V: Send> = fn(K, V);
|
type putter<K: Send, V: Send> = fn(&K, V);
|
||||||
|
|
||||||
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
|
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
|
||||||
|
|
||||||
type getter<V: Send> = fn() -> Option<V>;
|
type getter<V: Send> = fn() -> Option<V>;
|
||||||
|
|
||||||
type reducer<K: Copy Send, V: Copy Send> = fn~(K, getter<V>);
|
type reducer<K: Copy Send, V: Copy Send> = fn~(&K, getter<V>);
|
||||||
|
|
||||||
enum ctrl_proto<K: Copy Send, V: Copy Send> {
|
enum ctrl_proto<K: Copy Send, V: Copy Send> {
|
||||||
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
|
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
|
||||||
@@ -145,9 +143,9 @@ mod map_reduce {
|
|||||||
|
|
||||||
fn start_mappers<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send,
|
fn start_mappers<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send,
|
||||||
V: Copy Send>(
|
V: Copy Send>(
|
||||||
map: mapper<K1, K2, V>,
|
map: &mapper<K1, K2, V>,
|
||||||
&ctrls: ~[ctrl_proto::server::open<K2, V>],
|
&ctrls: ~[ctrl_proto::server::open<K2, V>],
|
||||||
inputs: ~[K1])
|
inputs: &~[K1])
|
||||||
-> ~[joinable_task]
|
-> ~[joinable_task]
|
||||||
{
|
{
|
||||||
let mut tasks = ~[];
|
let mut tasks = ~[];
|
||||||
@@ -155,7 +153,8 @@ mod map_reduce {
|
|||||||
let (ctrl, ctrl_server) = ctrl_proto::init();
|
let (ctrl, ctrl_server) = ctrl_proto::init();
|
||||||
let ctrl = box(ctrl);
|
let ctrl = box(ctrl);
|
||||||
let i = copy *i;
|
let i = copy *i;
|
||||||
tasks.push(spawn_joinable(|move i| map_task(map, ctrl, i)));
|
let m = copy *map;
|
||||||
|
tasks.push(spawn_joinable(|move i| map_task(m, &ctrl, i)));
|
||||||
ctrls.push(ctrl_server);
|
ctrls.push(ctrl_server);
|
||||||
}
|
}
|
||||||
return tasks;
|
return tasks;
|
||||||
@@ -163,20 +162,22 @@ mod map_reduce {
|
|||||||
|
|
||||||
fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
|
fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
|
||||||
map: mapper<K1, K2, V>,
|
map: mapper<K1, K2, V>,
|
||||||
ctrl: box<ctrl_proto::client::open<K2, V>>,
|
ctrl: &box<ctrl_proto::client::open<K2, V>>,
|
||||||
input: K1)
|
input: K1)
|
||||||
{
|
{
|
||||||
// log(error, "map_task " + input);
|
// log(error, "map_task " + input);
|
||||||
let intermediates = map::HashMap();
|
let intermediates: HashMap<K2, Chan<reduce_proto<V>>>
|
||||||
|
= map::HashMap();
|
||||||
|
|
||||||
do map(input) |key, val| {
|
do map(input) |key: &K2, val| {
|
||||||
let mut c = None;
|
let mut c = None;
|
||||||
let found = intermediates.find(key);
|
let found: Option<Chan<reduce_proto<V>>>
|
||||||
|
= intermediates.find(*key);
|
||||||
match found {
|
match found {
|
||||||
Some(_c) => { c = Some(_c); }
|
Some(_c) => { c = Some(_c); }
|
||||||
None => {
|
None => {
|
||||||
do ctrl.swap |ctrl| {
|
do ctrl.swap |ctrl| {
|
||||||
let ctrl = ctrl_proto::client::find_reducer(ctrl, key);
|
let ctrl = ctrl_proto::client::find_reducer(ctrl, *key);
|
||||||
match pipes::recv(ctrl) {
|
match pipes::recv(ctrl) {
|
||||||
ctrl_proto::reducer(c_, ctrl) => {
|
ctrl_proto::reducer(c_, ctrl) => {
|
||||||
c = Some(c_);
|
c = Some(c_);
|
||||||
@@ -184,7 +185,7 @@ mod map_reduce {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intermediates.insert(key, c.get());
|
intermediates.insert(*key, c.get());
|
||||||
send(c.get(), addref);
|
send(c.get(), addref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,7 @@ mod map_reduce {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reduce_task<K: Copy Send, V: Copy Send>(
|
fn reduce_task<K: Copy Send, V: Copy Send>(
|
||||||
reduce: reducer<K, V>,
|
reduce: ~reducer<K, V>,
|
||||||
key: K,
|
key: K,
|
||||||
out: Chan<Chan<reduce_proto<V>>>)
|
out: Chan<Chan<reduce_proto<V>>>)
|
||||||
{
|
{
|
||||||
@@ -231,7 +232,7 @@ mod map_reduce {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce(key, || get(p, ref_count, is_done) );
|
(*reduce)(&key, || get(p, ref_count, is_done) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
|
fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
|
||||||
@@ -245,7 +246,7 @@ mod map_reduce {
|
|||||||
// to do the rest.
|
// to do the rest.
|
||||||
|
|
||||||
let reducers = map::HashMap();
|
let reducers = map::HashMap();
|
||||||
let mut tasks = start_mappers(map, ctrl, inputs);
|
let mut tasks = start_mappers(&map, ctrl, &inputs);
|
||||||
let mut num_mappers = vec::len(inputs) as int;
|
let mut num_mappers = vec::len(inputs) as int;
|
||||||
|
|
||||||
while num_mappers > 0 {
|
while num_mappers > 0 {
|
||||||
@@ -270,7 +271,7 @@ mod map_reduce {
|
|||||||
let p = Port();
|
let p = Port();
|
||||||
let ch = Chan(&p);
|
let ch = Chan(&p);
|
||||||
let r = reduce, kk = k;
|
let r = reduce, kk = k;
|
||||||
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
|
tasks.push(spawn_joinable(|| reduce_task(~r, kk, ch) ));
|
||||||
c = recv(p);
|
c = recv(p);
|
||||||
reducers.insert(k, c);
|
reducers.insert(k, c);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user