Permalink
Browse files

Merge branch 'master' of github.com:JuliaLang/julia

  • Loading branch information...
2 parents b7a1bc9 + 6617665 commit 9135b314826b4bf3ab23668baf0f060b7b74d4ef @StefanKarpinski StefanKarpinski committed Jan 25, 2013
Showing with 107 additions and 110 deletions.
  1. +0 −1 base/array.jl
  2. +12 −9 base/deprecated.jl
  3. +1 −2 base/exports.jl
  4. +94 −98 base/socket.jl
View
@@ -1094,7 +1094,6 @@ function rotl90(A::AbstractMatrix, k::Integer)
end
rotr90(A::AbstractMatrix, k::Integer) = rotl90(A,-k)
rot180(A::AbstractMatrix, k::Integer) = mod(k, 2) == 1 ? rot180(A) : copy(A)
-const rot90 = rotl90
reverse(v::StridedVector) = (n=length(v); [ v[n-i+1] for i=1:n ])
function reverse!(v::StridedVector)
View
@@ -19,23 +19,14 @@ end
@deprecate del delete!
@deprecate del_all empty!
@deprecate load require
-@deprecate numel length
@deprecate idump xdump
@deprecate cwd pwd
@deprecate strlen length
-@deprecate islogical isbool
-@deprecate csvread readcsv
-@deprecate dlmread readdlm
-@deprecate csvwrite writecsv
-@deprecate dlmwrite writedlm
@deprecate lc lowercase
@deprecate uc uppercase
@deprecate nCr binomial
@deprecate julia_pkgdir Pkg.dir
@deprecate tintersect typeintersect
-@deprecate chi2rnd randchi2
-@deprecate betarnd randbeta
-@deprecate exprnd randexp
@deprecate searchsorted searchsortedfirst
@deprecate choose first
@deprecate system run
@@ -44,6 +35,18 @@ end
export strcat
strcat(xs...) = string(xs...)
+# compatibility aliases
+@deprecate numel length
+@deprecate islogical isbool
+@deprecate csvread readcsv
+@deprecate dlmread readdlm
+@deprecate csvwrite writecsv
+@deprecate dlmwrite writedlm
+@deprecate chi2rnd randchi2
+@deprecate betarnd randbeta
+@deprecate exprnd randexp
+@deprecate rot90 rotl90
+
export randi, randival, randexp, randg, randbeta, randchi2
randi(x...) = error("randi is deprecated. Instead use: rand(r::Range)")
View
@@ -484,7 +484,6 @@ export
reverse,
reverse!,
rot180,
- rot90,
rotl90,
rotr90,
searchsortedfirst,
@@ -1030,6 +1029,7 @@ export
spawnat,
spawnlocal,
take,
+ wait,
# distributed arrays
defaultdist,
@@ -1115,7 +1115,6 @@ export
read_from,
run,
success,
- wait,
write_to,
# C interface
View
@@ -2,52 +2,52 @@
abstract IpAddr
type IPv4 <: IpAddr
- host::Uint32
- IPv4(host::Uint32) = new(host)
- IPv4(a::Uint8,b::Uint8,c::Uint8,d::Uint8) = new(uint32(a)<<24|
- uint32(b)<<16|
- uint32(c)<<8|
- d)
- function IPv4(a::Integer,b::Integer,c::Integer,d::Integer)
- if(!( 0<=a<=255 && 0<=b<=255 && 0<=c<=255 && 0<=d<=255 ))
- throw(DomainError())
- end
- IPv4(uint8(a),uint8(b),uint8(c),uint8(d))
+ host::Uint32
+ IPv4(host::Uint32) = new(host)
+ IPv4(a::Uint8,b::Uint8,c::Uint8,d::Uint8) = new(uint32(a)<<24|
+ uint32(b)<<16|
+ uint32(c)<<8|
+ d)
+ function IPv4(a::Integer,b::Integer,c::Integer,d::Integer)
+ if !(0<=a<=255 && 0<=b<=255 && 0<=c<=255 && 0<=d<=255)
+ throw(DomainError())
end
+ IPv4(uint8(a),uint8(b),uint8(c),uint8(d))
+ end
end
type IPv6 <: IpAddr
- host::Uint128
- IPv6(host::Uint128) = new(host)
- IPv6(a::Uint16,b::Uint16,c::Uint16,d::Uint16,
- e::Uint16,f::Uint16,g::Uint16,h::Uint16) = new(uint128(a)<<(7*16)|
- uint128(b)<<(6*16)|
- uint128(c)<<(5*16)|
- uint128(d)<<(4*16)|
- uint128(e)<<(3*16)|
- uint128(f)<<(2*16)|
- uint128(g)<<(1*16)|
- h)
- function IPv6(a::Integer,b::Integer,c::Integer,d::Integer,
- e::Integer,f::Integer,g::Integer,h::Integer)
- if(!( 0<=a<=0xFFFF && 0<=b<=0xFFFF && 0<=c<=0xFFFF && 0<=d<=0xFFFF
- && 0<=e<=0xFFFF && 0<=f<=0xFFFF && 0<=g<=0xFFFF && 0<=h<=0xFFFF ))
- throw(DomainError())
- end
- IPv6(uint16(a),uint16(b),uint16(c),uint16(d),
- uint16(e),uint16(f),uint16(g),uint16(h))
+ host::Uint128
+ IPv6(host::Uint128) = new(host)
+ IPv6(a::Uint16,b::Uint16,c::Uint16,d::Uint16,
+ e::Uint16,f::Uint16,g::Uint16,h::Uint16) = new(uint128(a)<<(7*16)|
+ uint128(b)<<(6*16)|
+ uint128(c)<<(5*16)|
+ uint128(d)<<(4*16)|
+ uint128(e)<<(3*16)|
+ uint128(f)<<(2*16)|
+ uint128(g)<<(1*16)|
+ h)
+ function IPv6(a::Integer,b::Integer,c::Integer,d::Integer,
+ e::Integer,f::Integer,g::Integer,h::Integer)
+ if !(0<=a<=0xFFFF && 0<=b<=0xFFFF && 0<=c<=0xFFFF && 0<=d<=0xFFFF &&
+ 0<=e<=0xFFFF && 0<=f<=0xFFFF && 0<=g<=0xFFFF && 0<=h<=0xFFFF)
+ throw(DomainError())
end
+ IPv6(uint16(a),uint16(b),uint16(c),uint16(d),
+ uint16(e),uint16(f),uint16(g),uint16(h))
+ end
end
type InetAddr
- host::IpAddr
- port::Uint16
- function InetAddr(host,port)
- if(!(0 <= port <= typemax(Uint16)))
- throw(DomainError())
- end
- new(host,uint16(port))
+ host::IpAddr
+ port::Uint16
+ function InetAddr(host,port)
+ if !(0 <= port <= typemax(Uint16))
+ throw(DomainError())
end
+ new(host,uint16(port))
+ end
end
@@ -67,12 +67,12 @@ type TcpSocket <: Socket
closecb::Callback
closenotify::Vector{WaitTask}
TcpSocket(handle,open)=new(handle,open,true,PipeString(),false,
- WaitTask[],false,WaitTask[],false,WaitTask[])
+ WaitTask[],false,WaitTask[],false,WaitTask[])
function TcpSocket()
this = TcpSocket(C_NULL,false)
this.handle = ccall(:jl_make_tcp,Ptr{Void},(Ptr{Void},TcpSocket),
- globalEventLoop(),this)
- if(this.handle == C_NULL)
+ globalEventLoop(),this)
+ if (this.handle == C_NULL)
error("Failed to start reading: ",_uv_lasterror())
end
this
@@ -91,22 +91,22 @@ type UdpSocket <: Socket
closecb::Callback
closenotify::Vector{WaitTask}
UdpSocket(handle,open)=new(handle,open,true,PipeString(),false,WaitTask[],
- false,WaitTask[],false,WaitTask[])
+ false,WaitTask[],false,WaitTask[])
function UdpSocket()
this = UdpSocket(C_NULL,false)
this.handle = ccall(:jl_make_tcp,Ptr{Void},(Ptr{Void},UdpSocket),
- globalEventLoop(),this)
+ globalEventLoop(),this)
this
end
end
show(io::IO,sock::TcpSocket) = print(io,"TcpSocket(",sock.open?"connected,":
- "disconnected,",nb_available(sock.buffer),
- " bytes waiting)")
+ "disconnected,",nb_available(sock.buffer),
+ " bytes waiting)")
show(io::IO,sock::UdpSocket) = print(io,"UdpSocket(",sock.open?"connected,":
- "disconnected,",nb_available(sock.buffer),
- " bytes waiting)")
+ "disconnected,",nb_available(sock.buffer),
+ " bytes waiting)")
_jl_tcp_init(loop::Ptr{Void}) = ccall(:jl_tcp_init,Ptr{Void},(Ptr{Void},),loop)
_jl_udp_init(loop::Ptr{Void}) = ccall(:jl_udp_init,Ptr{Void},(Ptr{Void},),loop)
@@ -164,10 +164,10 @@ bind(sock::Socket, addr::InetAddr) = bind(sock,addr.host,addr.port)
bind(sock::Socket, host::IpAddr, port) = bind(sock, InetAddr(host,port))
bind(sock::TcpSocket, host::IPv4, port::Uint16) =
- ccall(:jl_tcp_bind, Int32, (Ptr{Void}, Uint16, Uint32),
- sock.handle, hton(port), hton(host.host)) != -1
+ ccall(:jl_tcp_bind, Int32, (Ptr{Void}, Uint16, Uint32),
+ sock.handle, hton(port), hton(host.host)) != -1
bind(sock::TcpSocket, host::IPv6, port::Uint16) =
- error("IPv6 Support not fully implemented")
+ error("IPv6 Support not fully implemented")
##
@@ -178,70 +178,67 @@ function getaddrinfo_callback(cb, addrinfo::Ptr{Void}, status::Int32)
cb(IPv4(_jl_sockaddr_from_addrinfo(addrinfo_list)))
end
-jl_getaddrinfo(loop::Ptr{Void},host::ByteString,service::Ptr{Void},cb::Function) = ccall(:jl_getaddrinfo,Int32,(Ptr{Void}, Ptr{Uint8}, Ptr{Uint8}, Function),
- loop, host, service, cb)
+jl_getaddrinfo(loop::Ptr{Void},host::ByteString,service::Ptr{Void},cb::Function) =
+ ccall(:jl_getaddrinfo,Int32,(Ptr{Void}, Ptr{Uint8}, Ptr{Uint8}, Function),
+ loop, host, service, cb)
getaddrinfo(cb::Function,host::ASCIIString) =
- jl_getaddrinfo(globalEventLoop(),host,C_NULL,(addr,status)->
- getaddrinfo_callback(cb,addr,status))
+ jl_getaddrinfo(globalEventLoop(),host,C_NULL,(addr,status)->
+ getaddrinfo_callback(cb,addr,status))
function getaddrinfo(host::ASCIIString)
- ct = current_task()
- getaddrinfo(host) do IP
- yieldto(ct,IP)
- ct.runnable = true
- end
- ct.runnable = false
- ip = yield()
- yieldto(Scheduler)
- return ip
+ ct = current_task()
+ getaddrinfo(host) do IP
+ yieldto(ct,IP)
+ ct.runnable = true
+ end
+ ct.runnable = false
+ ip = yield()
+ yieldto(Scheduler)
+ return ip
end
##
-
function connect(cb::Function, sock::TcpSocket, host::IPv4, port::Uint16)
- sock.ccb = cb
- uv_error("connect",ccall(:jl_tcp4_connect,Int32,(Ptr{Void},Uint32,Uint16),
- sock.handle,host.host,hton(port)) != -1)
+ sock.ccb = cb
+ uv_error("connect",ccall(:jl_tcp4_connect,Int32,(Ptr{Void},Uint32,Uint16),
+ sock.handle,host.host,hton(port)) != -1)
end
function connect(sock::TcpSocket, host::IPv4, port::Uint16)
- uv_error("connect",ccall(:jl_tcp4_connect,Int32,(Ptr{Void},Uint32,Uint16),
- sock.handle,host.host,hton(port)) != -1)
- wait_connected(sock)
+ uv_error("connect",ccall(:jl_tcp4_connect,Int32,(Ptr{Void},Uint32,Uint16),
+ sock.handle,host.host,hton(port)) != -1)
+ wait_connected(sock)
end
-
for (args,forward_args) in ( ((:(addr::InetAddr),), (:(addr.host),:(addr.port)) ),
- ((:(host::IpAddr),:port),(:(InetAddr(host,port)),) ),
- ((:(addr::InetAddr),), (:(addr.host),:(addr.port)))
- )
- @eval begin
- connect(sock::Socket,$(args...)) = connect(sock,$(forward_args...))
- connect(cb::Function,sock::Socket,$(args...)) =
- connect(cb,sock,$(forward_args...))
- function connect($(args...))
- sock = TcpSocket()
- connect(sock,$(forward_args...))
- sock
- end
- function connect(cb::Function,$(args...))
- sock = TcpSocket()
- connect(cb,sock,$(forward_args...))
- sock
- end
+ ((:(host::IpAddr),:port),(:(InetAddr(host,port)),) ),
+ ((:(addr::InetAddr),), (:(addr.host),:(addr.port))))
+ @eval begin
+ connect(sock::Socket,$(args...)) = connect(sock,$(forward_args...))
+ connect(cb::Function,sock::Socket,$(args...)) =
+ connect(cb,sock,$(forward_args...))
+ function connect($(args...))
+ sock = TcpSocket()
+ connect(sock,$(forward_args...))
+ sock
+ end
+ function connect(cb::Function,$(args...))
+ sock = TcpSocket()
+ connect(cb,sock,$(forward_args...))
+ sock
end
+ end
end
-
##
-function listen(host::IPv4, port::Uint16)
- sock = TcpSocket()
- uv_error("listen",!bind(sock,host,port))
- listen(sock)
- sock
+function listen(host::IPv4, port::Uint16)
+ sock = TcpSocket()
+ uv_error("listen",!bind(sock,host,port))
+ listen(sock)
+ sock
end
listen(port::Integer) = listen(IPv4(uint32(0)),uint16(port))
listen(addr::InetAddr) = listen(addr.host,addr.port)
@@ -260,9 +257,8 @@ function accept(server::TcpSocket,client::TcpSocket)
err
end
function accept(server::TcpSocket)
- client = TcpSocket()
- uv_error("accept",_jl_tcp_accept(server.handle,client.handle) == -1)
- client.open = true
- client
+ client = TcpSocket()
+ uv_error("accept",_jl_tcp_accept(server.handle,client.handle) == -1)
+ client.open = true
+ client
end
-

0 comments on commit 9135b31

Please sign in to comment.