Skip to content

Commit 1850d26

Browse files
committed
Remove lots of uv/C++ wrappers
1 parent 556088c commit 1850d26

File tree

14 files changed

+272
-940
lines changed

14 files changed

+272
-940
lines changed

src/librustuv/addrinfo.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ impl GetAddrInfoRequest {
110110
self.get_req_data().getaddrinfo_cb = Some(wrapper_cb);
111111

112112
unsafe {
113-
assert!(0 == uvll::getaddrinfo(loop_.native_handle(),
114-
self.native_handle(),
115-
getaddrinfo_cb,
116-
c_node_ptr,
117-
c_service_ptr,
118-
hint_ptr));
113+
assert!(0 == uvll::uv_getaddrinfo(loop_.native_handle(),
114+
self.native_handle(),
115+
getaddrinfo_cb,
116+
c_node_ptr,
117+
c_service_ptr,
118+
hint_ptr));
119119
}
120120

121121
extern "C" fn getaddrinfo_cb(req: *uvll::uv_getaddrinfo_t,
@@ -127,7 +127,7 @@ impl GetAddrInfoRequest {
127127
let data = req.get_req_data();
128128
(*data.getaddrinfo_cb.get_ref())(req, &addrinfo, err);
129129
unsafe {
130-
uvll::freeaddrinfo(res);
130+
uvll::uv_freeaddrinfo(res);
131131
}
132132
}
133133
}

src/librustuv/async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl AsyncWatcher {
2626
watcher.install_watcher_data();
2727
let data = watcher.get_watcher_data();
2828
data.async_cb = Some(cb);
29-
assert_eq!(0, uvll::async_init(loop_.native_handle(), handle, async_cb));
29+
assert_eq!(0, uvll::uv_async_init(loop_.native_handle(), handle, async_cb));
3030
return watcher;
3131
}
3232

@@ -42,7 +42,7 @@ impl AsyncWatcher {
4242
pub fn send(&mut self) {
4343
unsafe {
4444
let handle = self.native_handle();
45-
uvll::async_send(handle);
45+
uvll::uv_async_send(handle);
4646
}
4747
}
4848
}

src/librustuv/file.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
use std::ptr::null;
1212
use std::c_str;
1313
use std::c_str::CString;
14-
use std::libc::c_void;
15-
use std::cast::transmute;
1614
use std::libc;
17-
use std::libc::{c_int};
15+
use std::libc::{c_void, c_int, c_uint};
16+
use std::cast::transmute;
1817

1918
use super::{Request, NativeHandle, Loop, FsCallback, Buf,
2019
status_to_maybe_uv_error, UvError};
@@ -43,8 +42,9 @@ impl FsRequest {
4342
me.req_boilerplate(Some(cb))
4443
};
4544
let ret = path.with_ref(|p| unsafe {
46-
uvll::fs_open(loop_.native_handle(),
47-
self.native_handle(), p, flags, mode, complete_cb_ptr)
45+
uvll::uv_fs_open(loop_.native_handle(),
46+
self.native_handle(), p, flags as c_int,
47+
mode as c_int, complete_cb_ptr)
4848
});
4949
assert_eq!(ret, 0);
5050
}
@@ -56,8 +56,9 @@ impl FsRequest {
5656
me.req_boilerplate(None)
5757
};
5858
let result = path.with_ref(|p| unsafe {
59-
uvll::fs_open(loop_.native_handle(),
60-
self.native_handle(), p, flags, mode, complete_cb_ptr)
59+
uvll::uv_fs_open(loop_.native_handle(),
60+
self.native_handle(), p, flags as c_int,
61+
mode as c_int, complete_cb_ptr)
6162
});
6263
self.sync_cleanup(result)
6364
}
@@ -68,8 +69,8 @@ impl FsRequest {
6869
me.req_boilerplate(Some(cb))
6970
};
7071
let ret = path.with_ref(|p| unsafe {
71-
uvll::fs_unlink(loop_.native_handle(),
72-
self.native_handle(), p, complete_cb_ptr)
72+
uvll::uv_fs_unlink(loop_.native_handle(),
73+
self.native_handle(), p, complete_cb_ptr)
7374
});
7475
assert_eq!(ret, 0);
7576
}
@@ -81,8 +82,8 @@ impl FsRequest {
8182
me.req_boilerplate(None)
8283
};
8384
let result = path.with_ref(|p| unsafe {
84-
uvll::fs_unlink(loop_.native_handle(),
85-
self.native_handle(), p, complete_cb_ptr)
85+
uvll::uv_fs_unlink(loop_.native_handle(),
86+
self.native_handle(), p, complete_cb_ptr)
8687
});
8788
self.sync_cleanup(result)
8889
}
@@ -93,8 +94,8 @@ impl FsRequest {
9394
me.req_boilerplate(Some(cb))
9495
};
9596
let ret = path.with_ref(|p| unsafe {
96-
uvll::fs_stat(loop_.native_handle(),
97-
self.native_handle(), p, complete_cb_ptr)
97+
uvll::uv_fs_stat(loop_.native_handle(),
98+
self.native_handle(), p, complete_cb_ptr)
9899
});
99100
assert_eq!(ret, 0);
100101
}
@@ -107,9 +108,9 @@ impl FsRequest {
107108
let base_ptr = buf.base as *c_void;
108109
let len = buf.len as uint;
109110
let ret = unsafe {
110-
uvll::fs_write(loop_.native_handle(), self.native_handle(),
111-
fd, base_ptr,
112-
len, offset, complete_cb_ptr)
111+
uvll::uv_fs_write(loop_.native_handle(), self.native_handle(),
112+
fd, base_ptr,
113+
len as c_uint, offset, complete_cb_ptr)
113114
};
114115
assert_eq!(ret, 0);
115116
}
@@ -122,9 +123,9 @@ impl FsRequest {
122123
let base_ptr = buf.base as *c_void;
123124
let len = buf.len as uint;
124125
let result = unsafe {
125-
uvll::fs_write(loop_.native_handle(), self.native_handle(),
126-
fd, base_ptr,
127-
len, offset, complete_cb_ptr)
126+
uvll::uv_fs_write(loop_.native_handle(), self.native_handle(),
127+
fd, base_ptr,
128+
len as c_uint, offset, complete_cb_ptr)
128129
};
129130
self.sync_cleanup(result)
130131
}
@@ -137,9 +138,9 @@ impl FsRequest {
137138
let buf_ptr = buf.base as *c_void;
138139
let len = buf.len as uint;
139140
let ret = unsafe {
140-
uvll::fs_read(loop_.native_handle(), self.native_handle(),
141-
fd, buf_ptr,
142-
len, offset, complete_cb_ptr)
141+
uvll::uv_fs_read(loop_.native_handle(), self.native_handle(),
142+
fd, buf_ptr,
143+
len as c_uint, offset, complete_cb_ptr)
143144
};
144145
assert_eq!(ret, 0);
145146
}
@@ -152,9 +153,9 @@ impl FsRequest {
152153
let buf_ptr = buf.base as *c_void;
153154
let len = buf.len as uint;
154155
let result = unsafe {
155-
uvll::fs_read(loop_.native_handle(), self.native_handle(),
156-
fd, buf_ptr,
157-
len, offset, complete_cb_ptr)
156+
uvll::uv_fs_read(loop_.native_handle(), self.native_handle(),
157+
fd, buf_ptr,
158+
len as c_uint, offset, complete_cb_ptr)
158159
};
159160
self.sync_cleanup(result)
160161
}
@@ -165,8 +166,8 @@ impl FsRequest {
165166
me.req_boilerplate(Some(cb))
166167
};
167168
let ret = unsafe {
168-
uvll::fs_close(loop_.native_handle(), self.native_handle(),
169-
fd, complete_cb_ptr)
169+
uvll::uv_fs_close(loop_.native_handle(), self.native_handle(),
170+
fd, complete_cb_ptr)
170171
};
171172
assert_eq!(ret, 0);
172173
}
@@ -176,8 +177,8 @@ impl FsRequest {
176177
me.req_boilerplate(None)
177178
};
178179
let result = unsafe {
179-
uvll::fs_close(loop_.native_handle(), self.native_handle(),
180-
fd, complete_cb_ptr)
180+
uvll::uv_fs_close(loop_.native_handle(), self.native_handle(),
181+
fd, complete_cb_ptr)
181182
};
182183
self.sync_cleanup(result)
183184
}
@@ -188,8 +189,9 @@ impl FsRequest {
188189
me.req_boilerplate(Some(cb))
189190
};
190191
let ret = path.with_ref(|p| unsafe {
191-
uvll::fs_mkdir(loop_.native_handle(),
192-
self.native_handle(), p, mode, complete_cb_ptr)
192+
uvll::uv_fs_mkdir(loop_.native_handle(),
193+
self.native_handle(), p,
194+
mode as c_int, complete_cb_ptr)
193195
});
194196
assert_eq!(ret, 0);
195197
}
@@ -200,8 +202,8 @@ impl FsRequest {
200202
me.req_boilerplate(Some(cb))
201203
};
202204
let ret = path.with_ref(|p| unsafe {
203-
uvll::fs_rmdir(loop_.native_handle(),
204-
self.native_handle(), p, complete_cb_ptr)
205+
uvll::uv_fs_rmdir(loop_.native_handle(),
206+
self.native_handle(), p, complete_cb_ptr)
205207
});
206208
assert_eq!(ret, 0);
207209
}
@@ -213,8 +215,8 @@ impl FsRequest {
213215
me.req_boilerplate(Some(cb))
214216
};
215217
let ret = path.with_ref(|p| unsafe {
216-
uvll::fs_readdir(loop_.native_handle(),
217-
self.native_handle(), p, flags, complete_cb_ptr)
218+
uvll::uv_fs_readdir(loop_.native_handle(),
219+
self.native_handle(), p, flags, complete_cb_ptr)
218220
});
219221
assert_eq!(ret, 0);
220222
}
@@ -228,12 +230,10 @@ impl FsRequest {
228230
None => Ok(result)
229231
}
230232
}
231-
fn req_boilerplate(&mut self, cb: Option<FsCallback>) -> *u8 {
233+
fn req_boilerplate(&mut self, cb: Option<FsCallback>) -> uvll::uv_fs_cb {
232234
let result = match cb {
233-
Some(_) => {
234-
compl_cb as *u8
235-
},
236-
None => 0 as *u8
235+
Some(_) => compl_cb,
236+
None => 0 as uvll::uv_fs_cb
237237
};
238238
self.install_req_data(cb);
239239
result
@@ -304,7 +304,7 @@ impl FsRequest {
304304
let data = uvll::get_data_for_req(self.native_handle());
305305
let _data = transmute::<*c_void, ~RequestData>(data);
306306
uvll::set_data_for_req(self.native_handle(), null::<()>());
307-
uvll::fs_req_cleanup(self.native_handle());
307+
uvll::uv_fs_req_cleanup(self.native_handle());
308308
free_req(self.native_handle() as *c_void)
309309
}
310310
}

src/librustuv/idle.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl IdleWatcher {
2121
unsafe {
2222
let handle = uvll::malloc_handle(uvll::UV_IDLE);
2323
assert!(handle.is_not_null());
24-
assert_eq!(uvll::idle_init(loop_.native_handle(), handle), 0);
24+
assert_eq!(uvll::uv_idle_init(loop_.native_handle(), handle), 0);
2525
let mut watcher: IdleWatcher = NativeHandle::from_native_handle(handle);
2626
watcher.install_watcher_data();
2727
return watcher
@@ -35,14 +35,14 @@ impl IdleWatcher {
3535
}
3636

3737
unsafe {
38-
assert_eq!(uvll::idle_start(self.native_handle(), idle_cb), 0)
38+
assert_eq!(uvll::uv_idle_start(self.native_handle(), idle_cb), 0)
3939
}
4040
}
4141

4242
pub fn restart(&mut self) {
4343
unsafe {
4444
assert!(self.get_watcher_data().idle_cb.is_some());
45-
assert_eq!(uvll::idle_start(self.native_handle(), idle_cb), 0)
45+
assert_eq!(uvll::uv_idle_start(self.native_handle(), idle_cb), 0)
4646
}
4747
}
4848

@@ -52,7 +52,7 @@ impl IdleWatcher {
5252
// free
5353

5454
unsafe {
55-
assert_eq!(uvll::idle_stop(self.native_handle()), 0);
55+
assert_eq!(uvll::uv_idle_stop(self.native_handle()), 0);
5656
}
5757
}
5858
}

src/librustuv/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::str::raw::from_c_str;
4848
use std::vec;
4949
use std::ptr;
5050
use std::str;
51-
use std::libc::{c_void, c_int, size_t, malloc, free};
51+
use std::libc::{c_void, c_int, size_t, malloc, free, c_char, c_uint};
5252
use std::cast::transmute;
5353
use std::ptr::null;
5454
use std::unstable::finally::Finally;
@@ -126,11 +126,11 @@ impl Loop {
126126
}
127127

128128
pub fn run(&mut self) {
129-
unsafe { uvll::run(self.native_handle()) };
129+
unsafe { uvll::uv_run(self.native_handle(), uvll::RUN_DEFAULT) };
130130
}
131131

132132
pub fn close(&mut self) {
133-
unsafe { uvll::loop_delete(self.native_handle()) };
133+
unsafe { uvll::uv_loop_delete(self.native_handle()) };
134134
}
135135
}
136136

@@ -239,7 +239,9 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
239239
data.close_cb = Some(cb);
240240
}
241241

242-
unsafe { uvll::close(self.native_handle(), close_cb); }
242+
unsafe {
243+
uvll::uv_close(self.native_handle() as *uvll::uv_handle_t, close_cb);
244+
}
243245

244246
extern fn close_cb(handle: *uvll::uv_handle_t) {
245247
let mut h: Handle = NativeHandle::from_native_handle(handle);
@@ -250,7 +252,9 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
250252
}
251253

252254
fn close_async(self) {
253-
unsafe { uvll::close(self.native_handle(), close_cb); }
255+
unsafe {
256+
uvll::uv_close(self.native_handle() as *uvll::uv_handle_t, close_cb);
257+
}
254258

255259
extern fn close_cb(handle: *uvll::uv_handle_t) {
256260
let mut h: Handle = NativeHandle::from_native_handle(handle);
@@ -269,7 +273,7 @@ impl UvError {
269273
pub fn name(&self) -> ~str {
270274
unsafe {
271275
let inner = match self { &UvError(a) => a };
272-
let name_str = uvll::err_name(inner);
276+
let name_str = uvll::uv_err_name(inner);
273277
assert!(name_str.is_not_null());
274278
from_c_str(name_str)
275279
}
@@ -278,7 +282,7 @@ impl UvError {
278282
pub fn desc(&self) -> ~str {
279283
unsafe {
280284
let inner = match self { &UvError(a) => a };
281-
let desc_str = uvll::strerror(inner);
285+
let desc_str = uvll::uv_strerror(inner);
282286
assert!(desc_str.is_not_null());
283287
from_c_str(desc_str)
284288
}
@@ -308,7 +312,7 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
308312
use std::rt::io::*;
309313
310314
// uv error descriptions are static
311-
let c_desc = uvll::strerror(*uverr);
315+
let c_desc = uvll::uv_strerror(*uverr);
312316
let desc = str::raw::c_str_to_static_slice(c_desc);
313317
314318
let kind = match *uverr {
@@ -359,7 +363,7 @@ pub fn empty_buf() -> Buf {
359363
/// Borrow a slice to a Buf
360364
pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
361365
let data = vec::raw::to_ptr(v);
362-
unsafe { uvll::buf_init(data, v.len()) }
366+
unsafe { uvll::uv_buf_init(data as *c_char, v.len() as c_uint) }
363367
}
364368
365369
// XXX: Do these conversions without copying
@@ -375,7 +379,7 @@ pub fn vec_to_uv_buf(v: ~[u8]) -> Buf {
375379
let data = data as *mut u8;
376380
ptr::copy_memory(data, b, l)
377381
}
378-
uvll::buf_init(data, v.len())
382+
uvll::uv_buf_init(data as *c_char, v.len() as c_uint)
379383
}
380384
}
381385

0 commit comments

Comments
 (0)