1
Fork 0

convert most of libstd over to structs

This commit is contained in:
Erick Tryzelaar 2013-01-22 08:44:24 -08:00
parent c15facb5c0
commit e84576b888
13 changed files with 544 additions and 418 deletions

View file

@ -158,17 +158,10 @@ fn run_tests(config: config) {
} }
fn test_opts(config: config) -> test::TestOpts { fn test_opts(config: config) -> test::TestOpts {
{filter: test::TestOpts {
match config.filter { filter: config.filter,
option::Some(s) => option::Some(s),
option::None => option::None
},
run_ignored: config.run_ignored, run_ignored: config.run_ignored,
logfile: logfile: config.logfile.map(|s| s.to_str()),
match config.logfile {
option::Some(s) => option::Some(s.to_str()),
option::None => option::None
}
} }
} }

View file

@ -287,7 +287,7 @@ fn get_lint_settings_level(settings: lint_settings,
// This is kind of unfortunate. It should be somewhere else, or we should use // This is kind of unfortunate. It should be somewhere else, or we should use
// a persistent data structure... // a persistent data structure...
fn clone_lint_modes(modes: lint_modes) -> lint_modes { fn clone_lint_modes(modes: lint_modes) -> lint_modes {
smallintmap::SmallIntMap_(@{v: copy modes.v}) smallintmap::SmallIntMap_(@smallintmap::SmallIntMap_ { v: copy modes.v })
} }
type ctxt_ = {dict: lint_dict, type ctxt_ = {dict: lint_dict,

View file

@ -68,7 +68,11 @@ const tydesc_drop_glue_index: size_t = 3 as size_t;
// The way arena uses arrays is really deeply awful. The arrays are // The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array // allocated, and have capacities reserved, but the fill for the array
// will always stay at 0. // will always stay at 0.
type Chunk = {data: @[u8], mut fill: uint, is_pod: bool}; struct Chunk {
data: @[u8],
mut fill: uint,
is_pod: bool,
}
pub struct Arena { pub struct Arena {
// The head is seperated out from the list as a unbenchmarked // The head is seperated out from the list as a unbenchmarked
@ -93,13 +97,19 @@ impl Arena : Drop {
fn chunk(size: uint, is_pod: bool) -> Chunk { fn chunk(size: uint, is_pod: bool) -> Chunk {
let mut v: @[const u8] = @[]; let mut v: @[const u8] = @[];
unsafe { at_vec::raw::reserve(&mut v, size); } unsafe { at_vec::raw::reserve(&mut v, size); }
{ data: unsafe { cast::transmute(v) }, mut fill: 0u, is_pod: is_pod } Chunk {
data: unsafe { cast::transmute(v) },
fill: 0u,
is_pod: is_pod,
}
} }
pub fn arena_with_size(initial_size: uint) -> Arena { pub fn arena_with_size(initial_size: uint) -> Arena {
return Arena {mut head: chunk(initial_size, false), Arena {
mut pod_head: chunk(initial_size, true), head: chunk(initial_size, false),
mut chunks: @Nil}; pod_head: chunk(initial_size, true),
chunks: @Nil,
}
} }
pub fn Arena() -> Arena { pub fn Arena() -> Arena {

View file

@ -61,10 +61,12 @@ pub fn create<T: Copy>() -> Deque<T> {
match (*elts).get_elt(i) { Some(move t) => t, _ => fail } match (*elts).get_elt(i) { Some(move t) => t, _ => fail }
} }
type Repr<T> = {mut nelts: uint, struct Repr<T> {
mut nelts: uint,
mut lo: uint, mut lo: uint,
mut hi: uint, mut hi: uint,
elts: DVec<Cell<T>>}; elts: DVec<Cell<T>>,
}
impl <T: Copy> Repr<T>: Deque<T> { impl <T: Copy> Repr<T>: Deque<T> {
fn size() -> uint { return self.nelts; } fn size() -> uint { return self.nelts; }
@ -119,15 +121,14 @@ pub fn create<T: Copy>() -> Deque<T> {
} }
} }
let repr: Repr<T> = { let repr: Repr<T> = Repr {
mut nelts: 0u, nelts: 0u,
mut lo: 0u, lo: 0u,
mut hi: 0u, hi: 0u,
elts: elts: dvec::from_vec(vec::from_elem(initial_capacity, None)),
dvec::from_vec(
vec::from_elem(initial_capacity, None))
}; };
(move repr) as Deque::<T>
repr as Deque::<T>
} }
#[cfg(test)] #[cfg(test)]
@ -254,7 +255,11 @@ mod tests {
Onepar(int), Twopar(int, int), Threepar(int, int, int), Onepar(int), Twopar(int, int), Threepar(int, int, int),
} }
type RecCy = {x: int, y: int, t: Taggy}; struct RecCy {
x: int,
y: int,
t: Taggy,
}
impl Taggy : Eq { impl Taggy : Eq {
pure fn eq(&self, other: &Taggy) -> bool { pure fn eq(&self, other: &Taggy) -> bool {
@ -335,10 +340,10 @@ mod tests {
#[test] #[test]
fn test_param_reccy() { fn test_param_reccy() {
let reccy1: RecCy = {x: 1, y: 2, t: One(1)}; let reccy1 = RecCy { x: 1, y: 2, t: One(1) };
let reccy2: RecCy = {x: 345, y: 2, t: Two(1, 2)}; let reccy2 = RecCy { x: 345, y: 2, t: Two(1, 2) };
let reccy3: RecCy = {x: 1, y: 777, t: Three(1, 2, 3)}; let reccy3 = RecCy { x: 1, y: 777, t: Three(1, 2, 3) };
let reccy4: RecCy = {x: 19, y: 252, t: Two(17, 42)}; let reccy4 = RecCy { x: 19, y: 252, t: Two(17, 42) };
test_parameterized::<RecCy>(reccy1, reccy2, reccy3, reccy4); test_parameterized::<RecCy>(reccy1, reccy2, reccy3, reccy4);
} }
} }

View file

@ -107,7 +107,11 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
} }
pub mod util { pub mod util {
pub type Rational = {num: int, den: int}; // : int::positive(*.den); pub struct Rational {
// : int::positive(*.den);
num: int,
den: int,
}
pub pure fn rational_leq(x: Rational, y: Rational) -> bool { pub pure fn rational_leq(x: Rational, y: Rational) -> bool {
// NB: Uses the fact that rationals have positive denominators WLOG: // NB: Uses the fact that rationals have positive denominators WLOG:
@ -265,9 +269,11 @@ pub mod chained {
// consider rehashing if more 3/4 full // consider rehashing if more 3/4 full
let nchains = vec::len(self.chains); let nchains = vec::len(self.chains);
let load = {num: (self.count + 1u) as int, let load = util::Rational {
den: nchains as int}; num: (self.count + 1u) as int,
if !util::rational_leq(load, {num:3, den:4}) { den: nchains as int,
};
if !util::rational_leq(load, util::Rational {num:3, den:4}) {
self.rehash(); self.rehash();
} }
@ -324,9 +330,11 @@ pub mod chained {
// consider rehashing if more 3/4 full // consider rehashing if more 3/4 full
let nchains = vec::len(self.chains); let nchains = vec::len(self.chains);
let load = {num: (self.count + 1u) as int, let load = util::Rational {
den: nchains as int}; num: (self.count + 1u) as int,
if !util::rational_leq(load, {num:3, den:4}) { den: nchains as int,
};
if !util::rational_leq(load, util::Rational {num:3, den:4}) {
self.rehash(); self.rehash();
} }

View file

@ -48,9 +48,9 @@ pub enum IpAddr {
} }
/// Human-friendly feedback on why a parse_addr attempt failed /// Human-friendly feedback on why a parse_addr attempt failed
pub type ParseAddrErr = { pub struct ParseAddrErr {
err_msg: ~str err_msg: ~str,
}; }
/** /**
* Convert a `IpAddr` to a str * Convert a `IpAddr` to a str
@ -122,7 +122,7 @@ pub fn get_addr(node: &str, iotask: iotask)
log(debug, fmt!("slice len %?", len)); log(debug, fmt!("slice len %?", len));
let handle = create_uv_getaddrinfo_t(); let handle = create_uv_getaddrinfo_t();
let handle_ptr = ptr::addr_of(&handle); let handle_ptr = ptr::addr_of(&handle);
let handle_data: GetAddrData = { let handle_data = GetAddrData {
output_ch: output_ch output_ch: output_ch
}; };
let handle_data_ptr = ptr::addr_of(&handle_data); let handle_data_ptr = ptr::addr_of(&handle_data);
@ -187,7 +187,7 @@ pub mod v4 {
} }
// the simple, old style numberic representation of // the simple, old style numberic representation of
// ipv4 // ipv4
pub type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 }; pub struct Ipv4Rep { a: u8, b: u8, c: u8, d: u8 }
pub trait AsUnsafeU32 { pub trait AsUnsafeU32 {
unsafe fn as_u32() -> u32; unsafe fn as_u32() -> u32;
@ -207,14 +207,14 @@ pub mod v4 {
} }
}); });
if parts.len() != 4 { if parts.len() != 4 {
result::Err(fmt!("'%s' doesn't have 4 parts", ip)) Err(fmt!("'%s' doesn't have 4 parts", ip))
} } else if parts.contains(&256) {
else if parts.contains(&256) { Err(fmt!("invalid octal in addr '%s'", ip))
result::Err(fmt!("invalid octal in addr '%s'", ip)) } else {
} Ok(Ipv4Rep {
else { a: parts[0] as u8, b: parts[1] as u8,
result::Ok({a: parts[0] as u8, b: parts[1] as u8, c: parts[2] as u8, d: parts[3] as u8,
c: parts[2] as u8, d: parts[3] as u8}) })
} }
} }
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> { pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
@ -223,7 +223,7 @@ pub mod v4 {
let ip_rep_result = parse_to_ipv4_rep(ip); let ip_rep_result = parse_to_ipv4_rep(ip);
if result::is_err(&ip_rep_result) { if result::is_err(&ip_rep_result) {
let err_str = result::get_err(&ip_rep_result); let err_str = result::get_err(&ip_rep_result);
return result::Err({err_msg: err_str}) return result::Err(ParseAddrErr { err_msg: err_str })
} }
// ipv4_rep.as_u32 is unsafe :/ // ipv4_rep.as_u32 is unsafe :/
let input_is_inaddr_none = let input_is_inaddr_none =
@ -236,15 +236,16 @@ pub mod v4 {
let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name); let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name);
if result::is_err(&ref_ip_rep_result) { if result::is_err(&ref_ip_rep_result) {
let err_str = result::get_err(&ref_ip_rep_result); let err_str = result::get_err(&ref_ip_rep_result);
return result::Err({err_msg: err_str}) return Err(ParseAddrErr { err_msg: err_str })
} }
if result::get(&ref_ip_rep_result).as_u32() == INADDR_NONE && if result::get(&ref_ip_rep_result).as_u32() == INADDR_NONE &&
!input_is_inaddr_none { !input_is_inaddr_none {
return result::Err( Err(ParseAddrErr {
{err_msg: ~"uv_ip4_name produced invalid result."}) err_msg: ~"uv_ip4_name produced invalid result.",
} })
else { } else {
result::Ok(Ipv4(copy(new_addr))) Ok(Ipv4(copy(new_addr)))
} }
} }
} }
@ -289,19 +290,18 @@ pub mod v6 {
// '::' appears to be uv_ip6_name() returns for bogus // '::' appears to be uv_ip6_name() returns for bogus
// parses.. // parses..
if ip != &"::" && reparsed_name == ~"::" { if ip != &"::" && reparsed_name == ~"::" {
result::Err({err_msg:fmt!("failed to parse '%s'", Err(ParseAddrErr { err_msg:fmt!("failed to parse '%s'", ip) })
ip)})
} }
else { else {
result::Ok(Ipv6(new_addr)) Ok(Ipv6(new_addr))
} }
} }
} }
} }
type GetAddrData = { struct GetAddrData {
output_ch: oldcomm::Chan<result::Result<~[IpAddr],IpGetAddrErr>> output_ch: oldcomm::Chan<result::Result<~[IpAddr],IpGetAddrErr>>
}; }
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
res: *addrinfo) { res: *addrinfo) {

View file

@ -83,10 +83,11 @@ pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
} }
/// Contains raw, string-based, error information returned from libuv /// Contains raw, string-based, error information returned from libuv
pub type TcpErrData = { pub struct TcpErrData {
err_name: ~str, err_name: ~str,
err_msg: ~str err_msg: ~str,
}; }
/// Details returned as part of a `result::err` result from `tcp::listen` /// Details returned as part of a `result::err` result from `tcp::listen`
pub enum TcpListenErrData { pub enum TcpListenErrData {
/** /**
@ -155,7 +156,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
let reader_po = oldcomm::Port::<result::Result<~[u8], TcpErrData>>(); let reader_po = oldcomm::Port::<result::Result<~[u8], TcpErrData>>();
let stream_handle_ptr = malloc_uv_tcp_t(); let stream_handle_ptr = malloc_uv_tcp_t();
*(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t(); *(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t();
let socket_data = @{ let socket_data = @TcpSocketData {
reader_po: reader_po, reader_po: reader_po,
reader_ch: oldcomm::Chan(&reader_po), reader_ch: oldcomm::Chan(&reader_po),
stream_handle_ptr: stream_handle_ptr, stream_handle_ptr: stream_handle_ptr,
@ -231,7 +232,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
// ip or somesuch // ip or somesuch
let err_data = uv::ll::get_last_err_data(loop_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr);
oldcomm::send((*conn_data_ptr).result_ch, oldcomm::send((*conn_data_ptr).result_ch,
ConnFailure(err_data.to_tcp_err())); ConnFailure(err_data));
uv::ll::set_data_for_uv_handle(stream_handle_ptr, uv::ll::set_data_for_uv_handle(stream_handle_ptr,
conn_data_ptr); conn_data_ptr);
uv::ll::close(stream_handle_ptr, uv::ll::close(stream_handle_ptr,
@ -243,7 +244,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
// failure to create a tcp handle // failure to create a tcp handle
let err_data = uv::ll::get_last_err_data(loop_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr);
oldcomm::send((*conn_data_ptr).result_ch, oldcomm::send((*conn_data_ptr).result_ch,
ConnFailure(err_data.to_tcp_err())); ConnFailure(err_data));
} }
} }
} }
@ -513,7 +514,7 @@ pub fn accept(new_conn: TcpNewConnection)
let iotask = (*server_data_ptr).iotask; let iotask = (*server_data_ptr).iotask;
let stream_handle_ptr = malloc_uv_tcp_t(); let stream_handle_ptr = malloc_uv_tcp_t();
*(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t(); *(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t();
let client_socket_data = @{ let client_socket_data = @TcpSocketData {
reader_po: reader_po, reader_po: reader_po,
reader_ch: oldcomm::Chan(&reader_po), reader_ch: oldcomm::Chan(&reader_po),
stream_handle_ptr : stream_handle_ptr, stream_handle_ptr : stream_handle_ptr,
@ -785,7 +786,7 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
* A buffered wrapper that you can cast as an `io::reader` or `io::writer` * A buffered wrapper that you can cast as an `io::reader` or `io::writer`
*/ */
pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
TcpSocketBuf(@{ sock: move sock, mut buf: ~[] }) TcpSocketBuf(@TcpBufferedSocketData { sock: sock, buf: ~[] })
} }
/// Convenience methods extending `net::tcp::tcp_socket` /// Convenience methods extending `net::tcp::tcp_socket`
@ -979,7 +980,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint)
match move read_result { match move read_result {
None => { None => {
log(debug, ~"tcp::read: timed out.."); log(debug, ~"tcp::read: timed out..");
let err_data = { let err_data = TcpErrData {
err_name: ~"TIMEOUT", err_name: ~"TIMEOUT",
err_msg: ~"req timed out" err_msg: ~"req timed out"
}; };
@ -1020,9 +1021,10 @@ fn read_stop_common_impl(socket_data: *TcpSocketData) ->
} }
} }
}; };
match oldcomm::recv(stop_po) { match oldcomm::recv(stop_po) {
Some(ref err_data) => result::Err(err_data.to_tcp_err()), Some(move err_data) => Err(err_data),
None => result::Ok(()) None => Ok(())
} }
} }
} }
@ -1108,8 +1110,8 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData,
// ownership of everything to the I/O task and let it deal with the // ownership of everything to the I/O task and let it deal with the
// aftermath, so we don't have to sit here blocking. // aftermath, so we don't have to sit here blocking.
match oldcomm::recv(result_po) { match oldcomm::recv(result_po) {
TcpWriteSuccess => result::Ok(()), TcpWriteSuccess => Ok(()),
TcpWriteError(ref err_data) => result::Err(err_data.to_tcp_err()) TcpWriteError(move err_data) => Err(err_data)
} }
} }
} }
@ -1118,15 +1120,15 @@ enum TcpNewConnection {
NewTcpConn(*uv::ll::uv_tcp_t) NewTcpConn(*uv::ll::uv_tcp_t)
} }
type TcpListenFcData = { struct TcpListenFcData {
server_stream_ptr: *uv::ll::uv_tcp_t, server_stream_ptr: *uv::ll::uv_tcp_t,
stream_closed_ch: oldcomm::Chan<()>, stream_closed_ch: oldcomm::Chan<()>,
kill_ch: oldcomm::Chan<Option<TcpErrData>>, kill_ch: oldcomm::Chan<Option<TcpErrData>>,
on_connect_cb: fn~(*uv::ll::uv_tcp_t), on_connect_cb: fn~(*uv::ll::uv_tcp_t),
iotask: IoTask, iotask: IoTask,
ipv6: bool, ipv6: bool,
mut active: bool mut active: bool,
}; }
extern fn tcp_lfc_close_cb(handle: *uv::ll::uv_tcp_t) { extern fn tcp_lfc_close_cb(handle: *uv::ll::uv_tcp_t) {
unsafe { unsafe {
@ -1191,7 +1193,7 @@ trait ToTcpErr {
impl uv::ll::uv_err_data: ToTcpErr { impl uv::ll::uv_err_data: ToTcpErr {
fn to_tcp_err() -> TcpErrData { fn to_tcp_err() -> TcpErrData {
{ err_name: self.err_name, err_msg: self.err_msg } TcpErrData { err_name: self.err_name, err_msg: self.err_msg }
} }
} }
@ -1244,9 +1246,9 @@ extern fn on_alloc_cb(handle: *libc::c_void,
} }
} }
type TcpSocketCloseData = { struct TcpSocketCloseData {
closed_ch: oldcomm::Chan<()> closed_ch: oldcomm::Chan<()>,
}; }
extern fn tcp_socket_dtor_close_cb(handle: *uv::ll::uv_tcp_t) { extern fn tcp_socket_dtor_close_cb(handle: *uv::ll::uv_tcp_t) {
unsafe { unsafe {
@ -1273,19 +1275,19 @@ extern fn tcp_write_complete_cb(write_req: *uv::ll::uv_write_t,
let err_data = uv::ll::get_last_err_data(loop_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr);
log(debug, ~"failure to write"); log(debug, ~"failure to write");
oldcomm::send((*write_data_ptr).result_ch, oldcomm::send((*write_data_ptr).result_ch,
TcpWriteError(err_data)); TcpWriteError(err_data.to_tcp_err()));
} }
} }
} }
type WriteReqData = { struct WriteReqData {
result_ch: oldcomm::Chan<TcpWriteResult> result_ch: oldcomm::Chan<TcpWriteResult>,
}; }
type ConnectReqData = { struct ConnectReqData {
result_ch: oldcomm::Chan<ConnAttempt>, result_ch: oldcomm::Chan<ConnAttempt>,
closed_signal_ch: oldcomm::Chan<()> closed_signal_ch: oldcomm::Chan<()>,
}; }
extern fn stream_error_close_cb(handle: *uv::ll::uv_tcp_t) { extern fn stream_error_close_cb(handle: *uv::ll::uv_tcp_t) {
unsafe { unsafe {
@ -1337,20 +1339,20 @@ enum ConnAttempt {
ConnFailure(uv::ll::uv_err_data) ConnFailure(uv::ll::uv_err_data)
} }
type TcpSocketData = { struct TcpSocketData {
reader_po: oldcomm::Port<result::Result<~[u8], TcpErrData>>, reader_po: oldcomm::Port<result::Result<~[u8], TcpErrData>>,
reader_ch: oldcomm::Chan<result::Result<~[u8], TcpErrData>>, reader_ch: oldcomm::Chan<result::Result<~[u8], TcpErrData>>,
stream_handle_ptr: *uv::ll::uv_tcp_t, stream_handle_ptr: *uv::ll::uv_tcp_t,
connect_req: uv::ll::uv_connect_t, connect_req: uv::ll::uv_connect_t,
write_req: uv::ll::uv_write_t, write_req: uv::ll::uv_write_t,
ipv6: bool, ipv6: bool,
iotask: IoTask iotask: IoTask,
}; }
type TcpBufferedSocketData = { struct TcpBufferedSocketData {
sock: TcpSocket, sock: TcpSocket,
mut buf: ~[u8] mut buf: ~[u8],
}; }
//#[cfg(test)] //#[cfg(test)]
pub mod test { pub mod test {

View file

@ -595,12 +595,12 @@ pub mod node {
* string can be shared between several ropes, e.g. for indexing * string can be shared between several ropes, e.g. for indexing
* purposes. * purposes.
*/ */
pub type Leaf = { pub struct Leaf {
byte_offset: uint, byte_offset: uint,
byte_len: uint, byte_len: uint,
char_len: uint, char_len: uint,
content: @~str content: @~str,
}; }
/** /**
* A node obtained from the concatenation of two other nodes * A node obtained from the concatenation of two other nodes
@ -619,14 +619,14 @@ pub mod node {
* *
* Used for rebalancing and to allocate stacks for traversals. * Used for rebalancing and to allocate stacks for traversals.
*/ */
pub type Concat = { pub struct Concat {
//FIXME (#2744): Perhaps a `vec` instead of `left`/`right` //FIXME (#2744): Perhaps a `vec` instead of `left`/`right`
left: @Node, left: @Node,
right: @Node, right: @Node,
char_len: uint, char_len: uint,
byte_len: uint, byte_len: uint,
height: uint height: uint,
}; }
pub enum Node { pub enum Node {
/// A leaf consisting in a `str` /// A leaf consisting in a `str`
@ -709,11 +709,12 @@ pub mod node {
pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint,
char_len: uint) -> @Node { char_len: uint) -> @Node {
assert(byte_start + byte_len <= str::len(*str)); assert(byte_start + byte_len <= str::len(*str));
let candidate = @Leaf({ let candidate = @Leaf(Leaf {
byte_offset: byte_start, byte_offset: byte_start,
byte_len: byte_len, byte_len: byte_len,
char_len: char_len, char_len: char_len,
content: str}); content: str,
});
if char_len <= hint_max_leaf_char_len { if char_len <= hint_max_leaf_char_len {
return candidate; return candidate;
} else { } else {
@ -736,11 +737,11 @@ pub mod node {
else { hint_max_leaf_char_len }; else { hint_max_leaf_char_len };
let chunk_byte_len = let chunk_byte_len =
str::count_bytes(*str, offset, chunk_char_len); str::count_bytes(*str, offset, chunk_char_len);
nodes[i] = @Leaf({ nodes[i] = @Leaf(Leaf {
byte_offset: offset, byte_offset: offset,
byte_len: chunk_byte_len, byte_len: chunk_byte_len,
char_len: chunk_char_len, char_len: chunk_char_len,
content: str content: str,
}); });
offset += chunk_byte_len; offset += chunk_byte_len;
@ -767,15 +768,15 @@ pub mod node {
pub pure fn byte_len(node: @Node) -> uint { pub pure fn byte_len(node: @Node) -> uint {
//FIXME (#2744): Could we do this without the pattern-matching? //FIXME (#2744): Could we do this without the pattern-matching?
match (*node) { match (*node) {
Leaf(y) => return y.byte_len, Leaf(y) => y.byte_len,
Concat(ref y) => return y.byte_len Concat(ref y) => y.byte_len
} }
} }
pub pure fn char_len(node: @Node) -> uint { pub pure fn char_len(node: @Node) -> uint {
match (*node) { match (*node) {
Leaf(y) => return y.char_len, Leaf(y) => y.char_len,
Concat(ref y) => return y.char_len Concat(ref y) => y.char_len
} }
} }
@ -867,13 +868,13 @@ pub mod node {
pub fn flatten(node: @Node) -> @Node { pub fn flatten(node: @Node) -> @Node {
unsafe { unsafe {
match (*node) { match (*node) {
Leaf(_) => return node, Leaf(_) => node,
Concat(ref x) => { Concat(ref x) => {
return @Leaf({ @Leaf(Leaf {
byte_offset: 0u, byte_offset: 0u,
byte_len: x.byte_len, byte_len: x.byte_len,
char_len: x.char_len, char_len: x.char_len,
content: @serialize_node(node) content: @serialize_node(node),
}) })
} }
} }
@ -943,10 +944,12 @@ pub mod node {
node::Leaf(x) => { node::Leaf(x) => {
let char_len = let char_len =
str::count_chars(*x.content, byte_offset, byte_len); str::count_chars(*x.content, byte_offset, byte_len);
return @Leaf({byte_offset: byte_offset, return @Leaf(Leaf {
byte_offset: byte_offset,
byte_len: byte_len, byte_len: byte_len,
char_len: char_len, char_len: char_len,
content: x.content}); content: x.content,
});
} }
node::Concat(ref x) => { node::Concat(ref x) => {
let left_len: uint = node::byte_len(x.left); let left_len: uint = node::byte_len(x.left);
@ -1007,10 +1010,12 @@ pub mod node {
str::count_bytes(*x.content, 0u, char_offset); str::count_bytes(*x.content, 0u, char_offset);
let byte_len = let byte_len =
str::count_bytes(*x.content, byte_offset, char_len); str::count_bytes(*x.content, byte_offset, char_len);
return @Leaf({byte_offset: byte_offset, return @Leaf(Leaf {
byte_offset: byte_offset,
byte_len: byte_len, byte_len: byte_len,
char_len: char_len, char_len: char_len,
content: x.content}); content: x.content,
});
} }
node::Concat(ref x) => { node::Concat(ref x) => {
if char_offset == 0u && char_len == x.char_len {return node;} if char_offset == 0u && char_len == x.char_len {return node;}
@ -1040,18 +1045,19 @@ pub mod node {
} }
pub fn concat2(left: @Node, right: @Node) -> @Node { pub fn concat2(left: @Node, right: @Node) -> @Node {
return @Concat({left : left, @Concat(Concat {
right : right, left: left,
right: right,
char_len: char_len(left) + char_len(right), char_len: char_len(left) + char_len(right),
byte_len: byte_len(left) + byte_len(right), byte_len: byte_len(left) + byte_len(right),
height: uint::max(height(left), height(right)) + 1u height: uint::max(height(left), height(right)) + 1u,
}) })
} }
pub pure fn height(node: @Node) -> uint { pub pure fn height(node: @Node) -> uint {
match (*node) { match (*node) {
Leaf(_) => return 0u, Leaf(_) => 0u,
Concat(ref x) => return x.height Concat(ref x) => x.height,
} }
} }
@ -1135,7 +1141,7 @@ pub mod node {
loop { loop {
match *node { match *node {
Leaf(x) => return str::char_at(*x.content, pos), Leaf(x) => return str::char_at(*x.content, pos),
Concat({left, right, _}) => { Concat(Concat {left, right, _}) => {
let left_len = char_len(left); let left_len = char_len(left);
node = if left_len > pos { left } node = if left_len > pos { left }
else { pos -= left_len; right }; else { pos -= left_len; right };
@ -1151,22 +1157,22 @@ pub mod node {
use core::prelude::*; use core::prelude::*;
use core::vec; use core::vec;
pub type T = { pub struct T {
stack: ~[mut @Node], stack: ~[mut @Node],
mut stackpos: int mut stackpos: int,
}; }
pub fn empty() -> T { pub fn empty() -> T {
let stack : ~[mut @Node] = ~[mut]; let stack : ~[mut @Node] = ~[mut];
return {stack: move stack, mut stackpos: -1} T { stack: stack, stackpos: -1 }
} }
pub fn start(node: @Node) -> T { pub fn start(node: @Node) -> T {
let stack = vec::cast_to_mut( let stack = vec::cast_to_mut(
vec::from_elem(height(node)+1u, node)); vec::from_elem(height(node)+1u, node));
return { T {
stack: move stack, stack: stack,
mut stackpos: 0 stackpos: 0,
} }
} }
@ -1196,25 +1202,25 @@ pub mod node {
use core::prelude::*; use core::prelude::*;
use core::str; use core::str;
pub type T = { pub struct T {
leaf_iterator: leaf_iterator::T, leaf_iterator: leaf_iterator::T,
mut leaf: Option<Leaf>, mut leaf: Option<Leaf>,
mut leaf_byte_pos: uint mut leaf_byte_pos: uint,
}; }
pub fn start(node: @Node) -> T { pub fn start(node: @Node) -> T {
return { T {
leaf_iterator: leaf_iterator::start(node), leaf_iterator: leaf_iterator::start(node),
mut leaf: option::None, leaf: option::None,
mut leaf_byte_pos: 0u leaf_byte_pos: 0u,
} }
} }
pub fn empty() -> T { pub fn empty() -> T {
return { T {
leaf_iterator: leaf_iterator::empty(), leaf_iterator: leaf_iterator::empty(),
mut leaf: option::None, leaf: option::None,
mut leaf_byte_pos: 0u leaf_byte_pos: 0u,
} }
} }

View file

@ -284,7 +284,10 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
unsafe { unsafe {
type Test = {input: ~str, output: ~[u8]}; struct Test {
input: ~str,
output: ~[u8],
}
fn a_million_letter_a() -> ~str { fn a_million_letter_a() -> ~str {
let mut i = 0; let mut i = 0;
@ -297,47 +300,64 @@ mod tests {
} }
// Test messages from FIPS 180-1 // Test messages from FIPS 180-1
let fips_180_1_tests: ~[Test] = let fips_180_1_tests = ~[
~[{input: ~"abc", Test {
output: input: ~"abc",
~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, output: ~[
0xA9u8, 0x99u8, 0x3Eu8, 0x36u8,
0x47u8, 0x06u8, 0x81u8, 0x6Au8, 0x47u8, 0x06u8, 0x81u8, 0x6Au8,
0xBAu8, 0x3Eu8, 0x25u8, 0x71u8, 0xBAu8, 0x3Eu8, 0x25u8, 0x71u8,
0x78u8, 0x50u8, 0xC2u8, 0x6Cu8, 0x78u8, 0x50u8, 0xC2u8, 0x6Cu8,
0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]}, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8,
{input: ],
},
Test {
input:
~"abcdbcdecdefdefgefghfghighij" + ~"abcdbcdecdefdefgefghfghighij" +
~"hijkijkljklmklmnlmnomnopnopq", ~"hijkijkljklmklmnlmnomnopnopq",
output: output: ~[
~[0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x84u8, 0x98u8, 0x3Eu8, 0x44u8,
0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8, 0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8,
0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8, 0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8,
0xF9u8, 0x51u8, 0x29u8, 0xE5u8, 0xF9u8, 0x51u8, 0x29u8, 0xE5u8,
0xE5u8, 0x46u8, 0x70u8, 0xF1u8]}, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8,
{input: a_million_letter_a(), ],
output: },
~[0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, Test {
input: a_million_letter_a(),
output: ~[
0x34u8, 0xAAu8, 0x97u8, 0x3Cu8,
0xD4u8, 0xC4u8, 0xDAu8, 0xA4u8, 0xD4u8, 0xC4u8, 0xDAu8, 0xA4u8,
0xF6u8, 0x1Eu8, 0xEBu8, 0x2Bu8, 0xF6u8, 0x1Eu8, 0xEBu8, 0x2Bu8,
0xDBu8, 0xADu8, 0x27u8, 0x31u8, 0xDBu8, 0xADu8, 0x27u8, 0x31u8,
0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}]; 0x65u8, 0x34u8, 0x01u8, 0x6Fu8,
],
},
];
// Examples from wikipedia // Examples from wikipedia
let wikipedia_tests: ~[Test] = let wikipedia_tests = ~[
~[{input: ~"The quick brown fox jumps over the lazy dog", Test {
output: input: ~"The quick brown fox jumps over the lazy dog",
~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, output: ~[
0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8,
0x7au8, 0x2du8, 0x28u8, 0xfcu8, 0x7au8, 0x2du8, 0x28u8, 0xfcu8,
0xedu8, 0x84u8, 0x9eu8, 0xe1u8, 0xedu8, 0x84u8, 0x9eu8, 0xe1u8,
0xbbu8, 0x76u8, 0xe7u8, 0x39u8, 0xbbu8, 0x76u8, 0xe7u8, 0x39u8,
0x1bu8, 0x93u8, 0xebu8, 0x12u8]}, 0x1bu8, 0x93u8, 0xebu8, 0x12u8,
{input: ~"The quick brown fox jumps over the lazy cog", ],
output: },
~[0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, Test {
input: ~"The quick brown fox jumps over the lazy cog",
output: ~[
0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8,
0xd2u8, 0x5eu8, 0x1bu8, 0x3au8, 0xd2u8, 0x5eu8, 0x1bu8, 0x3au8,
0xfau8, 0xd3u8, 0xe8u8, 0x5au8, 0xfau8, 0xd3u8, 0xe8u8, 0x5au8,
0x0bu8, 0xd1u8, 0x7du8, 0x9bu8, 0x0bu8, 0xd1u8, 0x7du8, 0x9bu8,
0x10u8, 0x0du8, 0xb4u8, 0xb3u8]}]; 0x10u8, 0x0du8, 0xb4u8, 0xb3u8,
],
},
];
let tests = fips_180_1_tests + wikipedia_tests; let tests = fips_180_1_tests + wikipedia_tests;
fn check_vec_eq(v0: ~[u8], v1: ~[u8]) { fn check_vec_eq(v0: ~[u8], v1: ~[u8]) {
assert (vec::len::<u8>(v0) == vec::len::<u8>(v1)); assert (vec::len::<u8>(v0) == vec::len::<u8>(v1));

View file

@ -25,7 +25,9 @@ use core::prelude::*;
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that // FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
// requires this to be. // requires this to be.
type SmallIntMap_<T: Copy> = {v: DVec<Option<T>>}; struct SmallIntMap_<T: Copy> {
v: DVec<Option<T>>,
}
pub enum SmallIntMap<T:Copy> { pub enum SmallIntMap<T:Copy> {
SmallIntMap_(@SmallIntMap_<T>) SmallIntMap_(@SmallIntMap_<T>)
@ -34,7 +36,7 @@ pub enum SmallIntMap<T:Copy> {
/// Create a smallintmap /// Create a smallintmap
pub fn mk<T: Copy>() -> SmallIntMap<T> { pub fn mk<T: Copy>() -> SmallIntMap<T> {
let v = DVec(); let v = DVec();
return SmallIntMap_(@{v: move v}); SmallIntMap_(@SmallIntMap_ { v: v } )
} }
/** /**

View file

@ -74,8 +74,11 @@ pub fn test_main(args: &[~str], tests: &[TestDesc]) {
if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; } if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; }
} }
pub type TestOpts = {filter: Option<~str>, run_ignored: bool, pub struct TestOpts {
logfile: Option<~str>}; filter: Option<~str>,
run_ignored: bool,
logfile: Option<~str>,
}
type OptRes = Either<TestOpts, ~str>; type OptRes = Either<TestOpts, ~str>;
@ -97,10 +100,13 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
let run_ignored = getopts::opt_present(&matches, ~"ignored"); let run_ignored = getopts::opt_present(&matches, ~"ignored");
let logfile = getopts::opt_maybe_str(&matches, ~"logfile"); let logfile = getopts::opt_maybe_str(&matches, ~"logfile");
let test_opts = {filter: filter, run_ignored: run_ignored, let test_opts = TestOpts {
logfile: logfile}; filter: filter,
run_ignored: run_ignored,
logfile: logfile,
};
return either::Left(test_opts); either::Left(test_opts)
} }
#[deriving_eq] #[deriving_eq]
@ -396,7 +402,10 @@ pub fn filter_tests(opts: &TestOpts,
move filtered move filtered
} }
type TestFuture = {test: TestDesc, wait: fn@() -> TestResult}; struct TestFuture {
test: TestDesc,
wait: fn@() -> TestResult,
}
pub fn run_test(test: TestDesc, monitor_ch: oldcomm::Chan<MonitorMsg>) { pub fn run_test(test: TestDesc, monitor_ch: oldcomm::Chan<MonitorMsg>) {
if test.ignore { if test.ignore {
@ -431,7 +440,7 @@ mod tests {
#[legacy_exports]; #[legacy_exports];
use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc}; use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc};
use test::{run_test}; use test::{TestOpts, run_test};
use core::either; use core::either;
use core::oldcomm; use core::oldcomm;
@ -528,13 +537,26 @@ mod tests {
// When we run ignored tests the test filter should filter out all the // When we run ignored tests the test filter should filter out all the
// unignored tests and flip the ignore flag on the rest to false // unignored tests and flip the ignore flag on the rest to false
let opts = {filter: option::None, run_ignored: true, let opts = TestOpts {
logfile: option::None}; filter: option::None,
let tests = run_ignored: true,
~[TestDesc {name: ~"1", testfn: fn~() { }, logfile: option::None,
ignore: true, should_fail: false}, };
TestDesc {name: ~"2", testfn: fn~() { },
ignore: false, should_fail: false}]; let tests = ~[
TestDesc {
name: ~"1",
testfn: fn~() { },
ignore: true,
should_fail: false,
},
TestDesc {
name: ~"2",
testfn: fn~() { },
ignore: false,
should_fail: false,
},
];
let filtered = filter_tests(&opts, tests); let filtered = filter_tests(&opts, tests);
assert (vec::len(filtered) == 1u); assert (vec::len(filtered) == 1u);
@ -544,8 +566,11 @@ mod tests {
#[test] #[test]
fn sort_tests() { fn sort_tests() {
let opts = {filter: option::None, run_ignored: false, let opts = TestOpts {
logfile: option::None}; filter: option::None,
run_ignored: false,
logfile: option::None,
};
let names = let names =
~[~"sha1::test", ~"int::test_to_str", ~"int::test_pow", ~[~"sha1::test", ~"int::test_to_str", ~"int::test_pow",

View file

@ -111,7 +111,7 @@ fn run_loop(iotask_ch: Chan<IoTask>) {
ll::async_init(loop_ptr, async_handle, wake_up_cb); ll::async_init(loop_ptr, async_handle, wake_up_cb);
// initialize our loop data and store it in the loop // initialize our loop data and store it in the loop
let data: IoTaskLoopData = { let data = IoTaskLoopData {
async_handle: async_handle, async_handle: async_handle,
msg_po: Port() msg_po: Port()
}; };
@ -134,10 +134,10 @@ fn run_loop(iotask_ch: Chan<IoTask>) {
} }
// data that lives for the lifetime of the high-evel oo // data that lives for the lifetime of the high-evel oo
type IoTaskLoopData = { struct IoTaskLoopData {
async_handle: *ll::uv_async_t, async_handle: *ll::uv_async_t,
msg_po: Port<IoTaskMsg> msg_po: Port<IoTaskMsg>,
}; }
fn send_msg(iotask: IoTask, msg: IoTaskMsg) { fn send_msg(iotask: IoTask, msg: IoTaskMsg) {
unsafe { unsafe {
@ -214,10 +214,10 @@ mod test {
ll::close(handle, async_close_cb); ll::close(handle, async_close_cb);
} }
} }
type AhData = { struct AhData {
iotask: IoTask, iotask: IoTask,
exit_ch: oldcomm::Chan<()> exit_ch: oldcomm::Chan<()>,
}; }
fn impl_uv_iotask_async(iotask: IoTask) { fn impl_uv_iotask_async(iotask: IoTask) {
unsafe { unsafe {
let async_handle = ll::async_t(); let async_handle = ll::async_t();

View file

@ -41,10 +41,10 @@ use core::str;
use core::vec; use core::vec;
// libuv struct mappings // libuv struct mappings
pub type uv_ip4_addr = { pub struct uv_ip4_addr {
ip: ~[u8], ip: ~[u8],
port: int port: int,
}; }
pub type uv_ip6_addr = uv_ip4_addr; pub type uv_ip6_addr = uv_ip4_addr;
pub enum uv_handle_type { pub enum uv_handle_type {
@ -67,31 +67,31 @@ pub enum uv_handle_type {
pub type handle_type = libc::c_uint; pub type handle_type = libc::c_uint;
pub type uv_handle_fields = { pub struct uv_handle_fields {
loop_handle: *libc::c_void, loop_handle: *libc::c_void,
type_: handle_type, type_: handle_type,
close_cb: *u8, close_cb: *u8,
mut data: *libc::c_void, mut data: *libc::c_void,
}; }
// unix size: 8 // unix size: 8
pub type uv_err_t = { pub struct uv_err_t {
code: libc::c_int, code: libc::c_int,
sys_errno_: libc::c_int sys_errno_: libc::c_int
}; }
// don't create one of these directly. instead, // don't create one of these directly. instead,
// count on it appearing in libuv callbacks or embedded // count on it appearing in libuv callbacks or embedded
// in other types as a pointer to be used in other // in other types as a pointer to be used in other
// operations (so mostly treat it as opaque, once you // operations (so mostly treat it as opaque, once you
// have it in this form..) // have it in this form..)
pub type uv_stream_t = { pub struct uv_stream_t {
fields: uv_handle_fields fields: uv_handle_fields,
}; }
// 64bit unix size: 272 // 64bit unix size: 272
#[cfg(unix)] #[cfg(unix)]
pub type uv_tcp_t = { pub struct uv_tcp_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
@ -101,24 +101,24 @@ pub type uv_tcp_t = {
a20: *u8, a21: *u8, a22: *u8, a23: *u8, a20: *u8, a21: *u8, a22: *u8, a23: *u8,
a24: *u8, a25: *u8, a26: *u8, a27: *u8, a24: *u8, a25: *u8, a26: *u8, a27: *u8,
a28: *u8, a28: *u8,
a30: uv_tcp_t_32bit_unix_riders a30: uv_tcp_t_32bit_unix_riders,
}; }
// 32bit unix size: 328 (164) // 32bit unix size: 328 (164)
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type uv_tcp_t_32bit_unix_riders = { pub struct uv_tcp_t_32bit_unix_riders {
a29: *u8 a29: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type uv_tcp_t_32bit_unix_riders = { pub struct uv_tcp_t_32bit_unix_riders {
a29: *u8, a30: *u8, a31: *u8, a29: *u8, a30: *u8, a31: *u8,
a32: *u8, a33: *u8, a34: *u8, a32: *u8, a33: *u8, a34: *u8,
a35: *u8, a36: *u8 a35: *u8, a36: *u8,
}; }
// 32bit win32 size: 240 (120) // 32bit win32 size: 240 (120)
#[cfg(windows)] #[cfg(windows)]
pub type uv_tcp_t = { pub struct uv_tcp_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
@ -126,140 +126,140 @@ pub type uv_tcp_t = {
a12: *u8, a13: *u8, a14: *u8, a15: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8,
a16: *u8, a17: *u8, a18: *u8, a19: *u8, a16: *u8, a17: *u8, a18: *u8, a19: *u8,
a20: *u8, a21: *u8, a22: *u8, a23: *u8, a20: *u8, a21: *u8, a22: *u8, a23: *u8,
a24: *u8, a25: *u8 a24: *u8, a25: *u8,
}; }
// unix size: 48 // unix size: 48
#[cfg(unix)] #[cfg(unix)]
pub type uv_connect_t = { pub struct uv_connect_t {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8 a04: *u8, a05: *u8,
}; }
// win32 size: 88 (44) // win32 size: 88 (44)
#[cfg(windows)] #[cfg(windows)]
pub type uv_connect_t = { pub struct uv_connect_t {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a10: *u8 a08: *u8, a09: *u8, a10: *u8,
}; }
// unix size: 16 // unix size: 16
pub type uv_buf_t = { pub struct uv_buf_t {
base: *u8, base: *u8,
len: libc::size_t len: libc::size_t,
}; }
// no gen stub method.. should create // no gen stub method.. should create
// it via uv::direct::buf_init() // it via uv::direct::buf_init()
// unix size: 144 // unix size: 144
#[cfg(unix)] #[cfg(unix)]
pub type uv_write_t = { pub struct uv_write_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a10: *u8, a11: *u8, a08: *u8, a09: *u8, a10: *u8, a11: *u8,
a12: *u8, a12: *u8,
a14: uv_write_t_32bit_unix_riders a14: uv_write_t_32bit_unix_riders,
}; }
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type uv_write_t_32bit_unix_riders = { pub struct uv_write_t_32bit_unix_riders {
a13: *u8 a13: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type uv_write_t_32bit_unix_riders = { pub struct uv_write_t_32bit_unix_riders {
a13: *u8, a14: *u8 a13: *u8, a14: *u8,
}; }
// win32 size: 136 (68) // win32 size: 136 (68)
#[cfg(windows)] #[cfg(windows)]
pub type uv_write_t = { pub struct uv_write_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a10: *u8, a11: *u8, a08: *u8, a09: *u8, a10: *u8, a11: *u8,
a12: *u8 a12: *u8,
}; }
// 64bit unix size: 120 // 64bit unix size: 120
// 32bit unix size: 152 (76) // 32bit unix size: 152 (76)
#[cfg(unix)] #[cfg(unix)]
pub type uv_async_t = { pub struct uv_async_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a08: *u8, a09: *u8,
a11: uv_async_t_32bit_unix_riders a11: uv_async_t_32bit_unix_riders,
}; }
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type uv_async_t_32bit_unix_riders = { pub struct uv_async_t_32bit_unix_riders {
a10: *u8 a10: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type uv_async_t_32bit_unix_riders = { pub struct uv_async_t_32bit_unix_riders {
a10: *u8, a11: *u8, a12: *u8, a13: *u8 a10: *u8, a11: *u8, a12: *u8, a13: *u8,
}; }
// win32 size 132 (68) // win32 size 132 (68)
#[cfg(windows)] #[cfg(windows)]
pub type uv_async_t = { pub struct uv_async_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a10: *u8, a11: *u8, a08: *u8, a09: *u8, a10: *u8, a11: *u8,
a12: *u8 a12: *u8,
}; }
// 64bit unix size: 128 // 64bit unix size: 128
// 32bit unix size: 84 // 32bit unix size: 84
#[cfg(unix)] #[cfg(unix)]
pub type uv_timer_t = { pub struct uv_timer_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a08: *u8, a09: *u8,
a11: uv_timer_t_32bit_unix_riders a11: uv_timer_t_32bit_unix_riders,
}; }
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type uv_timer_t_32bit_unix_riders = { pub struct uv_timer_t_32bit_unix_riders {
a10: *u8, a11: *u8 a10: *u8, a11: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type uv_timer_t_32bit_unix_riders = { pub struct uv_timer_t_32bit_unix_riders {
a10: *u8, a11: *u8, a12: *u8, a13: *u8, a10: *u8, a11: *u8, a12: *u8, a13: *u8,
a14: *u8, a15: *u8, a16: *u8 a14: *u8, a15: *u8, a16: *u8,
}; }
// win32 size: 64 // win32 size: 64
#[cfg(windows)] #[cfg(windows)]
pub type uv_timer_t = { pub struct uv_timer_t {
fields: uv_handle_fields, fields: uv_handle_fields,
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8,
a08: *u8, a09: *u8, a10: *u8, a11: *u8 a08: *u8, a09: *u8, a10: *u8, a11: *u8,
}; }
// unix size: 16 // unix size: 16
pub type sockaddr_in = { pub struct sockaddr_in {
mut sin_family: u16, mut sin_family: u16,
mut sin_port: u16, mut sin_port: u16,
mut sin_addr: u32, // in_addr: this is an opaque, per-platform struct mut sin_addr: u32, // in_addr: this is an opaque, per-platform struct
mut sin_zero: (u8, u8, u8, u8, u8, u8, u8, u8) mut sin_zero: (u8, u8, u8, u8, u8, u8, u8, u8),
}; }
// unix size: 28 .. FIXME #1645 // unix size: 28 .. FIXME #1645
// stuck with 32 becuse of rust padding structs? // stuck with 32 becuse of rust padding structs?
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type sockaddr_in6 = { pub struct sockaddr_in6 {
a0: *u8, a1: *u8, a0: *u8, a1: *u8,
a2: *u8, a3: *u8 a2: *u8, a3: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type sockaddr_in6 = { pub struct sockaddr_in6 {
a0: *u8, a1: *u8, a0: *u8, a1: *u8,
a2: *u8, a3: *u8, a2: *u8, a3: *u8,
a4: *u8, a5: *u8, a4: *u8, a5: *u8,
a6: *u8, a7: *u8 a6: *u8, a7: *u8,
}; }
// unix size: 28 .. FIXME #1645 // unix size: 28 .. FIXME #1645
// stuck with 32 becuse of rust padding structs? // stuck with 32 becuse of rust padding structs?
@ -267,25 +267,25 @@ pub type addr_in = addr_in_impl::addr_in;
#[cfg(unix)] #[cfg(unix)]
pub mod addr_in_impl { pub mod addr_in_impl {
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type addr_in = { pub struct addr_in {
a0: *u8, a1: *u8, a0: *u8, a1: *u8,
a2: *u8, a3: *u8 a2: *u8, a3: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type addr_in = { pub struct addr_in {
a0: *u8, a1: *u8, a0: *u8, a1: *u8,
a2: *u8, a3: *u8, a2: *u8, a3: *u8,
a4: *u8, a5: *u8, a4: *u8, a5: *u8,
a6: *u8, a7: *u8, a6: *u8, a7: *u8,
}; }
} }
#[cfg(windows)] #[cfg(windows)]
pub mod addr_in_impl { pub mod addr_in_impl {
pub type addr_in = { pub struct addr_in {
a0: *u8, a1: *u8, a0: *u8, a1: *u8,
a2: *u8, a3: *u8 a2: *u8, a3: *u8,
}; }
} }
// unix size: 48, 32bit: 32 // unix size: 48, 32bit: 32
@ -294,42 +294,60 @@ pub type addrinfo = addrinfo_impl::addrinfo;
#[cfg(target_os="android")] #[cfg(target_os="android")]
pub mod addrinfo_impl { pub mod addrinfo_impl {
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub type addrinfo = { pub struct addrinfo {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8 a04: *u8, a05: *u8,
}; }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub type addrinfo = { pub struct addrinfo {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8, a06: *u8, a07: *u8 a04: *u8, a05: *u8, a06: *u8, a07: *u8,
}; }
} }
#[cfg(target_os="macos")] #[cfg(target_os="macos")]
#[cfg(target_os="freebsd")] #[cfg(target_os="freebsd")]
pub mod addrinfo_impl { pub mod addrinfo_impl {
pub type addrinfo = { pub struct addrinfo {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8 a04: *u8, a05: *u8,
}; }
} }
#[cfg(windows)] #[cfg(windows)]
pub mod addrinfo_impl { pub mod addrinfo_impl {
pub type addrinfo = { pub struct addrinfo {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8,
a04: *u8, a05: *u8 a04: *u8, a05: *u8,
}; }
} }
// unix size: 72 // unix size: 72
pub type uv_getaddrinfo_t = { pub struct uv_getaddrinfo_t {
a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8,
a06: *u8, a07: *u8, a08: *u8 a06: *u8, a07: *u8, a08: *u8,
}; }
pub mod uv_ll_struct_stubgen { pub mod uv_ll_struct_stubgen {
use uv_ll::{uv_async_t, uv_connect_t, uv_getaddrinfo_t, uv_tcp_t}; use uv_ll::{
use uv_ll::{uv_timer_t, uv_write_t}; uv_async_t,
uv_connect_t,
uv_getaddrinfo_t,
uv_handle_fields,
uv_tcp_t,
uv_timer_t,
uv_write_t,
};
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
use uv_ll::{
uv_async_t_32bit_unix_riders,
uv_tcp_t_32bit_unix_riders,
uv_timer_t_32bit_unix_riders,
uv_write_t_32bit_unix_riders,
};
use core::ptr; use core::ptr;
@ -343,9 +361,12 @@ pub mod uv_ll_struct_stubgen {
return gen_stub_arch(); return gen_stub_arch();
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub fn gen_stub_arch() -> uv_tcp_t { pub fn gen_stub_arch() -> uv_tcp_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_tcp_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
@ -361,17 +382,18 @@ pub mod uv_ll_struct_stubgen {
a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8,
a27: 0 as *u8, a27: 0 as *u8,
a28: 0 as *u8, a28: 0 as *u8,
a30: { a30: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8 },
a29: 0 as *u8
} }
};
} }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub fn gen_stub_arch() -> uv_tcp_t { pub fn gen_stub_arch() -> uv_tcp_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_tcp_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
@ -387,19 +409,22 @@ pub mod uv_ll_struct_stubgen {
a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8,
a27: 0 as *u8, a27: 0 as *u8,
a28: 0 as *u8, a28: 0 as *u8,
a30: { a30: uv_tcp_t_32bit_unix_riders {
a29: 0 as *u8, a30: 0 as *u8, a31: 0 as *u8, a29: 0 as *u8, a30: 0 as *u8, a31: 0 as *u8,
a32: 0 as *u8, a33: 0 as *u8, a34: 0 as *u8, a32: 0 as *u8, a33: 0 as *u8, a34: 0 as *u8,
a35: 0 as *u8, a36: 0 as *u8 a35: 0 as *u8, a36: 0 as *u8,
},
} }
};
} }
} }
#[cfg(windows)] #[cfg(windows)]
pub fn gen_stub_os() -> uv_tcp_t { pub fn gen_stub_os() -> uv_tcp_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_tcp_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
@ -412,58 +437,62 @@ pub mod uv_ll_struct_stubgen {
a19: 0 as *u8, a19: 0 as *u8,
a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8,
a23: 0 as *u8, a23: 0 as *u8,
a24: 0 as *u8, a25: 0 as *u8 a24: 0 as *u8, a25: 0 as *u8,
}; }
} }
} }
#[cfg(unix)] #[cfg(unix)]
pub fn gen_stub_uv_connect_t() -> uv_connect_t { pub fn gen_stub_uv_connect_t() -> uv_connect_t {
return { uv_connect_t {
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8 a04: 0 as *u8, a05: 0 as *u8,
}; }
} }
#[cfg(windows)] #[cfg(windows)]
pub fn gen_stub_uv_connect_t() -> uv_connect_t { pub fn gen_stub_uv_connect_t() -> uv_connect_t {
return { uv_connect_t {
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8 a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8,
}; }
} }
#[cfg(unix)] #[cfg(unix)]
pub fn gen_stub_uv_async_t() -> uv_async_t { pub fn gen_stub_uv_async_t() -> uv_async_t {
return gen_stub_arch(); return gen_stub_arch();
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
pub fn gen_stub_arch() -> uv_async_t { pub fn gen_stub_arch() -> uv_async_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_async_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8,
a11: { a11: uv_async_t_32bit_unix_riders { a10: 0 as *u8 },
a10: 0 as *u8
} }
};
} }
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub fn gen_stub_arch() -> uv_async_t { pub fn gen_stub_arch() -> uv_async_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_async_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8,
a11: { a11: uv_async_t_32bit_unix_riders {
a10: 0 as *u8, a11: 0 as *u8, a10: 0 as *u8, a11: 0 as *u8,
a12: 0 as *u8, a13: 0 as *u8 a12: 0 as *u8, a13: 0 as *u8
} }
@ -472,107 +501,133 @@ pub mod uv_ll_struct_stubgen {
} }
#[cfg(windows)] #[cfg(windows)]
pub fn gen_stub_uv_async_t() -> uv_async_t { pub fn gen_stub_uv_async_t() -> uv_async_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_async_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8,
a11: 0 as *u8, a11: 0 as *u8,
a12: 0 as *u8 a12: 0 as *u8,
}; }
} }
#[cfg(unix)] #[cfg(unix)]
pub fn gen_stub_uv_timer_t() -> uv_timer_t { pub fn gen_stub_uv_timer_t() -> uv_timer_t {
return gen_stub_arch(); return gen_stub_arch();
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
pub fn gen_stub_arch() -> uv_timer_t { pub fn gen_stub_arch() -> uv_timer_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_timer_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8,
a11: { a11: uv_timer_t_32bit_unix_riders {
a10: 0 as *u8, a11: 0 as *u8 a10: 0 as *u8, a11: 0 as *u8
},
} }
};
} }
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub fn gen_stub_arch() -> uv_timer_t { pub fn gen_stub_arch() -> uv_timer_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_timer_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8,
a11: { a11: uv_timer_t_32bit_unix_riders {
a10: 0 as *u8, a11: 0 as *u8, a10: 0 as *u8, a11: 0 as *u8,
a12: 0 as *u8, a13: 0 as *u8, a12: 0 as *u8, a13: 0 as *u8,
a14: 0 as *u8, a15: 0 as *u8, a14: 0 as *u8, a15: 0 as *u8,
a16: 0 as *u8 a16: 0 as *u8,
},
} }
};
} }
} }
#[cfg(windows)] #[cfg(windows)]
pub fn gen_stub_uv_timer_t() -> uv_timer_t { pub fn gen_stub_uv_timer_t() -> uv_timer_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_timer_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8,
a11: 0 as *u8 a11: 0 as *u8,
}; }
} }
#[cfg(unix)] #[cfg(unix)]
pub fn gen_stub_uv_write_t() -> uv_write_t { pub fn gen_stub_uv_write_t() -> uv_write_t {
return gen_stub_arch(); return gen_stub_arch();
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
pub fn gen_stub_arch() -> uv_write_t { pub fn gen_stub_arch() -> uv_write_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_write_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8,
a11: 0 as *u8, a11: 0 as *u8,
a12: 0 as *u8, a14: { a13: 0 as *u8 } a12: 0 as *u8,
}; a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8 },
}
} }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
pub fn gen_stub_arch() -> uv_write_t { pub fn gen_stub_arch() -> uv_write_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_write_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
a07: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8,
a11: 0 as *u8, a11: 0 as *u8,
a12: 0 as *u8, a14: { a13: 0 as *u8, a14: 0 as *u8 } a12: 0 as *u8,
a14: uv_write_t_32bit_unix_riders {
a13: 0 as *u8,
a14: 0 as *u8,
}
}; };
} }
} }
#[cfg(windows)] #[cfg(windows)]
pub fn gen_stub_uv_write_t() -> uv_write_t { pub fn gen_stub_uv_write_t() -> uv_write_t {
return { fields: { loop_handle: ptr::null(), type_: 0u32, uv_write_t {
fields: uv_handle_fields {
loop_handle: ptr::null(), type_: 0u32,
close_cb: ptr::null(), close_cb: ptr::null(),
mut data: ptr::null() }, data: ptr::null(),
},
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8,
a03: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8,
@ -583,7 +638,7 @@ pub mod uv_ll_struct_stubgen {
}; };
} }
pub fn gen_stub_uv_getaddrinfo_t() -> uv_getaddrinfo_t { pub fn gen_stub_uv_getaddrinfo_t() -> uv_getaddrinfo_t {
{ uv_getaddrinfo_t {
a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8,
a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a07: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a07: 0 as *u8,
a08: 0 as *u8 a08: 0 as *u8
@ -851,7 +906,7 @@ pub unsafe fn async_send(async_handle: *uv_async_t) {
return rustrt::rust_uv_async_send(async_handle); return rustrt::rust_uv_async_send(async_handle);
} }
pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t { pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
let out_buf = { base: ptr::null(), len: 0 as libc::size_t }; let out_buf = uv_buf_t { base: ptr::null(), len: 0 as libc::size_t };
let out_buf_ptr = ptr::addr_of(&out_buf); let out_buf_ptr = ptr::addr_of(&out_buf);
log(debug, fmt!("buf_init - input %u len %u out_buf: %u", log(debug, fmt!("buf_init - input %u len %u out_buf: %u",
input as uint, input as uint,
@ -1043,13 +1098,13 @@ pub unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data {
let err_ptr = ptr::addr_of(&err); let err_ptr = ptr::addr_of(&err);
let err_name = str::raw::from_c_str(err_name(err_ptr)); let err_name = str::raw::from_c_str(err_name(err_ptr));
let err_msg = str::raw::from_c_str(strerror(err_ptr)); let err_msg = str::raw::from_c_str(strerror(err_ptr));
{ err_name: err_name, err_msg: err_msg } uv_err_data { err_name: err_name, err_msg: err_msg }
} }
pub type uv_err_data = { pub struct uv_err_data {
err_name: ~str, err_name: ~str,
err_msg: ~str err_msg: ~str,
}; }
pub unsafe fn is_ipv4_addrinfo(input: *addrinfo) -> bool { pub unsafe fn is_ipv4_addrinfo(input: *addrinfo) -> bool {
rustrt::rust_uv_is_ipv4_addrinfo(input) rustrt::rust_uv_is_ipv4_addrinfo(input)
@ -1090,11 +1145,11 @@ pub mod test {
tcp_read_error tcp_read_error
} }
type request_wrapper = { struct request_wrapper {
write_req: *uv_write_t, write_req: *uv_write_t,
req_buf: *~[uv_buf_t], req_buf: *~[uv_buf_t],
read_chan: *oldcomm::Chan<~str> read_chan: *oldcomm::Chan<~str>,
}; }
extern fn after_close_cb(handle: *libc::c_void) { extern fn after_close_cb(handle: *libc::c_void) {
log(debug, fmt!("after uv_close! handle ptr: %?", log(debug, fmt!("after uv_close! handle ptr: %?",
@ -1424,18 +1479,18 @@ pub mod test {
} }
} }
type tcp_server_data = { struct tcp_server_data {
client: *uv_tcp_t, client: *uv_tcp_t,
server: *uv_tcp_t, server: *uv_tcp_t,
server_kill_msg: ~str, server_kill_msg: ~str,
server_resp_buf: *~[uv_buf_t], server_resp_buf: *~[uv_buf_t],
server_chan: *oldcomm::Chan<~str>, server_chan: *oldcomm::Chan<~str>,
server_write_req: *uv_write_t server_write_req: *uv_write_t,
}; }
type async_handle_data = { struct async_handle_data {
continue_chan: *oldcomm::Chan<bool> continue_chan: *oldcomm::Chan<bool>,
}; }
extern fn async_close_cb(handle: *libc::c_void) { extern fn async_close_cb(handle: *libc::c_void) {
log(debug, fmt!("SERVER: closing async cb... h: %?", log(debug, fmt!("SERVER: closing async cb... h: %?",
@ -1489,7 +1544,7 @@ pub mod test {
{ continue_chan: continue_chan }; { continue_chan: continue_chan };
let async_data_ptr = ptr::addr_of(&async_data); let async_data_ptr = ptr::addr_of(&async_data);
let server_data: tcp_server_data = { let server_data = tcp_server_data {
client: tcp_client_ptr, client: tcp_client_ptr,
server: tcp_server_ptr, server: tcp_server_ptr,
server_kill_msg: kill_server_msg, server_kill_msg: kill_server_msg,