Bulk-edit mutable -> mut.

This commit is contained in:
Graydon Hoare
2012-03-26 18:35:18 -07:00
parent 34283ce7e8
commit 6e6798c4e1
160 changed files with 772 additions and 772 deletions

View File

@@ -24,7 +24,7 @@ export spawn;
#[doc = "The future type"]
enum future<A> = {
mutable v: either<@A, fn@() -> A>
mut v: either<@A, fn@() -> A>
};
#[doc = "Methods on the `future` type"]
@@ -52,7 +52,7 @@ fn from_value<A>(+val: A) -> future<A> {
"];
future({
mutable v: either::left(@val)
mut v: either::left(@val)
})
}
@@ -79,7 +79,7 @@ fn from_fn<A>(f: fn@() -> A) -> future<A> {
"];
future({
mutable v: either::right(f)
mut v: either::right(f)
})
}

View File

@@ -174,10 +174,10 @@ fn convert_whence(whence: seek_style) -> i32 {
impl of reader for *libc::FILE {
fn read_bytes(len: uint) -> [u8] unsafe {
let mut buf : [mutable u8] = [mutable];
let mut buf : [mut u8] = [mut];
vec::reserve(buf, len);
vec::as_mut_buf(buf) {|b|
let read = libc::fread(b as *mutable c_void, 1u,
let read = libc::fread(b as *mut c_void, 1u,
len, self);
vec::unsafe::set_len(buf, read);
}
@@ -237,7 +237,7 @@ fn file_reader(path: str) -> result<reader, str> {
// Byte buffer readers
// TODO: const u8, but this fails with rustboot.
type byte_buf = {buf: [u8], mutable pos: uint, len: uint};
type byte_buf = {buf: [u8], mut pos: uint, len: uint};
impl of reader for byte_buf {
fn read_bytes(len: uint) -> [u8] {
@@ -268,7 +268,7 @@ fn bytes_reader(bytes: [u8]) -> reader {
}
fn bytes_reader_between(bytes: [u8], start: uint, end: uint) -> reader {
{buf: bytes, mutable pos: start, len: end} as reader
{buf: bytes, mut pos: start, len: end} as reader
}
fn with_bytes_reader<t>(bytes: [u8], f: fn(reader) -> t) -> t {
@@ -514,14 +514,14 @@ fn stderr() -> writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
fn print(s: str) { stdout().write_str(s); }
fn println(s: str) { stdout().write_line(s); }
type mem_buffer = @{mutable buf: [mutable u8],
mutable pos: uint};
type mem_buffer = @{mut buf: [mut u8],
mut pos: uint};
impl of writer for mem_buffer {
fn write(v: [const u8]) {
// Fast path.
if self.pos == vec::len(self.buf) {
for b: u8 in v { self.buf += [mutable b]; }
for b: u8 in v { self.buf += [mut b]; }
self.pos += vec::len(v);
ret;
}
@@ -531,7 +531,7 @@ impl of writer for mem_buffer {
while vpos < vlen {
let b = v[vpos];
if self.pos == vec::len(self.buf) {
self.buf += [mutable b];
self.buf += [mut b];
} else { self.buf[self.pos] = b; }
self.pos += 1u;
vpos += 1u;
@@ -547,7 +547,7 @@ impl of writer for mem_buffer {
}
fn mem_buffer() -> mem_buffer {
@{mutable buf: [mutable], mutable pos: 0u}
@{mut buf: [mut], mut pos: 0u}
}
fn mem_buffer_writer(b: mem_buffer) -> writer { b as writer }
fn mem_buffer_buf(b: mem_buffer) -> [u8] { vec::from_mut(b.buf) }

View File

@@ -346,17 +346,17 @@ mod types {
type LPCWSTR = *WCHAR;
type LPCSTR = *CHAR;
type LPWSTR = *mutable WCHAR;
type LPSTR = *mutable CHAR;
type LPWSTR = *mut WCHAR;
type LPSTR = *mut CHAR;
// Not really, but opaque to us.
type LPSECURITY_ATTRIBUTES = LPVOID;
type LPVOID = *mutable c_void;
type LPWORD = *mutable WORD;
type LPVOID = *mut c_void;
type LPWORD = *mut WORD;
type LRESULT = LONG_PTR;
type PBOOL = *mutable BOOL;
type PBOOL = *mut BOOL;
type WCHAR = wchar_t;
type WORD = u16;
}
@@ -757,7 +757,7 @@ mod funcs {
fn setbuf(stream: *FILE, buf: *c_char);
// Omitted: printf and scanf variants.
fn fgetc(stream: *FILE) -> c_int;
fn fgets(buf: *mutable c_char, n: c_int,
fn fgets(buf: *mut c_char, n: c_int,
stream: *FILE) -> *c_char;
fn fputc(c: c_int, stream: *FILE) -> c_int;
fn fputs(s: *c_char, stream: *FILE) -> *c_char;
@@ -769,7 +769,7 @@ mod funcs {
// Omitted: putc, putchar (might be macros).
fn puts(s: *c_char) -> c_int;
fn ungetc(c: c_int, stream: *FILE) -> c_int;
fn fread(ptr: *mutable c_void, size: size_t,
fn fread(ptr: *mut c_void, size: size_t,
nobj: size_t, stream: *FILE) -> size_t;
fn fwrite(ptr: *c_void, size: size_t,
nobj: size_t, stream: *FILE) -> size_t;
@@ -933,11 +933,11 @@ mod funcs {
fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
#[link_name = "_pipe"]
fn pipe(fds: *mutable c_int, psize: c_uint,
fn pipe(fds: *mut c_int, psize: c_uint,
textmode: c_int) -> c_int;
#[link_name = "_read"]
fn read(fd: c_int, buf: *mutable c_void, count: c_uint) -> c_int;
fn read(fd: c_int, buf: *mut c_void, count: c_uint) -> c_int;
#[link_name = "_rmdir"]
fn rmdir(path: *c_char) -> c_int;
@@ -1013,7 +1013,7 @@ mod funcs {
fn getegid() -> gid_t;
fn geteuid() -> uid_t;
fn getgid() -> gid_t ;
fn getgroups(ngroups_max: c_int, groups: *mutable gid_t) -> c_int;
fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int;
fn getlogin() -> *c_char;
fn getopt(argc: c_int, argv: **c_char, optstr: *c_char) -> c_int;
fn getpgrp() -> pid_t;
@@ -1025,8 +1025,8 @@ mod funcs {
fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
fn pathconf(path: *c_char, name: c_int) -> c_long;
fn pause() -> c_int;
fn pipe(fds: *mutable c_int) -> c_int;
fn read(fd: c_int, buf: *mutable c_void,
fn pipe(fds: *mut c_int) -> c_int;
fn read(fd: c_int, buf: *mut c_void,
count: size_t) -> ssize_t;
fn rmdir(path: *c_char) -> c_int;
fn setgid(gid: gid_t) -> c_int;
@@ -1050,7 +1050,7 @@ mod funcs {
#[nolink]
#[abi = "cdecl"]
native mod unistd {
fn readlink(path: *c_char, buf: *mutable c_char,
fn readlink(path: *c_char, buf: *mut c_char,
bufsz: size_t) -> ssize_t;
fn fsync(fd: c_int) -> c_int;
@@ -1067,7 +1067,7 @@ mod funcs {
#[nolink]
#[abi = "cdecl"]
native mod wait {
fn waitpid(pid: pid_t, status: *mutable c_int,
fn waitpid(pid: pid_t, status: *mut c_int,
options: c_int) -> pid_t;
}
}
@@ -1096,15 +1096,15 @@ mod funcs {
native mod bsd44 {
fn sysctl(name: *c_int, namelen: c_uint,
oldp: *mutable c_void, oldlenp: *mutable size_t,
oldp: *mut c_void, oldlenp: *mut size_t,
newp: *c_void, newlen: size_t) -> c_int;
fn sysctlbyname(name: *c_char,
oldp: *mutable c_void, oldlenp: *mutable size_t,
oldp: *mut c_void, oldlenp: *mut size_t,
newp: *c_void, newlen: size_t) -> c_int;
fn sysctlnametomib(name: *c_char, mibp: *mutable c_int,
sizep: *mutable size_t) -> c_int;
fn sysctlnametomib(name: *c_char, mibp: *mut c_int,
sizep: *mut size_t) -> c_int;
}
@@ -1118,8 +1118,8 @@ mod funcs {
#[nolink]
#[abi = "cdecl"]
native mod extra {
fn _NSGetExecutablePath(buf: *mutable c_char,
bufsize: *mutable u32) -> c_int;
fn _NSGetExecutablePath(buf: *mut c_char,
bufsize: *mut u32) -> c_int;
}
#[cfg(target_os = "freebsd")]

View File

@@ -109,10 +109,10 @@ fn test_unwrap_str() {
#[test]
fn test_unwrap_resource() {
resource r(i: @mutable int) {
resource r(i: @mut int) {
*i += 1;
}
let i = @mutable 0;
let i = @mut 0;
{
let x = r(i);
let opt = some(x);

View File

@@ -61,7 +61,7 @@ fn as_c_charp<T>(s: str, f: fn(*c_char) -> T) -> T {
str::as_c_str(s) {|b| f(b as *c_char) }
}
fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
-> option<str> {
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
vec::as_mut_buf(buf) { |b|
@@ -77,7 +77,7 @@ fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
mod win32 {
import dword = libc::types::os::arch::extra::DWORD;
fn fill_utf16_buf_and_decode(f: fn(*mutable u16, dword) -> dword)
fn fill_utf16_buf_and_decode(f: fn(*mut u16, dword) -> dword)
-> option<str> {
// FIXME: remove these when export globs work properly.
@@ -241,8 +241,8 @@ fn waitpid(pid: pid_t) -> c_int {
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "macos")]
fn pipe() -> {in: c_int, out: c_int} {
let fds = {mutable in: 0 as c_int,
mutable out: 0 as c_int };
let fds = {mut in: 0 as c_int,
mut out: 0 as c_int };
assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int));
ret {in: fds.in, out: fds.out};
}
@@ -258,8 +258,8 @@ fn pipe() -> {in: c_int, out: c_int} {
// understand. Here we explicitly make the pipe non-inheritable, which
// means to pass it to a subprocess they need to be duplicated first, as
// in rust_run_program.
let fds = { mutable in: 0 as c_int,
mutable out: 0 as c_int };
let fds = { mut in: 0 as c_int,
mut out: 0 as c_int };
let res = libc::pipe(ptr::mut_addr_of(fds.in),
1024 as c_uint,
(O_BINARY | O_NOINHERIT) as c_int);
@@ -294,7 +294,7 @@ fn self_exe_path() -> option<path> {
KERN_PROC as c_int,
KERN_PROC_PATHNAME as c_int, -1 as c_int];
sysctl(vec::unsafe::to_ptr(mib), vec::len(mib) as c_uint,
buf as *mutable c_void, ptr::mut_addr_of(sz),
buf as *mut c_void, ptr::mut_addr_of(sz),
ptr::null(), 0u as size_t) == (0 as c_int)
}
}

View File

@@ -28,9 +28,9 @@ native mod rusti {
#[inline(always)]
fn addr_of<T>(val: T) -> *T { rusti::addr_of(val) }
#[doc = "Get an unsafe mutable pointer to a value"]
#[doc = "Get an unsafe mut pointer to a value"]
#[inline(always)]
fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
fn mut_addr_of<T>(val: T) -> *mut T unsafe {
unsafe::reinterpret_cast(rusti::addr_of(val))
}
@@ -40,10 +40,10 @@ fn offset<T>(ptr: *T, count: uint) -> *T unsafe {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
#[doc = "Calculate the offset from a mutable pointer"]
#[doc = "Calculate the offset from a mut pointer"]
#[inline(always)]
fn mut_offset<T>(ptr: *mutable T, count: uint) -> *mutable T {
(ptr as uint + count * sys::size_of::<T>()) as *mutable T
fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
(ptr as uint + count * sys::size_of::<T>()) as *mut T
}
@@ -77,16 +77,16 @@ unsafe fn memmove<T>(dst: *T, src: *T, count: uint) {
#[test]
fn test() unsafe {
type pair = {mutable fst: int, mutable snd: int};
let p = {mutable fst: 10, mutable snd: 20};
let pptr: *mutable pair = mut_addr_of(p);
let iptr: *mutable int = unsafe::reinterpret_cast(pptr);
type pair = {mut fst: int, mut snd: int};
let p = {mut fst: 10, mut snd: 20};
let pptr: *mut pair = mut_addr_of(p);
let iptr: *mut int = unsafe::reinterpret_cast(pptr);
assert (*iptr == 10);;
*iptr = 30;
assert (*iptr == 30);
assert (p.fst == 30);;
*pptr = {mutable fst: 50, mutable snd: 60};
*pptr = {mut fst: 50, mut snd: 60};
assert (*iptr == 50);
assert (p.fst == 50);
assert (p.snd == 60);

View File

@@ -198,10 +198,10 @@ fn start_program(prog: str, args: [str]) -> program {
libc::close(pipe_err.out);
type prog_repr = {pid: pid_t,
mutable in_fd: c_int,
mut in_fd: c_int,
out_file: *libc::FILE,
err_file: *libc::FILE,
mutable finished: bool};
mut finished: bool};
fn close_repr_input(r: prog_repr) {
let invalid_fd = -1i32;
@@ -233,10 +233,10 @@ fn start_program(prog: str, args: [str]) -> program {
fn destroy() { destroy_repr(*self); }
}
let repr = {pid: pid,
mutable in_fd: pipe_input.out,
mut in_fd: pipe_input.out,
out_file: os::fdopen(pipe_output.in),
err_file: os::fdopen(pipe_err.in),
mutable finished: false};
mut finished: false};
ret prog_res(repr) as program;
}

View File

@@ -157,8 +157,8 @@ Provides detailed control over the properties and behavior of new tasks.
// the run function move them in.
enum task_builder {
task_builder_({
mutable opts: task_opts,
mutable gen_body: fn@(+fn~()) -> fn~(),
mut opts: task_opts,
mut gen_body: fn@(+fn~()) -> fn~(),
can_not_copy: option<comm::port<()>>
})
}
@@ -187,8 +187,8 @@ fn task_builder() -> task_builder {
let body_identity = fn@(+body: fn~()) -> fn~() { body };
task_builder_({
mutable opts: default_task_opts(),
mutable gen_body: body_identity,
mut opts: default_task_opts(),
mut gen_body: body_identity,
can_not_copy: none
})
}

View File

@@ -150,15 +150,15 @@ fn from_elem<T: copy>(n_elts: uint, t: T) -> [T] {
ret v;
}
#[doc = "Produces a mutable vector from an immutable vector."]
fn to_mut<T>(+v: [T]) -> [mutable T] unsafe {
#[doc = "Produces a mut vector from an immutable vector."]
fn to_mut<T>(+v: [T]) -> [mut T] unsafe {
let r = ::unsafe::reinterpret_cast(v);
::unsafe::forget(v);
r
}
#[doc = "Produces an immutable vector from a mutable vector."]
fn from_mut<T>(+v: [mutable T]) -> [T] unsafe {
#[doc = "Produces an immutable vector from a mut vector."]
fn from_mut<T>(+v: [mut T]) -> [T] unsafe {
let r = ::unsafe::reinterpret_cast(v);
::unsafe::forget(v);
r
@@ -396,7 +396,7 @@ Sets the element at position `index` to `val`. If `index` is past the end
of the vector, expands the vector by replicating `initval` to fill the
intervening space.
"]
fn grow_set<T: copy>(&v: [mutable T], index: uint, initval: T, val: T) {
fn grow_set<T: copy>(&v: [mut T], index: uint, initval: T, val: T) {
if index >= len(v) { grow(v, index - len(v) + 1u, initval); }
v[index] = val;
}
@@ -729,12 +729,12 @@ Swaps two elements in a vector
* a - The index of the first element
* b - The index of the second element
"]
fn swap<T>(v: [mutable T], a: uint, b: uint) {
fn swap<T>(v: [mut T], a: uint, b: uint) {
v[a] <-> v[b];
}
#[doc = "Reverse the order of elements in a vector, in place"]
fn reverse<T>(v: [mutable T]) {
fn reverse<T>(v: [mut T]) {
let mut i: uint = 0u;
let ln = len::<T>(v);
while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
@@ -890,8 +890,8 @@ fn as_buf<E,T>(v: [const E], f: fn(*E) -> T) -> T unsafe {
let buf = unsafe::to_ptr(v); f(buf)
}
fn as_mut_buf<E,T>(v: [mutable E], f: fn(*mutable E) -> T) -> T unsafe {
let buf = unsafe::to_ptr(v) as *mutable E; f(buf)
fn as_mut_buf<E,T>(v: [mut E], f: fn(*mut E) -> T) -> T unsafe {
let buf = unsafe::to_ptr(v) as *mut E; f(buf)
}
#[doc = "An extension implementation providing a `len` method"]
@@ -905,7 +905,7 @@ impl vec_len<T> for [const T] {
mod unsafe {
// FIXME: This should have crate visibility
#[doc = "The internal representation of a vector"]
type vec_repr = {mutable fill: uint, mutable alloc: uint, data: u8};
type vec_repr = {mut fill: uint, mut alloc: uint, data: u8};
#[doc = "
Constructs a vector from an unsafe pointer to a buffer
@@ -1212,7 +1212,7 @@ mod tests {
#[test]
fn test_grow_set() {
let mut v = [mutable 1, 2, 3];
let mut v = [mut 1, 2, 3];
grow_set(v, 4u, 4, 5);
assert (len(v) == 5u);
assert (v[0] == 1);
@@ -1619,7 +1619,7 @@ mod tests {
#[test]
fn reverse_and_reversed() {
let v: [mutable int] = [mutable 10, 20];
let v: [mut int] = [mut 10, 20];
assert (v[0] == 10);
assert (v[1] == 20);
reverse(v);
@@ -1634,13 +1634,13 @@ mod tests {
let v4 = reversed::<int>([]);
assert (v4 == []);
let v3: [mutable int] = [mutable];
let v3: [mut int] = [mut];
reverse::<int>(v3);
}
#[test]
fn reversed_mut() {
let v2 = reversed::<int>([mutable 10, 20]);
let v2 = reversed::<int>([mut 10, 20]);
assert (v2[0] == 20);
assert (v2[1] == 10);
}