Don't attempt to export uv functions directly

This commit is contained in:
Alex Crichton 2013-10-17 11:28:05 -07:00
parent b46f60a729
commit 59d45b8fe7
8 changed files with 84 additions and 52 deletions

View File

@ -115,13 +115,6 @@ impl StdReader {
Err(e) => io_error::cond.raise(e),
}
}
/// Resets the mode of this stream back to its original state.
///
/// # Failure
///
/// This function cannot fail.
pub fn reset_mode(&mut self) { self.inner.reset_mode(); }
}
impl Reader for StdReader {
@ -177,13 +170,6 @@ impl StdWriter {
Err(e) => io_error::cond.raise(e),
}
}
/// Resets the mode of this stream back to its original state.
///
/// # Failure
///
/// This function cannot fail.
pub fn reset_mode(&mut self) { self.inner.reset_mode(); }
}
impl Writer for StdWriter {

View File

@ -186,7 +186,6 @@ pub trait RtioTTY {
fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError>;
fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
fn set_raw(&mut self, raw: bool) -> Result<(), IoError>;
fn reset_mode(&mut self);
fn get_winsize(&mut self) -> Result<(int, int), IoError>;
}

View File

@ -40,7 +40,7 @@ impl Pipe {
#[fixed_stack_segment] #[inline(never)]
pub fn open(&mut self, file: libc::c_int) -> Result<(), uv::UvError> {
match unsafe { uvll::uv_pipe_open(self.native_handle(), file) } {
match unsafe { uvll::pipe_open(self.native_handle(), file) } {
0 => Ok(()),
n => Err(uv::UvError(n))
}
@ -49,7 +49,7 @@ impl Pipe {
#[fixed_stack_segment] #[inline(never)]
pub fn bind(&mut self, name: &CString) -> Result<(), uv::UvError> {
do name.with_ref |name| {
match unsafe { uvll::uv_pipe_bind(self.native_handle(), name) } {
match unsafe { uvll::pipe_bind(self.native_handle(), name) } {
0 => Ok(()),
n => Err(uv::UvError(n))
}
@ -68,10 +68,10 @@ impl Pipe {
let name = do name.with_ref |p| { p };
unsafe {
uvll::uv_pipe_connect(connect.native_handle(),
self.native_handle(),
name,
connect_cb)
uvll::pipe_connect(connect.native_handle(),
self.native_handle(),
name,
connect_cb)
}
extern "C" fn connect_cb(req: *uvll::uv_connect_t, status: libc::c_int) {

View File

@ -29,8 +29,8 @@ impl TTY {
assert!(handle.is_not_null());
let ret = unsafe {
uvll::uv_tty_init(loop_.native_handle(), handle, fd as libc::c_int,
readable as libc::c_int)
uvll::tty_init(loop_.native_handle(), handle, fd as libc::c_int,
readable as libc::c_int)
};
match ret {
0 => {
@ -52,17 +52,12 @@ impl TTY {
#[fixed_stack_segment] #[inline(never)]
pub fn set_mode(&self, raw: bool) -> Result<(), uv::UvError> {
let raw = raw as libc::c_int;
match unsafe { uvll::uv_tty_set_mode(self.native_handle(), raw) } {
match unsafe { uvll::tty_set_mode(self.native_handle(), raw) } {
0 => Ok(()),
n => Err(uv::UvError(n))
}
}
#[fixed_stack_segment] #[inline(never)]
pub fn reset_mode(&self) {
unsafe { uvll::uv_tty_reset_mode(self.native_handle()) }
}
#[fixed_stack_segment] #[inline(never)] #[allow(unused_mut)]
pub fn get_winsize(&self) -> Result<(int, int), uv::UvError> {
let mut width: libc::c_int = 0;
@ -70,8 +65,8 @@ impl TTY {
let widthptr: *libc::c_int = &width;
let heightptr: *libc::c_int = &width;
match unsafe { uvll::uv_tty_get_winsize(self.native_handle(),
widthptr, heightptr) } {
match unsafe { uvll::tty_get_winsize(self.native_handle(),
widthptr, heightptr) } {
0 => Ok((width as int, height as int)),
n => Err(uv::UvError(n))
}

View File

@ -1829,10 +1829,6 @@ impl RtioTTY for UvTTY {
}
}
fn reset_mode(&mut self) {
do self.home_for_io |self_| { self_.tty.reset_mode() }
}
fn get_winsize(&mut self) -> Result<(int, int), IoError> {
do self.home_for_io |self_| {
match self_.tty.get_winsize() {

View File

@ -959,6 +959,33 @@ pub unsafe fn freeaddrinfo(ai: *addrinfo) {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_freeaddrinfo(ai);
}
pub unsafe fn pipe_open(pipe: *uv_pipe_t, file: c_int) -> c_int {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_pipe_open(pipe, file)
}
pub unsafe fn pipe_bind(pipe: *uv_pipe_t, name: *c_char) -> c_int {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_pipe_bind(pipe, name)
}
pub unsafe fn pipe_connect(req: *uv_connect_t, handle: *uv_pipe_t,
name: *c_char, cb: uv_connect_cb) {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_pipe_connect(req, handle, name, cb)
}
pub unsafe fn tty_init(loop_ptr: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
readable: c_int) -> c_int {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_tty_init(loop_ptr, tty, fd, readable)
}
pub unsafe fn tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_tty_set_mode(tty, mode)
}
pub unsafe fn tty_get_winsize(tty: *uv_tty_t, width: *c_int,
height: *c_int) -> c_int {
#[fixed_stack_segment]; #[inline(never)];
rust_uv_tty_get_winsize(tty, width, height)
}
pub struct uv_err_data {
priv err_name: ~str,
@ -1104,16 +1131,15 @@ extern {
stream: *uv_stream_t);
fn rust_uv_pipe_init(loop_ptr: *c_void, p: *uv_pipe_t, ipc: c_int) -> c_int;
pub fn uv_pipe_open(pipe: *uv_pipe_t, file: c_int) -> c_int;
pub fn uv_pipe_bind(pipe: *uv_pipe_t, name: *c_char) -> c_int;
pub fn uv_pipe_connect(req: *uv_connect_t, handle: *uv_pipe_t,
name: *c_char, cb: uv_connect_cb);
pub fn uv_tty_init(loop_ptr: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
readable: c_int) -> c_int;
pub fn uv_tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int;
pub fn uv_tty_reset_mode(tty: *uv_tty_t);
pub fn uv_tty_get_winsize(tty: *uv_tty_t, width: *c_int,
height: *c_int) -> c_int;
fn rust_uv_pipe_open(pipe: *uv_pipe_t, file: c_int) -> c_int;
fn rust_uv_pipe_bind(pipe: *uv_pipe_t, name: *c_char) -> c_int;
fn rust_uv_pipe_connect(req: *uv_connect_t, handle: *uv_pipe_t,
name: *c_char, cb: uv_connect_cb);
fn rust_uv_tty_init(loop_ptr: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
readable: c_int) -> c_int;
fn rust_uv_tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int;
fn rust_uv_tty_get_winsize(tty: *uv_tty_t, width: *c_int,
height: *c_int) -> c_int;
// These should all really be constants...
#[rust_stack] pub fn rust_SOCK_STREAM() -> c_int;

View File

@ -650,3 +650,34 @@ extern "C" int rust_AI_NUMERICHOST() { return AI_NUMERICHOST; }
extern "C" int rust_AI_NUMERICSERV() { return AI_NUMERICSERV; }
extern "C" int rust_AI_PASSIVE() { return AI_PASSIVE; }
extern "C" int rust_AI_V4MAPPED() { return AI_V4MAPPED; }
extern "C" int
rust_uv_pipe_open(uv_pipe_t *pipe, int file) {
return uv_pipe_open(pipe, file);
}
extern "C" int
rust_uv_pipe_bind(uv_pipe_t *pipe, char *name) {
return uv_pipe_bind(pipe, name);
}
extern "C" void
rust_uv_pipe_connect(uv_connect_t *req, uv_pipe_t *handle,
char *name, uv_connect_cb cb) {
uv_pipe_connect(req, handle, name, cb);
}
extern "C" int
rust_uv_tty_init(uv_loop_t *loop, uv_tty_t *tty, int fd, int readable) {
return uv_tty_init(loop, tty, fd, readable);
}
extern "C" int
rust_uv_tty_set_mode(uv_tty_t *tty, int mode) {
return uv_tty_set_mode(tty, mode);
}
extern "C" int
rust_uv_tty_get_winsize(uv_tty_t *tty, int *width, int *height) {
return uv_tty_get_winsize(tty, width, height);
}

View File

@ -211,10 +211,9 @@ rust_AI_NUMERICHOST
rust_AI_NUMERICSERV
rust_AI_PASSIVE
rust_AI_V4MAPPED
uv_pipe_open
uv_pipe_bind
uv_pipe_connect
uv_tty_init
uv_tty_set_mode
uv_tty_reset_mode
uv_tty_get_winsize
rust_uv_pipe_open
rust_uv_pipe_bind
rust_uv_pipe_connect
rust_uv_tty_init
rust_uv_tty_set_mode
rust_uv_tty_get_winsize