about summary refs log tree commit diff
path: root/src/libnative/io
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-14 23:05:01 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-19 12:59:40 -0700
commit9d5d97b55d6487ee23b805bc1acbaa0669b82116 (patch)
treeb72dcf7045e331e94ea0f8658d088ab42d917935 /src/libnative/io
parentfb169d5543c84e11038ba2d07b538ec88fb49ca6 (diff)
Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.

This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.

[breaking-change]
Diffstat (limited to 'src/libnative/io')
-rw-r--r--src/libnative/io/addrinfo.rs10
-rw-r--r--src/libnative/io/c_windows.rs4
-rw-r--r--src/libnative/io/file_windows.rs6
-rw-r--r--src/libnative/io/helper_thread.rs7
-rw-r--r--src/libnative/io/pipe_windows.rs4
-rw-r--r--src/libnative/io/process.rs21
-rw-r--r--src/libnative/io/timer_unix.rs6
-rw-r--r--src/libnative/io/tty_windows.rs8
8 files changed, 36 insertions, 30 deletions
diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs
index 7a07b622127..d40438e4272 100644
--- a/src/libnative/io/addrinfo.rs
+++ b/src/libnative/io/addrinfo.rs
@@ -11,7 +11,7 @@
 use libc::{c_char, c_int};
 use libc;
 use std::mem;
-use std::ptr::{null, mut_null};
+use std::ptr::{null, null_mut};
 use std::rt::rtio;
 use std::rt::rtio::IoError;
 
@@ -38,16 +38,16 @@ impl GetAddrInfoRequest {
                 ai_socktype: 0,
                 ai_protocol: 0,
                 ai_addrlen: 0,
-                ai_canonname: mut_null(),
-                ai_addr: mut_null(),
-                ai_next: mut_null()
+                ai_canonname: null_mut(),
+                ai_addr: null_mut(),
+                ai_next: null_mut()
             }
         });
 
         let hint_ptr = hint.as_ref().map_or(null(), |x| {
             x as *const libc::addrinfo
         });
-        let mut res = mut_null();
+        let mut res = null_mut();
 
         // Make the call
         let s = unsafe {
diff --git a/src/libnative/io/c_windows.rs b/src/libnative/io/c_windows.rs
index 067a31166a5..eed3df28b8f 100644
--- a/src/libnative/io/c_windows.rs
+++ b/src/libnative/io/c_windows.rs
@@ -141,8 +141,8 @@ pub mod compat {
     // layer (after it's loaded) shouldn't be any slower than a regular DLL
     // call.
     unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) {
-        let module: Vec<u16> = module.utf16_units().collect();
-        let module = module.append_one(0);
+        let mut module: Vec<u16> = module.utf16_units().collect();
+        module.push(0);
         symbol.with_c_str(|symbol| {
             let handle = GetModuleHandleW(module.as_ptr());
             let func: uint = transmute(GetProcAddress(handle, symbol));
diff --git a/src/libnative/io/file_windows.rs b/src/libnative/io/file_windows.rs
index 6aa965948fd..eb4d4f22132 100644
--- a/src/libnative/io/file_windows.rs
+++ b/src/libnative/io/file_windows.rs
@@ -253,7 +253,11 @@ impl Drop for Inner {
 
 pub fn to_utf16(s: &CString) -> IoResult<Vec<u16>> {
     match s.as_str() {
-        Some(s) => Ok(s.utf16_units().collect::<Vec<u16>>().append_one(0)),
+        Some(s) => Ok({
+            let mut s = s.utf16_units().collect::<Vec<u16>>();
+            s.push(0);
+            s
+        }),
         None => Err(IoError {
             code: libc::ERROR_INVALID_NAME as uint,
             extra: 0,
diff --git a/src/libnative/io/helper_thread.rs b/src/libnative/io/helper_thread.rs
index 8aff1732a41..d1368ad31f4 100644
--- a/src/libnative/io/helper_thread.rs
+++ b/src/libnative/io/helper_thread.rs
@@ -22,13 +22,14 @@
 
 #![macro_escape]
 
+use std::cell::UnsafeCell;
 use std::mem;
 use std::rt::bookkeeping;
 use std::rt::mutex::StaticNativeMutex;
 use std::rt;
-use std::cell::UnsafeCell;
+use std::task::TaskBuilder;
 
-use task;
+use NativeTaskBuilder;
 
 /// A structure for management of a helper thread.
 ///
@@ -86,7 +87,7 @@ impl<M: Send> Helper<M> {
                 *self.signal.get() = send as uint;
 
                 let t = f();
-                task::spawn(proc() {
+                TaskBuilder::new().native().spawn(proc() {
                     bookkeeping::decrement();
                     helper(receive, rx, t);
                     self.lock.lock().signal()
diff --git a/src/libnative/io/pipe_windows.rs b/src/libnative/io/pipe_windows.rs
index 5475de6d7e1..bc08ede39f7 100644
--- a/src/libnative/io/pipe_windows.rs
+++ b/src/libnative/io/pipe_windows.rs
@@ -359,7 +359,7 @@ impl rtio::RtioPipe for UnixStream {
 
         let mut bytes_read = 0;
         let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
-        overlapped.hEvent = self.read.get_ref().handle();
+        overlapped.hEvent = self.read.as_ref().unwrap().handle();
 
         // Pre-flight check to see if the reading half has been closed. This
         // must be done before issuing the ReadFile request, but after we
@@ -431,7 +431,7 @@ impl rtio::RtioPipe for UnixStream {
 
         let mut offset = 0;
         let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
-        overlapped.hEvent = self.write.get_ref().handle();
+        overlapped.hEvent = self.write.as_ref().unwrap().handle();
 
         while offset < buf.len() {
             let mut bytes_written = 0;
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 2ca25f1eeb9..b94d81cff95 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -350,8 +350,8 @@ fn spawn_process_os(cfg: ProcessConfig,
                         lpSecurityDescriptor: ptr::null_mut(),
                         bInheritHandle: 1,
                     };
-                    let filename: Vec<u16> = "NUL".utf16_units().collect();
-                    let filename = filename.append_one(0);
+                    let mut filename: Vec<u16> = "NUL".utf16_units().collect();
+                    filename.push(0);
                     *slot = libc::CreateFileW(filename.as_ptr(),
                                               access,
                                               libc::FILE_SHARE_READ |
@@ -396,7 +396,7 @@ fn spawn_process_os(cfg: ProcessConfig,
         with_envp(cfg.env, |envp| {
             with_dirp(cfg.cwd, |dirp| {
                 let mut cmd_str: Vec<u16> = cmd_str.as_slice().utf16_units().collect();
-                cmd_str = cmd_str.append_one(0);
+                cmd_str.push(0);
                 let created = CreateProcessW(ptr::null(),
                                              cmd_str.as_mut_ptr(),
                                              ptr::null_mut(),
@@ -473,7 +473,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
     append_arg(&mut cmd, prog.as_str()
                              .expect("expected program name to be utf-8 encoded"));
     for arg in args.iter() {
-        cmd.push_char(' ');
+        cmd.push(' ');
         append_arg(&mut cmd, arg.as_str()
                                 .expect("expected argument to be utf-8 encoded"));
     }
@@ -485,14 +485,14 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
         // it will be dropped entirely when parsed on the other end.
         let quote = arg.chars().any(|c| c == ' ' || c == '\t') || arg.len() == 0;
         if quote {
-            cmd.push_char('"');
+            cmd.push('"');
         }
         let argvec: Vec<char> = arg.chars().collect();
         for i in range(0u, argvec.len()) {
             append_char_at(cmd, &argvec, i);
         }
         if quote {
-            cmd.push_char('"');
+            cmd.push('"');
         }
     }
 
@@ -508,11 +508,11 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
                     cmd.push_str("\\\\");
                 } else {
                     // Pass other backslashes through unescaped.
-                    cmd.push_char('\\');
+                    cmd.push('\\');
                 }
             }
             c => {
-                cmd.push_char(c);
+                cmd.push(c);
             }
         }
     }
@@ -817,9 +817,8 @@ fn with_dirp<T>(d: Option<&CString>, cb: |*const u16| -> T) -> T {
       Some(dir) => {
           let dir_str = dir.as_str()
                            .expect("expected workingdirectory to be utf-8 encoded");
-          let dir_str: Vec<u16> = dir_str.utf16_units().collect();
-          let dir_str = dir_str.append_one(0);
-
+          let mut dir_str: Vec<u16> = dir_str.utf16_units().collect();
+          dir_str.push(0);
           cb(dir_str.as_ptr())
       },
       None => cb(ptr::null())
diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs
index 4d4ba33aec4..6f57a5e88ba 100644
--- a/src/libnative/io/timer_unix.rs
+++ b/src/libnative/io/timer_unix.rs
@@ -115,7 +115,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
     // signals the first requests in the queue, possible re-enqueueing it.
     fn signal(active: &mut Vec<Box<Inner>>,
               dead: &mut Vec<(uint, Box<Inner>)>) {
-        let mut timer = match active.shift() {
+        let mut timer = match active.remove(0) {
             Some(timer) => timer, None => return
         };
         let mut cb = timer.cb.take().unwrap();
@@ -137,7 +137,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
             let now = now();
             // If this request has already expired, then signal it and go
             // through another iteration
-            if active.get(0).target <= now {
+            if active[0].target <= now {
                 signal(&mut active, &mut dead);
                 continue;
             }
@@ -145,7 +145,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
             // The actual timeout listed in the requests array is an
             // absolute date, so here we translate the absolute time to a
             // relative time.
-            let tm = active.get(0).target - now;
+            let tm = active[0].target - now;
             timeout.tv_sec = (tm / 1000) as libc::time_t;
             timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t;
             &mut timeout as *mut libc::timeval
diff --git a/src/libnative/io/tty_windows.rs b/src/libnative/io/tty_windows.rs
index 1c3904a8943..cf2a0f9dda4 100644
--- a/src/libnative/io/tty_windows.rs
+++ b/src/libnative/io/tty_windows.rs
@@ -36,7 +36,7 @@ use libc::types::os::arch::extra::LPCVOID;
 use std::io::MemReader;
 use std::ptr;
 use std::rt::rtio::{IoResult, IoError, RtioTTY};
-use std::str::{from_utf16, from_utf8};
+use std::str::from_utf8;
 
 fn invalid_encoding() -> IoError {
     IoError {
@@ -103,7 +103,7 @@ impl RtioTTY for WindowsTTY {
                 _ => (),
             };
             utf16.truncate(num as uint);
-            let utf8 = match from_utf16(utf16.as_slice()) {
+            let utf8 = match String::from_utf16(utf16.as_slice()) {
                 Some(utf8) => utf8.into_bytes(),
                 None => return Err(invalid_encoding()),
             };
@@ -115,7 +115,9 @@ impl RtioTTY for WindowsTTY {
 
     fn write(&mut self, buf: &[u8]) -> IoResult<()> {
         let utf16 = match from_utf8(buf) {
-            Some(utf8) => utf8.to_utf16(),
+            Some(utf8) => {
+                utf8.as_slice().utf16_units().collect::<Vec<u16>>()
+            }
             None => return Err(invalid_encoding()),
         };
         let mut num: DWORD = 0;